({ log, onExit, onSelect }: Props)
| 16 | }; |
| 17 | |
| 18 | export function SessionPreview({ log, onExit, onSelect }: Props): React.ReactNode { |
| 19 | // fullLog holds the complete log with messages loaded. |
| 20 | // The input `log` may be a "lite log" (empty messages array), |
| 21 | // so we load the full messages on mount and store them here. |
| 22 | const [fullLog, setFullLog] = React.useState<LogOption | null>(null); |
| 23 | |
| 24 | // Load full messages if this is a lite log |
| 25 | React.useEffect(() => { |
| 26 | setFullLog(null); |
| 27 | if (isLiteLog(log)) { |
| 28 | void loadFullLog(log).then(setFullLog); |
| 29 | } |
| 30 | }, [log]); |
| 31 | |
| 32 | const isLoading = isLiteLog(log) && fullLog === null; |
| 33 | const displayLog = fullLog ?? log; |
| 34 | const conversationId = getSessionIdFromLog(displayLog) || ('' as UUID); |
| 35 | |
| 36 | // Get all base tools for preview (no permissions needed for read-only view) |
| 37 | const tools = getAllBaseTools(); |
| 38 | |
| 39 | // Handle keyboard input via keybindings |
| 40 | useKeybinding('confirm:no', onExit, { context: 'Confirmation' }); |
| 41 | |
| 42 | const handleSelect = useCallback(() => { |
| 43 | onSelect(fullLog ?? log); |
| 44 | }, [onSelect, fullLog, log]); |
| 45 | |
| 46 | useKeybinding('confirm:yes', handleSelect, { context: 'Confirmation' }); |
| 47 | |
| 48 | // Show loading state while fetching full log |
| 49 | if (isLoading) { |
| 50 | return ( |
| 51 | <Box flexDirection="column" padding={1}> |
| 52 | <LoadingState message="Loading session…" /> |
| 53 | <Text dimColor> |
| 54 | <Byline> |
| 55 | <ConfigurableShortcutHint action="confirm:no" context="Confirmation" fallback="Esc" description="cancel" /> |
| 56 | </Byline> |
| 57 | </Text> |
| 58 | </Box> |
| 59 | ); |
| 60 | } |
| 61 | |
| 62 | return ( |
| 63 | <Box flexDirection="column"> |
| 64 | <Messages |
| 65 | messages={displayLog.messages} |
| 66 | tools={tools} |
| 67 | commands={[]} |
| 68 | verbose={true} |
| 69 | toolJSX={null} |
| 70 | toolUseConfirmQueue={[]} |
| 71 | inProgressToolUseIDs={new Set()} |
| 72 | isMessageSelectorVisible={false} |
| 73 | conversationId={conversationId} |
| 74 | screen="transcript" |
| 75 | streamingToolUses={[]} |
nothing calls this directly
no test coverage detected