fix: persist elapsed timer across session switches#484
Merged
op7418 merged 2 commits intoop7418:mainfrom Apr 15, 2026
Merged
Conversation
**问题** 切换 Session 后,`StreamingMessage` 底部的计时器会从 0 重新开始计数。根因是 `ElapsedTimer` 组件在 mount 时用 `Date.now()` 本地初始化开始时间,Session 切换导致组件 remount 后时间重置。 **修复** - `stream-session-manager` 的 `SessionStreamSnapshot` 已包含 `startedAt` 字段,记录流的真实开始时间 - 将 `startedAt` 从 `ChatView` → `MessageList` → `StreamingMessage` → `StreamingStatusBar` → `ElapsedTimer` 逐级透传 - `ElapsedTimer` 改为基于传入的 `startedAt` 计算 elapsed,组件 remount 后仍能恢复真实累计时长 **影响范围** 仅影响流式响应状态下的底部计时器显示,不改变任何持久化逻辑或计时行为。 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@KevinYoung-Kw is attempting to deploy a commit to the op7418's projects Team on Vercel. A member of the Team first needs to authorize it. |
Owner
|
已合并 🎉 根因定位 + 修法都很干净(把本来就存在的 startedAt 透传到底层就够了,不用改数据模型)。只有一个小 nit:MessageList.tsx 里 感谢贡献,下次发版带上。 |
op7418
added a commit
that referenced
this pull request
Apr 15, 2026
Fixes: - cc-switch 切换 provider 被默默改路由 (#461/#478/#476/#457/#470/#474) - OpenAI OAuth 403/网络失败自动重试 (#464) - Electron 端口稳定化修复 localStorage 配置全丢 (#465/#466/#477) - v0.49.0+ 长对话 AI_MissingToolResultsError 回归 - Turbopack CJS↔ESM interop 导致 streamClaudeSdk is not a function - 内置 MCP 自动批准 (Memory/Widget/Notify 等 7 个) - Claude Code executable not found on Windows (SDK bundle 修复) - 切换会话后计时器归零 (#480/#484) - 选 slash 命令清空已输入文本 (#479/#486) - Skills 弹窗误触发路径 + 多选 + badge 去描述 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CodePilot 版本: v0.50.1
问题描述
在侧边栏切换 Session 后再切回来,底部流式回复的计时器会从
0s重新开始计数。期望它应该基于真实的流累计时长展示,不因切换而重置。根因
ElapsedTimer在StreamingMessage.tsx里 mount 时用本地Date.now()记录开始时间。切换 Session 导致ChatView(连带StreamingMessage)unmount/remount,计时器就归零了。修复
stream-session-manager的SessionStreamSnapshot已包含startedAt字段,记录流的真实开始时间。现在把它从组件树顶层一路透传到底层:ChatView→MessageList→StreamingMessage→StreamingStatusBar→ElapsedTimerElapsedTimer改为基于传入的startedAt计算 elapsed,组件 remount 后仍能恢复正确的累计时长。改动文件
src/components/chat/ChatView.tsxstreamSnapshot.startedAt传给MessageListsrc/components/chat/MessageList.tsxstartedAtprop 并透传给StreamingMessagesrc/components/chat/StreamingMessage.tsxStreamingStatusBar/ElapsedTimer接收startedAt并基于它计算验证方式
npm run test通过(typecheck + 单元测试)