({
onDone,
onResume
}: {
onDone: (result?: string, options?: {
display?: CommandResultDisplay;
}) => void;
onResume: (sessionId: UUID, log: LogOption, entrypoint: ResumeEntrypoint) => Promise<void>;
})
| 87 | return t5; |
| 88 | } |
| 89 | function ResumeCommand({ |
| 90 | onDone, |
| 91 | onResume |
| 92 | }: { |
| 93 | onDone: (result?: string, options?: { |
| 94 | display?: CommandResultDisplay; |
| 95 | }) => void; |
| 96 | onResume: (sessionId: UUID, log: LogOption, entrypoint: ResumeEntrypoint) => Promise<void>; |
| 97 | }): React.ReactNode { |
| 98 | const [logs, setLogs] = React.useState<LogOption[]>([]); |
| 99 | const [worktreePaths, setWorktreePaths] = React.useState<string[]>([]); |
| 100 | const [loading, setLoading] = React.useState(true); |
| 101 | const [resuming, setResuming] = React.useState(false); |
| 102 | const [showAllProjects, setShowAllProjects] = React.useState(false); |
| 103 | const { |
| 104 | rows |
| 105 | } = useTerminalSize(); |
| 106 | const insideModal = useIsInsideModal(); |
| 107 | const loadLogs = React.useCallback(async (allProjects: boolean, paths: string[]) => { |
| 108 | setLoading(true); |
| 109 | try { |
| 110 | const allLogs = allProjects ? await loadAllProjectsMessageLogs() : await loadSameRepoMessageLogs(paths); |
| 111 | const resumable = filterResumableSessions(allLogs, getSessionId()); |
| 112 | if (resumable.length === 0) { |
| 113 | onDone('No conversations found to resume'); |
| 114 | return; |
| 115 | } |
| 116 | setLogs(resumable); |
| 117 | } catch (_err) { |
| 118 | onDone('Failed to load conversations'); |
| 119 | } finally { |
| 120 | setLoading(false); |
| 121 | } |
| 122 | }, [onDone]); |
| 123 | React.useEffect(() => { |
| 124 | async function init() { |
| 125 | const paths_0 = await getWorktreePaths(getOriginalCwd()); |
| 126 | setWorktreePaths(paths_0); |
| 127 | void loadLogs(false, paths_0); |
| 128 | } |
| 129 | void init(); |
| 130 | }, [loadLogs]); |
| 131 | const handleToggleAllProjects = React.useCallback(() => { |
| 132 | const newValue = !showAllProjects; |
| 133 | setShowAllProjects(newValue); |
| 134 | void loadLogs(newValue, worktreePaths); |
| 135 | }, [showAllProjects, loadLogs, worktreePaths]); |
| 136 | async function handleSelect(log: LogOption) { |
| 137 | const sessionId = validateUuid(getSessionIdFromLog(log)); |
| 138 | if (!sessionId) { |
| 139 | onDone('Failed to resume conversation'); |
| 140 | return; |
| 141 | } |
| 142 | |
| 143 | // Load full messages for lite logs |
| 144 | const fullLog = isLiteLog(log) ? await loadFullLog(log) : log; |
| 145 | |
| 146 | // Check if this conversation is from a different directory |
nothing calls this directly
no test coverage detected