diff --git a/packages/opencode/src/cli/cmd/tui/component/dialog-workspace-create.tsx b/packages/opencode/src/cli/cmd/tui/component/dialog-workspace-create.tsx index 8c3111e2aa..538428e8f1 100644 --- a/packages/opencode/src/cli/cmd/tui/component/dialog-workspace-create.tsx +++ b/packages/opencode/src/cli/cmd/tui/component/dialog-workspace-create.tsx @@ -43,9 +43,7 @@ export function recentConnectedWorkspaces input.status(workspace.id) === "connected") - const workspaces = allWorkspaces - .filter((workspace) => workspace.id !== input.omitWorkspaceID) - .toSorted((a, b) => Number(b.timeUsed) - Number(a.timeUsed)) + const workspaces = allWorkspaces.toSorted((a, b) => Number(b.timeUsed) - Number(a.timeUsed)) const recent = workspaces.slice(0, input.limit ?? 3) return { recent, hasMore: recent.length < workspaces.length } @@ -83,10 +81,8 @@ export async function openWorkspaceSelect(input: { onSelect: (selection: WorkspaceSelection) => Promise | void }) { input.dialog.clear() - void input.sdk.client.experimental.workspace - .syncList() - .then(() => input.project.workspace.sync()) - .catch(() => undefined) + await input.sdk.client.experimental.workspace.syncList().catch(() => undefined) + await input.project.workspace.sync().catch(() => undefined) const adapters = await loadWorkspaceAdapters(input) if (!adapters) return input.dialog.replace(() => ) diff --git a/packages/opencode/src/control-plane/adapters/worktree.ts b/packages/opencode/src/control-plane/adapters/worktree.ts index 33f8940bc3..605d114ace 100644 --- a/packages/opencode/src/control-plane/adapters/worktree.ts +++ b/packages/opencode/src/control-plane/adapters/worktree.ts @@ -48,7 +48,7 @@ export const WorktreeAdapter: WorkspaceAdapter = { return (await AppRuntime.runPromise(Worktree.Service.use((svc) => svc.list()))).map((info) => ({ type: "worktree", name: info.name, - branch: info.branch, + branch: info.branch ?? null, directory: info.directory, extra: null, projectID: Instance.project.id, diff --git a/packages/opencode/src/worktree/index.ts b/packages/opencode/src/worktree/index.ts index 7f5b426a77..088dc9eb35 100644 --- a/packages/opencode/src/worktree/index.ts +++ b/packages/opencode/src/worktree/index.ts @@ -156,7 +156,7 @@ export interface Interface { readonly makeWorktreeInfo: (name?: string) => Effect.Effect readonly createFromInfo: (info: Info, startCommand?: string) => Effect.Effect readonly create: (input?: CreateInput) => Effect.Effect - readonly list: () => Effect.Effect + readonly list: () => Effect.Effect<(Omit & { branch?: string })[]> readonly remove: (input: RemoveInput) => Effect.Effect readonly reset: (input: ResetInput) => Effect.Effect } @@ -368,8 +368,8 @@ export const layer: Layer.Layer< if (directory === primary) return undefined return { name: pathSvc.basename(directory), - branch: entry.branch ? entry.branch.replace(/^refs\/heads\//, "") : null, directory, + ...(entry.branch ? { branch: entry.branch.replace(/^refs\/heads\//, "") } : {}), } }), ).pipe(Effect.map((items) => items.filter((item) => item !== undefined)))