(props: WorkspaceViewProps)
| 36 | } |
| 37 | |
| 38 | export function WorkspaceView(props: WorkspaceViewProps): ReactElement { |
| 39 | // Mount ONLY this tab's own pinned session. Each session is its own tab with |
| 40 | // its own WorkspaceView, and TabHost keeps every tab mounted (display:none |
| 41 | // when inactive) — so a session's terminal already persists across tab |
| 42 | // switches without a WS reconnect. Mounting *every* running session here (the |
| 43 | // old single-shared-view design) duplicates each session's <TerminalView> |
| 44 | // into every open tab: a session open in N tabs then gets N WebSockets |
| 45 | // fighting over its single-attach PTY → kick/reconnect war that wedges the |
| 46 | // session (ANG-120 — e.g. claude froze whenever an opencode tab was also open). |
| 47 | // |
| 48 | // activeRecord is null when sessionId is null (empty-state landing) or during |
| 49 | // the brief post-spawn race before the record lands in the list — both |
| 50 | // correctly render no slot (the CTA / paused-CTA path covers them). |
| 51 | const runningSlots = useMemo<readonly SessionRecord[]>( |
| 52 | () => |
| 53 | props.activeRecord !== null && props.activeRecord.state === 'running' |
| 54 | ? [props.activeRecord] |
| 55 | : [], |
| 56 | [props.activeRecord], |
| 57 | ); |
| 58 | |
| 59 | // Right-pane state machine: |
| 60 | // - no selection.sessionId → CTA ("start a new session") |
| 61 | // - sessionId but record missing or running-but-still-loading → CTA (the |
| 62 | // slot will appear once optimistic / poll lands) |
| 63 | // - sessionId + record.state === 'paused' → ResumeCta |
| 64 | // - sessionId + record.state === 'running' → active slot among slots |
| 65 | const showPausedCta = |
| 66 | props.sessionId !== null && |
| 67 | props.activeRecord !== null && |
| 68 | props.activeRecord.state === 'paused'; |
| 69 | const showEmptyCta = props.sessionId === null; |
| 70 | |
| 71 | // Files panel visibility. User-level pref; mobile gets a separate |
| 72 | // kill-switch so the 360px right column doesn't eat half a phone screen. |
| 73 | const isDesktop = useIsDesktop(); |
| 74 | const sidePrefs = useWorkspaceSidePanels(); |
| 75 | const mobileSuppresses = !isDesktop && sidePrefs.autoHideMobile; |
| 76 | const showFiles = sidePrefs.files && !mobileSuppresses; |
| 77 | const showAside = showFiles; |
| 78 | const viewClass = `workspace-view${showAside ? '' : ' has-no-side'}`; |
| 79 | |
| 80 | return ( |
| 81 | <div className={viewClass}> |
| 82 | <div className="workspace-terminal"> |
| 83 | {showEmptyCta && ( |
| 84 | <EmptyState |
| 85 | sessions={props.sessions} |
| 86 | onResume={props.onResume} |
| 87 | onSelectSession={props.onSelectSession} |
| 88 | onSpawn={props.onSpawnFresh} |
| 89 | /> |
| 90 | )} |
| 91 | {showPausedCta && props.activeRecord && ( |
| 92 | <ResumeCta |
| 93 | record={props.activeRecord} |
| 94 | onResume={() => props.onResume(props.activeRecord!.id)} |
| 95 | /> |
nothing calls this directly
no test coverage detected