MCPcopy
hub / github.com/claude-code-best/claude-code / SessionPreview

Function SessionPreview

src/components/SessionPreview.tsx:18–102  ·  view source on GitHub ↗
({ log, onExit, onSelect }: Props)

Source from the content-addressed store, hash-verified

16};
17
18export 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={[]}

Callers

nothing calls this directly

Calls 7

isLiteLogFunction · 0.85
loadFullLogFunction · 0.85
getSessionIdFromLogFunction · 0.85
getAllBaseToolsFunction · 0.85
useKeybindingFunction · 0.85
formatRelativeTimeAgoFunction · 0.85
onSelectFunction · 0.50

Tested by

no test coverage detected