Skip to content

Commit c5535fd

Browse files
committed
Preserve conversation history during session retry
1 parent 9ffbd2f commit c5535fd

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

apps/twig/src/renderer/features/sessions/service/service.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1218,6 +1218,7 @@ export class SessionService {
12181218

12191219
/**
12201220
* Clear session error and allow retry.
1221+
* Preserves session events so the conversation stays visible during reconnect.
12211222
*/
12221223
async clearSessionError(taskId: string): Promise<void> {
12231224
const session = sessionStoreSetters.getSessionByTaskId(taskId);
@@ -1238,7 +1239,12 @@ export class SessionService {
12381239
});
12391240
}
12401241
this.unsubscribeFromChannel(session.taskRunId);
1241-
sessionStoreSetters.removeSession(session.taskRunId);
1242+
// Clear error state but keep the session and its events so the
1243+
// conversation remains visible while we reconnect.
1244+
sessionStoreSetters.updateSession(session.taskRunId, {
1245+
status: "disconnected",
1246+
errorMessage: undefined,
1247+
});
12421248
}
12431249
// Clear from connecting tasks as well
12441250
this.connectingTasks.delete(taskId);

apps/twig/src/renderer/features/task-detail/components/TaskLogsPanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export function TaskLogsPanel({ taskId, task }: TaskLogsPanelProps) {
5454
const isResumingExistingSession = !!task.latest_run?.id;
5555
const isInitializing =
5656
!session ||
57-
session.status === "connecting" ||
57+
(session.status === "connecting" && events.length === 0) ||
5858
(session.status === "connected" &&
5959
events.length === 0 &&
6060
(isPromptPending ||

0 commit comments

Comments
 (0)