mirror of
https://github.com/openai/codex.git
synced 2026-11-18 23:02:23 +00:00
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:
1 parent
4167628622
commit
f1c963d77e
32 files changed
+2709
-177
No files matched your search
@@ -0,0 +1,71 @@
|
||||
use super::*;
|
||||
|
||||
#[tokio::test]
|
||||
async fn goal_menu_active_snapshot() {
|
||||
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
let thread_id = ThreadId::new();
|
||||
|
||||
chat.show_goal_summary(test_goal(
|
||||
thread_id,
|
||||
AppThreadGoalStatus::Active,
|
||||
/*token_budget*/ Some(80_000),
|
||||
));
|
||||
|
||||
assert_chatwidget_snapshot!("goal_menu_active", rendered_goal_summary(&mut rx));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn goal_menu_paused_snapshot() {
|
||||
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
let thread_id = ThreadId::new();
|
||||
|
||||
chat.show_goal_summary(test_goal(
|
||||
thread_id,
|
||||
AppThreadGoalStatus::Paused,
|
||||
/*token_budget*/ None,
|
||||
));
|
||||
|
||||
assert_chatwidget_snapshot!("goal_menu_paused", rendered_goal_summary(&mut rx));
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn goal_menu_budget_limited_snapshot() {
|
||||
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
let thread_id = ThreadId::new();
|
||||
|
||||
chat.show_goal_summary(test_goal(
|
||||
thread_id,
|
||||
AppThreadGoalStatus::BudgetLimited,
|
||||
/*token_budget*/ Some(80_000),
|
||||
));
|
||||
|
||||
assert_chatwidget_snapshot!("goal_menu_budget_limited", rendered_goal_summary(&mut rx));
|
||||
}
|
||||
|
||||
fn test_goal(
|
||||
thread_id: ThreadId,
|
||||
status: AppThreadGoalStatus,
|
||||
token_budget: Option<i64>,
|
||||
) -> AppThreadGoal {
|
||||
AppThreadGoal {
|
||||
thread_id: thread_id.to_string(),
|
||||
objective: "Keep improving the bare goal command until it feels calm and useful."
|
||||
.to_string(),
|
||||
status,
|
||||
token_budget,
|
||||
tokens_used: 12_500,
|
||||
time_used_seconds: 90,
|
||||
created_at: 1_776_272_400,
|
||||
updated_at: 1_776_272_460,
|
||||
}
|
||||
}
|
||||
|
||||
fn rendered_goal_summary(
|
||||
rx: &mut tokio::sync::mpsc::UnboundedReceiver<crate::app_event::AppEvent>,
|
||||
) -> String {
|
||||
drain_insert_history(rx)
|
||||
.iter()
|
||||
.map(|lines| lines_to_single_string(lines))
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n")
|
||||
}
|
||||
Reference in new issue
Block a user