fix(app): land on agent tab after creating a workspace
Workspace creation landed on the setup tab because openTab implicitly focused the tab it opened, and the setup auto-open effect ran after the setup dialog's navigation, stomping on the agent tab's focus. Split the store API into explicit openTabFocused and openTabInBackground so every caller declares intent. The setup auto-open effect now opens in background and no longer steals focus; user-intent call sites (sidebar, kebab menus, file explorer, terminal creation, prepareWorkspaceTab) use openTabFocused and drop the redundant paired focusTab call.
This commit is contained in:
@@ -1019,6 +1019,7 @@ function insertNewTabIntoFocusedPane(input: {
|
||||
layout: WorkspaceLayout;
|
||||
target: WorkspaceTabTarget;
|
||||
now: number;
|
||||
focus: boolean;
|
||||
}): OpenTabInLayoutResult {
|
||||
const layout = asInternalLayout(input.layout);
|
||||
const focusedPane =
|
||||
@@ -1034,20 +1035,22 @@ function insertNewTabIntoFocusedPane(input: {
|
||||
createdAt: input.now,
|
||||
};
|
||||
|
||||
const preservedFocusTabId = focusedPane.focusedTabId ?? tabId;
|
||||
|
||||
return {
|
||||
tabId,
|
||||
layout: {
|
||||
root: insertTabIntoPane(layout.root, {
|
||||
paneId: focusedPane.id,
|
||||
tab: nextTab,
|
||||
focusTabId: tabId,
|
||||
focusTabId: input.focus ? tabId : preservedFocusTabId,
|
||||
}),
|
||||
focusedPaneId: focusedPane.id,
|
||||
focusedPaneId: input.focus ? focusedPane.id : layout.focusedPaneId,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function openTabInLayout(input: OpenTabInLayoutInput): OpenTabInLayoutResult {
|
||||
export function openTabInLayoutFocused(input: OpenTabInLayoutInput): OpenTabInLayoutResult {
|
||||
const layout = asInternalLayout(input.layout);
|
||||
const existingTab = collectAllTabs(layout.root).find((tab) =>
|
||||
workspaceTabTargetsEqual(tab.target, input.target),
|
||||
@@ -1063,7 +1066,19 @@ export function openTabInLayout(input: OpenTabInLayoutInput): OpenTabInLayoutRes
|
||||
};
|
||||
}
|
||||
|
||||
return insertNewTabIntoFocusedPane(input);
|
||||
return insertNewTabIntoFocusedPane({ ...input, focus: true });
|
||||
}
|
||||
|
||||
export function openTabInLayoutBackground(input: OpenTabInLayoutInput): OpenTabInLayoutResult {
|
||||
const layout = asInternalLayout(input.layout);
|
||||
const existingTab = collectAllTabs(layout.root).find((tab) =>
|
||||
workspaceTabTargetsEqual(tab.target, input.target),
|
||||
);
|
||||
if (existingTab) {
|
||||
return { tabId: existingTab.tabId, layout: input.layout };
|
||||
}
|
||||
|
||||
return insertNewTabIntoFocusedPane({ ...input, focus: false });
|
||||
}
|
||||
|
||||
export function closeTabInLayout(input: CloseTabInLayoutInput): WorkspaceLayout | null {
|
||||
|
||||
Reference in New Issue
Block a user