MCPcopy
hub / github.com/slopus/happy / resumeExistingThread

Function resumeExistingThread

packages/happy-cli/src/codex/resumeExistingThread.ts:20–50  ·  view source on GitHub ↗
(opts: {
    client: ResumeThreadClient;
    session: ResumeThreadSession;
    messageBuffer: ResumeThreadMessageBuffer;
    threadId: string;
    cwd: string;
    mcpServers: Record<string, unknown>;
})

Source from the content-addressed store, hash-verified

18};
19
20export async function resumeExistingThread(opts: {
21 client: ResumeThreadClient;
22 session: ResumeThreadSession;
23 messageBuffer: ResumeThreadMessageBuffer;
24 threadId: string;
25 cwd: string;
26 mcpServers: Record<string, unknown>;
27}): Promise<{ threadId: string; model: string }> {
28 try {
29 const resumedThread = await opts.client.resumeThread({
30 threadId: opts.threadId,
31 cwd: opts.cwd,
32 mcpServers: opts.mcpServers,
33 });
34
35 opts.session.updateMetadata((currentMetadata) => ({
36 ...currentMetadata,
37 codexThreadId: resumedThread.threadId,
38 }));
39 opts.messageBuffer.addMessage(`Resumed thread ${trimIdent(resumedThread.threadId)}`, 'status');
40 opts.session.sendSessionEvent({
41 type: 'message',
42 message: `Resumed Codex thread ${resumedThread.threadId}`,
43 });
44
45 return resumedThread;
46 } catch (error) {
47 const reason = error instanceof Error ? error.message : String(error);
48 throw new Error(`Failed to resume Codex thread ${opts.threadId}: ${reason}`);
49 }
50}

Callers 2

runCodexFunction · 0.90

Calls 5

trimIdentFunction · 0.90
resumeThreadMethod · 0.80
updateMetadataMethod · 0.80
addMessageMethod · 0.80
sendSessionEventMethod · 0.80

Tested by

no test coverage detected