Repository navigation
test: cover the remaining user operations in the e2e cache topic - #5578
Conversation
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0de999293f
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Add an openSession action that returns to an earlier session the way a user does on each surface: the /sessions picker in the terminal UI, the sidebar in Desktop and Web, and session/list plus session/load from an ACP editor. Sessions are found by their title, which is the first prompt of the session when the product cannot generate titles. The new cache scenario starts a second session, goes back to the first one and checks that the next request extends the first session's last request under the same prompt cache key, while the second session uses a key of its own. Catalog entry A2 now lists it as explicit coverage.
Add the reload, init and useSkill actions to the E2E drivers, with a self-test for each, and cover catalog entries B8, E6 and C4 with cache scenarios that check the main requests continue one another while the system prompt and the tool list stay the same.
…ache scenarios Add switchModel and setThinkingEffort to every e2e surface with self-tests, cover B3 (switching to another model and back keeps the first model's prefix) and B4 (changing the thinking effort breaks only the model settings) in the prompt cache catalog.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b66c741122
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…ments, browser control and plugins Goal mode, /add-dir, /experiments, turning the Desktop browser control off and enabling a plugin all keep the request prefix: the system prompt and the tool list stay as the session started, and the change reaches the model in reminders. Record the promises as keeps and say what each entry still needs.
…ode, experiments and plugins Add two E2E actions with self-tests: addDir on the TUI, which adds a workspace directory for this session with /add-dir, and setBrowserControl on Desktop, which switches agent control of the built-in browser in the Browser settings. Two cache scenarios use them to show that the system prompt, the tool list and the prompt cache prefix stay the same while the change reaches the model in a reminder. The KAP prompt cache scenarios now also start a goal between two turns, turn an experimental feature off and reload the session, and enable a plugin, and the catalog lists all five entries as covered.
Add a setPlanMode action on every surface and a btw action on the terminal UI, Desktop and Web, each with positive and negative self-tests. ACP has no side question: the agent answers /btw with "Unknown ACP command". Two cache scenarios use them. Turning plan mode on and off between turns reaches the model as reminders while system and tools stay the same, and the main requests continue one prefix. A /btw side question leaves the main history alone, and its request reuses the whole prefix of the last main request before it. Catalog entries B2 and D9 now list these scenarios instead of a gap.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b8a32a7251
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…eep workspace snapshots out of .git - TUI: after /sessions the CLI stops drawing the activity area, so the replayed last entry and the resume notice sit right on top of the input box. The driver now counts that block as transcript instead of status, so expectReply and expectTranscript see the resumed turn. - Desktop and Web: the side chat does not split its conversation into list rows. btw() now finds the question as exact text in the Side Chat tab and the reply as a visible Markdown block outside its input. - snapshotDirectory takes a list of top-level directories to skip, and git workspaces skip .git, so a lock file that git removes mid-snapshot no longer fails the step on Windows.
…ig options on reopening a session - TUI btw(): the side panel has no sign that the side turn finished, so two identical reads were taken as the end. Between two streamed parts the panel holds still, and the driver pressed Esc and cancelled the rest of the answer. It now waits for the requested reply or a failure line, and closes the panel before it throws on a timeout. A new self-test streams the side answer in two parts. - ACP openSession(): keep the configuration options that session/load returns, as the restart path already does. Before, switchModel() in a reopened session read the options of the session it had just left. A new self-test switches back to the first model in an earlier session left on the second one.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c6213cc263
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| await this.switchMode('setPlanMode()', state === 'on' ? PLAN_MODE : (this.modeBeforePlan ?? SESSION_MODES.manual)); | ||
| this.modeBeforePlan = state === 'on' ? current : undefined; |
There was a problem hiding this comment.
Keep the pre-plan permission mode scoped to its session
When two sessions enter plan mode from different permission modes, modeBeforePlan can belong to the session just left rather than the one currently open. For example, enter plan mode in session A from manual, create session B, switch B to yolo and enter plan mode, then reopen A and turn plan mode off. Because openSession() never restores or clears modeBeforePlan, this call switches A to yolo instead of its original manual, silently changing approval behavior in subsequent scenario steps. Store the pre-plan mode per session and restore it when reopening that session, using the documented default only when its previous mode is unknown.
AGENTS.md reference: tests/e2e/AGENTS.md:L113-L113
Useful? React with 👍 / 👎.
Requirement or Bug
这是
tests/e2e/scenarios/cache专题(#5526)的第 3 批,也是最后一批。清单catalog.yaml列出会改变产品发给模型服务的请求的用户操作,开这个 PR 之前还有 16 项写着缺口,多数是因为驱动还没有对应的用户动作:换模型、思考强度、计划模式、/btw、回到旧会话、/reload、技能、/init等。这个 PR 把有价值的都补上:先加用户动作和驱动自测,再写缓存场景。做完之后清单 40 项,只剩 2 项缺口。Bug Reproduction Steps
N/A
Root Cause
N/A
Code Changes
核心思路:每一项都是同一个套路。先用真实的用户操作做这件事,证明它生效了(界面上看得见的效果,或者模型收到的内容),再断言账本里前后主请求的延续关系:承诺「保持」的,一路以上一次主请求为基线、没有断点,system 和工具不变;承诺「有意断开」的,用清单里的原因声明断点,并断言断点只落在该落的那一段。
新增的用户动作(都登记在
support/verbs.ts的VERBS,每个面都有正例和反例自测,tests/e2e/AGENTS.md「写驱动」表里各有一行写明各面怎么做、证据是什么):openSession(标题)/sessions面板;Desktop/Web 点侧栏会话行;ACPsession/list加session/loadswitchModel(名字)、setThinkingEffort(强度)/model、/effort选择器;Desktop/Web 模型菜单;ACPsession/set_config_optionsetPlanMode('on' | 'off')/plan on/off;Desktop/WebAdd菜单里的Plan和Exit mode;ACPsession/set_mode planbtw(问题, 回答)/btw,看到旁路回答后关掉旁路回到主对话。ACP 没有旁路问题reload()/reload。ACP 没有重新加载会话的请求useSkill(名字)/skill:<名字>init()/init。别的面没有这个入口addDir(路径)/add-dirsetBrowserControl('on' | 'off')缓存场景(
scenarios/cache/):going-back-to-an-earlier-session-keeps-its-prefixmanual-compaction-keeps-the-prefix-across-a-restartundo-breaks-only-the-historyplan-mode-keeps-the-prefixswitching-to-another-model-and-back-keeps-the-prefixthinking-effort-change-breaks-only-the-model-settingsparams,历史不变adding-a-workspace-directory-keeps-the-prefix/add-dir只加提醒,system 不重渲染reload-keeps-the-prefix/reload不改前缀skill-keeps-the-prefixturning-the-browser-control-off-and-on-keeps-the-prefixside-question-keeps-the-prefixreusedTokens覆盖上一次主请求),主对话之后照常延续git-branch-switch-keeps-the-prefixinit-keeps-the-prefix/init写出 AGENTS.md 后 system 不变(只在 TUI)KAP 场景(
tests/scenarios/prompt-cache.test.ts):B6 goal 模式、B9 关掉实验特性后重新加载、C7 启用插件、F1 第二个客户端中途订阅并发出下一回合。这几项要么协议层更便宜,要么 E2E 没有办法准备(例如在测试 home 里安装插件)。清单的其他改动:A7 新增一项,压缩请求被服务端拒为太长后去掉最早的消息重试,有意断开历史,覆盖指向 #5538 的两条引擎用例;B6、B7、B9、C5、C7 原来承诺未定,读代码并实测后都定为「保持」,依据写在各自的说明里。
测试基建:
git和workspace.git(参数):把工作区做成 git 仓库,像用户在自己的终端里那样跑 git。testkit 的createGitRepository支持分支,新增runGit;测试仓库设了core.autocrlf=false,检出的文件和提交时一字不差,不随机器的 git 配置变(Windows 的 CI 机器默认会把换行换成 CRLF)。工作区快照不计.git/。support/scenario.ts改成按会话记录「标题和上一条提示词」,openSession()之后restart()等的是当前会话的上一条提示词。收尾检查「主请求的缓存键个数 ≤ 1 +newSession()次数」不变:回到旧会话不算新会话。setPermissionMode和setPlanMode共用同一个切模式的实现,setPermissionMode的行为不变。阅读顺序:
tests/e2e/scenarios/cache/catalog.yaml:每项的承诺、覆盖和依据;tests/e2e/AGENTS.md「写驱动」表里新增的几行;switching-to-another-model-and-back-keeps-the-prefix和thinking-effort-change-breaks-only-the-model-settings;surfaces/tui.ts、surfaces/acp.ts、surfaces/renderer.ts)和self-test/下的新自测。可以略读:
STEP_TITLES的中文步骤标题、page-driver.ts的转发。Behavior Changes and Affected Users
没有改产品代码,产品行为不变。测试一侧:
createGitRepository建的仓库core.autocrlf=false,文件原样检出createGitWorktree等),Windows 上原来可能拿到 CRLFnewSession()再restart()的场景openSession()时和原来一样setPermissionModesession/set_modesetPlanMode共用一个实现setPermissionMode的自测和场景顺带发现的产品问题(都和缓存无关,没在这个 PR 里改):
/reload或/new生效」,但/reload恢复的是存下来的 system,插件的 prompt 进不来,只有新会话才有。建议改文案,不要让/reload重渲染 system,那会破坏缓存。验证:见折叠块。
运行的命令和结果
本地在 macOS 上跑,E2E 全部交给本 PR 的 CI(Linux 和 Windows)。
pnpm lint:通过,e2e-cache-catalog报 40 项、24 个缓存场景都已登记、2 项写明了缺口(C7 的 E2E、E1)。node --test 'scripts/checks/*.test.mjs':124 条通过。pnpm run check:duplication 488dbc119:没有新增重复。pnpm exec tsc -p tests/e2e/tsconfig.json --noEmit、pnpm exec tsc -p tests/scenarios/tsconfig.json --noEmit、pnpm exec tsc -p packages/testkit/tsconfig.json --noEmit:通过。pnpm exec vitest run packages/testkit/test/fixtures.test.ts -t createGit:2 条通过,其中 1 条是新加的分支和runGit。tests/scenarios/prompt-cache.test.ts里新增的 KAP 用例在本地跑过,通过。Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.