Any new-tab target (new agent, terminal, browser, or a terminal profile) can be pinned as a quick-launch button. Pins are global client app state (persisted), not daemon config, so the same set shows on every workspace; profile pins resolve per host and are dropped where that profile is absent. The sidebar mirror launches via a navigate-then-launch intent store rather than calling the create handlers directly: terminal creation only works in the mounted/focused workspace, so the sidebar requests the launch and the workspace screen consumes it on focus.
59 lines
2.3 KiB
TypeScript
59 lines
2.3 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import type { TerminalProfile } from "@getpaseo/protocol/messages";
|
|
import type { TerminalProfileInput } from "@/screens/workspace/terminals/use-workspace-terminals";
|
|
import { runPinnedTabTarget, type TabTargetHandlers } from "./run";
|
|
|
|
const PROFILES: readonly TerminalProfile[] = [
|
|
{ id: "claude", name: "Claude Code", command: "claude" },
|
|
];
|
|
|
|
interface RecordedLaunch {
|
|
action: "draft" | "terminal" | "browser" | "profile";
|
|
profile?: TerminalProfileInput;
|
|
}
|
|
|
|
function recordingHandlers() {
|
|
const launches: RecordedLaunch[] = [];
|
|
const handlers: TabTargetHandlers = {
|
|
createDraft: () => launches.push({ action: "draft" }),
|
|
createTerminal: () => launches.push({ action: "terminal" }),
|
|
createBrowser: () => launches.push({ action: "browser" }),
|
|
createTerminalWithProfile: (profile) => launches.push({ action: "profile", profile }),
|
|
};
|
|
return { launches, handlers };
|
|
}
|
|
|
|
describe("runPinnedTabTarget", () => {
|
|
it("creates a draft agent for the draft target", () => {
|
|
const { launches, handlers } = recordingHandlers();
|
|
runPinnedTabTarget({ kind: "draft" }, PROFILES, handlers);
|
|
expect(launches).toEqual([{ action: "draft" }]);
|
|
});
|
|
|
|
it("creates a terminal for the terminal target", () => {
|
|
const { launches, handlers } = recordingHandlers();
|
|
runPinnedTabTarget({ kind: "terminal" }, PROFILES, handlers);
|
|
expect(launches).toEqual([{ action: "terminal" }]);
|
|
});
|
|
|
|
it("creates a browser for the browser target", () => {
|
|
const { launches, handlers } = recordingHandlers();
|
|
runPinnedTabTarget({ kind: "browser" }, PROFILES, handlers);
|
|
expect(launches).toEqual([{ action: "browser" }]);
|
|
});
|
|
|
|
it("launches the resolved profile command for a known profile target", () => {
|
|
const { launches, handlers } = recordingHandlers();
|
|
runPinnedTabTarget({ kind: "profile", profileId: "claude" }, PROFILES, handlers);
|
|
expect(launches).toEqual([
|
|
{ action: "profile", profile: { name: "Claude Code", command: "claude" } },
|
|
]);
|
|
});
|
|
|
|
it("does nothing when the profile id is absent from the host", () => {
|
|
const { launches, handlers } = recordingHandlers();
|
|
runPinnedTabTarget({ kind: "profile", profileId: "missing" }, PROFILES, handlers);
|
|
expect(launches).toEqual([]);
|
|
});
|
|
});
|