mirror of
https://github.com/block/goose.git
synced 2026-07-17 12:56:20 +02:00
fix: preserve imported apps during session-backed list refresh
When refreshing apps through an active session, the cache wipe for the "apps" extension was dropping cache-only imported apps. Now we save imported apps before the wipe and restore them, and merge them into the response so they appear alongside MCP-served apps. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1158,6 +1158,19 @@ async fn list_apps(
|
||||
.flat_map(|app| app.mcp_servers.iter().cloned())
|
||||
.collect();
|
||||
|
||||
// Before wiping the cache, save imported apps (cache-only) so they survive the refresh.
|
||||
// These are apps with mcp_servers=["apps"] whose URIs don't appear in the live MCP response.
|
||||
let live_uris: HashSet<&str> = apps.iter().map(|a| a.resource.uri.as_str()).collect();
|
||||
let imported_apps: Vec<GooseApp> = cache
|
||||
.list_apps()
|
||||
.unwrap_or_default()
|
||||
.into_iter()
|
||||
.filter(|a| {
|
||||
a.mcp_servers.contains(&"apps".to_string())
|
||||
&& !live_uris.contains(a.resource.uri.as_str())
|
||||
})
|
||||
.collect();
|
||||
|
||||
for extension_name in active_extensions {
|
||||
if let Err(e) = cache.delete_extension_apps(&extension_name) {
|
||||
warn!(
|
||||
@@ -1172,9 +1185,32 @@ async fn list_apps(
|
||||
warn!("Failed to cache app {}: {}", app.resource.name, e);
|
||||
}
|
||||
}
|
||||
|
||||
// Restore imported apps back to cache
|
||||
for app in &imported_apps {
|
||||
if let Err(e) = cache.store_app(app) {
|
||||
warn!(
|
||||
"Failed to restore imported app {}: {}",
|
||||
app.resource.name, e
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut apps = apps;
|
||||
// Merge imported apps into the response
|
||||
if let Some(cache) = cache.as_ref() {
|
||||
let live_uris: HashSet<String> = apps.iter().map(|a| a.resource.uri.clone()).collect();
|
||||
let imported: Vec<GooseApp> = cache
|
||||
.list_apps()
|
||||
.unwrap_or_default()
|
||||
.into_iter()
|
||||
.filter(|a| {
|
||||
a.mcp_servers.contains(&"apps".to_string()) && !live_uris.contains(&a.resource.uri)
|
||||
})
|
||||
.collect();
|
||||
apps.extend(imported);
|
||||
}
|
||||
mark_deletable_apps(&mut apps);
|
||||
|
||||
Ok(Json(ListAppsResponse { apps }))
|
||||
|
||||
Reference in New Issue
Block a user