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

@@ -1842,3 +1842,27 @@ async fn live_app_server_thread_closed_requests_immediate_exit() {
assert_matches!(rx.try_recv(), Ok(AppEvent::Exit(ExitMode::Immediate)));
}
#[tokio::test]
async fn permission_discovery_invalidates_on_thread_settings_and_uses_updated_cwd() {
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
let thread_id = ThreadId::new();
chat.thread_id = Some(thread_id);
chat.config.explicit_permission_profile_mode = true;
for complete in [false, true] {
chat.open_permissions_popup();
let request_id = chat.permission_popup_request_id.unwrap();
if complete {
chat.on_permission_profiles_loaded(request_id, Err("disconnected".to_string()));
}
chat.on_thread_settings_updated(thread_settings_for_test("gpt-5.2", thread_id));
chat.on_permission_profiles_loaded(request_id, Err("stale".to_string()));
assert!(!chat.bottom_pane.has_active_view());
}
while rx.try_recv().is_ok() {}
chat.open_permissions_popup();
let AppEvent::FetchPermissionProfiles { thread_cwd, .. } = rx.try_recv().unwrap() else {
panic!("expected discovery")
};
assert_eq!(thread_cwd, Some(test_path_buf("/tmp/thread-settings")));
}