fix: prevent title bar flickering with multiple split-pane agents (#701)

This commit is contained in:
Jinwoo Hong 2026-04-16 01:59:42 -04:00 committed by GitHub
parent c2d312888e
commit e17d917afe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 30 additions and 2 deletions

View file

@ -98,7 +98,14 @@ export function connectPanePty(
const onTitleChange = (title: string, rawTitle: string): void => {
manager.setPaneGpuRendering(pane.id, !isGeminiTerminalTitle(rawTitle))
deps.setRuntimePaneTitle(deps.tabId, pane.id, title)
deps.updateTabTitle(deps.tabId, title)
// Why: only the focused pane should drive the tab title — otherwise two
// agents in split panes cause rapid title flickering as each emits OSC
// sequences. Mirrors Ghostty's approach: only the active split's title
// propagates to the tab. When focus changes, onActivePaneChange syncs
// the newly active pane's stored title to the tab.
if (manager.getActivePane()?.id === pane.id) {
deps.updateTabTitle(deps.tabId, title)
}
if (!hasConsideredInitialCacheTimerSeed) {
hasConsideredInitialCacheTimerSeed = true

View file

@ -304,13 +304,34 @@ export function useTerminalPaneLifecycle({
// Dismiss the rename dialog if it was open for the closed pane,
// otherwise it would submit against a non-existent pane.
setRenamingPaneId((prev) => (prev === paneId ? null : prev))
// Why: PaneManager.closePane() reassigns activePaneId directly without
// calling setActivePane(), so onActivePaneChange does not fire. Sync the
// tab title to the survivor's stored title here so the tab label doesn't
// stay stuck on the closed pane's last title.
const newActivePane = managerRef.current?.getActivePane()
if (newActivePane) {
const paneTitles = useAppStore.getState().runtimePaneTitlesByTabId[tabId] ?? {}
const activeTitle = paneTitles[newActivePane.id]
if (activeTitle) {
updateTabTitle(tabId, activeTitle)
}
}
scheduleRuntimeGraphSync()
},
onActivePaneChange: () => {
onActivePaneChange: (pane) => {
scheduleRuntimeGraphSync()
if (shouldPersistLayout) {
persistLayoutSnapshot()
}
// Why: when the user switches focus between split panes, update the
// tab title to the newly active pane's last-known title so the tab
// label reflects the focused agent — not a stale title from the
// previously focused pane.
const paneTitles = useAppStore.getState().runtimePaneTitlesByTabId[tabId] ?? {}
const paneTitle = paneTitles[pane.id]
if (paneTitle) {
updateTabTitle(tabId, paneTitle)
}
},
onLayoutChanged: () => {
scheduleRuntimeGraphSync()