Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): do not reuse archived thread ids as new drafts #7183

Closedmaslinedwin(GitHub profile, opens in a new tab)wants to merge 3 commits intomain fromrefs/pull/7183/headopened View on GitHub

Fixes #6128. New-thread no longer reuses a composer draft whose thread id was archived (or otherwise already created). Archiving the open thread retires that project draft mapping.


Note

Medium Risk Touches composer draft persistence and new-thread routing; incorrect reuse could recreate wrong threads or drop drafts, but behavior is covered by new unit tests.

Overview Fixes new-thread reusing a project's stored draft thread id after that thread was archived, deleted, or already sent.

retireProjectDraftMappingForThread clears the project's + draft mapping when a thread is archived or deleted, without wiping composer text or attachments. Unpromoted draft sessions get a new minted thread id so the old id cannot be resurrected from the sidebar.

decideStoredDraftReuse centralizes when a stored id may be reused: mint if the id is live, archived, deleted, or promoted; reuse only when snapshots show it is unused and unpromoted. An unloaded archive snapshot is treated as unknown (still reusable for empty drafts). readArchivedThreadExists peeks already-fetched archive snapshots so new-thread does not trigger a full archive load.

useHandleNewThread replaces the old "live shell exists → mint" check with this logic for reuse, race detection, and promoted-draft marking.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit d4a85070fba85cb13dc0a5a7635159cb68e8f0a0. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Fix reuse of archived or deleted thread IDs as new draft thread IDs

  • Adds retireProjectDraftMappingForThread to the composer draft store, which drops the logical project→draft mapping for a thread and remints the draft's thread ID (without clearing composer content) when a thread is archived or deleted.
  • Introduces decideStoredDraftReuse in useHandleNewThread.logic.ts to decide whether a stored draft thread ID can be reused (reuse) or must be replaced (mint), based on live, archived, deleted, and promoted state.
  • Updates useNewThreadHandler to use this decision in all three draft-reuse paths: initial reuse, stale-check, and async race resolution.
  • Adds readArchivedThreadExists in archivedThreadsState.ts to check cached archive snapshots without triggering a fetch.
  • Behavioral Change: archiving or deleting a thread now immediately invalidates its ID as the project's next draft thread ID.
Macroscope summarized d4a8507.
    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: dcfb5e08-4ea8-4f4f-8417-276cada5c762

      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

      Approvability

      Verdict: Approved d4a8507

      Bug fix preventing archived/deleted thread IDs from being reused as new drafts. Changes are well-tested, limited in scope to draft ID management, and have clear defensive intent.

      You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. 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 c3ee002c1805be0ea933cbe72c1ce76802bce227. Configure [here](https://www.cursor.com/dashboard/bugbot).
    5. Note

      This comment is posted by Julius' dot

      Closing for missing verification results. The PR adds draft retirement and reuse tests, but neither the description nor the followup comments report running them or checking the archive, new thread, and send sequence from #6128. Report focused test commands and results, then show that sequence succeeding while unsent composer content is preserved before requesting reconsideration.

    6. juliusmarminge closed this

Sign in to join this conversation.