Repository navigation
fix(chat): show a new conversation's first answer, and save answers when the client leaves - #582
Merged
Merged
Conversation
…hen the client leaves The web app re-read a new conversation after its answer was saved with invalidateQueries, which waits on a first read still under way (asked before the save) instead of reading again, so the question showed with "No answer was saved". refetchFresh drops that read and reads afresh; Chat, the page assistant and a recording's Chat tab use it. The answer stream now runs on a thread of its own, so a client that leaves mid-answer no longer abandons it unsaved, and its cleanup never runs on whichever thread collects the generator. Also lists answering questions about Lens itself as built (as #578), which the requirements check needs on main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VGkdmhXwoXaBtU2n9nbdnt
…-jbfduq # Conflicts: # README.md
adeelahmad
pushed a commit
that referenced
this pull request
Oct 18, 2026
…rst load raced the stream" This reverts commit 7f260ec: #582 carries the same fix for main (refetchFresh in every chat panel, and the answer written on a thread of its own), so this PR stays one concern. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ln25ykE6uBDqx21WBU94SX
21 of 23 tasks
…-jbfduq # Conflicts: # CHANGELOG.md
19 of 23 tasks
adeelahmad
added a commit
that referenced
this pull request
Oct 18, 2026
* feat(timeline): emoji reactions and comments on activities
The timeline becomes a feed everyone in a namespace talks on. An opened item has a React button with a palette and shows everyone's reactions as chips; its comments open as threads with Reply, where Enter sends. A closed line sums its items' reactions and says how many comments it has. A comment on an asset's arrival is a comment on the asset, so the same thread shows on its page.
Each reaction is a reaction.added activity (noisy, by the person, with the activity as its object) and each comment a comment.added with the activity as its target, following the activity's audience, so automations and agents can act on them. Agents react and comment over MCP (react_to_activity, activity_comments, comment_on_activity) and through POST /activities/{id}/react and /activities/{id}/comments.
Reactions are one event_reaction row per person and activity, as marks are; comments reuse the comment table with an activity field. No model call is involved.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ln25ykE6uBDqx21WBU94SX
* docs(readme): list the assistant's answers about Lens itself as built
Release 0.15.0 carries #400, so the requirements check failed on main
with it still under In progress; it moves to the built list with its
checks.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ln25ykE6uBDqx21WBU94SX
* fix(chat): show a new conversation's first answer when its first load raced the stream
The page moves to /chat/{id} as a new conversation's first answer
streams. On a slow device that first load of the conversation is still
in flight when the answer ends, and the query cache folds the refetch
asked for then into the load, which predates the answer: the page showed
"No answer was saved for this question" until reloaded (the phone
clicks survey's chat-ask journey in CI). After an answer, when the
conversation read back lacks it, it is read once more.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ln25ykE6uBDqx21WBU94SX
* Revert "fix(chat): show a new conversation's first answer when its first load raced the stream"
This reverts commit 7f260ec: #582 carries
the same fix for main (refetchFresh in every chat panel, and the answer
written on a thread of its own), so this PR stays one concern.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ln25ykE6uBDqx21WBU94SX
* docs(changelog): move the reactions and comments entry to a changelog.d fragment, and name them in the README
The release commit folds Unreleased into the version section and #581 moved new entries to changelog.d/, so the
entry becomes changelog.d/timeline-social.md. The README's built line lost its reactions and comments clause in an
earlier merge; it is back.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ln25ykE6uBDqx21WBU94SX
---------
Co-authored-by: Adeel Ahmad <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.
Requested by Adeel · project thread
Description
Before: asking the first question of a new conversation sometimes showed the question with "No answer was saved for this question. Ask it again to get one." even though the answer had been saved, until something made the page read the conversation again. Separately, closing the tab or losing the connection mid-answer dropped the answer for good.
After: the answer shows as soon as it is saved, and an answer is finished and saved even when the browser leaves before it ends; only Stop ends one early.
Cause (from the Clicks failures on #535, runs 39108195666 and 39108209701, reproduced locally in 1 of 7 runs of
ci/clicks/run.sh --only …,first-question,chat-ask): a new conversation's page starts its first read ofGET /chats/{id}while the answer is still streaming. When the stream ends,invalidateQueriesdoesn't read again: TanStack Query attaches to a first read still in flight (no data yet) instead of cancelling it (query.js: it only cancels whendata !== undefined). That read was answered before the save, so the page shows the bare question and, with a 10 s stale time, nothing reads it again. The backend log shows exactly oneGET /chats/{id}after thePOST …/messagesin each failure; a diagnostic on the backend generator confirmed it was never closed early, so the server did save the answer.How:
refetchFresh(qc, key)(components/chat/data.ts) cancels a read under way, then invalidates, so the conversation is read after the save. Chat, the page assistant and a recording's Chat tab use it after an answer.docs/frontend.mdnotes the rule.POST /chats/{cid}/messages) now runs on a thread of its own (_detached, the same pattern as/v1/chat/completions); the response only hands events over. A client that disconnects (Starlette cancels the response under uvicorn's ASGI 2.3) no longer abandons the generator beforesave(), and its cleanup (Answering.end, compaction, the title) runs on that thread rather than wherever the garbage collector closes it (the hazard behind fix(settings): test the LLM address and model on screen, not only the saved ones #539/feat(automations): look back and compare in running automations #542).Motivation and Context
Flaky
Clicksjourneys (first-question,chat-ask) on several PRs; a real bug people hit with quick answers.Steps to reproduce (if appropriate):
Loop
ci/clicks/run.sh --only install,first-admin,setup-wizard,first-question,import-paste,chat-ask; before this change run 7 failed with the screenshot above. Tests reproduce both halves deterministically:chat-fresh-answer.test.tsxfails with invalidate-only, andtest_an_answer_is_saved_when_the_client_leavesfails on main (the conversation keeps only the question).Types of changes
!in the title)Checklist:
docs/accordingly (assistant.mdChat,frontend.mdData,requirements.md).## UnreleasedinCHANGELOG.md.Done questions (AGENTS.md)
make openapi).routes/completions.py; TanStack's owncancelQueries.Generated by Claude Code