Skip to content

fix(tui): preserve initial user message on new session hydration#36176

Open
akshitj11 wants to merge 1 commit into
anomalyco:devfrom
akshitj11:fix/tui-missing-initial-user-message
Open

fix(tui): preserve initial user message on new session hydration#36176
akshitj11 wants to merge 1 commit into
anomalyco:devfrom
akshitj11:fix/tui-missing-initial-user-message

Conversation

@akshitj11

@akshitj11 akshitj11 commented Jul 10, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #35988

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

On a new session's first prompt, the TUI navigates to the session view and runs session.sync() before the server has persisted the user message. Hydration can complete with only the assistant reply, so the user bubble never appears.

This adds an optimistic user message in the sync store at submit time, keeps it through hydration merge, and removes it when the real message.updated arrives (or on prompt failure).

How did you verify your code works?

  • cd packages/tui && bun test test/cli/cmd/tui/sync-live-hydration.test.tsx
  • cd packages/tui && bun test
  • cd packages/tui && bun run typecheck

Added regression test: optimistic user message survives new session hydration race.

Screenshots / recordings

No recording yet — race is timing-dependent. Happy to add one with a slow MCP config if needed.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Insert an optimistic user message when submitting the first prompt in a
new session so hydration cannot drop it before server events arrive.
Reconcile with the server message on message.updated and clear on prompt
failure.

Fixes anomalyco#35988
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Jul 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tui: initial user message can be missing from a new session

1 participant