Skip to content

fix(web): discarding a draft from the sidebar asks first - #12736

Closed
Mnigos wants to merge 1 commit into
pingdotgg:mainfrom
Mnigos:sidebar-confirm-discard-draft
Closed

Mnigos wants to merge 1 commit into
pingdotgg:mainfrom
Mnigos:sidebar-confirm-discard-draft

Conversation

@Mnigos

@Mnigos Mnigos commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #12735.

Problem

In the sidebar, a thread row with an unsent draft and a new-thread draft row both show a hover-only X ("Discard draft"). One click wiped the prompt, attachments, and contexts with no confirmation, undo, or toast. The X sits on the row's own click target and composerDraftStore keeps no snapshot, so a click meant to open the thread could lose the message for good.

Fix

The triage offered a confirm or an undo toast. I went with the confirm, because it matches what already exists: mobile guards the same action with Alert.alert("Discard draft?", …), and sidebar delete and archive use api.dialogs.confirm.

  • confirmDiscardDraft in Sidebar.tsx opens the destructive confirm dialog ("Discard draft? The unsent message and its attachments will be removed.").
  • Both discard paths await it before touching the store: handleDiscardDraftClick on thread rows (clearComposerContent) and handleDiscard on draft rows (clearDraftThread). Uploads are released only after confirming.

No new setting: unlike delete and archive, there is no way to get a discarded draft back, so an opt-out did not seem worth it. Moving the X out of the row's click target is left out to keep this to one concern; with the confirm in place a stray click no longer loses anything. docs/user/thread-sidebar.md does not mention the control, so there is nothing to update.

Verification

Web typecheck and targeted lint are clean. No unit test: the change routes two click handlers through the existing dialog, and a test would only assert that wiring.

Recorded in a real browser against the dev server, on a new-thread draft row. After: the X opens the dialog, Cancel keeps the draft, Confirm removes it.

Before: one click, the draft is gone After: the click asks first
before after
before still after still

Implemented with Claude Code (Claude Fable 5.1).

The hover-only X on a thread row with an unsent draft, and on a new-thread
draft row, cleared the prompt and attachments on a single click. It sits on
the row's own click target and the draft store keeps no snapshot, so a click
meant to open the thread could lose the message for good.

Both paths now go through the same destructive confirm dialog that thread
delete uses, matching the "Discard draft?" alert on mobile.
@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Sep 20, 2026
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Sep 20, 2026
@macroscopeapp

macroscopeapp Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 2457ecc

Macroscope's review found this PR approvable — This one-file fix adds an existing confirmation-dialog pattern to both sidebar draft-discard paths while preserving the original cleanup behavior after confirmation. Cancellation or dialog failure leaves the draft intact, and no defaults, schemas, infrastructure, or static-analysis settings are changed.

Notes:

  • Diff unchanged. Approvability was decided on eligibility alone.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: f729ee2c-d913-4a37-a45c-3c622dde81fe

📥 Commits

Reviewing files that changed from the base of the PR and between 7445aa7 and 2457ecc.

📒 Files selected for processing (1)
  • apps/web/src/components/Sidebar.tsx

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

Draft discard actions in the sidebar now require destructive confirmation. Declined or unavailable confirmation leaves drafts unchanged. Confirmed actions release uploads and clear the relevant draft content.

Changes

Draft discard confirmation

Layer / File(s) Summary
Confirmation gate
apps/web/src/components/Sidebar.tsx
confirmDiscardDraft checks local API availability and accepts deletion only after an affirmative response.
Discard action integration
apps/web/src/components/Sidebar.tsx
Draft-block and thread-row discard handlers wait for confirmation before releasing uploads and clearing draft content.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: t3dotgg

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Issue #12735 requires a guard against accidental loss from both sidebar draft-discard controls. The PR summary states that it adds a destructive “Discard draft?” confirmation dialog, routes both threa…
Out of Scope Changes check ✅ Passed The reported change is limited to apps/web/src/components/Sidebar.tsx. The described additions modify draft-discard behavior and upload release timing, which directly address Issue #12735. No unrela…
Title check ✅ Passed The title clearly identifies the main change: requiring confirmation before discarding a sidebar draft.
Description check ✅ Passed The description explains the problem, the implemented fix, the affected discard paths, and verification results. It includes UI screenshots and interaction recordings. It does not use the template hea…
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Comment @coderabbitai help to get the list of available commands.

@myfunc

myfunc commented Sep 20, 2026

Copy link
Copy Markdown

What do you think about "double-click" on it without modal? I don't remember where I've seen this practice, but I found it nice.

image

@Mnigos

Mnigos commented Sep 20, 2026

Copy link
Copy Markdown
Contributor Author

Note

🤖 Claude Fable 5.1 on behalf of Mnigos

Nice idea, and lighter than a modal. I kept the confirm dialog here because the triage on #12735 asked for a confirm or an undo toast, and the dialog matches what mobile and thread delete/archive already do. An inline "discard?" second step would be a new pattern in the sidebar (extra state, reset on mouse leave, and a fast accidental double-click still loses the draft), so I would rather leave that call to the maintainers. Happy to switch if they prefer it.

@juliusmarminge juliusmarminge added the macroscope-review Opt PRs made by unvouched contributors in for Macroscope review. Vouched contributors auto-reviews label Oct 1, 2026 — with ChatGPT Codex Connector
@macroscopeapp
macroscopeapp Bot dismissed their stale review October 1, 2026 20:29

Dismissing prior approval to re-evaluate 2457ecc

Copy link
Copy Markdown
Member

Note

Grok responding on behalf of Julius.

Closing as superseded by #10637. The confirm-dialog approach is no longer needed: discard now uses the sidebar undo notice (discardComposerDraft), which resolves #12735.

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

Labels

macroscope-review Opt PRs made by unvouched contributors in for Macroscope review. Vouched contributors auto-reviews size:S 10-29 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Hover-only "Discard draft" X in the sidebar deletes the draft on one click, no confirmation or undo

3 participants