Wire terminal worktree navigation to back-and-forth stack (#6310)
* Wire terminal-initiated worktree navigation to back-and-forth stack * Unify terminal-driven worktree activation and Cmd+J recency marking. * Record worktree visits in the back/forward history stack unless navigating history. * fix: focus terminal-initiated worktree tabs
This commit is contained in:
parent
19b0174dca
commit
c3241bdb91
|
|
@ -1816,6 +1816,8 @@ describe('useIpcEvents updater integration', () => {
|
|||
expect(setActiveTabType).toHaveBeenCalledWith('terminal')
|
||||
expect(setActiveTab).toHaveBeenCalledWith('tab-new')
|
||||
expect(revealWorktreeInSidebar).toHaveBeenCalledWith('wt-2')
|
||||
expect(focusRuntimeTerminalSurface).toHaveBeenCalledWith('tab-new', undefined)
|
||||
expect(focusTerminalTabSurface).toHaveBeenCalledWith('tab-new', undefined)
|
||||
expect(setTabCustomTitle).toHaveBeenCalledWith('tab-new', 'Runner', {
|
||||
recordInteraction: false
|
||||
})
|
||||
|
|
@ -1836,6 +1838,8 @@ describe('useIpcEvents updater integration', () => {
|
|||
setTabCustomTitle.mockClear()
|
||||
queueTabStartupCommand.mockClear()
|
||||
replyTerminalCreate.mockClear()
|
||||
focusRuntimeTerminalSurface.mockClear()
|
||||
focusTerminalTabSurface.mockClear()
|
||||
requestTerminalCreateListenerRef.current({
|
||||
requestId: 'req-focused',
|
||||
worktreeId: 'wt-3',
|
||||
|
|
@ -1850,6 +1854,8 @@ describe('useIpcEvents updater integration', () => {
|
|||
expect(setActiveTabType).toHaveBeenCalledWith('terminal')
|
||||
expect(setActiveTab).toHaveBeenCalledWith('tab-new')
|
||||
expect(revealWorktreeInSidebar).toHaveBeenCalledWith('wt-3')
|
||||
expect(focusRuntimeTerminalSurface).toHaveBeenCalledWith('tab-new', undefined)
|
||||
expect(focusTerminalTabSurface).toHaveBeenCalledWith('tab-new', undefined)
|
||||
expect(setTabCustomTitle).toHaveBeenCalledWith('tab-new', 'Shell', {
|
||||
recordInteraction: false
|
||||
})
|
||||
|
|
@ -1869,6 +1875,8 @@ describe('useIpcEvents updater integration', () => {
|
|||
revealWorktreeInSidebar.mockClear()
|
||||
setTabCustomTitle.mockClear()
|
||||
queueTabStartupCommand.mockClear()
|
||||
focusRuntimeTerminalSurface.mockClear()
|
||||
focusTerminalTabSurface.mockClear()
|
||||
requestTerminalCreateListenerRef.current({
|
||||
requestId: 'req-renderer-backed',
|
||||
worktreeId: 'wt-2',
|
||||
|
|
@ -1894,6 +1902,8 @@ describe('useIpcEvents updater integration', () => {
|
|||
expect(setActiveTabType).not.toHaveBeenCalled()
|
||||
expect(setActiveTab).not.toHaveBeenCalled()
|
||||
expect(revealWorktreeInSidebar).not.toHaveBeenCalled()
|
||||
expect(focusRuntimeTerminalSurface).not.toHaveBeenCalled()
|
||||
expect(focusTerminalTabSurface).not.toHaveBeenCalled()
|
||||
expect(dispatchEvent).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
type: 'orca-background-mount-terminal-worktree',
|
||||
|
|
|
|||
|
|
@ -263,6 +263,12 @@ function activateTerminalInitiatedWorktree(store: AppState, worktreeId: string):
|
|||
}
|
||||
}
|
||||
|
||||
function focusTerminalInitiatedTab(tabId: string, leafId?: string | null): void {
|
||||
if (!focusRuntimeTerminalSurface(tabId, leafId)) {
|
||||
focusTerminalTabSurface(tabId, leafId)
|
||||
}
|
||||
}
|
||||
|
||||
type TerminalSplitDirection = 'horizontal' | 'vertical'
|
||||
|
||||
function insertLeafAfterSource(
|
||||
|
|
@ -1393,6 +1399,7 @@ export function useIpcEvents(): void {
|
|||
store.setActiveTabType('terminal')
|
||||
store.setActiveTab(tab.id)
|
||||
store.revealWorktreeInSidebar(worktreeId)
|
||||
focusTerminalInitiatedTab(tab.id, leafId)
|
||||
}
|
||||
// Why: only stamp the runtime-supplied title on freshly created tabs.
|
||||
// Existing tabs may have a user customTitle (set via UI rename) that
|
||||
|
|
@ -1571,6 +1578,7 @@ export function useIpcEvents(): void {
|
|||
store.setActiveTabType('terminal')
|
||||
store.setActiveTab(tab.id)
|
||||
store.revealWorktreeInSidebar(worktreeId)
|
||||
focusTerminalInitiatedTab(tab.id)
|
||||
}
|
||||
if (data.title) {
|
||||
store.setTabCustomTitle(tab.id, data.title, { recordInteraction: false })
|
||||
|
|
@ -1646,9 +1654,7 @@ export function useIpcEvents(): void {
|
|||
})
|
||||
return
|
||||
}
|
||||
if (!focusRuntimeTerminalSurface(tabId, leafId)) {
|
||||
focusTerminalTabSurface(tabId, leafId)
|
||||
}
|
||||
focusTerminalInitiatedTab(tabId, leafId)
|
||||
}
|
||||
)
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue