合并master最新会话隔离修复

同步后台轮询环境下的会话隔离断言与异步测试约定
This commit is contained in:
2026-09-16 02:17:41 +08:00
2 changed files with 7 additions and 2 deletions
@@ -649,17 +649,21 @@ export function registerDeveloperAgentWindowTests() {
sourceSessionId: createdSessionId,
title: '',
});
const refreshCallStart = invoke.mock.calls.length;
fireEvent.click(screen.getByRole('button', { name: '刷新状态' }));
expect(await screen.findByText('只属于新会话的问题')).not.toBeNull();
await waitFor(() => {
expect(invoke).toHaveBeenLastCalledWith(
const runtimeReads = invoke.mock.calls
.slice(refreshCallStart)
.filter(([command]) => command === 'read_game_creator_agent_runtime');
expect(runtimeReads.at(-1)).toEqual([
'read_game_creator_agent_runtime',
{
projectPath: '/tmp/authorized-game',
agentId: 'design-director',
sessionId: archivedForkedSessionId,
},
);
]);
});
});
@@ -5615,3 +5615,4 @@ Cocos Creator 根目录由 `package.json.creator.version` 与普通 `assets/`
- 在 hook 内运行临时仓库测试时,`cwd` 不会覆盖继承的 `GIT_DIR``GIT_WORK_TREE``GIT_INDEX_FILE`。未隔离的 Git/lint-staged 子进程可能向真实仓库提交 fixture,甚至把测试版 ESLint、Prettier 配置带入主分支。
- fixture 子进程统一清除 `GIT_*` 环境,并用一次性外层 linked worktree 验证引用、索引、配置不变;原有工程检查规则保持完整,不能用逐项关闭规则修复 fixture 污染。
- Vitest 的 `toHaveBeenCalledWith` 匹配任意一次调用,失败输出会列出其它命令;应先定位相同命令的真实参数差异,不能由其它调用的序号推断时序故障。
- 存在后台轮询的 IPC mock 不应要求目标命令占据全局最后一次调用。验证刷新时先记录调用边界,再筛选该边界之后的目标命令,严格核对其最后一次参数,避免后台查询影响断言,也避免旧调用掩盖刷新未执行。