use super::{centered, fg, INK3, SEED};
use ratatui::layout::Rect;
use ratatui::text::{Line, Span};
use ratatui::widgets::{Block, Clear, Paragraph};
use ratatui::Frame;
const KEYS: &[(&str, &str)] = &[
("1-7, tab", "switch tab"),
("4 5 6 7", "Models, Jobs, Envs, Spaces"),
("↑↓ j k, pgup/pgdn, g G", "move"),
("⏎", "open · expand · act"),
("/", "filter the list · search models (Models)"),
(":", "command bar"),
("r", "refresh now"),
("c / y", "copy node address / SDK line"),
("space, + -, p", "sharing, workers, price (Share)"),
("a", "start zc agent (when it is not running)"),
("q, ctrl-c", "quit · esc closes overlays first"),
];
const COMMANDS: &[(&str, &str)] = &[
(":price <n>", "set this machine's price per hour"),
(":workers <n>", "set the worker count"),
(":share on|off", "turn sharing on or off"),
(":copy <zc://…>", "copy an address"),
(":models [words]", "open Models, searched"),
(":jobs :envs :spaces", "open that tab"),
(":env stop <id>", "stop an environment"),
(":space cancel|pause|resume <id>", "act on a Space"),
(":refresh :quit", ""),
(
":model :dataset :env :space",
"look up on the hub (ls, show …)",
),
(
":usage :tx :quotas :squad",
"account and squads, outside the session",
),
(":connect :disconnect", "run outside the session, with"),
(":up :down :update :login", "the terminal (sudo, progress)"),
];
pub fn render(f: &mut Frame, area: Rect) {
let mut lines = vec![Line::from(Span::styled("Keys", fg(SEED)))];
for (k, v) in KEYS {
lines.push(Line::from(vec![
Span::raw(format!(" {k:<32}")),
Span::styled(*v, fg(INK3)),
]));
}
lines.push(Line::default());
lines.push(Line::from(Span::styled("Commands", fg(SEED))));
for (k, v) in COMMANDS {
lines.push(Line::from(vec![
Span::raw(format!(" {k:<32}")),
Span::styled(*v, fg(INK3)),
]));
}
let r = centered(area, 80, lines.len() as u16 + 2);
f.render_widget(Clear, r);
f.render_widget(
Paragraph::new(lines).block(
Block::bordered()
.border_style(fg(INK3))
.title(" help · esc to close "),
),
r,
);
}