๐๐ผโโ๏ธ The blackboard for coding agents - agentic development environment for claude code, codex, cursor, opencode, grok and more.
Rust adeai-agentsclaudeclaude-codecodexcursorgeminigrokopencodespec-driven-developmentvibe-codingvim
feat: polish tui (#143)
Fynn Fluegged763abd4a3ca
diff --git a/CLAUDE.md b/CLAUDE.mdindex dd9b5e6..f964d41 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -480,7 +480,7 @@ In global mode all CRUD tools (`list_tasks`, `create_task`, etc.) require a `proGlobal config lives at `~/.config/agtx/config.toml` (`GlobalConfig`):```tomldefault_agent = "claude"-fullscreen_on_enter = false # When true, Enter on a task attaches to tmux directly instead of opening the in-TUI popup+fullscreen_on_enter = false # When true, Enter opens the task's tmux pane fullscreen inside agtxagent_hooks = true # Write agent lifecycle-hook configs into worktrees (see Hook-Based Phase Status)auto_trust = false # Answer agents' trust / bypass-permission prompts by reading the pane (see First-Launch Dialogs)update_check = true # Daily GitHub release check + header notice (see Self-Update)@@ -549,7 +549,7 @@ color_popup_header = "#69fae7" # Popup headers (light cyan)| `o` | Create new task || `Enter` | Open task popup (tmux view) / Edit task (backlog) || `x` | Delete task (with confirmation) |-| `Ctrl+f` | Fullscreen attach to task's tmux session |+| `Ctrl+f` | Open the task popup fullscreen; press again to return to windowed mode || `d` | Show git diff for task || `D` | Open dependency-graph overlay || `m` | Move task forward (advance workflow) |@@ -590,7 +590,7 @@ color_popup_header = "#69fae7" # Popup headers (light cyan)| `Ctrl+j/k` or `Ctrl+n/p` | Scroll up/down || `Ctrl+d/u` or `PageDown/PageUp` | Page down/up || `Ctrl+g` | Jump to bottom |-| `Ctrl+f` | Fullscreen attach to tmux session |+| `Ctrl+f` | Toggle the task popup between windowed and fullscreen modes || `Ctrl+q` | Close popup || Other keys | Forwarded to tmux/agent (including `Esc`) |diff --git a/README.md b/README.mdindex 640be3a..8c09803 100644--- a/README.md+++ b/README.md@@ -172,7 +172,7 @@ reason, and you answer it in the agent's own pane (`โฉ` to open the task).| `o` | Create new task || `R` | Enter research mode || `โฉ` | Open task (view agent session) |-| `Ctrl+f` | Fullscreen attach to task's tmux session |+| `Ctrl+f` | Open the task popup fullscreen; press again to return to windowed mode || `m` | Move task forward in workflow || `r` | Resume task (Review โ Running) / Move back (Running โ Planning) || `p` | Next phase (Review โ Planning, cyclic plugins only) |@@ -214,12 +214,12 @@ When writing a task description, you can reference files, skills, and other task### Agent Sessions-Each task runs in its own tmux window with a dedicated coding agent. The session persists across the entire task lifecycle โ you can open the task popup at any time to see live agent output, or press `Ctrl+f` to attach fullscreen.+Each task runs in its own tmux window with a dedicated coding agent. The session persists across the entire task lifecycle โ you can open the task popup at any time to see live agent output, or press `Ctrl+f` to open it fullscreen inside agtx.- **Persistent context**: The agent's full conversation history is preserved across Planning โ Running โ Review- **Resume from Review**: Moving a task back to Running simply reconnects to the existing session โ no re-initialization needed- **Inline view**: Press `โฉ` on any active task to open a scrollable tmux view inside the TUI-- **Fullscreen**: Press `Ctrl+f` to attach directly to the agent's tmux window+- **Fullscreen**: Press `Ctrl+f` to expand the task popup inside agtx. Press `Ctrl+f` again for windowed mode or `Ctrl+q` to return to the board.- **Auto merge-conflict resolution**: When a Review task becomes idle, agtx checks for merge conflicts with the default branch using a non-destructive virtual merge (`git merge-tree`). If conflicts are detected, the agent is automatically sent the `/agtx:merge-conflicts` skill to resolve them and re-commit## Brainstorm & Sweep Skills@@ -346,7 +346,7 @@ Config file location: `~/.config/agtx/config.toml````tomldefault_agent = "claude"-fullscreen_on_enter = false # Enter attaches to tmux directly instead of the in-TUI popup+fullscreen_on_enter = false # When true, Enter opens the tmux pane fullscreen inside agtxagent_hooks = true # Let agents report their own phase status via lifecycle hooksauto_trust = false # Answer agents' trust prompts on your behalfupdate_check = true # Check GitHub daily for a new release (see Updating)diff --git a/src/tmux/operations.rs b/src/tmux/operations.rsindex 9e894fa..909f3c2 100644--- a/src/tmux/operations.rs+++ b/src/tmux/operations.rs@@ -65,8 +65,8 @@ pub trait TmuxOperations: Send + Sync {/// Capture pane content with history (returns raw bytes for ANSI parsing)fn capture_pane_with_history(&self, target: &str, history_lines: i32) -> Vec<u8>;- /// Get cursor position and pane height: (cursor_y, pane_height)- fn get_cursor_info(&self, target: &str) -> Option<(usize, usize)>;+ /// Get cursor position and pane height: (cursor_x, cursor_y, pane_height)+ fn get_cursor_info(&self, target: &str) -> Option<(usize, usize, usize)>;/// Resize a tmux windowfn resize_window(&self, target: &str, width: u16, height: u16) -> Result<()>;@@ -245,27 +245,36 @@ impl TmuxOperations for RealTmuxOps {fn capture_pane_with_history(&self, target: &str, history_lines: i32) -> Vec<u8> {std::process::Command::new("tmux").args(["-L", super::AGENT_SERVER])- .args(["capture-pane", "-t", target, "-p", "-e", "-J"])+ // Keep wrapped rows separate: tmux reports cursor_y in physical+ // pane rows, so joining wrapped rows would misalign the cursor.+ .args(["capture-pane", "-t", target, "-p", "-e"]).args(["-S", &format!("-{}", history_lines)]).output().map(|o| o.stdout).unwrap_or_default()}- fn get_cursor_info(&self, target: &str) -> Option<(usize, usize)> {+ fn get_cursor_info(&self, target: &str) -> Option<(usize, usize, usize)> {let output = std::process::Command::new("tmux").args(["-L", super::AGENT_SERVER])- .args(["display", "-p", "-t", target, "#{cursor_y} #{pane_height}"])+ .args([+ "display",+ "-p",+ "-t",+ target,+ "#{cursor_x} #{cursor_y} #{pane_height}",+ ]).output().ok()?;if output.status.success() {let output_str = String::from_utf8_lossy(&output.stdout);let parts: Vec<&str> = output_str.trim().split_whitespace().collect();- if parts.len() == 2 {- let cursor_y: usize = parts[0].parse().ok()?;- let pane_height: usize = parts[1].parse().ok()?;- return Some((cursor_y, pane_height));+ if parts.len() == 3 {+ let cursor_x: usize = parts[0].parse().ok()?;+ let cursor_y: usize = parts[1].parse().ok()?;+ let pane_height: usize = parts[2].parse().ok()?;+ return Some((cursor_x, cursor_y, pane_height));}}Nonediff --git a/src/tui/app.rs b/src/tui/app.rsindex 55bb2ba..742279f 100644--- a/src/tui/app.rs+++ b/src/tui/app.rs@@ -29,6 +29,7 @@ use crate::AppMode;use super::board::BoardState;use super::input::InputMode;use super::shell_popup::{self, ShellPopup};+use super::theme::TuiStyles;/// Helper to convert hex color string to ratatui Colorfn hex_to_color(hex: &str) -> Color {@@ -87,6 +88,59 @@ fn build_footer_text(}}+/// Turn the existing contextual help string into modern keycap/value spans.+/// Keeping `build_footer_text` as the source preserves its tested behavior.+fn styled_footer(text: &str, styles: TuiStyles) -> Line<'static> {+ let mut spans = Vec::new();+ let mut rest = text.trim();+ while let Some(open) = rest.find('[') {+ if open > 0 {+ spans.push(Span::styled(rest[..open].to_string(), styles.muted()));+ }+ let Some(close) = rest[open..].find(']') else {+ spans.push(Span::styled(rest[open..].to_string(), styles.muted()));+ rest = "";+ break;+ };+ let end = open + close + 1;+ spans.push(Span::styled(rest[open..end].to_string(), styles.keycap()));+ rest = &rest[end..];+ }+ if !rest.is_empty() {+ spans.push(Span::styled(rest.to_string(), styles.muted()));+ }+ Line::from(spans)+}++fn visible_column_range(selected: usize, width: u16) -> std::ops::Range<usize> {+ let visible = if width >= 140 { 5 } else if width >= 96 { 3 } else { 2 };+ let start = selected+ .saturating_sub(visible / 2)+ .min(5usize.saturating_sub(visible));+ start..start + visible+}++fn board_scrollbar_metrics(+ total_items: usize,+ visible_items: usize,+ scroll_offset: usize,+ track_height: usize,+) -> Option<(usize, usize)> {+ if track_height == 0 || total_items <= visible_items || visible_items == 0 {+ return None;+ }++ let min_thumb_height = track_height.min(2);+ let thumb_height = (visible_items * track_height / total_items)+ .max(min_thumb_height)+ .min(track_height);+ let max_thumb_pos = track_height.saturating_sub(thumb_height);+ let max_scroll_offset = total_items.saturating_sub(visible_items);+ let thumb_pos = scroll_offset.min(max_scroll_offset) * max_thumb_pos / max_scroll_offset;++ Some((thumb_pos, thumb_height))+}+type Terminal = ratatui::Terminal<AppBackend>;/// Backend abstraction: real CrosstermBackend in production, TestBackend in tests.@@ -252,6 +306,9 @@ struct AppState {show_project_list: bool,// Task shell popupshell_popup: Option<ShellPopup>,+ // At most one pane-history capture runs off the input thread at a time.+ shell_refresh_rx:+ Option<mpsc::Receiver<(String, Vec<u8>, Option<(usize, usize, usize)>)>>,// File search dropdownfile_search: Option<FileSearchState>,// Skill search dropdown@@ -716,6 +773,7 @@ impl App {selected_project: 0,show_project_list: false,shell_popup: None,+ shell_refresh_rx: None,file_search: None,skill_search: None,task_ref_search: None,@@ -940,6 +998,7 @@ impl App {selected_project: 0,show_project_list: false,shell_popup: None,+ shell_refresh_rx: None,file_search: None,skill_search: None,task_ref_search: None,@@ -1059,7 +1118,7 @@ impl App {// Process MCP transition requests from the command queueself.process_transition_requests()?;- if event::poll(std::time::Duration::from_millis(100))? {+ if event::poll(main_event_poll_timeout(self.state.shell_popup.is_some()))? {match event::read()? {Event::Key(key) if key.kind == KeyEventKind::Press => {self.handle_key(key)?;@@ -1071,13 +1130,46 @@ impl App {}}- // Refresh shell popup content periodically (every poll cycle when open)- if let Some(ref mut popup) = self.state.shell_popup {- popup.cached_content = capture_tmux_pane_with_history(- &popup.window_name,- 500,- self.state.tmux_ops.as_ref(),- );+ // Apply a completed pane capture without ever waiting for tmux on+ // the input thread.+ if let Some(ref rx) = self.state.shell_refresh_rx {+ match rx.try_recv() {+ Ok((window_name, content, cursor_info)) => {+ self.state.shell_refresh_rx = None;+ if let Some(popup) = self.state.shell_popup.as_mut() {+ if popup.window_name == window_name {+ popup.cached_content = content;+ popup.cursor_info = cursor_info;+ }+ }+ }+ Err(std::sync::mpsc::TryRecvError::Disconnected) => {+ self.state.shell_refresh_rx = None;+ }+ Err(std::sync::mpsc::TryRecvError::Empty) => {}+ }+ }++ // Capturing history invokes tmux twice (content + cursor metadata),+ // so run it in a single background worker at a responsive 20 FPS.+ if self.state.shell_refresh_rx.is_none() {+ if let Some(popup) = self.state.shell_popup.as_mut() {+ if popup.content_refresh_due(SHELL_REFRESH_INTERVAL) {+ let window_name = popup.window_name.clone();+ let tmux_ops = Arc::clone(&self.state.tmux_ops);+ let (tx, rx) = mpsc::channel();+ popup.mark_content_refreshed();+ self.state.shell_refresh_rx = Some(rx);+ std::thread::spawn(move || {+ let (content, cursor_info) = capture_tmux_pane_snapshot(+ &window_name,+ 500,+ tmux_ops.as_ref(),+ );+ let _ = tx.send((window_name, content, cursor_info));+ });+ }+ }}// Apply results from background session refresh (non-blocking)@@ -1192,22 +1284,21 @@ impl App {main_chunks[0]};- // Main layout: header, board, footer+ let styles = TuiStyles::from_theme(&state.config.theme);++ // Main layout: compact application bar, board, contextual command bar.let chunks = Layout::default().direction(Direction::Vertical).constraints([- Constraint::Length(3), // Header+ Constraint::Length(2), // Header + dividerConstraint::Min(0), // Board- Constraint::Length(3), // Footer+ Constraint::Length(2), // Divider + footer]).split(content_area);// Headerlet plugin_label = state.config.workflow_plugin.as_deref().unwrap_or("agtx");- let left = Span::styled(- format!(" {} ", state.project_name),- Style::default().fg(Color::Cyan).bold(),- );+ let left = Span::styled(format!(" {}", state.project_name), Style::default().fg(styles.text).bold());let mut right_spans: Vec<Span> = Vec::new();if state.flags.experimental {let orch_active = state.orchestrator_session.is_some();@@ -1246,30 +1337,35 @@ impl App {Style::default().fg(hex_to_color(&state.config.theme.color_dimmed)),),]);- let left_len = state.project_name.len() + 2;+ let left_len = state.project_name.chars().count() + 2;// Character count, not byte count: the update notice's "โฌ" is 3 bytes// and one column, and a byte-based width would over-pad the header.let right_len: usize = right_spans.iter().map(|s| s.content.chars().count()).sum();- let padding = (chunks[0].width as usize).saturating_sub(left_len + right_len + 2); // 2 for borders+ let padding = (chunks[0].width as usize).saturating_sub(left_len + right_len + 2);let mut spans = vec![left, Span::raw(" ".repeat(padding))];spans.extend(right_spans);- let header =- Paragraph::new(Line::from(spans)).block(Block::default().borders(Borders::ALL));- frame.render_widget(header, chunks[0]);+ frame.render_widget(Paragraph::new(Line::from(spans)), Rect { height: 1, ..chunks[0] });+ frame.render_widget(+ Paragraph::new("โ".repeat(chunks[0].width as usize)).style(styles.muted()),+ Rect { y: chunks[0].y + 1, height: 1, ..chunks[0] },+ );- // Board columns (5 columns: Backlog, Planning, Running, Review, Done)- let columns = Layout::default()- .direction(Direction::Horizontal)- .constraints([- Constraint::Percentage(20),- Constraint::Percentage(20),- Constraint::Percentage(20),- Constraint::Percentage(20),- Constraint::Percentage(20),- ])- .split(chunks[1]);+ // Keep cards usable on narrow terminals by showing a window around the+ // selected column. Navigation still spans all five workflow columns.+ let visible_range = visible_column_range(state.board.selected_column, chunks[1].width);+ let mut constraints = Vec::new();+ for slot in 0..visible_range.len() {+ if slot > 0 {+ constraints.push(Constraint::Length(1));+ }+ constraints.push(Constraint::Ratio(1, visible_range.len() as u32));+ }+ let board_areas = Layout::horizontal(constraints).split(chunks[1]);- for (i, status) in TaskStatus::columns().iter().enumerate() {+ let statuses = TaskStatus::columns();+ for (slot, i) in visible_range.enumerate() {+ let status = &statuses[i];+ let column_area = board_areas[slot * 2];let tasks: Vec<&Task> = state.board.tasks@@ -1279,22 +1375,38 @@ impl App {let is_selected_column = state.board.selected_column == i;- let title = format!(" {} ({}) ", status.display_name(), tasks.len());- let (border_style, title_style) = if is_selected_column {- (- Style::default().fg(hex_to_color(&state.config.theme.color_selected)),- Style::default().fg(hex_to_color(&state.config.theme.color_selected)),- )+ let title_style = if is_selected_column {+ Style::default().fg(styles.selected).bold()} else {- (- Style::default().fg(hex_to_color(&state.config.theme.color_normal)),- Style::default().fg(hex_to_color(&state.config.theme.color_column_header)),- )+ Style::default().fg(styles.column_header).bold()};- // Calculate card height (title + preview lines + borders)- let card_height: u16 = 10; // 1 title + 7 preview lines + 2 borders- let max_visible_cards = (columns[i].height.saturating_sub(2) / card_height) as usize;+ let header_area = Rect { height: 2, ..column_area };+ let count = Span::styled(format!(" {}", tasks.len()), styles.muted());+ frame.render_widget(+ Paragraph::new(Line::from(vec![+ Span::styled(+ format!(" {}", status.display_name().to_uppercase()),+ title_style,+ ),+ count,+ ])),+ Rect { height: 1, ..header_area },+ );+ let rule_color = if is_selected_column { styles.selected } else { styles.dimmed };+ frame.render_widget(+ Paragraph::new("โ".repeat(header_area.width as usize))+ .style(Style::default().fg(rule_color)),+ Rect { y: header_area.y + 1, height: 1, ..header_area },+ );++ let inner_area = Rect {+ y: column_area.y + 2,+ height: column_area.height.saturating_sub(2),+ ..column_area+ };+ let card_height: u16 = if column_area.height >= 34 { 8 } else { 6 };+ let max_visible_cards = (inner_area.height / card_height).max(1) as usize;// Calculate scroll offset to keep selected task visiblelet scroll_offset = if is_selected_column && tasks.len() > max_visible_cards {@@ -1310,21 +1422,6 @@ impl App {// Check if we need a scrollbarlet needs_scrollbar = tasks.len() > max_visible_cards;- let content_width = if needs_scrollbar {- columns[i].width.saturating_sub(3) // Leave room for scrollbar- } else {- columns[i].width.saturating_sub(2)- };-- // Draw column border- let column_block = Block::default()- .title(title)- .title_style(title_style)- .borders(Borders::ALL)- .border_style(border_style);- let inner_area = column_block.inner(columns[i]);- frame.render_widget(column_block, columns[i]);-// Render task cards with scroll offsetlet visible_tasks: Vec<_> = tasks.iter()@@ -1367,6 +1464,11 @@ impl App {);}+ if tasks.is_empty() {+ let empty = if is_selected_column { " No tasks ยท [o] new" } else { " No tasks" };+ frame.render_widget(Paragraph::new(empty).style(styles.muted()), inner_area);+ }+// Draw scrollbar if neededif needs_scrollbar {let scrollbar_area = Rect {@@ -1376,28 +1478,30 @@ impl App {height: inner_area.height,};- let total_tasks = tasks.len();let scrollbar_height = inner_area.height as usize;- let thumb_height = (max_visible_cards * scrollbar_height / total_tasks).max(1);- let thumb_pos = (scroll_offset * scrollbar_height / total_tasks)- .min(scrollbar_height - thumb_height);-- for y in 0..scrollbar_height {- let char = if y >= thumb_pos && y < thumb_pos + thumb_height {- "โ"- } else {- "โ"- };- let style = Style::default().fg(hex_to_color(&state.config.theme.color_dimmed));- frame.render_widget(- Paragraph::new(char).style(style),- Rect {- x: scrollbar_area.x,- y: scrollbar_area.y + y as u16,- width: 1,- height: 1,- },- );+ if let Some((thumb_pos, thumb_height)) = board_scrollbar_metrics(+ tasks.len(),+ max_visible_cards,+ scroll_offset,+ scrollbar_height,+ ) {+ for y in 0..scrollbar_height {+ let is_thumb = y >= thumb_pos && y < thumb_pos + thumb_height;+ let (glyph, style) = if is_thumb {+ ("โ", Style::default().fg(styles.selected).bold())+ } else {+ ("โ", styles.muted())+ };+ frame.render_widget(+ Paragraph::new(glyph).style(style),+ Rect {+ x: scrollbar_area.x,+ y: scrollbar_area.y + y as u16,+ width: 1,+ height: 1,+ },+ );+ }}}}@@ -1437,10 +1541,19 @@ impl App {)};- let footer = Paragraph::new(footer_text.as_str())- .style(footer_style)- .block(Block::default().borders(Borders::ALL));- frame.render_widget(footer, chunks[2]);+ frame.render_widget(+ Paragraph::new("โ".repeat(chunks[2].width as usize)).style(styles.muted()),+ Rect { height: 1, ..chunks[2] },+ );+ let footer_line = if footer_style.fg == Some(Color::Yellow) {+ Line::from(Span::styled(format!(" {}", footer_text.trim()), footer_style))+ } else {+ styled_footer(&footer_text, styles)+ };+ frame.render_widget(+ Paragraph::new(footer_line).alignment(Alignment::Center),+ Rect { y: chunks[2].y + 1, height: 1, ..chunks[2] },+ );// Input overlay if in input modeif matches!(@@ -1554,6 +1667,7 @@ impl App {// IME composition (Korean, Japanese, Chinese) inline at the cursor// instead of drifting to wherever the last text was written.let mut cursor_display: Option<(u16, u16)> = None;+ let mut selected_plugin_rows: Option<std::ops::Range<usize>> = None;let cursor_line_start = lines.len();match state.input_mode {InputMode::InputTitle => {@@ -1584,6 +1698,7 @@ impl App {InputMode::SelectPlugin => {let active_plugin = state.config.workflow_plugin.as_deref().unwrap_or("");for (i, opt) in state.wizard_plugin_options.iter().enumerate() {+ let option_start = lines.len();let is_sel = i == state.wizard_selected_plugin;let marker = if is_sel { " > " } else { " " };let is_project_default = (opt.name.is_empty() && active_plugin.is_empty())@@ -1596,18 +1711,18 @@ impl App {} else {Style::default().fg(text_color)};- push_wrapped(- &mut lines,- vec![- Span::styled(marker.to_string(), name_style),- Span::styled(format!("{:<14}", &opt.label), name_style),- Span::styled(- opt.description.clone(),- Style::default().fg(desc_color),- ),- Span::styled(check.to_string(), Style::default().fg(Color::Green)),- ],- );+ lines.extend(wizard_plugin_option_lines(+ marker,+ &opt.label,+ &opt.description,+ check,+ name_style,+ Style::default().fg(desc_color),+ wrap_width,+ ));+ if is_sel {+ selected_plugin_rows = Some(option_start..lines.len());+ }}}InputMode::InputDescription => {@@ -1656,8 +1771,13 @@ impl App {// No `.wrap(...)` โ `lines` is already pre-wrapped by `wrap_spans`// to fit `wrap_width`. Letting Ratatui re-wrap would re-introduce// the two-source-of-truth bug between renderer and cursor.+ let viewport_height = input_area.height.saturating_sub(2) as usize;+ let wizard_scroll = selected_plugin_rows+ .map(|selected| wizard_plugin_scroll_offset(lines.len(), viewport_height, selected))+ .unwrap_or(0);let content = Paragraph::new(Text::from(lines)).style(Style::default().fg(text_color))+ .scroll((wizard_scroll as u16, 0)).block(Block::default().title(block_title)@@ -2682,8 +2802,11 @@ impl App {}fn draw_shell_popup(popup: &ShellPopup, frame: &mut Frame, area: Rect, theme: &ThemeConfig) {- let popup_area =- centered_rect_fixed_width(SHELL_POPUP_WIDTH, SHELL_POPUP_HEIGHT_PERCENT, area);+ let popup_area = if popup.fullscreen {+ area+ } else {+ centered_rect_fixed_width(SHELL_POPUP_WIDTH, SHELL_POPUP_HEIGHT_PERCENT, area)+ };// Parse ANSI escape sequences for colorslet styled_lines = parse_ansi_to_lines(&popup.cached_content);@@ -2712,10 +2835,11 @@ impl App {spinner_frame: usize,deps_blocked: bool,) {+ let styles = TuiStyles::from_theme(theme);let border_style = if is_selected {- Style::default().fg(hex_to_color(&theme.color_selected))+ Style::default().fg(styles.selected)} else {- Style::default().fg(hex_to_color(&theme.color_normal))+ Style::default().fg(styles.dimmed)};let title_style = if is_selected {@@ -2739,18 +2863,17 @@ impl App {task.title.clone()};- let border_type = if is_selected {- BorderType::Thick- } else {- BorderType::Plain- };-let card_block = Block::default().borders(Borders::ALL).border_style(border_style)- .border_type(border_type);- let inner = card_block.inner(area);+ .border_type(if is_selected { BorderType::Rounded } else { BorderType::Plain });+ let block_inner = card_block.inner(area);frame.render_widget(card_block, area);+ let inner = Rect {+ x: block_inner.x.saturating_add(1),+ width: block_inner.width.saturating_sub(2),+ ..block_inner+ };// Title line with optional phase indicatorlet show_indicator = matches!(@@ -2833,7 +2956,7 @@ impl App {frame.render_widget(title_line, title_area);}- // Footer line with agent name (for active tasks)+ // Footer line with a compact phase label and agent badge.let show_agent = task.status != TaskStatus::Backlog || task.session_name.is_some();let footer_height = if show_agent && inner.height > 2 {1u16@@ -2851,7 +2974,7 @@ impl App {};// Show description or placeholder- let preview_text = task.description.as_deref().unwrap_or("No description");+ let preview_text = task.description.as_deref().unwrap_or("");// Truncate description to fit preview arealet max_chars = (preview_area.width as usize) * (preview_area.height as usize);@@ -2868,11 +2991,7 @@ impl App {};let preview = Paragraph::new(truncated)- .style(- Style::default()- .fg(hex_to_color(&theme.color_description))- .italic(),- )+ .style(Style::default().fg(styles.description)).wrap(Wrap { trim: true });frame.render_widget(preview, preview_area);}@@ -2905,14 +3024,28 @@ impl App {}None => Style::default().fg(Color::White),};- let agent_label = Paragraph::new(format!(" {} ", task.agent))- .style(agent_style)- .alignment(Alignment::Right);- frame.render_widget(agent_label, footer_area);+ let phase_label = phase_status.map(|(status, _)| match status {+ PhaseStatus::Ready => "โ Ready",+ PhaseStatus::Working => "โ Working",+ PhaseStatus::Blocked => "? Blocked",+ PhaseStatus::Idle => "โ ก Idle",+ PhaseStatus::Exited => "ร Exited",+ });+ let mut spans = Vec::new();+ if let Some(label) = phase_label {+ spans.push(Span::styled(label, styles.muted()));+ }+ let used: usize = spans.iter().map(|span| span.width()).sum();+ let agent = format!(" {} ", task.agent);+ let gap = (footer_area.width as usize).saturating_sub(used + agent.chars().count());+ spans.push(Span::raw(" ".repeat(gap)));+ spans.push(Span::styled(agent, agent_style));+ frame.render_widget(Paragraph::new(Line::from(spans)), footer_area);}}fn draw_sidebar(state: &AppState, frame: &mut Frame, area: Rect) {+ let styles = TuiStyles::from_theme(&state.config.theme);// Show projects from databaselet current_path = state.project_path@@ -2937,25 +3070,42 @@ impl App {Style::default().fg(hex_to_color(&state.config.theme.color_text))};- let marker = if is_current { " โ" } else { "" };- ListItem::new(format!(" {}{}", project.name, marker)).style(style)+ let marker = if is_current { "โ" } else { " " };+ ListItem::new(format!("{} {}", marker, project.name)).style(style)}).collect();- let title = format!(" ๐ Projects ({}) ", state.projects.len());- let border_color = if state.sidebar_focused {- hex_to_color(&state.config.theme.color_selected)+ let title_style = if state.sidebar_focused {+ Style::default().fg(styles.selected).bold()} else {- hex_to_color(&state.config.theme.color_normal)+ Style::default().fg(styles.column_header).bold()};- let list = List::new(items).block(+ frame.render_widget(+ Paragraph::new(Line::from(vec![+ Span::styled(" PROJECTS", title_style),+ Span::styled(format!(" {}", state.projects.len()), styles.muted()),+ ])),+ Rect { height: 1, ..area },+ );+ frame.render_widget(+ Paragraph::new("โ".repeat(area.width.saturating_sub(1) as usize)).style(styles.muted()),+ Rect { y: area.y + 1, height: 1, ..area },+ );+ frame.render_widget(+ List::new(items),+ Rect {+ x: area.x + 1,+ y: area.y + 3,+ width: area.width.saturating_sub(2),+ height: area.height.saturating_sub(3),+ },+ );+ frame.render_widget(Block::default()- .title(title)- .borders(Borders::ALL)- .border_style(Style::default().fg(border_color)),+ .borders(Borders::RIGHT)+ .border_style(styles.muted()),+ area,);-- frame.render_widget(list, area);}fn draw_dashboard(state: &AppState, frame: &mut Frame, area: Rect) {@@ -3148,18 +3298,13 @@ impl App {AppMode::Dashboard => self.handle_dashboard_key(key.code),AppMode::Project(_) => match self.state.input_mode {InputMode::Normal => {- // Ctrl+f = fullscreen attach (handled here since handle_normal_key only gets KeyCode)+ // Ctrl+f = open the selected task in the in-app fullscreen view.if key.code == KeyCode::Char('f')&& key.modifiers.contains(crossterm::event::KeyModifiers::CONTROL){- if let Some(task) = self.state.board.selected_task() {- if let Some(window_name) = task.session_name.clone() {- self.state.shell_popup = None;- return self.attach_to_tmux_fullscreen(&window_name);- }- }+ self.open_selected_task_fullscreen()?;return Ok(());}self.handle_normal_key(key.code)@@ -3831,6 +3976,19 @@ impl App {return Ok(());}+ // Ctrl+Space is a prefix for keys that agtx normally reserves for+ // popup navigation (for example Ctrl+q or Ctrl+u). This preserves+ // complete terminal access without leaving the in-app fullscreen.+ if popup.pass_through_next_key {+ popup.pass_through_next_key = false;+ send_key_to_tmux(&window_name, key, self.state.tmux_ops.as_ref());+ return Ok(());+ }+ if has_ctrl && matches!(key.code, KeyCode::Char(' ')) {+ popup.pass_through_next_key = true;+ return Ok(());+ }+match key.code {// Ctrl+q = close popupKeyCode::Char('q') if has_ctrl => {@@ -3862,22 +4020,33 @@ impl App {KeyCode::Char('g') if has_ctrl => {popup.scroll_to_bottom();}- // Ctrl+f = fullscreen attach to tmux session+ // Ctrl+f toggles between centered and fullscreen in-app views.KeyCode::Char('f') if has_ctrl => {- // Close the popup first so the tmux window isn't stuck at popup dimensions- self.state.shell_popup = None;- self.attach_to_tmux_fullscreen(&window_name)?;+ popup.fullscreen = !popup.fullscreen;+ let (pane_width, pane_height) = if popup.fullscreen {+ crossterm::terminal::size()+ .map(|(width, height)| {+ (width.saturating_sub(2), height.saturating_sub(4))+ })+ .unwrap_or((SHELL_POPUP_CONTENT_WIDTH, 20))+ } else {+ let height = crossterm::terminal::size()+ .map(|(_, height)| {+ (height as u32 * SHELL_POPUP_HEIGHT_PERCENT as u32 / 100) as u16+ })+ .unwrap_or(24);+ (SHELL_POPUP_CONTENT_WIDTH, height.saturating_sub(4))+ };+ let _ = self+ .state+ .tmux_ops+ .resize_window(&window_name, pane_width, pane_height);+ popup.last_pane_size = Some((pane_width, pane_height));return Ok(());}_ => {// Forward all other keys to tmux window (including Esc)send_key_to_tmux(&window_name, key, self.state.tmux_ops.as_ref());- // After sending a key, refresh content to show the result- popup.cached_content = capture_tmux_pane_with_history(- &window_name,- 500,- self.state.tmux_ops.as_ref(),- );}}}@@ -4083,8 +4252,7 @@ impl App {if task.status == TaskStatus::Backlog && task.session_name.is_some() {// Backlog task with active research sessionif self.state.config.fullscreen_on_enter {- let window_name = task.session_name.clone().unwrap();- self.attach_to_tmux_fullscreen(&window_name)?;+ self.open_selected_task_fullscreen()?;} else {self.open_selected_task()?;}@@ -4098,8 +4266,7 @@ impl App {} else if task.session_name.is_some() {// Open shell popup or fullscreenif self.state.config.fullscreen_on_enter {- let window_name = task.session_name.clone().unwrap();- self.attach_to_tmux_fullscreen(&window_name)?;+ self.open_selected_task_fullscreen()?;} else {self.open_selected_task()?;}@@ -6999,92 +7166,20 @@ impl App {Ok(())}- /// Suspend the TUI and attach directly to a tmux window for full interaction.- /// Restores the TUI when the user detaches (Ctrl+b d).- fn attach_to_tmux_fullscreen(&mut self, window_name: &str) -> Result<()> {- // window_name is the full session:window target (e.g. "docugap:task-75189cbb-test")- // Check if the tmux window still exists before attempting to attach.- if !self- .state- .tmux_ops- .window_exists(window_name)- .unwrap_or(true)- {- self.state.warning_message = Some((- "Session window no longer exists".to_string(),- std::time::Instant::now(),- ));- return Ok(());- }-- let session = &self.state.tmux_project_name;-- // Check if we're already inside the agtx tmux server โ if so, just- // switch windows instead of nesting with attach.- let inside_agtx = std::env::var("TMUX")- .map(|v| v.contains(tmux::AGENT_SERVER))- .unwrap_or(false);-- if inside_agtx {- // Already inside agtx tmux โ just switch to the task window.- // window_name is already session:window format, use it directly.- let _ = std::process::Command::new("tmux")- .args([- "-L",- tmux::AGENT_SERVER,- "select-window",- "-t",- window_name,- ";",- "resize-window",- "-A",- ])- .output();- } else {- // Leave alternate screen and disable raw mode- match self.terminal.backend_mut() {- AppBackend::Crossterm(backend) => {- let _ = disable_raw_mode();- let _ = execute!(backend, LeaveAlternateScreen, DisableBracketedPaste);- }- #[cfg(feature = "test-mocks")]- AppBackend::Test(_) => {}- }-- // Attach to the agtx tmux server, select the task window, and resize.- // Unset $TMUX so tmux allows attaching when inside a different tmux.- let _ = std::process::Command::new("tmux")- .args([- "-L",- tmux::AGENT_SERVER,- "attach",- "-t",- session,- ";",- "select-window",- "-t",- window_name,- ";",- "resize-window",- "-A",- ])- .env_remove("TMUX")- .status();-- // Restore terminal- match self.terminal.backend_mut() {- AppBackend::Crossterm(backend) => {- enable_raw_mode()?;- execute!(backend, EnterAlternateScreen, EnableBracketedPaste)?;- }- #[cfg(feature = "test-mocks")]- AppBackend::Test(_) => {}+ fn open_selected_task_fullscreen(&mut self) -> Result<()> {+ self.open_selected_task()?;+ if let Some(popup) = self.state.shell_popup.as_mut() {+ popup.fullscreen = true;+ if let Ok((width, height)) = crossterm::terminal::size() {+ let pane_size = (width.saturating_sub(2), height.saturating_sub(4));+ let _ = self.state.tmux_ops.resize_window(+ &popup.window_name,+ pane_size.0,+ pane_size.1,+ );+ popup.last_pane_size = Some(pane_size);}-- // Force full redraw- self.terminal.clear()?;}-Ok(())}@@ -8529,6 +8624,14 @@ fn capture_tmux_pane_with_history(history_lines: i32,tmux_ops: &dyn TmuxOperations,) -> Vec<u8> {+ capture_tmux_pane_snapshot(window_name, history_lines, tmux_ops).0+}++fn capture_tmux_pane_snapshot(+ window_name: &str,+ history_lines: i32,+ tmux_ops: &dyn TmuxOperations,+) -> (Vec<u8>, Option<(usize, usize, usize)>) {let content = tmux_ops.capture_pane_with_history(window_name, history_lines);// Get the cursor position and pane height to know where the "real" content ends@@ -8536,7 +8639,11 @@ fn capture_tmux_pane_with_history(let cursor_info = tmux_ops.get_cursor_info(window_name);// Trim content to only include lines up to cursor position- shell_popup::trim_content_to_cursor(content, cursor_info)+ let trim_info = cursor_info.map(|(_, y, height)| (y, height));+ (+ shell_popup::trim_content_to_cursor(content, trim_info),+ cursor_info,+ )}/// Generate PR title and description using the configured agent@@ -8667,6 +8774,7 @@ fn send_key_to_tmux() {use crossterm::event::KeyModifiers;let has_alt = key.modifiers.contains(KeyModifiers::ALT);+ let has_ctrl = key.modifiers.contains(KeyModifiers::CONTROL);let base = match key.code {KeyCode::Char(c) => c.to_string(),@@ -8688,11 +8796,27 @@ fn send_key_to_tmux(_ => return,};- let key_str = if has_alt { format!("M-{}", base) } else { base };+ let key_str = match (has_ctrl, has_alt) {+ (true, true) => format!("C-M-{}", base),+ (true, false) => format!("C-{}", base),+ (false, true) => format!("M-{}", base),+ (false, false) => base,+ };let _ = tmux_ops.send_key(window_name, &key_str);}+const SHELL_REFRESH_INTERVAL: std::time::Duration = std::time::Duration::from_millis(50);+const DEFAULT_EVENT_POLL_INTERVAL: std::time::Duration = std::time::Duration::from_millis(100);++fn main_event_poll_timeout(shell_popup_open: bool) -> std::time::Duration {+ if shell_popup_open {+ SHELL_REFRESH_INTERVAL+ } else {+ DEFAULT_EVENT_POLL_INTERVAL+ }+}+/// Parse ANSI escape sequences to ratatui Lines with colorsfn parse_ansi_to_lines(bytes: &[u8]) -> Vec<Line<'static>> {let text = String::from_utf8_lossy(bytes);@@ -8925,6 +9049,70 @@ fn wrap_spans(spans: Vec<Span<'static>>, wrap_width: usize) -> Vec<Line<'static>visual.into_iter().map(Line::from).collect()}+/// Render one plugin choice with a fixed metadata column and an independently+/// wrapped description column. Continuation rows start beneath the description+/// rather than at the wizard's left border.+fn wizard_plugin_option_lines(+ marker: &str,+ label: &str,+ description: &str,+ check: &str,+ name_style: Style,+ description_style: Style,+ width: usize,+) -> Vec<Line<'static>> {+ const LABEL_WIDTH: usize = 14;+ const CHECK_WIDTH: usize = 2;+ const RIGHT_PADDING: usize = 2;++ let marker_width = Span::raw(marker.to_string()).width();+ let prefix_width = marker_width + LABEL_WIDTH + CHECK_WIDTH;+ let description_width = width+ .saturating_sub(prefix_width + RIGHT_PADDING)+ .max(1);+ let mut description_lines = wrap_spans(+ vec![Span::styled(description.to_string(), description_style)],+ description_width,+ );+ if description_lines.is_empty() {+ description_lines.push(Line::default());+ }++ let short_label = truncate_str(label, LABEL_WIDTH);+ let check = format!("{:<CHECK_WIDTH$}", check);+ for (index, line) in description_lines.iter_mut().enumerate() {+ let mut spans = if index == 0 {+ vec![+ Span::styled(marker.to_string(), name_style),+ Span::styled(format!("{short_label:<LABEL_WIDTH$}"), name_style),+ Span::styled(check.clone(), Style::default().fg(Color::Green)),+ ]+ } else {+ vec![Span::raw(" ".repeat(prefix_width))]+ };+ spans.append(&mut line.spans);+ *line = Line::from(spans);+ }+ description_lines+}++/// Keep the complete selected plugin entry inside the wizard viewport while+/// retaining as much preceding context as possible.+fn wizard_plugin_scroll_offset(+ total_rows: usize,+ viewport_rows: usize,+ selected_rows: std::ops::Range<usize>,+) -> usize {+ if viewport_rows == 0 || total_rows <= viewport_rows {+ return 0;+ }++ selected_rows+ .end+ .saturating_sub(viewport_rows)+ .min(total_rows.saturating_sub(viewport_rows))+}+/// Snap `pos` back to the nearest UTF-8 char boundary at or before it./// Cursor arithmetic tracks bytes, but String indexing panics mid-codepoint โ/// callers use this to stay valid after moving across multi-byte chars.diff --git a/src/tui/app_tests.rs b/src/tui/app_tests.rsindex bf4a4b0..32e0920 100644--- a/src/tui/app_tests.rs+++ b/src/tui/app_tests.rs@@ -9,6 +9,80 @@ use crate::git::{MockGitOperations, MockGitProviderOperations};#[cfg(feature = "test-mocks")]use crate::tmux::MockTmuxOperations;+#[test]+fn visible_columns_use_all_columns_on_wide_terminals() {+ assert_eq!(visible_column_range(0, 160), 0..5);+ assert_eq!(visible_column_range(4, 140), 0..5);+}++#[test]+fn visible_columns_follow_selection_on_standard_terminals() {+ assert_eq!(visible_column_range(0, 120), 0..3);+ assert_eq!(visible_column_range(2, 120), 1..4);+ assert_eq!(visible_column_range(4, 120), 2..5);+}++#[test]+fn visible_columns_keep_two_usable_columns_on_narrow_terminals() {+ assert_eq!(visible_column_range(0, 80), 0..2);+ assert_eq!(visible_column_range(2, 80), 1..3);+ assert_eq!(visible_column_range(4, 80), 3..5);+}++#[test]+fn board_scrollbar_has_visible_thumb_and_reaches_track_ends() {+ assert_eq!(board_scrollbar_metrics(10, 3, 0, 12), Some((0, 3)));+ assert_eq!(board_scrollbar_metrics(10, 3, 7, 12), Some((9, 3)));+ assert_eq!(board_scrollbar_metrics(20, 1, 0, 8), Some((0, 2)));+}++#[test]+fn board_scrollbar_is_hidden_without_overflow_or_height() {+ assert_eq!(board_scrollbar_metrics(3, 3, 0, 12), None);+ assert_eq!(board_scrollbar_metrics(10, 3, 0, 0), None);+}++#[test]+fn styled_footer_emphasizes_shortcuts_without_changing_text() {+ let styles = TuiStyles::from_theme(&ThemeConfig::default());+ let line = styled_footer(" [o] new [Enter] open ", styles);+ let rendered: String = line.spans.iter().map(|span| span.content.as_ref()).collect();+ assert_eq!(rendered, "[o] new [Enter] open");+ assert_eq!(line.spans[0].style.fg, Some(styles.selected));+ assert_eq!(line.spans[1].style.fg, Some(styles.dimmed));+}++#[test]+fn wizard_plugin_descriptions_wrap_and_align() {+ let lines = wizard_plugin_option_lines(+ " > ",+ "agtx",+ "A deliberately long plugin description that must stay inside the wizard",+ " โ",+ Style::default(),+ Style::default(),+ 42,+ );++ assert!(lines.len() > 1);+ for line in &lines {+ assert!(line.width() <= 40, "line reached the right margin: {:?}", line);+ }+ let continuation: String = lines[1]+ .spans+ .iter()+ .map(|span| span.content.as_ref())+ .collect();+ assert!(continuation.starts_with(&" ".repeat(20)));+}++#[test]+fn wizard_plugin_scroll_keeps_late_selection_visible() {+ assert_eq!(wizard_plugin_scroll_offset(30, 10, 24..27), 17);+ assert_eq!(wizard_plugin_scroll_offset(30, 10, 4..7), 0);+ assert_eq!(wizard_plugin_scroll_offset(8, 10, 6..8), 0);+}+/// Test that generate_pr_description correctly combines git diff and agent-generated text#[test]#[cfg(feature = "test-mocks")]@@ -870,6 +944,57 @@ fn test_send_key_to_tmux_alt_b_f() {);}+/// Control modifiers must reach the pane so terminal programs can be+/// interrupted, suspended, or otherwise controlled from the in-app popup.+#[test]+#[cfg(feature = "test-mocks")]+fn test_send_key_to_tmux_control_char() {+ let mut mock_tmux = MockTmuxOperations::new();+ mock_tmux+ .expect_send_key()+ .with(mockall::predicate::eq("win"), mockall::predicate::eq("C-c"))+ .times(1)+ .returning(|_, _| Ok(()));++ send_key_to_tmux(+ "win",+ crossterm::event::KeyEvent::new(+ KeyCode::Char('c'),+ crossterm::event::KeyModifiers::CONTROL,+ ),+ &mock_tmux,+ );+}++#[test]+#[cfg(feature = "test-mocks")]+fn test_send_key_to_tmux_control_alt_char() {+ let mut mock_tmux = MockTmuxOperations::new();+ mock_tmux+ .expect_send_key()+ .with(+ mockall::predicate::eq("win"),+ mockall::predicate::eq("C-M-x"),+ )+ .times(1)+ .returning(|_, _| Ok(()));++ send_key_to_tmux(+ "win",+ crossterm::event::KeyEvent::new(+ KeyCode::Char('x'),+ crossterm::event::KeyModifiers::CONTROL | crossterm::event::KeyModifiers::ALT,+ ),+ &mock_tmux,+ );+}++#[test]+fn shell_popup_uses_twenty_fps_poll_interval() {+ assert_eq!(main_event_poll_timeout(true), std::time::Duration::from_millis(50));+ assert_eq!(main_event_poll_timeout(false), std::time::Duration::from_millis(100));+}+// =============================================================================// Tests for capture_tmux_pane_with_history// =============================================================================@@ -891,7 +1016,7 @@ fn test_capture_tmux_pane_with_history() {mock_tmux.expect_get_cursor_info().with(mockall::predicate::eq("test-window"))- .returning(|_| Some((2, 3))); // cursor at line 2, pane has 3 lines+ .returning(|_| Some((0, 2, 3))); // cursor at column 0, line 2, pane has 3 lineslet content = capture_tmux_pane_with_history("test-window", 500, &mock_tmux);diff --git a/src/tui/mod.rs b/src/tui/mod.rsindex 873dff0..5e45054 100644--- a/src/tui/mod.rs+++ b/src/tui/mod.rs@@ -3,6 +3,7 @@ pub mod board;pub mod dep_graph;mod input;pub mod shell_popup;+mod theme;pub use app::App;pub use shell_popup::ShellPopup;diff --git a/src/tui/shell_popup.rs b/src/tui/shell_popup.rsindex 27d1a48..e89676e 100644--- a/src/tui/shell_popup.rs+++ b/src/tui/shell_popup.rs@@ -1,5 +1,6 @@use ratatui::prelude::*;use ratatui::widgets::{Block, Borders, Clear, Paragraph};+use std::time::{Duration, Instant};/// State for the shell popup that shows a detached tmux window#[derive(Debug, Clone)]@@ -15,6 +16,15 @@ pub struct ShellPopup {pub escalation_note: Option<String>,/// Task ID (used to clear escalation note on dismiss)pub task_id: Option<String>,+ /// Whether the popup fills the agtx terminal instead of using a centered window.+ pub fullscreen: bool,+ /// Pane capture is deliberately throttled so typing never performs two+ /// expensive tmux captures for every character.+ pub last_content_refresh: Instant,+ /// Cursor position inside the visible tmux pane and its pane height.+ pub cursor_info: Option<(usize, usize, usize)>,+ /// Forward the next key directly to tmux, even when agtx normally owns it.+ pub pass_through_next_key: bool,}impl ShellPopup {@@ -27,6 +37,10 @@ impl ShellPopup {last_pane_size: None,escalation_note: None,task_id: None,+ fullscreen: false,+ last_content_refresh: Instant::now(),+ cursor_info: None,+ pass_through_next_key: false,}}@@ -54,6 +68,14 @@ impl ShellPopup {pub fn is_at_bottom(&self) -> bool {self.scroll_offset >= 0}++ pub fn content_refresh_due(&self, interval: Duration) -> bool {+ self.last_content_refresh.elapsed() >= interval+ }++ pub fn mark_content_refreshed(&mut self) {+ self.last_content_refresh = Instant::now();+ }}/// Computed view data for rendering - separates computation from rendering@@ -117,13 +139,22 @@ pub fn compute_visible_lines<'a>(/// Build the footer text for the shell popuppub fn build_footer_text(scroll_offset: i32, start_line: usize) -> String {+ build_footer_text_for_mode(scroll_offset, start_line, false)+}++fn build_footer_text_for_mode(scroll_offset: i32, start_line: usize, fullscreen: bool) -> String {+ let view_action = if fullscreen { "windowed" } else { "fullscreen" };if scroll_offset < 0 {format!(- " [C-j/k] scroll [C-d/u] page [C-g] bottom [C-f] fullscreen [C-q] close | Line {} ",- start_line + 1+ " Line {} | [C-g] bottom [C-f] {} [C-Space] send next [C-q] close [C-j/k] scroll [C-d/u] page ",+ start_line + 1,+ view_action)} else {- " [C-j/k] scroll [C-d/u] page [C-f] fullscreen [C-q] close | At bottom ".to_string()+ format!(+ " At bottom | [C-f] {} [C-Space] send next [C-q] close [C-j/k] scroll [C-d/u] page ",+ view_action+ )}}@@ -255,7 +286,8 @@ pub fn render_shell_popup(// Draw border around the popuplet border_block = Block::default().borders(Borders::ALL)- .border_style(Style::default().fg(colors.border));+ .border_style(Style::default().fg(colors.border))+ .border_type(ratatui::widgets::BorderType::Rounded);let inner_area = border_block.inner(popup_area);frame.render_widget(border_block, popup_area);@@ -274,10 +306,10 @@ pub fn render_shell_popup(.split(inner_area);// Title bar (pad to fill width)- let title = format!(" {} ", popup.task_title);+ let title = format!(" {} ", popup.task_title);let padded_title = format!("{:<width$}", title, width = popup_chunks[0].width as usize);let title_bar = Paragraph::new(padded_title)- .style(Style::default().fg(colors.header_fg).bg(colors.header_bg));+ .style(Style::default().fg(colors.header_bg).bold());frame.render_widget(title_bar, popup_chunks[0]);// Escalation banner (if present)@@ -306,20 +338,36 @@ pub fn render_shell_popup(let visible_height = popup_chunks[2].height as usize;// Use the testable helper to compute visible lines- let (visible_lines, start_line, _total_lines) =+ let (visible_lines, start_line, total_lines) =compute_visible_lines(styled_lines, visible_height, popup.scroll_offset);let content = Paragraph::new(visible_lines);frame.render_widget(content, popup_chunks[2]);+ // A captured pane is text-only; explicitly restore tmux's live cursor when+ // it falls inside the current (non-scrolled) viewport.+ if popup.scroll_offset >= 0 {+ if let Some((cursor_x, cursor_y, pane_height)) = popup.cursor_info {+ let pane_start = total_lines.saturating_sub(pane_height);+ let cursor_line = pane_start.saturating_add(cursor_y);+ if cursor_line >= start_line && cursor_line < start_line + visible_height {+ let x = popup_chunks[2]+ .x+ .saturating_add(cursor_x.min(popup_chunks[2].width.saturating_sub(1) as usize) as u16);+ let y = popup_chunks[2].y.saturating_add((cursor_line - start_line) as u16);+ frame.set_cursor_position((x, y));+ }+ }+ }+// Footer with scroll indicator (pad to fill width)- let footer_text = build_footer_text(popup.scroll_offset, start_line);+ let footer_text = build_footer_text_for_mode(popup.scroll_offset, start_line, popup.fullscreen);let padded_footer = format!("{:<width$}",footer_text,width = popup_chunks[3].width as usize);let footer = Paragraph::new(padded_footer)- .style(Style::default().fg(colors.footer_fg).bg(colors.footer_bg));+ .style(Style::default().fg(colors.footer_bg));frame.render_widget(footer, popup_chunks[3]);}diff --git a/src/tui/theme.rs b/src/tui/theme.rsnew file mode 100644index 0000000..5bcb419--- /dev/null+++ b/src/tui/theme.rs@@ -0,0 +1,41 @@+use ratatui::prelude::*;++use crate::config::ThemeConfig;++fn color(hex: &str) -> Color {+ ThemeConfig::parse_hex(hex)+ .map(|(r, g, b)| Color::Rgb(r, g, b))+ .unwrap_or(Color::White)+}++/// Semantic styles shared by the board chrome and cards. Keeping these names+/// independent of individual widgets makes the existing palette usable by a+/// less border-heavy visual language.+#[derive(Clone, Copy)]+pub struct TuiStyles {+ pub selected: Color,+ pub dimmed: Color,+ pub text: Color,+ pub description: Color,+ pub column_header: Color,+}++impl TuiStyles {+ pub fn from_theme(theme: &ThemeConfig) -> Self {+ Self {+ selected: color(&theme.color_selected),+ dimmed: color(&theme.color_dimmed),+ text: color(&theme.color_text),+ description: color(&theme.color_description),+ column_header: color(&theme.color_column_header),+ }+ }++ pub fn keycap(self) -> Style {+ Style::default().fg(self.selected).bold()+ }++ pub fn muted(self) -> Style {+ Style::default().fg(self.dimmed)+ }+}diff --git a/tests/shell_popup_tests.rs b/tests/shell_popup_tests.rsindex e0146df..46f11f4 100644--- a/tests/shell_popup_tests.rs+++ b/tests/shell_popup_tests.rs@@ -3,6 +3,7 @@ use agtx::tui::shell_popup::{trim_trailing_empty_lines, ShellPopup, ShellPopupColors, MAX_TRAILING_EMPTY_LINES,};use ratatui::backend::TestBackend;+use std::time::{Duration, Instant};use ratatui::prelude::*;use ratatui::Terminal;@@ -17,6 +18,18 @@ fn test_shell_popup_new() {assert!(popup.last_pane_size.is_none());}+#[test]+fn test_content_refresh_is_throttled() {+ let mut popup = ShellPopup::new("Task".to_string(), "window".to_string());+ assert!(!popup.content_refresh_due(Duration::from_millis(100)));++ popup.last_content_refresh = Instant::now() - Duration::from_millis(101);+ assert!(popup.content_refresh_due(Duration::from_millis(100)));++ popup.mark_content_refreshed();+ assert!(!popup.content_refresh_due(Duration::from_millis(100)));+}+#[test]fn test_shell_popup_scroll_up() {let mut popup = ShellPopup::new("Test".to_string(), "window".to_string());@@ -203,6 +216,41 @@ fn test_build_footer_text_at_top() {assert!(footer.contains("Line 1"));}+#[test]+fn test_fullscreen_footer_offers_windowed_toggle() {+ let popup = ShellPopup {+ fullscreen: true,+ ..ShellPopup::new("Task".to_string(), "window".to_string())+ };+ let backend = TestBackend::new(80, 24);+ let mut terminal = Terminal::new(backend).unwrap();+ terminal+ .draw(|frame| {+ render_shell_popup(+ &popup,+ frame,+ Rect::new(0, 0, 80, 24),+ vec![],+ &ShellPopupColors::default(),+ );+ })+ .unwrap();+ let content: String = terminal+ .backend()+ .buffer()+ .content()+ .iter()+ .map(|cell| cell.symbol())+ .collect();+ assert!(content.contains("[C-f] windowed"));+}++#[test]+fn test_footer_documents_reserved_key_passthrough() {+ let footer = build_footer_text(0, 0);+ assert!(footer.contains("[C-Space] send next"));+}+// === Rendering Tests ===#[test]@@ -233,6 +281,8 @@ fn test_render_shell_popup_basic() {// Check that the title is rendered somewhere in the bufferlet buffer_content: String = buffer.content().iter().map(|c| c.symbol()).collect();assert!(buffer_content.contains("Test Task"));+ assert_eq!(buffer[(0, 0)].symbol(), "โญ");+ assert_eq!(buffer[(79, 0)].symbol(), "โฎ");}#[test]