tui: keep inaccessible apps out of mentions (#24625)

## Summary

Fix the TUI `$` app mention paths so App Directory rows that are not
accessible are not treated as usable apps.

This includes the core preservation fix from #24104, but expands it to
the other app mention paths:

- preserve app-server `is_accessible` flags when partial
`app/list/updated` snapshots reach the TUI
- require apps to be both accessible and enabled when resolving exact
`$slug` mentions
- require restored/stale `app://...` bindings to point at accessible,
enabled apps before emitting structured app mentions
- remove the now-unused `codex-chatgpt` dependency from `codex-tui`,
which addresses the `cargo shear` failure seen on #24104

## Root Cause

The app server already sends merged app snapshots with accessibility
computed. The TUI handled app-server app list updates as partial app
loads and re-ran the old accessible-app merge path. That path treated
every notification row as accessible, so App Directory entries with
`isAccessible=false` could appear in `$` suggestions.

Regression source: #22914 routed app-list updates through the app server
while reusing the old TUI partial-load handling. Related precursor:
#14717 introduced the partial-load path, but #22914 made it user-visible
for app-server updates.

## Issues

Fixes #24145
Fixes #24205
Fixes #24319

## Validation

- `just fmt`
- `git diff --check`
- `just bazel-lock-update`
- `just bazel-lock-check`
- `just argument-comment-lint -p codex-tui`
- `just test -p codex-tui
chatwidget::tests::popups_and_settings::apps_notification_update_excludes_inaccessible_apps_from_mentions
chatwidget::tests::composer_submission::submit_user_message_ignores_inaccessible_app_mentions_from_bindings
chatwidget::skills::tests::find_app_mentions_requires_accessible_enabled_apps_for_bound_paths
chatwidget::skills::tests::find_app_mentions_requires_accessible_enabled_apps_for_slugs`
This commit is contained in:
canvrno-oai authored and GitHub committed 2026-05-26 12:09:07 -07:00
1 parent 833c19ed53
commit cd934c8bcb
8 files changed
+212 -15

No files matched your search

+78 -3
View File
@@ -315,12 +315,12 @@ pub(crate) fn find_app_mentions(
}
let mut slug_counts: HashMap<String, usize> = HashMap::new();
for app in apps.iter().filter(|app| app.is_enabled) {
for app in apps.iter().filter(|app| is_app_mentionable(app)) {
let slug = codex_connectors::metadata::connector_mention_slug(app);
*slug_counts.entry(slug).or_insert(0) += 1;
}
for app in apps.iter().filter(|app| app.is_enabled) {
for app in apps.iter().filter(|app| is_app_mentionable(app)) {
let slug = codex_connectors::metadata::connector_mention_slug(app);
let slug_count = slug_counts.get(&slug).copied().unwrap_or(0);
if mentions.names.contains(&slug)
@@ -333,11 +333,15 @@ pub(crate) fn find_app_mentions(
}
apps.iter()
.filter(|app| app.is_enabled && selected_ids.contains(&app.id))
.filter(|app| is_app_mentionable(app) && selected_ids.contains(&app.id))
.cloned()
.collect()
}
pub(crate) fn is_app_mentionable(app: &AppInfo) -> bool {
app.is_accessible && app.is_enabled
}
pub(crate) struct ToolMentions {
names: HashSet<String>,
linked_paths: HashMap<String, String>,
@@ -497,3 +501,74 @@ fn app_id_from_path(path: &str) -> Option<&str> {
path.strip_prefix("app://")
.filter(|value| !value.is_empty())
}
#[cfg(test)]
mod tests {
use super::*;
use pretty_assertions::assert_eq;
fn app(id: &str, name: &str) -> AppInfo {
AppInfo {
id: id.to_string(),
name: name.to_string(),
description: None,
logo_url: None,
logo_url_dark: None,
distribution_channel: None,
branding: None,
app_metadata: None,
labels: None,
install_url: None,
is_accessible: true,
is_enabled: true,
plugin_display_names: Vec::new(),
}
}
#[test]
fn find_app_mentions_requires_accessible_enabled_apps_for_slugs() {
let apps = vec![
app("google_drive", "Google Drive"),
AppInfo {
is_accessible: false,
..app("arabica_uae", "% Arabica UAE")
},
AppInfo {
is_enabled: false,
..app("linear", "Linear")
},
];
let mentions = collect_tool_mentions("$google-drive $arabica-uae $linear", &HashMap::new());
assert_eq!(
find_app_mentions(&mentions, &apps, &HashSet::new()),
vec![apps[0].clone()]
);
}
#[test]
fn find_app_mentions_requires_accessible_enabled_apps_for_bound_paths() {
let apps = vec![
app("google_drive", "Google Drive"),
AppInfo {
is_accessible: false,
..app("arabica_uae", "% Arabica UAE")
},
AppInfo {
is_enabled: false,
..app("linear", "Linear")
},
];
let mention_paths = HashMap::from([
("google-drive".to_string(), "app://google_drive".to_string()),
("arabica-uae".to_string(), "app://arabica_uae".to_string()),
("linear".to_string(), "app://linear".to_string()),
]);
let mentions = collect_tool_mentions("$google-drive $arabica-uae $linear", &mention_paths);
assert_eq!(
find_app_mentions(&mentions, &apps, &HashSet::new()),
vec![apps[0].clone()]
);
}
}