fix(tui): invite payload gets a chrome-free region so mouse-copy is exact #122
Loading…
Reference in a new issue
No description provided.
Delete branch "onionwire/t_af8b509e-onionwire-tui-invite-mouse-copy-must-not"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What this fixes
Mouse-selecting an invite copied the pane border into the link.
draw_sharerendered thepayload inside
themed_block("(o) invite"), which appliesBorders::ALL: every wrappedrow sat between
│at column 0 and│at the last column. OnionWire never enables mousecapture (
grep -rn EnableMouseCapture src/is empty), so the terminal's own drag-select isthe copy path — and it copies the cells a drag crosses, borders included.
Cause verified before fixing, by rendering
draw_shareon base throughTestBackendat 80x24 (
cargo test --locked --test tui_frames -- --nocapture dump_audit_frames). Thesig=row is 79 cells wide, so it reached the trailing border column as well as the leadingone.
Approach (a), and why
The payload owns a region of its own: flush at column 0, full frame width, no block, no
title, no gutter on any row it occupies, with the chrome — title,
fp,onion, the copyhint — in a bordered block above it.
Layout::vertical([Length(body + 2), Min(0)])sizesthe block from its own content, so the payload always starts on the row after the bottom
border and can never collide with it.
wrap_inviteis untouched: it still breaks on:, sothe payload rows join back to the payload byte for byte, and it now wraps at the full frame
width instead of
width - 2.(b) is shipped too, because it was cheap:
Cwrites the payload to the terminal's clipboardwith OSC 52 — the same
osc52_copy_sequencethe F9 menu already uses for the receive address,no crate, works over SSH. The screen names the key, and names the mouse selection as the
fallback for terminals that ignore OSC 52:
?lists it asF2 share invite (C copies it). There is no transient "copied" line: theclipboard write is fire-and-forget and
draw_sharetakes only the payload.Before — 80x24 (
draw_shareon base)Payload rows are fenced by
│on both sides; the lastsig=row reaches the trailing border.After — 80x24
The payload is the selection: column 0 to the frame edge, nothing beside it.
After — 120x40
fpandonionshare one row here (the block is a line shorter); the payload region isunchanged.
Also dumped at 200x60 and rendered at 60x20 in the new tests.
Regression test, RED on base
New in
tests/tui_chrome.rs:share_payload_rebuilds_from_the_frame_at_80x24_and_120x40— rendersdraw_share, takesthe rows carrying payload (trailing pad cells aside, nothing else removed), joins them and
asserts equality with the payload. Covers 80x24, 120x40, 200x60 and 60x20.
share_payload_rows_carry_no_border_glyph— no row that carries payload carries│,|,┃,+,-or┄(the unicode set andASCII_BORDERS).share_copy_key_sequence_carries_the_payload_exactly— decodes the OSC 52 sequence'sbase64 back to the invite, and asserts the frame names the copy key.
RED on base (
git show HEAD:src/tui.rs > src/tui.rs, new tests unchanged):GREEN after: same 4 tests, 4 passed.
Verification
Existing locked tests stay green untouched:
tui_spec::wrap_invite_breaks_on_field_boundaries,tui_spec::draw_share_invite_does_not_wrap_mid_token,tui_chrome::share_screen_shows_invite_not_qr_at_80x24,tui_spec::ascii_switch_80x24_frame_is_pure_ascii(ASCII chrome still draws+/-/|in theblock above the payload).
wrap_invitekeeps its name, signature and join-back contract.Stacking
Branched on
eefa7e5(PR #120, the chrome redesign) as the card requires, so this PR's diffincludes #120 until it merges; the change of this card is the last commit,
c3116eb. Base ismain.Files
src/tui.rs(draw_share +share_body_lines,Chandler,copy_invite),tests/tui_chrome.rs(3 new tests + frame helpers),
docs/TUI.md(payload-region section with the frame).