From 7d5f6127010d0b2171cef8f31f658ca2cc649b49 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 31 Jan 2026 12:52:13 +0000 Subject: [PATCH] fix: correct canResume logic to avoid showing spurious Resume button - Initialize finishReason to "stop" in new sessions (was undefined) - Fix canResume to only be true when there's actually something to resume: - tool_calls: model called tools, waiting for results - length: response was truncated - null with streamingContent: user aborted mid-stream Previously, undefined finishReason passed the check (undefined !== "stop") causing Resume button to appear on fresh conversations. https://claude.ai/code/session_01HqtD9R33oqfB14Gu1V5wHC --- src/hooks/useChatSession.ts | 10 +++++++--- src/services/llm/session-manager.ts | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/hooks/useChatSession.ts b/src/hooks/useChatSession.ts index 4115cbc..72c54cf 100644 --- a/src/hooks/useChatSession.ts +++ b/src/hooks/useChatSession.ts @@ -106,12 +106,16 @@ export function useChatSession( usage: session?.usage, cost: session?.sessionCost ?? 0, - // Resume state + // Resume state - only show resume when there's actually something to continue + // tool_calls: model called tools, waiting for results + // length: response was truncated + // null: user aborted mid-stream (only if there's partial content) canResume: Boolean( session && !session.isLoading && - session.finishReason !== "stop" && - session.finishReason !== "error", + (session.finishReason === "tool_calls" || + session.finishReason === "length" || + (session.finishReason === null && session.streamingContent)), ), finishReason: session?.finishReason, }), diff --git a/src/services/llm/session-manager.ts b/src/services/llm/session-manager.ts index 6c59ab8..6e4aa68 100644 --- a/src/services/llm/session-manager.ts +++ b/src/services/llm/session-manager.ts @@ -116,6 +116,7 @@ class ChatSessionManager { sessionCost: 0, subscriberCount: 1, lastActivity: Date.now(), + finishReason: "stop", // Nothing to resume initially }; this.updateSession(conversationId, session);