fix(desktop): retry auto-title when first user message is not yet persisted#5120
Open
HUQIANTAO wants to merge 4 commits into
Open
fix(desktop): retry auto-title when first user message is not yet persisted#5120HUQIANTAO wants to merge 4 commits into
HUQIANTAO wants to merge 4 commits into
Conversation
…sisted When a new topic is created, the auto-title mechanism reads the JSONL session file to extract the first user message as the topic title. If the first snapshot occurs before the user message is written to disk, topicTitleFromSession returns an empty string and the title stays as the default '新的会话' indefinitely — the function never retries. Fix autoTitleTopicFromSession to return a retry flag. When the title extraction fails but the current title is still the default (meaning no title has ever been set), signal the caller to try again on the next snapshot loop iteration instead of giving up permanently. Fixes esengine#5017
c2c768f to
59cb156
Compare
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.
Problem
All session titles remain as the default "新的会话" (New Session) indefinitely. The
.jsonl.metasidecar files have an emptytopic_titlefield, and the auto-title mechanism silently gives up after the first failed attempt.Reproduction (Issue #5017):
Root Cause
The auto-title flow in
desktop/tabs.go:tabSnapshotLoopcallsmaybeAutoTitleTopicafter each successfulctrl.Snapshot()maybeAutoTitleTopiccallsautoTitleTopicFromSessionautoTitleTopicFromSessioncallstopicTitleFromSession(sessionPath)which opens the JSONL file and reads messages until it findsrole: "user"topicTitleFromSessionreturns"""", falsewith no retry signal — the title stays as default foreverThe race condition: the first
Snapshot()can complete before the user's first message is fully written to the JSONL file. The auto-title mechanism reads an empty file, gets no result, and never tries again.Fix
Modify
autoTitleTopicFromSessionto return a retry flag as a third return value. When the title extraction fails but the current title is still the default (meaning no title has ever been successfully set), signal the caller to retry on the next snapshot loop iteration instead of giving up permanently.Changes in
desktop/tabs.go:The caller
maybeAutoTitleTopicnow uses the retry flag:Testing