返回 CodeWhale
phase_strip.rs
根目录 / crates / tui / src / tui / phase_strip.rs
1 //! The posture bar and the route-identity shedding it shares with the
2 //! metrics line.
3 //!
4 //! Two one-row bands sit under the composer and never trade places with
5 //! it: the **posture bar** (this module's widget — permission, mode, live
6 //! counts, the one hint that applies now, with the remote-control state or
7 //! a live notice pinned right) and the **metrics line**
8 //! (`crate::tui::infoline` — model, context, cost, ttft, tok/s, output
9 //! tokens). Both rows are reserved in every frame, so a turn moving between
10 //! idle, thinking, tool use, approval, completion, failure, and cancellation
11 //! changes text inside fixed rows and never displaces the composer.
12 //!
13 //! One owner per fact: the context reading and the price are the metrics
14 //! line's; mode, permission and the working clock are this bar's. The module
15 //! name is the historical one — the phase word it painted also lives in the
16 //! transcript's active row, but the bar keeps its own copy beside the clock
17 //! (#5914): a bare duration cannot say whether the session is producing
18 //! tokens or parked waiting on a tool, a sub-agent, or you.
19
20 use codewhale_ratatui::{PostureBar, PostureFact};
21 use ratatui::{buffer::Buffer, layout::Rect};
22 use unicode_width::UnicodeWidthStr;
23
24 use crate::tui::{
25 app::App,
26 underwater::{LiveActivity, ShellPhase, ShellTier, phase_marker_with_activity},
27 };
28 use codewhale_localization::{MessageId, tr};
29 use codewhale_palette::ChromeInk;
30
31 /// Fixed one-row reservation for the identity band below the composer.
32 #[must_use]
33 pub fn height() -> u16 {
34 1
35 }
36
37 /// Route identity for a rail or info line segment, shed field by field until it
38 /// fits `budget`.
39 ///
40 /// The old version composed the full `provider · model · effort` label and
41 /// then `truncate_to_width`'d it to a fixed 24/44/64 columns, which happily
42 /// rendered `deepseek-v4-flash-prev…`. A clipped model name is worse than no
43 /// model name: routes share prefixes, so the ellipsis is the rail admitting
44 /// it will not tell you which model is answering. Shed the qualifiers
45 /// instead — provider first, then effort — and if the bare model name still
46 /// does not fit, shed the whole group. `/model` and `/status` own the full
47 /// route either way.
48 pub(crate) fn route_identity_fields(
49 app: &App,
50 tier: ShellTier,
51 budget: usize,
52 ) -> Option<Vec<RouteIdentityField>> {
53 let (provider, model) = app.effective_route_identity_display();
54 // A route that cannot prove its effective tier states no effort field
55 // rather than `high→effective unavailable` (#5950): a placeholder that
56 // can never resolve is noise, not a reading. First-party routes keep
57 // their tier, `auto: tier` and `req→eff` labels.
58 // Labeled, so a bare "max" never sits on the row unexplained (mark 8).
59 let effort = app
60 .provable_reasoning_effort_label()
61 .map(|level| {
62 app.tr(MessageId::InfoLineThinking)
63 .replace("{level}", &level)
64 })
65 .unwrap_or_default();
66 if model.is_empty() {
67 return None;
68 }
69 let field = |kind, text: String| RouteIdentityField { kind, text };
70 let mut candidates: Vec<Vec<RouteIdentityField>> = Vec::new();
71 if tier != ShellTier::Compact && !provider.is_empty() {
72 // The smallest shell never repeats the provider: model and effort are
73 // the two facts that change what comes back.
74 let mut fields = vec![
75 field(RouteFieldKind::Provider, provider),
76 field(RouteFieldKind::Model, model.clone()),
77 ];
78 if !effort.is_empty() {
79 fields.push(field(RouteFieldKind::Effort, effort.clone()));
80 }
81 candidates.push(fields);
82 }
83 if !effort.is_empty() {
84 candidates.push(vec![
85 field(RouteFieldKind::Model, model.clone()),
86 field(RouteFieldKind::Effort, effort),
87 ]);
88 }
89 candidates.push(vec![field(RouteFieldKind::Model, model)]);
90 candidates.into_iter().find(|fields| {
91 let width = fields.iter().map(|field| field.text.width()).sum::<usize>()
92 + fields.len().saturating_sub(1) * ITEM_SEPARATOR_WIDTH;
93 width <= budget
94 })
95 }
96
97 /// Which route fact a rendered field is. The info line needs this to send a
98 /// click to the surface that owns the fact the user pointed at: the provider
99 /// name to `/provider`, the model and its effort tier to `/model`.
100 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
101 pub(crate) enum RouteFieldKind {
102 Provider,
103 Model,
104 Effort,
105 }
106
107 /// One rendered route field: what it says, and what it is.
108 #[derive(Debug, Clone, PartialEq, Eq)]
109 pub(crate) struct RouteIdentityField {
110 pub kind: RouteFieldKind,
111 pub text: String,
112 }
113
114 /// The info line's route budget: reserve 60 columns for other metrics, with
115 /// a floor that grows from 24 to 32 columns with half the row's width. This
116 /// keeps longer effort labels at 80 columns without crowding narrower rows.
117 ///
118 /// One owner. The rule used to be written out at the call site in
119 /// `ui/frame.rs` and copied again into two tests with a comment pointing
120 /// back at the original, which is how a shed rule drifts.
121 pub(crate) fn info_route_budget(width: u16) -> usize {
122 let width = usize::from(width);
123 width.saturating_sub(60).max((width / 2).clamp(24, 32))
124 }
125
126 /// Split a notice at its joints, coarsest first.
127 ///
128 /// A rail notice is prose, and prose has joints. Cutting at a joint keeps
129 /// every word that survives true; cutting mid-phrase and hanging an ellipsis
130 /// off the end only advertises that the row lost the argument. Sentence stops
131 /// are the joint we want; the inner marks are the fallback for a one-sentence
132 /// notice that is still too long for a narrow rail — losing the second half
133 /// of `Auto-denied exec_shell: denied earlier` beats losing the warning.
134 fn notice_clauses<'a>(text: &'a str, marks: &[char]) -> Vec<&'a str> {
135 let mut clauses = Vec::new();
136 let mut start = 0usize;
137 let mut chars = text.char_indices().peekable();
138 while let Some((idx, ch)) = chars.next() {
139 if !marks.contains(&ch) {
140 continue;
141 }
142 // Full-width marks carry no trailing space, so they break on sight.
143 // ASCII marks only break before whitespace, which keeps `0.9.11`,
144 // `docs/TELEMETRY.md`, and `https://…` in one piece.
145 let breaks = !ch.is_ascii() || chars.peek().is_none_or(|(_, next)| next.is_whitespace());
146 if !breaks {
147 continue;
148 }
149 // `1.` opening a numbered step is a list ordinal, not a sentence
150 // stop — breaking there leaves the toast ending on a bare `1.`
151 // (the send-blocked clip: `…not found. 1.`). Only the pure
152 // number-and-stop shape is exempt; `Version 1.` still ends a clause.
153 if ch == '.'
154 && text[start..idx].trim().bytes().all(|b| b.is_ascii_digit())
155 && !text[start..idx].trim().is_empty()
156 {
157 continue;
158 }
159 let end = idx + ch.len_utf8();
160 let clause = text[start..end].trim();
161 if !clause.is_empty() {
162 clauses.push(clause);
163 }
164 start = end;
165 }
166 let rest = text[start..].trim();
167 if !rest.is_empty() {
168 clauses.push(rest);
169 }
170 clauses
171 }
172
173 /// Sentence stops — the joint a notice prefers to be cut at.
174 const SENTENCE_MARKS: [char; 7] = ['.', '!', '?', '…', '。', '!', '?'];
175 /// Inner joints, used only when one sentence still will not fit the rail.
176 const CLAUSE_MARKS: [char; 8] = [';', ':', ',', '—', ';', ':', ',', '、'];
177
178 fn join_while_fitting(clauses: &[&str], budget: usize) -> Option<String> {
179 let mut fitted = String::new();
180 for clause in clauses {
181 // A full-width stop already carries its own breathing room; putting
182 // a Latin space after `。` is a typographic accent in the wrong
183 // language.
184 let space = usize::from(!fitted.is_empty() && fitted.ends_with(|ch: char| ch.is_ascii()));
185 let candidate = fitted.width() + space + clause.width();
186 if candidate > budget {
187 break;
188 }
189 if space == 1 {
190 fitted.push(' ');
191 }
192 fitted.push_str(clause);
193 }
194 // A phrase that ends on `:` or `;` is still telling you more is coming —
195 // the same lie an ellipsis tells. Cut the mark and let the phrase stand.
196 let fitted = fitted
197 .trim_end_matches(|ch| CLAUSE_MARKS.contains(&ch) || ch == ' ')
198 .to_string();
199 (!fitted.is_empty()).then_some(fitted)
200 }
201
202 /// Fit a notice into `budget` by dropping whole trailing clauses.
203 ///
204 /// Returns `None` only when not even the first inner phrase fits, and the
205 /// rail then says nothing rather than dangling a stump. Notices get first
206 /// call on the row: identity and the ledger chips have already stood down by
207 /// the time this is asked, and the key hints stand down after it if that is
208 /// what the notice needs.
209 fn fit_notice(text: &str, budget: usize) -> Option<String> {
210 let text = text.trim();
211 if text.is_empty() || budget == 0 {
212 return None;
213 }
214 if text.width() <= budget {
215 return Some(text.to_string());
216 }
217 let sentences = notice_clauses(text, &SENTENCE_MARKS);
218 if let Some(fitted) = join_while_fitting(&sentences, budget) {
219 return Some(fitted);
220 }
221 let first = sentences.first().copied().unwrap_or(text);
222 let clauses = notice_clauses(first, &CLAUSE_MARKS);
223 let fitted = join_while_fitting(&clauses, budget)?;
224 // A one-word label whose value was shed is not a notice, it is a false
225 // one: `Thinking: high → max · model qwen` cut to `Thinking` sat in an
226 // idle footer reading as if a turn were thinking (experience mark 8).
227 // A phrase before the colon (`Auto-denied exec_shell`) still stands.
228 let bare_label = clauses
229 .first()
230 .is_some_and(|label| label.ends_with([':', ':']))
231 && !fitted.contains(char::is_whitespace);
232 (!bare_label).then_some(fitted)
233 }
234
235 /// Map the boot surface's typed severity through the same semantic palette as
236 /// every other footer fact. Keeping this conversion closed makes the plugin
237 /// warning/failure distinction testable without guessing from its text.
238 fn boot_activity_ink(level: crate::tui::session_boot::SessionBootActivityLevel) -> ChromeInk {
239 match level {
240 crate::tui::session_boot::SessionBootActivityLevel::Active => ChromeInk::Active,
241 crate::tui::session_boot::SessionBootActivityLevel::Attention => ChromeInk::Attention,
242 crate::tui::session_boot::SessionBootActivityLevel::Failure => ChromeInk::Failure,
243 }
244 }
245
246 /// Pick the notice a band owes its row to right now, if any. Shared by the
247 /// classic activity band and the Tideline merged footer so the two can never
248 /// disagree about which toast is live. Completion may land in the same event
249 /// drain as an approval denial: unresolved Warning/Error receipts stay
250 /// visible after `done`, only routine informational copy yields.
251 fn selected_notice(
252 status_toast: Option<crate::tui::app::StatusToast>,
253 phase_label: &str,
254 ) -> Option<(String, ChromeInk, bool)> {
255 status_toast
256 .filter(|toast| !toast.text.trim().is_empty() && toast.text.trim() != phase_label)
257 .map(|toast| {
258 let urgent = matches!(
259 toast.level,
260 crate::tui::app::StatusToastLevel::Warning
261 | crate::tui::app::StatusToastLevel::Error
262 );
263 (toast.text.clone(), toast.level.ink(), urgent)
264 })
265 }
266
267 /// Provider/model fields retain their internal separator width when shed.
268 const ITEM_SEPARATOR_WIDTH: usize = 3;
269
270 #[cfg(test)]
271 mod tests {
272 use super::*;
273 use crate::{config::Config, tui::app::TuiOptions};
274 use std::path::PathBuf;
275
276 fn test_app() -> App {
277 App::new(
278 TuiOptions {
279 model: "deepseek-v4-flash".to_string(),
280 ..crate::test_support::test_tui_options(PathBuf::from("."))
281 },
282 &Config::default(),
283 )
284 }
285
286 #[test]
287 fn done_footer_preserves_unresolved_notice_behind_later_routine_info() {
288 use crate::tui::app::StatusToastLevel;
289 for (level, ink) in [
290 (StatusToastLevel::Warning, ChromeInk::Attention),
291 (StatusToastLevel::Error, ChromeInk::Failure),
292 ] {
293 let mut app = test_app();
294 app.runtime_turn_status = Some("completed".into());
295 app.push_status_toast("Unresolved issue", level, Some(12_000));
296 app.push_status_toast("Routine update", StatusToastLevel::Info, Some(5_000));
297 assert_eq!(ShellPhase::from_app(&app), ShellPhase::Done);
298 assert!(
299 app.history.is_empty(),
300 "the transcript must not satisfy this fixture"
301 );
302 let facts = tideline_footer_from_app(&mut app, 140);
303 assert_eq!(facts.right, Some(("Unresolved issue".into(), ink)));
304 let mut buf = Buffer::empty(Rect::new(0, 0, 140, 1));
305 render_tideline_footer(
306 Rect::new(0, 0, 140, 1),
307 &mut buf,
308 &facts.widget(&app.ui_theme, false),
309 );
310 let text: String = buf.content.iter().map(|cell| cell.symbol()).collect();
311 assert!(text.contains("Unresolved issue"), "{text}");
312 assert!(!text.contains("Routine update"));
313 }
314 }
315
316 #[test]
317 fn boot_activity_levels_keep_plugin_attention_and_failure_distinct() {
318 use crate::tui::session_boot::SessionBootActivityLevel;
319
320 assert_eq!(
321 boot_activity_ink(SessionBootActivityLevel::Active),
322 ChromeInk::Active
323 );
324 assert_eq!(
325 boot_activity_ink(SessionBootActivityLevel::Attention),
326 ChromeInk::Attention
327 );
328 assert_eq!(
329 boot_activity_ink(SessionBootActivityLevel::Failure),
330 ChromeInk::Failure
331 );
332 }
333
334 #[test]
335 fn notice_clauses_split_on_sentences_and_keep_versions_and_paths_whole() {
336 assert_eq!(
337 notice_clauses(
338 "Counts are on. Code is never collected. See docs/T.md",
339 &SENTENCE_MARKS
340 ),
341 vec![
342 "Counts are on.",
343 "Code is never collected.",
344 "See docs/T.md"
345 ]
346 );
347 assert_eq!(
348 notice_clauses("Updated to 0.9.11 from 0.9.10", &SENTENCE_MARKS),
349 vec!["Updated to 0.9.11 from 0.9.10"]
350 );
351 // Full-width stops carry no trailing space, so they break on sight.
352 assert_eq!(
353 notice_clauses(
354 "匿名の利用回数は有効です。会話とコードは収集されません。",
355 &SENTENCE_MARKS
356 ),
357 vec![
358 "匿名の利用回数は有効です。",
359 "会話とコードは収集されません。"
360 ]
361 );
362 // A colon inside a URL is not a joint.
363 assert_eq!(
364 notice_clauses("Docs: https://example.test/x", &CLAUSE_MARKS),
365 vec!["Docs:", "https://example.test/x"]
366 );
367 }
368
369 #[test]
370 fn shed_clauses_rejoin_without_a_latin_space_after_a_full_width_stop() {
371 const JA: &str = "匿名の利用状況集計はオンです。会話やコードは一切収集しません。/settings で変更できます。スキーマ: docs/TELEMETRY.md";
372 let clauses = notice_clauses(JA, &SENTENCE_MARKS);
373 let joined = join_while_fitting(&clauses, 200).expect("fits");
374 assert!(!joined.contains("。 "), "{joined:?}");
375 assert!(joined.ends_with("docs/TELEMETRY.md"), "{joined:?}");
376 }
377
378 #[test]
379 fn a_notice_sheds_whole_clauses_and_never_dangles() {
380 const NOTICE: &str = "Anonymous usage counts are on. Conversations and code are never collected. Change this in /settings; schema: docs/TELEMETRY.md";
381 assert_eq!(fit_notice(NOTICE, 200).as_deref(), Some(NOTICE));
382 assert_eq!(
383 fit_notice(NOTICE, 80).as_deref(),
384 Some("Anonymous usage counts are on. Conversations and code are never collected.")
385 );
386 assert_eq!(
387 fit_notice(NOTICE, 40).as_deref(),
388 Some("Anonymous usage counts are on.")
389 );
390 assert_eq!(fit_notice(" ", 40), None);
391 }
392
393 /// Experience mark 8: a `/model` thinking change on a narrow rail used to
394 /// shed to a bare `Thinking`, which read as a live indicator with nothing
395 /// running. A label whose value cannot fit says nothing instead.
396 #[test]
397 fn a_label_never_sheds_to_a_bare_word_that_reads_as_activity() {
398 let notice = "Thinking: high → max · model deepseek-v4-flash";
399 assert_eq!(fit_notice(notice, 40), None);
400 assert_eq!(
401 fit_notice("思考:高 → 最高 · 模型 deepseek-v4-flash", 12),
402 None
403 );
404 // Room for the whole reading keeps it whole.
405 assert_eq!(fit_notice(notice, 60).as_deref(), Some(notice));
406 // A phrase before the colon is still a notice on its own.
407 assert_eq!(
408 fit_notice("Auto-denied exec_shell: denied earlier this turn", 30).as_deref(),
409 Some("Auto-denied exec_shell")
410 );
411 }
412
413 /// The failure this caught: a one-sentence warning longer than the row
414 /// used to have no sentence joint to shed at, so the rail dropped the
415 /// whole warning. Inner joints are the fallback, and the phrase that
416 /// survives never ends on a `:` or `;` — that mark says "more is coming"
417 /// as loudly as an ellipsis does.
418 #[test]
419 fn a_clause_less_warning_sheds_at_inner_joints_rather_than_vanishing() {
420 const WARNING: &str =
421 "Auto-denied exec_shell: denied earlier; restart Codewhale to re-enable it.";
422 assert_eq!(fit_notice(WARNING, 120).as_deref(), Some(WARNING));
423 assert_eq!(
424 fit_notice(WARNING, 60).as_deref(),
425 Some("Auto-denied exec_shell: denied earlier")
426 );
427 assert_eq!(
428 fit_notice(WARNING, 30).as_deref(),
429 Some("Auto-denied exec_shell")
430 );
431 }
432
433 #[test]
434 fn session_metrics_strip_is_on_by_default() {
435 assert!(
436 crate::config::StatusItem::default_footer().contains(&crate::config::StatusItem::Ttft)
437 && crate::config::StatusItem::default_footer()
438 .contains(&crate::config::StatusItem::OutputRate)
439 );
440 assert_eq!(
441 crate::config::StatusItem::from_key("session_metrics"),
442 Some(crate::config::StatusItem::SessionMetrics)
443 );
444 }
445
446 /// The route identity (the info line Model segment's value) sheds whole
447 /// fields — provider first, then the effort label — and stands down
448 /// entirely rather than clip a model name. Ported from the identity
449 /// band to `route_identity_fields`, the live shedding authority the
450 /// info line calls with the same budget rule.
451 #[test]
452 fn route_identity_sheds_qualifiers_before_it_would_clip_a_model_name() {
453 let model = "deepseek-v4-flash-preview-2026-05-01";
454 let mut app = App::new(
455 TuiOptions {
456 model: model.to_string(),
457 ..crate::test_support::test_tui_options(PathBuf::from("."))
458 },
459 &Config::default(),
460 );
461 app.ui_locale = codewhale_localization::Locale::En;
462
463 // Use the info line's own budget rule, including its adaptive floor.
464 let fields = |width: u16| {
465 route_identity_fields(
466 &app,
467 ShellTier::for_chrome_width(width),
468 info_route_budget(width),
469 )
470 };
471
472 let wide = fields(140).expect("wide budget keeps the route");
473 assert!(
474 wide.iter().any(|f| f.text.contains("DeepSeek"))
475 && wide.iter().any(|f| f.text == model),
476 "{wide:?}"
477 );
478
479 // Below the group's width the provider sheds first; the model stays
480 // whole or the whole group stands down — never a clipped name.
481 for width in [30u16, 34, 40, 46, 50, 60] {
482 let shed = fields(width).unwrap_or_default();
483 for field in &shed {
484 assert!(
485 !field.text.contains('…'),
486 "{width} dangled a clipped field: {shed:?}"
487 );
488 }
489 if shed.iter().any(|f| f.text.contains("deepseek-v4-flash-p")) {
490 assert!(
491 shed.iter().any(|f| f.text == model),
492 "{width} clipped the model name: {shed:?}"
493 );
494 }
495 }
496 }
497
498 /// A named custom route can carry a long provider identity next to a
499 /// long model id; whole fields shed (provider first, effort label next)
500 /// and neither name is ever clipped. Ported from the identity band to
501 /// `route_identity_fields`.
502 #[test]
503 fn unproven_effort_keeps_named_provider_when_the_route_fits() {
504 let mut app = test_app();
505 app.set_provider_identity(crate::config::ProviderKind::Custom, "lab-gateway");
506 app.model = "unlisted-model".to_string();
507 assert!(app.provable_reasoning_effort_label().is_none());
508 let fields = route_identity_fields(&app, ShellTier::for_chrome_width(160), 100).unwrap();
509 assert_eq!(
510 fields.iter().map(|field| field.kind).collect::<Vec<_>>(),
511 vec![RouteFieldKind::Provider, RouteFieldKind::Model]
512 );
513 assert_eq!(fields[0].text, "lab-gateway");
514 assert_eq!(fields[1].text, "unlisted-model");
515 let compact = route_identity_fields(&app, ShellTier::Compact, 100).unwrap();
516 assert_eq!(compact.len(), 1);
517 assert_eq!(compact[0].kind, RouteFieldKind::Model);
518 let narrow = route_identity_fields(&app, ShellTier::for_chrome_width(160), 14).unwrap();
519 assert_eq!(narrow.len(), 1);
520 assert_eq!(narrow[0].text, "unlisted-model");
521 }
522
523 #[test]
524 fn long_custom_route_names_shed_whole_fields_across_width_tiers() {
525 let model = "deepseek-v4-flash-vision-preview-2026-08-01";
526 let mut app = test_app();
527 app.ui_locale = codewhale_localization::Locale::En;
528 app.set_provider_identity(
529 crate::config::ProviderKind::Custom,
530 "acme-research-gateway-eu-central",
531 );
532 app.model = model.to_string();
533
534 for width in [30u16, 40, 50, 60, 70, 80, 160] {
535 let shed = route_identity_fields(
536 &app,
537 ShellTier::for_chrome_width(width),
538 info_route_budget(width),
539 )
540 .unwrap_or_default();
541 for field in &shed {
542 assert!(
543 !field.text.contains('…'),
544 "{width} dangled a clipped field: {shed:?}"
545 );
546 }
547 if shed
548 .iter()
549 .any(|f| f.text.contains("deepseek-v4-flash-vision"))
550 {
551 assert!(
552 shed.iter().any(|f| f.text == model),
553 "{width} clipped the model name: {shed:?}"
554 );
555 }
556 assert!(
557 !shed
558 .iter()
559 .any(|f| f.text.contains("acme-research-gateway-eu-c")
560 && f.text != "acme-research-gateway-eu-central"),
561 "{width} clipped the provider name: {shed:?}"
562 );
563 }
564 }
565 }
566
567 // ---------------------------------------------------------------------------
568 // Tideline merged footer (spec §3 slots 6+8 merged, §5a "Footer"): one
569 // band — phase·cost on the left, the notice/keys slot on the right.
570 // Wired into `ui/frame.rs` as the shell's single footer row: the classic
571 // activity band (slot 6) and identity band (slot 8) collapsed into it, with
572 // the old header's mode/permission chips carried in the left half per §3.
573 // ---------------------------------------------------------------------------
574 // The posture bar (SHELL-DESIGN-20260901 §2.0 item 3, §2.3b; founder
575 // direction 2026-09-02): the first row under the composer, in Claude Code's
576 // grammar —
577 //
578 // ● full access Shift+Tab to change work (Tab) 2 agents, 1 task Esc to interrupt rc connected
579 //
580 // permission chip first (never sheds, #5796), marked `●` so the current
581 // permission reads without color (experience mark 8) and followed by what
582 // its key does, then the mode, the turn clock, the
583 // live counts, the session clock, then the one hint that applies right now;
584 // the remote-control state or a live notice pinned right. No cost: the
585 // roster owns per-agent elapsed and the metrics line owns the price. The
586 // context reading is the metrics line's; this row only says what to do about
587 // it at the cap.
588 //
589 // The clock came back in #5914. It was the `worked Nm Ss` chip on the
590 // classic footer until `146ab7f756` deleted that path, and the phase band's
591 // `working_detail` until `329960fcbf` (the 0.9.12 mega shell) merged the
592 // bands and left the elapsed reading to the transcript's active row. A
593 // multi-hour operate session scrolls that row out of sight, so the founder
594 // looking straight at the screen had no way to tell how long the session had
595 // been working or whether the current turn was stuck. The fixed row is where
596 // a glancing user looks; the clock lives here.
597 // ---------------------------------------------------------------------------
598
599 /// The context cap warning at ≥80% (spec §5a/§5e). The reading itself lives
600 /// in the metrics line; this bar still says what to do about it.
601 const DEPTH_WARN: &str = "surface soon — /compact";
602
603 /// What the caller owes the posture bar. All injected, deterministic.
604 pub struct TidelineFooter<'a> {
605 pub theme: &'a codewhale_palette::UiTheme,
606 /// Permission chip (`ask` / `auto` / `full access`, plus the filesystem
607 /// scope notice when it deviates) in its Permission ink. Never sheds.
608 pub permission_chip: (&'a str, codewhale_palette::ChromeInk),
609 /// What the permission key does, when the binding is live for the
610 /// current focus and not yet learned (`Shift+Tab to change`). Painted
611 /// after the chip in hint ink.
612 pub permission_key: Option<&'a str>,
613 /// Mode chip (`work` / `plan` / `operate`) in its Policy ink.
614 pub mode_chip: Option<(&'a str, codewhale_palette::ChromeInk)>,
615 /// The chord that cycles the mode, when the binding is live (`Tab`).
616 pub mode_key: Option<&'a str>,
617 /// The turn half of the working clock (`working 1m 15s`): what the
618 /// session is doing right now and for how long. `None` between turns.
619 pub turn_clock: Option<(&'a str, codewhale_palette::ChromeInk)>,
620 /// Live counts (`2 agents`, `1 task`) in their own inks, joined with
621 /// `, `.
622 pub counts: &'a [(String, ChromeInk)],
623 /// The session half of the working clock (`worked 41m 12s`): how long
624 /// this session has actually worked — the reading the founder went
625 /// looking for and could not find (#5914). Outlives the turn half, and
626 /// sheds before the hint and the counts. `None` until the session has
627 /// worked a minute, and while it would repeat the turn reading (#6041).
628 pub session_clock: Option<(&'a str, codewhale_palette::ChromeInk)>,
629 /// The one hint that applies right now (`Esc to interrupt`).
630 pub hint: Option<(&'a str, codewhale_palette::ChromeInk)>,
631 /// Context window percentage 0–100. The metrics line paints the reading;
632 /// this bar only uses it to decide whether the ≥80% cap warning outranks
633 /// `hint`.
634 pub context_percent: u8,
635 /// Pinned right: a live notice (status toast / boot activity chip) or
636 /// the remote-control state.
637 pub right: Option<(&'a str, codewhale_palette::ChromeInk)>,
638 pub ascii_safe: bool,
639 /// `tui.posture_bar = "compact"` (#5950): start the shed ladder at
640 /// the kit's compact rung instead of rung 0, so the row states its posture —
641 /// the permission and mode chips, and the cap warning when it is owed —
642 /// and nothing live. Width sheds the rest exactly as it always did.
643 pub compact: bool,
644 }
645
646 impl<'a> TidelineFooter<'a> {
647 #[must_use]
648 pub fn new(
649 theme: &'a codewhale_palette::UiTheme,
650 permission_chip: (&'a str, codewhale_palette::ChromeInk),
651 ) -> Self {
652 Self {
653 theme,
654 permission_chip,
655 permission_key: None,
656 mode_chip: None,
657 mode_key: None,
658 turn_clock: None,
659 counts: &[],
660 session_clock: None,
661 hint: None,
662 context_percent: 0,
663 right: None,
664 ascii_safe: false,
665 compact: false,
666 }
667 }
668
669 #[must_use]
670 pub fn permission_key(mut self, key: Option<&'a str>) -> Self {
671 self.permission_key = key;
672 self
673 }
674
675 #[must_use]
676 pub fn mode_chip(mut self, chip: Option<(&'a str, codewhale_palette::ChromeInk)>) -> Self {
677 self.mode_chip = chip;
678 self
679 }
680
681 #[must_use]
682 pub fn mode_key(mut self, key: Option<&'a str>) -> Self {
683 self.mode_key = key;
684 self
685 }
686
687 #[must_use]
688 pub fn turn_clock(mut self, clock: Option<(&'a str, codewhale_palette::ChromeInk)>) -> Self {
689 self.turn_clock = clock;
690 self
691 }
692
693 #[must_use]
694 pub fn session_clock(mut self, clock: Option<(&'a str, codewhale_palette::ChromeInk)>) -> Self {
695 self.session_clock = clock;
696 self
697 }
698
699 #[must_use]
700 pub fn counts(mut self, counts: &'a [(String, ChromeInk)]) -> Self {
701 self.counts = counts;
702 self
703 }
704
705 #[must_use]
706 pub fn hint(mut self, hint: Option<(&'a str, codewhale_palette::ChromeInk)>) -> Self {
707 self.hint = hint;
708 self
709 }
710
711 #[must_use]
712 pub fn context_percent(mut self, percent: u8) -> Self {
713 self.context_percent = percent;
714 self
715 }
716
717 #[must_use]
718 pub fn right(mut self, right: Option<(&'a str, codewhale_palette::ChromeInk)>) -> Self {
719 self.right = right;
720 self
721 }
722
723 #[must_use]
724 pub fn ascii_safe(mut self, ascii_safe: bool) -> Self {
725 self.ascii_safe = ascii_safe;
726 self
727 }
728
729 #[must_use]
730 pub fn compact(mut self, compact: bool) -> Self {
731 self.compact = compact;
732 self
733 }
734
735 fn kit(&self) -> PostureBar<'_> {
736 use crate::tui::infoline::ink_role;
737 // Preserve every host ink in a distinct role, including the right
738 // fact: the current kit does not retain right.ink through layout.
739 // The shared adapter maps these identities to the live UiTheme.
740 let mut bar = PostureBar::new(self.permission_chip.0)
741 .permission_role(ink_role(self.permission_chip.1))
742 .context_percent(self.context_percent)
743 .cap_warning(DEPTH_WARN)
744 .compact(self.compact);
745 bar.permission_key = self.permission_key.map(Into::into);
746 bar.mode = self.mode_chip.map(posture_fact);
747 bar.mode_key = self.mode_key.map(Into::into);
748 bar.turn_clock = self.turn_clock.map(posture_fact);
749 bar.counts = self
750 .counts
751 .iter()
752 .map(|(text, ink)| PostureFact::new(text.as_str(), ink_role(*ink)))
753 .collect();
754 bar.session_clock = self.session_clock.map(posture_fact);
755 bar.hint = self.hint.map(posture_fact);
756 bar.right = self.right.map(posture_fact);
757 bar
758 }
759 }
760
761 fn posture_fact((text, ink): (&str, ChromeInk)) -> PostureFact<'_> {
762 PostureFact::new(text, crate::tui::infoline::ink_role(ink))
763 }
764
765 #[cfg(test)]
766 fn tchrome(
767 theme: &codewhale_palette::UiTheme,
768 ink: codewhale_palette::ChromeInk,
769 ) -> ratatui::style::Style {
770 codewhale_palette::grammar::chrome_style(theme, ink)
771 }
772
773 /// Paint the posture bar and return each live count's exact visible cells.
774 /// The kit owns the one shared shedding, projection, clipping and pointer
775 /// layout. Engine facts, localized text, clock lifecycle, live theme and
776 /// action routing remain with the callers.
777 pub fn render_tideline_footer(
778 area: Rect,
779 buf: &mut Buffer,
780 footer: &TidelineFooter<'_>,
781 ) -> Vec<(usize, Rect)> {
782 use crate::tui::infoline::{paint_native_row, source_theme};
783 let area = area.intersection(buf.area);
784 let bar = footer.kit();
785 let count_rects = bar.count_hitboxes(area, &source_theme(footer.ascii_safe));
786 paint_native_row(&bar, area, buf, footer.theme, footer.ascii_safe);
787 count_rects
788 }
789
790 /// Owned posture facts, built from real `App` state at render time and lent
791 /// to [`TidelineFooter`] for painting.
792 pub(crate) struct TidelineFooterFacts {
793 pub permission_chip: (String, codewhale_palette::ChromeInk),
794 /// `Shift+Tab to change`, localized, while the binding is live and not
795 /// yet learned.
796 pub permission_key: Option<String>,
797 pub mode_chip: Option<(String, codewhale_palette::ChromeInk)>,
798 pub mode_key: Option<&'static str>,
799 pub turn_clock: ClockReading,
800 pub counts: Vec<(String, ChromeInk)>,
801 pub session_clock: ClockReading,
802 /// The action each entry of `counts` runs when clicked — same
803 /// length, same order.
804 pub count_actions: Vec<crate::tui::tideline::InteractionAction>,
805 pub hint: Option<(String, codewhale_palette::ChromeInk)>,
806 pub context_percent: u8,
807 pub right: Option<(String, codewhale_palette::ChromeInk)>,
808 }
809
810 impl TidelineFooterFacts {
811 /// Borrow the facts as the deterministic widget's input.
812 pub(crate) fn widget<'a>(
813 &'a self,
814 theme: &'a codewhale_palette::UiTheme,
815 ascii_safe: bool,
816 ) -> TidelineFooter<'a> {
817 let borrow = |chip: &'a Option<(String, ChromeInk)>| {
818 chip.as_ref().map(|(text, ink)| (text.as_str(), *ink))
819 };
820 TidelineFooter::new(
821 theme,
822 (self.permission_chip.0.as_str(), self.permission_chip.1),
823 )
824 .permission_key(self.permission_key.as_deref())
825 .mode_chip(borrow(&self.mode_chip))
826 .mode_key(self.mode_key)
827 .turn_clock(borrow(&self.turn_clock))
828 .counts(&self.counts)
829 .session_clock(borrow(&self.session_clock))
830 .hint(borrow(&self.hint))
831 .context_percent(self.context_percent)
832 .right(borrow(&self.right))
833 .ascii_safe(ascii_safe)
834 }
835 }
836
837 /// The session has to have worked this long before the bar states a total.
838 /// A fresh launch that says `worked 4s` is furniture, not information; the
839 /// classic footer's `worked` chip used the same floor (#448).
840 const CLOCK_SESSION_FLOOR_SECS: u64 = 60;
841
842 /// One half of the working clock: its text and the ink that says whether the
843 /// clock is running. `None` when that half has nothing true to say.
844 pub(crate) type ClockReading = Option<(String, ChromeInk)>;
845
846 /// The working clock (#5914), as its two halves — `(turn, session)`.
847 ///
848 /// * the **turn** reading is `{phase_label} {elapsed}` — the phase word is
849 /// the transcript's own, so `working 1m 15s` and `waiting on you 1m 15s`
850 /// and `sub-agents underway 1m 15s` all say what the clock is counting.
851 /// A duration alone cannot distinguish a session producing tokens from one
852 /// parked on a tool, a sub-agent, or an unanswered prompt. `None` between
853 /// turns: there is no turn to time.
854 /// * the **session** reading is the classic `worked {elapsed}` chip (#448):
855 /// `App::cumulative_turn_duration` (the sum of finished turns) plus the
856 /// live turn, so it ticks continuously and never jumps at `TurnComplete`.
857 /// It is model work, not wall clock since launch — an idle TUI does not
858 /// claim to have been working. Quiet ink while no turn is running, because
859 /// the clock is stopped. Suppressed while it would repeat the turn
860 /// reading — on a session's first turn the two are the same duration
861 /// (#6041); it returns as soon as a finished turn makes the totals
862 /// different.
863 pub(crate) fn working_clock(
864 app: &App,
865 phase: ShellPhase,
866 phase_label: &str,
867 ) -> (ClockReading, ClockReading) {
868 let turn = app.turn_started_at.map(|started| started.elapsed());
869 let ink = match phase {
870 ShellPhase::Waiting | ShellPhase::Approval => ChromeInk::Waiting,
871 ShellPhase::Failed => ChromeInk::Attention,
872 _ => ChromeInk::Active,
873 };
874 let turn_clock = turn.map(|turn| {
875 (
876 format!(
877 "{phase_label} {}",
878 crate::elapsed::format_elapsed_secs(turn.as_secs())
879 ),
880 ink,
881 )
882 });
883 let worked = app
884 .cumulative_turn_duration
885 .saturating_add(turn.unwrap_or_default());
886 // #6041: on a session's first turn there is no finished-turn total, so
887 // the session reading would print the same duration the turn reading
888 // already carries. The turn half names what is happening; the worked
889 // chip earns its place only once a finished turn makes it a different
890 // number.
891 let repeats_turn = turn.is_some_and(|turn| turn.as_secs() == worked.as_secs());
892 let session_clock =
893 (worked.as_secs() >= CLOCK_SESSION_FLOOR_SECS && !repeats_turn).then(|| {
894 (
895 tr(app.ui_locale, MessageId::FooterWorkedChip).replace(
896 "{duration}",
897 &crate::elapsed::format_elapsed_secs(worked.as_secs()),
898 ),
899 if turn.is_some() {
900 ink
901 } else {
902 ChromeInk::MetadataValue
903 },
904 )
905 });
906 (turn_clock, session_clock)
907 }
908
909 /// Context window percentage — the snapshot the metrics line's reading
910 /// paints, and the posture bar's ≥80% cap-warning trigger.
911 pub(crate) fn context_percent_from_app(app: &App) -> u8 {
912 crate::tui::ui::context_usage_snapshot(app)
913 .map(|(_, _, percent)| percent.round().clamp(0.0, 100.0) as u8)
914 .unwrap_or(0)
915 }
916
917 /// The live counts: running sub-agents, live shells, background tasks, and
918 /// scheduled automation. Each count is zero-suppressed — the bar never
919 /// grows furniture for work that is not happening.
920 fn live_counts(
921 app: &App,
922 tier: ShellTier,
923 ) -> (
924 Vec<(String, ChromeInk)>,
925 Vec<crate::tui::tideline::InteractionAction>,
926 ) {
927 use crate::tui::background_indicator::{PendingItemKind, pending_work_from_app};
928 use crate::tui::tideline::InteractionAction;
929 use crate::tui::work_surface::RailPanel;
930 let mut counts = Vec::new();
931 let mut panels = Vec::new();
932 let agents = crate::tui::subagent_routing::running_agent_count(app);
933 match agents {
934 0 => {}
935 1 => {
936 counts.push((
937 tr(app.ui_locale, MessageId::FooterAgentSingular).into_owned(),
938 ChromeInk::Active,
939 ));
940 panels.push(InteractionAction::ShowDockPanel(RailPanel::Agents));
941 }
942 n => {
943 counts.push((
944 tr(app.ui_locale, MessageId::FooterAgentsPlural).replace("{count}", &n.to_string()),
945 ChromeInk::Active,
946 ));
947 panels.push(InteractionAction::ShowDockPanel(RailPanel::Agents));
948 }
949 }
950 let shells = app
951 .task_panel
952 .iter()
953 .filter(|entry| crate::tui::background_indicator::is_live_shell_entry(entry))
954 .count();
955 if shells > 0 {
956 counts.push((
957 format!("{shells} {}", PendingItemKind::Shell.plural_noun(shells)),
958 ChromeInk::Active,
959 ));
960 panels.push(InteractionAction::ShowDockPanel(RailPanel::Background));
961 }
962 let tasks = pending_work_from_app(app).count(PendingItemKind::Task);
963 if tasks > 0 {
964 counts.push((
965 format!("{tasks} {}", PendingItemKind::Task.plural_noun(tasks)),
966 ChromeInk::Active,
967 ));
968 panels.push(InteractionAction::ShowDockPanel(RailPanel::Background));
969 }
970 // Scheduled automation: the `AutomationPanelState` projection stays the
971 // single owner; Compact keeps the abbreviated count (chrome sheds
972 // before content) and the ink says whether a run failed unacknowledged.
973 let automation = if tier == ShellTier::Compact {
974 app.automation_panel.activity_slot_compact()
975 } else {
976 app.automation_panel.activity_slot(app.ui_locale)
977 };
978 if let Some(automation) = automation {
979 counts.push((automation, app.automation_panel.activity_ink()));
980 panels.push(InteractionAction::OpenAutomations);
981 }
982 // With nothing live there is still one bottom affordance that opens the
983 // dock (founder, 2026-09-03: the bar opens when used, or when you click
984 // something at the bottom to ask for it). The word is the dock's own
985 // TODO view title; it disappears while the dock is up.
986 //
987 // It reads at `MetadataValue`, not `MetadataDim`: `TEXT_DIM` is aliased to
988 // `TEXT_HINT` in every theme but Solarized, so a dim affordance paints the
989 // exact grey as the separators around it and the one clickable word in an
990 // idle footer disappears into punctuation. Live counts already carry
991 // `Active`; this is the idle case earning the same "you can click this".
992 if counts.is_empty() && app.work_surface.last_area.is_none() {
993 // The word alone did not say it was an affordance, let alone which
994 // key opened it — founder live-test: "what do we press at the bottom
995 // to get the workbar to show up?". It carries its chord until the
996 // binding has been used, exactly like the permission and mode chips.
997 let label = "Work bar".to_string();
998 let chord = crate::tui::shell_key_routing::binding(
999 crate::tui::shell_key_routing::ShellBindingId::ViewCycle,
1000 )
1001 .footer_chord;
1002 let label = if crate::tui::footer_hints::retired(
1003 &app.footer_hint_uses,
1004 crate::tui::footer_hints::DOCK_OPEN,
1005 ) {
1006 label
1007 } else {
1008 format!("{label} ({chord})")
1009 };
1010 counts.push((label, ChromeInk::Info));
1011 panels.push(InteractionAction::ShowDockPanel(RailPanel::Tasks));
1012 }
1013 (counts, panels)
1014 }
1015
1016 /// Build the posture bar's facts from live `App` state. `width` is the
1017 /// row's width — notices clause-shed against it, never dangle.
1018 pub(crate) fn tideline_footer_from_app(app: &mut App, width: u16) -> TidelineFooterFacts {
1019 use crate::tui::shell_key_routing::{ShellBindingId, binding};
1020 let activity = LiveActivity::from_app(app);
1021 let phase = ShellPhase::from_app_with_activity(app, activity);
1022 let (_, phase_label) = phase_marker_with_activity(app, phase, activity);
1023 let tier = ShellTier::for_chrome_width(width);
1024 let focus = app.focus();
1025
1026 let (mode_chip, permission_chip) = crate::tui::underwater::posture_chips(app);
1027 let permission_chip = permission_chip
1028 .map(|(text, ink)| (text.into_owned(), ink))
1029 .unwrap_or_else(|| (String::new(), ChromeInk::PermissionAsk));
1030 // The mode chip is the one posture fact `/statusline` composes (#5950):
1031 // its `StatusItem::Mode` toggle used to be inert. The permission chip,
1032 // the working clocks (#5914) and the live counts are the bar's own
1033 // posture statement and stay unconditional.
1034 let mode_chip = mode_chip
1035 .filter(|_| app.status_items.contains(&crate::config::StatusItem::Mode))
1036 .map(|(text, ink)| (text.into_owned(), ink));
1037 // Cycle keys come from the binding table and only when that binding is
1038 // live for the current focus.
1039 let live_chord = |id: ShellBindingId| -> Option<&'static str> {
1040 let binding = binding(id);
1041 binding.focus.admits(focus).then_some(binding.footer_chord)
1042 };
1043
1044 // The one hint that applies now: the double-tap send-now window while a
1045 // turn is running, else the interrupt affordance, else the arrow keys
1046 // the empty composer lends to the agent roster. Each hint retires once
1047 // its binding has been used enough times (`footer_hints::retired`): a
1048 // taught binding renders the bare state, never more chrome.
1049 let hint = if app.double_tap_window_open() {
1050 Some((
1051 tr(app.ui_locale, MessageId::PostureHintEnterAgain)
1052 .replace("{enter}", "Enter")
1053 .replace("{steer}", "Ctrl+Enter"),
1054 ChromeInk::MetadataHint,
1055 crate::tui::footer_hints::ENTER_AGAIN,
1056 ))
1057 } else if matches!(phase, ShellPhase::Working | ShellPhase::Verifying) {
1058 // #6502: while the workbar owns focus, Esc closes the workbar and the
1059 // turn keeps running, so the interrupt promise would be false.
1060 (!app.work_surface.focused).then(|| {
1061 (
1062 tr(app.ui_locale, MessageId::FooterHintEscInterrupt).into_owned(),
1063 ChromeInk::MetadataHint,
1064 crate::tui::footer_hints::ESC_INTERRUPT,
1065 )
1066 })
1067 } else if crate::tui::agent_focus::shell_shortcuts_available(app, false) {
1068 Some((
1069 crate::tui::agent_focus::footer_agent_hints(app),
1070 ChromeInk::MetadataHint,
1071 crate::tui::footer_hints::AGENT_ARROWS,
1072 ))
1073 } else {
1074 None
1075 };
1076 let hint = hint
1077 .filter(|(_, _, key)| !crate::tui::footer_hints::retired(&app.footer_hint_uses, key))
1078 .map(|(text, ink, _)| (text, ink));
1079 // While a turn runs, the arrow keys stay live beside Esc, so the row reads
1080 // `Esc to interrupt · ← for agents · ↓ to manage` — the running agents and
1081 // workflows are what a user wants to reach mid-turn.
1082 let hint = if matches!(phase, ShellPhase::Working | ShellPhase::Verifying)
1083 && !app.double_tap_window_open()
1084 && crate::tui::agent_focus::shell_shortcuts_available(app, false)
1085 && !crate::tui::footer_hints::retired(
1086 &app.footer_hint_uses,
1087 crate::tui::footer_hints::AGENT_ARROWS,
1088 ) {
1089 let arrows = crate::tui::agent_focus::footer_agent_hints(app);
1090 Some(match hint {
1091 Some((text, ink)) => (format!("{text} · {arrows}"), ink),
1092 None => (arrows, ChromeInk::MetadataHint),
1093 })
1094 } else {
1095 hint
1096 };
1097
1098 // The right slot: the live status toast if one is owed, else the compact
1099 // MCP or plugin boot chip, else the remote-control state when it is on.
1100 // Clause-shed against half the row — the posture facts own the other
1101 // half.
1102 let notice_budget = (usize::from(width) / 2).max(8);
1103 let right = selected_notice(app.active_status_toast(phase), &phase_label)
1104 .map(|(text, ink, _urgent)| {
1105 (
1106 text,
1107 if ink == ChromeInk::Info {
1108 ChromeInk::Metadata
1109 } else {
1110 ink
1111 },
1112 )
1113 })
1114 .or_else(|| {
1115 // The launch screen carries the full MCP block — every state, with
1116 // the failing and unauthorized servers named. Repeating a squeezed
1117 // one-server chip down here would give the same fact two homes and
1118 // show strictly less of it. Suppress the chip, not the surface:
1119 // `SessionBootSurface::from_app` stays untouched so every other
1120 // consumer of boot state, including the launch block itself, is
1121 // unaffected.
1122 if app.launch.visible {
1123 return None;
1124 }
1125 let boot = crate::tui::session_boot::SessionBootSurface::from_app(app);
1126 boot.activity_notice(app.ui_locale, notice_budget)
1127 .map(|chip| (chip.text, boot_activity_ink(chip.level)))
1128 })
1129 .and_then(|(text, ink)| fit_notice(&text, notice_budget).map(|fitted| (fitted, ink)))
1130 .or_else(|| {
1131 app.remote_control
1132 .status_word()
1133 .map(|word| (format!("/rc {word}"), ChromeInk::Info))
1134 });
1135
1136 let (turn_clock, session_clock) = working_clock(app, phase, &phase_label);
1137 let (counts, count_actions) = live_counts(app, tier);
1138 TidelineFooterFacts {
1139 permission_chip,
1140 permission_key: live_chord(ShellBindingId::PermissionCycle)
1141 .filter(|_| {
1142 !crate::tui::footer_hints::retired(
1143 &app.footer_hint_uses,
1144 crate::tui::footer_hints::PERMISSION_CYCLE,
1145 )
1146 })
1147 .map(|chord| {
1148 tr(app.ui_locale, MessageId::FooterPermissionKeyHint).replace("{key}", chord)
1149 }),
1150 mode_chip,
1151 mode_key: live_chord(ShellBindingId::ModeCycle).filter(|_| {
1152 !crate::tui::footer_hints::retired(
1153 &app.footer_hint_uses,
1154 crate::tui::footer_hints::MODE_CYCLE,
1155 )
1156 }),
1157 turn_clock,
1158 counts,
1159 session_clock,
1160 count_actions,
1161 hint,
1162 context_percent: context_percent_from_app(app),
1163 right,
1164 }
1165 }
1166
1167 #[cfg(test)]
1168 mod tideline_tests;
1169
1170 #[cfg(test)]
1171 mod posture_tests;
1172
1173 #[cfg(test)]
1174 mod neutrality_tests {
1175 #[test]
1176 fn session_metrics_strip_is_on_by_default() {
1177 assert!(
1178 crate::config::StatusItem::default_footer().contains(&crate::config::StatusItem::Ttft)
1179 && crate::config::StatusItem::default_footer()
1180 .contains(&crate::config::StatusItem::OutputRate)
1181 );
1182 assert_eq!(
1183 crate::config::StatusItem::from_key("session_metrics"),
1184 Some(crate::config::StatusItem::SessionMetrics)
1185 );
1186 }
1187 }
1188
1188 lines RUST