✂️ fix: Trim Reasoning Tags from Titles and Delete Button Visibility #10285
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.
Summary
Fixes #10284
This PR fixes a bug where LLM reasoning tags (e.g.,
<think>...) are incorrectly saved as chat titles, particularly when using models likeqwen3:8bon Ollama. This pollutes the database and causes a UI bug where the "Delete Conversation" modal overflows, hiding the "Delete" button.This fix is in two parts:
sanitizeTitleutility is added topackages/apito strip all<think>...</think>blocks from new titles before they are saved. This is integrated into theapi/server/controllers/agents/client.jscontroller.client/src/components/Conversations/ConvoOptions/DeleteButton.tsx) is updated withtruncate w-full. This defensively handles any existing malformed titles already in the database, preventing the UI overflow.Change Type
Testing
I performed both automated and manual testing for this two-part fix.
Backend Testing (Automated):
packages/api/src/utils/sanitizeTitle.ts.packages/api/src/utils/sanitizeTitle.spec.tswith 34 new unit tests covering all edge cases (stripping, case-insensitivity, attributes, fallbacks, etc.).api/server/controllers/agents/client.jswith 2 new integration tests to verify thesanitizeTitlefunction is correctly called.Frontend Testing (Automated & Manual):
qwen3:8bmodel.<think>tags.<think>...).This will delete <think>...), and the "Delete" button was visible and clickable.Test Configuration:
qwen3:8b(to reproduce the bug)Checklist
sanitizeTitle)