fix(chat): title a chat after its first successful turn, not only the first submit - #530
Merged
Merged
Conversation
… first submit Auto-titling hung off the first submit's success. When that first turn errored the rename never ran, and retry, regenerate and edit never titled the chat either. The file kept its "New Chat" name while no longer being empty (the failed run still checkpoints the user message), so every later new chat was deduped to "New Chat (2)", "(3)", ... Now any turn that succeeds while the thread still carries the placeholder name titles it from the conversation's opening message. The placeholder name and its matcher move to utils/chatTitle.ts so creation, empty-chat reuse and titling share one definition. Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
|
…est the retry path Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
A first turn that errors still checkpoints the user message, so the chat no longer counts as empty and can't be reused, yet it kept the "New Chat" name, pushing every later new chat to "New Chat (2)", "(3)", ... Rename it to "New Chat (failed)" on error so the next new chat is plain "New Chat". A later successful turn still titles it: needsChatTitle covers the failed variants, while isDefaultChatTitle stays the reusable-placeholder check. Stopping a turn is not a failure and leaves the name alone. Co-Authored-By: Claude <noreply@anthropic.com>
A run that fails before checkpointing (e.g. no chat model configured) leaves the chat empty, and an empty "New Chat" is reused by the next new chat. Renaming it to "New Chat (failed)" would strand an empty file, so markThreadFailed skips threads with no checkpoints. Co-Authored-By: Claude <noreply@anthropic.com>
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.
What
If the first turn of a new chat errored, the chat was never titled: titling only ran after the first submit succeeded, and retry, regenerate and edit never titled it. The file kept its
New Chatname but was no longer empty (the failed run still checkpoints the user message), socreateNewChatcouldn't reuse it and every later new chat got numberedNew Chat (2),(3), and so on.When a turn fails on a chat still named
New Chat(orNew Chat (N)), the file is renamed toNew Chat (failed)(deduped asNew Chat (failed) (2)), so the next new chat is plainNew Chatagain. Stopping a turn yourself is not treated as a failure.Any turn that succeeds while the thread has never been titled (
New Chat,New Chat (N), or aNew Chat (failed)variant) titles it from the conversation's opening message. This covers retry, regenerate and edit, and fixes existing stuck chats on their next successful turn. The placeholder name and its matcher now live insrc/utils/chatTitle.ts, so chat creation, empty-chat reuse and titling share one definition.Trade-off: if title generation itself keeps returning nothing, it's retried on each later successful turn while the name is still the placeholder. Before, it was tried once and never again.
How I tested it
bun run check,format,lintand the fullbun run test(1996 tests) pass. Newtest/stores/chatSessionAutoTitle.test.tscovers: a placeholder chat gets titled on a successful run (the retry-after-error case), aNew Chat (3)also gets titled, an already-titled chat is left alone, a failed turn doesn't title, a failed placeholder moves toNew Chat (failed)(not when stopped, not twice, not for titled chats, and a throwing rename keeps the error visible), plus the matcher cases. Not yet verified in a live vault; the dev build is ready in slot wt3 (S2B WT3) for Leo's live test.AI assistance: Claude Code (Opus) diagnosed the bug and wrote the fix and tests from Leo's report that an errored first message skips titling, plus Leo's follow-up to rename failed chats to
New Chat (failed); Leo reviews and live-tests before merging.Checklist
bun run check,bun run format,bun run lint, andbun run testpass locallymanifest.json: I noted that the docs site needs updating (see "Documentation" in CONTRIBUTING.md)