mirror of
https://github.com/openai/codex.git
synced 2026-04-24 14:45:27 +00:00
tui: defer /plan history until mode
This commit is contained in:
@@ -2058,7 +2058,7 @@ impl ChatComposer {
|
||||
return None;
|
||||
}
|
||||
|
||||
let (name, rest, _rest_offset) = parse_slash_name(&text)?;
|
||||
let (name, rest, rest_offset) = parse_slash_name(&text)?;
|
||||
if rest.is_empty() || name.contains('/') {
|
||||
return None;
|
||||
}
|
||||
@@ -2081,8 +2081,22 @@ impl ChatComposer {
|
||||
return Some(InputResult::None);
|
||||
}
|
||||
|
||||
let record_history = matches!(cmd, SlashCommand::Plan);
|
||||
let (prepared_text, prepared_elements) = self.prepare_submission_text(record_history)?;
|
||||
if cmd == SlashCommand::Plan {
|
||||
let mut args_elements = Self::slash_command_args_elements(
|
||||
rest,
|
||||
rest_offset,
|
||||
&self.textarea.text_elements(),
|
||||
);
|
||||
let trimmed_rest = rest.trim();
|
||||
args_elements = Self::trim_text_elements(rest, trimmed_rest, args_elements);
|
||||
return Some(InputResult::CommandWithArgs(
|
||||
cmd,
|
||||
trimmed_rest.to_string(),
|
||||
args_elements,
|
||||
));
|
||||
}
|
||||
|
||||
let (prepared_text, prepared_elements) = self.prepare_submission_text(false)?;
|
||||
let (_, prepared_rest, prepared_rest_offset) = parse_slash_name(&prepared_text)?;
|
||||
let mut args_elements = Self::slash_command_args_elements(
|
||||
prepared_rest,
|
||||
@@ -2098,6 +2112,19 @@ impl ChatComposer {
|
||||
))
|
||||
}
|
||||
|
||||
pub(crate) fn prepare_plan_args_submission(&mut self) -> Option<(String, Vec<TextElement>)> {
|
||||
let (prepared_text, prepared_elements) = self.prepare_submission_text(true)?;
|
||||
let (_, prepared_rest, prepared_rest_offset) = parse_slash_name(&prepared_text)?;
|
||||
let mut args_elements = Self::slash_command_args_elements(
|
||||
prepared_rest,
|
||||
prepared_rest_offset,
|
||||
&prepared_elements,
|
||||
);
|
||||
let trimmed_rest = prepared_rest.trim();
|
||||
args_elements = Self::trim_text_elements(prepared_rest, trimmed_rest, args_elements);
|
||||
Some((trimmed_rest.to_string(), args_elements))
|
||||
}
|
||||
|
||||
fn reject_slash_command_if_unavailable(&self, cmd: SlashCommand) -> bool {
|
||||
if !self.is_task_running || cmd.available_during_task() {
|
||||
return false;
|
||||
|
||||
@@ -794,6 +794,10 @@ impl BottomPane {
|
||||
.take_recent_submission_images_with_placeholders()
|
||||
}
|
||||
|
||||
pub(crate) fn prepare_plan_args_submission(&mut self) -> Option<(String, Vec<TextElement>)> {
|
||||
self.composer.prepare_plan_args_submission()
|
||||
}
|
||||
|
||||
fn as_renderable(&'_ self) -> RenderableItem<'_> {
|
||||
if let Some(view) = self.active_view() {
|
||||
RenderableItem::Borrowed(view)
|
||||
|
||||
@@ -3024,7 +3024,7 @@ impl ChatWidget {
|
||||
&mut self,
|
||||
cmd: SlashCommand,
|
||||
args: String,
|
||||
text_elements: Vec<TextElement>,
|
||||
_text_elements: Vec<TextElement>,
|
||||
) {
|
||||
if !cmd.available_during_task() && self.bottom_pane.is_task_running() {
|
||||
let message = format!(
|
||||
@@ -3054,15 +3054,19 @@ impl ChatWidget {
|
||||
SlashCommand::Plan if !trimmed.is_empty() => {
|
||||
self.dispatch_command(cmd);
|
||||
if self.active_mode_kind() != ModeKind::Plan {
|
||||
self.bottom_pane.drain_pending_submission_state();
|
||||
return;
|
||||
}
|
||||
let Some((prepared_args, prepared_elements)) =
|
||||
self.bottom_pane.prepare_plan_args_submission()
|
||||
else {
|
||||
return;
|
||||
};
|
||||
let user_message = UserMessage {
|
||||
text: args,
|
||||
text: prepared_args,
|
||||
local_images: self
|
||||
.bottom_pane
|
||||
.take_recent_submission_images_with_placeholders(),
|
||||
text_elements,
|
||||
text_elements: prepared_elements,
|
||||
mention_paths: self.bottom_pane.take_mention_paths(),
|
||||
};
|
||||
if self.is_session_configured() {
|
||||
|
||||
Reference in New Issue
Block a user