mirror of
https://github.com/getpaseo/paseo.git
synced 2026-07-29 12:01:31 +00:00
Hide browser shortcuts outside the desktop app (#2116)
* fix: hide browser pin on non-Electron web Browser is desktop-only, but the pinned shortcut bar still rendered a New browser pin on web where createBrowser is a silent no-op. Skip browser pins in usePinnedLaunchers when not Electron, and drop browser from default pinned targets so new users only get terminal. * fix(app): preserve browser pin defaults on desktop Keep platform availability in the pinned-target policy so regular web hides browser shortcuts without changing Electron defaults. --------- Co-authored-by: Mohamed Boudra <boudra.moha@gmail.com>
This commit is contained in:
@@ -7,9 +7,14 @@ import {
|
||||
resolveTerminalProfiles,
|
||||
} from "@getpaseo/protocol/terminal-profiles";
|
||||
import { getProviderIcon } from "@/components/provider-icons";
|
||||
import { getIsElectron } from "@/constants/platform";
|
||||
import { useDaemonConfig } from "@/hooks/use-daemon-config";
|
||||
import type { Theme } from "@/styles/theme";
|
||||
import { pinnedTargetKey, type PinnedTabTarget } from "@/workspace-pins/target";
|
||||
import {
|
||||
isPinnedTargetAvailable,
|
||||
pinnedTargetKey,
|
||||
type PinnedTabTarget,
|
||||
} from "@/workspace-pins/target";
|
||||
import { usePinnedTargetsStore } from "@/workspace-pins/store";
|
||||
|
||||
export interface ResolvedPin {
|
||||
@@ -64,6 +69,9 @@ export function usePinnedLaunchers({ serverId, onLaunch }: UsePinnedLaunchersInp
|
||||
return useMemo(() => {
|
||||
const resolved: ResolvedPin[] = [];
|
||||
for (const target of pinned) {
|
||||
if (!isPinnedTargetAvailable(target, { isElectron: getIsElectron() })) {
|
||||
continue;
|
||||
}
|
||||
if (target.kind === "draft") {
|
||||
resolved.push({
|
||||
key: pinnedTargetKey(target),
|
||||
|
||||
@@ -1,5 +1,29 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { isTargetPinned, pinnedTargetKey, togglePinnedTarget } from "./target";
|
||||
import {
|
||||
isPinnedTargetAvailable,
|
||||
isTargetPinned,
|
||||
pinnedTargetKey,
|
||||
togglePinnedTarget,
|
||||
} from "./target";
|
||||
|
||||
describe("isPinnedTargetAvailable", () => {
|
||||
it("only offers browser targets in Electron", () => {
|
||||
const browser = { kind: "browser" } as const;
|
||||
|
||||
expect(isPinnedTargetAvailable(browser, { isElectron: true })).toBe(true);
|
||||
expect(isPinnedTargetAvailable(browser, { isElectron: false })).toBe(false);
|
||||
});
|
||||
|
||||
it("offers cross-platform targets outside Electron", () => {
|
||||
const environment = { isElectron: false };
|
||||
|
||||
expect(isPinnedTargetAvailable({ kind: "draft" }, environment)).toBe(true);
|
||||
expect(isPinnedTargetAvailable({ kind: "terminal" }, environment)).toBe(true);
|
||||
expect(isPinnedTargetAvailable({ kind: "profile", profileId: "claude" }, environment)).toBe(
|
||||
true,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("pinnedTargetKey", () => {
|
||||
it("uses the bare kind as the key for non-profile targets", () => {
|
||||
|
||||
@@ -4,6 +4,13 @@ export type PinnedTabTarget =
|
||||
| { kind: "browser" }
|
||||
| { kind: "profile"; profileId: string };
|
||||
|
||||
export function isPinnedTargetAvailable(
|
||||
target: PinnedTabTarget,
|
||||
environment: { isElectron: boolean },
|
||||
): boolean {
|
||||
return target.kind !== "browser" || environment.isElectron;
|
||||
}
|
||||
|
||||
export function pinnedTargetKey(target: PinnedTabTarget): string {
|
||||
if (target.kind === "profile") {
|
||||
return `profile:${target.profileId}`;
|
||||
|
||||
Reference in New Issue
Block a user