From 423f92e607dd51908d23b04758bc0fcd6ec5ff39 Mon Sep 17 00:00:00 2001 From: Brooklyn Nicholson Date: Thu, 13 Aug 2026 17:25:26 -0500 Subject: [PATCH] fix(desktop): connect pills reload tools into the session that clicked them Both connect providers captured `sessionId` when the suggestion was built and ignored the one the pill hands `invoke`. An offer that outlived a session switch therefore aimed its `reload.mcp` at the session the draft was sampled in, so the chat the user actually clicked from resumed without the tools the pill just said were ready. Prefer the invoking pill's session; the captured one stays as the fallback. --- apps/desktop/src/store/suggestion-providers/mcp.ts | 4 +++- apps/desktop/src/store/suggestion-providers/repair.ts | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/desktop/src/store/suggestion-providers/mcp.ts b/apps/desktop/src/store/suggestion-providers/mcp.ts index 72676c4291..81e7bf5617 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 f0ee2265c0..159348d486 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),