Skip to content

fix(agent): preserve messages until send succeeds#3766

Merged
trunk-io[bot] merged 1 commit into
mainfrom
posthog-code/preserve-failed-message
Jul 23, 2026
Merged

fix(agent): preserve messages until send succeeds#3766
trunk-io[bot] merged 1 commit into
mainfrom
posthog-code/preserve-failed-message

Conversation

@tatoalo

@tatoalo tatoalo commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Problem

A failed message request can clear the composer before the server acknowledges it, leaving users without the text they attempted to send.

Changes

Keep composer content in place while a message is being sent. Disable repeat submission during the request and clear the composer only after a successful acknowledgement.

@trunk-io

trunk-io Bot commented Jul 23, 2026

Copy link
Copy Markdown

😎 Merged successfully - details.

@tatoalo tatoalo self-assigned this Jul 23, 2026
@tatoalo tatoalo added the Stamphog This will request an autostamp by stamphog on small changes label Jul 23, 2026
@tatoalo
tatoalo force-pushed the posthog-code/preserve-failed-message branch from 9dbd327 to b27454c Compare July 23, 2026 16:14
@tatoalo tatoalo changed the title fix(chat): preserve messages until send succeeds fix(agent): preserve messages until send succeeds Jul 23, 2026
@tatoalo
tatoalo marked this pull request as ready for review July 23, 2026 16:15
@greptile-apps

greptile-apps Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor
Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
packages/ui/src/features/sessions/components/SessionView.tsx:320-321
**Successful send clears newer draft**

When a user starts typing the next message while the previous request is pending, the successful-send path unconditionally clears the live editor, erasing the newer message and its saved draft.

### Issue 2 of 2
packages/ui/src/features/sessions/components/SessionView.tsx:315-318
**State guard permits duplicate sends**

When two submission events occur before React commits the first state update, both callbacks read `isSendingPrompt` as false and start a request, causing duplicate agent prompts or a duplicate queued message.

Reviews (1): Last reviewed commit: "fix(agent): preserve messages until send..." | Re-trigger Greptile

Comment thread packages/ui/src/features/sessions/components/SessionView.tsx Outdated
Comment thread packages/ui/src/features/sessions/components/SessionView.tsx
@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit 427da82.

@stamphog stamphog Bot removed the Stamphog This will request an autostamp by stamphog on small changes label Jul 23, 2026
@tatoalo
tatoalo force-pushed the posthog-code/preserve-failed-message branch from 84a2384 to 427da82 Compare July 23, 2026 16:24
@tatoalo tatoalo added the Stamphog This will request an autostamp by stamphog on small changes label Jul 23, 2026 — with PostHog
@PostHog PostHog deleted a comment from stamphog Bot Jul 23, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Low-risk UI fix to composer clear/resend logic; the two Greptile P1 concerns (duplicate sends, clearing a newer draft) are both visibly addressed in the diff via the sync ref lock and content-comparison guard, and Greptile reacted 👍 to the fixes. Test coverage added for the failed-send path.

  • Author wrote 0% of the modified lines and has 10 merged PRs in these paths (familiarity MODERATE).
  • 👍 on the PR from greptile-apps[bot].
Gate mechanics and policy version
Gate Result
prerequisites all clear
deny-list no deny categories matched
size 46L, 2F substantive, 64L/3F incl. docs/generated/snapshots — within ceiling
tier T1-agent / T1b-small (64L, 3F, single-area, fix)
stamphog 2.0.0b3 .stamphog/policy.yml @ 72fff49 · reviewed head 427da82

@posthog

posthog Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

👋 Visual changes detected for this PR.

Review and approve in PostHog Visual Review

If these changes are unexpected, they may be caused by a flaky test or a broken snapshot on master. Don't approve — rerun the job or wait for a fix.

@tatoalo
tatoalo enabled auto-merge (squash) July 23, 2026 16:44
@trunk-io
trunk-io Bot merged commit cdf0fe4 into main Jul 23, 2026
37 of 39 checks passed
@trunk-io
trunk-io Bot deleted the posthog-code/preserve-failed-message branch July 23, 2026 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Stamphog This will request an autostamp by stamphog on small changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant