Compare commits

...
Author SHA1 Message Date
t3-code[bot]andWout Stiens b77d7b2183 fix(web): restart repeated update check spins
Co-authored-by: Wout Stiens <[email protected]>
2026-08-12 15:06:25 +00:00
t3-code[bot]andWout Stiens ff762f8aa3 fix(web): reset update check animation latch
Co-authored-by: Wout Stiens <[email protected]>
2026-08-12 14:58:46 +00:00
t3-code[bot]andWout Stiens 2cc713b3b3 fix(web): complete fast update check rotation
Co-authored-by: Wout Stiens <[email protected]>
2026-08-12 14:44:52 +00:00
Exotic b73232bdd3 feat(web): reset sidebar width on double click (#6320) 2026-08-12 10:07:39 -04:00
Wout Stiens f131228a59 fix(web): theme Clerk surfaces (#6300) 2026-08-12 19:36:04 +05:30
t3-code[bot]andWout Stiens e321667b10 fix(web): prevent changed files header overlap (#6314)
Co-authored-by: t3-code[bot] <269035359+t3-code[bot]@users.noreply.github.com>
Co-authored-by: Wout Stiens <[email protected]>
2026-08-12 08:56:13 -04:00
9 changed files with 254 additions and 14 deletions

No files matched your search

+10 -2
View File
@@ -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"]>;
@@ -0,0 +1,31 @@
import { RefreshCwIcon } from "lucide-react";
import type { AnimationEventHandler } from "react";
import { cn } from "../../lib/utils";
export function nextDesktopUpdateCheckAnimationKey(key: number) {
return key + 1;
}
export function shouldContinueDesktopUpdateCheckAnimation({
isChecking,
}: {
readonly isChecking: boolean;
}) {
return isChecking;
}
export function DesktopUpdateCheckIcon({
isAnimating,
onAnimationIteration,
}: {
readonly isAnimating: boolean;
readonly onAnimationIteration?: AnimationEventHandler<SVGSVGElement>;
}) {
return (
<RefreshCwIcon
className={cn("size-4", isAnimating && "animate-spin")}
onAnimationIteration={onAnimationIteration}
/>
);
}
@@ -0,0 +1,42 @@
import { renderToStaticMarkup } from "react-dom/server";
import { describe, expect, it } from "vite-plus/test";
import {
DesktopUpdateCheckIcon,
nextDesktopUpdateCheckAnimationKey,
shouldContinueDesktopUpdateCheckAnimation,
} from "./DesktopUpdateCheckIcon";
describe("DesktopUpdateCheckIcon", () => {
it("keeps the refresh icon spinning while a fast update check settles", () => {
const markup = renderToStaticMarkup(<DesktopUpdateCheckIcon isAnimating />);
expect(markup).toContain("animate-spin");
});
it("does not animate while idle", () => {
const markup = renderToStaticMarkup(<DesktopUpdateCheckIcon isAnimating={false} />);
expect(markup).not.toContain("animate-spin");
});
it("keeps status-driven checks spinning across rotations", () => {
expect(
shouldContinueDesktopUpdateCheckAnimation({
isChecking: true,
}),
).toBe(true);
});
it("releases the manual animation latch after one rotation", () => {
expect(
shouldContinueDesktopUpdateCheckAnimation({
isChecking: false,
}),
).toBe(false);
});
it("restarts the animation for each manual check", () => {
expect(nextDesktopUpdateCheckAnimationKey(2)).toBe(3);
});
});
@@ -1,5 +1,5 @@
import { DownloadIcon, RefreshCwIcon, RotateCwIcon, TriangleAlertIcon } from "lucide-react";
import { useCallback, useState } from "react";
import { DownloadIcon, RotateCwIcon, TriangleAlertIcon } from "lucide-react";
import { useCallback, useEffect, useState } from "react";
import { isElectron } from "../../env";
import { cn } from "../../lib/utils";
import { ensureLocalApi } from "../../localApi";
@@ -21,6 +21,11 @@ import { Alert, AlertDescription, AlertTitle } from "../ui/alert";
import { Separator } from "../ui/separator";
import { SidebarMenuItem } from "../ui/sidebar";
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
import {
DesktopUpdateCheckIcon,
nextDesktopUpdateCheckAnimationKey,
shouldContinueDesktopUpdateCheckAnimation,
} from "./DesktopUpdateCheckIcon";
function keyReleaseNoteItems(items: ReadonlyArray<string>) {
const occurrences = new Map<string, number>();
@@ -110,6 +115,12 @@ export function SidebarUpdatePill() {
function SidebarUpdateControl() {
const state = useDesktopUpdateState();
const [isActionPending, setIsActionPending] = useState(false);
const [checkAnimationKey, setCheckAnimationKey] = useState(0);
const [isCheckIconAnimating, setIsCheckIconAnimating] = useState(false);
useEffect(() => {
if (state?.status === "checking") setIsCheckIconAnimating(true);
}, [state?.status]);
const action = state ? resolveDesktopUpdateButtonAction(state) : "none";
const isDownloading = state?.status === "downloading";
@@ -209,6 +220,8 @@ function SidebarUpdateControl() {
return;
}
setIsCheckIconAnimating(true);
setCheckAnimationKey(nextDesktopUpdateCheckAnimationKey);
void bridge
.checkForUpdate()
.then((result) => {
@@ -234,6 +247,12 @@ function SidebarUpdateControl() {
.finally(() => setIsActionPending(false));
}, [action, disabled, isActionPending, state]);
const handleCheckAnimationIteration = useCallback(() => {
setIsCheckIconAnimating(
shouldContinueDesktopUpdateCheckAnimation({ isChecking: state?.status === "checking" }),
);
}, [state?.status]);
return (
<SidebarMenuItem className="ml-auto shrink-0">
<Tooltip>
@@ -257,8 +276,10 @@ function SidebarUpdateControl() {
) : isUpdateState ? (
<DownloadIcon className="size-4" />
) : (
<RefreshCwIcon
className={cn("size-4", state?.status === "checking" && "animate-spin")}
<DesktopUpdateCheckIcon
key={checkAnimationKey}
isAnimating={isCheckIconAnimating}
onAnimationIteration={handleCheckAnimationIteration}
/>
)}
</button>
+7 -2
View File
@@ -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>
)