Repository navigation
fix(tui): keep the Mini draft caret when closing the command palette - #63260
Conversation
User decisions: - Correct the existing Mini draft against current dev. - Keep the upstream diff focused on production code.
70501b4 to
da22bf1
Compare
There was a problem hiding this comment.
I reproduced the bug on dev and the fix works. opencode-drive can't open Mini, so I mounted the real footer in OpenTUI's test renderer and ran the PR's steps on both revisions: type a draft, move the caret left, press Ctrl+P, then Escape, then Z.
dev:paperandgridboth lose the caret position (paperZ,gridZ).- This PR: the caret stays put (
paZper,Zgrid). - End-of-draft
red\nblue: passes on both, as the description says.
All packages/tui/test/mini tests pass and tsc -b is clean.
Removing the restore that ran when the view changed back to prompt looks right: the composer only renders in that view, so the restore on rebind already covers it. When the draft is replaced while the composer is closed, the caret still goes to the end, and resetDraft puts it back at 0.
Public API is unchanged; this is internal TUI state.
No blocking concerns.
|
Thanks for checking this on both revisions. I replaced the reconstructed frames in the description with a real side-by-side recording of |
Issue for this PR
Type
paperin Mini and press Left three times:pa│per. Press Ctrl+P, Escape, then typeZ. The draft survives on both revisions. Ondev, the caret jumps from offset 2 to 5 and the next key producespaperZ. With the fix, Escape restores offset 2 and the next key producespaZper.Type of change
What does this PR do?
Save the native textarea offset as the composer unbinds, then restore the draft and offset together when it binds again. The existing editor measurement and clamping still apply when restoring a replacement draft.
How did you verify your code works?
Ran the same nine-case Statecheck property against
dev(1af61ee45c41713c47fd42e80ff775e5d060c06b) and this fix (da22bf16cc4521cad62a1f4a0b76a82d6ded8a02). Three cases failed on dev: the middle ofpaper, the middle of a wide-character multiline draft, and the start ofgrid. All nine passed on the fix. The originalred\nblueend-of-draft example already passes on dev. Controls also cover direct typing and selecting Show status and New session, including their callbacks.Property, replay bundle, and full receipts
The fixture mounts the production Mini footer in OpenTUI 0.8.4’s native 64×16 test renderer under Bun 1.4.2. Each case drives the keymap and reads the focused editor and rendered frames. The host guard deferred the broader suite because a delegated cgroup was unavailable. Scope: footer only.
Replay bundle with property and full receipts · Dev trace · Fix trace · Trace viewer
Extract the bundle, then run from its root on Linux with Bun,
unshare -n, and installed checkouts of the two SHAs above:Screenshots / recordings
Real
opencode mini, same keys on both revisions: typepaper, ← ×3, Ctrl+P, Escape,Z. Left:devends withpaperZ. Right: the fix keeps the caret and ends withpaZper. MP4Checklist