Skip to content

fix(mobile-web): stamp assistant messages with the turn completion time - #3811

Merged
bobleer merged 1 commit into
openBitFun:mainfrom
bobleer:fix/mobile-agent-message-timestamp
Nov 8, 2026
Merged

bobleer merged 1 commit into
openBitFun:mainfrom
bobleer:fix/mobile-agent-message-timestamp

Conversation

@bobleer

@bobleer bobleer commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator

问题

mobile-web 里 AI 消息下的时间戳显示的是用户按下发送的时刻,不是回答完成的时刻。一轮跑了几分钟工具的话,时间戳会停在开头,看起来就像 agent 秒回。

根因

SessionEventReducer 在 agentic://dialog-turn-started 时记录 Date.now()(秒),然后:

  • dialog-turn-completed/cancelled/failed 构造 assistant 消息时复用了同一个 this.timestamp
  • 历史回放(SessionRecordPresentation)用 turn.timestamp(轮次开始时间)

host 侧 DialogTurnData 其实有 end_time(毫秒,轮次结束时写入)和 duration_ms,只是 mobile-web 没读。

改动

  • 实时流:assistant 消息改用轮次关闭时的时间
  • 历史回放:优先 endTime,缺字段时退回 turn.timestamp(老记录兼容)

用户消息时间戳保持不动。没有按 timestamp 排序的代码,isOldResponse 用的是 index,顺序不受影响。

验证

pnpm --dir src/mobile-web run type-check 通过(tsc + vite build)。

The reducer captured `Date.now()` on `dialog-turn-started` and reused it for
the assistant message, so a turn that ran tools for minutes showed the moment
the user pressed send instead of when the answer landed.

Record the completion time when the turn closes. Replayed turns now prefer the
host's `endTime` and fall back to the turn timestamp for records written
before that field existed.
@bobleer
bobleer merged commit dc3d2ac into openBitFun:main Nov 8, 2026
9 checks passed
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