Discover permission profiles from the app server (#42453)

## Why

The permissions menu needs to reflect the profiles and configuration requirements available in the active app-server scope, including remote workspaces.

## What changed

- Load permission profiles and configuration requirements asynchronously when opening the permissions menu, using the active thread working directory.
- Render loading, retry, empty-catalog, and unsupported-server states, and fall back to the legacy permissions menu when explicit profiles are not configured.
- Disable profiles rejected by server requirements or unavailable in the catalog. Remote custom profiles remain visible but cannot yet be selected.
- Bound pagination and request time, reject malformed catalogs, and ignore responses made stale by account, thread, or modal changes.

## Testing

- Cover local, session-only, remote, legacy, empty, unsupported, pagination, malformed-response, and timeout discovery paths.
- Add TUI tests for loading, failures, retries, empty results, remote catalogs, stale responses, and working-directory changes.

GitOrigin-RevId: 3e2ab53a4eae1179587d064f9a4c605765ea7880
This commit is contained in:
Eric Traut authored and copyberry committed 2026-09-03 05:24:31 +00:00
1 parent 8b8ee28a9b
commit c9fecd3fa0
19 files changed
+797 -22

No files matched your search

+20 -5
View File
@@ -1570,6 +1570,20 @@ impl App {
}
}
}
AppEvent::FetchPermissionProfiles { request_id, thread_cwd } => {
if self.chat_widget.permission_popup_request_is_current(request_id) {
crate::permission_discovery::fetch(
app_server,
request_id,
self.chat_widget.config_ref(),
thread_cwd.as_deref(),
self.app_event_tx.clone(),
);
}
}
AppEvent::PermissionProfilesLoaded { request_id, result } => {
self.chat_widget.on_permission_profiles_loaded(request_id, result);
}
AppEvent::FetchModels { request_id } => {
if self.chat_widget.model_popup_request_is_current(request_id) {
app_server.fetch_models(request_id, self.app_event_tx.clone());
@@ -2494,9 +2508,6 @@ impl App {
));
}
}
AppEvent::OpenApprovalsPopup => {
self.chat_widget.open_approvals_popup();
}
AppEvent::OpenAgentsOverview => {
self.open_agents_overview(app_server);
}
@@ -2732,8 +2743,12 @@ impl App {
self.chat_widget.add_error_message(err);
}
}
AppEvent::OpenPermissionsPopup => {
self.chat_widget.open_permissions_popup();
AppEvent::OpenPermissionsPopup | AppEvent::OpenApprovalsPopup => {
if app_server.uses_remote_workspace() {
self.chat_widget.request_permission_profiles();
} else {
self.chat_widget.open_approvals_popup();
}
}
AppEvent::OpenReviewBranchPicker(cwd) => {
self.chat_widget.show_review_branch_picker(&cwd).await;