mirror of
https://github.com/purrgrammer/grimoire.git
synced 2026-04-13 08:57:04 +02:00
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:
@@ -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,
|
||||
}),
|
||||
|
||||
@@ -116,6 +116,7 @@ class ChatSessionManager {
|
||||
sessionCost: 0,
|
||||
subscriberCount: 1,
|
||||
lastActivity: Date.now(),
|
||||
finishReason: "stop", // Nothing to resume initially
|
||||
};
|
||||
|
||||
this.updateSession(conversationId, session);
|
||||
|
||||
Reference in New Issue
Block a user