fix(tui): invite payload gets a chrome-free region so mouse-copy is exact #122

Merged
sirius merged 2 commits from onionwire/t_af8b509e-onionwire-tui-invite-mouse-copy-must-not into main 2026-09-19 14:46:43 +00:00
Owner

What this fixes

Mouse-selecting an invite copied the pane border into the link. draw_share rendered the
payload inside themed_block("(o) invite"), which applies Borders::ALL: every wrapped
row sat between │ at column 0 and │ at the last column. OnionWire never enables mouse
capture (grep -rn EnableMouseCapture src/ is empty), so the terminal's own drag-select is
the copy path — and it copies the cells a drag crosses, borders included.

Cause verified before fixing, by rendering draw_share on base through TestBackend
at 80x24 (cargo test --locked --test tui_frames -- --nocapture dump_audit_frames). The
sig= row is 79 cells wide, so it reached the trailing border column as well as the leading
one.

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 copy
hint — in a bordered block above it. Layout::vertical([Length(body + 2), Min(0)]) sizes
the block from its own content, so the payload always starts on the row after the bottom
border and can never collide with it. wrap_invite is untouched: it still breaks on :, so
the 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: C writes the payload to the terminal's clipboard
with OSC 52 — the same osc52_copy_sequence the 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:

│select the link below with the mouse, or press C to copy                      │

? lists it as F2 share invite (C copies it). There is no transient "copied" line: the
clipboard write is fire-and-forget and draw_share takes only the payload.

Before — 80x24 (draw_share on base)

Payload rows are fenced by │ on both sides; the last sig= row reaches the trailing border.

===== draw_share (real)  80x24 =====
┌(o) invite────────────────────────────────────────────────────────────────────┐
│give this string to a friend; they F3 paste it                                │
│                                                                              │
│fp  ea4a6c63…                                                                 │
│onion  abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx.onion         │
│                                                                              │
│onionwire:v1:                                                                 │
│k=ea4a6c63e29c520abef5507b132ec5f9954776aebebe7b92421eea691446d22c:           │
│o=abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx.onion:             │
│spk=0101010101010101010101010101010101010101010101010101010101010101:         │
│sig=46caf16b6da95e86bf93a6ee80605ec74d9e24a419c4ef802632af74f46406fae9953690e0│
│5401b0af934cefea617f71466f406af4bef956847200a8e915190b                        │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
│                                                                              │
└──────────────────────────────────────────────────────────────────────────────┘

After — 80x24

The payload is the selection: column 0 to the frame edge, nothing beside it.

===== draw_share (real)  80x24 =====
┌(o) invite────────────────────────────────────────────────────────────────────┐
│give this string to a friend; they F3 paste it                                │
│fp  ea4a6c63…                                                                 │
│onion  abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx.onion         │
│select the link below with the mouse, or press C to copy                      │
└──────────────────────────────────────────────────────────────────────────────┘
onionwire:v1:k=ea4a6c63e29c520abef5507b132ec5f9954776aebebe7b92421eea691446d22c:
o=abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx.onion:               
spk=0101010101010101010101010101010101010101010101010101010101010101:           
sig=46caf16b6da95e86bf93a6ee80605ec74d9e24a419c4ef802632af74f46406fae9953690e054
01b0af934cefea617f71466f406af4bef956847200a8e915190b                            
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                
                                                                                

After — 120x40

fp and onion share one row here (the block is a line shorter); the payload region is
unchanged.

===== draw_share (real)  120x40 =====
┌(o) invite────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│give this string to a friend; they F3 paste it                                                                        │
│fp  ea4a6c63…    onion  abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx.onion                                │
│select the link below with the mouse, or press C to copy                                                              │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
onionwire:v1:k=ea4a6c63e29c520abef5507b132ec5f9954776aebebe7b92421eea691446d22c:                                        
o=abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx.onion:                                                       
spk=0101010101010101010101010101010101010101010101010101010101010101:                                                   
sig=46caf16b6da95e86bf93a6ee80605ec74d9e24a419c4ef802632af74f46406fae9953690e05401b0af934cefea617f71466f406af4bef9568472
00a8e915190b                                                                                                            
                                                                                                                        
                                                                                                                        
                                                                                                                        
                                                                                                                        
                                                                                                                        
                                                                                                                        
                                                                                                                        
                                                                                                                        
                                                                                                                        
                                                                                                                        
                                                                                                                        
                                                                                                                        
                                                                                                                        
                                                                                                                        
                                                                                                                        
                                                                                                                        
                                                                                                                        
                                                                                                                        
                                                                                                                        
                                                                                                                        
                                                                                                                        
                                                                                                                        
                                                                                                                        
                                                                                                                        
                                                                                                                        
                                                                                                                        
                                                                                                                        
                                                                                                                        
                                                                                                                        
                                                                                                                        

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 — renders draw_share, takes
    the 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 and ASCII_BORDERS).
  • share_copy_key_sequence_carries_the_payload_exactly — decodes the OSC 52 sequence's
    base64 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):

running 4 tests
test share_screen_shows_invite_not_qr_at_80x24 ... ok
test share_payload_rebuilds_from_the_frame_at_80x24_and_120x40 ... FAILED
test share_payload_rows_carry_no_border_glyph ... FAILED
test share_copy_key_sequence_carries_the_payload_exactly ... FAILED

---- share_payload_rebuilds_from_the_frame_at_80x24_and_120x40 stdout ----
thread ... panicked at tests/tui_chrome.rs:415:9:
no chrome-free payload row at column 0 on the 80x24 share screen; a mouse drag across the invite would copy the pane borders:

---- share_payload_rows_carry_no_border_glyph stdout ----
thread ... panicked at tests/tui_chrome.rs:453:17:
row 6 carries invite payload AND the border glyph '│' at 80x24: "│onionwire:v1:                                                                 │"

test result: FAILED. 1 passed; 3 failed; 0 ignored; 0 measured; 14 filtered out

GREEN after: same 4 tests, 4 passed.

Verification

cargo test --locked
  passed 369  failed 0  ignored 4

cargo clippy --locked --all-targets -- -D warnings
  Finished `dev` profile [unoptimized + debuginfo] target(s)

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 the
block above the payload). wrap_invite keeps its name, signature and join-back contract.

Stacking

Branched on eefa7e5 (PR #120, the chrome redesign) as the card requires, so this PR's diff
includes #120 until it merges; the change of this card is the last commit,
c3116eb. Base is main.

Files

src/tui.rs (draw_share + share_body_lines, C handler, copy_invite), tests/tui_chrome.rs
(3 new tests + frame helpers), docs/TUI.md (payload-region section with the frame).

## What this fixes Mouse-selecting an invite copied the pane border into the link. `draw_share` rendered the payload inside `themed_block("(o) invite")`, which applies `Borders::ALL`: every wrapped row sat between `│` at column 0 and `│` at the last column. OnionWire never enables mouse capture (`grep -rn EnableMouseCapture src/` is empty), so the terminal's own drag-select is the copy path — and it copies the cells a drag crosses, borders included. **Cause verified before fixing**, by rendering `draw_share` on base through `TestBackend` at 80x24 (`cargo test --locked --test tui_frames -- --nocapture dump_audit_frames`). The `sig=` row is 79 cells wide, so it reached the trailing border column as well as the leading one. ### 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 copy hint — in a bordered block *above* it. `Layout::vertical([Length(body + 2), Min(0)])` sizes the block from its own content, so the payload always starts on the row after the bottom border and can never collide with it. `wrap_invite` is untouched: it still breaks on `:`, so the 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: `C` writes the payload to the terminal's clipboard with OSC 52 — the same `osc52_copy_sequence` the 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: │select the link below with the mouse, or press C to copy │ `?` lists it as `F2 share invite (C copies it)`. There is no transient "copied" line: the clipboard write is fire-and-forget and `draw_share` takes only the payload. ## Before — 80x24 (`draw_share` on base) Payload rows are fenced by `│` on both sides; the last `sig=` row reaches the trailing border. ``` ===== draw_share (real) 80x24 ===== ┌(o) invite────────────────────────────────────────────────────────────────────┐ │give this string to a friend; they F3 paste it │ │ │ │fp ea4a6c63… │ │onion abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx.onion │ │ │ │onionwire:v1: │ │k=ea4a6c63e29c520abef5507b132ec5f9954776aebebe7b92421eea691446d22c: │ │o=abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx.onion: │ │spk=0101010101010101010101010101010101010101010101010101010101010101: │ │sig=46caf16b6da95e86bf93a6ee80605ec74d9e24a419c4ef802632af74f46406fae9953690e0│ │5401b0af934cefea617f71466f406af4bef956847200a8e915190b │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ └──────────────────────────────────────────────────────────────────────────────┘ ``` ## After — 80x24 The payload is the selection: column 0 to the frame edge, nothing beside it. ``` ===== draw_share (real) 80x24 ===== ┌(o) invite────────────────────────────────────────────────────────────────────┐ │give this string to a friend; they F3 paste it │ │fp ea4a6c63… │ │onion abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx.onion │ │select the link below with the mouse, or press C to copy │ └──────────────────────────────────────────────────────────────────────────────┘ onionwire:v1:k=ea4a6c63e29c520abef5507b132ec5f9954776aebebe7b92421eea691446d22c: o=abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx.onion: spk=0101010101010101010101010101010101010101010101010101010101010101: sig=46caf16b6da95e86bf93a6ee80605ec74d9e24a419c4ef802632af74f46406fae9953690e054 01b0af934cefea617f71466f406af4bef956847200a8e915190b ``` ## After — 120x40 `fp` and `onion` share one row here (the block is a line shorter); the payload region is unchanged. ``` ===== draw_share (real) 120x40 ===== ┌(o) invite────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │give this string to a friend; they F3 paste it │ │fp ea4a6c63… onion abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx.onion │ │select the link below with the mouse, or press C to copy │ └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘ onionwire:v1:k=ea4a6c63e29c520abef5507b132ec5f9954776aebebe7b92421eea691446d22c: o=abcdefghijklmnopqrstuvwxyz234567abcdefghijklmnopqrstuvwx.onion: spk=0101010101010101010101010101010101010101010101010101010101010101: sig=46caf16b6da95e86bf93a6ee80605ec74d9e24a419c4ef802632af74f46406fae9953690e05401b0af934cefea617f71466f406af4bef9568472 00a8e915190b ``` 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` — renders `draw_share`, takes the 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 and `ASCII_BORDERS`). - `share_copy_key_sequence_carries_the_payload_exactly` — decodes the OSC 52 sequence's base64 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): ``` running 4 tests test share_screen_shows_invite_not_qr_at_80x24 ... ok test share_payload_rebuilds_from_the_frame_at_80x24_and_120x40 ... FAILED test share_payload_rows_carry_no_border_glyph ... FAILED test share_copy_key_sequence_carries_the_payload_exactly ... FAILED ---- share_payload_rebuilds_from_the_frame_at_80x24_and_120x40 stdout ---- thread ... panicked at tests/tui_chrome.rs:415:9: no chrome-free payload row at column 0 on the 80x24 share screen; a mouse drag across the invite would copy the pane borders: ---- share_payload_rows_carry_no_border_glyph stdout ---- thread ... panicked at tests/tui_chrome.rs:453:17: row 6 carries invite payload AND the border glyph '│' at 80x24: "│onionwire:v1: │" test result: FAILED. 1 passed; 3 failed; 0 ignored; 0 measured; 14 filtered out ``` GREEN after: same 4 tests, 4 passed. ## Verification ``` cargo test --locked passed 369 failed 0 ignored 4 cargo clippy --locked --all-targets -- -D warnings Finished `dev` profile [unoptimized + debuginfo] target(s) ``` 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 the block above the payload). `wrap_invite` keeps its name, signature and join-back contract. ## Stacking Branched on `eefa7e5` (PR #120, the chrome redesign) as the card requires, so this PR's diff includes #120 until it merges; the change of this card is the last commit, `c3116eb`. Base is `main`. ## Files `src/tui.rs` (draw_share + `share_body_lines`, `C` handler, `copy_invite`), `tests/tui_chrome.rs` (3 new tests + frame helpers), `docs/TUI.md` (payload-region section with the frame).
tui: clean-look chrome redesign (one accent, honest tor phase, real frames)
All checks were successful
ci / test (pull_request) Successful in 5m42s
ci / sdk (pull_request) Successful in 1m29s
ci / fuzz (pull_request) Successful in 4m41s
android-ci / android (pull_request) Successful in 10m45s
eefa7e5cc6
Applies the bitchat-tui clean-look principles to the OnionWire main screen.

- Hierarchy: header, roster + one primary chat pane, one status line, one
  footer hint line. The header gives up the accent (the accent is reserved
  for focus), so it stops competing with the panes.
- Tor phase is a first-class state: Node::tor_state() -> TorPhase (glyph +
  word, header and footer) so connecting / ready / degraded / off are never
  colour-only and never implied. No new data field.
- Footer changes with the focused pane (pane_footer_hints) and the phase; the
  main footer drops the redundant onion (the header already prints it) and
  uses those cells for hints. status_footer keeps its signature and strings.
- Empty roster / empty chat / connecting / degraded / off are designed states
  with their own copy, not blank panes.
- draw_main_chrome + MainView: the real main render path is public and
  Node-free, so tests/tui_frames.rs dumps the actual chrome at 80x24, 120x40
  and 200x60 (12 tests, 5 states, real Message/OutboxEntry rows) instead of a
  reconstructed stand-in.
- Widths in cells everywhere touched: status_footer*, alert_line,
  main_header_line*, draw_text_overlay, roster_row_text. The roster spends its
  budget name-first, so a 22-cell pane reads `bob-the-sta…  stale` instead of
  `…  bbbbbbbb… stale`.
- draw_text_overlay is centered with a one-cell side margin and clears
  underneath; never full-bleed.

Also fixes a pre-existing race in tests/tui_spec.rs (the ellipsis-form
assertion did not tolerate ONIONWIRE_ASCII being set by a parallel test).

Co-Authored-By: Hermes <[email protected]>
fix(tui): invite payload gets a chrome-free region so mouse-copy is exact
Some checks failed
android-ci / android (pull_request) Has been cancelled
ci / test (pull_request) Has been cancelled
ci / sdk (pull_request) Has been cancelled
ci / fuzz (pull_request) Has been cancelled
c3116eb19e
Mouse-selecting the invite copied the pane border: draw_share rendered the
payload inside themed_block, which is Borders::ALL, so every wrapped row sat
between a leading and a trailing glyph. OnionWire enables no mouse capture,
so the terminal's own drag-select is the copy path and it picks up chrome.

The payload now has its own region — flush at column 0, full frame width,
no block, no title, no gutter on any row it occupies — with the block
(title, fp, onion, copy hint) above it. Measured in cells, not chars.

Also add C: OSC 52 hand the payload to the terminal clipboard (same
sequence the F9 menu uses), with the key named on the screen and the mouse
selection named as the fallback for terminals that block the sequence.

Regression tests reconstruct the payload out of the rendered frame at
80x24, 120x40, 200x60 and 60x20 (they fail on base: the leading border
column) and assert no payload row carries a border glyph.
Merge branch 'main' into onionwire/t_af8b509e-onionwire-tui-invite-mouse-copy-must-not
All checks were successful
ci / test (pull_request) Successful in 5m17s
ci / sdk (pull_request) Successful in 1m11s
ci / fuzz (pull_request) Successful in 4m52s
android-ci / android (pull_request) Successful in 12m17s
87196e2297
sirius merged commit 2df10124ef into main 2026-09-19 14:46:43 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
sirius/onionwire!122
No description provided.