Skip to content

test(e2e): check the restored last turn after a restart and start new sessions - #5398

Closed
RealKai42 wants to merge 4 commits into
test/e2e-windowsfrom
test/e2e-session-verbs
Closed

RealKai42 wants to merge 4 commits into
test/e2e-windowsfrom
test/e2e-session-verbs

Conversation

@RealKai42

Copy link
Copy Markdown
Collaborator

Requirement or Bug

迁移旧 Desktop 旅程时,有两类断言新 E2E 表达不了:重启之后查对话里的工具卡和失败卡;以及新建会话(例如「本会话批准过的命令,新会话里要重新问」)。这个 PR 补上这两样,并迁入三个场景。

基于 MoonshotAI/kimi-code#5397(Windows),这个 PR 的 base 是它的分支 test/e2e-windows。

Bug Reproduction Steps

N/A

Root Cause

N/A

Code Changes

核心思路:重启之后,「最近一回合」就是恢复出来的最后一回合,不再禁止读它;新建会话是一个用户动作,四个面都有。

改动 之前 之后
重启后的 expectReply、expectTool、expectError、expectAbsent 下一次发消息之前一律报错,只能用 expectTranscript 读恢复出来的最后一回合(对话里最后一条用户消息之后)
ACP 上恢复出来的回合 无 取 session/load 回放里最后一条用户消息之后;重启前的编辑器和它开的终端都不在了,命令输出从工具调用内容的文字里读,不要求编辑器那一侧的证据;回放里没有「回合失败」,这类场景排除 ACP
新动作 newSession() 无 TUI 输入 /new,证据是新会话提示里的会话 ID 变了;Desktop、Web 点 New Session,证据是对话变空;ACP 发 session/new,要求拿到另一个会话 ID,之后只看新会话的消息

新场景:

场景 面
shell/command-card-survives-restart:成功和失败的命令卡,重启后状态和输出都不变 四个面
errors/continue-a-failed-turn-after-restart:失败的回合重启后仍显示失败,点 Continue 接着做 Desktop、Web(只有它们有 Continue)
approval/new-session-asks-again:本会话批准过的命令,新会话里要重新批准 四个面

关键决策:

决策 选择 没选 理由
重启后读最近一回合 读恢复出来的最后一回合 保留限制、另加一组「查恢复出来的对话」的动作 用户重开产品时看到的就是最后一回合,动作的含义不用分两套
TUI 重启后看不出上一回合失败了 场景先不合入,问题另记 用 except 排除 TUI 产品问题挡住的场景随修复合入,不能用 except 藏起来;Desktop、Web 的这部分由 Continue 那个场景覆盖
ACP 回放里文件工具没有 locations 驱动不替产品补,不写查文件工具卡的重启场景 从 rawInput.path 补 驱动不能替产品掩盖问题;问题另记

阅读指南:

  1. tests/e2e/support/scenario.ts:去掉的限制、newSession 后清掉上一条提示词。
  2. tests/e2e/surfaces/acp.ts 的 turnUpdates、replayedTurn、newSession。
  3. tests/e2e/surfaces/tui.ts 的 newSession,surfaces/renderer.ts 的 newSession。
  4. self-test/restart.spec.ts、self-test/new-session.spec.ts 和三个场景。

Behavior Changes and Affected Users

产品代码没有改动,受影响的是写和跑新 E2E 的人。

Behavior Before After Who relies on the old behavior Escape hatch
重启后、发消息前调用 expectReply 等四个动作 报错 读恢复出来的最后一回合 restart 自测里固定旧行为的反例,已改成「不把更早的回合当成最近一回合」 无
动作表 没有 newSession 四个面都有 无 无

验证结论:四个面的全套在本机 macOS 上通过;两个新动作都做过破坏性检查。

验证细节

本机 macOS arm64,构建产物:

  • 这个 PR 的头上:TUI + ACP 319 条全过(47 条不适用)。
  • 和下一个 PR 叠在一起的头上:Desktop 172 条、Web 178 条全过。
  • newSession 的自测和新场景在四个面上连跑 3 遍都过。

破坏性检查:

改坏 结果
ACP 建了新会话却不切过去 newSession 正例变红:新会话的请求里有旧提问

被产品问题挡住、这次没放进来的场景:「重启后失败的回合仍显示为失败」。Desktop、Web 通过;TUI 上恢复出来的对话只有用户的提问,看不出那一回合失败了。修好时随修复合入。另外 ACP 回放里的文件工具没有 locations(实时的有),编辑器在恢复出来的会话里不知道是哪个文件,所以没写查文件工具卡的重启场景。

评审:只读 agent 没报 P1;改了几条 P2:ACP 丢掉离开的会话晚到的通知、用明确的标志表示「恢复出来的回合」、newSession 后马上重启不再等旧提示词(加了自测)。改的时候引入过一个问题(丢掉的通知没计入已处理,回合结束不了),全套里发现,已修。

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: issue must have a maintainer's /approve).
  • I have added tests that prove my feature works.
  • The behavior-change table above is complete, and every removed behavior or flipped default is named in the changeset and either has an escape hatch or was explicitly approved by a maintainer in this PR.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

@changeset-bot

changeset-bot Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: aa9e35a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-25T11:45:19.668790Z aa9e35a New commits
🔒 Security Review ✅ Completed 2026-11-25T07:38:35.674238Z be9a30e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@pkg-pr-new

pkg-pr-new Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@aa9e35a
npx https://pkg.pr.new/@moonshot-ai/kimi-code@aa9e35a

commit: aa9e35a

@RealKai42
RealKai42 force-pushed the test/e2e-session-verbs branch from be9a30e to 2cd0e58 Compare November 25, 2026 08:41
… sessions

After restart() the latest-turn checks (expectReply, expectTool,
expectError, expectAbsent) now read the last turn restored from before
the restart instead of refusing until the next message. Over ACP that
turn is what session/load replays after the last user message; the
editor and the terminals it ran before the restart are gone, so a
replayed command's output is read from the text of the tool call and no
editor-side evidence is required.

Add a newSession() user action on all four surfaces: /new on the TUI,
the New Session button on Desktop and Web, and session/new over ACP.

New scenarios: a finished command keeps its card, status and output
after a restart (four surfaces); a failed turn still shows as failed
after a restart and continues from there (Desktop, Web); a command
approved for the session asks again in a new session (four surfaces).
- ACP drops late notifications from a session the editor has left, and
  marks a restored conversation explicitly instead of inferring it from
  the absence of a turn.
- expectError over ACP after a restart says that replays carry no
  failures.
- newSession() clears the last prompt, so a restart right after it waits
  only for the product to be ready; a self-test covers it.
- The guide notes that on Desktop and Web an empty conversation cannot
  show whether New Session did anything.
The ACP driver drops notifications from a session the editor has left,
but still compared the kept ones against every notification received,
so a turn in the new session never looked finished once the old session
sent another update.
@RealKai42
RealKai42 force-pushed the test/e2e-session-verbs branch from 2cd0e58 to 3ea142c Compare November 25, 2026 10:41
@RealKai42
RealKai42 added this pull request to stack #5419 November 25, 2026 11:34
@RealKai42

Copy link
Copy Markdown
Collaborator Author

已并入 #5423:叠着的四个 PR 合成一个,避免 squash 合并后每个都要再解一次冲突。改动不变,请在 #5423 继续评审。

@RealKai42 RealKai42 closed this Nov 25, 2026
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.

2 participants