Skip to content

Keep your New GitHub issue draft after an accidental dismissal - #7778

Merged
brennanb2025 merged 1 commit into
mainfrom
brennanb2025/confirm-modal-close
Jul 8, 2026
Merged

brennanb2025 merged 1 commit into
mainfrom
brennanb2025/confirm-modal-close

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Dismissing the New GitHub issue dialog by clicking outside it (or pressing Escape, or clicking Cancel) no longer discards the in-progress issue. The title, body, labels, assignees, and target repo are kept in app state and restored when the dialog is reopened. The draft is cleared only after a successful create.

Boundary (what does not change): the draft is session-only / in-memory — not written to disk, so it does not survive an app restart. It survives close→reopen and navigating away from the Tasks view and back. Scope is the New GitHub issue dialog only; other create-modals are intentionally out of scope (see Notes). No confirmation prompt is added — recovery is silent.

Approach: the draft is lifted into a session-only store slice (newIssueDraft, not persist-wrapped), mirroring the existing newWorkspaceDraft slice. Reset-on-reopen was the data-loss point; the + open handler now restores a content-non-empty draft (a bare repoId/empty form is not "content", so an untouched open never pins a meaningless draft). A content-gated write-through effect mirrors live edits into the slice while the dialog is open. Repo-scoped labels/assignees are cleared only by a genuine user repo switch or when the chosen repo leaves the selection — a restore never routes through a clear path, so it can't wipe just-restored fields (this replaces a reactive "clear on target-id change" effect that couldn't tell a restore apart from a switch). clearNewIssueDraft() runs in the submit-success block, with newIssueOpen flipping false in the same commit so the write-through can't re-persist emptied fields. New logic lives in named modules: store/slices/new-issue-draft.ts and components/task-page-new-issue-draft.ts (pure helpers), wired in TaskPage.tsx.

Screenshots

Live Electron validation captured full-window screenshots of each state; verified during review:

  • Typed → title DRAFT-RECOVERY-TEST: accidental dismissal should not lose my work + a multi-line body.
  • Dismissed (backdrop click) → dialog closes.
  • Restored on reopen → title + body come back identically.
  • Escape + all fields → title ESCAPE-FRESH-EDIT…, body, plus browser + bug label chips and the brennanb2025 assignee all restored.
  • Created + cleared on submit → filing a real issue against a private throwaway repo succeeds, and reopening the dialog afterward shows a completely empty form (title/body/labels/assignees all cleared) — confirming the draft clears only on a successful create.

Per repo policy, evidence images are not committed. Screenshots are attached to the PR conversation / shared with the reviewer rather than checked in.

Testing

  • pnpm typecheck — clean
  • pnpm lint — oxlint clean on all changed files; a full-repo pnpm lint fails only on one pre-existing, unrelated file (right-sidebar/source-control-manual-review-url.ts), not part of this diff
  • pnpm test — focused suites for the new slice + helpers pass (20/20): pnpm vitest run --config config/vitest.config.ts src/renderer/src/store/slices/new-issue-draft.test.ts src/renderer/src/components/task-page-new-issue-draft.test.ts (plus affected store suites); full suite not run
  • Live clear-on-submit — a real issue was created against a private throwaway repo and the dialog came back empty on reopen (the draft clears only on successful create)
  • pnpm build — not run (renderer-only change; typecheck + oxlint cover the touched surface)
  • Added high-quality regression tests (seed-vs-restore incl. content-gate and repo-vanished; vanish-guard; user-switch clear; a load-bearing store-retention P1 regression; and an array-aliasing regression that fails if the empty-draft factory is reverted)

AI Review Report

Reviewed through Brennan's PR process end-to-end:

  • Design review converged; an initial intricate "restore-suppression token" (correctness dependent on React batching) was rejected in self-review for the simpler, locally-verifiable cause-decomposition.
  • Perf audit found and fixed one real issue: newIssueDraft was subscribed in the very large TaskPage, causing an extra full re-render per keystroke (the write-through changes object identity each keystroke). Fixed by reading it via useAppStore.getState() at click time (TaskPage is the only consumer) → zero extra re-renders. Write-through is an O(1) store set (no disk/IPC); the vanish-guard keys on a memoized selectedRepos so it doesn't thrash; no leaks/polling/subprocess churn.
  • Two-reviewer code-review loop: 2 rounds. Round 1 flagged one P2 (a shared empty-draft array singleton that could alias labels/assignees under the Partial patch API) — fixed with a per-seed factory + regression test. Round 2: both reviewers clean.
  • Completeness verification: all checks pass; no path where a restore triggers a scoped-field clear.
  • Cross-platform (macOS/Linux/Windows): explicitly checked — this is a renderer-only React/store change with no keyboard-shortcut, path, shell, label-locale, or Electron-platform code touched. Behavior is platform-agnostic. The createIssue transport (local vs runtime RPC / SSH) is unchanged, so SSH/remote behavior is unaffected.

Security Audit

  • Input handling: the only new data flow is storing the user's own already-entered issue fields (title/body/labels/assignees/repoId) in an in-memory renderer store and reading them back into the same form. No parsing/deserialization of untrusted input.
  • Command execution / path handling: none introduced.
  • Auth / secrets: none touched; the GitHub create/auth path is unchanged.
  • IPC: no new IPC or main-process surface; the slice is renderer-only and never persisted to disk.
  • Follow-up: none.

Notes

  • Cancel now preserves the draft (all close paths preserve; the draft clears on submit). Deliberate. A "Cancel = discard" affordance would be a small follow-up.
  • Session-only: in-memory, not persisted to disk — does not survive app restart. By design.
  • Deferred (approved non-goals): other create-modals with the same latent loss (New Workspace composer — draft machinery currently disabled; New Linear project), confirm-before-close UX, and cross-restart persistence.
  • Broad app consistency: brings the New GitHub issue dialog in line with the "modal draft survives accidental dismissal" behavior; neighboring create-modals are intentionally deferred; no cross-surface regression introduced.
  • Pre-existing lint: the unrelated pnpm lint failure noted above is not introduced by this PR.

Dismissing the "New GitHub issue" dialog by clicking outside (or Escape/
Cancel) no longer discards the in-progress issue. The title, body, labels,
assignees, and target repo are kept in a session-only store slice and
restored when the dialog is reopened. The draft is cleared only on a
successful create (or app restart).

Reset-on-reopen was the data-loss point; the open handler now restores a
content-non-empty draft instead of resetting. Repo-scoped labels/assignees
are cleared only by a genuine user repo switch or when the chosen repo
leaves the selection, so a restore never wipes them.

Session-only and in-memory: not persisted to disk, so it does not survive
an app restart. Scoped to the New GitHub issue dialog only.
@coderabbitai

coderabbitai Bot commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds a session-persistent draft system for the "New GitHub issue" dialog in TaskPage. A new Zustand slice (createNewIssueDraftSlice) stores draft state with set/clear actions, registered in the root store and AppState type. New pure helper functions (isNewIssueDraftContentful, resolveNewIssueOpenSeed, resolveUserRepoSwitchReset, resolveVanishedNewIssueRepoReset) determine how to seed, reset, or restore draft fields. TaskPage now seeds the dialog from the stored draft on open, mirrors live edits into the draft, handles repo-switch and vanished-repo resets, and clears the draft on successful submission. Corresponding unit tests and test-store helper updates are included.

Sequence Diagram(s)

Included above within the hidden review stack artifact for the TaskPage dialog wiring layer.

Estimated code review effort: High

Related PRs: None specified

Suggested labels: enhancement, needs-review

Suggested reviewers: None specified

🐰 A draft tucked safe in session's nest,
seeds reborn when repos rest,
labels clear when choices stray,
cleared for good on submit day.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: preserving the New GitHub issue draft after accidental dismissal.
Description check ✅ Passed The description follows the required template and fills all major sections with relevant implementation, testing, review, security, and notes details.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

@brennanb2025
brennanb2025 merged commit e218bf8 into main Jul 8, 2026
2 checks passed
Jinwoo-H added a commit that referenced this pull request Jul 9, 2026
Clean auto-merge, no conflicts. Brought in from main:
- daemon boot hardening: fail builds/CI when terminal daemon can't start;
  plain-node-entry-guard + verify-packaged-daemon-entry (electron require
  leaked into daemon-entry chunk, #7844/#7849)
- perf(windows): relax whole-process-table scans for terminals with no
  agent evidence (#7607) — foreground-scan-cadence
- fix(agents): route WSL OMP hooks to the Windows listener (#7565/#7641)
- fix: recover fresh local terminal spawns from a deleted saved cwd (#7847)
- native-chat: upload composer attachments over SSH (#7832)
- mobile: keyboard dismiss control; agent-tab launch fix
- new GitHub issue draft persistence (#7778)

Perf-branch structure preserved (clean auto-merge; no restructured terminal
files conflicted). Gates: typecheck 0 errors; terminal-pane + ipc/pty +
daemon + pane-manager suites 4497 passed / 14 skipped / 0 failed.

Co-authored-by: Orca <[email protected]>
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
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.

1 participant