Skip to content

Commit 01bc3ca

Browse files
charlesvienjonathanlab
authored andcommitted
Revert "Dev tool: force invalid sdkSessionId to test error handling"
This reverts commit 6bde65c.
1 parent 1466241 commit 01bc3ca

2 files changed

Lines changed: 16 additions & 77 deletions

File tree

apps/twig/src/main/index.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -271,20 +271,6 @@ function createWindow(): void {
271271
});
272272
},
273273
},
274-
{
275-
label: "Force invalid SDK session on next reconnect",
276-
click: () => {
277-
container
278-
.get<AgentService>(MAIN_TOKENS.AgentService)
279-
.setForceInvalidSdkSessionId(true);
280-
dialog.showMessageBox({
281-
type: "info",
282-
title: "Flag Set",
283-
message:
284-
"Next session reconnect will use an invalid sdkSessionId.\n\nNavigate away and back to a task to trigger the error.",
285-
});
286-
},
287-
},
288274
],
289275
},
290276
],

apps/twig/src/main/services/agent/service.ts

Lines changed: 16 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -232,31 +232,6 @@ export class AgentService extends TypedEventEmitter<AgentServiceEvents> {
232232
return count;
233233
}
234234

235-
/**
236-
* Flag to force invalid sdkSessionId on next reconnect (dev tool for testing error handling).
237-
*/
238-
private forceInvalidSdkSessionId = false;
239-
240-
/**
241-
* Enable forcing an invalid sdkSessionId on the next reconnect.
242-
* This triggers the "No conversation found" error for testing.
243-
*/
244-
public setForceInvalidSdkSessionId(enabled: boolean): void {
245-
this.forceInvalidSdkSessionId = enabled;
246-
log.info("Force invalid sdkSessionId", { enabled });
247-
}
248-
249-
/**
250-
* Check and consume the forceInvalidSdkSessionId flag.
251-
*/
252-
private consumeForceInvalidSdkSessionId(): boolean {
253-
if (this.forceInvalidSdkSessionId) {
254-
this.forceInvalidSdkSessionId = false;
255-
return true;
256-
}
257-
return false;
258-
}
259-
260235
/**
261236
* Respond to a pending permission request from the UI.
262237
* This resolves the promise that the agent is waiting on.
@@ -436,44 +411,22 @@ export class AgentService extends TypedEventEmitter<AgentServiceEvents> {
436411
const mcpServers = this.buildMcpServers(credentials);
437412

438413
if (isReconnect) {
439-
// Dev tool: force invalid sdkSessionId to test error handling
440-
const effectiveSdkSessionId = this.consumeForceInvalidSdkSessionId()
441-
? "00000000-0000-0000-0000-000000000000"
442-
: sdkSessionId;
443-
444-
if (effectiveSdkSessionId !== sdkSessionId) {
445-
log.warn("Using forced invalid sdkSessionId for testing", {
446-
original: sdkSessionId,
447-
forced: effectiveSdkSessionId,
448-
});
449-
}
450-
451-
try {
452-
await connection.extMethod("_posthog/session/resume", {
453-
sessionId: taskRunId,
454-
cwd: repoPath,
455-
mcpServers,
456-
_meta: {
457-
...(logUrl && {
458-
persistence: { taskId, runId: taskRunId, logUrl },
459-
}),
460-
...(effectiveSdkSessionId && {
461-
sdkSessionId: effectiveSdkSessionId,
462-
}),
463-
...(additionalDirectories?.length && {
464-
claudeCode: {
465-
options: { additionalDirectories },
466-
},
467-
}),
468-
},
469-
});
470-
} catch (resumeError) {
471-
log.error("Failed to resume session via extMethod", {
472-
taskRunId,
473-
error: resumeError,
474-
});
475-
throw resumeError;
476-
}
414+
await connection.extMethod("_posthog/session/resume", {
415+
sessionId: taskRunId,
416+
cwd: repoPath,
417+
mcpServers,
418+
_meta: {
419+
...(logUrl && {
420+
persistence: { taskId, runId: taskRunId, logUrl },
421+
}),
422+
...(sdkSessionId && { sdkSessionId }),
423+
...(additionalDirectories?.length && {
424+
claudeCode: {
425+
options: { additionalDirectories },
426+
},
427+
}),
428+
},
429+
});
477430
} else {
478431
await connection.newSession({
479432
cwd: repoPath,

0 commit comments

Comments
 (0)