summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTimo Clasen <[email protected]>2025-08-15 00:58:44 +0200
committerGitHub <[email protected]>2025-08-14 17:58:44 -0500
commit156cc6cffe417a419cb23069d3cb97df20d4311d (patch)
treebff6eadc21c236383c45e76da14ed69c3d058941
parentbcd1dddcbe3f5191c99f2f5ae1610af199232aff (diff)
downloadopencode-156cc6cffe417a419cb23069d3cb97df20d4311d.tar.gz
opencode-156cc6cffe417a419cb23069d3cb97df20d4311d.zip
fix(TUI): fix agent types agents modal (#1942)
-rw-r--r--packages/opencode/src/agent/agent.ts5
-rw-r--r--packages/sdk/go/app.go2
-rw-r--r--packages/tui/internal/components/dialog/agents.go43
3 files changed, 24 insertions, 26 deletions
diff --git a/packages/opencode/src/agent/agent.ts b/packages/opencode/src/agent/agent.ts
index 7f0831c08..98884abaf 100644
--- a/packages/opencode/src/agent/agent.ts
+++ b/packages/opencode/src/agent/agent.ts
@@ -13,6 +13,7 @@ export namespace Agent {
name: z.string(),
description: z.string().optional(),
mode: z.union([z.literal("subagent"), z.literal("primary"), z.literal("all")]),
+ builtIn: z.boolean(),
topP: z.number().optional(),
temperature: z.number().optional(),
permission: z.object({
@@ -58,6 +59,7 @@ export namespace Agent {
options: {},
permission: agentPermission,
mode: "subagent",
+ builtIn: true,
},
build: {
name: "build",
@@ -65,6 +67,7 @@ export namespace Agent {
options: {},
permission: agentPermission,
mode: "primary",
+ builtIn: true,
},
plan: {
name: "plan",
@@ -76,6 +79,7 @@ export namespace Agent {
patch: false,
},
mode: "primary",
+ builtIn: true,
},
}
for (const [key, value] of Object.entries(cfg.agent ?? {})) {
@@ -91,6 +95,7 @@ export namespace Agent {
permission: agentPermission,
options: {},
tools: {},
+ builtIn: false,
}
const { model, prompt, tools, description, temperature, top_p, mode, permission, ...extra } = value
item.options = {
diff --git a/packages/sdk/go/app.go b/packages/sdk/go/app.go
index 2771f6bd4..36d5be77f 100644
--- a/packages/sdk/go/app.go
+++ b/packages/sdk/go/app.go
@@ -72,6 +72,7 @@ func (r *AppService) Providers(ctx context.Context, opts ...option.RequestOption
}
type Agent struct {
+ BuiltIn bool `json:"builtIn,required"`
Mode AgentMode `json:"mode,required"`
Name string `json:"name,required"`
Options map[string]interface{} `json:"options,required"`
@@ -87,6 +88,7 @@ type Agent struct {
// agentJSON contains the JSON metadata for the struct [Agent]
type agentJSON struct {
+ BuiltIn apijson.Field
Mode apijson.Field
Name apijson.Field
Options apijson.Field
diff --git a/packages/tui/internal/components/dialog/agents.go b/packages/tui/internal/components/dialog/agents.go
index 38a3d3599..c2cbd6450 100644
--- a/packages/tui/internal/components/dialog/agents.go
+++ b/packages/tui/internal/components/dialog/agents.go
@@ -76,20 +76,15 @@ func (a agentSelectItem) Render(
agentName := a.displayName
- // For user agents and subagents, show description; for built-in, show mode
+ // Determine if agent is built-in or custom using the agent's builtIn field
var displayText string
- if a.description != "" && (a.mode == "all" || a.mode == "subagent") {
- // User agent or subagent with description
- displayText = a.description
+ if a.agent.BuiltIn {
+ displayText = "(built-in)"
} else {
- // Built-in without description - show mode
- switch a.mode {
- case "primary":
- displayText = "(built-in)"
- case "all":
+ if a.description != "" {
+ displayText = a.description
+ } else {
displayText = "(user)"
- default:
- displayText = ""
}
}
@@ -206,23 +201,19 @@ func (a *agentDialog) calculateOptimalWidth(agents []agentSelectItem) int {
for _, agent := range agents {
// Calculate the width needed for this item: "AgentName - Description" (visual improvement)
itemWidth := len(agent.displayName)
- if agent.description != "" && (agent.mode == "all" || agent.mode == "subagent") {
- // User agent or subagent - use description (capped to maxDescriptionLength)
- descLength := len(agent.description)
- if descLength > maxDescriptionLength {
- descLength = maxDescriptionLength
- }
- itemWidth += descLength + 3 // " - "
+
+ if agent.agent.BuiltIn {
+ itemWidth += len("(built-in)") + 3 // " - "
} else {
- // Built-in without description - use mode
- var modeText string
- switch agent.mode {
- case "primary":
- modeText = "(built-in)"
- case "all":
- modeText = "(user)"
+ if agent.description != "" {
+ descLength := len(agent.description)
+ if descLength > maxDescriptionLength {
+ descLength = maxDescriptionLength
+ }
+ itemWidth += descLength + 3 // " - "
+ } else {
+ itemWidth += len("(user)") + 3 // " - "
}
- itemWidth += len(modeText) + 3 // " - "
}
if itemWidth > maxWidth {