fix(codex): restore shared sessions after heartbeat and archive

This commit is contained in:
weishu
2026-09-12 18:29:57 +08:00
parent 4d92afaf36
commit d1f4972079
4 changed files with 36 additions and 14 deletions
+2 -13
View File
@@ -1493,19 +1493,8 @@ export async function startRunner(options: { workspaceRoots?: string[] } = {}):
// Heartbeat
try {
const updatedState: RunnerLocallyPersistedState = {
pid: process.pid,
httpPort: controlPort,
startTime: fileState.startTime,
startedWithCliVersion: packageJson.version,
startedWithCliMtimeMs,
startedWithApiUrl: fileState.startedWithApiUrl,
startedWithMachineId: fileState.startedWithMachineId,
startedWithCliApiTokenHash: fileState.startedWithCliApiTokenHash,
startedWithExtraHeadersHash: fileState.startedWithExtraHeadersHash,
startedWithArgv,
startedWithVersionHandoffDisabled,
lastHeartbeat: new Date().toLocaleString(),
runnerLogPath: fileState.runnerLogPath
...fileState,
lastHeartbeat: new Date().toLocaleString()
};
writeRunnerState(updatedState);
if (process.env.DEBUG) {
+11
View File
@@ -174,6 +174,17 @@ describe.skipIf(!await isServerHealthy())('Runner Integration Tests', { timeout:
expect(sessions).toEqual([]);
});
it('preserves shared Codex support after a runner heartbeat', async () => {
const initial = await readRunnerState();
expect(initial?.sharedCodexRuntime).toBe(true);
await waitFor(async () => Boolean((await readRunnerState())?.lastHeartbeat), 35_000);
const afterHeartbeat = await readRunnerState();
expect(afterHeartbeat?.pid).toBe(initial?.pid);
expect(afterHeartbeat?.sharedCodexRuntime).toBe(true);
}, 40_000);
it('should track session-started webhook from terminal session', async () => {
// Simulate a terminal-started session reporting to runner
const mockMetadata: Metadata = {