fix(subagents): correct duration display showing 5-6x inflated runtime#57739
Conversation
Greptile SummaryThis PR fixes a longstanding display bug where the
Confidence Score: 5/5Safe to merge — the fix is minimal, correct, and all affected call sites are properly updated. No P0 or P1 issues found. The change replaces a clearly broken duplicate function with a re-export of the well-tested canonical implementation, adds No files require special attention.
|
| Filename | Overview |
|---|---|
| src/shared/subagents-format.ts | Buggy duplicate removed; replaced with a one-line re-export of the canonical formatDurationCompact from src/infra/format-time/format-duration.ts. |
| src/agents/subagent-control.ts | Added ?? "n/a" fallback to handle the canonical function's undefined return for invalid/missing runtime values. |
| src/auto-reply/reply/commands-subagents/shared.ts | Added ?? "n/a" fallback at the formatDurationCompact call site, mirroring the change in subagent-control.ts. |
| src/shared/subagents-format.test.ts | Test updated to assert toBeUndefined() for no-arg call, and to lock in 30s / 1m30s regression cases that the old duplicate would have failed. |
Reviews (1): Last reviewed commit: "fix(subagents): correct duration display..." | Re-trigger Greptile
Replace buggy duplicate formatDurationCompact (ms/60000, minutes-only) with re-export of canonical implementation (ms/1000, second-level). Add ?? "n/a" fallback at two call sites for undefined return. Closes openclaw#45009 Signed-off-by: samzong <[email protected]>
9a77c51 to
018bbbc
Compare
|
Merged via squash.
Thanks @samzong! |
openclaw#57739) Merged via squash. Prepared head SHA: 018bbbc Co-authored-by: samzong <[email protected]> Co-authored-by: frankekn <[email protected]> Reviewed-by: @frankekn
openclaw#57739) Merged via squash. Prepared head SHA: 018bbbc Co-authored-by: samzong <[email protected]> Co-authored-by: frankekn <[email protected]> Reviewed-by: @frankekn
openclaw#57739) Merged via squash. Prepared head SHA: 018bbbc Co-authored-by: samzong <[email protected]> Co-authored-by: frankekn <[email protected]> Reviewed-by: @frankekn
openclaw#57739) Merged via squash. Prepared head SHA: 018bbbc Co-authored-by: samzong <[email protected]> Co-authored-by: frankekn <[email protected]> Reviewed-by: @frankekn
openclaw#57739) Merged via squash. Prepared head SHA: 018bbbc Co-authored-by: samzong <[email protected]> Co-authored-by: frankekn <[email protected]> Reviewed-by: @frankekn
openclaw#57739) Merged via squash. Prepared head SHA: 018bbbc Co-authored-by: samzong <[email protected]> Co-authored-by: frankekn <[email protected]> Reviewed-by: @frankekn
openclaw#57739) Merged via squash. Prepared head SHA: 018bbbc Co-authored-by: samzong <[email protected]> Co-authored-by: frankekn <[email protected]> Reviewed-by: @frankekn
openclaw#57739) Merged via squash. Prepared head SHA: 018bbbc Co-authored-by: samzong <[email protected]> Co-authored-by: frankekn <[email protected]> Reviewed-by: @frankekn
Summary
/subagents listruntime during active runsformatDurationCompactinsrc/shared/subagents-format.tswith a re-export of the canonical implementation fromsrc/infra/format-time/format-duration.ts; added?? "n/a"fallback at two call sitesChange Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause / Regression History (if applicable)
formatDurationCompactinsrc/shared/subagents-format.tsdivides ms by 60,000 (jumping to minutes) instead of 1,000 (seconds).Math.max(1, Math.round(ms / 60_000))rounds anything under 60s up to "1m".src/infra/format-time/format-duration.tsalready handles second-level granularity correctly with full test coverage.Regression Test Plan (if applicable)
src/shared/subagents-format.test.tsformatDurationCompact(30_000)returns"30s"(not"1m"), andformatDurationCompact(90_000)returns"1m30s"src/infra/format-time/format-time.test.tscovers the canonical implementationUser-visible / Behavior Changes
/subagents listand/subagents infonow show seconds-level granularity (e.g.45sinstead of1m)Diagram (if applicable)
N/A
Security Impact (required)
Repro + Verification
Environment
Steps
/subagents listduring executionExpected
30sActual
1m(before fix)Evidence
formatDurationCompact(30_000)→"1m"formatDurationCompact(30_000)→"30s"Human Verification (required)
subagents-format.test.ts(5/5),subagent-control.test.ts+reply-plumbing.test.ts+format-time.test.ts(104/104 all passed)undefinedinput, sub-second input, boundary values (59s, 60s, 3599s, 3600s)Review Conversations
Compatibility / Migration
Risks and Mitigations
None. The canonical formatter is already used by other callers (
bash-tools.process.ts,sandbox-display.ts,usage-render-*.ts); this change aligns the remaining three callers to the same implementation.Credit: Root cause originally identified by @jackjin1997 in #45009 comments and #45700. This PR corrects the test expectations that were missed in the prior attempt.