fix(app): open new tabs in the focused pane

Preserve ambient placement for reconciliation and background opens while routing user-directed tab creation through the focused visible pane. Defer terminal reconciliation during creates so a push cannot preempt the intended pane placement.
This commit is contained in:
Mohamed Boudra
2026-08-19 15:52:51 +02:00
parent 133c38c5c3
commit ce905d9483
12 changed files with 267 additions and 51 deletions
+7 -5
View File
@@ -1019,7 +1019,9 @@ function useDiffTabNavigation({
cwd: string;
isMobile: boolean;
}) {
const openWorkspaceTabFocused = useWorkspaceLayoutStore((state) => state.openTabFocused);
const openWorkspaceTabInFocusedPane = useWorkspaceLayoutStore(
(state) => state.openTabInFocusedPane,
);
const closeWorkspaceTab = useWorkspaceLayoutStore((state) => state.closeTab);
const persistenceKey = useMemo(
() => buildWorkspaceTabPersistenceKey({ serverId, workspaceId: workspaceId ?? cwd }),
@@ -1040,12 +1042,12 @@ function useDiffTabNavigation({
if (!persistenceKey || isMobile) {
return;
}
openWorkspaceTabFocused(persistenceKey, {
openWorkspaceTabInFocusedPane(persistenceKey, {
kind: "working_diff",
...(path ? { focusPath: path, focusRequestId: Date.now() } : {}),
});
},
[isMobile, openWorkspaceTabFocused, persistenceKey],
[isMobile, openWorkspaceTabInFocusedPane, persistenceKey],
);
const toggleChanges = useCallback(() => {
if (!persistenceKey || isMobile) {
@@ -1060,10 +1062,10 @@ function useDiffTabNavigation({
const openCommit = useCallback(
(sha: string) => {
if (persistenceKey) {
openWorkspaceTabFocused(persistenceKey, { kind: "commit_diff", sha });
openWorkspaceTabInFocusedPane(persistenceKey, { kind: "commit_diff", sha });
}
},
[openWorkspaceTabFocused, persistenceKey],
[openWorkspaceTabInFocusedPane, persistenceKey],
);
return {
changesTabOpen,