Files
paseo/packages/app/src/plugins/host-navigation.ts
T
Mohamed Boudra c7db3c5a8c Let plugins open external links and workspace browsers (#4972)
* feat(plugins): open external links and workspace browsers

* fix(plugins): refuse invalid links and unavailable browser workspaces

* docs(plugins): clarify external links and browser navigation
2026-09-16 23:25:17 +02:00

31 lines
1.2 KiB
TypeScript

import type { PluginSurfaceProps } from "@getpaseo/plugin/client";
import { useSessionStore } from "@/stores/session-store";
import { resolveWorkspaceMapKeyByIdentity } from "@/utils/workspace-identity";
import { useMemo } from "react";
import { navigateToWorkspace } from "@/stores/navigation-active-workspace-store";
import { navigateToAgent } from "@/utils/navigate-to-agent";
import { getIsElectron } from "@/constants/platform";
import { createWorkspaceBrowser } from "@/desktop/browser/store";
import { createPluginHostNavigation } from "./host-navigation-model";
export function usePluginHostNavigation(
serverId: string,
): NonNullable<PluginSurfaceProps["navigation"]> {
return useMemo(
() =>
createPluginHostNavigation(serverId, {
browserAvailable: getIsElectron(),
openAgent: navigateToAgent,
openWorkspace: navigateToWorkspace,
createBrowser: createWorkspaceBrowser,
resolveWorkspace: ({ serverId: targetServerId, workspaceId }) =>
resolveWorkspaceMapKeyByIdentity({
workspaces: useSessionStore.getState().sessions[targetServerId]?.workspaces,
workspaceId,
}),
}),
[serverId],
);
}