Skip to content

The agent that grows with you

fix(desktop): connect pills reload tools into the session that clicked them

Brooklyn Nicholson423f92e607dd
diff --git a/apps/desktop/src/store/suggestion-providers/mcp.ts b/apps/desktop/src/store/suggestion-providers/mcp.ts
index 72676c4291e..81e7bf56175 100644
--- a/apps/desktop/src/store/suggestion-providers/mcp.ts
+++ b/apps/desktop/src/store/suggestion-providers/mcp.ts
@@ -186,7 +186,9 @@ function toSuggestion(match: McpMatch, sessionId: string | null): ComposerSugges
doneLabel: copy('added', name),
doneTip: copy('addedTip'),
id: match.server,
- invoke: context => connect(match.server, sessionId, context.cancelled),
+ // The pill's session wins over the one captured at sample time: the reload
+ // has to reach the session the user is actually looking at.
+ invoke: context => connect(match.server, context.sessionId ?? sessionId, context.cancelled),
label: copy('label', name),
provider: 'mcp',
tip: copy('tip', match.keyword),
diff --git a/apps/desktop/src/store/suggestion-providers/repair.ts b/apps/desktop/src/store/suggestion-providers/repair.ts
index f0ee2265c00..159348d486d 100644
--- a/apps/desktop/src/store/suggestion-providers/repair.ts
+++ b/apps/desktop/src/store/suggestion-providers/repair.ts
@@ -73,7 +73,7 @@ function toSuggestion(server: string, sessionId: string | null): ComposerSuggest
doneTip: copy('doneTip'),
icon: 'plug',
id: server,
- invoke: context => reconnect(server, sessionId, context.cancelled),
+ invoke: context => reconnect(server, context.sessionId ?? sessionId, context.cancelled),
label: copy('label', name),
provider: 'repair',
tip: copy('tip', name),