Implementation:23blocks OS Ai maestro Use Transcript Export Hook
| Knowledge Sources | |
|---|---|
| Domains | UI, Export |
| Last Updated | 2026-10-26 18:00 GMT |
Overview
Concrete tool for creating and polling transcript export jobs, with progress tracking, cancellation, and automatic cleanup, provided by AI Maestro's `hooks/useTranscriptExport.ts`.
Description
The useTranscriptExport hook manages transcript export jobs. `exportTranscript` creates a job via `POST /api/agents/<id>/export`, then polls `GET /api/agents/<id>/export/jobs/<jobId>` every 1 second for progress, up to 5 minutes (`EXPORT_MAX_POLL_DURATION_MS`). It tracks jobs, loading, and error states. `cancelExport` cancels an active job and clears its poll timer. `loadJobs` loads existing jobs. An `isMountedRef` guard prevents state writes after unmount. Poll timers are tracked in a ref record and cleaned up on unmount.
Usage
Call with `agentId`. Use `exportTranscript(format, options)` to start; read `jobs`, `loading`, `error`; call `cancelExport(jobId)` to abort.
Code Reference
Source Location
- Repository: ai-maestro
- File: hooks/useTranscriptExport.ts
- Lines: L1-L283
Signature
export function useTranscriptExport(agentId: string): {
jobs: ExportJob[]
loading: boolean
error: Error | null
exportTranscript: (format: ExportType, options?: Partial<ExportOptions>) => Promise<void>
cancelExport: (jobId: string) => void
}
Import
import { useTranscriptExport } from '@/hooks/useTranscriptExport'
I/O Contract
| Name | Type | Description |
|---|---|---|
| jobs | ExportJob[] | Active/complete export jobs |
| exportTranscript | (format, options?) => Promise<void> | Start an export |
| cancelExport | (jobId: string) => void | Cancel and clear poll timer |
Usage Examples
import { useTranscriptExport } from '@/hooks/useTranscriptExport'
function ExportButton({ agentId }) {
const { exportTranscript, jobs, loading } = useTranscriptExport(agentId)
return (
<>
<button onClick={() => exportTranscript('markdown')} disabled={loading}>
Export Markdown
</button>
{jobs.map(j => <div key={j.id}>{j.status}: {j.progress}%</div>)}
</>
)
}