Skip to main content

gallery/
overlay.rs

1//! Overlay tab: a transcript with a model-switcher modal and a help layer.
2//!
3//! `Ctrl+K` opens the switcher, `Ctrl+G` toggles help, `Esc` closes the top
4//! layer. The document keeps native scrollback while layers come and go.
5
6use omp_tui::{
7	Component, Dim, IntoComponent as _, OverlayAnchor, OverlayId, OverlayMargin, OverlayOptions,
8	Size, Ui, dom,
9};
10
11pub(crate) const MODELS: [(&str, &str, &str); 4] = [
12	("fable", "anthropic/claude-fable-5", "4.5s · 64t/s · $10/50"),
13	("flash", "google/gemini-3.6-flash", "2.6s · 342t/s · $1.5/7.5"),
14	("sol", "openai/gpt-5.6-sol", "1.7s · 41t/s · $5/30"),
15	("opus", "anthropic/claude-opus-5", "6.1s · 44t/s · $5/25"),
16];
17
18/// The overlay-demo pane hosted by the gallery's `Overlay` tab.
19pub(crate) fn pane() -> Box<dyn Component> {
20	dom! {
21		<col gap=1 pad="1 2">
22			<md>{"The **overlay demo** transcript. Document content stays on the normal screen and keeps native scrollback while layers composite above it."}</md>
23			<md>{"Press `Ctrl+K` to switch models, `Ctrl+G` for help, `Esc` to close the top layer."}</md>
24			<text id=status fg=muted>{"model: anthropic/claude-fable-5"}</text>
25			<box border=round title="Composer">
26				<input id=composer placeholder="Type while overlays come and go"/>
27			</box>
28		</col>
29	}
30	.into_component()
31}
32
33/// Opens the model-switcher modal; commit surfaces as `Changed { id: "model"
34/// }`.
35pub(crate) fn show_picker(ui: &mut Ui) -> OverlayId {
36	ui.show_overlay(
37		dom! {
38			<box border=round title="Switch Model">
39				<col gap=1>
40					<text dim>{"Session-only switch — role models stay unchanged"}</text>
41					<select id=model>
42						for (value, label, stats) in MODELS {
43							<option value={value} desc={stats}>{label}</option>
44						}
45					</select>
46				</col>
47			</box>
48		},
49		OverlayOptions::default()
50			.anchor(OverlayAnchor::Center)
51			.width(Dim::Pct(70))
52			.min_width(48)
53			.max_height(Dim::Pct(60))
54			.min_viewport(Size::new(40, 8)),
55	)
56}
57
58/// Opens the keybinding help layer.
59pub(crate) fn show_help(ui: &mut Ui) -> OverlayId {
60	ui.show_overlay(
61		dom! {
62			<box border=round title="Help">
63				<col>
64					<text>{"Ctrl+K  switch model"}</text>
65					<text>{"Ctrl+G  toggle this help"}</text>
66					<text>{"Esc     close top layer"}</text>
67					<text>{"Ctrl+C  quit"}</text>
68				</col>
69			</box>
70		},
71		OverlayOptions::default()
72			.anchor(OverlayAnchor::BottomRight)
73			.width(Dim::Cells(30))
74			.margin(OverlayMargin::uniform(1)),
75	)
76}