| 1 | # Codewhale Ratatui |
| 2 | |
| 3 | The terminal components behind [Codewhale](https://github.com/Hmbown/CodeWhale), |
| 4 | ready for your [Ratatui](https://ratatui.rs) app. Native layouts, ocean depth, |
| 5 | quiet motion, and a little life in the water. |
| 6 | |
| 7 |  |
| 8 | |
| 9 | <details> |
| 10 | <summary>See WhaleLight</summary> |
| 11 | |
| 12 |  |
| 13 | |
| 14 | </details> |
| 15 | |
| 16 | **One component or a whole workspace.** The original eight-panel workbar, |
| 17 | composer, sessions, settings, approvals and results share the same native |
| 18 | colors and backgrounds. All 16 TUI themes, fish, jellyfish, spinners and whale |
| 19 | actions are included. Your app owns the state and clock. |
| 20 | |
| 21 | [Components](#explore-the-components) · [Terminal view guide](VIEWS.md) · |
| 22 | [Design](DESIGN.md) · [Quality](QUALITY.md) · [Benchmarks](BENCHMARKS.md) |
| 23 | |
| 24 | The [website explorer](WEBSITE.md) separates every catalogue entry into a |
| 25 | searchable component page, with terminal profiles, real width variants, |
| 26 | Rust rendering source and controlled animation playback. |
| 27 | |
| 28 | ## Get started |
| 29 | |
| 30 | The current registry release is 0.2.0. This Engine vendor snapshot prepares |
| 31 | 0.2.1, which requires Codewhale Protocol 0.10.4; publication requires its |
| 32 | separate release approval. Since 0.2.0, the `WorkflowRun.total` field and the |
| 33 | total argument to `WorkflowRun::outcomes` use `u64`; convert existing `usize` |
| 34 | totals with `as u64`. |
| 35 | |
| 36 | ```toml |
| 37 | [dependencies] |
| 38 | codewhale-ratatui = "0.2.0" |
| 39 | ratatui = "0.30.2" |
| 40 | ``` |
| 41 | |
| 42 | ```rust |
| 43 | use codewhale_ratatui::{NativeComposer, Paint, Theme}; |
| 44 | |
| 45 | let theme = Theme::detect().tui(); |
| 46 | let composer = NativeComposer::new("Review the changes") |
| 47 | .focused(true); |
| 48 | frame.render_widget(composer.themed(&theme), frame.area()); |
| 49 | ``` |
| 50 | |
| 51 | Rust 1.89+. Your app chooses the terminal backend. |
| 52 | Try `cargo run --example starter` for a small editable app, or |
| 53 | `cargo run --example showcase` to explore the native layout. |
| 54 | |
| 55 | ## Explore the components |
| 56 | |
| 57 | Open a collection to see its full dark and light previews. Every one of the |
| 58 | 199 gallery entries is here, rendered from actual Ratatui buffers. The |
| 59 | [component guide](COMPONENTS.md) maps them to Codewhale's terminal views. |
| 60 | Run `cargo run --example gallery` to try every variation yourself. |
| 61 | |
| 62 | <!-- gallery:start --> |
| 63 | |
| 64 | ### Native Codewhale |
| 65 | |
| 66 | <a id="the-live-component-gallery"></a> |
| 67 | <details> |
| 68 | <summary>The live component gallery · 5 examples</summary> |
| 69 | |
| 70 | The native conversation layout, composer and workbar, plus interactive component studies. |
| 71 | |
| 72 |  |
| 73 | |
| 74 |  |
| 75 | |
| 76 |  |
| 77 | |
| 78 |  |
| 79 | |
| 80 |  |
| 81 | |
| 82 | <details> |
| 83 | <summary>Light appearance</summary> |
| 84 | |
| 85 |  |
| 86 | |
| 87 |  |
| 88 | |
| 89 |  |
| 90 | |
| 91 |  |
| 92 | |
| 93 |  |
| 94 | |
| 95 | </details> |
| 96 | |
| 97 | <details> |
| 98 | <summary>Watch the animation</summary> |
| 99 | |
| 100 |  |
| 101 | |
| 102 |  |
| 103 | |
| 104 | </details> |
| 105 | |
| 106 | </details> |
| 107 | |
| 108 | <a id="codewhale-terminal-views"></a> |
| 109 | <details> |
| 110 | <summary>Codewhale terminal views · 22 examples</summary> |
| 111 | |
| 112 | Sessions, settings, pickers and work panels built from reusable native parts. |
| 113 | |
| 114 |  |
| 115 | |
| 116 |  |
| 117 | |
| 118 |  |
| 119 | |
| 120 |  |
| 121 | |
| 122 |  |
| 123 | |
| 124 |  |
| 125 | |
| 126 |  |
| 127 | |
| 128 |  |
| 129 | |
| 130 |  |
| 131 | |
| 132 |  |
| 133 | |
| 134 |  |
| 135 | |
| 136 |  |
| 137 | |
| 138 |  |
| 139 | |
| 140 |  |
| 141 | |
| 142 |  |
| 143 | |
| 144 |  |
| 145 | |
| 146 |  |
| 147 | |
| 148 |  |
| 149 | |
| 150 |  |
| 151 | |
| 152 |  |
| 153 | |
| 154 |  |
| 155 | |
| 156 |  |
| 157 | |
| 158 | <details> |
| 159 | <summary>Light appearance</summary> |
| 160 | |
| 161 |  |
| 162 | |
| 163 |  |
| 164 | |
| 165 |  |
| 166 | |
| 167 |  |
| 168 | |
| 169 |  |
| 170 | |
| 171 |  |
| 172 | |
| 173 |  |
| 174 | |
| 175 |  |
| 176 | |
| 177 |  |
| 178 | |
| 179 |  |
| 180 | |
| 181 |  |
| 182 | |
| 183 |  |
| 184 | |
| 185 |  |
| 186 | |
| 187 |  |
| 188 | |
| 189 |  |
| 190 | |
| 191 |  |
| 192 | |
| 193 |  |
| 194 | |
| 195 |  |
| 196 | |
| 197 |  |
| 198 | |
| 199 |  |
| 200 | |
| 201 |  |
| 202 | |
| 203 |  |
| 204 | |
| 205 | </details> |
| 206 | |
| 207 | </details> |
| 208 | |
| 209 | <a id="the-native-composer-and-footer"></a> |
| 210 | <details> |
| 211 | <summary>The native composer and footer · 22 examples</summary> |
| 212 | |
| 213 | Composer geometry, permission and mode, workflow rows and model/context metrics. |
| 214 | |
| 215 |  |
| 216 | |
| 217 |  |
| 218 | |
| 219 | <details> |
| 220 | <summary>Light appearance</summary> |
| 221 | |
| 222 |  |
| 223 | |
| 224 |  |
| 225 | |
| 226 | </details> |
| 227 | |
| 228 | </details> |
| 229 | |
| 230 | <a id="the-native-workbar"></a> |
| 231 | <details> |
| 232 | <summary>The native workbar · 12 examples</summary> |
| 233 | |
| 234 | Tasks, Fleet, Jobs, Files, Notes, Context, Git and Cost; bottom, top and side placement. |
| 235 | |
| 236 |  |
| 237 | |
| 238 |  |
| 239 | |
| 240 | <details> |
| 241 | <summary>Light appearance</summary> |
| 242 | |
| 243 |  |
| 244 | |
| 245 |  |
| 246 | |
| 247 | </details> |
| 248 | |
| 249 | </details> |
| 250 | |
| 251 | ### Color and atmosphere |
| 252 | |
| 253 | <a id="every-codewhale-tui-theme"></a> |
| 254 | <details> |
| 255 | <summary>Every Codewhale TUI theme · 16 examples</summary> |
| 256 | |
| 257 | Sixteen source presets with their actual backgrounds, status, permission and mode inks. |
| 258 | |
| 259 |  |
| 260 | |
| 261 |  |
| 262 | |
| 263 |  |
| 264 | |
| 265 |  |
| 266 | |
| 267 |  |
| 268 | |
| 269 |  |
| 270 | |
| 271 | <details> |
| 272 | <summary>Light appearance</summary> |
| 273 | |
| 274 |  |
| 275 | |
| 276 |  |
| 277 | |
| 278 |  |
| 279 | |
| 280 |  |
| 281 | |
| 282 |  |
| 283 | |
| 284 |  |
| 285 | |
| 286 | </details> |
| 287 | |
| 288 | </details> |
| 289 | |
| 290 | <a id="codewhale-water-and-ombres"></a> |
| 291 | <details> |
| 292 | <summary>Codewhale water and ombres · 10 examples</summary> |
| 293 | |
| 294 | The current TUI ocean, plus optional Lagoon, Dusk, Coral and Graphite treatments. |
| 295 | |
| 296 |  |
| 297 | |
| 298 |  |
| 299 | |
| 300 |  |
| 301 | |
| 302 |  |
| 303 | |
| 304 |  |
| 305 | |
| 306 |  |
| 307 | |
| 308 |  |
| 309 | |
| 310 |  |
| 311 | |
| 312 |  |
| 313 | |
| 314 |  |
| 315 | |
| 316 | <details> |
| 317 | <summary>Light appearance</summary> |
| 318 | |
| 319 |  |
| 320 | |
| 321 |  |
| 322 | |
| 323 |  |
| 324 | |
| 325 |  |
| 326 | |
| 327 |  |
| 328 | |
| 329 |  |
| 330 | |
| 331 |  |
| 332 | |
| 333 |  |
| 334 | |
| 335 |  |
| 336 | |
| 337 |  |
| 338 | |
| 339 | </details> |
| 340 | |
| 341 | </details> |
| 342 | |
| 343 | ### Inputs and controls |
| 344 | |
| 345 | <a id="the-codewhale-language"></a> |
| 346 | <details> |
| 347 | <summary>The Codewhale language · 7 examples</summary> |
| 348 | |
| 349 | Depth, rules, marks, hints and terminal chrome. |
| 350 | |
| 351 |  |
| 352 | |
| 353 | <details> |
| 354 | <summary>Light appearance</summary> |
| 355 | |
| 356 |  |
| 357 | |
| 358 | </details> |
| 359 | |
| 360 | </details> |
| 361 | |
| 362 | <a id="input-and-selection"></a> |
| 363 | <details> |
| 364 | <summary>Input and selection · 21 examples</summary> |
| 365 | |
| 366 | Editable fields, forms, lists and focused choices. |
| 367 | |
| 368 |  |
| 369 | |
| 370 |  |
| 371 | |
| 372 | <details> |
| 373 | <summary>Light appearance</summary> |
| 374 | |
| 375 |  |
| 376 | |
| 377 |  |
| 378 | |
| 379 | </details> |
| 380 | |
| 381 | </details> |
| 382 | |
| 383 | <a id="navigation-and-controls"></a> |
| 384 | <details> |
| 385 | <summary>Navigation and controls · 7 examples</summary> |
| 386 | |
| 387 | Headings, tabs, toggles and keyboard maps. |
| 388 | |
| 389 |  |
| 390 | |
| 391 | <details> |
| 392 | <summary>Light appearance</summary> |
| 393 | |
| 394 |  |
| 395 | |
| 396 | </details> |
| 397 | |
| 398 | </details> |
| 399 | |
| 400 | ### Conversation and work |
| 401 | |
| 402 | <a id="conversation-and-queued-input"></a> |
| 403 | <details> |
| 404 | <summary>Conversation and queued input · 12 examples</summary> |
| 405 | |
| 406 | Rich prose, code, attached context and the next instruction. |
| 407 | |
| 408 |  |
| 409 | |
| 410 | <details> |
| 411 | <summary>Light appearance</summary> |
| 412 | |
| 413 |  |
| 414 | |
| 415 | </details> |
| 416 | |
| 417 | </details> |
| 418 | |
| 419 | <a id="conversation-and-agents"></a> |
| 420 | <details> |
| 421 | <summary>Conversation and agents · 13 examples</summary> |
| 422 | |
| 423 | Inline messages and optional tool, agent and fleet cards. |
| 424 | |
| 425 |  |
| 426 | |
| 427 |  |
| 428 | |
| 429 | <details> |
| 430 | <summary>Light appearance</summary> |
| 431 | |
| 432 |  |
| 433 | |
| 434 |  |
| 435 | |
| 436 | </details> |
| 437 | |
| 438 | </details> |
| 439 | |
| 440 | <a id="work-and-results"></a> |
| 441 | <details> |
| 442 | <summary>Work and results · 25 examples</summary> |
| 443 | |
| 444 | Diffs, trees, progress, approvals and run results. |
| 445 | |
| 446 |  |
| 447 | |
| 448 |  |
| 449 | |
| 450 |  |
| 451 | |
| 452 |  |
| 453 | |
| 454 | <details> |
| 455 | <summary>Light appearance</summary> |
| 456 | |
| 457 |  |
| 458 | |
| 459 |  |
| 460 | |
| 461 |  |
| 462 | |
| 463 |  |
| 464 | |
| 465 | </details> |
| 466 | |
| 467 | </details> |
| 468 | |
| 469 | <a id="optional-workspace-compositions"></a> |
| 470 | <details> |
| 471 | <summary>Optional workspace compositions · 5 examples</summary> |
| 472 | |
| 473 | Desktop-inspired conversation, review and fleet layouts you can compose from the library. |
| 474 | |
| 475 |  |
| 476 | |
| 477 |  |
| 478 | |
| 479 |  |
| 480 | |
| 481 |  |
| 482 | |
| 483 |  |
| 484 | |
| 485 | <details> |
| 486 | <summary>Light appearance</summary> |
| 487 | |
| 488 |  |
| 489 | |
| 490 |  |
| 491 | |
| 492 |  |
| 493 | |
| 494 |  |
| 495 | |
| 496 |  |
| 497 | |
| 498 | </details> |
| 499 | |
| 500 | </details> |
| 501 | |
| 502 | ### Motion and marine life |
| 503 | |
| 504 | <a id="motion-and-feedback"></a> |
| 505 | <details> |
| 506 | <summary>Motion and feedback · 13 examples</summary> |
| 507 | |
| 508 | Spinners, notifications and calm transitions. |
| 509 | |
| 510 |  |
| 511 | |
| 512 | <details> |
| 513 | <summary>Light appearance</summary> |
| 514 | |
| 515 |  |
| 516 | |
| 517 | </details> |
| 518 | |
| 519 | <details> |
| 520 | <summary>Watch the animation</summary> |
| 521 | |
| 522 |  |
| 523 | |
| 524 |  |
| 525 | |
| 526 | </details> |
| 527 | |
| 528 | </details> |
| 529 | |
| 530 | <a id="life-in-the-water"></a> |
| 531 | <details> |
| 532 | <summary>Life in the water · 5 examples</summary> |
| 533 | |
| 534 | Fish, jellyfish and bubbles, drawn in terminal cells. |
| 535 | |
| 536 |  |
| 537 | |
| 538 | <details> |
| 539 | <summary>Light appearance</summary> |
| 540 | |
| 541 |  |
| 542 | |
| 543 | </details> |
| 544 | |
| 545 | <details> |
| 546 | <summary>Watch the animation</summary> |
| 547 | |
| 548 |  |
| 549 | |
| 550 | </details> |
| 551 | |
| 552 | </details> |
| 553 | |
| 554 | <a id="a-whale-with-a-job"></a> |
| 555 | <details> |
| 556 | <summary>A whale with a job · 8 examples</summary> |
| 557 | |
| 558 | Session state, attention, completion and the pod. |
| 559 | |
| 560 |  |
| 561 | |
| 562 | <details> |
| 563 | <summary>Light appearance</summary> |
| 564 | |
| 565 |  |
| 566 | |
| 567 | </details> |
| 568 | |
| 569 | </details> |
| 570 | |
| 571 | <a id="every-whale-action"></a> |
| 572 | <details> |
| 573 | <summary>Every whale action · 1 example</summary> |
| 574 | |
| 575 | The complete v2 state vocabulary, in terminal cells. |
| 576 | |
| 577 |  |
| 578 | |
| 579 | <details> |
| 580 | <summary>Light appearance</summary> |
| 581 | |
| 582 |  |
| 583 | |
| 584 | </details> |
| 585 | |
| 586 | <details> |
| 587 | <summary>Watch the animation</summary> |
| 588 | |
| 589 |  |
| 590 | |
| 591 | </details> |
| 592 | |
| 593 | </details> |
| 594 | |
| 595 | <a id="terminal-profiles"></a> |
| 596 | <details> |
| 597 | <summary>All nine terminal profiles</summary> |
| 598 | |
| 599 |  |
| 600 | |
| 601 | </details> |
| 602 | |
| 603 | <!-- gallery:end --> |
| 604 | |
| 605 | ## Build with the kit |
| 606 | |
| 607 | <details> |
| 608 | <summary>Composition, editing and stateful widgets</summary> |
| 609 | |
| 610 | ```rust |
| 611 | use codewhale_ratatui::{ |
| 612 | Depth, KeyHint, KeyHints, Paint, Panel, Picker, PickerItem, PickerState, Theme, |
| 613 | }; |
| 614 | |
| 615 | // Once, after enabling raw mode, if the host does not already detect it: |
| 616 | codewhale_ratatui::detect::probe_terminal_background(); |
| 617 | let theme = Theme::detect().tui(); |
| 618 | |
| 619 | // In your draw callback, with a Ratatui area and buffer: |
| 620 | let hints = KeyHints::new(vec![ |
| 621 | KeyHint::new("↑↓", "move"), |
| 622 | KeyHint::new("Enter", "select"), |
| 623 | KeyHint::new("Esc", "cancel"), |
| 624 | ]); |
| 625 | let inner = Panel::new(Depth::Overlay) |
| 626 | .title("Mode") |
| 627 | .hints(&hints) |
| 628 | .draw(area, buf, &theme); |
| 629 | let items = [PickerItem::new("Work").key('1'), PickerItem::new("Plan").key('2')]; |
| 630 | Picker::new(&items, PickerState::new(0)).paint(inner, buf, &theme); |
| 631 | ``` |
| 632 | |
| 633 | Every `Paint` component also becomes a Ratatui widget with `.themed(&theme)`: |
| 634 | |
| 635 | ```rust |
| 636 | use codewhale_ratatui::{NativeComposer, Paint, Theme}; |
| 637 | let theme = Theme::detect().tui(); |
| 638 | let composer = NativeComposer::new("Review the changes") |
| 639 | .target("my-project / main"); |
| 640 | frame.render_widget(composer.themed(&theme), frame.area()); |
| 641 | ``` |
| 642 | |
| 643 | Keep a widget and render it by reference across frames: |
| 644 | |
| 645 | ```rust |
| 646 | let widget = composer.themed(&theme); |
| 647 | frame.render_widget(&widget, frame.area()); |
| 648 | ``` |
| 649 | |
| 650 | For a collection of different components, use `Themed::new(&dyn Paint, &theme)`. |
| 651 | The library enables no Ratatui terminal backend; your application selects its |
| 652 | backend. The [standalone consumer](tests/consumer/src/main.rs) demonstrates |
| 653 | this with `TestBackend`. The [starter app](examples/starter.rs) shows native |
| 654 | composition, Unicode editing, bracketed paste and terminal cleanup. |
| 655 | |
| 656 | Lists and pickers also support `frame.render_stateful_widget`: keep a |
| 657 | `ListState` or `PickerState` in your app and pass the themed widget with that |
| 658 | state. Rendering stores the scroll offset for the actual viewport, including |
| 659 | query rows, tabs and clipping. |
| 660 | |
| 661 | ```rust |
| 662 | use codewhale_ratatui::{List, ListState, Paint}; |
| 663 | // Keep `state` in your app between frames. |
| 664 | let rows = ["First session", "Second session"]; |
| 665 | let list = List::new(&rows, ListState::default()); |
| 666 | frame.render_stateful_widget(list.themed(&theme), frame.area(), &mut state); |
| 667 | ``` |
| 668 | |
| 669 | Input states return outcomes for your app to act on. Typing and navigation |
| 670 | can repeat while a key is held; submit, choose, toggle and cancel require an |
| 671 | initial press. Modified navigation and activation shortcuts stay with your app. |
| 672 | |
| 673 | Compose the native conversation layout: |
| 674 | |
| 675 | ```rust |
| 676 | use codewhale_ratatui::{ |
| 677 | Message, NativeComposer, Paint, PostureBar, TerminalShell, |
| 678 | Workbar, WorkbarPanel, WorkbarRow, |
| 679 | }; |
| 680 | |
| 681 | let composer = NativeComposer::new("Review the changes").focused(true); |
| 682 | let workbar = Workbar::new(WorkbarPanel::Tasks, vec![ |
| 683 | WorkbarRow::new("task:review", "Review the changes").mark("●"), |
| 684 | ]); |
| 685 | let shell = TerminalShell::new(composer.desired_height(area.width, area.height / 2)) |
| 686 | .workbar_rows(workbar.height(area.width, &theme)); |
| 687 | shell.paint(area, buf, &theme); |
| 688 | let regions = shell.areas(area); |
| 689 | Message::native("The changes are ready for review.").paint(regions.conversation, buf, &theme); |
| 690 | composer.paint(regions.composer, buf, &theme); |
| 691 | PostureBar::new("ask").paint(regions.posture, buf, &theme); |
| 692 | workbar.paint(regions.workbar, buf, &theme); |
| 693 | ``` |
| 694 | |
| 695 | Choose a native background and keep the same components: |
| 696 | |
| 697 | ```rust |
| 698 | use codewhale_ratatui::{Theme, TuiPalette}; |
| 699 | let theme = Theme::detect().tui_palette(TuiPalette::TokyoNight); |
| 700 | ``` |
| 701 | |
| 702 | `Theme::tui()` chooses Underwater for a dark terminal and WhaleLight for a |
| 703 | light terminal. `Whale` and `WhaleLight` preserve the terminal-owned shell |
| 704 | backgrounds from the TUI. `Theme::new` also supports the existing desktop |
| 705 | role-token theme; `Ombre` offers additional spatial treatments. Native view |
| 706 | recipes are in [src/gallery/native_views.rs](src/gallery/native_views.rs). |
| 707 | |
| 708 | For open water, paint foreground content first, then call `Habitat::paint`. |
| 709 | It protects occupied cells and their clearance; the entire jellyfish is |
| 710 | withheld when its silhouette cannot fit. Pass decision and overlay rectangles |
| 711 | to `Habitat::protected` so their blank space stays protected too. Keep a |
| 712 | dedicated habitat viewport separate from any decision overlay. The habitat |
| 713 | never requests a frame itself. Selection and pointer helpers use the same clipped |
| 714 | viewport passed to painting. |
| 715 | |
| 716 | The whale's ordinary `Paint` implementation shows its current poster pose. |
| 717 | For animation, pass the packed `whale::Grid` evaluated by your existing |
| 718 | owner to `Whale::paint_frame(area, buf, &theme, &grid)`. The widget paints that |
| 719 | exact frame and its state words; it owns no Director or clock. The whole |
| 720 | frame must fit, with a row for the label. Invalid, narrow or ASCII frames |
| 721 | fall back to words. Repaint the underlying surface first because empty |
| 722 | cells in the frame are transparent. For the native animated performance, use `whale_motion::Stage` and |
| 723 | `colored_braille`; the [showcase host](examples/showcase.rs) demonstrates the |
| 724 | shared clock and motion policy. |
| 725 | |
| 726 | The [gallery fixtures](src/gallery/) are runnable usage examples for every |
| 727 | family. [Component contribution instructions](CONTRIBUTING-COMPONENTS.md) |
| 728 | explain the rendering and ownership contracts. |
| 729 | |
| 730 | ## Choose a terminal profile |
| 731 | |
| 732 | - **Truecolor:** native TUI presets retain exact source inks and grounds. |
| 733 | `Theme::tui()` selects the native default; desktop role-token mode is also available. |
| 734 | - **256 colors:** native preset RGBs use the nearest fixed-cube index. Desktop |
| 735 | role-token mode uses its contrast-audited table. |
| 736 | - **16 colors or unknown ground:** named terminal colors and visible marks/edges; |
| 737 | the terminal owns the background. |
| 738 | - **`NO_COLOR`:** words, weight and marks carry every state. |
| 739 | - **`CODEWHALE_ASCII_SAFE=1`:** component chrome uses ASCII glyphs; user-authored |
| 740 | Unicode remains text supplied by the host. |
| 741 | |
| 742 | Set `CODEWHALE_APPEARANCE=light` or `dark` if the ground cannot be measured. |
| 743 | A host with its own detection can pass `Theme::new(Caps { depth, ascii, |
| 744 | appearance })` and avoid a second probe. Changes to a theme reach components |
| 745 | on their next paint; components hold roles rather than cached colors. |
| 746 | |
| 747 | |
| 748 | </details> |
| 749 | |
| 750 | <details> |
| 751 | <summary>Full component reference</summary> |
| 752 | |
| 753 | ## Component catalogue |
| 754 | |
| 755 | | Family | Components | What they do | |
| 756 | |---|---|---| |
| 757 | | Optional workspace composition | `WorkspaceFrame`, `WorkspaceAreas`, `PaneHeader`, `ContextRibbon`, `ContextItem` | Responsive conversation and dock regions, one quiet module header, composer-adjacent facts folded by priority with explicit counts | |
| 758 | | Native shell | `TerminalShell`, `ShellAreas` | Current conversation → pending input → composer → posture → workflows → metrics → workbar ordering | |
| 759 | | Native workbar | `Workbar`, `WorkbarPanel`, `WorkbarRow`, `WorkbarState`, `WorkbarLayout`, `WorkbarScrollbar`, `DockTabRow`, `DockTabPlan`, `DockTabStyles`, `DockTabTarget` | All eight panels, goals, row selection, keyboard outcomes, scrolling, hitboxes and bottom/top/side placement | |
| 760 | | Native composer and workflow rows | `NativeComposer`, `WorkflowProgress`, `WorkflowRun` | Rounded input enclosure, prompt, submit control, target chip and borderless workflow progress | |
| 761 | | Native footer | `PostureBar`, `MetricsLine`, `MetricSegment` | Permission and mode, clocks, live counts, context warnings and width-aware model/usage facts | |
| 762 | | Native views | `InstrumentSurface`, `SessionList`, `SessionRow` | TUI title/action rails, quiet gutters, session selection, ranges, search and rename presentation | |
| 763 | | TUI themes | `TuiPalette`, `TuiInk` | All 16 fixed source palettes, exact grounds and distinct native permission/mode/status inks | |
| 764 | | Attention and results | `AttentionQueue`, `AttentionItem`, `ArtifactShelf`, `Artifact` | Project-aware decisions, selected action hints, review/file/run/link results and reported receipts | |
| 765 | | Marine life | `Habitat`, `FishSchool`, `Jellyfish`, `BubbleField`, `HabitatDensity` | Native braille poses and ASCII silhouettes, caller-clock motion, bounded populations, complete visitors and text-safe open-water collision | |
| 766 | | Water and palette | `OceanColumn`, `OceanRamp`, `OceanPhase`, `OceanPaintFacts`, `OceanCausticFacts`, `OceanContrastInks`, `ocean_semantic_surfaces`, `Ombre`, `WaterPalette` | Native TUI depth column, context rise, steady attention tint, completion breath and five spatial materials; contrast and fallback guards | |
| 767 | | Living whale | `whale_motion::Stage`, `Director`, `ColoredGrid` | One session performance, authored clips and springs, native colored props, shared terminal cadence and hide/resume boundaries | |
| 768 | | Session surfaces | `Message`, `ToolCard`, `Composer`, `AgentCard`, `Fleet` | Speaker anchors, output rails, honest omission counts, caller-owned prompts and each agent's own state, route and task | |
| 769 | | Pending input | `PendingInputPreview`, `PendingInputItem`, `ContextPreviewItem`, `PendingCard` | Queued, steering, editing, paused and in-flight input; native composer preview over localized caller facts; context and host-dispatched actions | |
| 770 | | Rich transcript | `Transcript`, `TranscriptBlock`, `TranscriptSpan`, `CodeBlock` | Authored headings, prose, quotes, lists, tables and numbered code; exact copy source and out-of-band links | |
| 771 | | Identity and state | `BrailleFrame`, `Whale`, `WhaleState`, `Icon`, `StatusMark`, `StateWords` | The v2 whale's 17 actions and pods; marks always paired with words; localized state labels | |
| 772 | | Surfaces | `Panel`, `Depth`, `Dialog`, `Sheet`, `HorizonRule` | Deep, stage, raised and overlay grounds; centered decisions, edge-anchored sheets and the composer ledge | |
| 773 | | Navigation | `Heading`, `Tabs`, `KeyHints`, `Keymap`, `Picker`, `List` | Shared heading hierarchy, selection, scrolling, keyboard labels and caller-owned outcomes | |
| 774 | | Input and controls | `TextInput`, `Form`, `Toggle`, `Segmented` | Unicode-aware editing, masked fields, validation and controls that explain disabled state | |
| 775 | | Search and empty states | `PickerQuery`, `PickerTabs`, `PickerMatches`, fuzzy matching helpers, `EmptyState` | Ranked choices, search highlights, tabs, previews and a clear next action when there are no results | |
| 776 | | Work and results | `Receipt`, `ReceiptTable`, `Diff`, `WorkflowTree`, `CountBar` | Measured values, explicit unknowns, numbered additions/removals, workflow hierarchy and progress from known totals | |
| 777 | | Decisions | `ApprovalCard`, `DecisionBand`, `ReviewVerdict`, `ReviewAggregate` | What will happen, where, why, and the caller's available next actions | |
| 778 | | Settings | `SettingRow`, `SettingDetail` | Value, source, lock reason, changed state, apply timing and reset details | |
| 779 | | Feedback and motion | `Toasts`, `Spinner`, `VerificationSpinner`, `MotionStep`, `MotionSet`, `FrameBudget` | Working swell, verification tick, notices, measured elapsed time, bounded transitions and reduced/still motion | |
| 780 | |
| 781 | Words and data arrive from the caller, with English defaults where useful. |
| 782 | The kit does not calculate a diff, parse Markdown, validate credentials, |
| 783 | authorize a command, estimate cost or run an agent. |
| 784 | |
| 785 | `OceanColumn` is adapted from the current TUI's three native stops: |
| 786 | `#102A45` → `#0A1E33` → `#061320`. Apply it after painting a scene to share |
| 787 | one continuous column behind ordinary grounds. Give it the full shell with |
| 788 | `.viewport(area)`, then use `.apply_matching(composer_area, buffer, theme, composer_ground)` |
| 789 | for a composer with its own base fill. The native [starter example](examples/starter.rs) |
| 790 | shows this complete composition. Selections, elevated panels, |
| 791 | diffs and code retain their backgrounds. The host supplies phase, elapsed time |
| 792 | and measured context; quiet policies stop breathing. The dark field is |
| 793 | opt-in on measured truecolor Ocean; light and limited-color terminals retain |
| 794 | their selected grounds. |
| 795 | |
| 796 | `Ombre` finishes a painted scene with a spatial palette wash. It preserves |
| 797 | state ink and readable contrast, and leaves unsupported profiles unchanged. |
| 798 | The native TUI column is the studio default; the logo Ocean wash is also |
| 799 | available alongside Lagoon, Dusk, Coral and Graphite. |
| 800 | |
| 801 | |
| 802 | </details> |
| 803 | |
| 804 | <details> |
| 805 | <summary>Animation, reduced motion and the host clock</summary> |
| 806 | |
| 807 | ## Spinners and animation |
| 808 | |
| 809 | `Spinner` uses Codewhale's eight-frame swell; `VerificationSpinner` uses the |
| 810 | Engine's distinct round verification tick. Both wait 400 ms before moving, |
| 811 | advance at five steps per second, and keep the caller's work verb visible. |
| 812 | Reduced and still motion show a static mark plus words. ASCII terminals have |
| 813 | their own frames. |
| 814 | |
| 815 | `MotionStep` and `MotionSet` handle token-timed state ink, selection movement |
| 816 | and detail reveal. The caller changes the state and supplies the instant; |
| 817 | the state words change immediately. `FrameBudget` combines redraw deadlines |
| 818 | and lets the host claim one primary spinner per frame. Once transitions |
| 819 | settle, the host can wait for input instead of painting identical frames. |
| 820 | |
| 821 | The animated demonstrations are under [Motion and feedback](#motion-and-feedback). |
| 822 | The normal gallery samples fixed instants; `cargo run --example motion` is |
| 823 | the live example. |
| 824 | |
| 825 | The native whale performance lives in `whale_motion`. A host keeps one `Stage` |
| 826 | per foreground session, reports explicit owner inputs, and advances it on its |
| 827 | own clock. `Tier::Terminal` caps active paints at six per second and rest at |
| 828 | two. Reduced motion uses authored posters; hiding and resuming discard missed |
| 829 | motion. `colored_braille` adds native body and prop inks to the exact packed |
| 830 | geometry. It uses majority visible ink per Braille cell because terminals |
| 831 | provide one foreground per cell. The [source and fixtures](assets/whale-motion/PROVENANCE.md) |
| 832 | pin the native implementation and its conformance oracle. |
| 833 | |
| 834 | |
| 835 | </details> |
| 836 | |
| 837 | [Contribution guide](CONTRIBUTING-COMPONENTS.md) · [Changelog](CHANGELOG.md) |
| 838 | |
| 839 | <details> |
| 840 | <summary>Maintainer notes: render previews, verify and update source assets</summary> |
| 841 | |
| 842 | ## Browse and regenerate |
| 843 | |
| 844 | ```sh |
| 845 | cargo run --example starter # small native application |
| 846 | cargo run --example gallery # interactive catalogue |
| 847 | cargo run --example showcase # the full terminal studio |
| 848 | cargo run --example habitat # live fish, jellyfish, bubbles |
| 849 | cargo run --example motion # working, verification and transitions |
| 850 | cargo run --example gallery -- --print dark-256 # ANSI preview to stdout |
| 851 | cargo run --example gallery -- --dump out/ # .ans and styled .txt, all profiles |
| 852 | cargo run --example gallery -- --svg target/readme-buffers |
| 853 | python3 tools/render-gallery.py target/readme-buffers assets/readme --readme README.md |
| 854 | python3 tools/render-gallery.py target/readme-buffers assets/readme --readme README.md --check |
| 855 | ``` |
| 856 | |
| 857 | The optional animation build needs Node, `sharp` and FFmpeg. Each animation |
| 858 | comes from deterministic actual-buffer frames, using one shared media builder: |
| 859 | |
| 860 | ```sh |
| 861 | cargo run --locked --example habitat -- --frames target/habitat-frames |
| 862 | node tools/render-animation.cjs target/habitat-frames assets/readme/habitat-motion.gif |
| 863 | python3 tools/check-animation.py target/habitat-frames assets/readme/habitat-motion.gif |
| 864 | cargo run --locked --example motion -- --frames target/motion-frames |
| 865 | node tools/render-animation.cjs target/motion-frames assets/readme/motion-demo.gif |
| 866 | python3 tools/check-animation.py target/motion-frames assets/readme/motion-demo.gif |
| 867 | cargo run --locked --example motion -- --frames target/motion-light-frames --profile light-truecolor |
| 868 | node tools/render-animation.cjs target/motion-light-frames assets/readme/motion-demo-light.gif |
| 869 | python3 tools/check-animation.py target/motion-light-frames assets/readme/motion-demo-light.gif |
| 870 | cargo run --locked --example showcase -- --frames target/showcase-frames |
| 871 | node tools/render-animation.cjs target/showcase-frames assets/readme/showcase.gif |
| 872 | python3 tools/check-animation.py target/showcase-frames assets/readme/showcase.gif |
| 873 | cargo run --locked --example showcase -- --frames target/showcase-light-frames --profile light-truecolor |
| 874 | node tools/render-animation.cjs target/showcase-light-frames assets/readme/showcase-light.gif |
| 875 | python3 tools/check-animation.py target/showcase-light-frames assets/readme/showcase-light.gif |
| 876 | cargo run --locked --example showcase -- --frames target/whale-action-frames --section life |
| 877 | node tools/render-animation.cjs target/whale-action-frames assets/readme/whale-performance.gif |
| 878 | python3 tools/check-animation.py target/whale-action-frames assets/readme/whale-performance.gif |
| 879 | ``` |
| 880 | |
| 881 | CI verifies both the current frame hash and the GIF file hash; it needs no |
| 882 | raster tools. Static previews and the live terminal example use the normal |
| 883 | Rust/Python toolchain. |
| 884 | |
| 885 | In the interactive gallery: `↑↓` or `j/k` selects a component, `p/P` switches |
| 886 | terminal profile, `w/W` switches width, `PgUp/PgDn` scrolls tall previews, |
| 887 | `Home/End` jumps through them, and `q` or `Esc` exits. This includes the full |
| 888 | 17-action whale sheet on an ordinary-height terminal. `f` expands the canvas |
| 889 | for the composed workspace scenes. The habitat example uses `p` for profile, |
| 890 | `m` for motion and `q` to close. |
| 891 | In the motion example, `Space` finishes or restarts the demonstration, `v` |
| 892 | switches working/verification, `r` replays, `p` changes profile, and `m` |
| 893 | changes motion policy. `q` or `Esc` closes it. |
| 894 | |
| 895 | In the studio, `F1`–`F6` choose the six sections. `F7` changes terminal profile, |
| 896 | `F8` motion policy, `F9` native TUI theme, and `F10` the example work phase. |
| 897 | The composer starts focused. `Enter` queues a follow-up while work is running; |
| 898 | `Esc` interrupts the illustrative turn and keeps the draft. `Shift+Tab` changes |
| 899 | permission. The decision accepts an explicit answer. Life uses `←→` to study |
| 900 | an action and `Space` to play all seventeen. |
| 901 | In Work, `Ctrl+X` opens Fleet, `Alt+W` focuses the workbar, and Left/Right |
| 902 | switches its panel while focused. `Esc` closes the dock. Color controls select |
| 903 | optional ombré washes separately from the native F9 theme. |
| 904 | Components supports search and tall-preview scrolling. `Ctrl+R` restarts the |
| 905 | demonstration; `q` or `Esc` closes outside editing. |
| 906 | `Ctrl+C` closes from any section or focus. |
| 907 | |
| 908 | Profiles: `dark-truecolor`, `dark-graphite`, `light-truecolor`, `dark-256`, |
| 909 | `light-256`, `ansi-16`, `unknown-ground`, `no-color`, `ascii`. |
| 910 | |
| 911 | ## Verify it |
| 912 | |
| 913 | ```sh |
| 914 | cargo fmt --check |
| 915 | cargo clippy --all-targets --locked -- -D warnings |
| 916 | cargo test --locked |
| 917 | cargo test --example gallery --locked |
| 918 | cargo run --locked --manifest-path tests/consumer/Cargo.toml |
| 919 | RUSTDOCFLAGS=-Dwarnings cargo doc --locked --no-deps |
| 920 | python3 vendor/codewhale-design/generate.py --check |
| 921 | ``` |
| 922 | |
| 923 | Run `cargo bench --bench render` for the prepared-widget and native-view |
| 924 | measurements described in [BENCHMARKS.md](BENCHMARKS.md). |
| 925 | |
| 926 | Snapshots record the role each run uses, alongside its glyphs. Tests exercise |
| 927 | profiles and widths, Unicode input, missing data, clipped output and disabled |
| 928 | controls. The generated README boards can be checked separately with the |
| 929 | command above. GitHub CI qualifies the branch; a local pass proves local |
| 930 | behavior only. |
| 931 | |
| 932 | ## Update source palettes and design assets |
| 933 | |
| 934 | The native TUI palette export retains the source's backgrounds, permission, |
| 935 | mode and status slots. With a current Codewhale checkout: |
| 936 | |
| 937 | ```sh |
| 938 | python3 tools/export-tui-palettes.py ../codewhale |
| 939 | python3 tools/export-tui-palettes.py ../codewhale --check |
| 940 | ``` |
| 941 | |
| 942 | Tokens are vendored from the private `codewhale-design` source. Maintainers |
| 943 | with that checkout can sync and regenerate: |
| 944 | |
| 945 | ```sh |
| 946 | ../codewhale-design/scripts/sync-to.sh . |
| 947 | CODEWHALE_BLESS=1 cargo test --test generated |
| 948 | ``` |
| 949 | |
| 950 | `src/roles.rs` is generated from the tokens, including terminal-derived hint, |
| 951 | dim and diff-tint roles. Contrast tests cover truecolor and quantized colors. |
| 952 | |
| 953 | `assets/whale-v2.scenes` holds contours exported from the v2 whale kit. To |
| 954 | update or check them with that source available: |
| 955 | |
| 956 | ```sh |
| 957 | node tools/export-whale.cjs <path-to-whale-character-v2> |
| 958 | node tools/export-whale.cjs <path-to-whale-character-v2> --check |
| 959 | ``` |
| 960 | |
| 961 | `tests/whale.rs` checks all 17 actions against the kit's 32×16 and 20×10 stills, |
| 962 | dot for dot. Artwork shows up to three calves; the state label gives the true |
| 963 | agent count, including larger fleets. Compact or ASCII terminals keep the |
| 964 | state in words when the art cannot fit. |
| 965 | |
| 966 | |
| 967 | </details> |
| 968 | |
| 969 | MIT · [License](LICENSE). Use as a Git dependency during development; |
| 970 | the crate has not been published to a package registry. |
| 971 | |
| 972 | ### Native decision band |
| 973 | |
| 974 | `DecisionBand` extends the approval components with a bottom-anchored native |
| 975 | band over caller-projected body, option and validated rule-coverage facts. |
| 976 | `plan(area)` returns the same body/control/save region, stable option-order |
| 977 | rectangles and save visibility that `render(area, buffer)` paints. A host keeps |
| 978 | its own decision handler and enables persistent-save keys only while the last |
| 979 | paint reports `save_shown`; no `ApprovalState` or second decision loop is needed. |
| 980 | The gallery's `approval-native-band` and collapsed companion use this real API. |
| 981 | The existing bordered `ApprovalCard` keeps its verbatim-subject and caller-key |
| 982 | contract. The band accepts host-projected display lines; it does not reparse |
| 983 | commands, infer policy or construct permission rules. |
| 984 | |
| 985 | ### Mounted composer row plan |
| 986 | |
| 987 | `NativeComposerFrame` projects host-owned scalar cursor/selection, localized |
| 988 | styled copy, completion/history menu facts and live styles through one pure |
| 989 | layout/paint/caret/viewport/pointer plan. Raw source positions retain hidden |
| 990 | characters; display content is guarded before width measurement and paint. |
| 991 | `NativeComposer` uses the same plan and keeps its existing grapheme cursor |
| 992 | API. The actual `native-composer-rich-selection` and `native-composer-rich-search` gallery |
| 993 | entries show both presentations. Editing, bindings, IME, completion filtering |
| 994 | and submit dispatch stay with the host. |
| 995 | |
| 996 | |
| 997 | ### Mounted transcript viewport |
| 998 | |
| 999 | `TranscriptViewport` projects host-parsed styled rows through one clipped |
| 1000 | content/chrome plan, retaining pinned rows, offsets, semantic styles and exact |
| 1001 | scrollbar/jump geometry. `TranscriptViewportPlan::link_rects` returns only |
| 1002 | visible cells and excludes opaque jump chrome; targets never enter kit data. |
| 1003 | The measured selection helper accepts a host's existing terminal column grammar |
| 1004 | without owning its parser, clipboard, streaming cache or selection state. |
| 1005 | Staged content/chrome paint lets a host retain semantic Ocean finishing between |
| 1006 | them. The actual `transcript-mounted` and `transcript-mounted-focus` gallery |
| 1007 | entries use this API. Existing authored `Transcript`/`TranscriptBlock` remain |
| 1008 | the structured content option; this viewport does not reparse native rows. |
| 1009 | |
| 1010 | |
| 1011 | `ocean::OceanPaintFacts` carries cached absolute-row colors and protected |
| 1012 | semantic rectangles into `OceanColumn::apply_native`; its ink callback returns |
| 1013 | the exact color the host backend would show over the proposed water without |
| 1014 | changing source cells. `OceanContrastInks` maps the same decorative/supporting |
| 1015 | contrast floors to actual live palette colors. `ocean_semantic_surfaces` |
| 1016 | projects display-safe prewrapped styled rows using the host's column grammar; |
| 1017 | `TranscriptViewportPlan::display_rows()` supplies its exact pinned/offset rows; |
| 1018 | explicit backgrounds remain semantic even if their RGB equals a pane base. |
| 1019 | `apply_caustics` finishes only already painted ordinary water, shares capability |
| 1020 | and reduced-motion gates, and spares visible symbols, reversed cells and |
| 1021 | semantic padding. Both methods retain the existing measured dark truecolor |
| 1022 | Ocean gate; facts and an explicit ramp do not grant terminal capability. The |
| 1023 | `ocean-native-guarded` gallery entry exercises cached water, caustics, selected |
| 1024 | source, blank semantic padding and reverse protection across all profiles. |
| 1025 | |
| 1026 | ### Host-owned Dock tabs and character frames |
| 1027 | |
| 1028 | `DockTabRow` is the tab row used by `Workbar` and the native Engine Dock |
| 1029 | adapter. Give it the caller's available `WorkbarTab` facts, active panel, |
| 1030 | pressed/hovered targets, five live `DockTabStyles` and the close text that matches |
| 1031 | your actual action. `row.plan(area).hitboxes()` and `(&row).render(area, buf)` use |
| 1032 | the same fitting rules. The host owns focus, Esc handling and action dispatch. |
| 1033 | The Engine's full Dock body remains separate from this tab presentation slice. |
| 1034 | |
| 1035 | For a small companion or an externally simulated frame with a raw caption: |
| 1036 | |
| 1037 | ```rust |
| 1038 | use codewhale_ratatui::BrailleFrame; |
| 1039 | use ratatui::{style::Style, widgets::Widget}; |
| 1040 | |
| 1041 | // Row-major packed cells from your existing simulation; zero is transparent. |
| 1042 | BrailleFrame { cells: &cells, caption: "resting", style: Style::default() } |
| 1043 | .render(area, buf); |
| 1044 | ``` |
| 1045 | |
| 1046 | The last viewport row holds the centered caption. Tiny viewports keep the |
| 1047 | complete wrapped text cue. Ink and modifiers are supplied by the caller; the |
| 1048 | component has no clock or activity model. The Engine cameo and live embedded |
| 1049 | world both use this path. `Whale::paint_frame` shares its cell painter and keeps |
| 1050 | its own semantic caption, admission rules and theme gradient. This API does not |
| 1051 | replace the Engine's character controller or accessibility policy. |
| 1052 | |
| 1053 | The guarded Ocean gallery uses `OceanPaintFacts`, `OceanCausticFacts` and |
| 1054 | `ocean_semantic_surfaces`; `OceanContrastInks` supplies host role mapping for |
| 1055 | native finishing through the existing guarded |
| 1056 | `OceanColumn` methods. Their facts preserve host protection and ink roles; |
| 1057 | terminal capability, motion and semantic contrast guards still apply. |
| 1058 | |
| 1059 | `WorkbarLayout::for_body` fits the already-admitted body viewport from current |
| 1060 | row counts and header facts. `WorkbarScrollbar` paints its rail using the same |
| 1061 | current offset/counts and caller-supplied symbols/styles. Both Workbar and the |
| 1062 | Engine body use these calculations. No remembered selection, focus or scrolling |
| 1063 | state lives in the kit; native row composition and action receipts stay with |
| 1064 | the host. |
| 1065 |