Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): restore reverted messages to composer #6044

Closedamitray007(GitHub profile, opens in a new tab)wants to merge 7 commits intomain fromrefs/pull/6044/headopened View on GitHub

What Changed

Reverted user messages now return to the composer with their images. If a draft is already present, it is saved to Stash first.

The live timeline also removes the reverted message once the server confirms the rewind.

Why

“Revert to this message” rewound the checkpoint, but left the selected message in the timeline and forced users to recreate the prompt before sending it again.

Closes https://github.com/pingdotgg/t3code/issues/5685

UI Changes

BeforeAfter
Before revertAfter revert

Interaction

https://github.com/user-attachments/assets/66af7cd0-ec2a-41e2-88ed-7d98a82c5f8b

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Built with GPT-5.6-Sol through T3 Code.

Note

Restore reverted user message prompt and attachments into the composer

  • When reverting a thread checkpoint, the user's original message prompt and image attachments are now fetched and written back into the composer after revert completes.
  • deriveRevertedMessageContent strips review comment blocks and preview-annotation screenshots from the prompt before restoration; fetchRevertedMessageAttachmentBlob fetches attachment blobs with a 10-second abort timeout.
  • The composer is disabled during revert preparation; attachments are deduplicated, capped at PROVIDER_SEND_TURN_MAX_ATTACHMENTS, and any existing stash or context attachments are cleared before writing.
  • Toasts surface warnings for missing images, attachment overflow, stash/clear behavior, and stash failures.
  • Turnless message retention in threadReducer is now bounded by the latest retained checkpoint instead of keeping all turnless messages unconditionally.
  • Risk: blob URLs are created during draft preparation and must be revoked on cleanup; any fetch failure within the timeout marks that attachment as unavailable rather than blocking restoration.
Macroscope summarized a216c72.

Note

Medium Risk Touches checkpoint revert UX and client-side message retention after thread.reverted, plus blob URL lifecycle for restored attachments. Failures are mostly soft (toasts / unavailable images), but incorrect retention or cleanup would affect timeline correctness and composer state.

Overview Reverting a checkpoint now puts the selected user message back into the composer (editable text + images), so users can edit and resend instead of recreating the prompt.

Existing draft text/images are stashed first when possible; session-bound context (terminal/element/preview/review) is cleared because it cannot be safely reused after a rewind. Preview-annotation screenshots and review/context blocks are stripped from the restored prompt. Attachment blobs are fetched with a 10s abort timeout, deduped, and capped at the composer image limit, with toasts for missing/overflow images and stash/clear outcomes.

Separately, retainMessagesAfterRevert now drops turnless messages after the latest retained checkpoint, so the timeline actually removes the reverted prompt once the server confirms the rewind.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit a216c727fdd934115f86f742ed77fd228c9aa93a. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: ad10ca3c-9852-4304-9a76-f7b9f24cfd86

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review

      Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

      ❤️ Share
      Comment `@coderabbitai help` to get the list of available commands.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟠 High

      https://github.com/pingdotgg/t3code/blob/1ea7561d235dacfb49954b646690ae99009eb76f/apps/web/src/components/ChatView.tsx#L4024

      pendingRevertedMessageRestore is never cleared when the route switches to another thread, so checkpoint reverts are disabled in the newly opened thread. After a revert starts, the restore effect bails out when revertObservedThreadId !== pending.threadId, but the state is never cleared, and onRevertToTurnCount rejects every subsequent revert while any pending restore exists. Navigating away before the old thread publishes its reverted messages therefore blocks all reverts in the new thread (and retains the prepared blob URLs) until the user returns to the original thread or unmounts ChatViewContent. Consider clearing the pending restore on thread change, or scoping it by thread.

      ✅ Resolved in 7595b96912b57e308ccd47d5c3e9ef4ba5765d55

      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟠 High

      https://github.com/pingdotgg/t3code/blob/1ea7561d235dacfb49954b646690ae99009eb76f/packages/client-runtime/src/state/threadReducer.ts#L681

      retainMessagesAfterRevert uses the absolute event.payload.turnCount to compute missingUserCount and missingAssistantCount, but the function only sees the messages loaded in the current client window. For a paginated thread whose loaded window starts at a later turn, missingUserCount = turnCount - retainedUserCount can be far larger than the number of surviving turns actually loaded. Reverting to turn 99 when turns 90–100 are loaded computes missingUserCount = 99, so all loaded turnless user messages are retained — including the turn-100 prompt the revert should remove. The same absolute-count defect affects the assistant fallback. Reverted messages stay visible whenever the thread's earlier turns are not loaded. The fallback counts should be derived from the retained checkpoints/messages in the loaded window rather than the global turn count.

      No longer relevant as of 7595b96912b57e308ccd47d5c3e9ef4ba5765d55

    4. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Needs human review

      This PR introduces a new feature for restoring reverted messages to the composer, including attachment fetching, draft stashing, and complex state management. Despite the 'fix' prefix, the ~670 lines of additions represent significant new user-facing capability that warrants human review.

      You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    5. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium

      https://github.com/pingdotgg/t3code/blob/50b09fb1d929c69d2c6d9bc566f013e75e5276ca/packages/client-runtime/src/state/threadReducer.ts#L654

      retainMessagesAfterRevert caps turnless user messages to one per surviving turn (missingUserCount = retainedTurnIds.size - retainedUserCount), but steering prompts are also emitted before the provider assigns a turn id. When a retained turn has an initial prompt plus steering messages, reverting a later turn silently drops those steering prompts from the live timeline even though their turn survives. The same one-per-turn cap is applied to assistant messages, so multi-message assistant turns lose commentary. Retention should be bounded by checkpoint/timeline boundaries per turn rather than by a fixed count.

      ✅ Resolved in 176cb9f37f59a79d7c92c6354f2676cf5033f1f7

    6. Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

      Fix All in Cursor ❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot). Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit af4d49122a15121bd56b5a385e0d64db176d5ecd. Configure [here](https://www.cursor.com/dashboard/bugbot).
    7. Won't be able to maintain this PR anymore. Feel free to use the code if needed, using a personal fork going forward.

Sign in to join this conversation.