返回 CodeWhale
constants.rs
根目录 / crates / tui / src / tui / history / constants.rs
1 //! Shared constants for history transcript rendering.
2 //!
3 //! ## Live tool-card budgets
4 //!
5 //! The general command/output caps were measured against 53 real saved
6 //! sessions from `~/.codewhale/sessions` — 5,470 tool results, 4,001 of them
7 //! `Bash` (the "run" cards) and 3,777 `Bash` commands. Successful output uses
8 //! a smaller preview to reduce routine transcript noise; the details pager
9 //! retains the complete result.
10 //!
11 //! Observed `Bash` result length, in source lines:
12 //! `p25=3 p50=9 p75=25 p90=60 p95=113 max=1161`.
13 //!
14 //! Observed `Bash` command length: `p50=251 chars`, `p90=1404` — i.e. the
15 //! median command is multi-line once wrapped, not a one-liner.
16 //!
17 //! General command/output caps sit at the knee of their coverage curves: the
18 //! point past which more rows buy very little more content. Going further
19 //! chases a long tail that a single card should never try to hold — that is
20 //! what the details pager is for.
21
22 /// Wrapped rows of the *command* echoed inside a live tool card.
23 ///
24 /// Coverage of real `Bash` commands shown whole, at an 80-column terminal:
25 /// `3 → 45%`, `4 → 58%`, **`6 → 70%`**, `8 → 75%`, `10 → 77%`.
26 /// Six is the knee: +25 points over the old cap of 3, where 8 adds only 4
27 /// more and 10 only 2. At 3 the *median* command was clipped, which is the
28 /// "run cards never show enough" complaint at its source.
29 pub(super) const TOOL_COMMAND_LINE_LIMIT: usize = 6;
30
31 /// Failed generic and MCP results keep a six-row head/tail excerpt.
32 /// Full output remains available in the transcript and details pager.
33 pub(super) const TOOL_FAILURE_PREVIEW_LINES: usize = 6;
34
35 /// Wrapped rows of tool *output* shown in a live card before the details
36 /// affordance takes over.
37 ///
38 /// Fraction of real `Bash` results shown whole: `8 → 50%`, `12 → 60%`,
39 /// `16 → 68%`, **`20 → 72%`**, `24 → 75%`, `32 → 80%`.
40 /// Twenty covers three quarters of real results while still leaving half of
41 /// a 40-row terminal for everything else; 24 buys under three points for
42 /// four more rows.
43 pub(super) const TOOL_OUTPUT_LINE_LIMIT: usize = 20;
44
45 /// Rows of output a *successful* live `run` card shows before the details
46 /// affordance takes over. Two opening rows and one tail row retain a quick
47 /// read on what the command did while keeping routine successes quiet; failures
48 /// keep their larger preview budget. The full result remains in the details
49 /// transcript.
50 pub(super) const TOOL_SUCCESS_OUTPUT_PREVIEW_LINES: usize = 3;
51
52 pub(super) const TOOL_TEXT_LIMIT: usize = 300;
53
54 /// Characters of the summary shown after `·` in a tool-card header. Real
55 /// commands run far longer than any header (p50 = 251 chars), so this is a
56 /// glance budget, not a fit budget — the header line is width-clipped
57 /// downstream regardless. 72 keeps the header inside an 80-column terminal
58 /// while showing meaningfully more of the command on a wide one.
59 pub(super) const TOOL_HEADER_SUMMARY_LIMIT: usize = 72;
60
61 /// Contiguous rows taken from the start of a truncated output.
62 ///
63 /// `p50` of a real `Bash` result is 9 source lines, so a 10-row head shows
64 /// the whole opening of a median result rather than a fragment of it.
65 pub(super) const TOOL_OUTPUT_HEAD_LINES: usize = 10;
66
67 /// Contiguous rows taken from the end of a truncated output — where exit
68 /// status, totals, and error summaries land. Head + tail = 16 of the 20-row
69 /// budget, leaving 4 rows for importance-ranked lines from the middle.
70 pub(super) const TOOL_OUTPUT_TAIL_LINES: usize = 6;
71 #[cfg(test)]
72 pub(super) const TOOL_RUNNING_SYMBOLS: [&str; 8] = crate::tui::spinner::BRAILLE_SPINNER_FRAMES;
73 #[cfg(test)]
74 pub(super) const TOOL_STATUS_SYMBOL_MS: u64 = crate::tui::spinner::BRAILLE_SPINNER_FRAME_MS;
75 /// Visual marker for the user role at the start of their message line. Solid
76 /// vertical bar — no animation; user input is a finished thing.
77 pub(super) const USER_GLYPH: &str = crate::tui::glyphs::USER;
78 /// Visual marker for the assistant role. Solid bullet that pulses at 2s
79 /// cycle while the response is streaming, holds full brightness when idle.
80 pub(super) const ASSISTANT_GLYPH: &str = crate::tui::glyphs::CURRENT;
81 /// Transcript body left rail. Solid 1/8 block (`▏`) followed by a space —
82 /// used as a visual left-margin anchor for continuation lines, tool-card
83 /// detail rows, and affordance lines. Dimmed so it guides the eye without
84 /// competing with content.
85 pub(super) const TRANSCRIPT_RAIL: &str = crate::tui::glyphs::TRANSCRIPT_RAIL;
86 /// Total rendered rows a non-failed tool card keeps when `show_tool_details`
87 /// is off or calm mode is on — both shipped defaults, so this is the cap a user
88 /// actually sees.
89 ///
90 /// It was an unnamed literal `2`: header plus a single row, then an "expand"
91 /// affordance. Three rows spent to learn that *something* ran. Every other
92 /// budget in this file was invisible underneath it. Six rows is a header, up
93 /// to four rows of real content, and the affordance — enough to answer "what
94 /// did that do?" without opening anything, and still a card rather than a
95 /// wall. Failures are excluded from this path entirely and keep their full
96 /// budget.
97 pub(super) const TOOL_SUMMARY_CARD_LINES: usize = 6;
98
99 pub(super) const TOOL_DONE_SYMBOL: &str = crate::tui::glyphs::DONE;
100 pub(super) const TOOL_FAILED_SYMBOL: &str = crate::tui::glyphs::FAILED;
101 /// Compact Ctrl+B affordance for foreground shell waits in the live transcript.
102 pub(super) const FOREGROUND_SHELL_WAIT_HINT: &str = "Ctrl+B → /jobs";
103
103 lines RUST