fix(sessions): stop chat-title regeneration on every view remount#3315
fix(sessions): stop chat-title regeneration on every view remount#3315tatoalo wants to merge 2 commits into
Conversation
Title/summary generation bookkeeping lived in refs inside useChatTitleGenerator, so it reset on every mount: reopening a task whose conversation had 1 or REGENERATE_INTERVAL+ prompts re-fired an LLM gateway call per view switch, and two simultaneously mounted views of the same task could double-fire. Move the bookkeeping into a shared zustand store keyed by task id, and skip catch-up fires entirely when the user has renamed the task and a conversation summary is already stored (both outputs would be unused). Generated-By: PostHog Code Task-Id: 40590239-d05a-487c-9e49-d2209ffa93c7
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
Make the title-lock check lazy so the query-cache scan only runs when a stale first fire is actually being suppressed, collapse the suppression into one condition, drop the no-op prompt-count clamp and the test-only store reset API, and trim comments. Generated-By: PostHog Code Task-Id: 40590239-d05a-487c-9e49-d2209ffa93c7
There was a problem hiding this comment.
Well-targeted bug fix with solid test coverage. Moving from per-mount refs to a shared Zustand store correctly follows the project's architecture conventions, and the new titleLocked/hasSummary logic is simple, well-tested, and backward-compatible. No data, API, or security concerns.
New commits pushed (delta classified non_trivial_delta) — stamphog approval dismissed; re-review running automatically.
|
Reviews (1): Last reviewed commit: "refactor(sessions): simplify title-gener..." | Re-trigger Greptile |
Problem
Opening or switching to a task chat view re-fired the LLM title/summary generation even when nothing had changed.
~14,000–21,000 eliminated LLM calls/week
~15–20M gateway tokens/week that stop counting against users' metered LLM usage
Per user roughly one fewer 2.2s background gateway request + IPC round trip on most task-view
Changes
move title generation state into a shared Zustand store keyed by task ID, preserving generation state across remounts and preventing concurrent generation.
skip catch-up title generation when the title is locked and a summary already exists, while continuing normal generation triggers so summaries stay up to date.
clamp prompt counts to prevent newer task runs with shorter event logs from resetting generation state.