Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

fix(subagents): disambiguate identical fallback labels

inorilzy2349815e5891
diff --git a/apps/desktop/src/components/settings/SubagentFallbackModels.tsx b/apps/desktop/src/components/settings/SubagentFallbackModels.tsx
index aaf75e2dc..536952b16 100644
--- a/apps/desktop/src/components/settings/SubagentFallbackModels.tsx
+++ b/apps/desktop/src/components/settings/SubagentFallbackModels.tsx
@@ -18,6 +18,10 @@ export function SubagentFallbackModels({ primary, values, choices, onChange }: {
const { t } = useTranslation();
const selected = new Set([primary, ...values].map((pin) => subagentModelSelectValue(pin, choices)));
const available = choices.filter((choice) => !selected.has(choice.value));
+ const rows = values.map((pin) => {
+ const choice = choices.find((candidate) => pinMatchesChoice(pin, candidate));
+ return { choice, text: choice ? `${choice.providerName}/${choice.modelId}` : pin };
+ });
const move = (index: number, delta: number) => {
const next = [...values];
[next[index], next[index + delta]] = [next[index + delta], next[index]];
@@ -27,8 +31,13 @@ export function SubagentFallbackModels({ primary, values, choices, onChange }: {
<Field label={t("extensions.subagents.fallbackModels")} hint={t("extensions.subagents.fallbackModelsHint")}>
<ol className="space-y-2">
{values.map((pin, index) => {
- const choice = choices.find((candidate) => pinMatchesChoice(pin, candidate));
- const label = choice ? `${choice.providerName}/${choice.modelId}` : pin;
+ const { choice, text } = rows[index];
+ const duplicate = rows.some((other, position) => position !== index && other.text === text);
+ const sameProvider = choice && rows.some((other, position) =>
+ position !== index && other.text === text && other.choice?.providerId === choice.providerId);
+ const label = duplicate
+ ? `${text} (${!choice || sameProvider ? `${index + 1}: ${pin}` : choice.providerId})`
+ : text;
return (
<li key={`${index}:${pin}`} className="flex items-center gap-2">
<span className="min-w-0 flex-1 break-all text-sm">{index + 1}. {label}</span>
diff --git a/apps/desktop/test/subagent-fallback-label.test.mjs b/apps/desktop/test/subagent-fallback-label.test.mjs
index d51df5050..3ea4ff32f 100644
--- a/apps/desktop/test/subagent-fallback-label.test.mjs
+++ b/apps/desktop/test/subagent-fallback-label.test.mjs
@@ -7,10 +7,11 @@ import { createServer } from "vite";
import test from "node:test";
import { fileURLToPath } from "node:url";
-test("fallback rows show configured provider names without changing model pins", async () => {
+test("fallback rows show provider names and disambiguate equal labels", async () => {
const server = await createServer({
root: fileURLToPath(new URL("..", import.meta.url)),
configFile: false,
+ resolve: { alias: { "@pi-desktop/shared": fileURLToPath(new URL("../../../packages/shared/src/index.ts", import.meta.url)) } },
server: { middlewareMode: true, hmr: false, ws: false },
esbuild: { jsx: "automatic" },
appType: "custom",
@@ -56,6 +57,22 @@ test("fallback rows show configured provider names without changing model pins",
assert.doesNotMatch(html, /721fcc76-026e-4f35-a32d-5e2a8d204499/);
assert.doesNotMatch(html, /1\. Other Workspace\/deepseek-v4\.1-flash/);
+ const duplicateChoices = choices.map((choice) => ({ ...choice, providerName: "Shared Workspace" }));
+ const duplicate = render([pin, choices[0].value], duplicateChoices);
+ assert.match(duplicate, /Shared Workspace\/deepseek-v4\.1-flash \(721fcc76-026e-4f35-a32d-5e2a8d204499\)/);
+ assert.match(duplicate, /Shared Workspace\/deepseek-v4\.1-flash \(other-provider\)/);
+ assert.match(duplicate, /aria-label="Remove Shared Workspace\/deepseek-v4\.1-flash \(721fcc76-026e-4f35-a32d-5e2a8d204499\)"/);
+ assert.match(duplicate, /aria-label="Remove Shared Workspace\/deepseek-v4\.1-flash \(other-provider\)"/);
+
+ const legacy = render(["Shared Workspace/deepseek-v4.1-flash", pin], duplicateChoices);
+ assert.match(legacy, /Shared Workspace\/deepseek-v4\.1-flash \(1: Shared Workspace\/deepseek-v4\.1-flash\)/);
+ assert.match(legacy, /Shared Workspace\/deepseek-v4\.1-flash \(721fcc76-026e-4f35-a32d-5e2a8d204499\)/);
+
+ const sameProviderChoices = [{ ...choices[1], value: "anthropic/deepseek-v4.1-flash", providerName: "Anthropic" }];
+ const sameProvider = render(["anthropic/deepseek-v4.1-flash", "Anthropic/deepseek-v4.1-flash"], sameProviderChoices);
+ assert.match(sameProvider, /Anthropic\/deepseek-v4\.1-flash \(1: anthropic\/deepseek-v4\.1-flash\)/);
+ assert.match(sameProvider, /Anthropic\/deepseek-v4\.1-flash \(2: Anthropic\/deepseek-v4\.1-flash\)/);
+
const unavailable = render([pin], []);
assert.match(unavailable, /721fcc76-026e-4f35-a32d-5e2a8d204499\/deepseek-v4\.1-flash/);
} finally {
diff --git a/docs/spec/03-runtime/13-model-catalog-and-selection.md b/docs/spec/03-runtime/13-model-catalog-and-selection.md
index c33e53723..9c68285e2 100644
--- a/docs/spec/03-runtime/13-model-catalog-and-selection.md
+++ b/docs/spec/03-runtime/13-model-catalog-and-selection.md
@@ -157,8 +157,10 @@ provider disappears from the picker.
The sheet also offers an ordered **Fallback models** list using that same
configured-model picker. Users can add, move up/down, or remove alternatives.
Already-selected models are excluded from the add menu. Each saved row shows the
-configured provider display name and model ID when the catalog still contains it;
-the stored pin is unchanged. Saved pins that become
+configured provider display name and model ID when the catalog still contains it.
+When selected fallback rows have the same visible label, resolved rows include
+the provider ID; unresolved or same-provider duplicates include their position
+and stored pin instead. The stored pin is unchanged. Saved pins that become
unavailable stay visible and removable; reopening or editing another field
must not drop them. Clearing the list saves `fallbackModels: []`. Inherit-session
remains a primary-only choice. The hint explains that alternatives run after
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index 13f84c7c6..5e19cda2e 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -10204,8 +10204,10 @@ This test plan spec is accepted when:
their pins use distinct stored provider ids. Add one as a fallback model,
save and reopen the sheet. Confirm the ordered row and its move/remove
accessible names use the provider display name and model ID, not the id,
- while the saved pin still identifies the chosen provider. Disable that
- provider and confirm the unavailable pin stays visible and removable.
+ while the saved pin still identifies the chosen provider. Add the second
+ provider with the same model ID and confirm both rows and their accessible
+ names include their provider IDs to distinguish them. Disable one provider
+ and confirm its unavailable pin stays visible and removable.
5. Confirm the picker offers no **Custom (provider/model)…** entry and the
field renders no free-text input, so a model id can only come from the
configured catalog. Switch the picker to **Inherit session model**, save,