Add goal TUI UX (5 / 5) (#18077)

Adds the TUI user experience for goals on top of the core runtime from
PR 4.

## Why

Users need a direct TUI control surface for long-running goals. The UI
should make the current goal visible, support common goal actions
without waiting for a model turn, and avoid confusing end-of-turn
notifications while an active goal is immediately continuing.

## What changed

- Added `/goal` summary rendering for the current goal, including
active, paused, budget-limited, and complete states.
- Added `/goal <objective>` creation/replacement through the app-server
goal API rather than a model prompt.
- Added `/goal clear`, `/goal pause`, and `/goal unpause` command
variants.
- Added a confirmation menu when the user enters a new goal while
another goal already exists.
- Updated `/goal` help and summary tip text so it reflects the supported
command variants without advertising slash-command token budgets.
- Added footer/statusline goal indicators, including elapsed time and
token budget display when a budget exists from API/tool-created goals.
- Consumes goal updated/cleared notifications so the TUI stays in sync
with external app-server changes.
- Suppresses end-of-turn desktop notifications only when a goal is still
active and follow-up work is expected.
- Preserves slash-command history behavior and avoids leaking queued
`/goal` state into unrelated submissions.

## Verification

- Added TUI unit and snapshot coverage for goal command availability,
summary rendering, control commands, replacement menu behavior,
status/footer display, notification handling, and command history.
This commit is contained in:
Eric Traut authored and GitHub committed 2026-04-24 21:16:45 -07:00
1 parent 4167628622
commit f1c963d77e
32 files changed
+2709 -177

No files matched your search

+40
View File
@@ -95,6 +95,14 @@ pub(crate) enum CollaborationModeIndicator {
Execute,
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub(crate) enum GoalStatusIndicator {
Active { usage: Option<String> },
Paused,
BudgetLimited { usage: Option<String> },
Complete { usage: Option<String> },
}
const MODE_CYCLE_HINT: &str = "shift+tab to cycle";
const FOOTER_CONTEXT_GAP_COLS: u16 = 1;
@@ -483,6 +491,38 @@ pub(crate) fn mode_indicator_line(
indicator.map(|indicator| Line::from(vec![indicator.styled_span(show_cycle_hint)]))
}
pub(crate) fn goal_status_indicator_line(
indicator: Option<&GoalStatusIndicator>,
) -> Option<Line<'static>> {
let indicator = indicator?;
let label = match indicator {
GoalStatusIndicator::Active { usage } => {
if let Some(usage) = usage {
format!("Pursuing goal ({usage})")
} else {
"Pursuing goal".to_string()
}
}
GoalStatusIndicator::Paused => "Goal paused (/goal to unpause)".to_string(),
GoalStatusIndicator::BudgetLimited { usage } => {
if let Some(usage) = usage {
format!("Goal unmet ({usage})")
} else {
"Goal abandoned".to_string()
}
}
GoalStatusIndicator::Complete { usage } => {
if let Some(usage) = usage {
format!("Goal achieved ({usage})")
} else {
"Goal achieved".to_string()
}
}
};
Some(Line::from(vec![Span::from(label).magenta()]))
}
pub(crate) fn side_conversation_context_line(label: &str) -> Line<'static> {
if let Some(rest) = label.strip_prefix("Side ") {
Line::from(vec!["Side".magenta().bold(), format!(" {rest}").magenta()])