mirror of
https://github.com/hanzoai/dev.git
synced 2026-10-25 03:23:33 +00:00
feat(tui/branch): include hidden preface with auto-submitted task instructing agent to ask for confirmation and optionally merge+cleanup on success
This commit is contained in:
@@ -872,7 +872,8 @@ impl App<'_> {
|
||||
if let AppState::Chat { widget } = &mut self.app_state {
|
||||
if let Some(prompt) = initial_prompt {
|
||||
if !prompt.is_empty() {
|
||||
widget.submit_text_message(prompt);
|
||||
let preface = "[internal] When you finish this task, ask the user if they want any changes. If they are happy, offer to merge the branch back into the repository's default branch and delete the worktree. Wait for explicit confirmation before merging.".to_string();
|
||||
widget.submit_text_message_with_preface(prompt, preface);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5627,6 +5627,22 @@ impl ChatWidget<'_> {
|
||||
self.submit_user_message(text.into());
|
||||
}
|
||||
|
||||
/// Submit a visible text message, but prepend a hidden instruction that is
|
||||
/// sent to the agent in the same turn. The hidden text is not added to the
|
||||
/// chat history; only `visible` appears to the user.
|
||||
pub(crate) fn submit_text_message_with_preface(&mut self, visible: String, preface: String) {
|
||||
if visible.is_empty() { return; }
|
||||
use crate::chatwidget::message::UserMessage;
|
||||
use codex_core::protocol::InputItem;
|
||||
let mut ordered = Vec::new();
|
||||
if !preface.trim().is_empty() {
|
||||
ordered.push(InputItem::Text { text: preface });
|
||||
}
|
||||
ordered.push(InputItem::Text { text: visible.clone() });
|
||||
let msg = UserMessage { display_text: visible, ordered_items: ordered };
|
||||
self.submit_user_message(msg);
|
||||
}
|
||||
|
||||
pub(crate) fn token_usage(&self) -> &TokenUsage {
|
||||
&self.total_token_usage
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user