Plugins TUI install/uninstall (#15342)

- Add install/uninstall actions to the TUI plugins menu
- Wire plugin install/uninstall through both TUI and `tui_app_server`
- Refresh config/plugin state after changes so the UI updates
immediately
- Add a post-install app setup flow for plugins that require additional
app auth

<img width="1567" height="300" alt="Screenshot 2026-03-20 at 4 08 44 PM"
src="https://github.com/user-attachments/assets/366bd31b-2ffd-4e80-b4a3-3a9a9c674a5f"
/>
<img width="445" height="240" alt="Screenshot 2026-03-20 at 4 08 54 PM"
src="https://github.com/user-attachments/assets/613999ab-269a-4758-ab59-7c057a1742dc"
/>
<img width="797" height="219" alt="Screenshot 2026-03-20 at 4 09 07 PM"
src="https://github.com/user-attachments/assets/b9679e60-40f5-49bb-ade0-2e40449c3fbf"
/>
<img width="499" height="235" alt="Screenshot 2026-03-20 at 4 09 24 PM"
src="https://github.com/user-attachments/assets/261ce2fe-f356-4e99-8ac9-f29ed850bc75"
/>




Note/known issue: The /plugin install flow fails in `tui_app_server`
because after a successful install it tries to trigger a
ReloadUserConfig operation, but `tui_app_server` has not yet implemented
transport for that operation, so it falls through to the generic “Not
available in app-server TUI yet” stub.
This commit is contained in:
canvrno-oai authored and GitHub committed 2026-03-23 12:38:39 -07:00
1 parent f55f5c258f
commit b5d0a5518d
20 files changed
+2611 -56

No files matched your search

+244
View File
@@ -45,10 +45,14 @@ use codex_app_server_client::InProcessClientStartArgs;
use codex_app_server_protocol::ClientRequest;
use codex_app_server_protocol::ConfigLayerSource;
use codex_app_server_protocol::ConfigWarningNotification;
use codex_app_server_protocol::PluginInstallParams;
use codex_app_server_protocol::PluginInstallResponse;
use codex_app_server_protocol::PluginListParams;
use codex_app_server_protocol::PluginListResponse;
use codex_app_server_protocol::PluginReadParams;
use codex_app_server_protocol::PluginReadResponse;
use codex_app_server_protocol::PluginUninstallParams;
use codex_app_server_protocol::PluginUninstallResponse;
use codex_app_server_protocol::RequestId;
use codex_arg0::Arg0DispatchPaths;
use codex_core::AuthManager;
@@ -355,6 +359,72 @@ async fn request_plugin_detail(
response
}
async fn request_plugin_install(
arg0_paths: Arg0DispatchPaths,
config: Config,
cli_kv_overrides: Vec<(String, TomlValue)>,
loader_overrides: LoaderOverrides,
cloud_requirements: CloudRequirementsLoader,
feedback: codex_feedback::CodexFeedback,
params: PluginInstallParams,
) -> Result<PluginInstallResponse> {
let client = start_plugin_request_client(
arg0_paths,
config,
cli_kv_overrides,
loader_overrides,
cloud_requirements,
feedback,
)
.await?;
let request_handle = client.request_handle();
let request_id = RequestId::String(format!("plugin-install-{}", Uuid::new_v4()));
let response = request_handle
.request_typed(ClientRequest::PluginInstall { request_id, params })
.await
.wrap_err("plugin/install failed in legacy TUI");
if let Err(err) = client.shutdown().await {
tracing::warn!(%err, "failed to shut down embedded app server after plugin/install");
}
response
}
async fn request_plugin_uninstall(
arg0_paths: Arg0DispatchPaths,
config: Config,
cli_kv_overrides: Vec<(String, TomlValue)>,
loader_overrides: LoaderOverrides,
cloud_requirements: CloudRequirementsLoader,
feedback: codex_feedback::CodexFeedback,
plugin_id: String,
) -> Result<PluginUninstallResponse> {
let client = start_plugin_request_client(
arg0_paths,
config,
cli_kv_overrides,
loader_overrides,
cloud_requirements,
feedback,
)
.await?;
let request_handle = client.request_handle();
let request_id = RequestId::String(format!("plugin-uninstall-{}", Uuid::new_v4()));
let response = request_handle
.request_typed(ClientRequest::PluginUninstall {
request_id,
params: PluginUninstallParams {
plugin_id,
force_remote_sync: false,
},
})
.await
.wrap_err("plugin/uninstall failed in legacy TUI");
if let Err(err) = client.shutdown().await {
tracing::warn!(%err, "failed to shut down embedded app server after plugin/uninstall");
}
response
}
fn emit_project_config_warnings(app_event_tx: &AppEventSender, config: &Config) {
let mut disabled_folders = Vec::new();
@@ -1365,6 +1435,85 @@ impl App {
});
}
fn fetch_plugin_install(
&mut self,
cwd: PathBuf,
marketplace_path: AbsolutePathBuf,
plugin_name: String,
plugin_display_name: String,
) {
let config = self.config.clone();
let arg0_paths = self.arg0_paths.clone();
let cli_kv_overrides = self.cli_kv_overrides.clone();
let loader_overrides = self.loader_overrides.clone();
let cloud_requirements = self.cloud_requirements.clone();
let feedback = self.feedback.clone();
let app_event_tx = self.app_event_tx.clone();
tokio::spawn(async move {
let cwd_for_event = cwd.clone();
let marketplace_path_for_event = marketplace_path.clone();
let plugin_name_for_event = plugin_name.clone();
let result = request_plugin_install(
arg0_paths,
config,
cli_kv_overrides,
loader_overrides,
cloud_requirements,
feedback,
PluginInstallParams {
marketplace_path,
plugin_name,
force_remote_sync: false,
},
)
.await
.map_err(|err| format!("Failed to install plugin: {err}"));
app_event_tx.send(AppEvent::PluginInstallLoaded {
cwd: cwd_for_event,
marketplace_path: marketplace_path_for_event,
plugin_name: plugin_name_for_event,
plugin_display_name,
result,
});
});
}
fn fetch_plugin_uninstall(
&mut self,
cwd: PathBuf,
plugin_id: String,
plugin_display_name: String,
) {
let config = self.config.clone();
let arg0_paths = self.arg0_paths.clone();
let cli_kv_overrides = self.cli_kv_overrides.clone();
let loader_overrides = self.loader_overrides.clone();
let cloud_requirements = self.cloud_requirements.clone();
let feedback = self.feedback.clone();
let app_event_tx = self.app_event_tx.clone();
tokio::spawn(async move {
let cwd_for_event = cwd.clone();
let plugin_id_for_event = plugin_id.clone();
let result = request_plugin_uninstall(
arg0_paths,
config,
cli_kv_overrides,
loader_overrides,
cloud_requirements,
feedback,
plugin_id,
)
.await
.map_err(|err| format!("Failed to uninstall plugin: {err}"));
app_event_tx.send(AppEvent::PluginUninstallLoaded {
cwd: cwd_for_event,
plugin_id: plugin_id_for_event,
plugin_display_name,
result,
});
});
}
fn clear_ui_header_lines_with_version(
&self,
width: u16,
@@ -2953,6 +3102,15 @@ impl App {
AppEvent::RefreshConnectors { force_refetch } => {
self.chat_widget.refresh_connectors(force_refetch);
}
AppEvent::PluginInstallAuthAdvance { refresh_connectors } => {
if refresh_connectors {
self.chat_widget.refresh_connectors(/*force_refetch*/ true);
}
self.chat_widget.advance_plugin_install_auth_flow();
}
AppEvent::PluginInstallAuthAbandon => {
self.chat_widget.abandon_plugin_install_auth_flow();
}
AppEvent::FetchPluginsList { cwd } => {
self.fetch_plugins_list(cwd);
}
@@ -2962,6 +3120,18 @@ impl App {
self.chat_widget
.open_plugin_detail_loading_popup(&plugin_display_name);
}
AppEvent::OpenPluginInstallLoading {
plugin_display_name,
} => {
self.chat_widget
.open_plugin_install_loading_popup(&plugin_display_name);
}
AppEvent::OpenPluginUninstallLoading {
plugin_display_name,
} => {
self.chat_widget
.open_plugin_uninstall_loading_popup(&plugin_display_name);
}
AppEvent::StartFileSearch(query) => {
self.file_search.on_user_query(query);
}
@@ -2983,6 +3153,55 @@ impl App {
AppEvent::PluginDetailLoaded { cwd, result } => {
self.chat_widget.on_plugin_detail_loaded(cwd, result);
}
AppEvent::FetchPluginInstall {
cwd,
marketplace_path,
plugin_name,
plugin_display_name,
} => {
self.fetch_plugin_install(cwd, marketplace_path, plugin_name, plugin_display_name);
}
AppEvent::FetchPluginUninstall {
cwd,
plugin_id,
plugin_display_name,
} => {
self.fetch_plugin_uninstall(cwd, plugin_id, plugin_display_name);
}
AppEvent::PluginInstallLoaded {
cwd,
marketplace_path,
plugin_name,
plugin_display_name,
result,
} => {
let install_succeeded = result.is_ok();
if install_succeeded {
if let Err(err) = self.refresh_in_memory_config_from_disk().await {
tracing::warn!(error = %err, "failed to refresh config after plugin install");
}
self.chat_widget.submit_op(Op::ReloadUserConfig);
}
let should_refresh_plugin_detail = self.chat_widget.on_plugin_install_loaded(
cwd.clone(),
marketplace_path.clone(),
plugin_name.clone(),
plugin_display_name,
result,
);
if install_succeeded && self.chat_widget.config_ref().cwd == cwd {
self.fetch_plugins_list(cwd.clone());
if should_refresh_plugin_detail {
self.fetch_plugin_detail(
cwd,
PluginReadParams {
marketplace_path,
plugin_name,
},
);
}
}
}
AppEvent::UpdateReasoningEffort(effort) => {
self.on_update_reasoning_effort(effort);
self.refresh_status_surfaces();
@@ -3400,6 +3619,31 @@ impl App {
}
}
}
AppEvent::PluginUninstallLoaded {
cwd,
plugin_id: _plugin_id,
plugin_display_name,
result,
} => {
let uninstall_succeeded = result.is_ok();
if uninstall_succeeded {
if let Err(err) = self.refresh_in_memory_config_from_disk().await {
tracing::warn!(
error = %err,
"failed to refresh config after plugin uninstall"
);
}
self.chat_widget.submit_op(Op::ReloadUserConfig);
}
self.chat_widget.on_plugin_uninstall_loaded(
cwd.clone(),
plugin_display_name,
result,
);
if uninstall_succeeded && self.chat_widget.config_ref().cwd == cwd {
self.fetch_plugins_list(cwd);
}
}
AppEvent::PersistPersonalitySelection { personality } => {
let profile = self.active_profile.as_deref();
match ConfigEditsBuilder::new(&self.config.codex_home)