TUI/Core: preserve duplicate skill/app mention selection across submit + resume#10855
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5def75d495
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
17c1372 to
ffdefc3
Compare
xl-openai
reviewed
Feb 6, 2026
xl-openai
reviewed
Feb 6, 2026
xl-openai
reviewed
Feb 6, 2026
| } | ||
|
|
||
| #[derive(Clone, Debug)] | ||
| struct ComposerMentionBinding { |
Collaborator
There was a problem hiding this comment.
@codex can you help me understand how we use MentionBinding? More specially:
- When do we set MentionBinding;
- How do we clear MentionBinding.
Contributor
There was a problem hiding this comment.
Answer
1. When do we set MentionBinding?
- On mention selection from the popup: when a user picks a skill/app mention,
insert_selected_mentioninserts the$tokenas an element and stores the binding (mention+path) inmention_bindingskeyed by that element id. codex-rs/tui/src/bottom_pane/chat_composer.rsL1846-L1861 - When restoring a draft with bindings:
set_text_content_with_mention_bindingsrehydrates mention bindings viabind_mentions_from_snapshot, which scans for$tokenoccurrences and rebuilds the binding map to match the restored text/elements. codex-rs/tui/src/bottom_pane/chat_composer.rsL777-L815 codex-rs/tui/src/bottom_pane/chat_composer.rsL1912-L1944
2. How do we clear MentionBinding?
- Fresh draft resets:
set_text_contentroutes toset_text_content_with_mention_bindings(..., Vec::new()), which explicitly clearsself.mention_bindingsbefore any new content is set, so starting fresh clears all bindings. codex-rs/tui/src/bottom_pane/chat_composer.rsL757-L796 - Explicit drain:
take_mention_bindingsremoves any bindings tied to current mention elements and then clears the map entirely, returning the drained bindings. codex-rs/tui/src/bottom_pane/chat_composer.rsL426-L440 - Snapshot rebind:
bind_mentions_from_snapshotalways clears existing bindings before re-adding the snapshot’s bindings, so rehydrate paths replace the current map rather than merge with it. codex-rs/tui/src/bottom_pane/chat_composer.rsL1912-L1944
Commands Used
sed -n '1,220p' codex-rs/tui/src/bottom_pane/chat_composer.rsrg -n "MentionBinding" codex-rs/tui/src/bottom_pane/chat_composer.rssed -n '260,520p' codex-rs/tui/src/bottom_pane/chat_composer.rssed -n '780,980p' codex-rs/tui/src/bottom_pane/chat_composer.rssed -n '1820,1985p' codex-rs/tui/src/bottom_pane/chat_composer.rsrg -n "mention_bindings\\.clear|mention_bindings =|mention_bindings\\.insert" codex-rs/tui/src/bottom_pane/chat_composer.rsrg -n "set_text_content\\(" -n codex-rs/tui/src/bottom_pane/chat_composer.rsrg -n "take_mention_bindings\\(|mention_bindings\\(" codex-rs/tui/srcsed -n '220,520p' codex-rs/tui/src/bottom_pane/mod.rssed -n '3000,3095p' codex-rs/tui/src/chatwidget.rsnl -ba codex-rs/tui/src/bottom_pane/chat_composer.rs | sed -n '720,860p'nl -ba codex-rs/tui/src/bottom_pane/chat_composer.rs | sed -n '1828,1935p'nl -ba codex-rs/tui/src/bottom_pane/chat_composer.rs | sed -n '1935,1965p'nl -ba codex-rs/tui/src/bottom_pane/chat_composer.rs | sed -n '420,450p'
xl-openai
approved these changes
Feb 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
codex-rs/core/src/skills/injection.rs, we now honor explicitUserInput::Skill { name, path }first, then fall back to text mentions only when safe.codex-rs/tui/src/bottom_pane/chat_composer.rs, mention selection is now token-bound (selected mention is tied to the specific inserted$token), and we snapshot bindings at submit time so selection is not lost.codex-rs/tui/src/chatwidget.rsandcodex-rs/tui/src/bottom_pane/mod.rs, submit/queue paths now consume the submit-time mention snapshot (instead of rereading cleared composer state).codex-rs/tui/src/mention_codec.rsandcodex-rs/tui/src/bottom_pane/chat_composer_history.rs, history now round-trips mention targets so resume restores the same selected duplicate.codex-rs/tui/src/bottom_pane/skill_popup.rsandcodex-rs/tui/src/bottom_pane/chat_composer.rs, duplicate labels are normalized to[Repo]/[App], app rows no longer showConnected -, and description space is a bit wider.Before vs now
Manual test
cd /Users/daniels/code/codex/codex-rscargo build -p codex-cli --bin codex./target/debug/codex$and pick a duplicate entry (not the first one).[Repo][App]Connected -Expected: it keeps the same selected duplicate target.
/resumeto reopen the session and send again.Expected: restored mention still resolves to the same duplicate target.