Skip to content

fix(chat): title a chat after its first successful turn, not only the first submit - #530

Merged
Leo310 merged 5 commits into
mainfrom
fix/title-after-error-retry
Sep 27, 2026
Merged

Leo310 merged 5 commits into
mainfrom
fix/title-after-error-retry

Conversation

@Leo310

@Leo310 Leo310 commented Sep 27, 2026 •

Copy link
Copy Markdown
Member

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 Chat name but was no longer empty (the failed run still checkpoints the user message), so createNewChat couldn't reuse it and every later new chat got numbered New Chat (2), (3), and so on.

When a turn fails on a chat still named New Chat (or New Chat (N)), the file is renamed to New Chat (failed) (deduped as New Chat (failed) (2)), so the next new chat is plain New Chat again. 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 a New 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 in src/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, lint and the full bun run test (1996 tests) pass. New test/stores/chatSessionAutoTitle.test.ts covers: a placeholder chat gets titled on a successful run (the retry-after-error case), a New Chat (3) also gets titled, an already-titled chat is left alone, a failed turn doesn't title, a failed placeholder moves to New 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, and bun run test pass locally
  • I tried the change in a real Obsidian vault (or explained above why that isn't applicable)
  • I read CONTRIBUTING.md, including the section on AI assistance
  • If this adds a provider, a bundled skill, a built-in tool, or changes manifest.json: I noted that the docs site needs updating (see "Documentation" in CONTRIBUTING.md)

… 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>
@greptile-apps

greptile-apps Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Changes when and how chats get auto-titled after messages.

The PR appears safe to merge based on the reviewed changes.

Summary

The PR titles placeholder chats after a successful turn, including recovery turns, and renames checkpointed chats after a failed turn while leaving empty chats reusable.

  • Adds a shared definition of placeholder titles and tests for failure, retry, and naming behavior.

Reviews (4) · Last reviewed commit: "fix(chat): only mark a failed chat once ..."

Comment thread src/stores/chatStore.svelte.ts Outdated
Comment thread src/stores/chatStore.svelte.ts Outdated
Comment thread test/stores/chatSessionAutoTitle.test.ts Outdated
Leo310 and others added 2 commits September 27, 2026 17:17
…est the retry path

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Comment thread src/stores/chatStore.svelte.ts
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>
Comment thread src/stores/chatStore.svelte.ts
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>
@Leo310
Leo310 merged commit 71d324a into main Sep 27, 2026
3 checks passed
@Leo310
Leo310 deleted the fix/title-after-error-retry branch September 27, 2026 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant