Skip to content

Ask before q or a screen switch drops a new-task draft - #1092

Merged
lezli01 merged 1 commit into
tui-auditfrom
fix/form-drafts-ask-before-dropping
Nov 23, 2026
Merged

lezli01 merged 1 commit into
tui-auditfrom
fix/form-drafts-ask-before-dropping

Conversation

@lezli01

@lezli01 lezli01 commented Nov 23, 2026

Copy link
Copy Markdown
Owner

Closes #1051. Merges into tui-audit.

New-task form

  • q and every screen switch now ask before dropping a touched new-task form: a tab, the palette, !, an open from elsewhere. The question sits in the status line: discard the task draft and quit? y/n or … and leave? y/n. y goes ahead, n/esc keeps the form.
  • The guard is a new leaveGuard that the root consults in switchTo (switchNow is the unguarded path, used on y) and on the quit key.
  • ctrl+c never asks, so the TUI stays killable.
  • A form whose create is in flight does not ask: the landing on the new task is the switch it causes.
  • Why the new-task form had this hole: switching away left its draft in memory, but n reopens it pristine. The existing switchGuard only covered project switches.

Project form

  • esc on a touched form now asks discard these changes? y/n, as the new-task form does. "Touched" means the request a save would send differs from the one it opened with, so typing a field back to its value is not a draft.
  • I confirmed rather than assumed the other half of the issue: with the form open, the projects view already captures every key (q included), and the form survives a screen switch. It needed no leave guard, and a test now holds that.

Checks

  • Tests: q asks, n keeps the draft, y quits; a switch asks, esc keeps the form, y switches; no question for an untouched or submitting form; the project form's esc question and its dirty rule; the project form surviving q and a switch.
  • One live test that left a seeded draft behind now answers the form's own question first.
  • Updated the TUI guide.
  • go test ./internal/tui passes and mage lintall is clean.

q and every screen switch away from a touched new-task form now ask
"discard the task draft and quit/leave? y/n" in the status line; a form
whose create is in flight does not ask, and ctrl+c never does. esc on a
project form whose request would differ from what it opened with asks
"discard these changes? y/n", as the new-task form does. The project
form already captured q and survived a switch.

Closes #1051
@lezli01
lezli01 merged commit 9caa281 into tui-audit Nov 23, 2026
24 checks passed
@lezli01
lezli01 deleted the fix/form-drafts-ask-before-dropping branch November 23, 2026 09:41
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