Skip to content

Commit 09a7a78

Browse files
fix(ui): scope tool-result to the current invocation
Address review feedback: the write Views derive their success card from `toolResult`, but it wasn't cleared when a new invocation arrived (only the in-app `successPR`/`successIssue` was reset on `toolInput` change). A completed result from a previous invocation could briefly render a stale success card over the next, still-deferred form. Clear `toolResult` whenever a new `tool-input` notification arrives. The spec guarantees `tool-input` precedes that invocation's `tool-result`, so this scopes the result to the current invocation centrally in the hook — fixing all three Views without per-app invocation keys. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent d0ecf75 commit 09a7a78

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

ui/src/hooks/useMcpApp.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ export function useMcpApp({
6969
app.ontoolinput = async (input) => {
7070
const args = (input.arguments ?? {}) as Record<string, unknown>;
7171
setToolInput(args);
72+
// A tool-input notification marks a new invocation, and the spec
73+
// guarantees it is delivered before that invocation's tool-result.
74+
// Drop any prior result so a completed result from a previous
75+
// invocation can't leak into the new render (e.g. a stale success card
76+
// showing over a fresh, still-deferred form). The current invocation's
77+
// result, if any, arrives next via ontoolresult.
78+
setToolResult(null);
7279
onToolInput?.(args);
7380
};
7481
app.onhostcontextchanged = (params) => {

0 commit comments

Comments
 (0)