fix types
This commit is contained in:
parent
771170fb03
commit
8d63dc34c0
3 changed files with 6 additions and 10 deletions
|
|
@ -43,9 +43,7 @@ export function recentConnectedWorkspaces<WorkspaceInfo extends { id: string; ti
|
||||||
omitWorkspaceID?: string
|
omitWorkspaceID?: string
|
||||||
}) {
|
}) {
|
||||||
const allWorkspaces = input.workspaces.filter((workspace) => input.status(workspace.id) === "connected")
|
const allWorkspaces = input.workspaces.filter((workspace) => input.status(workspace.id) === "connected")
|
||||||
const workspaces = allWorkspaces
|
const workspaces = allWorkspaces.toSorted((a, b) => Number(b.timeUsed) - Number(a.timeUsed))
|
||||||
.filter((workspace) => workspace.id !== input.omitWorkspaceID)
|
|
||||||
.toSorted((a, b) => Number(b.timeUsed) - Number(a.timeUsed))
|
|
||||||
const recent = workspaces.slice(0, input.limit ?? 3)
|
const recent = workspaces.slice(0, input.limit ?? 3)
|
||||||
|
|
||||||
return { recent, hasMore: recent.length < workspaces.length }
|
return { recent, hasMore: recent.length < workspaces.length }
|
||||||
|
|
@ -83,10 +81,8 @@ export async function openWorkspaceSelect(input: {
|
||||||
onSelect: (selection: WorkspaceSelection) => Promise<void> | void
|
onSelect: (selection: WorkspaceSelection) => Promise<void> | void
|
||||||
}) {
|
}) {
|
||||||
input.dialog.clear()
|
input.dialog.clear()
|
||||||
void input.sdk.client.experimental.workspace
|
await input.sdk.client.experimental.workspace.syncList().catch(() => undefined)
|
||||||
.syncList()
|
await input.project.workspace.sync().catch(() => undefined)
|
||||||
.then(() => input.project.workspace.sync())
|
|
||||||
.catch(() => undefined)
|
|
||||||
const adapters = await loadWorkspaceAdapters(input)
|
const adapters = await loadWorkspaceAdapters(input)
|
||||||
if (!adapters) return
|
if (!adapters) return
|
||||||
input.dialog.replace(() => <DialogWorkspaceSelect adapters={adapters} onSelect={input.onSelect} />)
|
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) => ({
|
return (await AppRuntime.runPromise(Worktree.Service.use((svc) => svc.list()))).map((info) => ({
|
||||||
type: "worktree",
|
type: "worktree",
|
||||||
name: info.name,
|
name: info.name,
|
||||||
branch: info.branch,
|
branch: info.branch ?? null,
|
||||||
directory: info.directory,
|
directory: info.directory,
|
||||||
extra: null,
|
extra: null,
|
||||||
projectID: Instance.project.id,
|
projectID: Instance.project.id,
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,7 @@ export interface Interface {
|
||||||
readonly makeWorktreeInfo: (name?: string) => Effect.Effect<Info>
|
readonly makeWorktreeInfo: (name?: string) => Effect.Effect<Info>
|
||||||
readonly createFromInfo: (info: Info, startCommand?: string) => Effect.Effect<void>
|
readonly createFromInfo: (info: Info, startCommand?: string) => Effect.Effect<void>
|
||||||
readonly create: (input?: CreateInput) => Effect.Effect<Info>
|
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 remove: (input: RemoveInput) => Effect.Effect<boolean>
|
||||||
readonly reset: (input: ResetInput) => Effect.Effect<boolean>
|
readonly reset: (input: ResetInput) => Effect.Effect<boolean>
|
||||||
}
|
}
|
||||||
|
|
@ -368,8 +368,8 @@ export const layer: Layer.Layer<
|
||||||
if (directory === primary) return undefined
|
if (directory === primary) return undefined
|
||||||
return {
|
return {
|
||||||
name: pathSvc.basename(directory),
|
name: pathSvc.basename(directory),
|
||||||
branch: entry.branch ? entry.branch.replace(/^refs\/heads\//, "") : null,
|
|
||||||
directory,
|
directory,
|
||||||
|
...(entry.branch ? { branch: entry.branch.replace(/^refs\/heads\//, "") } : {}),
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
).pipe(Effect.map((items) => items.filter((item) => item !== undefined)))
|
).pipe(Effect.map((items) => items.filter((item) => item !== undefined)))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue