From 842ec2220f1baea75a9114a89cfddffdace0ee35 Mon Sep 17 00:00:00 2001 From: Kiet Ho Date: Mon, 1 Dec 2025 15:05:20 -0800 Subject: [PATCH] Fix setup script appearing 3 times when starting a worktree MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Race condition caused scrollback and pending events to both contain the same terminal output, resulting in duplicate display when attaching to an existing terminal session. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../ContentView/TabsContent/Terminal/Terminal.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/Terminal.tsx b/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/Terminal.tsx index 46efd0dbb40..7568a42dff5 100644 --- a/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/Terminal.tsx +++ b/apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/Terminal.tsx @@ -161,7 +161,11 @@ export const Terminal = ({ tabId, workspaceId }: TerminalProps) => { }, { onSuccess: (result) => { - applyInitialScrollback(result); + // Avoid duplication when pending events already contain scrollback data + const hasPendingEvents = pendingEventsRef.current.length > 0; + if (result.isNew || !hasPendingEvents) { + applyInitialScrollback(result); + } setSubscriptionEnabled(true); flushPendingEvents(); },