Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
82ad879504 | ||
|
|
8d24b5131f | ||
|
|
770946d026 | ||
|
|
8601797233 | ||
|
|
b73232bdd3 | ||
|
|
f131228a59 | ||
|
|
e321667b10 |
No files matched your search
@@ -12,6 +12,7 @@ import {
|
||||
resolveCursorAcpConfigUpdates,
|
||||
} from "../Layers/CursorProvider.ts";
|
||||
import * as AcpSessionRuntime from "./AcpSessionRuntime.ts";
|
||||
import { discoverCursorPluginDirectories } from "./CursorMcpServers.ts";
|
||||
|
||||
type CursorAcpRuntimeCursorSettings = Pick<CursorSettings, "apiEndpoint" | "binaryPath">;
|
||||
|
||||
@@ -46,6 +47,20 @@ export function buildCursorAcpSpawnInput(
|
||||
};
|
||||
}
|
||||
|
||||
export function addCursorPluginDirectories(
|
||||
spawn: AcpSessionRuntime.AcpSpawnInput,
|
||||
pluginDirectories: ReadonlyArray<string>,
|
||||
): AcpSessionRuntime.AcpSpawnInput {
|
||||
return {
|
||||
...spawn,
|
||||
args: [
|
||||
...spawn.args.slice(0, -1),
|
||||
...pluginDirectories.flatMap((path) => ["--plugin-dir", path]),
|
||||
...spawn.args.slice(-1),
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
export const makeCursorAcpRuntime = (
|
||||
input: CursorAcpRuntimeInput,
|
||||
): Effect.Effect<
|
||||
@@ -54,10 +69,14 @@ export const makeCursorAcpRuntime = (
|
||||
Crypto.Crypto | Scope.Scope
|
||||
> =>
|
||||
Effect.gen(function* () {
|
||||
const pluginDirectories = yield* discoverCursorPluginDirectories(
|
||||
input.environment === undefined ? {} : { environment: input.environment },
|
||||
);
|
||||
const spawn = buildCursorAcpSpawnInput(input.cursorSettings, input.cwd, input.environment);
|
||||
const acpContext = yield* Layer.build(
|
||||
AcpSessionRuntime.layer({
|
||||
...input,
|
||||
spawn: buildCursorAcpSpawnInput(input.cursorSettings, input.cwd, input.environment),
|
||||
spawn: addCursorPluginDirectories(spawn, pluginDirectories),
|
||||
authMethodId: "cursor_login",
|
||||
clientCapabilities: CURSOR_PARAMETERIZED_MODEL_PICKER_CAPABILITIES,
|
||||
}).pipe(
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
// @effect-diagnostics nodeBuiltinImport:off
|
||||
import * as NodeFSP from "node:fs/promises";
|
||||
import * as NodePath from "node:path";
|
||||
|
||||
import { describe, expect, it } from "@effect/vitest";
|
||||
import * as Effect from "effect/Effect";
|
||||
|
||||
import { addCursorPluginDirectories, buildCursorAcpSpawnInput } from "./CursorAcpSupport.ts";
|
||||
import { discoverCursorPluginDirectories } from "./CursorMcpServers.ts";
|
||||
|
||||
const writePlugin = Effect.fn("writePlugin")(function* (pluginsRoot: string, slug: string) {
|
||||
const pluginRoot = NodePath.join(pluginsRoot, slug, "hash");
|
||||
yield* Effect.promise(() =>
|
||||
NodeFSP.mkdir(NodePath.join(pluginRoot, ".cursor-plugin"), { recursive: true }),
|
||||
);
|
||||
yield* Effect.promise(() =>
|
||||
NodeFSP.writeFile(
|
||||
NodePath.join(pluginRoot, ".cursor-plugin", "plugin.json"),
|
||||
`{"name":"${slug}"}`,
|
||||
),
|
||||
);
|
||||
yield* Effect.promise(() =>
|
||||
NodeFSP.writeFile(NodePath.join(pluginRoot, "mcp.json"), '{"mcpServers":{}}'),
|
||||
);
|
||||
return pluginRoot;
|
||||
});
|
||||
|
||||
describe("discoverCursorPluginDirectories", () => {
|
||||
it.effect("returns cached Cursor plugins that provide MCP servers", () =>
|
||||
Effect.gen(function* () {
|
||||
const temp = yield* Effect.acquireRelease(
|
||||
Effect.promise(() => NodeFSP.mkdtemp("/tmp/t3-cursor-mcp-")),
|
||||
(path) => Effect.promise(() => NodeFSP.rm(path, { recursive: true, force: true })),
|
||||
);
|
||||
const pluginsRoot = NodePath.join(temp, "plugins", "cache", "cursor-public");
|
||||
const paperRoot = yield* writePlugin(pluginsRoot, "paper-desktop");
|
||||
const noMcpRoot = NodePath.join(pluginsRoot, "no-mcp", "hash");
|
||||
yield* Effect.promise(() =>
|
||||
NodeFSP.mkdir(NodePath.join(noMcpRoot, ".cursor-plugin"), { recursive: true }),
|
||||
);
|
||||
yield* Effect.promise(() =>
|
||||
NodeFSP.writeFile(
|
||||
NodePath.join(noMcpRoot, ".cursor-plugin", "plugin.json"),
|
||||
'{"name":"no-mcp"}',
|
||||
),
|
||||
);
|
||||
|
||||
const directories = yield* discoverCursorPluginDirectories({ pluginsRoot });
|
||||
|
||||
expect(directories).toEqual([paperRoot]);
|
||||
|
||||
const spawn = buildCursorAcpSpawnInput(null, "/workspace");
|
||||
expect(addCursorPluginDirectories(spawn, directories).args).toEqual([
|
||||
"--plugin-dir",
|
||||
paperRoot,
|
||||
"acp",
|
||||
]);
|
||||
}).pipe(Effect.scoped),
|
||||
);
|
||||
});
|
||||
@@ -0,0 +1,46 @@
|
||||
// @effect-diagnostics nodeBuiltinImport:off
|
||||
import * as NodeFS from "node:fs";
|
||||
import * as NodePath from "node:path";
|
||||
|
||||
import { Effect } from "effect";
|
||||
|
||||
interface DiscoverCursorPluginDirectoriesOptions {
|
||||
readonly environment?: NodeJS.ProcessEnv;
|
||||
readonly homeDirectory?: string;
|
||||
readonly pluginsRoot?: string;
|
||||
}
|
||||
|
||||
function resolveHome(environment: NodeJS.ProcessEnv, explicit: string | undefined): string {
|
||||
return explicit ?? environment.HOME ?? environment.USERPROFILE ?? "";
|
||||
}
|
||||
|
||||
/** Finds cached Cursor plugins that declare MCP servers. */
|
||||
export function discoverCursorPluginDirectories(
|
||||
options: DiscoverCursorPluginDirectoriesOptions = {},
|
||||
): Effect.Effect<ReadonlyArray<string>> {
|
||||
return Effect.sync(() => {
|
||||
const environment = options.environment ?? process.env;
|
||||
const homeDirectory = resolveHome(environment, options.homeDirectory);
|
||||
const pluginsRoot =
|
||||
options.pluginsRoot ??
|
||||
NodePath.join(homeDirectory, ".cursor", "plugins", "cache", "cursor-public");
|
||||
if (!NodeFS.existsSync(pluginsRoot)) return [];
|
||||
|
||||
const directories: string[] = [];
|
||||
for (const slug of NodeFS.readdirSync(pluginsRoot, { withFileTypes: true })) {
|
||||
if (!slug.isDirectory()) continue;
|
||||
const slugRoot = NodePath.join(pluginsRoot, slug.name);
|
||||
for (const version of NodeFS.readdirSync(slugRoot, { withFileTypes: true })) {
|
||||
if (!version.isDirectory()) continue;
|
||||
const pluginRoot = NodePath.join(slugRoot, version.name);
|
||||
if (
|
||||
NodeFS.existsSync(NodePath.join(pluginRoot, "mcp.json")) ||
|
||||
NodeFS.existsSync(NodePath.join(pluginRoot, ".mcp.json"))
|
||||
) {
|
||||
directories.push(pluginRoot);
|
||||
}
|
||||
}
|
||||
}
|
||||
return directories.sort();
|
||||
});
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
import { useLocation, useNavigate } from "@tanstack/react-router";
|
||||
|
||||
import { isElectron } from "../env";
|
||||
import { getLocalStorageItem } from "../hooks/useLocalStorage";
|
||||
import { getLocalStorageItem, removeLocalStorageItem } from "../hooks/useLocalStorage";
|
||||
import { resolveShortcutCommand, shortcutLabelForCommand } from "../keybindings";
|
||||
import { cn, isMacPlatform } from "../lib/utils";
|
||||
import { primaryServerKeybindingsAtom } from "../state/server";
|
||||
@@ -147,6 +147,14 @@ export function AppSidebarLayout({ children }: { children: ReactNode }) {
|
||||
// that would otherwise refresh a render-time snapshot.
|
||||
const viewportWidth = useSyncExternalStore(subscribeToViewportWidth, readViewportWidth);
|
||||
const sidebarMaximumWidth = resolveThreadSidebarMaximumWidth(viewportWidth);
|
||||
const resetSidebarWidth = () => {
|
||||
try {
|
||||
removeLocalStorageItem(THREAD_SIDEBAR_WIDTH_STORAGE_KEY);
|
||||
} catch (error) {
|
||||
console.error("Could not clear persisted thread sidebar width.", error);
|
||||
}
|
||||
setSidebarWidth(resolveInitialThreadSidebarWidth(null, viewportWidth));
|
||||
};
|
||||
const [isWindowFullscreen, setIsWindowFullscreen] = useState(() => {
|
||||
const getWindowFullscreenState = window.desktopBridge?.getWindowFullscreenState;
|
||||
return isMacosDesktop && typeof getWindowFullscreenState === "function"
|
||||
@@ -225,7 +233,7 @@ export function AppSidebarLayout({ children }: { children: ReactNode }) {
|
||||
) : (
|
||||
<ThreadSidebar />
|
||||
)}
|
||||
<SidebarRail />
|
||||
<SidebarRail onDoubleClick={resetSidebarWidth} />
|
||||
</Sidebar>
|
||||
{children}
|
||||
<SidebarControl />
|
||||
|
||||
@@ -23,6 +23,14 @@ describe("ChangedFilesCard", () => {
|
||||
expect(markup).toContain('data-changed-files-state="expanded"');
|
||||
expect(markup).toContain('aria-expanded="true"');
|
||||
expect(markup).toContain("whitespace-nowrap");
|
||||
expect(markup).toContain(
|
||||
'class="group flex min-w-0 flex-1 items-center gap-1.5 overflow-hidden',
|
||||
);
|
||||
expect(markup).toContain('class="flex shrink-0 items-center gap-1 whitespace-nowrap');
|
||||
expect(markup).toContain('class="ml-1 hidden min-w-0 flex-1 truncate');
|
||||
expect(markup).toContain("@[24rem]/changed-files:inline");
|
||||
expect(markup).not.toContain("sm:inline");
|
||||
expect(markup).toContain('class="flex shrink-0 items-center gap-1.5"');
|
||||
expect(markup).toContain("!size-[22px]");
|
||||
expect(markup).toContain("size-3");
|
||||
expect(markup).toContain('aria-label="Collapse all folders"');
|
||||
|
||||
@@ -56,7 +56,7 @@ export const ChangedFilesCard = memo(function ChangedFilesCard(props: {
|
||||
|
||||
return (
|
||||
<div
|
||||
className="mt-4 rounded-2xl border border-border/70 bg-secondary p-2 dark:border-transparent dark:bg-input/32"
|
||||
className="@container/changed-files mt-4 rounded-2xl border border-border/70 bg-secondary p-2 dark:border-transparent dark:bg-input/32"
|
||||
data-changed-files-state={
|
||||
expanded ? "expanded" : compactPreviewVisible ? "preview" : "collapsed"
|
||||
}
|
||||
@@ -73,7 +73,7 @@ export const ChangedFilesCard = memo(function ChangedFilesCard(props: {
|
||||
type="button"
|
||||
aria-expanded={expanded}
|
||||
data-scroll-anchor-ignore
|
||||
className="group flex min-w-0 flex-1 items-center gap-1.5 rounded-lg px-1 py-1.5 text-left transition-colors hover:bg-accent/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
||||
className="group flex min-w-0 flex-1 items-center gap-1.5 overflow-hidden rounded-lg px-1 py-1.5 text-left transition-colors hover:bg-accent/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
||||
onClick={() => onExpandedChange(!expanded)}
|
||||
>
|
||||
<ChevronRightIcon
|
||||
@@ -83,7 +83,7 @@ export const ChangedFilesCard = memo(function ChangedFilesCard(props: {
|
||||
expanded && "rotate-90",
|
||||
)}
|
||||
/>
|
||||
<span className="flex min-w-0 items-center gap-1 whitespace-nowrap font-medium text-foreground text-xs leading-4">
|
||||
<span className="flex shrink-0 items-center gap-1 whitespace-nowrap font-medium text-foreground text-xs leading-4">
|
||||
<span>
|
||||
{files.length} changed file{files.length === 1 ? "" : "s"}
|
||||
</span>
|
||||
@@ -96,11 +96,11 @@ export const ChangedFilesCard = memo(function ChangedFilesCard(props: {
|
||||
/>
|
||||
)}
|
||||
</span>
|
||||
<span className="ml-1 hidden truncate text-[11px] text-muted-foreground group-hover:text-foreground/80 sm:inline">
|
||||
<span className="ml-1 hidden min-w-0 flex-1 truncate text-[11px] text-muted-foreground group-hover:text-foreground/80 @[24rem]/changed-files:inline">
|
||||
{expanded ? "Hide files" : "Show files"}
|
||||
</span>
|
||||
</button>
|
||||
<div className="flex items-center gap-1.5">
|
||||
<div className="flex shrink-0 items-center gap-1.5">
|
||||
{expanded ? (
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
@@ -142,7 +142,7 @@ export const ChangedFilesCard = memo(function ChangedFilesCard(props: {
|
||||
}
|
||||
>
|
||||
<FileDiffIcon className="size-3" />
|
||||
<span className="hidden sm:inline">Open diff</span>
|
||||
<span className="hidden @[24rem]/changed-files:inline">Open diff</span>
|
||||
</TooltipTrigger>
|
||||
<TooltipPopup side="top">Open the full diff</TooltipPopup>
|
||||
</Tooltip>
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import {
|
||||
EMBER_THEME,
|
||||
GROVE_THEME,
|
||||
IRIS_THEME,
|
||||
OCEAN_THEME,
|
||||
T3_CHAT_THEME,
|
||||
themeColorToHex,
|
||||
type ThemeColors,
|
||||
} from "../../themePalette";
|
||||
import { clerkAppearance } from "./clerkAppearance";
|
||||
|
||||
function contrastRatio(first: string, second: string): number {
|
||||
const toRgb = (value: string) => {
|
||||
const hex = themeColorToHex(value)?.slice(1, 7);
|
||||
if (!hex) throw new Error(`Expected a theme color, received ${value}`);
|
||||
return [0, 1, 2].map(
|
||||
(channel) => Number.parseInt(hex.slice(channel * 2, channel * 2 + 2), 16) / 255,
|
||||
);
|
||||
};
|
||||
const luminance = (value: string) =>
|
||||
toRgb(value)
|
||||
.map((channel) => (channel <= 0.03928 ? channel / 12.92 : ((channel + 0.055) / 1.055) ** 2.4))
|
||||
.reduce((sum, channel, index) => sum + channel * [0.2126, 0.7152, 0.0722][index]!, 0);
|
||||
const lighter = Math.max(luminance(first), luminance(second));
|
||||
const darker = Math.min(luminance(first), luminance(second));
|
||||
return (lighter + 0.05) / (darker + 0.05);
|
||||
}
|
||||
|
||||
function mixThemeColors(first: string, second: string, firstWeight: number): string {
|
||||
const channels = [first, second].map((value) => {
|
||||
const hex = themeColorToHex(value)?.slice(1, 7);
|
||||
if (!hex) throw new Error(`Expected a theme color, received ${value}`);
|
||||
return [0, 1, 2].map((channel) => Number.parseInt(hex.slice(channel * 2, channel * 2 + 2), 16));
|
||||
});
|
||||
const mixed = channels[0]!.map((channel, index) =>
|
||||
Math.round(channel * firstWeight + channels[1]![index]! * (1 - firstWeight)),
|
||||
);
|
||||
return `#${mixed.map((channel) => channel.toString(16).padStart(2, "0")).join("")}`;
|
||||
}
|
||||
|
||||
const builtInThemeModes = [
|
||||
T3_CHAT_THEME,
|
||||
GROVE_THEME,
|
||||
OCEAN_THEME,
|
||||
EMBER_THEME,
|
||||
IRIS_THEME,
|
||||
].flatMap((theme) =>
|
||||
[theme.colors, theme.variants?.dark].filter((colors): colors is ThemeColors => !!colors),
|
||||
);
|
||||
|
||||
describe("clerkAppearance", () => {
|
||||
it("maps theme colors without overriding Clerk's component structure", () => {
|
||||
expect(clerkAppearance).toEqual({
|
||||
variables: {
|
||||
colorPrimary: "var(--update-foreground)",
|
||||
colorPrimaryForeground: "var(--card)",
|
||||
colorDanger: "var(--error)",
|
||||
colorSuccess: "var(--success)",
|
||||
colorWarning: "var(--warning)",
|
||||
colorNeutral: "var(--foreground)",
|
||||
colorForeground: "var(--foreground)",
|
||||
colorMuted: "color-mix(in srgb, var(--card) 98%, var(--foreground))",
|
||||
colorMutedForeground: "var(--muted-foreground)",
|
||||
colorBackground: "var(--card)",
|
||||
colorInputForeground: "var(--foreground)",
|
||||
colorInput: "var(--secondary)",
|
||||
colorRing: "var(--ring)",
|
||||
},
|
||||
elements: {
|
||||
formFieldErrorText: { color: "var(--error-foreground)" },
|
||||
formFieldWarningText: { color: "var(--warning-foreground)" },
|
||||
formFieldSuccessText: { color: "var(--success-foreground)" },
|
||||
otpCodeFieldErrorText: { color: "var(--error-foreground)" },
|
||||
otpCodeFieldSuccessText: { color: "var(--success-foreground)" },
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it.each(builtInThemeModes)("keeps Clerk text readable across a built-in palette", (colors) => {
|
||||
const mutedSurface = mixThemeColors(colors.surface, colors.text, 0.98);
|
||||
|
||||
expect(contrastRatio(colors.text, colors.surface)).toBeGreaterThanOrEqual(4.5);
|
||||
expect(contrastRatio(colors.mutedForeground, mutedSurface)).toBeGreaterThanOrEqual(4.5);
|
||||
expect(contrastRatio(colors.text, colors.secondary)).toBeGreaterThanOrEqual(4.5);
|
||||
expect(contrastRatio(colors.updateForeground, colors.surface)).toBeGreaterThanOrEqual(4.5);
|
||||
expect(contrastRatio(colors.errorForeground, colors.surface)).toBeGreaterThanOrEqual(4.5);
|
||||
expect(contrastRatio(colors.warningForeground, colors.surface)).toBeGreaterThanOrEqual(4.5);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,34 @@
|
||||
import type { ClerkProviderProps } from "@clerk/react";
|
||||
|
||||
/** Keeps Clerk's stock component structure while binding its color system to
|
||||
* the live T3 Code palette. CSS variables make theme changes propagate to
|
||||
* portaled sign-in and profile surfaces without remounting Clerk. */
|
||||
export const clerkAppearance = {
|
||||
variables: {
|
||||
// Clerk reuses its primary color for filled buttons and bare links. The
|
||||
// app's update foreground is the palette's action hue cast for readable
|
||||
// text, while the card surface provides the inverse filled-control pair.
|
||||
colorPrimary: "var(--update-foreground)",
|
||||
colorPrimaryForeground: "var(--card)",
|
||||
colorDanger: "var(--error)",
|
||||
colorSuccess: "var(--success)",
|
||||
colorWarning: "var(--warning)",
|
||||
colorNeutral: "var(--foreground)",
|
||||
colorForeground: "var(--foreground)",
|
||||
// The stock dark theme's muted token is translucent. Clerk uses this as
|
||||
// the footer's background, so derive an opaque muted surface from the card.
|
||||
colorMuted: "color-mix(in srgb, var(--card) 98%, var(--foreground))",
|
||||
colorMutedForeground: "var(--muted-foreground)",
|
||||
colorBackground: "var(--card)",
|
||||
colorInputForeground: "var(--foreground)",
|
||||
colorInput: "var(--secondary)",
|
||||
colorRing: "var(--ring)",
|
||||
},
|
||||
elements: {
|
||||
formFieldErrorText: { color: "var(--error-foreground)" },
|
||||
formFieldWarningText: { color: "var(--warning-foreground)" },
|
||||
formFieldSuccessText: { color: "var(--success-foreground)" },
|
||||
otpCodeFieldErrorText: { color: "var(--error-foreground)" },
|
||||
otpCodeFieldSuccessText: { color: "var(--success-foreground)" },
|
||||
},
|
||||
} satisfies NonNullable<ClerkProviderProps["appearance"]>;
|
||||
@@ -18,7 +18,7 @@ function ReleaseNotesLink({
|
||||
}) {
|
||||
return (
|
||||
<button
|
||||
className="ml-2 inline-flex cursor-pointer items-center gap-1 align-baseline text-muted-foreground underline decoration-dotted underline-offset-4 transition-colors hover:text-foreground"
|
||||
className="ml-2 inline cursor-pointer text-muted-foreground underline decoration-dotted underline-offset-4 transition-colors hover:text-foreground"
|
||||
onClick={() => {
|
||||
void (async () => {
|
||||
try {
|
||||
@@ -32,7 +32,11 @@ function ReleaseNotesLink({
|
||||
type="button"
|
||||
>
|
||||
Read more
|
||||
<ArrowRightIcon aria-hidden className="size-3 -rotate-45" strokeWidth={2.25} />
|
||||
<ArrowRightIcon
|
||||
aria-hidden
|
||||
className="ml-1 inline size-3 -rotate-45 align-[-0.125em]"
|
||||
strokeWidth={2.25}
|
||||
/>
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ function TooltipPopup({
|
||||
<TooltipPrimitive.Positioner
|
||||
align={align}
|
||||
anchor={anchor}
|
||||
className="pointer-events-none z-70 h-(--positioner-height) w-(--positioner-width) max-w-(--available-width) transition-[top,left,right,bottom,transform] data-instant:transition-none"
|
||||
className="pointer-events-none z-[140] h-(--positioner-height) w-(--positioner-width) max-w-(--available-width) transition-[top,left,right,bottom,transform] data-instant:transition-none"
|
||||
data-slot="tooltip-positioner"
|
||||
side={side}
|
||||
sideOffset={sideOffset}
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
openPullRequestLink,
|
||||
parseChangeRequestUrl,
|
||||
PullRequestLinkOpenError,
|
||||
shouldOpenPullRequestExternally,
|
||||
} from "./openPullRequestLink";
|
||||
|
||||
describe("openPullRequestLink", () => {
|
||||
@@ -34,6 +35,17 @@ describe("openPullRequestLink", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("shouldOpenPullRequestExternally", () => {
|
||||
it("uses the browser for command-click and control-click", () => {
|
||||
expect(shouldOpenPullRequestExternally({ metaKey: true, ctrlKey: false })).toBe(true);
|
||||
expect(shouldOpenPullRequestExternally({ metaKey: false, ctrlKey: true })).toBe(true);
|
||||
});
|
||||
|
||||
it("keeps an unmodified click in the pull request view", () => {
|
||||
expect(shouldOpenPullRequestExternally({ metaKey: false, ctrlKey: false })).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("parseChangeRequestUrl", () => {
|
||||
it("reads a GitHub pull request", () => {
|
||||
expect(parseChangeRequestUrl("https://github.com/T3Tools/T3Code/pull/123")).toEqual({
|
||||
|
||||
@@ -173,10 +173,19 @@ export function findProjectForChangeRequest(
|
||||
* should still be reading it afterwards. Any change request opens there, not only the thread's
|
||||
* own, since the panel is told which one to show.
|
||||
*/
|
||||
export function shouldOpenPullRequestExternally(
|
||||
event: Pick<MouseEvent<HTMLElement>, "metaKey" | "ctrlKey">,
|
||||
): boolean {
|
||||
return event.metaKey || event.ctrlKey;
|
||||
}
|
||||
|
||||
export function useOpenChangeRequestLink(
|
||||
threadRef?: ScopedThreadRef,
|
||||
): (
|
||||
event: Pick<MouseEvent<HTMLElement>, "preventDefault" | "stopPropagation">,
|
||||
event: Pick<
|
||||
MouseEvent<HTMLElement>,
|
||||
"preventDefault" | "stopPropagation" | "metaKey" | "ctrlKey"
|
||||
>,
|
||||
targetUrl: string,
|
||||
targetThreadRef?: ScopedThreadRef,
|
||||
) => boolean {
|
||||
@@ -186,6 +195,7 @@ export function useOpenChangeRequestLink(
|
||||
const primaryEnvironmentId = usePrimaryEnvironmentId();
|
||||
return useCallback(
|
||||
(event, targetUrl, targetThreadRef) => {
|
||||
if (shouldOpenPullRequestExternally(event)) return false;
|
||||
const resolvedThreadRef = targetThreadRef ?? threadRef;
|
||||
const environmentId = resolvedThreadRef?.environmentId ?? primaryEnvironmentId;
|
||||
if (
|
||||
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
syncDocumentWindowControlsOverlayClass,
|
||||
} from "./lib/windowControlsOverlay";
|
||||
import { AppRoot } from "./AppRoot";
|
||||
import { clerkAppearance } from "./components/clerk/clerkAppearance";
|
||||
|
||||
// Electron loads the app from a file-backed shell, so hash history avoids path resolution issues.
|
||||
const history = isElectron ? createHashHistory() : createBrowserHistory();
|
||||
@@ -35,11 +36,15 @@ ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
|
||||
<React.StrictMode>
|
||||
{clerkPublishableKey && hasCloudPublicConfig() ? (
|
||||
isElectron ? (
|
||||
<ElectronClerkProvider publishableKey={clerkPublishableKey} passkeys={passkeys}>
|
||||
<ElectronClerkProvider
|
||||
appearance={clerkAppearance}
|
||||
publishableKey={clerkPublishableKey}
|
||||
passkeys={passkeys}
|
||||
>
|
||||
<ManagedRelayAuthProvider>{app}</ManagedRelayAuthProvider>
|
||||
</ElectronClerkProvider>
|
||||
) : (
|
||||
<ClerkProvider publishableKey={clerkPublishableKey}>
|
||||
<ClerkProvider appearance={clerkAppearance} publishableKey={clerkPublishableKey}>
|
||||
<ManagedRelayAuthProvider>{app}</ManagedRelayAuthProvider>
|
||||
</ClerkProvider>
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user