summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-05-29 15:47:13 +0900
committerAdam Malczewski <[email protected]>2026-05-29 15:47:13 +0900
commit9c401530254b764d9c7a74c992bec612f32ccd8e (patch)
tree887cd41dbbd619f1568c89e6da2dfc3d8784fa71
parent48194753eee9c6cb8995cf52afcbd615cf115491 (diff)
downloaddispatch-9c401530254b764d9c7a74c992bec612f32ccd8e.tar.gz
dispatch-9c401530254b764d9c7a74c992bec612f32ccd8e.zip
fix: include agent_id in foreground summon results for Open Tab button; preserve slider selection on agent config refresh
-rw-r--r--packages/core/src/tools/summon.ts12
-rw-r--r--packages/frontend/src/lib/tabs.svelte.ts22
2 files changed, 24 insertions, 10 deletions
diff --git a/packages/core/src/tools/summon.ts b/packages/core/src/tools/summon.ts
index 34109f3..cf845ea 100644
--- a/packages/core/src/tools/summon.ts
+++ b/packages/core/src/tools/summon.ts
@@ -183,12 +183,18 @@ export function createSummonTool(
});
if (!background) {
- // Block until the child agent completes
+ // Block until the child agent completes. Always prefix the
+ // result with `agent_id: <uuid>` so the frontend's
+ // ToolCallDisplay regex (`agent_id:\s*([a-f0-9-]+)`) can
+ // surface the "Open Tab" button for foreground summons too —
+ // not just background ones. The child's tab still exists and
+ // holds the full conversation, so the user should always be
+ // able to open it.
const result = await callbacks.getResult(agentId);
if (result.status === "done") {
- return result.result;
+ return `agent_id: ${agentId}\n\n${result.result}`;
}
- return `Error from child agent: ${result.error}`;
+ return `agent_id: ${agentId}\n\nError from child agent: ${result.error}`;
}
return [
diff --git a/packages/frontend/src/lib/tabs.svelte.ts b/packages/frontend/src/lib/tabs.svelte.ts
index 9d0040c..ccdd587 100644
--- a/packages/frontend/src/lib/tabs.svelte.ts
+++ b/packages/frontend/src/lib/tabs.svelte.ts
@@ -1213,17 +1213,25 @@ export function createTabStore() {
const agents = data.agents ?? [];
const freshAgent = agents.find((a) => a.slug === tab.agentSlug && a.scope === tab.agentScope);
if (!freshAgent) return;
- const firstModel = freshAgent.models[0];
const patch: Partial<Tab> = {
agentModels: freshAgent.models,
workingDirectory: freshAgent.cwd || null,
};
- if (firstModel) {
- patch.keyId = firstModel.key_id;
- patch.modelId = firstModel.model_id;
- } else {
- patch.keyId = null;
- patch.modelId = null;
+ // Preserve the user's current selection if it still exists in the
+ // refreshed models list. Only fall back to the first model when the
+ // current selection is no longer valid.
+ const currentStillValid = freshAgent.models.some(
+ (m) => m.key_id === tab.keyId && m.model_id === tab.modelId,
+ );
+ if (!currentStillValid) {
+ const firstModel = freshAgent.models[0];
+ if (firstModel) {
+ patch.keyId = firstModel.key_id;
+ patch.modelId = firstModel.model_id;
+ } else {
+ patch.keyId = null;
+ patch.modelId = null;
+ }
}
updateTab(tabId, patch);
} catch {