| 1 | //! Workspace fixtures: transcript, input ledge, tool previews, agents and a fleet. |
| 2 | //! |
| 3 | //! All content is illustrative caller data. No fixture claims a provider |
| 4 | //! call, account state, cost, deployment or successful release. |
| 5 | |
| 6 | use ratatui::{buffer::Buffer, layout::Rect}; |
| 7 | |
| 8 | use super::Entry; |
| 9 | use crate::{ |
| 10 | AgentCard, Composer, Fleet, KeyHint, KeyHints, Message, Paint, Role, State, Theme, ToolCard, |
| 11 | glyphs, |
| 12 | }; |
| 13 | |
| 14 | fn message(area: Rect, buf: &mut Buffer, theme: &Theme) { |
| 15 | let first = Message::native("Show every component in the README.") |
| 16 | .role(Role::Primary) |
| 17 | .marker(glyphs::USER); |
| 18 | let first_height = first.height(area.width, theme).min(area.height); |
| 19 | first.paint( |
| 20 | Rect { |
| 21 | height: first_height, |
| 22 | ..area |
| 23 | }, |
| 24 | buf, |
| 25 | theme, |
| 26 | ); |
| 27 | let rest = Rect { |
| 28 | y: area |
| 29 | .y |
| 30 | .saturating_add(first_height.saturating_add(1).min(area.height)), |
| 31 | height: area.height.saturating_sub(first_height.saturating_add(1)), |
| 32 | ..area |
| 33 | }; |
| 34 | Message::native( "The gallery uses the same components as the library.\n\nEach preview includes light, dark and ASCII treatments.") |
| 35 | .paint(rest, buf, theme); |
| 36 | } |
| 37 | |
| 38 | fn composer(area: Rect, buf: &mut Buffer, theme: &Theme) { |
| 39 | let hints = KeyHints::new(vec![ |
| 40 | KeyHint::new("Enter", "send"), |
| 41 | KeyHint::new("Shift+Enter", "new line"), |
| 42 | KeyHint::new("Ctrl+O", "details"), |
| 43 | ]); |
| 44 | Composer::new("Show the new transcript, tool cards and fleet rail.\nKeep the previews connected to the public APIs.") |
| 45 | .context("codewhale-ratatui / workspace") |
| 46 | .hints(&hints) |
| 47 | .focused(true) |
| 48 | .paint(area, buf, theme); |
| 49 | } |
| 50 | |
| 51 | fn tool_card(area: Rect, buf: &mut Buffer, theme: &Theme) { |
| 52 | ToolCard::new("verify", "cargo test --test workspace", State::Done) |
| 53 | .elapsed("0.4s") |
| 54 | .output("transcript preserves authored lines: checked\noutput preview counts hidden lines: checked\nfleet retains each agent's identity: checked") |
| 55 | .omitted_lines(2) |
| 56 | .paint(area, buf, theme); |
| 57 | } |
| 58 | |
| 59 | fn agent_card(area: Rect, buf: &mut Buffer, theme: &Theme) { |
| 60 | AgentCard::new("Terminal review", State::NeedsYou) |
| 61 | .role("Reviewer") |
| 62 | .route("Local / caller-selected model") |
| 63 | .task("Choose translated state words.\nKeep the preview aligned with the host's locale.") |
| 64 | .elapsed("48s") |
| 65 | .paint(area, buf, theme); |
| 66 | } |
| 67 | |
| 68 | fn fleet(area: Rect, buf: &mut Buffer, theme: &Theme) { |
| 69 | Fleet::new(vec![ |
| 70 | AgentCard::new("Transcript", State::Working) |
| 71 | .role("Builder") |
| 72 | .route("Local / caller-selected model") |
| 73 | .task("Extract reusable message and tool surfaces.") |
| 74 | .elapsed("2m 10s"), |
| 75 | AgentCard::new("Accessibility", State::NeedsYou) |
| 76 | .role("Reviewer") |
| 77 | .task("Choose the host's localized state words.") |
| 78 | .elapsed("48s"), |
| 79 | AgentCard::new("Gallery", State::Done) |
| 80 | .role("Verifier") |
| 81 | .task("Review illustrative terminal profiles.") |
| 82 | .elapsed("1m 24s"), |
| 83 | ]) |
| 84 | .paint(area, buf, theme); |
| 85 | } |
| 86 | |
| 87 | pub(crate) fn entries() -> Vec<Entry> { |
| 88 | vec![ |
| 89 | Entry { |
| 90 | name: "message", |
| 91 | width: 64, |
| 92 | height: 9, |
| 93 | draw: message, |
| 94 | }, |
| 95 | Entry { |
| 96 | name: "composer", |
| 97 | width: 64, |
| 98 | height: 5, |
| 99 | draw: composer, |
| 100 | }, |
| 101 | Entry { |
| 102 | name: "tool-card", |
| 103 | width: 64, |
| 104 | height: 9, |
| 105 | draw: tool_card, |
| 106 | }, |
| 107 | Entry { |
| 108 | name: "agent-card", |
| 109 | width: 64, |
| 110 | height: 8, |
| 111 | draw: agent_card, |
| 112 | }, |
| 113 | Entry { |
| 114 | name: "fleet", |
| 115 | width: 64, |
| 116 | height: 14, |
| 117 | draw: fleet, |
| 118 | }, |
| 119 | ] |
| 120 | } |
| 121 |