fix(codex): fork archived sessions without reopening the source (#2231)

* fix(codex): fork archived sessions without reopening the source

* fix(codex): reconcile interrupted archived fork recovery

* fix(codex): release rejected forks and serialize source startup

* fix(codex): fence unconfirmed resume startup across retries

* test(codex): validate durable resume recovery and serialize archive

* fix(codex): block local resume of pending archived fork sources

* fix(hub): coalesce concurrent resume requests to preserve idempotent startup

* fix(hub): bypass startup coalescing for PTY sessions
This commit is contained in:
Ananovo
2026-11-01 09:55:01 +08:00
committed by GitHub
parent 639f71b6a6
commit 46bae9b0f1
30 changed files with 1377 additions and 34 deletions
@@ -29,6 +29,7 @@ vi.mock('@/ui/logger', () => ({
}));
import { CodexAppServerClient, isIndeterminateError } from './codexAppServerClient';
import { killProcessByChildProcess } from '@/utils/process';
function fakeStream(): EventEmitter & { setEncoding: ReturnType<typeof vi.fn> } {
return Object.assign(new EventEmitter(), { setEncoding: vi.fn() });
@@ -36,6 +37,8 @@ function fakeStream(): EventEmitter & { setEncoding: ReturnType<typeof vi.fn> }
function fakeChild() {
return Object.assign(new EventEmitter(), {
exitCode: null as number | null,
signalCode: null as string | null,
stdin: Object.assign(new EventEmitter(), {
end: vi.fn(),
write: vi.fn(),
@@ -60,6 +63,33 @@ describe('CodexAppServerClient process cwd', () => {
beforeEach(() => {
execFileSyncMock.mockClear();
spawnMock.mockReset();
vi.mocked(killProcessByChildProcess).mockClear();
});
it('lets a completed read/fork helper exit on stdin EOF without process-tree probing', async () => {
const child = fakeChild();
child.stdin.end.mockImplementation(() => { child.exitCode = 0; child.emit('exit', 0, null); });
spawnMock.mockReturnValue(child);
const client = new CodexAppServerClient();
await client.connect();
await client.disconnect({ gracefulTimeoutMs: 100 });
expect(child.stdin.end).toHaveBeenCalledTimes(1);
expect(killProcessByChildProcess).not.toHaveBeenCalled();
expect(client.isConnected()).toBe(false);
});
it('falls back to exact child cleanup if graceful helper shutdown does not finish', async () => {
vi.useFakeTimers();
try {
const child = fakeChild();
spawnMock.mockReturnValue(child);
const client = new CodexAppServerClient();
await client.connect();
const closing = client.disconnect({ gracefulTimeoutMs: 100 });
await vi.advanceTimersByTimeAsync(100);
await closing;
expect(killProcessByChildProcess).toHaveBeenCalledWith(child);
} finally { vi.useRealTimers(); }
});
it('passes an explicit neutral cwd to the app-server process', async () => {