feat(sessions): refill composer when cancelling before the agent starts#3006
Open
MattPua wants to merge 3 commits into
Open
feat(sessions): refill composer when cancelling before the agent starts#3006MattPua wants to merge 3 commits into
MattPua wants to merge 3 commits into
Conversation
Cancelling a turn before the agent produces any output now refills the just-sent message back into the composer so a quick "oops" doesn't lose it. The message stays in conversation history (it's already in the agent's context and the persisted log). Refill is skipped once the agent has started, and when you're not focused on that chat. Attachments and mentions are restored as chips via xmlToContent. Generated-By: PostHog Code Task-Id: ef6829e7-daed-47c3-abdd-59340c9d493c
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
Contributor
|
Reviews (1): Last reviewed commit: "feat(sessions): refill composer when can..." | Re-trigger Greptile |
…ases Collapse the three standalone false-returning tests into one it.each and the two turn-isolation cases into another, matching the codebase's preference for parametrised tests. Addresses greptile review feedback. Generated-By: PostHog Code Task-Id: fb9502ee-29c5-41cb-8c21-649fea69ca3d
Generated-By: PostHog Code Task-Id: 105b1780-2d0b-43b6-9f28-140a9e7cade2
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.
Problem
Cancelling a turn right after sending (before the agent has produced any output) loses the just-sent message. A quick "oops, wrong send" means retyping it.
Changes
CleanShot.2026-06-29.at.17.45.39.mp4
xmlToContent), not raw XML.Implementation:
hasAgentStartedTurn({ events, hasOptimisticItems })in core owns the decision:falsewhile still optimistic (echo not landed, no output possible), otherwise checks for agent output after the latestsession/prompt. Works for local and cloud (reads only persisted store state, avoids the local-onlyliveTurnContent).SessionService.hasAgentStartedCurrentTurn(taskId)is the thin session-aware wrapper.useSessionCallbackscaptures the serialized text on send and applies the queued-wins / focus gating on cancel.Danger level: 1/5 — additive, client-side only, no backend or protocol changes; gated behind narrow conditions and covered by tests.
How did you test this?
pnpm --filter @posthog/core test hasAgentStartedTurn— 9 cases (optimistic guard, prior-turn isolation, each agent output kind), all passing.pnpm --filter @posthog/core typecheckandpnpm --filter @posthog/ui typecheck— both clean.Automatic notifications
Created with PostHog Code