diff --git a/frontend/src/pages/SessionDetailPage.tsx b/frontend/src/pages/SessionDetailPage.tsx index 372ebe68..ab5b50a6 100644 --- a/frontend/src/pages/SessionDetailPage.tsx +++ b/frontend/src/pages/SessionDetailPage.tsx @@ -32,6 +32,8 @@ export function SessionDetailPage() { const [librarySteps, setLibrarySteps] = useState([]) const [copiedStepIndex, setCopiedStepIndex] = useState(null) const [maxStepIndex, setMaxStepIndex] = useState(null) + const [detailLevel, setDetailLevel] = useState<'standard' | 'full'>('standard') + const [includeSummary, setIncludeSummary] = useState(false) useEffect(() => { if (id) { @@ -96,6 +98,8 @@ export function SessionDetailPage() { include_timestamps: true, include_tree_info: true, ...(maxStepIndex !== null && { max_step_index: maxStepIndex }), + detail_level: detailLevel, + include_summary: includeSummary, } return await sessionsApi.export(session.id, options) } @@ -142,6 +146,8 @@ export function SessionDetailPage() { include_timestamps: true, include_tree_info: true, ...(maxStepIndex !== null && { max_step_index: maxStepIndex }), + detail_level: detailLevel, + include_summary: includeSummary, } const content = await sessionsApi.export(session.id, options) if (content) { @@ -156,9 +162,9 @@ export function SessionDetailPage() { } } - const handleDownload = () => { - if (!exportContent || !session) return - const blob = new Blob([exportContent], { type: 'text/plain' }) + const handleDownload = (content: string) => { + if (!session) return + const blob = new Blob([content], { type: 'text/plain' }) const url = URL.createObjectURL(blob) const a = document.createElement('a') a.href = url @@ -169,6 +175,30 @@ export function SessionDetailPage() { URL.revokeObjectURL(url) } + const handleToggleSummary = async (include: boolean) => { + setIncludeSummary(include) + if (!session) return + const options: SessionExport = { + format: exportFormat, + include_timestamps: true, + include_tree_info: true, + ...(maxStepIndex !== null && { max_step_index: maxStepIndex }), + detail_level: detailLevel, + include_summary: include, + } + try { + const content = await sessionsApi.export(session.id, options) + if (content) { + setExportContent(content) + toast.success(include ? 'Summary added' : 'Summary removed') + } + } catch (err) { + console.error('Failed to re-fetch export:', err) + toast.error('Failed to update export') + setIncludeSummary(!include) + } + } + const handleSaveAsTree = async (data: SaveAsTreeRequest) => { if (!session) return setIsSavingTree(true) @@ -406,6 +436,18 @@ export function SessionDetailPage() { ))} )} +