Add task mentions to the TUI composer (#40315)

## What changed

- Include matching Codex tasks in the `@` mention popup when the active thread supports task tools, prioritizing tasks from the current working directory.
- Submit selected tasks as bounded live thread references so Codex can load their contents with `read_thread`.
- Preserve task mentions across composer history and thread start, resume, and fork flows.

## Testing

- Add coverage for task search and capability propagation, popup selection and rendering, submission encoding, history round-trips, and reference validation and limits.

GitOrigin-RevId: 17502be91bf6d4b01745668829eb69fb318cb5b9
This commit is contained in:
Eric Traut authored and copyberry committed 2026-08-24 02:46:56 +00:00
1 parent a8468330bb
commit 76d98a771e
30 files changed
+1317 -44

No files matched your search

+53 -1
View File
@@ -596,8 +596,58 @@ pub(crate) fn mention_bindings_from_user_inputs(
| UserInput::LocalAudio { .. } => None,
})
.collect();
for item in items {
let UserInput::Text {
text,
text_elements,
} = item
else {
continue;
};
for element in text_elements {
if let Some((mention, path, end)) =
crate::task_mentions::parse_task_link(text, element.byte_range.start)
&& end == element.byte_range.end
&& element
.placeholder()
.and_then(|placeholder| placeholder.strip_prefix('@'))
== Some(mention.as_str())
{
mention_bindings.push(MentionBinding {
sigil: '@',
mention,
path,
});
}
}
}
mention_bindings.sort_by_key(|binding| {
mention_start(binding.sigil, &binding.mention).unwrap_or(usize::MAX)
let token = if crate::task_mentions::valid_thread_path(&binding.path).is_some() {
crate::task_mentions::format_task_link(&binding.mention, &binding.path)
} else {
format!("{}{}", binding.sigil, binding.mention)
};
let mut text_offset = 0;
items
.iter()
.find_map(|item| {
let UserInput::Text {
text,
text_elements,
} = item
else {
return None;
};
let offset = text_offset;
text_offset += text.len();
text_elements.iter().find_map(|element| {
(text.get(element.byte_range.start..element.byte_range.end)
== Some(token.as_str()))
.then_some(offset + element.byte_range.start)
})
})
.or_else(|| mention_start(binding.sigil, &binding.mention))
.unwrap_or(usize::MAX)
});
mention_bindings
}
@@ -714,6 +764,8 @@ impl ChatWidget {
}
}
(message, text_elements) = crate::task_mentions::decode_task_links(&message, text_elements);
Self::user_message_display_from_parts(
message,
text_elements,