Skip to content

Commit aebd84d

Browse files
committed
codex: address PR review feedback (#18077)
1 parent 69315d8 commit aebd84d

2 files changed

Lines changed: 45 additions & 8 deletions

File tree

codex-rs/tui/src/chatwidget.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5865,19 +5865,19 @@ impl ChatWidget {
58655865

58665866
// Persist the submitted text to cross-session message history. Mentions are encoded into
58675867
// placeholder syntax so recall can reconstruct the mention bindings in a future session.
5868+
let encoded_mentions = mention_bindings
5869+
.iter()
5870+
.map(|binding| LinkedMention {
5871+
mention: binding.mention.clone(),
5872+
path: binding.path.clone(),
5873+
})
5874+
.collect::<Vec<_>>();
58685875
let history_text = match &history_record {
58695876
UserMessageHistoryRecord::UserMessageText if !text.is_empty() => {
5870-
let encoded_mentions = mention_bindings
5871-
.iter()
5872-
.map(|binding| LinkedMention {
5873-
mention: binding.mention.clone(),
5874-
path: binding.path.clone(),
5875-
})
5876-
.collect::<Vec<_>>();
58775877
Some(encode_history_mentions(&text, &encoded_mentions))
58785878
}
58795879
UserMessageHistoryRecord::Override(history) if !history.text.is_empty() => {
5880-
Some(history.text.clone())
5880+
Some(encode_history_mentions(&history.text, &encoded_mentions))
58815881
}
58825882
UserMessageHistoryRecord::UserMessageText | UserMessageHistoryRecord::Override(_) => {
58835883
None

codex-rs/tui/src/chatwidget/tests/slash_commands.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,43 @@ async fn goal_slash_command_records_original_command_in_history() {
199199
);
200200
}
201201

202+
#[tokio::test]
203+
async fn goal_slash_command_records_mentions_in_history() {
204+
let (mut chat, _rx, mut op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
205+
chat.set_feature_enabled(Feature::GoalMode, /*enabled*/ true);
206+
chat.thread_id = Some(ThreadId::new());
207+
chat.bottom_pane.set_composer_text_with_mention_bindings(
208+
"/goal use $figma for the mockup".to_string(),
209+
Vec::new(),
210+
Vec::new(),
211+
vec![MentionBinding {
212+
mention: "figma".to_string(),
213+
path: "app://figma".to_string(),
214+
}],
215+
);
216+
217+
chat.handle_key_event(KeyEvent::new(KeyCode::End, KeyModifiers::NONE));
218+
chat.handle_key_event(KeyEvent::new(KeyCode::Esc, KeyModifiers::NONE));
219+
chat.handle_key_event(KeyEvent::new(KeyCode::Enter, KeyModifiers::NONE));
220+
221+
match next_submit_op(&mut op_rx) {
222+
Op::UserTurn { items, .. } => {
223+
let [UserInput::Text { text, .. }] = items.as_slice() else {
224+
panic!("expected one text item, got {items:?}");
225+
};
226+
assert!(
227+
text.starts_with("Set the current thread goal"),
228+
"model should receive goal-parser prompt, got {text:?}"
229+
);
230+
}
231+
other => panic!("expected user turn, got {other:?}"),
232+
}
233+
assert_eq!(
234+
next_add_to_history_op(&mut op_rx),
235+
"/goal use [$figma](app://figma) for the mockup"
236+
);
237+
}
238+
202239
#[tokio::test]
203240
async fn goal_slash_command_preserves_attached_images() {
204241
let (mut chat, _rx, mut op_rx) = make_chatwidget_manual(/*model_override*/ None).await;

0 commit comments

Comments
 (0)