Jelajahi Sumber

lil branch refactor

Dax Raad 2 bulan lalu
induk
melakukan
98031173b6

+ 1 - 1
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>

+ 1 - 1
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
         }
       }

+ 9 - 0
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()

+ 2 - 20
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,
           })
         },
       )

+ 1 - 6
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 = {