1use std::path::PathBuf;
15
16#[derive(Debug, Clone, Copy)]
17pub struct Step {
18 pub heading: &'static str,
19 pub body: &'static str,
20}
21
22pub const STEPS: &[Step] = &[
23 Step {
24 heading: "Welcome to teamctl-ui",
25 body: "A live view of your team. Agents sidebar on the left, with Detail above Mailbox on the right. Press any key to advance, Esc to leave.",
26 },
27 Step {
28 heading: "Agents + state glyphs",
29 body: "Each agent shows a single-cell glyph: ● working · ○ idle · ! approval pending · ✕ stopped · ? unknown. Tab to focus the Agents column, j/k to walk it.",
30 },
31 Step {
32 heading: "Detail pane",
33 body: "The selected agent's tmux session streams here. The title line shows which agent you're following; lines tail-clip to fit.",
34 },
35 Step {
36 heading: "Mailbox tabs",
37 body: "Inbox / Sent / Channel / Wire — `→` walks forward, `←` walks back, when the mailbox pane is focused. Tab itself always cycles pane focus, never tabs. Inbox is DMs to the focused agent; Sent is everything that agent has emitted (DMs, telegram replies, channel posts, wire broadcasts); Wire is project-wide broadcasts.",
38 },
39 Step {
40 heading: "Mailbox row UX",
41 body: "Inside the mailbox: j/k walks rows, PageDown/PageUp jumps a screen, Home/End jumps to ends. `f` filters by sender substring, `/` searches by body substring — both compose, both per-tab, Esc reverts, Enter keeps. ⏎ on a selected row opens a detail modal with the full body + metadata; Esc or q closes. Every row carries a short relative-time stamp (`2m`/`1h`/`3d`) on the right.",
42 },
43 Step {
44 heading: "Approvals",
45 body: "When an agent files request_approval, a stripe appears at the top. Press `a` to open the modal, then `y` to approve or Shift-`N` to deny. j/k cycle if multiple are pending.",
46 },
47 Step {
48 heading: "Compose",
49 body: "@ DMs the focused agent; ! broadcasts to a channel (picker first). The editor is vim-style — i to insert, Esc to normal, Ctrl+Enter to send, Esc Esc to cancel.",
50 },
51 Step {
52 heading: "Layouts",
53 body: "Ctrl+W toggles Wall view (4 agents at once + scroll). Ctrl+M toggles Mailbox-first (channel-feed centric). Both fall back to Triptych on toggle.",
54 },
55 Step {
56 heading: "Splits",
57 body: "Ctrl+| / Ctrl+- split the detail pane so you can watch two agents at once. Ctrl+H/J/K/L cycles between splits, Ctrl+W q closes the focused one.",
58 },
59 Step {
60 heading: "Help + quit",
61 body: "? opens the full keymap. q quits (with confirm). t reopens this tour. You're ready.",
62 },
63];
64
65pub fn sentinel_path(team_root: &std::path::Path) -> PathBuf {
69 team_root.join("state/ui-tutorial-completed")
70}
71
72pub fn has_completed(team_root: &std::path::Path) -> bool {
73 sentinel_path(team_root).exists()
74}
75
76pub fn mark_completed(team_root: &std::path::Path) -> std::io::Result<()> {
90 let path = sentinel_path(team_root);
91 if let Some(parent) = path.parent() {
92 std::fs::create_dir_all(parent)?;
93 }
94 std::fs::write(&path, b"")
95}
96
97#[cfg(test)]
98mod tests {
99 use super::*;
100 use std::fs;
101
102 #[test]
103 fn step_count_under_ten() {
104 assert!(
110 STEPS.len() <= 10,
111 "tutorial bloated to {} steps",
112 STEPS.len()
113 );
114 }
115
116 #[test]
117 fn sentinel_round_trip_in_tempdir() {
118 let tmp = tempfile::tempdir().unwrap();
119 let root = tmp.path();
120 assert!(!has_completed(root));
121 mark_completed(root).unwrap();
122 assert!(has_completed(root));
123 let marker = sentinel_path(root);
126 let bytes = fs::read(&marker).unwrap();
127 assert!(bytes.is_empty());
128 }
129}