fix(terminal): skip chat-panel terminals in workspace cd sync#263
Open
Raymond8196 wants to merge 1 commit into
Open
fix(terminal): skip chat-panel terminals in workspace cd sync#263Raymond8196 wants to merge 1 commit into
Raymond8196 wants to merge 1 commit into
Conversation
useTerminalRepoSync broadcasts `cd '<path>'` to every initialized terminal when the active workspace changes. Its guard only skipped readOnly and agent-pty- sessions, so chatpanel- terminals — which host interactive CLI agent TUIs (codex/claude/gemini) — received the cd and got their TUI corrupted (e.g. codex showed `cd '/path'` as user input). Extract the guard into a pure selectRepoSyncTargets() and add unit tests covering each excluded class (readOnly / agent-pty- / chatpanel- / uninitialized) plus a mixed case, so the regression is caught without a React renderer. Pre-commit hook ran. Total eslint: 0, total circular: 0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Switching sessions from the sidebar while a CLI agent TUI (codex/claude/gemini) was open in a chat-panel terminal injected
cd '<path>'into the running TUI, corrupting it (e.g. codex echoedcd '/path'back as user input). The session switch itself succeeded, but the TUI was visually broken.Root cause
useTerminalRepoSyncbroadcastscd '<repoPath>'to every initialized terminal when the active workspace changes. Its guard only skippedreadOnlyandagent-pty-sessions, sochatpanel-terminals — which host interactive CLI agent TUIs — received thecdand got their TUI corrupted.The session-list click →
jumpToSessionAtom→followSessionRepoupdatesactiveWorkspaceRootPathAtom, which fired the broadcast into the chat-panel terminal running the codex TUI.This is the only "iterate the terminal pool + inject a command" call site in the codebase; all other
write_ptywriters target a single active terminal and are unaffected.Fix
selectRepoSyncTargets()so it is unit-testable without a React renderer (the host project ships neither@testing-library/reactnor jsdom).isChatPanelTerminalIdto the exclusion list.readOnly/agent-pty-/chatpanel-/ uninitialized) plus a mixed case to lock the guard boundary.Test plan
npx vitest run src/hooks/terminal/__tests__/repoSyncTargets.test.ts— 6/6 passcdinjected.