fix: prevent stuck disabled message buttons after stop generation (#1508) - #2133
Open
xielixing wants to merge 1 commit into
Open
fix: prevent stuck disabled message buttons after stop generation (#1508)#2133xielixing wants to merge 1 commit into
xielixing wants to merge 1 commit into
Conversation
…vent stuck disabled buttons after stop generation (GCWing#1508)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix: Stuck disabled message buttons after Stop Generation (#1508)
Problem
After clicking "Stop Generation" during an AI response, message action buttons (edit, rollback) become permanently unclickable. The tooltip shows "Session history is not ready yet" (
editDisabledHistoryNotReady). This persists for the entire conversation and only resolves when a new conversation is started.Root Cause
absoluteSessionTurnIndexForIdinflowChatTurnOrdinal.tsreturnsundefinedwhen the turn catalog (validSessionTurnCatalog) is stale or invalid -- which happens after Stop Generation interrupts async session initialization andmarkSessionFinishedcreates a new session object via spread.When
absoluteSessionTurnIndexForIdreturnsundefined,UserMessageItem.tsxcomputesactionTurnIndex = -1, which triggers the!resolvedSessionId || actionTurnIndex < 0condition that disables the edit/rollback buttons with the "history not ready" tooltip.The sibling functions
absoluteSessionTurnIndexForLocalIndexandcreateAbsoluteSessionTurnIndexResolverboth already have alocalIndex + 1fallback for when the ordinal resolver returnsundefined. OnlyabsoluteSessionTurnIndexForIdwas missing this fallback.Fix
Add a local-index fallback to
absoluteSessionTurnIndexForId: whenresolveTurnOrdinalreturnsundefined, find the turn's local index insession.dialogTurnsand delegate toabsoluteSessionTurnIndexForLocalIndex(which has thelocalIndex + 1fallback).This makes all three turn-index resolution functions consistent in their fallback behavior.
Validation
tsc --noEmitonsrc/web-uipasses (no new type errors from this change)Testing
The fix can be verified by:
Fixes #1508