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
This commit is contained in:
Claude
2026-01-31 12:52:13 +00:00
parent 0b37298611
commit 7d5f612701
2 changed files with 8 additions and 3 deletions

View File

@@ -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,
}),

View File

@@ -116,6 +116,7 @@ class ChatSessionManager {
sessionCost: 0,
subscriberCount: 1,
lastActivity: Date.now(),
finishReason: "stop", // Nothing to resume initially
};
this.updateSession(conversationId, session);