mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-08 01:43:07 +00:00
fix(codex): preserve transcript sync across mode switches
This commit is contained in:
@@ -59,6 +59,27 @@ describe('codexSessionScanner', () => {
|
||||
expect(events[0]?.type).toBe('event_msg');
|
||||
});
|
||||
|
||||
it('flushes an appended tail without waiting for the watcher', async () => {
|
||||
await writeFile(
|
||||
transcriptPath,
|
||||
JSON.stringify({ type: 'session_meta', payload: { id: 'session-flush' } }) + '\n'
|
||||
);
|
||||
|
||||
scanner = await createCodexSessionScanner({
|
||||
transcriptPath,
|
||||
onEvent: (event) => events.push(event)
|
||||
});
|
||||
|
||||
await appendFile(
|
||||
transcriptPath,
|
||||
JSON.stringify({ type: 'event_msg', payload: { type: 'agent_message', message: 'final tail' } }) + '\n'
|
||||
);
|
||||
await scanner.flush();
|
||||
|
||||
expect(events).toHaveLength(1);
|
||||
expect(events[0]?.payload).toEqual({ type: 'agent_message', message: 'final tail' });
|
||||
});
|
||||
|
||||
it('reads exactly the requested transcript byte range', async () => {
|
||||
const initial = 'existing transcript\n';
|
||||
const appended = 'new event\n';
|
||||
|
||||
@@ -11,6 +11,7 @@ interface CodexSessionScannerOptions {
|
||||
}
|
||||
|
||||
export interface CodexSessionScanner {
|
||||
flush: () => Promise<void>;
|
||||
cleanup: () => Promise<void>;
|
||||
setTranscriptPath: (transcriptPath: string) => Promise<void>;
|
||||
}
|
||||
@@ -20,6 +21,9 @@ export async function createCodexSessionScanner(opts: CodexSessionScannerOptions
|
||||
await scanner.start();
|
||||
|
||||
return {
|
||||
flush: async () => {
|
||||
await scanner.flush();
|
||||
},
|
||||
cleanup: async () => {
|
||||
await scanner.cleanup();
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user