mirror of
https://github.com/openai/codex.git
synced 2026-11-15 21:50:46 +00:00
## Why Resuming another session must keep drafts, queued follow-ups, and interrupted steer retries with their original thread. Submitted input whose delivery is still uncertain must wait for matching receipts before the queue can advance. ## What changed - Pause submissions while draining outgoing events, then capture input before switching threads or backends. - Restore saved input through a shared resume path, reconcile receipts from resumed history and buffered events, preserve active-turn state, and dispatch eligible queued input when the resumed thread is idle. - Preserve whether a draft's leading `!` is literal text or a shell command. - Reject `!` shell commands in Cloud conversations with an error and clear the pending submission so the next prompt can proceed. ## Testing Add regression coverage for session round trips with buffered completion and interruption events, receipt reconciliation across read-only and writable resumes, draft shell mode, and submitting a prompt after a rejected Cloud shell command. GitOrigin-RevId: 9a823a398a371e689b8ae743de494323ae95ef57
660 lines
25 KiB
Rust
660 lines
25 KiB
Rust
//! User-message and shell-prompt submission behavior for `ChatWidget`.
|
|
|
|
use super::*;
|
|
use codex_app_server_protocol::ImageReference;
|
|
use codex_utils_path_uri::LegacyAppPathString;
|
|
|
|
impl ChatWidget {
|
|
pub(crate) fn set_task_mentions_enabled(&mut self, enabled: bool) {
|
|
self.bottom_pane.set_task_mentions_enabled(enabled);
|
|
}
|
|
|
|
pub(crate) fn on_task_search_result(
|
|
&mut self,
|
|
query: &str,
|
|
matches: Vec<crate::task_mentions::TaskMention>,
|
|
) {
|
|
self.bottom_pane.on_task_search_result(query, matches);
|
|
}
|
|
|
|
pub(super) fn user_message_from_submission(
|
|
&mut self,
|
|
text: String,
|
|
text_elements: Vec<TextElement>,
|
|
) -> UserMessage {
|
|
let local_images = self
|
|
.bottom_pane
|
|
.take_recent_submission_images_with_placeholders();
|
|
let remote_image_urls = self.take_remote_image_urls();
|
|
UserMessage {
|
|
text,
|
|
local_images,
|
|
remote_image_urls,
|
|
text_elements,
|
|
mention_bindings: self.bottom_pane.take_recent_submission_mention_bindings(),
|
|
}
|
|
}
|
|
|
|
fn submit_shell_command(&mut self, command: &str) -> QueueDrain {
|
|
let cmd = command.trim();
|
|
if cmd.is_empty() {
|
|
self.app_event_tx.send(AppEvent::InsertHistoryCell(Box::new(
|
|
history_cell::new_info_event(
|
|
USER_SHELL_COMMAND_HELP_TITLE.to_string(),
|
|
Some(USER_SHELL_COMMAND_HELP_HINT.to_string()),
|
|
),
|
|
)));
|
|
QueueDrain::Continue
|
|
} else {
|
|
self.submit_op(AppCommand::run_user_shell_command(cmd.to_string()));
|
|
QueueDrain::Stop
|
|
}
|
|
}
|
|
|
|
pub(crate) fn reject_user_shell_command(&mut self, message: String) {
|
|
// No turn event will arrive to clear the pending shell submission.
|
|
self.input_queue.user_turn_pending_start = false;
|
|
self.add_error_message(message);
|
|
self.maybe_send_next_queued_input();
|
|
}
|
|
|
|
fn submit_shell_command_with_history(
|
|
&mut self,
|
|
command: &str,
|
|
history_text: &str,
|
|
) -> QueueDrain {
|
|
let drain = self.submit_shell_command(command);
|
|
if drain == QueueDrain::Stop {
|
|
self.append_message_history_entry(history_text.to_string());
|
|
}
|
|
drain
|
|
}
|
|
|
|
pub(super) fn submit_queued_shell_prompt(&mut self, user_message: UserMessage) -> QueueDrain {
|
|
match user_message.text.strip_prefix('!') {
|
|
Some(command) => {
|
|
let history_text = user_message.text.clone();
|
|
self.submit_shell_command_with_history(command, &history_text)
|
|
}
|
|
None => {
|
|
self.submit_user_message(user_message);
|
|
QueueDrain::Stop
|
|
}
|
|
}
|
|
}
|
|
|
|
pub(super) fn submit_user_message(&mut self, user_message: UserMessage) {
|
|
let _accepted = self.submit_user_message_with_history_record(
|
|
user_message,
|
|
UserMessageHistoryRecord::UserMessageText,
|
|
);
|
|
}
|
|
|
|
pub(super) fn submit_user_message_with_history_record(
|
|
&mut self,
|
|
user_message: UserMessage,
|
|
history_record: UserMessageHistoryRecord,
|
|
) -> bool {
|
|
self.submit_user_message_with_history_and_shell_escape_policy(
|
|
user_message,
|
|
history_record,
|
|
ShellEscapePolicy::Allow,
|
|
UserMessageSource::Prompt,
|
|
)
|
|
.0
|
|
}
|
|
|
|
pub(super) fn submit_user_message_with_shell_escape_policy(
|
|
&mut self,
|
|
user_message: UserMessage,
|
|
shell_escape_policy: ShellEscapePolicy,
|
|
) -> Option<AppCommand> {
|
|
self.submit_user_message_with_history_and_shell_escape_policy(
|
|
user_message,
|
|
UserMessageHistoryRecord::UserMessageText,
|
|
shell_escape_policy,
|
|
UserMessageSource::Prompt,
|
|
)
|
|
.1
|
|
}
|
|
|
|
pub(crate) fn prepare_safety_recourse_rewrite(&mut self, prompt: &str) -> Option<AppCommand> {
|
|
if !self.is_session_configured()
|
|
|| self.is_user_turn_pending_or_running()
|
|
|| self.pending_image_submission.is_some()
|
|
|| self.input_queue.rate_limit_recovery_pending
|
|
|| self.safety_recourse.is_some()
|
|
{
|
|
return None;
|
|
}
|
|
let op = self
|
|
.submit_user_message_with_history_and_shell_escape_policy(
|
|
prompt.into(),
|
|
UserMessageHistoryRecord::UserMessageText,
|
|
ShellEscapePolicy::Disallow,
|
|
UserMessageSource::SafetyRecourse,
|
|
)
|
|
.1?;
|
|
self.safety_buffering_source = UserMessageSource::Prompt;
|
|
Some(op)
|
|
}
|
|
|
|
pub(super) fn submit_user_message_with_history_and_shell_escape_policy(
|
|
&mut self,
|
|
user_message: UserMessage,
|
|
history_record: UserMessageHistoryRecord,
|
|
shell_escape_policy: ShellEscapePolicy,
|
|
source: UserMessageSource,
|
|
) -> (bool, Option<AppCommand>) {
|
|
self.submit_user_message_with_prepared_images(
|
|
user_message,
|
|
history_record,
|
|
shell_escape_policy,
|
|
source,
|
|
/*prepared_images*/ None,
|
|
)
|
|
}
|
|
|
|
pub(super) fn submit_user_message_with_prepared_images(
|
|
&mut self,
|
|
user_message: UserMessage,
|
|
history_record: UserMessageHistoryRecord,
|
|
shell_escape_policy: ShellEscapePolicy,
|
|
source: UserMessageSource,
|
|
prepared_images: Option<Vec<UserInput>>,
|
|
) -> (bool, Option<AppCommand>) {
|
|
self.bottom_pane.dismiss_composer_sparkle();
|
|
if self.has_misalignment_policy_violation() {
|
|
return (false, None);
|
|
}
|
|
self.empty_state_animation.borrow_mut().dismiss();
|
|
if self.input_queue.rate_limit_recovery_pending
|
|
|| self.pending_image_submission.is_some()
|
|
|| self.safety_recourse.is_some()
|
|
{
|
|
let model_prompt = matches!(
|
|
source,
|
|
UserMessageSource::Prompt | UserMessageSource::DirectEnter
|
|
) && (shell_escape_policy == ShellEscapePolicy::Disallow
|
|
|| !user_message.text.starts_with('!'));
|
|
// A prepared submission was accepted before any messages queued behind it.
|
|
let queue_index = if prepared_images.is_some() {
|
|
0
|
|
} else {
|
|
self.input_queue.queued_user_messages.len()
|
|
};
|
|
self.input_queue.queued_user_messages.insert(
|
|
queue_index,
|
|
QueuedUserMessage {
|
|
source,
|
|
prepared_images,
|
|
..QueuedUserMessage::new(
|
|
user_message,
|
|
match shell_escape_policy {
|
|
ShellEscapePolicy::Allow => QueuedInputAction::Plain,
|
|
ShellEscapePolicy::Disallow => QueuedInputAction::Literal,
|
|
},
|
|
)
|
|
},
|
|
);
|
|
self.input_queue
|
|
.queued_user_message_history_records
|
|
.insert(queue_index, history_record);
|
|
self.refresh_pending_input_preview();
|
|
if model_prompt {
|
|
self.bottom_pane.clear_pending_questions();
|
|
}
|
|
return (true, None);
|
|
}
|
|
if !self.is_session_configured() {
|
|
let model_prompt = matches!(
|
|
source,
|
|
UserMessageSource::Prompt | UserMessageSource::DirectEnter
|
|
) && (shell_escape_policy == ShellEscapePolicy::Disallow
|
|
|| !user_message.text.starts_with('!'));
|
|
tracing::warn!("cannot submit user message before session is configured; queueing");
|
|
self.input_queue
|
|
.queued_user_messages
|
|
.push_front(QueuedUserMessage {
|
|
source,
|
|
..QueuedUserMessage::from(user_message)
|
|
});
|
|
self.input_queue
|
|
.queued_user_message_history_records
|
|
.push_front(history_record);
|
|
self.refresh_pending_input_preview();
|
|
if model_prompt {
|
|
self.bottom_pane.clear_pending_questions();
|
|
}
|
|
return (true, None);
|
|
}
|
|
if user_message.text.is_empty()
|
|
&& user_message.local_images.is_empty()
|
|
&& user_message.remote_image_urls.is_empty()
|
|
{
|
|
return (false, None);
|
|
}
|
|
if (!user_message.local_images.is_empty() || !user_message.remote_image_urls.is_empty())
|
|
&& !self.current_model_supports_images()
|
|
{
|
|
let UserMessage {
|
|
text,
|
|
text_elements,
|
|
local_images,
|
|
mention_bindings,
|
|
remote_image_urls,
|
|
} = user_message_for_restore(user_message, &history_record);
|
|
self.restore_blocked_image_submission(
|
|
text,
|
|
text_elements,
|
|
local_images,
|
|
mention_bindings,
|
|
remote_image_urls,
|
|
);
|
|
return (false, None);
|
|
}
|
|
let UserMessage {
|
|
text,
|
|
local_images,
|
|
remote_image_urls,
|
|
text_elements,
|
|
mut mention_bindings,
|
|
} = user_message;
|
|
|
|
let render_in_history = !self.turn_lifecycle.agent_turn_running;
|
|
let mut items: Vec<UserInput> = Vec::new();
|
|
|
|
// Special-case: "!cmd" executes a local shell command instead of sending to the model.
|
|
if shell_escape_policy == ShellEscapePolicy::Allow
|
|
&& let Some(stripped) = text.strip_prefix('!')
|
|
{
|
|
let app_command = match self.submit_shell_command_with_history(stripped, &text) {
|
|
QueueDrain::Continue => None,
|
|
QueueDrain::Stop => Some(AppCommand::run_user_shell_command(
|
|
stripped.trim().to_string(),
|
|
)),
|
|
};
|
|
return (app_command.is_some(), app_command);
|
|
}
|
|
|
|
for image_url in &remote_image_urls {
|
|
items.push(UserInput::Image {
|
|
image: ImageReference::Inline {
|
|
url: image_url.clone(),
|
|
},
|
|
detail: None,
|
|
});
|
|
}
|
|
|
|
if let Some(prepared_images) = prepared_images {
|
|
items.extend(prepared_images);
|
|
} else if self.snapshot_local_images && !local_images.is_empty() {
|
|
self.prepare_image_submission(
|
|
UserMessage {
|
|
text,
|
|
local_images,
|
|
remote_image_urls,
|
|
text_elements,
|
|
mention_bindings,
|
|
},
|
|
history_record,
|
|
source,
|
|
);
|
|
return (true, None);
|
|
} else {
|
|
items.extend(local_images.iter().map(|image| UserInput::LocalImage {
|
|
path: image.path.clone(),
|
|
detail: None,
|
|
}));
|
|
}
|
|
|
|
use crate::app_command::CloudSubmissionIntent;
|
|
let (cloud_submission, source) = match source {
|
|
UserMessageSource::DirectEnter => (
|
|
CloudSubmissionIntent::StartOrSteer,
|
|
UserMessageSource::Prompt,
|
|
),
|
|
UserMessageSource::Prompt => (CloudSubmissionIntent::StartIfIdle, source),
|
|
UserMessageSource::QuestionAnswer => (
|
|
CloudSubmissionIntent::QuestionAnswer {
|
|
during_turn: !render_in_history,
|
|
},
|
|
source,
|
|
),
|
|
UserMessageSource::SafetyRecourse => (CloudSubmissionIntent::UseKnownTurn, source),
|
|
};
|
|
if !text.is_empty() {
|
|
items.push(UserInput::Text {
|
|
text: text.clone(),
|
|
text_elements: app_server_text_elements(&text_elements),
|
|
});
|
|
}
|
|
|
|
if !self.bottom_pane.task_mentions_enabled() {
|
|
mention_bindings
|
|
.retain(|binding| crate::task_mentions::valid_thread_path(&binding.path).is_none());
|
|
}
|
|
|
|
let reply_text = crate::async_question_reply::display_text(&text);
|
|
let mentions =
|
|
collect_tool_mentions(reply_text.as_deref().unwrap_or(&text), &HashMap::new());
|
|
let bound_names: HashSet<String> = mention_bindings
|
|
.iter()
|
|
.filter(|binding| binding.sigil == '$')
|
|
.map(|binding| binding.mention.clone())
|
|
.collect();
|
|
let mut skill_names_lower: HashSet<String> = HashSet::new();
|
|
let mut selected_skill_paths = HashSet::new();
|
|
let mut selected_plugin_ids: HashSet<String> = HashSet::new();
|
|
|
|
if let Some(skills) = self.bottom_pane.skills() {
|
|
skill_names_lower = skills
|
|
.iter()
|
|
.map(|skill| skill.name.to_ascii_lowercase())
|
|
.collect();
|
|
|
|
// TODO(anp): Preserve executor path identity through both structured skill input paths
|
|
// below and selection. UserInput::Skill still relies on host-native path interpretation.
|
|
for binding in &mention_bindings {
|
|
let path = binding
|
|
.path
|
|
.strip_prefix("skill://")
|
|
.unwrap_or(binding.path.as_str());
|
|
let Some(path) = LegacyAppPathString::from_string(path).to_inferred_path_uri()
|
|
else {
|
|
continue;
|
|
};
|
|
if let Some(skill) = skills
|
|
.iter()
|
|
.find(|skill| skill.path.to_inferred_path_uri().as_ref() == Some(&path))
|
|
&& selected_skill_paths.insert(path)
|
|
{
|
|
items.push(UserInput::Skill {
|
|
name: skill.name.clone(),
|
|
path: PathBuf::from(skill.path.as_str()),
|
|
});
|
|
}
|
|
}
|
|
|
|
let skill_mentions = find_skill_mentions_with_tool_mentions(&mentions, skills);
|
|
for skill in skill_mentions {
|
|
let Some(path) = skill.path.to_inferred_path_uri() else {
|
|
continue;
|
|
};
|
|
if bound_names.contains(skill.name.as_str()) || !selected_skill_paths.insert(path) {
|
|
continue;
|
|
}
|
|
items.push(UserInput::Skill {
|
|
name: skill.name.clone(),
|
|
path: PathBuf::from(skill.path.as_str()),
|
|
});
|
|
}
|
|
}
|
|
|
|
if let Some(plugins) = self.plugins_for_mentions() {
|
|
for binding in &mention_bindings {
|
|
let Some(plugin_config_name) = binding
|
|
.path
|
|
.strip_prefix("plugin://")
|
|
.filter(|id| !id.is_empty())
|
|
else {
|
|
continue;
|
|
};
|
|
if !selected_plugin_ids.insert(plugin_config_name.to_string()) {
|
|
continue;
|
|
}
|
|
if let Some(plugin) = plugins
|
|
.iter()
|
|
.find(|plugin| plugin.config_name == plugin_config_name)
|
|
{
|
|
items.push(UserInput::Mention {
|
|
name: plugin.display_name.clone(),
|
|
path: binding.path.clone(),
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
let mut selected_app_ids: HashSet<String> = HashSet::new();
|
|
if let Some(apps) = self.connectors_for_mentions() {
|
|
for binding in &mention_bindings {
|
|
let Some(app_id) = binding
|
|
.path
|
|
.strip_prefix("app://")
|
|
.filter(|id| !id.is_empty())
|
|
else {
|
|
continue;
|
|
};
|
|
if selected_app_ids.contains(app_id) {
|
|
continue;
|
|
}
|
|
if let Some(app) = apps
|
|
.iter()
|
|
.find(|app| app.id == app_id && is_app_mentionable(app))
|
|
{
|
|
selected_app_ids.insert(app_id.to_string());
|
|
items.push(UserInput::Mention {
|
|
name: app.name.clone(),
|
|
path: binding.path.clone(),
|
|
});
|
|
}
|
|
}
|
|
|
|
let app_mentions = find_app_mentions(&mentions, apps, &skill_names_lower);
|
|
for app in app_mentions {
|
|
let slug = codex_connectors::metadata::connector_mention_slug(&app);
|
|
if bound_names.contains(&slug) || !selected_app_ids.insert(app.id.clone()) {
|
|
continue;
|
|
}
|
|
let app_id = app.id.as_str();
|
|
items.push(UserInput::Mention {
|
|
name: app.name.clone(),
|
|
path: format!("app://{app_id}"),
|
|
});
|
|
}
|
|
}
|
|
|
|
let effective_mode = self.effective_collaboration_mode();
|
|
if effective_mode.model().trim().is_empty() {
|
|
self.add_error_message(
|
|
"Thread model is unavailable. Wait for the thread to finish syncing or choose a model before sending input.".to_string(),
|
|
);
|
|
self.restore_user_message_to_composer(user_message_for_restore(
|
|
UserMessage {
|
|
text,
|
|
local_images,
|
|
remote_image_urls,
|
|
text_elements,
|
|
mention_bindings,
|
|
},
|
|
&history_record,
|
|
));
|
|
return (false, None);
|
|
}
|
|
|
|
self.maybe_apply_ide_context(&mut items);
|
|
crate::task_mentions::apply_task_references(&mut items, &mention_bindings, self.thread_id);
|
|
|
|
let collaboration_mode = if self.collaboration_modes_enabled() {
|
|
self.active_collaboration_mask
|
|
.as_ref()
|
|
.map(|_| effective_mode.clone())
|
|
} else {
|
|
None
|
|
};
|
|
let submitted_image_display = (render_in_history && !local_images.is_empty())
|
|
.then(|| Self::user_message_display_from_inputs(&items));
|
|
let client_user_message_id = uuid::Uuid::new_v4().to_string();
|
|
crate::startup_recovery::bind_submission(&text, &client_user_message_id);
|
|
let pending_steer = (!render_in_history).then(|| PendingSteer {
|
|
client_id: client_user_message_id.clone(),
|
|
admitted_turn_id: None,
|
|
optimistically_rendered: false,
|
|
user_message: UserMessage {
|
|
text: text.clone(),
|
|
local_images: local_images.clone(),
|
|
remote_image_urls: remote_image_urls.clone(),
|
|
text_elements: text_elements.clone(),
|
|
mention_bindings: mention_bindings.clone(),
|
|
},
|
|
history_record: history_record.clone(),
|
|
source,
|
|
compare_key: Self::pending_steer_compare_key_from_items(&items),
|
|
});
|
|
let service_tier = self.service_tier_update_for_core();
|
|
let active_permission_profile = self.config.permissions.active_permission_profile();
|
|
let op = AppCommand::user_turn(
|
|
if source == UserMessageSource::SafetyRecourse {
|
|
"safety_recourse_follow_up"
|
|
} else {
|
|
"user"
|
|
},
|
|
cloud_submission,
|
|
client_user_message_id.clone(),
|
|
items,
|
|
self.config.cwd.to_path_buf(),
|
|
AskForApproval::from(self.config.permissions.approval_policy.value()),
|
|
active_permission_profile,
|
|
effective_mode.model().to_string(),
|
|
effective_mode.reasoning_effort(),
|
|
/*summary*/ None,
|
|
service_tier,
|
|
/*final_output_json_schema*/ None,
|
|
collaboration_mode,
|
|
);
|
|
let submitted_message = UserMessage {
|
|
text,
|
|
local_images,
|
|
remote_image_urls,
|
|
text_elements,
|
|
mention_bindings,
|
|
};
|
|
|
|
// App-event submissions are handled serially, and turn/start can wait on remote work.
|
|
// Queue the optimistic prompt first so the user's input is visible while that happens.
|
|
// Direct submissions do not share that queue, so keep their existing failure behavior.
|
|
if render_in_history {
|
|
// Do not let a transient manual-recap progress cell become permanent terminal
|
|
// scrollback when the new user prompt flushes the active history cell.
|
|
self.clear_recap_loading();
|
|
}
|
|
let render_before_submit =
|
|
render_in_history && matches!(&self.codex_op_target, CodexOpTarget::AppEvent);
|
|
if render_before_submit {
|
|
self.on_user_message_display(user_message_display_for_history(
|
|
submitted_message.clone(),
|
|
&history_record,
|
|
));
|
|
}
|
|
|
|
// The app submits recourse turns directly to the verified fork.
|
|
if source != UserMessageSource::SafetyRecourse && !self.submit_op(op.clone()) {
|
|
return (false, None);
|
|
}
|
|
if source != UserMessageSource::QuestionAnswer {
|
|
self.bottom_pane.clear_pending_questions();
|
|
}
|
|
self.dismiss_backend_banner_for_new_turn();
|
|
self.note_realtime_typed_input(&submitted_message.text);
|
|
if render_in_history {
|
|
self.input_queue.user_turn_pending_start = true;
|
|
self.input_queue.pending_user_message_client_id = Some(client_user_message_id.clone());
|
|
self.input_queue.pending_user_message_history_record = Some(history_record.clone());
|
|
}
|
|
|
|
// Persist the submitted text to cross-session message history. Mentions are encoded into
|
|
// placeholder syntax so recall can reconstruct the mention bindings in a future session.
|
|
let encoded_mentions = submitted_message
|
|
.mention_bindings
|
|
.iter()
|
|
.map(|binding| LinkedMention {
|
|
sigil: binding.sigil,
|
|
mention: binding.mention.clone(),
|
|
path: binding.path.clone(),
|
|
})
|
|
.collect::<Vec<_>>();
|
|
let history = match &history_record {
|
|
UserMessageHistoryRecord::UserMessageText if !submitted_message.text.is_empty() => {
|
|
Some((
|
|
&submitted_message.text,
|
|
submitted_message.text_elements.as_slice(),
|
|
))
|
|
}
|
|
UserMessageHistoryRecord::Override(history) if !history.text.is_empty() => {
|
|
Some((&history.text, history.text_elements.as_slice()))
|
|
}
|
|
UserMessageHistoryRecord::UserMessageText | UserMessageHistoryRecord::Override(_) => {
|
|
None
|
|
}
|
|
};
|
|
if let Some((text, elements)) = history {
|
|
let reply_text = crate::async_question_reply::display_text(text);
|
|
let (text, elements) = match &reply_text {
|
|
Some(text) => (text.as_str(), &[][..]),
|
|
None => (text.as_str(), elements),
|
|
};
|
|
self.append_message_history_entry(encode_history_mentions_at_elements(
|
|
text,
|
|
&encoded_mentions,
|
|
elements,
|
|
));
|
|
}
|
|
|
|
if let Some(pending_steer) = pending_steer {
|
|
self.input_queue.pending_steers.push_back(pending_steer);
|
|
self.transcript.saw_plan_item_this_turn = false;
|
|
self.refresh_pending_input_preview();
|
|
}
|
|
|
|
if render_in_history {
|
|
self.safety_buffering_prompt = Some(submitted_message.clone());
|
|
self.safety_buffering_source = source;
|
|
if !render_before_submit {
|
|
self.on_user_message_display(user_message_display_for_history(
|
|
submitted_message,
|
|
&history_record,
|
|
));
|
|
}
|
|
}
|
|
|
|
if render_in_history {
|
|
self.last_rendered_user_message_client_id = Some(client_user_message_id);
|
|
}
|
|
if let Some(display) = submitted_image_display {
|
|
// Match the server echo's portable media without changing the locally rendered cell.
|
|
self.last_rendered_user_message_display = Some(display);
|
|
}
|
|
|
|
(true, Some(op))
|
|
}
|
|
|
|
/// Restore the blocked submission draft without losing mention resolution state.
|
|
///
|
|
/// The blocked-image path intentionally keeps the draft in the composer so
|
|
/// users can remove attachments and retry. We must restore
|
|
/// mention bindings alongside visible text; restoring only `$name` tokens
|
|
/// makes the draft look correct while degrading mention resolution to
|
|
/// name-only heuristics on retry.
|
|
pub(super) fn restore_blocked_image_submission(
|
|
&mut self,
|
|
text: String,
|
|
text_elements: Vec<TextElement>,
|
|
local_images: Vec<LocalImageAttachment>,
|
|
mention_bindings: Vec<MentionBinding>,
|
|
remote_image_urls: Vec<String>,
|
|
) {
|
|
// Preserve the user's composed payload so they can retry after changing models.
|
|
self.restore_user_message_to_composer(UserMessage {
|
|
text,
|
|
text_elements,
|
|
local_images,
|
|
mention_bindings,
|
|
remote_image_urls,
|
|
});
|
|
self.add_to_history(history_cell::new_warning_event(
|
|
self.image_inputs_not_supported_message(),
|
|
));
|
|
self.request_redraw();
|
|
}
|
|
}
|