Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/app/e2e/performance/timeline-stability/fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ export function userMessage(
role: "user",
time: { created: input.created ?? 1700000000000 },
summary: input.summary ?? { diffs: [] },
agent: "build",
agent: "work",
model,
},
parts: seeds.map((part) => ({
Expand Down Expand Up @@ -398,8 +398,8 @@ export function assistantMessage(
parentID: input.parentID ?? userID,
modelID: model.modelID,
providerID: model.providerID,
mode: "build",
agent: "build",
mode: "work",
agent: "work",
path: { cwd: directory, root: directory },
cost: 0.01,
tokens: { input: 100, output: 200, reasoning: 0, cache: { read: 0, write: 0 } },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const userMessage = {
role: "user",
time: { created: 1700000000000 },
summary: { diffs: [] },
agent: "build",
agent: "work",
model,
},
parts: [
Expand Down Expand Up @@ -83,8 +83,8 @@ const assistantMessage = {
parentID: userMessageID,
modelID: model.modelID,
providerID: model.providerID,
mode: "build",
agent: "build",
mode: "work",
agent: "work",
path: { cwd: directory, root: directory },
cost: 0.01,
tokens: { input: 100, output: 200, reasoning: 0, cache: { read: 0, write: 0 } },
Expand Down Expand Up @@ -329,7 +329,7 @@ function performanceTurn(index: number) {
role: "user",
time: { created: 1690000000000 + index * 2_000 },
summary: { diffs: [] },
agent: "build",
agent: "work",
model,
},
parts: [
Expand All @@ -351,8 +351,8 @@ function performanceTurn(index: number) {
parentID: userID,
modelID: model.modelID,
providerID: model.providerID,
mode: "build",
agent: "build",
mode: "work",
agent: "work",
path: { cwd: directory, root: directory },
cost: 0.01,
tokens: { input: 100, output: 200, reasoning: 0, cache: { read: 0, write: 0 } },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function userMessage(sessionID: string, index: number, textLength: number, diffs
role: "user",
time: { created: 1700000000000 + index * 10_000 },
summary: { diffs },
agent: "build",
agent: "work",
model,
},
parts: [
Expand All @@ -83,8 +83,8 @@ function assistantMessage(sessionID: string, index: number, parentID: string, pa
parentID,
modelID: model.modelID,
providerID: model.providerID,
mode: "build",
agent: "build",
mode: "work",
agent: "work",
path: { cwd: directory, root: directory },
cost: 0.01,
tokens: { input: 100, output: 200, reasoning: 0, cache: { read: 0, write: 0 } },
Expand Down
2 changes: 1 addition & 1 deletion packages/app/e2e/regression/cross-server-tab-close.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ async function mockServers(page: Page, requests: string[]) {
if (["/global/config", "/config", "/provider/auth", "/mcp"].includes(url.pathname)) return json(route, {})
if (url.pathname === "/provider")
return json(route, { all: [], connected: [], default: { providerID: "", modelID: "" } })
if (url.pathname === "/agent") return json(route, [{ name: "build", mode: "primary" }])
if (url.pathname === "/agent") return json(route, [{ name: "work", mode: "primary" }])
if (url.pathname === "/project" || url.pathname === "/project/current") {
const project = {
id: current.projectID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ async function mockServers(page: Page, permissionRequests: string[], permissionR
return json(route, [])
if (["/global/config", "/config", "/provider/auth", "/mcp"].includes(url.pathname)) return json(route, {})
if (url.pathname === "/provider") return json(route, provider(remote ? "server-b" : "server-a"))
if (url.pathname === "/agent") return json(route, [{ name: "build", mode: "primary" }])
if (url.pathname === "/agent") return json(route, [{ name: "work", mode: "primary" }])
if (url.pathname === "/project" || url.pathname === "/project/current") {
const project = {
id: remote ? sessionB.projectID : "project-server-a",
Expand Down
2 changes: 1 addition & 1 deletion packages/app/e2e/regression/remote-tab-busy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ async function mockServers(page: Page) {
if (["/global/config", "/config", "/provider/auth", "/mcp"].includes(url.pathname)) return json(route, {})
if (url.pathname === "/provider")
return json(route, { all: [], connected: [], default: { providerID: "", modelID: "" } })
if (url.pathname === "/agent") return json(route, [{ name: "build", mode: "primary" }])
if (url.pathname === "/agent") return json(route, [{ name: "work", mode: "primary" }])
if (url.pathname === "/project" || url.pathname === "/project/current") {
const project = {
id: current.projectID,
Expand Down
2 changes: 1 addition & 1 deletion packages/app/e2e/regression/review-image-flash.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ async function openReview(page: Page) {
role: "user",
time: { created: 1700000000000 },
summary: { diffs: [] },
agent: "build",
agent: "work",
model: { providerID: "opencode", modelID: "test" },
},
parts: [
Expand Down
2 changes: 1 addition & 1 deletion packages/app/e2e/regression/review-line-comment.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ async function openReview(page: Page) {
role: "user",
time: { created: 1700000000000 },
summary: { diffs: [] },
agent: "build",
agent: "work",
model: { providerID: "opencode", modelID: "test" },
},
parts: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const userMessage = {
role: "user",
time: { created: 1700000000000 },
summary: { diffs: [] },
agent: "build",
agent: "work",
model,
},
parts: [
Expand Down Expand Up @@ -90,8 +90,8 @@ const assistantMessage = {
parentID: userMessageID,
modelID: model.modelID,
providerID: model.providerID,
mode: "build",
agent: "build",
mode: "work",
agent: "work",
path: { cwd: directory, root: directory },
cost: 0.01,
tokens: { input: 100, output: 200, reasoning: 0, cache: { read: 0, write: 0 } },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ function turn(index: number, target: boolean, status: "running" | "completed" =
role: "user",
time: { created: 1700000000000 + index * 10_000 },
summary: { diffs: [] },
agent: "build",
agent: "work",
model,
},
parts: [{ id: id("prt_user", index), sessionID, messageID: userID, type: "text", text: `User message ${index}` }],
Expand All @@ -236,8 +236,8 @@ function turn(index: number, target: boolean, status: "running" | "completed" =
parentID: userID,
modelID: model.modelID,
providerID: model.providerID,
mode: "build",
agent: "build",
mode: "work",
agent: "work",
path: { cwd: directory, root: directory },
cost: 0.01,
tokens: { input: 100, output: 200, reasoning: 0, cache: { read: 0, write: 0 } },
Expand Down
6 changes: 3 additions & 3 deletions packages/app/e2e/regression/subagent-child-navigation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function parentMessages() {
sessionID: parentID,
role: "user",
time: { created: 1700000000000 },
agent: "build",
agent: "work",
model: { providerID: "opencode", modelID: "claude-opus-4-6" },
},
parts: [
Expand All @@ -150,8 +150,8 @@ function parentMessages() {
parentID: userID,
modelID: "claude-opus-4-6",
providerID: "opencode",
mode: "build",
agent: "build",
mode: "work",
agent: "work",
path: { cwd: directory, root: directory },
cost: 0.01,
tokens: { input: 100, output: 200, reasoning: 0, cache: { read: 0, write: 0 } },
Expand Down
2 changes: 1 addition & 1 deletion packages/app/e2e/regression/tab-navigate-mousedown.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ async function mockServer(page: Page) {
if (["/global/config", "/config", "/provider/auth", "/mcp"].includes(url.pathname)) return json(route, {})
if (url.pathname === "/provider")
return json(route, { all: [], connected: [], default: { providerID: "", modelID: "" } })
if (url.pathname === "/agent") return json(route, [{ name: "build", mode: "primary" }])
if (url.pathname === "/agent") return json(route, [{ name: "work", mode: "primary" }])
if (url.pathname === "/project" || url.pathname === "/project/current") {
const project = {
id: sessionA.projectID,
Expand Down
6 changes: 3 additions & 3 deletions packages/app/e2e/smoke/session-timeline.fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function userMessage(sessionID: string, index: number, textLength: number, diffs
role: "user",
time: { created: 1700000000000 + index * 10_000 },
summary: { diffs },
agent: "build",
agent: "work",
model,
},
parts: [
Expand All @@ -83,8 +83,8 @@ function assistantMessage(sessionID: string, index: number, parentID: string, pa
parentID,
modelID: model.modelID,
providerID: model.providerID,
mode: "build",
agent: "build",
mode: "work",
agent: "work",
path: { cwd: directory, root: directory },
cost: 0.01,
tokens: { input: 100, output: 200, reasoning: 0, cache: { read: 0, write: 0 } },
Expand Down
8 changes: 4 additions & 4 deletions packages/app/e2e/utils/mock-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export async function mockOpenCodeServer(page: Page, config: MockServerConfig) {
},
"/project": [config.project],
"/project/current": config.project,
"/agent": [{ name: "build", mode: "primary" }],
"/agent": [{ name: "work", mode: "primary" }],
"/vcs": { branch: "main", default_branch: "main" },
"/session": config.sessions,
}
Expand Down Expand Up @@ -125,7 +125,7 @@ export async function mockOpenCodeServer(page: Page, config: MockServerConfig) {
location: location(config),
data: [
{
id: "build",
id: "work",
name: "Build",
mode: "primary",
hidden: false,
Expand Down Expand Up @@ -343,7 +343,7 @@ export function currentSession(session: { id: string } & Record<string, unknown>
id: session.id,
parentID: session.parentID,
projectID: session.projectID ?? "project",
agent: session.agent ?? "build",
agent: session.agent ?? "work",
model: session.model ?? { id: "mock-model", providerID: "mock-provider" },
cost: session.cost ?? 0,
tokens: session.tokens ?? { input: 0, output: 0, reasoning: 0, cache: { read: 0, write: 0 } },
Expand Down Expand Up @@ -383,7 +383,7 @@ function currentMessage(value: unknown) {
id: item.info.id,
type: "assistant",
time: item.info.time,
agent: item.info.agent ?? "build",
agent: item.info.agent ?? "work",
model: { id: item.info.modelID ?? "model", providerID: item.info.providerID ?? "provider" },
cost: item.info.cost,
tokens: item.info.tokens,
Expand Down
12 changes: 6 additions & 6 deletions packages/app/src/components/prompt-input.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function createPromptInputStoryRuntime() {
function PromptInputExample() {
const input = createPromptInputStoryRuntime()
const [controls, setControls] = createStore({
agent: "build",
agent: "work",
variant: undefined as string | undefined,
comments: 0,
tabs: [] as string[],
Expand All @@ -49,13 +49,13 @@ function PromptInputExample() {
const inputControls = {
agents: {
available: [{ name: "review", hidden: false, mode: "subagent" }],
options: ["build", "review", "plan"],
options: ["work", "review", "plan"],
get current() {
return controls.agent
},
loading: false,
visible: true,
select: (agent?: string) => setControls("agent", agent ?? "build"),
select: (agent?: string) => setControls("agent", agent ?? "work"),
},
model: {
selection: model,
Expand Down Expand Up @@ -120,20 +120,20 @@ const todos: Todo[] = [
function PromptInputWithOpenDock() {
const input = createPromptInputStoryRuntime()
const [controls, setControls] = createStore({
agent: "build",
agent: "work",
activeTab: undefined as string | undefined,
todoCollapsed: false,
})
const inputControls = {
agents: {
available: [],
options: ["build"],
options: ["work"],
get current() {
return controls.agent
},
loading: false,
visible: true,
select: (agent?: string) => setControls("agent", agent ?? "build"),
select: (agent?: string) => setControls("agent", agent ?? "work"),
},
model: {
selection: {
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/context/global-sync/bootstrap.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ describe("bootstrapDirectory", () => {
provider,
},
sdk: {
app: { agents: async () => ({ data: [{ name: "build", mode: "primary" }] }) },
app: { agents: async () => ({ data: [{ name: "work", mode: "primary" }] }) },
config: {
get: async () => {
legacyConfigReads.push("directory")
Expand Down
6 changes: 3 additions & 3 deletions packages/app/src/context/global-sync/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ describe("normalizeAgentList", () => {
test("adapts current agents to the app agent shape", () => {
const result = normalizeAgentList([
{
id: "build",
name: "Build",
id: "work",
name: "Work",
mode: "primary",
hidden: false,
color: "primary",
Expand All @@ -25,7 +25,7 @@ describe("normalizeAgentList", () => {

expect(result).toEqual([
{
name: "build",
name: "work",
description: undefined,
mode: "primary",
hidden: false,
Expand Down
18 changes: 13 additions & 5 deletions packages/app/src/context/local-agent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,26 @@ describe("hasCustomAgent", () => {
})

describe("resolveAgent", () => {
const agents = [{ name: "plan" }, { name: "build" }, { name: "custom" }]
const agents = [{ name: "plan" }, { name: "work" }, { name: "custom" }]

test("uses the requested available agent", () => {
expect(resolveAgent(agents, "custom")?.name).toBe("custom")
})

test("defaults to build", () => {
expect(resolveAgent(agents)?.name).toBe("build")
expect(resolveAgent(agents, "missing")?.name).toBe("build")
test("defaults to work", () => {
expect(resolveAgent(agents)?.name).toBe("work")
expect(resolveAgent(agents, "missing")?.name).toBe("work")
})

test("uses the first agent when build is unavailable", () => {
test("resolves the legacy build id onto work", () => {
expect(resolveAgent(agents, "work")?.name).toBe("work")
})

test("prefers a real agent named build over the alias", () => {
expect(resolveAgent([{ name: "work" }, { name: "work" }], "work")?.name).toBe("work")
})

test("uses the first agent when work is unavailable", () => {
expect(resolveAgent([{ name: "custom" }], "missing")?.name).toBe("custom")
})
})
12 changes: 11 additions & 1 deletion packages/app/src/context/local-agent.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
import { Agent } from "@opencode-ai/schema/agent"

export function hasCustomAgent(items: Array<{ native?: boolean }>) {
return items.some((item) => item.native === false)
}

export function resolveAgent<T extends { name: string }>(items: T[], name?: string) {
return items.find((item) => item.name === name) ?? items.find((item) => item.name === "work") ?? items[0]
const byName = (value: string | undefined) => (value === undefined ? undefined : items.find((i) => i.name === value))
return (
byName(name) ??
// `build` is the legacy id of `work`: persisted preferences and old
// sessions still reference it.
byName(name === undefined ? undefined : Agent.LEGACY_IDS[name]) ??
byName(Agent.DEFAULT_ID) ??
items[0]
)
}
2 changes: 1 addition & 1 deletion packages/app/src/context/server-sdk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ describe("enqueueServerEvent", () => {
sessionID: "session",
role: "user",
time: { created: 1 },
agent: "build",
agent: "work",
model: { providerID: "provider", modelID: "model" },
},
},
Expand Down
Loading
Loading