Repository navigation
fix(wework): correct processing duration timer and header interactivity - #1329
Conversation
Fixes three issues with the "已处理 Xs 时间了" turn-duration display: 1. Timer froze during pure-thinking phases. getDuration now counts against the live clock while the turn isRunning instead of locking to the last block timestamp, so the elapsed time advances every second even when there is no new tool output. 2. A completed turn showed "已处理 0s 时间了" after a page refresh. The backend add_block fallback stamped blocks with the event loop's monotonic clock (a small non-epoch value the client rejects as invalid), collapsing the rendered duration to 0s. It now uses wall-clock epoch milliseconds (time.time). 3. Hovering the running header showed a not-allowed cursor because it was a disabled button. While running it now renders as plain, non-interactive text; the collapsible button only appears once the turn finishes. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughBackend now generates block IDs and timestamps using wall-clock epoch milliseconds; frontend anchors turn start and computes live durations using an explicit isRunning flag, updating UI rendering and adding tests for ticking, anchoring after refresh, and non-interactive running state. ChangesDuration Timer Fix: Wall-Clock Timestamps and Live Display
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…resh
When a page is refreshed mid-turn, the in-progress blocks live only in
Redis and are not yet persisted to subtask.result, so the DB-restored
turn starts with empty blocks and the resumed stream re-creates thinking
blocks with fresh client timestamps. Anchoring the elapsed time to the
first block therefore restarted the timer from the refresh moment
("已处理 2s 时间了").
Anchor the duration to the assistant subtask's created_at (passed via a
new startedAt prop), which is restored from the backend and preserved by
assistant_started across the reconnect. The timer now reflects the true
elapsed time after a refresh, both while running and once completed.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Resolve conflict in ToolBlocksDisplay: combine the refresh-surviving duration anchor (startedAt prop -> turnStartedAt) and non-interactive running header from this branch with main's improved Chinese duration copy (getDurationText + formatDuration). Reconcile the merged tests to the unified behavior.
Summary
Fixes three issues with the chat "已处理 Xs 时间了" turn-duration display:
getDurationnow counts against the live clock while the turnisRunninginstead of locking to the last block timestamp, so the elapsed time advances every second even when there is no new tool output.add_blockfallback stamped blocks with the event loop's monotonic clock — a small non-epoch value the client rejects as invalid (getBlockTimestamprequires> 1e12), collapsing the rendered duration to 0s. It now uses wall-clock epoch milliseconds (time.time).disabledbutton. While running it now renders as plain, non-interactive text; the collapsible button only appears once the turn finishes.Changes
wework/src/components/chat/blocks/ToolBlocksDisplay.tsx— live-clock duration while running; plain text vs. button header.backend/app/services/chat/storage/session.py—add_blockusestime.time()for both the generatedidandtimestampfallback.ToolBlocksDisplay.test.tsxandtest_session_blocks.py.Test plan
ToolBlocksDisplaytests pass (live tick while streaming with all blocks done; header renders as plain text while running)tsc --noEmit, eslint cleanblack --check/isort --check-onlyclean on changed filestest_add_block_fills_wall_clock_epoch_timestampregression test (runs in CI; local run blocked by network/env)🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes
Tests