fix(opencode): include all-mode agents in mode picker (#606)
This commit is contained in:
@@ -554,6 +554,15 @@ describe("OpenCode adapter context-window normalization", () => {
|
|||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("treats primary and all OpenCode agents as selectable modes", () => {
|
||||||
|
expect(__openCodeInternals.isSelectableOpenCodeAgent({ mode: "primary" })).toBe(true);
|
||||||
|
expect(__openCodeInternals.isSelectableOpenCodeAgent({ mode: "all" })).toBe(true);
|
||||||
|
expect(__openCodeInternals.isSelectableOpenCodeAgent({ mode: "subagent" })).toBe(false);
|
||||||
|
expect(__openCodeInternals.isSelectableOpenCodeAgent({ mode: "all", hidden: true })).toBe(
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("OpenCode adapter startTurn error handling", () => {
|
describe("OpenCode adapter startTurn error handling", () => {
|
||||||
|
|||||||
@@ -424,6 +424,10 @@ function resolveOpenCodeRuntimeAgentId(modeId: string | null | undefined): strin
|
|||||||
: normalizedModeId;
|
: normalizedModeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isSelectableOpenCodeAgent(agent: { mode?: string; hidden?: boolean }): boolean {
|
||||||
|
return (agent.mode === "primary" || agent.mode === "all") && agent.hidden !== true;
|
||||||
|
}
|
||||||
|
|
||||||
function mergeOpenCodeModes(discoveredModes: AgentMode[]): AgentMode[] {
|
function mergeOpenCodeModes(discoveredModes: AgentMode[]): AgentMode[] {
|
||||||
const modesById = new Map(DEFAULT_MODES.map((mode) => [mode.id, mode]));
|
const modesById = new Map(DEFAULT_MODES.map((mode) => [mode.id, mode]));
|
||||||
for (const mode of discoveredModes) {
|
for (const mode of discoveredModes) {
|
||||||
@@ -728,6 +732,7 @@ export const __openCodeInternals = {
|
|||||||
reconcileOpenCodeSessionClose,
|
reconcileOpenCodeSessionClose,
|
||||||
resolveOpenCodeModelLookupKeyFromAssistantMessage,
|
resolveOpenCodeModelLookupKeyFromAssistantMessage,
|
||||||
resolveOpenCodeSelectedModelContextWindow,
|
resolveOpenCodeSelectedModelContextWindow,
|
||||||
|
isSelectableOpenCodeAgent,
|
||||||
get OpenCodeAgentSession() {
|
get OpenCodeAgentSession() {
|
||||||
return OpenCodeAgentSession;
|
return OpenCodeAgentSession;
|
||||||
},
|
},
|
||||||
@@ -1191,16 +1196,14 @@ export class OpenCodeAgentClient implements AgentClient {
|
|||||||
return DEFAULT_MODES;
|
return DEFAULT_MODES;
|
||||||
}
|
}
|
||||||
|
|
||||||
const discovered = response.data
|
const discovered = response.data.filter(isSelectableOpenCodeAgent).map((agent) => ({
|
||||||
.filter((agent) => agent.mode === "primary" && agent.hidden !== true)
|
id: agent.name,
|
||||||
.map((agent) => ({
|
label: agent.name.charAt(0).toUpperCase() + agent.name.slice(1),
|
||||||
id: agent.name,
|
description:
|
||||||
label: agent.name.charAt(0).toUpperCase() + agent.name.slice(1),
|
typeof agent.description === "string" && agent.description.trim().length > 0
|
||||||
description:
|
? agent.description.trim()
|
||||||
typeof agent.description === "string" && agent.description.trim().length > 0
|
: DEFAULT_MODES.find((mode) => mode.id === agent.name)?.description,
|
||||||
? agent.description.trim()
|
}));
|
||||||
: DEFAULT_MODES.find((mode) => mode.id === agent.name)?.description,
|
|
||||||
}));
|
|
||||||
|
|
||||||
return mergeOpenCodeModes(discovered);
|
return mergeOpenCodeModes(discovered);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -2462,16 +2465,14 @@ class OpenCodeAgentSession implements AgentSession {
|
|||||||
});
|
});
|
||||||
const agents = response.error || !response.data ? [] : response.data;
|
const agents = response.error || !response.data ? [] : response.data;
|
||||||
|
|
||||||
const discoveredModes = agents
|
const discoveredModes = agents.filter(isSelectableOpenCodeAgent).map((agent) => ({
|
||||||
.filter((agent) => agent.mode === "primary" && agent.hidden !== true)
|
id: agent.name,
|
||||||
.map((agent) => ({
|
label: agent.name.charAt(0).toUpperCase() + agent.name.slice(1),
|
||||||
id: agent.name,
|
description:
|
||||||
label: agent.name.charAt(0).toUpperCase() + agent.name.slice(1),
|
typeof agent.description === "string" && agent.description.trim().length > 0
|
||||||
description:
|
? agent.description.trim()
|
||||||
typeof agent.description === "string" && agent.description.trim().length > 0
|
: DEFAULT_MODES.find((mode) => mode.id === agent.name)?.description,
|
||||||
? agent.description.trim()
|
}));
|
||||||
: DEFAULT_MODES.find((mode) => mode.id === agent.name)?.description,
|
|
||||||
}));
|
|
||||||
|
|
||||||
this.availableModesCache = mergeOpenCodeModes(discoveredModes);
|
this.availableModesCache = mergeOpenCodeModes(discoveredModes);
|
||||||
return this.availableModesCache;
|
return this.availableModesCache;
|
||||||
|
|||||||
Reference in New Issue
Block a user