Skip to content

Fix reasoning section elapsed timers#4629

Open
KyleAMathews wants to merge 2 commits into
mainfrom
horton/fix-thought-duration
Open

Fix reasoning section elapsed timers#4629
KyleAMathews wants to merge 2 commits into
mainfrom
horton/fix-thought-duration

Conversation

@KyleAMathews

Copy link
Copy Markdown
Contributor

Fix reasoning-section elapsed timers so each thinking block measures from when that block starts, not from the beginning of the run. This prevents later “Thought for …” sections in long tool-using runs from showing inflated durations that grow across the whole run.

Root Cause

ReasoningBlock received the parent run timestamp and used it for both the live elapsed timer and the final collapsed Thought for … label. In multi-step runs, later reasoning rows can start well after the run begins — for example after a tool call returns — so anchoring every row to the run start made each new reasoning section inherit all prior run time.

Approach

  • Make ReasoningBlock own its timing anchor locally.
  • Capture the first render where that reasoning row is live.
  • Use that captured timestamp for the live ElapsedTime display.
  • Snapshot the final duration when the row transitions from streaming to completed.
  • Remove the misleading parent timestamp prop from the reasoning block API.

Rows that mount already completed still render as bare Thought, because the UI does not know their true start/end duration.

Key Invariants

  • A reasoning block’s elapsed time is scoped to that block, not the whole run.
  • Later reasoning blocks must not inherit time spent in previous thinking, text, or tool-call sections.
  • Historical/completed reasoning rows should not invent durations from incomplete client-side timing data.
  • The parent response timestamp remains available for response-level metadata, but not for per-reasoning timing.

Non-goals

  • This does not persist reasoning start/end timestamps in the backend schema.
  • This does not change response-level ✓ done in … timing.
  • This does not alter reasoning ordering, markdown rendering, or redacted reasoning behavior.

Trade-offs

This uses the client-observed first-live-render time rather than a persisted provider/server timestamp. That is intentionally scoped: it fixes the live UI inflation bug without adding schema or event-model changes. Historical rows still avoid showing made-up durations.

Verification

cd packages/agents-server-ui
pnpm test src/components/ReasoningSection.test.tsx
pnpm typecheck

Also validated changeset coverage:

GITHUB_BASE_REF=main node scripts/check-changeset.mjs

Files changed

  • .changeset/fix-reasoning-timers.md

    • Adds a patch changeset for @electric-ax/agents-server-ui.
  • packages/agents-server-ui/src/components/AgentResponse.tsx

    • Stops passing the parent run timestamp into ReasoningBlock.
  • packages/agents-server-ui/src/components/ReasoningSection.tsx

    • Captures per-reasoning-row live start time.
    • Uses that local start time for live and settled reasoning duration labels.
    • Removes the timestamp prop from ReasoningBlock.
  • packages/agents-server-ui/src/components/ReasoningSection.test.tsx

    • Adds regression coverage proving live reasoning timers do not start from the run timestamp.
    • Adds client-rendered coverage for the live → completed transition producing Thought for Ns.

@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Electric Agents Desktop Builds

Build artifacts for commit 9eb8e69.

Platform Status Artifact
macOS Apple Silicon Passed DMG
macOS Intel Passed DMG
Windows x64 Passed Installer
Linux x64 Passed AppImage / deb

Workflow run

@github-actions

Copy link
Copy Markdown
Contributor

Electric Agents Mobile Build

Local mobile checks ran for commit 9eb8e69.

The EAS Android preview build was skipped because the mobile-eas-build label is not present.
Add the mobile-eas-build label to this PR to produce an installable preview build.

Workflow run

@codecov

codecov Bot commented Jun 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 35.27%. Comparing base (6587781) to head (9eb8e69).
⚠️ Report is 2 commits behind head on main.
✅ All tests successful. No failed tests found.

❗ There is a different number of reports uploaded between BASE (6587781) and HEAD (9eb8e69). Click for more details.

HEAD has 27 uploads less than BASE
Flag BASE (6587781) HEAD (9eb8e69)
unit-tests 12 3
packages/y-electric 1 0
typescript 12 3
packages/start 1 0
packages/agents-mcp 1 0
packages/agents 1 0
packages/electric-ax 1 0
packages/experimental 1 0
packages/react-hooks 1 0
packages/typescript-client 1 0
packages/agents-runtime 1 0
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #4629       +/-   ##
===========================================
- Coverage   59.24%   35.27%   -23.97%     
===========================================
  Files         385      233      -152     
  Lines       42734    19900    -22834     
  Branches    12273     7112     -5161     
===========================================
- Hits        25316     7020    -18296     
+ Misses      17343    12844     -4499     
+ Partials       75       36       -39     
Flag Coverage Δ
packages/agents ?
packages/agents-mcp ?
packages/agents-mobile 80.67% <ø> (ø)
packages/agents-runtime ?
packages/agents-server 75.47% <ø> (+0.21%) ⬆️
packages/agents-server-ui 8.34% <100.00%> (+0.82%) ⬆️
packages/electric-ax ?
packages/experimental ?
packages/react-hooks ?
packages/start ?
packages/typescript-client ?
packages/y-electric ?
typescript 35.27% <100.00%> (-23.97%) ⬇️
unit-tests 35.27% <100.00%> (-23.97%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant