diff options
| author | Dax Raad <[email protected]> | 2025-11-26 12:34:48 -0500 |
|---|---|---|
| committer | Dax Raad <[email protected]> | 2025-11-26 12:34:48 -0500 |
| commit | 98031173b6cbf91aa20b110c07b2f18526b14d03 (patch) | |
| tree | dcf9598aef450efa4683a863935514c75f3b2318 | |
| parent | e8e474597cbdacf67970465699752ea360cea79b (diff) | |
| download | opencode-98031173b6cbf91aa20b110c07b2f18526b14d03.tar.gz opencode-98031173b6cbf91aa20b110c07b2f18526b14d03.zip | |
lil branch refactor
| -rw-r--r-- | packages/opencode/src/cli/cmd/tui/app.tsx | 2 | ||||
| -rw-r--r-- | packages/opencode/src/cli/cmd/tui/context/sync.tsx | 2 | ||||
| -rw-r--r-- | packages/opencode/src/project/vcs.ts | 9 | ||||
| -rw-r--r-- | packages/opencode/src/server/server.ts | 22 | ||||
| -rw-r--r-- | packages/sdk/js/src/gen/types.gen.ts | 7 |
5 files changed, 14 insertions, 28 deletions
diff --git a/packages/opencode/src/cli/cmd/tui/app.tsx b/packages/opencode/src/cli/cmd/tui/app.tsx index 13b02154e..7c72274ad 100644 --- a/packages/opencode/src/cli/cmd/tui/app.tsx +++ b/packages/opencode/src/cli/cmd/tui/app.tsx @@ -480,7 +480,7 @@ function App() { <box paddingLeft={1} paddingRight={1}> <text fg={theme.textMuted}> {process.cwd().replace(Global.Path.home, "~")} - {sync.data.vcs?.vcs?.branch ? `:${sync.data.vcs.vcs.branch}` : ""} + {sync.data.vcs?.branch ? `:${sync.data.vcs.branch}` : ""} </text> </box> </box> diff --git a/packages/opencode/src/cli/cmd/tui/context/sync.tsx b/packages/opencode/src/cli/cmd/tui/context/sync.tsx index 0293abace..b7ef8a221 100644 --- a/packages/opencode/src/cli/cmd/tui/context/sync.tsx +++ b/packages/opencode/src/cli/cmd/tui/context/sync.tsx @@ -244,7 +244,7 @@ export const { use: useSync, provider: SyncProvider } = createSimpleContext({ } case "vcs.branch.updated": { - setStore("vcs", "vcs", { branch: event.properties.branch }) + setStore("vcs", { branch: event.properties.branch }) break } } diff --git a/packages/opencode/src/project/vcs.ts b/packages/opencode/src/project/vcs.ts index 59b2f99b7..c3b21f3be 100644 --- a/packages/opencode/src/project/vcs.ts +++ b/packages/opencode/src/project/vcs.ts @@ -18,6 +18,15 @@ export namespace Vcs { ), } + export const Info = z + .object({ + branch: z.string(), + }) + .meta({ + ref: "VcsInfo", + }) + export type Info = z.infer<typeof Info> + async function currentBranch() { return $`git rev-parse --abbrev-ref HEAD` .quiet() diff --git a/packages/opencode/src/server/server.ts b/packages/opencode/src/server/server.ts index 1c8d2a003..7743e3dbb 100644 --- a/packages/opencode/src/server/server.ts +++ b/packages/opencode/src/server/server.ts @@ -376,22 +376,7 @@ export namespace Server { description: "VCS info", content: { "application/json": { - schema: resolver( - z - .object({ - worktree: z.string(), - directory: z.string(), - projectID: z.string(), - vcs: z - .object({ - branch: z.string(), - }) - .optional(), - }) - .meta({ - ref: "VcsInfo", - }), - ), + schema: resolver(Vcs.Info), }, }, }, @@ -400,10 +385,7 @@ export namespace Server { async (c) => { const branch = await Vcs.branch() return c.json({ - worktree: Instance.worktree, - directory: Instance.directory, - projectID: Instance.project.id, - vcs: Instance.project.vcs ? { branch } : undefined, + branch, }) }, ) diff --git a/packages/sdk/js/src/gen/types.gen.ts b/packages/sdk/js/src/gen/types.gen.ts index 08335dd39..efa5c9946 100644 --- a/packages/sdk/js/src/gen/types.gen.ts +++ b/packages/sdk/js/src/gen/types.gen.ts @@ -1264,12 +1264,7 @@ export type Path = { } export type VcsInfo = { - worktree: string - directory: string - projectID: string - vcs?: { - branch: string - } + branch: string } export type NotFoundError = { |
