Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dfb884e5d4 | ||
|
|
1bb371e860 | ||
|
|
8d24b5131f | ||
|
|
770946d026 | ||
|
|
8601797233 | ||
|
|
48adadcc55 | ||
|
|
6bd7bdb99c | ||
|
|
4cd17fdf84 | ||
|
|
fa8d81fb00 | ||
|
|
b73232bdd3 | ||
|
|
f131228a59 | ||
|
|
e321667b10 |
No files matched your search
@@ -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>
|
||||
|
||||
@@ -2188,26 +2188,43 @@ const AgentSpawnCtaRow = memo(function AgentSpawnCtaRow(props: { workEntry: Time
|
||||
? `${failed} failed`
|
||||
: "✓ completed";
|
||||
|
||||
const actionLabel = live ? "Open agents" : "View agents";
|
||||
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
onClick={onOpenAgents}
|
||||
className="-mx-1 flex w-full items-center gap-2 rounded-md border border-border/60 bg-card/50 px-2.5 py-1.5 text-left text-[13px] transition hover:bg-accent/50"
|
||||
>
|
||||
<span aria-hidden className={cn("size-1.5 shrink-0 rounded-full", dotClass)} />
|
||||
<WorkEntryIconSvg name="bot" className="size-3.5 shrink-0 text-muted-foreground" />
|
||||
<span className="min-w-0 truncate">
|
||||
<span className="font-medium">{lead}</span>
|
||||
{workflowName ? <span className="text-muted-foreground"> · {workflowName}</span> : null}
|
||||
</span>
|
||||
<span className="ml-auto flex shrink-0 items-center gap-2 font-mono text-[.7rem] text-muted-foreground">
|
||||
<span>{status}</span>
|
||||
{totalTokens > 0 ? (
|
||||
<span className="tabular-nums">Σ {formatSubagentTokenCount(totalTokens)}</span>
|
||||
) : null}
|
||||
<span className="text-info-foreground">{live ? "Open Agents ▸" : "View ▸"}</span>
|
||||
</span>
|
||||
</button>
|
||||
<div className="@container/agent-spawn rounded-2xl border border-border/70 bg-secondary p-2 dark:border-transparent dark:bg-input/32">
|
||||
<div className="flex items-center justify-between gap-2 rounded-xl px-1">
|
||||
<button
|
||||
type="button"
|
||||
onClick={onOpenAgents}
|
||||
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"
|
||||
>
|
||||
<span className="flex min-w-0 shrink-0 items-center gap-1.5 whitespace-nowrap font-medium text-foreground text-xs leading-4">
|
||||
<span aria-hidden className={cn("size-1.5 shrink-0 rounded-full", dotClass)} />
|
||||
<WorkEntryIconSvg name="bot" className="size-3.5 shrink-0 text-muted-foreground" />
|
||||
<span className="truncate">{lead}</span>
|
||||
</span>
|
||||
{workflowName ? (
|
||||
<span className="ml-1 hidden min-w-0 flex-1 truncate text-[11px] text-muted-foreground group-hover:text-foreground/80 @[24rem]/agent-spawn:inline">
|
||||
{workflowName}
|
||||
</span>
|
||||
) : null}
|
||||
<span className="ml-1 hidden min-w-0 flex-1 truncate text-[11px] text-muted-foreground group-hover:text-foreground/80 @[24rem]/agent-spawn:inline">
|
||||
{status}
|
||||
{totalTokens > 0 ? ` · Σ ${formatSubagentTokenCount(totalTokens)}` : ""}
|
||||
</span>
|
||||
</button>
|
||||
<Button
|
||||
type="button"
|
||||
size="xs"
|
||||
variant="outline"
|
||||
aria-label={actionLabel}
|
||||
onClick={onOpenAgents}
|
||||
>
|
||||
<BotIcon className="size-3" />
|
||||
<span className="hidden @[24rem]/agent-spawn:inline">{actionLabel}</span>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -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