(props: DialogMoveSessionProps)
| 32 | } |
| 33 | |
| 34 | export function DialogMoveSession(props: DialogMoveSessionProps) { |
| 35 | const dialog = useDialog() |
| 36 | const sdk = useSDK() |
| 37 | const dimensions = useTerminalDimensions() |
| 38 | const { theme } = useTheme() |
| 39 | const sync = useSync() |
| 40 | const projectContext = useProject() |
| 41 | const route = useRoute() |
| 42 | const toast = useToast() |
| 43 | const paths = useTuiPaths() |
| 44 | const [working, setWorking] = createSignal(Boolean(props.initialRemoving)) |
| 45 | const [toDelete, setToDelete] = createSignal<string>() |
| 46 | const [removing, setRemoving] = createSignal(props.initialRemoving) |
| 47 | const [replacementCurrent, setReplacementCurrent] = createSignal<string>() |
| 48 | const [loadError, setLoadError] = createSignal<unknown>() |
| 49 | const deleteHint = useCommandShortcut("dialog.move_session.delete") |
| 50 | onMount(() => dialog.setSize("xlarge")) |
| 51 | |
| 52 | function reopen(initialRemoving?: string) { |
| 53 | dialog.replace(() => ( |
| 54 | <DialogMoveSession {...props} initialDirectories={directoryData()} initialRemoving={initialRemoving} /> |
| 55 | )) |
| 56 | } |
| 57 | |
| 58 | // A failed current-checkout lookup only affects which row is highlighted, so |
| 59 | // swallow it and let the directory list render without a current marker. |
| 60 | const [loadedProject] = createResource( |
| 61 | () => (projectContext.project() === props.projectID ? undefined : props.projectID), |
| 62 | (projectID) => |
| 63 | sdk.client.project |
| 64 | .current({}, { throwOnError: true }) |
| 65 | .then((result) => (result.data?.id === projectID ? result.data.worktree : undefined)) |
| 66 | .catch(() => undefined), |
| 67 | ) |
| 68 | const currentCheckout = createMemo(() => { |
| 69 | if (projectContext.project() === props.projectID) return projectContext.instance.path().worktree |
| 70 | return loadedProject() |
| 71 | }) |
| 72 | |
| 73 | const [directories, { refetch }] = createResource( |
| 74 | () => (props.initialRemoving ? undefined : props.projectID), |
| 75 | async (projectID, info): Promise<ProjectDirectory[] | undefined> => { |
| 76 | try { |
| 77 | await sdk.client.v2.projectCopy.refresh( |
| 78 | { projectID, location: { directory: sdk.directory } }, |
| 79 | { throwOnError: true }, |
| 80 | ) |
| 81 | const directories = await sdk.client.project.directories({ projectID }, { throwOnError: true }) |
| 82 | setLoadError(undefined) |
| 83 | return directories.data ?? [] |
| 84 | } catch (error) { |
| 85 | setLoadError(error) |
| 86 | // An initial load with no data surfaces the inline error view below. A |
| 87 | // failed refresh intentionally stays quiet and keeps the already-shown |
| 88 | // list interactive; reopening the dialog retries the load. |
| 89 | return info.value |
| 90 | } |
| 91 | }, |
nothing calls this directly
no test coverage detected