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(markdown): render the full terminal scrollback, not just the viewport

enesbb3d02955a9d
diff --git a/src/main/index.ts b/src/main/index.ts
index 27a25d4de..980647bc4 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -90,7 +90,9 @@ app.whenReady().then(() => {
generateTerminalName(ptyManager.captureSession(persistKey), cwd, settingsStore.get())
)
- ipcMain.handle(IPC.ptyCapture, (_e, persistKey: string) => ptyManager.captureSession(persistKey))
+ ipcMain.handle(IPC.ptyCapture, (_e, persistKey: string, full?: boolean) =>
+ ptyManager.captureSession(persistKey, full)
+ )
ipcMain.on(IPC.appCloseWindow, () => BrowserWindow.getFocusedWindow()?.close())
diff --git a/src/main/pty-manager.ts b/src/main/pty-manager.ts
index 821515df4..5cd34abf9 100644
--- a/src/main/pty-manager.ts
+++ b/src/main/pty-manager.ts
@@ -201,14 +201,17 @@ export class PtyManager {
this.sessions.delete(sessionId)
}
- /** Capture a session's recent visible output (for AI naming). Empty if no tmux session. */
- captureSession(persistKey: string): string {
+ /**
+ * Capture a session's output. `full` grabs the entire scrollback (`-S -`, for the
+ * markdown view); otherwise the recent ~200 lines (AI naming, palette search).
+ */
+ captureSession(persistKey: string, full = false): string {
if (!this.tmuxPath) return ''
try {
return execFileSync(
this.tmuxPath,
- ['-L', TMUX_SOCKET, 'capture-pane', '-p', '-t', sessionName(persistKey), '-S', '-200'],
- { encoding: 'utf-8', maxBuffer: 5 * 1024 * 1024 }
+ ['-L', TMUX_SOCKET, 'capture-pane', '-p', '-t', sessionName(persistKey), '-S', full ? '-' : '-200'],
+ { encoding: 'utf-8', maxBuffer: 50 * 1024 * 1024 }
)
} catch {
return ''
diff --git a/src/preload/index.ts b/src/preload/index.ts
index bb66585ad..833829f7f 100644
--- a/src/preload/index.ts
+++ b/src/preload/index.ts
@@ -15,7 +15,7 @@ const api: NodeTerminalApi = {
kill: (sessionId) => ipcRenderer.send(IPC.ptyKill, sessionId),
destroy: (persistKey) => ipcRenderer.send(IPC.ptyDestroy, persistKey),
generateName: (persistKey, cwd) => ipcRenderer.invoke(IPC.ptyGenerateName, persistKey, cwd),
- capture: (persistKey) => ipcRenderer.invoke(IPC.ptyCapture, persistKey),
+ capture: (persistKey, full) => ipcRenderer.invoke(IPC.ptyCapture, persistKey, full),
sendText: (persistKey, text) => ipcRenderer.invoke(IPC.ptySendText, persistKey, text),
onData: (sessionId, listener) => {
const channel = IPC.ptyData(sessionId)
diff --git a/src/renderer/nodes/TerminalNode.tsx b/src/renderer/nodes/TerminalNode.tsx
index 853d75ddb..c9b05b597 100644
--- a/src/renderer/nodes/TerminalNode.tsx
+++ b/src/renderer/nodes/TerminalNode.tsx
@@ -211,7 +211,8 @@ export function TerminalNode({ id, data, selected }: NodeProps<CanvasNode>) {
// When markdown mode turns on, capture the terminal output and render it.
useEffect(() => {
if (data.mdMode) {
- void window.nodeTerminal.pty.capture(id).then((t) => setMdHtml(renderMarkdown(t)))
+ // Full scrollback (not just the visible viewport) so the whole session renders.
+ void window.nodeTerminal.pty.capture(id, true).then((t) => setMdHtml(renderMarkdown(t)))
}
}, [data.mdMode, id])
diff --git a/src/shared/types.ts b/src/shared/types.ts
index 4e142119e..5a4ea14d6 100644
--- a/src/shared/types.ts
+++ b/src/shared/types.ts
@@ -97,8 +97,8 @@ export interface PtyApi {
destroy(persistKey: string): void
/** Suggest a terminal title from its recent output via the configured AI agent. */
generateName(persistKey: string, cwd: string): Promise<GitResult>
- /** Capture a terminal session's recent visible output as text. */
- capture(persistKey: string): Promise<string>
+ /** Capture a terminal session's output as text. `full` grabs the entire scrollback. */
+ capture(persistKey: string, full?: boolean): Promise<string>
/** Send literal text + Enter into a session (e.g. a slash command). Returns false if unavailable. */
sendText(persistKey: string, text: string): Promise<boolean>
/** Listens for PTY output. Returns an unsubscribe function. */