Skip to content

Commit 9dbfd1d

Browse files
committed
Fix dashboard single-character output by reading xterm buffer
1 parent a6ac882 commit 9dbfd1d

File tree

3 files changed

+35
-17
lines changed

3 files changed

+35
-17
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vbcdr",
3-
"version": "1.1.13",
3+
"version": "1.1.14",
44
"description": "Desktop vibe coding environment for Claude Code developers",
55
"author": {
66
"name": "jo vinkenroye",

src/renderer/components/terminal/TerminalInstance.tsx

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ interface TerminalEntry {
2525
}
2626

2727
const terminalsMap = new Map<string, TerminalEntry>()
28-
const lineAccumulators = new Map<string, string>()
28+
const bufferReadTimers = new Map<string, ReturnType<typeof setTimeout>>()
2929

3030
export function applyThemeToAll(themeId: string): void {
3131
const xtermTheme = getTerminalTheme(themeId)
@@ -63,6 +63,9 @@ export function TerminalInstance({ tabId, projectId, cwd, initialCommand }: Term
6363

6464
if (entry && !document.body.contains(entry.terminal.element)) {
6565
entry.unsubData?.()
66+
const staleTimer = bufferReadTimers.get(tabId)
67+
if (staleTimer) clearTimeout(staleTimer)
68+
bufferReadTimers.delete(tabId)
6669
try { entry.terminal.dispose() } catch { /* WebGL addon may throw */ }
6770
terminalsMap.delete(tabId)
6871
entry = undefined
@@ -152,14 +155,25 @@ export function TerminalInstance({ tabId, projectId, cwd, initialCommand }: Term
152155
useTerminalStore.getState().setTabStatus(tabId, 'idle')
153156
}, 3000)
154157

155-
const cleaned = stripAnsi(data)
156-
const pending = (lineAccumulators.get(projectId) ?? '') + cleaned
157-
const parts = pending.split('\n')
158-
lineAccumulators.set(projectId, parts.pop()!)
159-
const lines = parts.filter((l) => l.trim().length > 0)
160-
if (lines.length > 0) {
161-
store.appendOutput(projectId, lines)
162-
}
158+
const prevTimer = bufferReadTimers.get(tabId)
159+
if (prevTimer) clearTimeout(prevTimer)
160+
bufferReadTimers.set(tabId, setTimeout(() => {
161+
bufferReadTimers.delete(tabId)
162+
const te = terminalsMap.get(tabId)
163+
if (!te) return
164+
const buf = te.terminal.buffer.active
165+
const extracted: string[] = []
166+
for (let y = 0; y < te.terminal.rows; y++) {
167+
const row = buf.getLine(buf.baseY + y)
168+
if (row) {
169+
const text = row.translateToString(true)
170+
if (text.trim()) extracted.push(text)
171+
}
172+
}
173+
if (extracted.length > 0) {
174+
useTerminalStore.getState().setOutput(projectId, extracted)
175+
}
176+
}, 200))
163177
}
164178
}
165179
})
@@ -333,6 +347,9 @@ export function disposeTerminal(tabId: string): void {
333347
const entry = terminalsMap.get(tabId)
334348
if (entry) {
335349
entry.unsubData?.()
350+
const timer = bufferReadTimers.get(tabId)
351+
if (timer) clearTimeout(timer)
352+
bufferReadTimers.delete(tabId)
336353
try { entry.terminal.dispose() } catch { /* WebGL addon may throw during dispose */ }
337354
terminalsMap.delete(tabId)
338355
}

src/renderer/stores/terminal-store.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ interface TerminalStore {
1717
setActiveTab: (projectId: string, tabId: string) => void
1818
setTabStatus: (tabId: string, status: TabStatus) => void
1919
setTabTitle: (tabId: string, title: string) => void
20-
appendOutput: (projectId: string, lines: string[]) => void
20+
setOutput: (projectId: string, lines: string[]) => void
2121
initProject: (projectId: string, cwd: string) => void
2222
}
2323

@@ -96,12 +96,13 @@ export const useTerminalStore = create<TerminalStore>((set, get) => ({
9696
}))
9797
},
9898

99-
appendOutput: (projectId: string, lines: string[]) => {
100-
set((state) => {
101-
const existing = state.outputBufferPerProject[projectId] ?? []
102-
const merged = [...existing, ...lines].slice(-OUTPUT_BUFFER_SIZE)
103-
return { outputBufferPerProject: { ...state.outputBufferPerProject, [projectId]: merged } }
104-
})
99+
setOutput: (projectId: string, lines: string[]) => {
100+
set((state) => ({
101+
outputBufferPerProject: {
102+
...state.outputBufferPerProject,
103+
[projectId]: lines.slice(-OUTPUT_BUFFER_SIZE)
104+
}
105+
}))
105106
},
106107

107108
initProject: (projectId: string, cwd: string) => {

0 commit comments

Comments
 (0)