Commit d1c5552
fix: use last resumed event timestamp for 'running for' calculation (#328)
## Summary
When a sandbox has been paused and then resumed, the "running for" field
in the sandbox details header was incorrectly calculating duration from
the creation timestamp. This meant it included the paused time in the
displayed duration.
This fix looks up the last `sandbox.lifecycle.resumed` event from the
lifecycle events array and uses its timestamp as the start for the
"running for" calculation. If no resumed event exists (sandbox was never
paused), it falls back to the original `createdAt` timestamp.
## Review & Testing Checklist for Human
- [ ] Open a sandbox that has been paused and then resumed — verify the
"running for" field shows time since last resume, not since creation
- [ ] Open a sandbox that has never been paused — verify "running for"
still shows time since creation (no regression)
- [ ] Open a killed sandbox that was previously paused/resumed — verify
"ran for" shows duration from last resume to kill time
### Notes
The change is isolated to
`src/features/dashboard/sandbox/header/ran-for.tsx`. The events array
used is the same one already available in the sandbox lifecycle context
and used by the monitoring charts.
Link to Devin session:
https://app.devin.ai/sessions/ff633b5c68c846719d63d51498cedc2d
---------
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: ben@e2b.dev <ben@e2b.dev>1 parent ab740ed commit d1c5552
1 file changed
Lines changed: 17 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
13 | 26 | | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
18 | 31 | | |
19 | 32 | | |
20 | 33 | | |
| |||
0 commit comments