@@ -36,6 +36,21 @@ export function ViewerPane() { |
| 36 | 36 | return false; |
| 37 | 37 | }, [detail, inFlightTurns]); |
| 38 | 38 | |
| 39 | + // Build the claude argv for terminal mode. Must live above the |
| 40 | + // early returns below — React's rules of hooks require every |
| 41 | + // hook to run in the same order on every render, so an early |
| 42 | + // return followed by a later `useMemo` triggers the |
| 43 | + // "Rendered more hooks than during the previous render" crash. |
| 44 | + const claudeArgs = useMemo<string[]>(() => { |
| 45 | + if (!detail) return []; |
| 46 | + const { summary } = detail; |
| 47 | + if (summary.source === "archive") return []; |
| 48 | + if (summary.id.startsWith("pending-")) { |
| 49 | + return ["--session-id", summary.id.replace(/^pending-/, "")]; |
| 50 | + } |
| 51 | + return ["--resume", summary.id]; |
| 52 | + }, [detail]); |
| 53 | + |
| 39 | 54 | if (loading) { |
| 40 | 55 | return ( |
| 41 | 56 | <Shell subtitle={selectedSessionId ?? ""}> |
@@ -61,16 +76,6 @@ export function ViewerPane() { |
| 61 | 76 | const isArchive = summary.source === "archive"; |
| 62 | 77 | const mode = viewerMode.get(summary.id) ?? "cards"; |
| 63 | 78 | const hasLivePty = ptyIds.has(summary.id); |
| 64 | | - // Pending sessions strip their `pending-` prefix before being |
| 65 | | - // passed to `claude --session-id`. Disk sessions use their id |
| 66 | | - // directly with `--resume`. |
| 67 | | - const claudeArgs = useMemo<string[]>(() => { |
| 68 | | - if (isArchive) return []; |
| 69 | | - if (summary.id.startsWith("pending-")) { |
| 70 | | - return ["--session-id", summary.id.replace(/^pending-/, "")]; |
| 71 | | - } |
| 72 | | - return ["--resume", summary.id]; |
| 73 | | - }, [isArchive, summary.id]); |
| 74 | 79 | |
| 75 | 80 | return ( |
| 76 | 81 | <Shell |