Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

fix(settings): mount the debug log panel, which never rendered

review19fe41b99eea
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsx
index 869247831..8d5e09611 100644
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@ -197,6 +197,7 @@ import {
BugReportDialog,
PhonePairPopover,
MobileLaunchCard,
+ LogPanel,
KanbanView
} from '../components/lazyPanels'
import { WelcomeScreen } from '../components/WelcomeScreen'
@@ -19901,6 +19902,7 @@ export function Canvas() {
}}
/>
)}
+ {logPanelOpen && <LogPanel onClose={() => setLogPanelOpen(false)} />}
{mobileLaunchOpen && (
<MobileLaunchCard
onClose={() => {
diff --git a/src/renderer/components/LogPanel.dom.test.tsx b/src/renderer/components/LogPanel.dom.test.tsx
new file mode 100644
index 000000000..199d61060
--- /dev/null
+++ b/src/renderer/components/LogPanel.dom.test.tsx
@@ -0,0 +1,104 @@
+// @vitest-environment jsdom
+import { act } from 'react'
+import { createRoot, type Root } from 'react-dom/client'
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+import type { LogApi, LogRecord } from '@shared/types'
+import { LogPanel } from './LogPanel'
+
+;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true
+
+const record = (seq: number, msg: string, level: LogRecord['level'] = 'info', tag = 'pty'): LogRecord => ({
+ seq,
+ ts: Date.UTC(2026, 9, 18, 12, 0, seq),
+ level,
+ tag,
+ msg
+})
+
+let host: HTMLDivElement
+let root: Root
+let push: ((batch: LogRecord[]) => void) | null
+let unsubscribed: number
+let logs: LogApi
+
+beforeEach(() => {
+ push = null
+ unsubscribed = 0
+ logs = {
+ snapshot: vi.fn(async () => [record(1, 'booted'), record(2, 'socket refused', 'warn', 'relay')]),
+ clear: vi.fn(),
+ onBatch: (cb) => {
+ push = cb
+ return () => {
+ unsubscribed++
+ }
+ }
+ }
+ ;(window as unknown as { nodeTerminal: { logs: LogApi } }).nodeTerminal = { logs }
+ host = document.createElement('div')
+ document.body.appendChild(host)
+ root = createRoot(host)
+})
+
+afterEach(() => {
+ act(() => root.unmount())
+ host.remove()
+})
+
+const rows = (): string[] =>
+ [...document.querySelectorAll('.logpanel__msg')].map((el) => el.textContent ?? '')
+
+async function mount(onClose = vi.fn()): Promise<typeof onClose> {
+ await act(async () => {
+ root.render(<LogPanel onClose={onClose} />)
+ })
+ return onClose
+}
+
+describe('LogPanel', () => {
+ it('fills from the snapshot, then appends pushed batches without duplicating the overlap', async () => {
+ await mount()
+ expect(rows()).toEqual(['booted', 'socket refused'])
+
+ await act(async () => {
+ push?.([record(2, 'socket refused', 'warn', 'relay'), record(3, 'reattached')])
+ })
+ expect(rows()).toEqual(['booted', 'socket refused', 'reattached'])
+ })
+
+ it('filters by level and by text', async () => {
+ await mount()
+ const chip = [...document.querySelectorAll('.logpanel__chip')].find((el) => el.textContent === 'info')
+ await act(async () => {
+ ;(chip as HTMLButtonElement).click()
+ })
+ expect(rows()).toEqual(['socket refused'])
+ })
+
+ it('Escape and the close button both close it, and unmount unsubscribes', async () => {
+ const onClose = await mount()
+ act(() => {
+ window.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape' }))
+ })
+ expect(onClose).toHaveBeenCalledTimes(1)
+ act(() => {
+ ;(document.querySelector('.drawer__close') as HTMLButtonElement).click()
+ })
+ expect(onClose).toHaveBeenCalledTimes(2)
+
+ act(() => root.unmount())
+ expect(unsubscribed).toBe(1)
+ root = createRoot(host) // afterEach unmounts again
+ })
+
+ it('Clear empties the ring and the view', async () => {
+ await mount()
+ const clear = [...document.querySelectorAll('.logpanel__act')].find((el) => el.textContent === 'Clear')
+ await act(async () => {
+ ;(clear as HTMLButtonElement).click()
+ })
+ expect(logs.clear).toHaveBeenCalledTimes(1)
+ expect(rows()).toEqual([])
+ expect(document.querySelector('.logpanel__empty')?.textContent).toContain('Nothing captured yet')
+ })
+})
diff --git a/src/renderer/components/lazyPanels.mounted.test.ts b/src/renderer/components/lazyPanels.mounted.test.ts
new file mode 100644
index 000000000..273657632
--- /dev/null
+++ b/src/renderer/components/lazyPanels.mounted.test.ts
@@ -0,0 +1,50 @@
+/**
+ * A code-split panel that nothing mounts.
+ *
+ * The debug log panel (issue #78) shipped with its state, its Settings "Open" button, its palette
+ * command and its `lazyPanels` export, and with no `<LogPanel …/>` anywhere. Every path that
+ * opened it set `logPanelOpen` to true and rendered nothing. The settings dialog closed, so the
+ * click looked like it did something. It stayed that way for two months, because an unmounted
+ * component compiles, typechecks and passes its own tests. The only signal was
+ * `tsc --noUnusedLocals` reporting `logPanelOpen` as never read (found while answering #1252).
+ *
+ * So the guard is the pairing: every panel `lazyPanels.tsx` exports must appear as JSX somewhere
+ * in the renderer. A panel that is genuinely retired should leave `lazyPanels.tsx` too.
+ *
+ * MUTATION: delete the `<LogPanel …/>` line in Canvas.tsx → red, naming LogPanel.
+ */
+import { describe, expect, it } from 'vitest'
+import fs from 'fs'
+import path from 'path'
+
+const RENDERER = path.join(__dirname, '..')
+const LAZY = path.join(__dirname, 'lazyPanels.tsx')
+
+function walk(dir: string, out: string[] = []): string[] {
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
+ const full = path.join(dir, entry.name)
+ if (entry.isDirectory()) walk(full, out)
+ else if (/\.tsx$/.test(entry.name) && !/\.test\.tsx$/.test(entry.name)) out.push(full)
+ }
+ return out
+}
+
+describe('lazyPanels: every code-split panel is mounted somewhere', () => {
+ const exported = [...fs.readFileSync(LAZY, 'utf8').matchAll(/^export const (\w+) = withSuspense\(/gm)].map(
+ (m) => m[1]
+ )
+ const sources = walk(RENDERER)
+ .filter((file) => file !== LAZY)
+ .map((file) => fs.readFileSync(file, 'utf8'))
+
+ it('finds the exports it is guarding', () => {
+ // An empty list would make the check below pass vacuously.
+ expect(exported.length).toBeGreaterThan(5)
+ expect(exported).toContain('LogPanel')
+ })
+
+ it.each(exported)('%s is rendered as JSX', (name) => {
+ const jsx = new RegExp(`<${name}[\\s/>]`)
+ expect(sources.some((src) => jsx.test(src)), `<${name}> is exported by lazyPanels but never mounted`).toBe(true)
+ })
+})