GeezerVison is showing github.com — feat(app): migrate discovery workflows · anomalyco/opencode@9f299ff
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/app/e2e/regression/cross-server-tab-close.spec.ts +18-4Lines changed: 18 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import { expect, test, type Page, type Route } from "@playwright/test" | 2 | 2 | import { base64Encode } from "@opencode-ai/core/util/encode" | | 3 | +import { currentSession } from "../utils/mock-server" | 3 | 4 |
| 4 | 5 | const serverA = "http://127.0.0.1:4096" | 5 | 6 | const serverB = "http://127.0.0.1:4097" | @@ -33,7 +34,7 @@ test("closing the active server's last tab opens the remaining server tab", asyn | 33 | 34 | await tabA.locator('[data-slot="tab-close"] button').click() | 34 | 35 |
| 35 | 36 | await expect(page).toHaveURL(new RegExp(`${hrefB.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`)) | 36 | | - await expect.poll(() => requests.some((url) => url.startsWith(`${serverB}/session/${sessionB.id}`))).toBe(true) | | 37 | + await expect.poll(() => requests.some((url) => url.startsWith(`${serverB}/api/session/${sessionB.id}`))).toBe(true) | 37 | 38 | await expect(page.getByText(sessionB.title).first()).toBeVisible() | 38 | 39 | const sessionBRequests = requests.filter((url) => url.includes(`/session/${sessionB.id}`)) | 39 | 40 | expect(sessionBRequests.every((url) => url.startsWith(serverB))).toBe(true) | @@ -84,16 +85,19 @@ async function mockServers(page: Page, requests: string[]) { | 84 | 85 | const current = url.origin === serverA ? sessionA : sessionB | 85 | 86 | const directory = url.searchParams.get("directory") | 86 | 87 | if (directory && directory !== current.directory) return json(route, { name: "InvalidDirectory" }, 500) | 87 | | - if (url.pathname === "/global/event" || url.pathname === "/event") return sse(route) | | 88 | + if (url.pathname === "/global/event" || url.pathname === "/event" || url.pathname === "/api/event") return sse(route) | 88 | 89 | if (url.pathname === "/global/health") return json(route, { healthy: true }) | 89 | | - if (url.pathname === "/session") return json(route, [current]) | | 90 | + if (url.pathname === "/api/session") return json(route, { data: [currentSession(current)], cursor: {} }) | | 91 | + if (url.pathname === "/api/session/active") return json(route, { data: {} }) | | 92 | + if (url.pathname === `/api/session/${current.id}`) return json(route, { data: currentSession(current) }) | | 93 | + if (url.pathname === `/api/session/${current.id}/message`) return json(route, { data: [], cursor: {} }) | 90 | 94 | if (url.pathname === `/session/${current.id}`) return json(route, current) | 91 | 95 | if (/^\/session\/[^/]+$/.test(url.pathname)) return json(route, { name: "NotFoundError" }, 404) | 92 | 96 | if (url.pathname === `/session/${current.id}/message`) return json(route, []) | 93 | 97 | if (/^\/session\/[^/]+\/(children|todo|diff)$/.test(url.pathname)) return json(route, []) | 94 | 98 | if (["/skill", "/command", "/lsp", "/formatter", "/permission", "/question", "/vcs/diff"].includes(url.pathname)) | 95 | 99 | return json(route, []) | 96 | | - if (["/global/config", "/config", "/provider/auth", "/mcp", "/session/status"].includes(url.pathname)) | | 100 | + if (["/global/config", "/config", "/provider/auth", "/mcp"].includes(url.pathname)) | 97 | 101 | return json(route, {}) | 98 | 102 | if (url.pathname === "/provider") | 99 | 103 | return json(route, { all: [], connected: [], default: { providerID: "", modelID: "" } }) | @@ -116,7 +120,17 @@ async function mockServers(page: Page, requests: string[]) { | 116 | 120 | directory: current.directory, | 117 | 121 | home: current.directory, | 118 | 122 | }) | | 123 | + if (url.pathname === "/api/path") | | 124 | + return json(route, { | | 125 | + state: current.directory, | | 126 | + config: current.directory, | | 127 | + worktree: current.directory, | | 128 | + directory: current.directory, | | 129 | + home: current.directory, | | 130 | + }) | 119 | 131 | if (url.pathname === "/vcs") return json(route, { branch: "main", default_branch: "main" }) | | 132 | + if (url.pathname === "/api/vcs") | | 133 | + return json(route, { location: { directory: current.directory }, data: { branch: "main", defaultBranch: "main" } }) | 120 | 134 | return json(route, {}) | 121 | 135 | }) | 122 | 136 | } | |
Collapse file Copy file name to clipboardExpand all lines: packages/app/e2e/regression/remote-tab-busy.spec.ts +20-6Lines changed: 20 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import { expect, test, type Page, type Route } from "@playwright/test" | 2 | 2 | import { base64Encode } from "@opencode-ai/core/util/encode" | | 3 | +import { currentSession } from "../utils/mock-server" | 3 | 4 |
| 4 | 5 | const serverA = "http://127.0.0.1:4096" | 5 | 6 | const serverB = "http://127.0.0.1:4097" | @@ -57,11 +58,14 @@ async function mockServers(page: Page) { | 57 | 58 | const current = url.origin === serverA ? sessionA : sessionB | 58 | 59 | const directory = url.searchParams.get("directory") | 59 | 60 | if (directory && directory !== current.directory) return json(route, { name: "InvalidDirectory" }, 500) | 60 | | - if (url.pathname === "/global/event" || url.pathname === "/event") return sse(route) | | 61 | + if (url.pathname === "/global/event" || url.pathname === "/event" || url.pathname === "/api/event") | | 62 | + return sse(route, url.pathname === "/api/event") | 61 | 63 | if (url.pathname === "/global/health") return json(route, { healthy: true }) | 62 | | - if (url.pathname === "/session/status") | 63 | | - return json(route, url.origin === serverB ? { [sessionB.id]: { type: "busy" } } : {}) | 64 | | - if (url.pathname === "/session") return json(route, [current]) | | 64 | + if (url.pathname === "/api/session/active") | | 65 | + return json(route, { data: url.origin === serverB ? { [sessionB.id]: { type: "running" } } : {} }) | | 66 | + if (url.pathname === "/api/session") return json(route, { data: [currentSession(current)], cursor: {} }) | | 67 | + if (url.pathname === `/api/session/${current.id}`) return json(route, { data: currentSession(current) }) | | 68 | + if (url.pathname === `/api/session/${current.id}/message`) return json(route, { data: [], cursor: {} }) | 65 | 69 | if (url.pathname === `/session/${current.id}`) return json(route, current) | 66 | 70 | if (/^\/session\/[^/]+$/.test(url.pathname)) return json(route, { name: "NotFoundError" }, 404) | 67 | 71 | if (url.pathname === `/session/${current.id}/message`) return json(route, []) | @@ -90,7 +94,17 @@ async function mockServers(page: Page) { | 90 | 94 | directory: current.directory, | 91 | 95 | home: current.directory, | 92 | 96 | }) | | 97 | + if (url.pathname === "/api/path") | | 98 | + return json(route, { | | 99 | + state: current.directory, | | 100 | + config: current.directory, | | 101 | + worktree: current.directory, | | 102 | + directory: current.directory, | | 103 | + home: current.directory, | | 104 | + }) | 93 | 105 | if (url.pathname === "/vcs") return json(route, { branch: "main", default_branch: "main" }) | | 106 | + if (url.pathname === "/api/vcs") | | 107 | + return json(route, { location: { directory: current.directory }, data: { branch: "main", defaultBranch: "main" } }) | 94 | 108 | return json(route, {}) | 95 | 109 | }) | 96 | 110 | } | @@ -104,10 +118,10 @@ function json(route: Route, body: unknown, status = 200) { | 104 | 118 | }) | 105 | 119 | } | 106 | 120 |
| 107 | | -function sse(route: Route) { | | 121 | +function sse(route: Route, current: boolean) { | 108 | 122 | return route.fulfill({ | 109 | 123 | status: 200, | 110 | 124 | contentType: "text/event-stream", | 111 | | - body: `data: ${JSON.stringify({ payload: { id: "evt_mock_connected", type: "server.connected", properties: {} } })}\n\n`, | | 125 | + body: current ? 'data: {"id":"evt_connected","type":"server.connected","data":{}}\n\n' : ": ok\n\n", | 112 | 126 | }) | 113 | 127 | } |
Collapse file Copy file name to clipboardExpand all lines: packages/app/e2e/regression/session-list-path-loading.spec.ts +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -16,8 +16,8 @@ test("shows loaded sessions before the directory path request resolves", async ( | 16 | 16 | const pathBlocked = new Promise<void>((resolve) => { | 17 | 17 | releasePath = resolve | 18 | 18 | }) | 19 | | - await page.route("**/path?*", async (route) => { | 20 | | - if (!new URL(route.request().url()).searchParams.has("directory")) return route.fallback() | | 19 | + await page.route("**/api/path?*", async (route) => { | | 20 | + if (!new URL(route.request().url()).searchParams.has("location[directory]")) return route.fallback() | 21 | 21 | await pathBlocked | 22 | 22 | return route.fallback() | 23 | 23 | }) | |
Collapse file Copy file name to clipboardExpand all lines: packages/app/e2e/regression/tab-navigate-mousedown.spec.ts +22-3Lines changed: 22 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import { expect, test, type Page, type Route } from "@playwright/test" | 2 | 2 | import { base64Encode } from "@opencode-ai/core/util/encode" | | 3 | +import { currentSession } from "../utils/mock-server" | 3 | 4 |
| 4 | 5 | const server = "http://127.0.0.1:4096" | 5 | 6 | const sessionA = session("ses_tab_a", "Tab A session") | @@ -56,17 +57,22 @@ async function mockServer(page: Page) { | 56 | 57 | await page.route("**/*", async (route) => { | 57 | 58 | const url = new URL(route.request().url()) | 58 | 59 | if (url.origin !== server) return route.fallback() | 59 | | - if (url.pathname === "/global/event" || url.pathname === "/event") return sse(route) | | 60 | + if (url.pathname === "/global/event" || url.pathname === "/event" || url.pathname === "/api/event") return sse(route) | 60 | 61 | if (url.pathname === "/global/health") return json(route, { healthy: true }) | 61 | | - if (url.pathname === "/session") return json(route, sessions) | | 62 | + if (url.pathname === "/api/session") return json(route, { data: sessions.map(currentSession), cursor: {} }) | | 63 | + if (url.pathname === "/api/session/active") return json(route, { data: {} }) | | 64 | + const currentSessionInfo = sessions.find((item) => url.pathname === `/api/session/${item.id}`) | | 65 | + if (currentSessionInfo) return json(route, { data: currentSession(currentSessionInfo) }) | | 66 | + if (sessions.some((item) => url.pathname === `/api/session/${item.id}/message`)) | | 67 | + return json(route, { data: [], cursor: {} }) | 62 | 68 | const byId = sessions.find((item) => url.pathname === `/session/${item.id}`) | 63 | 69 | if (byId) return json(route, byId) | 64 | 70 | if (/^\/session\/[^/]+$/.test(url.pathname)) return json(route, { name: "NotFoundError" }, 404) | 65 | 71 | if (/^\/session\/[^/]+\/message$/.test(url.pathname)) return json(route, []) | 66 | 72 | if (/^\/session\/[^/]+\/(children|todo|diff)$/.test(url.pathname)) return json(route, []) | 67 | 73 | if (["/skill", "/command", "/lsp", "/formatter", "/permission", "/question", "/vcs/diff"].includes(url.pathname)) | 68 | 74 | return json(route, []) | 69 | | - if (["/global/config", "/config", "/provider/auth", "/mcp", "/session/status"].includes(url.pathname)) | | 75 | + if (["/global/config", "/config", "/provider/auth", "/mcp"].includes(url.pathname)) | 70 | 76 | return json(route, {}) | 71 | 77 | if (url.pathname === "/provider") | 72 | 78 | return json(route, { all: [], connected: [], default: { providerID: "", modelID: "" } }) | @@ -89,7 +95,20 @@ async function mockServer(page: Page) { | 89 | 95 | directory: sessionA.directory, | 90 | 96 | home: sessionA.directory, | 91 | 97 | }) | | 98 | + if (url.pathname === "/api/path") | | 99 | + return json(route, { | | 100 | + state: sessionA.directory, | | 101 | + config: sessionA.directory, | | 102 | + worktree: sessionA.directory, | | 103 | + directory: sessionA.directory, | | 104 | + home: sessionA.directory, | | 105 | + }) | 92 | 106 | if (url.pathname === "/vcs") return json(route, { branch: "main", default_branch: "main" }) | | 107 | + if (url.pathname === "/api/vcs") | | 108 | + return json(route, { | | 109 | + location: { directory: sessionA.directory }, | | 110 | + data: { branch: "main", defaultBranch: "main" }, | | 111 | + }) | 93 | 112 | return json(route, {}) | 94 | 113 | }) | 95 | 114 | } | |
Collapse file Copy file name to clipboardExpand all lines: packages/app/src/components/command-palette.ts +8-5Lines changed: 8 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import { getFilename } from "@opencode-ai/core/util/path" | 2 | | -import type { GlobalSession, Project } from "@opencode-ai/sdk/v2/client" | | 2 | +import type { Project } from "@opencode-ai/sdk/v2/client" | | 3 | +import type { SessionInfo } from "@opencode-ai/client/promise" | 3 | 4 | import { useDialog } from "@opencode-ai/ui/context/dialog" | 4 | 5 | import { createMemo, onCleanup } from "solid-js" | 5 | 6 | import { commandPaletteOptions, useCommand, type CommandOption } from "@/context/command" | @@ -13,6 +14,7 @@ import { useTabs } from "@/context/tabs" | 13 | 14 | import { displayName, projectForSession } from "@/pages/layout/helpers" | 14 | 15 | import { createSessionTabs } from "@/pages/session/helpers" | 15 | 16 | import { useSessionLayout } from "@/pages/session/session-layout" | | 17 | +import { normalizeSessionInfo } from "@/utils/session" | 16 | 18 |
| 17 | 19 | export type CommandPaletteEntry = { | 18 | 20 | id: string | @@ -145,7 +147,7 @@ export function createCommandPaletteModel(props: { filesOnly?: () => boolean; on | 145 | 147 | opened: serverCtx.projects.list, | 146 | 148 | stored: () => serverCtx.sync.data.project, | 147 | 149 | load: (search, signal) => | 148 | | - serverSDK.client.experimental.session.list({ roots: true, search, limit: 50 }, { signal }), | | 150 | + serverSDK.api.session.list({ parentID: null, search, limit: 50 }, { signal }), | 149 | 151 | untitled: () => language.t("command.session.new"), | 150 | 152 | category: () => language.t("command.category.session"), | 151 | 153 | }) | @@ -219,7 +221,7 @@ export function createServerSessionEntries(props: { | 219 | 221 | server: ServerConnection.Key | 220 | 222 | opened: () => LocalProject[] | 221 | 223 | stored: () => Project[] | 222 | | - load: (search: string, signal: AbortSignal) => Promise<{ data?: GlobalSession[] }> | | 224 | + load: (search: string, signal: AbortSignal) => Promise<{ data: SessionInfo[] }> | 223 | 225 | untitled: () => string | 224 | 226 | category: () => string | 225 | 227 | }) { | @@ -255,7 +257,8 @@ export function createServerSessionEntries(props: { | 255 | 257 | return props | 256 | 258 | .load(search, current.signal) | 257 | 259 | .then((result) => | 258 | | - (result.data ?? []) | | 260 | + result.data | | 261 | + .map(normalizeSessionInfo) | 259 | 262 | .filter((session) => !session.time.archived) | 260 | 263 | .map((session) => { | 261 | 264 | const project = | @@ -264,7 +267,7 @@ export function createServerSessionEntries(props: { | 264 | 267 | id: `session:${props.server}:${session.id}`, | 265 | 268 | type: "session" as const, | 266 | 269 | title: session.title || props.untitled(), | 267 | | - description: project ? displayName(project) : session.project?.name || getFilename(session.directory), | | 270 | + description: project ? displayName(project) : getFilename(session.directory), | 268 | 271 | category: props.category(), | 269 | 272 | directory: session.directory, | 270 | 273 | sessionID: session.id, | |
Collapse file Copy file name to clipboardExpand all lines: packages/app/src/components/dialog-command-palette-v2.tsx +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -80,7 +80,7 @@ export function DialogHomeCommandPaletteV2(props: { | 80 | 80 | opened: serverCtx.projects.list, | 81 | 81 | stored: () => serverCtx.sync.data.project, | 82 | 82 | load: (search, signal) => | 83 | | - serverCtx.sdk.client.experimental.session.list({ roots: true, search, limit: 50 }, { signal }), | | 83 | + serverCtx.sdk.api.session.list({ parentID: null, search, limit: 50 }, { signal }), | 84 | 84 | untitled: () => language.t("command.session.new"), | 85 | 85 | category: () => language.t("command.category.session"), | 86 | 86 | }) | |
|