Skip to content

Commit 0a6637e

Browse files
authored
chore(app): vendor v2 client snapshot (anomalyco#38818)
1 parent 2b2b69d commit 0a6637e

33 files changed

Lines changed: 268 additions & 191 deletions

bun.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/app/e2e/regression/review-state-persistence.spec.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ async function switchSession(page: Page, title: string) {
6565

6666
async function setup(page: Page) {
6767
await mockOpenCodeServer(page, {
68-
protocol: "v2",
68+
protocol: "v1",
6969
directory,
7070
project: {
7171
id: projectID,
@@ -93,20 +93,18 @@ async function setup(page: Page) {
9393
route.fulfill({
9494
status: 200,
9595
contentType: "application/json",
96-
body: JSON.stringify({ location: { directory }, data: { branch: "feature", defaultBranch: "dev" } }),
96+
body: JSON.stringify({ branch: "feature", default_branch: "dev" }),
9797
}),
9898
)
9999
await page.route("**/vcs/diff**", (route) =>
100100
route.fulfill({
101101
status: 200,
102102
contentType: "application/json",
103-
body: JSON.stringify({
104-
location: { directory },
105-
data:
106-
new URL(route.request().url()).searchParams.get("mode") === "branch"
107-
? [diff("src/alpha.ts"), diff("src/beta.ts")]
108-
: [diff("src/alpha.ts"), diff("src/gamma.ts")],
109-
}),
103+
body: JSON.stringify(
104+
new URL(route.request().url()).searchParams.get("mode") === "branch"
105+
? [diff("src/alpha.ts"), diff("src/beta.ts")]
106+
: [diff("src/alpha.ts"), diff("src/gamma.ts")],
107+
),
110108
}),
111109
)
112110
await page.addInitScript(

packages/app/e2e/regression/review-terminal-stacked.spec.ts

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ test("keeps the review tree and terminal sized when both panels are open", async
2525
let detailFailures = 1
2626
await page.setViewportSize({ width: 1400, height: 900 })
2727
await mockOpenCodeServer(page, {
28-
protocol: "v2",
28+
protocol: "v1",
2929
directory,
3030
project: {
3131
id: projectID,
@@ -67,33 +67,31 @@ test("keeps the review tree and terminal sized when both panels are open", async
6767
status: 200,
6868
contentType: "application/json",
6969
body: JSON.stringify({
70-
location: { directory },
71-
data: { branch: "review-pane-performance", defaultBranch: "dev" },
70+
branch: "review-pane-performance",
71+
default_branch: "dev",
7272
}),
7373
}),
7474
)
75-
await page.route("**/api/vcs/diff**", (route) => {
75+
await page.route("**/vcs/diff**", (route) => {
7676
const url = new URL(route.request().url())
77-
const scope = url.searchParams.get("location[directory]")?.replaceAll("\\", "/")
77+
const scope = url.searchParams.get("directory")?.replaceAll("\\", "/")
7878
const detail = scope?.endsWith("/src/branch/d00027")
7979
if (detail && detailFailures-- > 0) return route.fulfill({ status: 500, body: "retry detail" })
8080
return route.fulfill({
8181
status: 200,
8282
contentType: "application/json",
83-
body: JSON.stringify({
84-
location: { directory: scope ?? directory, project: { id: projectID, directory } },
85-
data:
86-
url.searchParams.get("mode") === "branch"
87-
? detail
88-
? branchDiffs
89-
.filter((diff) => diff.file.startsWith("src/branch/d00027/"))
90-
.map((diff) => fileDiff(diff.file, diff.additions, true, detailVersion))
91-
: branchDiffs
92-
: Array.from({ length: 7 }, (_, index) => fileDiff(`src/git-${index}.ts`, 1)),
93-
}),
83+
body: JSON.stringify(
84+
url.searchParams.get("mode") === "branch"
85+
? detail
86+
? branchDiffs
87+
.filter((diff) => diff.file.startsWith("src/branch/d00027/"))
88+
.map((diff) => fileDiff(diff.file, diff.additions, true, detailVersion))
89+
: branchDiffs
90+
: Array.from({ length: 7 }, (_, index) => fileDiff(`src/git-${index}.ts`, 1)),
91+
),
9492
})
9593
})
96-
await page.route("**/api/pty*", (route) =>
94+
await page.route("**/pty*", (route) =>
9795
route.fulfill({
9896
status: 200,
9997
contentType: "application/json",
@@ -111,7 +109,7 @@ test("keeps the review tree and terminal sized when both panels are open", async
111109
}),
112110
}),
113111
)
114-
await page.route("**/api/pty/pty_review_terminal*", (route) =>
112+
await page.route("**/pty/pty_review_terminal*", (route) =>
115113
route.fulfill({
116114
status: 200,
117115
contentType: "application/json",
@@ -129,7 +127,7 @@ test("keeps the review tree and terminal sized when both panels are open", async
129127
}),
130128
}),
131129
)
132-
await page.route("**/api/pty/pty_review_terminal/connect-token*", (route) =>
130+
await page.route("**/pty/pty_review_terminal/connect-token*", (route) =>
133131
route.fulfill({
134132
status: 200,
135133
contentType: "application/json",
@@ -139,7 +137,7 @@ test("keeps the review tree and terminal sized when both panels are open", async
139137
}),
140138
}),
141139
)
142-
await page.routeWebSocket("**/api/pty/pty_review_terminal/connect", () => undefined)
140+
await page.routeWebSocket("**/pty/pty_review_terminal/connect", () => undefined)
143141
await page.addInitScript(() => {
144142
localStorage.setItem("settings.v3", JSON.stringify({ general: { newLayoutDesigns: true } }))
145143
localStorage.setItem(
@@ -177,8 +175,8 @@ test("keeps the review tree and terminal sized when both panels are open", async
177175
const lazyDiff = page.waitForRequest((request) => {
178176
const url = new URL(request.url())
179177
return (
180-
url.pathname === "/api/vcs/diff" &&
181-
url.searchParams.get("location[directory]")?.replaceAll("\\", "/").endsWith("/src/branch/d00027") === true
178+
url.pathname === "/vcs/diff" &&
179+
url.searchParams.get("directory")?.replaceAll("\\", "/").endsWith("/src/branch/d00027") === true
182180
)
183181
})
184182
await lastFile.click()
@@ -192,8 +190,8 @@ test("keeps the review tree and terminal sized when both panels are open", async
192190
const refreshedDiff = page.waitForRequest((request) => {
193191
const url = new URL(request.url())
194192
return (
195-
url.pathname === "/api/vcs/diff" &&
196-
url.searchParams.get("location[directory]")?.replaceAll("\\", "/").endsWith("/src/branch/d00027") === true
193+
url.pathname === "/vcs/diff" &&
194+
url.searchParams.get("directory")?.replaceAll("\\", "/").endsWith("/src/branch/d00027") === true
197195
)
198196
})
199197
sessionStatus[sessionID] = { type: "idle" }

packages/app/e2e/regression/terminal-tab-switch.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ test("keeps the terminal session alive when switching session tabs in a workspac
3232
const connection = new URL(connections[0]!)
3333
expect(connection.pathname).toBe(`/api/pty/${ptyID}/connect`)
3434
expect(connection.searchParams.get("location[directory]")).toBe(directory)
35-
expect(connection.searchParams.get("ticket")).toBe("e2e-ticket")
35+
expect(connection.searchParams.get("ticket")).toBeNull()
3636
await writeProbe(page)
3737

3838
await switchTab(page, titleB)

packages/app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"@dnd-kit/helpers": "0.5.0",
5454
"@dnd-kit/solid": "0.5.0",
5555
"@kobalte/core": "catalog:",
56-
"@opencode-ai/client": "file:vendor/opencode-ai-client-1.17.13.tgz",
56+
"@opencode-ai/client": "file:vendor/opencode-ai-client-1.17.13-v2.tgz",
5757
"@opencode-ai/core": "workspace:*",
5858
"@opencode-ai/schema": "workspace:*",
5959
"@opencode-ai/sdk": "workspace:*",

packages/app/src/components/dialog-select-directory-v2.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { createEffect, createMemo, createResource, createSignal, For, onCleanup,
88
import { useGlobal } from "@/context/global"
99
import { useLanguage } from "@/context/language"
1010
import { ServerConnection } from "@/context/server"
11+
import type { Path } from "@opencode-ai/sdk/v2/client"
1112
import {
1213
absoluteTreePath,
1314
activeTreeNavigation,
@@ -68,7 +69,13 @@ export function DialogSelectDirectoryV2(props: DialogSelectDirectoryV2Props) {
6869
const missingBase = createMemo(() => !(sync.data.path.home || sync.data.path.directory))
6970
const [fallbackPath] = createResource(
7071
() => (missingBase() ? true : undefined),
71-
() => sdk.api.path.get().catch(() => undefined),
72+
async (): Promise<Path | undefined> => {
73+
if ((await sdk.protocol) !== "v1") return
74+
return sdk.client.path
75+
.get()
76+
.then((result) => result.data)
77+
.catch(() => undefined)
78+
},
7279
{ initialValue: undefined },
7380
)
7481
const home = createMemo(() => sync.data.path.home || fallbackPath()?.home || "")

packages/app/src/components/dialog-select-directory.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { useLanguage } from "@/context/language"
99
import { ServerConnection } from "@/context/server"
1010
import { useGlobal } from "@/context/global"
1111
import { cleanPickerInput, createDirectorySearch, displayPickerPath } from "./directory-picker-domain"
12+
import type { Path } from "@opencode-ai/sdk/v2/client"
1213

1314
interface DialogSelectDirectoryProps {
1415
title?: string
@@ -59,8 +60,12 @@ export function DialogSelectDirectory(props: DialogSelectDirectoryProps) {
5960
const missingBase = createMemo(() => !(sync.data.path.home || sync.data.path.directory))
6061
const [fallbackPath] = createResource(
6162
() => (missingBase() ? true : undefined),
62-
async () => {
63-
return sdk.api.path.get().catch(() => undefined)
63+
async (): Promise<Path | undefined> => {
64+
if ((await sdk.protocol) !== "v1") return
65+
return sdk.client.path
66+
.get()
67+
.then((result) => result.data)
68+
.catch(() => undefined)
6469
},
6570
{ initialValue: undefined },
6671
)

packages/app/src/components/edit-project.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,23 @@ export function createEditProjectModel(props: { project: LocalProject; server: S
7171
const start = store.startup.trim()
7272

7373
if (props.project.id && props.project.id !== "global") {
74-
const project = await serverCtx().sdk.api.project.update({
75-
projectID: props.project.id,
76-
name,
77-
icon: { color: store.color || "", override: store.iconOverride || "" },
78-
commands: { start },
79-
})
74+
if ((await serverCtx().sdk.protocol) !== "v1") return
75+
const project = await serverCtx()
76+
.sdk.client.project.update({
77+
projectID: props.project.id,
78+
directory: props.project.worktree,
79+
name,
80+
icon: { color: store.color || "", override: store.iconOverride || "" },
81+
commands: { start },
82+
})
83+
.then((result) => result.data)
84+
if (!project) return
85+
// const project = await serverCtx().sdk.api.project.update({
86+
// projectID: props.project.id,
87+
// name,
88+
// icon: { color: store.color || "", override: store.iconOverride || "" },
89+
// commands: { start },
90+
// })
8091
serverCtx().sync.set("project", (items) =>
8192
items.map((item) => (item.id === project.id ? normalizeProjectInfo(project) : item)),
8293
)

packages/app/src/components/prompt-input.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
709709
title: cmd.name,
710710
description: cmd.description,
711711
type: "custom" as const,
712-
source: cmd.source,
712+
// source: cmd.source,
713713
}))
714714

715715
return [...custom, ...builtin]

packages/app/src/components/settings-general.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ export const SettingsGeneral: Component = () => {
132132
if ((await sdk.protocol) === "v1") {
133133
return (await sdk.client.pty.shells()).data ?? []
134134
}
135-
return (await sdk.api.pty.shells()).data
135+
// return (await sdk.api.pty.shells()).data
136+
return [] as ShellOption[]
136137
},
137138
{ initialValue: [] as ShellOption[] },
138139
)

0 commit comments

Comments
 (0)