feat(tui): allow silent hidden-preface submissions

This commit is contained in:
James Peter
2025-12-13 09:44:30 +10:00
parent c6d6f49a9b
commit a086a4674b
3 changed files with 43 additions and 14 deletions
+10 -2
View File
@@ -2548,9 +2548,17 @@ impl App<'_> {
widget.submit_text_message_with_preface(visible, preface);
}
}
AppEvent::SubmitHiddenTextWithPreface { agent_text, preface } => {
AppEvent::SubmitHiddenTextWithPreface {
agent_text,
preface,
surface_notice,
} => {
if let AppState::Chat { widget } = &mut self.app_state {
widget.submit_hidden_text_message_with_preface(agent_text, preface);
widget.submit_hidden_text_message_with_preface_and_notice(
agent_text,
preface,
surface_notice,
);
}
}
AppEvent::RunReviewCommand(args) => {
+8 -2
View File
@@ -331,8 +331,14 @@ pub(crate) enum AppEvent {
/// Submit a message with hidden preface instructions
SubmitTextWithPreface { visible: String, preface: String },
/// Submit a hidden message that is not rendered in history but still sent to the LLM
SubmitHiddenTextWithPreface { agent_text: String, preface: String },
/// Submit a hidden message that is not rendered in history but still sent to the LLM.
/// When `surface_notice` is true, the TUI shows a developer-style notice with the
/// injected text; when false, the injection is silent.
SubmitHiddenTextWithPreface {
agent_text: String,
preface: String,
surface_notice: bool,
},
/// Run a review with an explicit prompt/hint pair (used by TUI selections)
RunReviewWithScope {
+25 -10
View File
@@ -26793,6 +26793,18 @@ Have we met every part of this goal and is there no further work to do?"#
&mut self,
agent_text: String,
preface: String,
) {
self.submit_hidden_text_message_with_preface_and_notice(agent_text, preface, true);
}
/// Submit a hidden message with optional notice surfacing.
/// When `surface_notice` is true, the injected text is also shown in history
/// as a developer-style notice; when false, the injection is silent.
pub(crate) fn submit_hidden_text_message_with_preface_and_notice(
&mut self,
agent_text: String,
preface: String,
surface_notice: bool,
) {
if agent_text.trim().is_empty() && preface.trim().is_empty() {
return;
@@ -26814,16 +26826,18 @@ Have we met every part of this goal and is there no further work to do?"#
return;
}
// Surface immediately in the TUI as a notice (developer-style message).
let mut notice_lines = Vec::new();
if !preface_cache.trim().is_empty() {
notice_lines.push(preface_cache.trim().to_string());
}
if !agent_cache.trim().is_empty() {
notice_lines.push(agent_cache.trim().to_string());
}
if !notice_lines.is_empty() {
self.history_push_plain_paragraphs(PlainMessageKind::Notice, notice_lines);
if surface_notice {
// Surface immediately in the TUI as a notice (developer-style message).
let mut notice_lines = Vec::new();
if !preface_cache.trim().is_empty() {
notice_lines.push(preface_cache.trim().to_string());
}
if !agent_cache.trim().is_empty() {
notice_lines.push(agent_cache.trim().to_string());
}
if !notice_lines.is_empty() {
self.history_push_plain_paragraphs(PlainMessageKind::Notice, notice_lines);
}
}
let msg = UserMessage {
@@ -34016,6 +34030,7 @@ impl ChatWidget<'_> {
tx.send(AppEvent::SubmitHiddenTextWithPreface {
agent_text: message,
preface: String::new(),
surface_notice: false,
});
});
}