Fix workspace navigation regression on web (#772)

Centralize workspace navigation behind a small route-derived API so the workspace shell reads active selection from the current Expo Router route instead of a separately synchronized store.

Remove the stale layout-driven active-workspace write that regressed web after 02e5b564.
This commit is contained in:
Mohamed Boudra
2026-05-06 13:22:31 +08:00
committed by GitHub
parent 0eacc98e17
commit 868479c493
26 changed files with 221 additions and 956 deletions
+3 -31
View File
@@ -1,11 +1,4 @@
import { router } from "expo-router";
import { isNative } from "@/constants/platform";
import { navigateToWorkspace } from "@/hooks/use-workspace-navigation";
import {
activateNavigationWorkspaceSelection,
getLastNavigationWorkspaceRouteSelection,
overrideNextNavigationWorkspaceRouteSelection,
} from "@/stores/navigation-active-workspace-store";
import { useWorkspaceLayoutStore } from "@/stores/workspace-layout-store";
import { generateDraftId } from "@/stores/draft-keys";
import {
@@ -22,7 +15,6 @@ interface PrepareWorkspaceTabInput {
}
interface NavigateToPreparedWorkspaceTabInput extends PrepareWorkspaceTabInput {
navigationMethod?: "navigate" | "replace";
currentPathname?: string | null;
}
@@ -52,28 +44,8 @@ export function prepareWorkspaceTab(input: PrepareWorkspaceTabInput) {
export function navigateToPreparedWorkspaceTab(input: NavigateToPreparedWorkspaceTabInput): string {
const route = prepareWorkspaceTab(input);
if (input.navigationMethod === "replace") {
const canReturnToWorkspaceShell =
isNative && getLastNavigationWorkspaceRouteSelection() !== null && router.canGoBack();
if (canReturnToWorkspaceShell) {
const nextSelection = {
serverId: input.serverId,
workspaceId: input.workspaceId,
};
overrideNextNavigationWorkspaceRouteSelection(nextSelection);
router.back();
setTimeout(() => {
activateNavigationWorkspaceSelection(nextSelection);
}, 0);
return route;
}
navigateToWorkspace(input.serverId, input.workspaceId, {
currentPathname: input.currentPathname,
});
} else {
navigateToWorkspace(input.serverId, input.workspaceId, {
currentPathname: input.currentPathname,
});
}
navigateToWorkspace(input.serverId, input.workspaceId, {
currentPathname: input.currentPathname,
});
return route;
}