mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-20 10:59:59 +00:00
fix types
This commit is contained in:
@@ -43,9 +43,7 @@ export function recentConnectedWorkspaces<WorkspaceInfo extends { id: string; ti
|
||||
omitWorkspaceID?: string
|
||||
}) {
|
||||
const allWorkspaces = input.workspaces.filter((workspace) => 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> | 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(() => <DialogWorkspaceSelect adapters={adapters} onSelect={input.onSelect} />)
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -156,7 +156,7 @@ export interface Interface {
|
||||
readonly makeWorktreeInfo: (name?: string) => Effect.Effect<Info>
|
||||
readonly createFromInfo: (info: Info, startCommand?: string) => Effect.Effect<void>
|
||||
readonly create: (input?: CreateInput) => Effect.Effect<Info>
|
||||
readonly list: () => Effect.Effect<Info[]>
|
||||
readonly list: () => Effect.Effect<(Omit<Info, "branch"> & { branch?: string })[]>
|
||||
readonly remove: (input: RemoveInput) => Effect.Effect<boolean>
|
||||
readonly reset: (input: ResetInput) => Effect.Effect<boolean>
|
||||
}
|
||||
@@ -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)))
|
||||
|
||||
Reference in New Issue
Block a user