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", () => {
|
||||
|
||||
@@ -424,6 +424,10 @@ function resolveOpenCodeRuntimeAgentId(modeId: string | null | undefined): strin
|
||||
: normalizedModeId;
|
||||
}
|
||||
|
||||
function isSelectableOpenCodeAgent(agent: { mode?: string; hidden?: boolean }): boolean {
|
||||
return (agent.mode === "primary" || agent.mode === "all") && agent.hidden !== true;
|
||||
}
|
||||
|
||||
function mergeOpenCodeModes(discoveredModes: AgentMode[]): AgentMode[] {
|
||||
const modesById = new Map(DEFAULT_MODES.map((mode) => [mode.id, mode]));
|
||||
for (const mode of discoveredModes) {
|
||||
@@ -728,6 +732,7 @@ export const __openCodeInternals = {
|
||||
reconcileOpenCodeSessionClose,
|
||||
resolveOpenCodeModelLookupKeyFromAssistantMessage,
|
||||
resolveOpenCodeSelectedModelContextWindow,
|
||||
isSelectableOpenCodeAgent,
|
||||
get OpenCodeAgentSession() {
|
||||
return OpenCodeAgentSession;
|
||||
},
|
||||
@@ -1191,9 +1196,7 @@ export class OpenCodeAgentClient implements AgentClient {
|
||||
return DEFAULT_MODES;
|
||||
}
|
||||
|
||||
const discovered = response.data
|
||||
.filter((agent) => agent.mode === "primary" && agent.hidden !== true)
|
||||
.map((agent) => ({
|
||||
const discovered = response.data.filter(isSelectableOpenCodeAgent).map((agent) => ({
|
||||
id: agent.name,
|
||||
label: agent.name.charAt(0).toUpperCase() + agent.name.slice(1),
|
||||
description:
|
||||
@@ -2462,9 +2465,7 @@ class OpenCodeAgentSession implements AgentSession {
|
||||
});
|
||||
const agents = response.error || !response.data ? [] : response.data;
|
||||
|
||||
const discoveredModes = agents
|
||||
.filter((agent) => agent.mode === "primary" && agent.hidden !== true)
|
||||
.map((agent) => ({
|
||||
const discoveredModes = agents.filter(isSelectableOpenCodeAgent).map((agent) => ({
|
||||
id: agent.name,
|
||||
label: agent.name.charAt(0).toUpperCase() + agent.name.slice(1),
|
||||
description:
|
||||
|
||||
Reference in New Issue
Block a user