refactor: move workspace tab navigation logic to prepareWorkspaceTab

This commit is contained in:
Mohamed Boudra
2026-03-21 15:21:02 +07:00
parent 78fc1fe862
commit 48c3308c31
17 changed files with 184 additions and 390 deletions
+7 -7
View File
@@ -12,11 +12,11 @@ import {
takeCommandCenterFocusRestoreElement,
} from "@/utils/command-center-focus-restore";
import {
buildHostWorkspaceAgentRoute,
buildHostSettingsRoute,
parseServerIdFromPathname,
} from "@/utils/host-routes";
import type { ShortcutKey } from "@/utils/format-shortcut";
import { prepareWorkspaceTab } from "@/utils/workspace-navigation";
import { focusWithRetries } from "@/utils/web-focus";
const EMPTY_AGENTS: AggregatedAgent[] = [];
@@ -199,12 +199,12 @@ export function useCommandCenter() {
// Don't restore focus back to the prior element after we navigate.
clearCommandCenterFocusRestoreElement();
setOpen(false);
const route: Href = buildHostWorkspaceAgentRoute(
agent.serverId,
agent.cwd,
agent.id
) as Href;
router.navigate(route);
const route = prepareWorkspaceTab({
serverId: agent.serverId,
workspaceId: agent.cwd,
target: { kind: "agent", agentId: agent.id },
});
router.navigate(route as any);
},
[setOpen]
);
+6 -6
View File
@@ -6,7 +6,7 @@ import {
normalizeWorkspaceDescriptor,
useSessionStore,
} from "@/stores/session-store";
import { buildHostWorkspaceRouteWithOpenIntent } from "@/utils/host-routes";
import { prepareWorkspaceTab } from "@/utils/workspace-navigation";
export function useOpenProject(
serverId: string | null
@@ -37,11 +37,11 @@ export function useOpenProject(
]);
setHasHydratedWorkspaces(normalizedServerId, true);
router.replace(
buildHostWorkspaceRouteWithOpenIntent(
normalizedServerId,
payload.workspace.id,
{ kind: "draft", draftId: "new" }
) as any
prepareWorkspaceTab({
serverId: normalizedServerId,
workspaceId: payload.workspace.id,
target: { kind: "draft", draftId: "new" },
}) as any
);
return true;
} catch (error) {