tui: extract pub ColorMode/TokenStyles/tokens_for for testable colour tokens #80
Loading…
Reference in a new issue
No description provided.
Delete branch "wt/t_49b7c2b1"
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?
All tests green. Clippy clean under
--locked --all-targets -- -D warnings.Summary
Extracted the colour token set into a public, testable API on
src/tui.rs— the first card of the visual-identity-v2 foundation (C2 in the wallet-redesign plan).ColorModeenum madepub(was private),color_mode()fn madepub, addedDebugderive.TokenStylesstruct +pub fn tokens_for(mode: ColorMode) -> TokenStylesas the single source of truth for everystyle_*helper (text / dim / accent / alert / stale / border / highlight).style_fgremoved (dead code after refactor); all locked helper names/signatures/return-types unchanged — they now delegate totokens_for(color_mode()).tokens_for(color_mode())produces the same Styles as the old inline match arms.alert_linestill prefixes!in None mode;delivery_glyphstill falls back took/queued/sending/failed.Test evidence
cargo test --locked: 26/26 tui_spec, 6/6 tui_frames, 10/10 tui_chrome, 25 node + 9 wallet + 8 zeroize — 0 failures.cargo clippy --locked --all-targets -- -D warnings: clean.tests/tui_spec.rs:rgb_tokens_resolve_to_palette_fg— exact RGB fg for every role (highlight also asserts bg + bold).none_tokens_strip_colour_fg_and_alert_keeps_bold— None mode strips all fg/bg; accent=bold-only, highlight=bold+reversed.ansi16_tokens_use_ansi_colours— White/DarkGray/Red/Yellow; highlight=reversed+bold, no colour.tokens_for_is_deterministic_across_calls.alert_line_prefixes_when_no_color— NO_COLOR ->alert_lineprepends!.cargo test --locked --test tui_spec -- --nocapture dump_spec_framesstill dumps AFTER main/help/share at 80x24 and 120x40.cargo test --locked --test tui_spec ascii_switch_80x24_frame_is_pure_asciistill green underNO_COLOR.16-colour disambiguation (card deliverable 4)
tokens_for(ColorMode::Ansi16)gives alert=Red!= stale=Yellow(no collapse), and stale is never signalled by colour alone — roster rows append thestale/sword, focus uses the>marker, delivery states carry their word (queued/sending/failed) beside the glyph. UnderNO_COLOR(ColorMode::None) every role emits no fg and no bg — only modifiers — soNO_COLORterminals see no fg/bgStyleat all.Files
src/tui.rs—ColorModepub,color_modepub,TokenStyles+tokens_foradded,style_fgremoved,style_*helpers refactored to delegate.tests/tui_spec.rs— 5 new token-set tests; one pre-existingis_none()+unwrap()clippy lint fixed.PR
wt/t_49b7c2b1, basemain.6ce97a0(token extraction) ->d4b0071(clippy unnecessary_unwrap fix).