Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions nori-rs/tui/src/chatwidget/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ impl ChatWidget {
),
);
}
} else if !next_snapshot.is_empty() {
self.add_to_history(
crate::nori::session_config_history::new_agent_options_initial_history_cell(
self.bottom_pane.agent_display_name(),
config_options,
),
);
}

self.acp_config_option_snapshot = Some(next_snapshot);
Expand Down
48 changes: 44 additions & 4 deletions nori-rs/tui/src/chatwidget/tests/part3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,10 +469,10 @@ fn session_config_update_history_shows_only_changed_values_after_baseline() {
],
},
));
assert!(
drain_insert_history(&mut rx).is_empty(),
"the first config snapshot should establish a baseline without history noise"
);
// Drain (and discard) the initial-snapshot banner so the snapshot below
// captures only the subsequent change-diff cell. The banner is covered
// by `session_config_update_history_renders_startup_banner_on_first_snapshot`.
let _ = drain_insert_history(&mut rx);

chat.handle_client_event(nori_protocol::ClientEvent::SessionConfigUpdate(
nori_protocol::SessionConfigUpdate {
Expand Down Expand Up @@ -509,6 +509,46 @@ fn session_config_update_history_shows_only_changed_values_after_baseline() {
assert_snapshot!("session_config_update_changed_values_history", rendered);
}

#[test]
fn session_config_update_history_renders_startup_banner_on_first_snapshot() {
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual();
chat.set_agent("claude-code");

chat.handle_client_event(nori_protocol::ClientEvent::SessionConfigUpdate(
nori_protocol::SessionConfigUpdate {
config_options: vec![
select_config_option(
"mode",
"Mode",
"default",
&[("default", "Default"), ("plan", "Plan")],
),
select_config_option(
"model",
"Model",
"opus-4-6",
&[("opus-4-6", "Opus 4.6"), ("sonnet-4-6", "Sonnet 4.6")],
),
select_config_option(
"effort",
"Effort",
"medium",
&[("medium", "Medium"), ("high", "High")],
),
],
},
));

let cells = drain_insert_history(&mut rx);
let rendered = cells
.iter()
.map(|lines| lines_to_single_string(lines))
.collect::<Vec<_>>()
.join("\n");

assert_snapshot!("session_config_update_startup_banner", rendered);
}

#[test]
fn session_config_set_history_uses_final_agent_named_message() {
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
source: tui/src/chatwidget/tests/part3.rs
expression: rendered
---
• Claude Code options: Mode=Default, Model=Opus 4.6, Effort=Medium (/config to change)
27 changes: 27 additions & 0 deletions nori-rs/tui/src/nori/session_config_history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,33 @@ pub(crate) fn changed_values(
.collect()
}

/// Initial-snapshot banner shown the first time the agent announces its
/// session config options. Lists every option's current value and surfaces
/// the `/config` affordance so the user knows how to change them.
pub(crate) fn new_agent_options_initial_history_cell(
agent_display_name: &str,
config_options: &[acp::SessionConfigOption],
) -> PlainHistoryCell {
let agent_display_name = if agent_display_name.is_empty() {
"Agent"
} else {
agent_display_name
};
let values: Vec<SessionConfigDisplayValue> =
config_options.iter().filter_map(display_value).collect();

let mut line = vec!["• ".dim(), format!("{agent_display_name} options: ").into()];
for (index, value) in values.iter().enumerate() {
if index > 0 {
line.push(", ".into());
}
line.push(format!("{}={}", value.name, value.value).cyan().bold());
}
line.push(" (/config to change)".dim());

PlainHistoryCell::new(vec![Line::from(line)])
}

pub(crate) fn new_agent_options_history_cell(
agent_display_name: &str,
changes: &[SessionConfigDisplayValue],
Expand Down
Loading