feat(web): make environment artwork theme aware (#6183)
Co-authored-by: codex <[email protected]>
This commit is contained in:
1 parent
ac4780f451
commit
b30a9bc414
12 files changed
+414
-123
No files matched your search
@@ -19,7 +19,10 @@ import LegacyThreadSidebar from "./LegacySidebar";
|
||||
import ThreadSidebar from "./Sidebar";
|
||||
import { SettingsSidebarNav } from "./settings/SettingsSidebarNav";
|
||||
import { SidebarChromeHeader } from "./sidebar/SidebarChrome";
|
||||
import { useSidebarStageBackdropVariant } from "./SidebarStageBackdrop";
|
||||
import {
|
||||
resolveSidebarStageFocusRingOffsetClass,
|
||||
useSidebarStageBackdropVariant,
|
||||
} from "./SidebarStageBackdrop";
|
||||
import { useProjects } from "../state/entities";
|
||||
import {
|
||||
resolveInitialThreadSidebarWidth,
|
||||
@@ -105,7 +108,10 @@ function SidebarControl() {
|
||||
"pointer-events-auto",
|
||||
isSidebarVisible &&
|
||||
stageBackdropVariant &&
|
||||
"[:hover,[data-pressed]]:bg-white/15 focus-visible:ring-white/90 focus-visible:ring-offset-blue-700 [&_svg]:stroke-white/90! [&_svg]:opacity-100! [&_svg]:hover:stroke-white!",
|
||||
"focus-visible:ring-white/90 [&_svg]:stroke-white/90! [&_svg]:opacity-100! [&_svg]:hover:stroke-white! [:hover,[data-pressed]]:bg-white/15",
|
||||
isSidebarVisible &&
|
||||
stageBackdropVariant &&
|
||||
resolveSidebarStageFocusRingOffsetClass(stageBackdropVariant),
|
||||
)}
|
||||
aria-label="Toggle main sidebar"
|
||||
/>
|
||||
|
||||
@@ -4,7 +4,9 @@ import { renderToStaticMarkup } from "react-dom/server";
|
||||
import {
|
||||
resolveEnvironmentIdentificationPillLabel,
|
||||
resolveSidebarStageBackdropVariant,
|
||||
resolveSidebarStageFocusRingOffsetClass,
|
||||
StageBackdropArt,
|
||||
StageBackdropButtonArt,
|
||||
} from "./SidebarStageBackdrop";
|
||||
|
||||
describe("SidebarStageBackdrop", () => {
|
||||
@@ -22,6 +24,15 @@ describe("SidebarStageBackdrop", () => {
|
||||
expect(resolveEnvironmentIdentificationPillLabel("Alpha")).toBeNull();
|
||||
});
|
||||
|
||||
it("matches the focus-ring offset to each artwork palette", () => {
|
||||
expect(resolveSidebarStageFocusRingOffsetClass("nightly")).toBe(
|
||||
"focus-visible:ring-offset-(--stage-night-bottom)",
|
||||
);
|
||||
expect(resolveSidebarStageFocusRingOffsetClass("dev")).toBe(
|
||||
"focus-visible:ring-offset-(--stage-art-bottom)",
|
||||
);
|
||||
});
|
||||
|
||||
it.each(["nightly", "dev"] as const)(
|
||||
"uses unique SVG definition ids when %s artwork is rendered more than once",
|
||||
(variant) => {
|
||||
@@ -37,4 +48,26 @@ describe("SidebarStageBackdrop", () => {
|
||||
expect(new Set(ids).size).toBe(ids.length);
|
||||
},
|
||||
);
|
||||
|
||||
it("paints each artwork variant with theme-owned color tokens", () => {
|
||||
const nightlyMarkup = renderToStaticMarkup(<StageBackdropArt variant="nightly" />);
|
||||
const devMarkup = renderToStaticMarkup(<StageBackdropArt variant="dev" />);
|
||||
|
||||
expect(nightlyMarkup).toContain("var(--stage-night-bottom)");
|
||||
expect(nightlyMarkup).toContain("var(--stage-night-line)");
|
||||
expect(devMarkup).toContain("var(--stage-art-bottom)");
|
||||
expect(devMarkup).toContain("var(--stage-art-line)");
|
||||
expect(nightlyMarkup).not.toMatch(/#[0-9a-f]{3,8}/i);
|
||||
expect(devMarkup).not.toMatch(/#[0-9a-f]{3,8}/i);
|
||||
});
|
||||
|
||||
it.each([
|
||||
["nightly", "96 0 8192 96"],
|
||||
["dev", "64 0 8192 96"],
|
||||
] as const)("uses the compact %s crop inside the send button", (variant, viewBox) => {
|
||||
const markup = renderToStaticMarkup(<StageBackdropButtonArt variant={variant} />);
|
||||
|
||||
expect(markup).toContain(`viewBox="${viewBox}"`);
|
||||
expect(markup).toContain(`stage-${variant === "dev" ? "blueprint" : "nightly"}`);
|
||||
});
|
||||
});
|
||||
@@ -23,6 +23,14 @@ export function resolveSidebarStageBackdropVariant(
|
||||
return null;
|
||||
}
|
||||
|
||||
export function resolveSidebarStageFocusRingOffsetClass(
|
||||
variant: SidebarStageBackdropVariant,
|
||||
): string {
|
||||
return variant === "nightly"
|
||||
? "focus-visible:ring-offset-(--stage-night-bottom)"
|
||||
: "focus-visible:ring-offset-(--stage-art-bottom)";
|
||||
}
|
||||
|
||||
export function resolveEnvironmentIdentificationPillLabel(
|
||||
stageLabel: string,
|
||||
): EnvironmentIdentificationPillLabel | null {
|
||||
@@ -62,6 +70,10 @@ export function StageBackdropArt({ variant }: { variant: SidebarStageBackdropVar
|
||||
return variant === "nightly" ? <NightlySkyArt /> : <DevBlueprintArt />;
|
||||
}
|
||||
|
||||
export function StageBackdropButtonArt({ variant }: { variant: SidebarStageBackdropVariant }) {
|
||||
return variant === "nightly" ? <NightlySkyArt compact /> : <DevBlueprintArt compact />;
|
||||
}
|
||||
|
||||
const NIGHTLY_STARS: ReadonlyArray<{
|
||||
cx: number;
|
||||
cy: number;
|
||||
@@ -93,7 +105,7 @@ const NIGHTLY_SPARKLES: ReadonlyArray<{ x: number; y: number }> = [
|
||||
{ x: 246, y: 26 },
|
||||
];
|
||||
|
||||
function NightlySkyArt() {
|
||||
function NightlySkyArt({ compact = false }: { compact?: boolean }) {
|
||||
const idPrefix = useId().replaceAll(":", "");
|
||||
const skyId = `${idPrefix}-stage-night-sky`;
|
||||
const glowId = `${idPrefix}-stage-night-glow`;
|
||||
@@ -104,10 +116,10 @@ function NightlySkyArt() {
|
||||
|
||||
return (
|
||||
<svg
|
||||
className="h-full w-full"
|
||||
className="stage-art stage-nightly h-full w-full"
|
||||
fill="none"
|
||||
preserveAspectRatio="xMinYMin slice"
|
||||
viewBox={STAGE_BACKDROP_VIEW_BOX}
|
||||
viewBox={compact ? "96 0 8192 96" : STAGE_BACKDROP_VIEW_BOX}
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<defs>
|
||||
@@ -120,9 +132,9 @@ function NightlySkyArt() {
|
||||
gradientUnits="userSpaceOnUse"
|
||||
spreadMethod="reflect"
|
||||
>
|
||||
<stop stopColor="#07152F" />
|
||||
<stop offset="0.5" stopColor="#151443" />
|
||||
<stop offset="1" stopColor="#32155B" />
|
||||
<stop style={{ stopColor: "var(--stage-night-bottom)" }} />
|
||||
<stop offset="0.5" style={{ stopColor: "var(--stage-night-mid)" }} />
|
||||
<stop offset="1" style={{ stopColor: "var(--stage-night-top)" }} />
|
||||
</linearGradient>
|
||||
<radialGradient
|
||||
id={glowId}
|
||||
@@ -132,20 +144,28 @@ function NightlySkyArt() {
|
||||
gradientTransform="translate(216 18) rotate(137) scale(120 84)"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
>
|
||||
<stop stopColor="#5165D8" stopOpacity="0.4" />
|
||||
<stop offset="0.5" stopColor="#283075" stopOpacity="0.16" />
|
||||
<stop offset="1" stopColor="#111635" stopOpacity="0" />
|
||||
<stop style={{ stopColor: "var(--stage-night-highlight)" }} stopOpacity="0.4" />
|
||||
<stop
|
||||
offset="0.5"
|
||||
style={{ stopColor: "var(--stage-night-secondary)" }}
|
||||
stopOpacity="0.16"
|
||||
/>
|
||||
<stop offset="1" style={{ stopColor: "var(--stage-night-bottom)" }} stopOpacity="0" />
|
||||
</radialGradient>
|
||||
<linearGradient id={cloudId} x1="0" y1="60" x2="288" y2="96" gradientUnits="userSpaceOnUse">
|
||||
<stop stopColor="#4EA4FF" stopOpacity="0.5" />
|
||||
<stop offset="0.52" stopColor="#696FEA" stopOpacity="0.62" />
|
||||
<stop offset="1" stopColor="#A85BEA" stopOpacity="0.5" />
|
||||
<stop style={{ stopColor: "var(--stage-night-highlight)" }} stopOpacity="0.5" />
|
||||
<stop
|
||||
offset="0.52"
|
||||
style={{ stopColor: "var(--stage-night-secondary)" }}
|
||||
stopOpacity="0.62"
|
||||
/>
|
||||
<stop offset="1" style={{ stopColor: "var(--stage-night-tertiary)" }} stopOpacity="0.5" />
|
||||
</linearGradient>
|
||||
<filter id={softId} x="-24" y="-24" width="336" height="144" filterUnits="userSpaceOnUse">
|
||||
<feGaussianBlur stdDeviation="4" />
|
||||
</filter>
|
||||
<pattern id={starsId} width="288" height="96" patternUnits="userSpaceOnUse">
|
||||
<g fill="#E4EAFF">
|
||||
<g style={{ fill: "var(--stage-night-line)" }}>
|
||||
{NIGHTLY_STARS.map((star) => (
|
||||
<circle
|
||||
key={`${star.cx}-${star.cy}`}
|
||||
@@ -156,7 +176,12 @@ function NightlySkyArt() {
|
||||
/>
|
||||
))}
|
||||
</g>
|
||||
<g stroke="#C8D7FF" strokeLinecap="round" strokeOpacity="0.7" strokeWidth="0.6">
|
||||
<g
|
||||
style={{ stroke: "var(--stage-night-line)" }}
|
||||
strokeLinecap="round"
|
||||
strokeOpacity="0.7"
|
||||
strokeWidth="0.6"
|
||||
>
|
||||
{NIGHTLY_SPARKLES.map((sparkle) => (
|
||||
<g key={`${sparkle.x}-${sparkle.y}`}>
|
||||
<path d={`M${sparkle.x - 1.5} ${sparkle.y}H${sparkle.x + 1.5}`} />
|
||||
@@ -191,7 +216,7 @@ function NightlySkyArt() {
|
||||
);
|
||||
}
|
||||
|
||||
function DevBlueprintArt() {
|
||||
function DevBlueprintArt({ compact = false }: { compact?: boolean }) {
|
||||
const idPrefix = useId().replaceAll(":", "");
|
||||
const paperId = `${idPrefix}-stage-bp-paper`;
|
||||
const glowId = `${idPrefix}-stage-bp-glow`;
|
||||
@@ -205,10 +230,10 @@ function DevBlueprintArt() {
|
||||
|
||||
return (
|
||||
<svg
|
||||
className="stage-blueprint h-full w-full"
|
||||
className="stage-art stage-blueprint h-full w-full"
|
||||
fill="none"
|
||||
preserveAspectRatio="xMinYMin slice"
|
||||
viewBox={STAGE_BACKDROP_VIEW_BOX}
|
||||
viewBox={compact ? "64 0 8192 96" : STAGE_BACKDROP_VIEW_BOX}
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<defs>
|
||||
@@ -221,9 +246,9 @@ function DevBlueprintArt() {
|
||||
gradientUnits="userSpaceOnUse"
|
||||
spreadMethod="reflect"
|
||||
>
|
||||
<stop style={{ stopColor: "var(--stage-bp-bottom)" }} />
|
||||
<stop offset="0.5" style={{ stopColor: "var(--stage-bp-mid)" }} />
|
||||
<stop offset="1" style={{ stopColor: "var(--stage-bp-top)" }} />
|
||||
<stop style={{ stopColor: "var(--stage-art-bottom)" }} />
|
||||
<stop offset="0.5" style={{ stopColor: "var(--stage-art-mid)" }} />
|
||||
<stop offset="1" style={{ stopColor: "var(--stage-art-top)" }} />
|
||||
</linearGradient>
|
||||
<radialGradient
|
||||
id={glowId}
|
||||
@@ -233,9 +258,13 @@ function DevBlueprintArt() {
|
||||
gradientTransform="translate(216 14) rotate(137) scale(120 84)"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
>
|
||||
<stop stopColor="#D4F6FF" stopOpacity="0.4" />
|
||||
<stop offset="0.52" stopColor="#65C8FF" stopOpacity="0.16" />
|
||||
<stop offset="1" stopColor="#276AF1" stopOpacity="0" />
|
||||
<stop style={{ stopColor: "var(--stage-art-highlight)" }} stopOpacity="0.4" />
|
||||
<stop
|
||||
offset="0.52"
|
||||
style={{ stopColor: "var(--stage-art-secondary)" }}
|
||||
stopOpacity="0.16"
|
||||
/>
|
||||
<stop offset="1" style={{ stopColor: "var(--stage-art-bottom)" }} stopOpacity="0" />
|
||||
</radialGradient>
|
||||
<radialGradient
|
||||
id={celesteGlowId}
|
||||
@@ -245,9 +274,13 @@ function DevBlueprintArt() {
|
||||
gradientTransform="translate(474 44) rotate(166) scale(156 92)"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
>
|
||||
<stop stopColor="#D2FFFF" stopOpacity="0.34" />
|
||||
<stop offset="0.5" stopColor="#48DCF5" stopOpacity="0.18" />
|
||||
<stop offset="1" stopColor="#277EF1" stopOpacity="0" />
|
||||
<stop style={{ stopColor: "var(--stage-art-highlight)" }} stopOpacity="0.34" />
|
||||
<stop
|
||||
offset="0.5"
|
||||
style={{ stopColor: "var(--stage-art-secondary)" }}
|
||||
stopOpacity="0.18"
|
||||
/>
|
||||
<stop offset="1" style={{ stopColor: "var(--stage-art-bottom)" }} stopOpacity="0" />
|
||||
</radialGradient>
|
||||
<radialGradient
|
||||
id={violetGlowId}
|
||||
@@ -257,20 +290,34 @@ function DevBlueprintArt() {
|
||||
gradientTransform="translate(704 18) rotate(145) scale(132 88)"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
>
|
||||
<stop stopColor="#D9D8FF" stopOpacity="0.3" />
|
||||
<stop offset="0.52" stopColor="#7C8BFF" stopOpacity="0.14" />
|
||||
<stop offset="1" stopColor="#3155DF" stopOpacity="0" />
|
||||
<stop style={{ stopColor: "var(--stage-art-highlight)" }} stopOpacity="0.3" />
|
||||
<stop
|
||||
offset="0.52"
|
||||
style={{ stopColor: "var(--stage-art-tertiary)" }}
|
||||
stopOpacity="0.14"
|
||||
/>
|
||||
<stop offset="1" style={{ stopColor: "var(--stage-art-bottom)" }} stopOpacity="0" />
|
||||
</radialGradient>
|
||||
<pattern id={minorGridId} width="8" height="8" patternUnits="userSpaceOnUse">
|
||||
<path d="M8 0H0V8" stroke="#EAF6FF" strokeOpacity="0.14" strokeWidth="0.5" />
|
||||
<path
|
||||
d="M8 0H0V8"
|
||||
style={{ stroke: "var(--stage-art-line)" }}
|
||||
strokeOpacity="0.14"
|
||||
strokeWidth="0.5"
|
||||
/>
|
||||
</pattern>
|
||||
<pattern id={majorGridId} width="32" height="32" patternUnits="userSpaceOnUse">
|
||||
<path d="M32 0H0V32" stroke="#EAF6FF" strokeOpacity="0.26" strokeWidth="0.6" />
|
||||
<path
|
||||
d="M32 0H0V32"
|
||||
style={{ stroke: "var(--stage-art-line)" }}
|
||||
strokeOpacity="0.26"
|
||||
strokeWidth="0.6"
|
||||
/>
|
||||
</pattern>
|
||||
<pattern id={rulerId} width="32" height="6" patternUnits="userSpaceOnUse">
|
||||
<path
|
||||
d="M4 0V2.5M12 0V2.5M20 0V4M28 0V2.5"
|
||||
stroke="#DDF7FF"
|
||||
style={{ stroke: "var(--stage-art-line)" }}
|
||||
strokeOpacity="0.5"
|
||||
strokeWidth="0.5"
|
||||
/>
|
||||
@@ -281,7 +328,12 @@ function DevBlueprintArt() {
|
||||
<rect width="768" height="96" fill={`url(#${violetGlowId})`} />
|
||||
</pattern>
|
||||
<pattern id={annotationsId} width="768" height="96" patternUnits="userSpaceOnUse">
|
||||
<g stroke="#DDF7FF" strokeLinecap="round" strokeOpacity="0.6" strokeWidth="0.7">
|
||||
<g
|
||||
style={{ stroke: "var(--stage-art-line)" }}
|
||||
strokeLinecap="round"
|
||||
strokeOpacity="0.6"
|
||||
strokeWidth="0.7"
|
||||
>
|
||||
<path d="M180 64H264" strokeDasharray="5 4" />
|
||||
<path d="M180 61V67M264 61V67" />
|
||||
<path d="M276 10V44" strokeDasharray="4 4" strokeOpacity="0.5" />
|
||||
@@ -294,7 +346,12 @@ function DevBlueprintArt() {
|
||||
<path d="M590 67V73M724 67V73" strokeOpacity="0.55" />
|
||||
</g>
|
||||
|
||||
<g stroke="#DDF7FF" strokeLinecap="round" strokeOpacity="0.55" strokeWidth="0.6">
|
||||
<g
|
||||
style={{ stroke: "var(--stage-art-line)" }}
|
||||
strokeLinecap="round"
|
||||
strokeOpacity="0.55"
|
||||
strokeWidth="0.6"
|
||||
>
|
||||
<g>
|
||||
<path d="M34 60L38 64M38 60L34 64" />
|
||||
</g>
|
||||
@@ -318,7 +375,7 @@ function DevBlueprintArt() {
|
||||
</g>
|
||||
</g>
|
||||
|
||||
<g stroke="#DDF7FF" strokeOpacity="0.35" strokeWidth="0.6">
|
||||
<g style={{ stroke: "var(--stage-art-line)" }} strokeOpacity="0.35" strokeWidth="0.6">
|
||||
<circle cx="196" cy="38" r="13" strokeDasharray="3.5 4" />
|
||||
<path d="M196 33V43M191 38H201" strokeOpacity="0.6" strokeWidth="0.4" />
|
||||
<circle cx="414" cy="64" r="10" strokeDasharray="2.5 3.5" />
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
import { createElement } from "react";
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
import { describe, expect, it, vi } from "vite-plus/test";
|
||||
import { afterEach, describe, expect, it, vi } from "vite-plus/test";
|
||||
|
||||
const stageArtworkState = vi.hoisted(() => ({
|
||||
mode: "none" as "artwork" | "none",
|
||||
variant: null as "nightly" | "dev" | null,
|
||||
}));
|
||||
|
||||
vi.mock("~/hooks/useSettings", () => ({
|
||||
useEnvironmentIdentificationMode: () => "none",
|
||||
useEnvironmentIdentificationMode: () => stageArtworkState.mode,
|
||||
}));
|
||||
vi.mock("../SidebarStageBackdrop", () => ({
|
||||
StageBackdropButtonArt: () => null,
|
||||
useSidebarStageBackdropVariant: () => null,
|
||||
StageBackdropButtonArt: ({ variant }: { variant: string }) => `stage-${variant}`,
|
||||
useSidebarStageBackdropVariant: (enabled = true) => (enabled ? stageArtworkState.variant : null),
|
||||
}));
|
||||
|
||||
import { ComposerPrimaryActions, formatPendingPrimaryActionLabel } from "./ComposerPrimaryActions";
|
||||
@@ -60,6 +65,32 @@ function renderStandaloneStop() {
|
||||
);
|
||||
}
|
||||
|
||||
function renderSendButton() {
|
||||
return renderToStaticMarkup(
|
||||
createElement(ComposerPrimaryActions, {
|
||||
compact: true,
|
||||
pendingAction: null,
|
||||
isRunning: false,
|
||||
showPlanFollowUpPrompt: false,
|
||||
promptHasText: true,
|
||||
isSendBusy: false,
|
||||
sendDisabledReason: null,
|
||||
isConnecting: false,
|
||||
isEnvironmentUnavailable: false,
|
||||
isPreparingWorktree: false,
|
||||
hasSendableContent: true,
|
||||
onPreviousPendingQuestion: () => {},
|
||||
onInterrupt: () => {},
|
||||
onImplementPlanInNewThread: () => {},
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
afterEach(() => {
|
||||
stageArtworkState.mode = "none";
|
||||
stageArtworkState.variant = null;
|
||||
});
|
||||
|
||||
describe("formatPendingPrimaryActionLabel", () => {
|
||||
it("returns 'Submitting...' while responding", () => {
|
||||
expect(
|
||||
@@ -164,4 +195,24 @@ describe("ComposerPrimaryActions", () => {
|
||||
expect(renderStandaloneStop()).toContain("size-8 sm:h-8 sm:w-8");
|
||||
expect(renderStandaloneStop()).not.toContain("sm:size-7");
|
||||
});
|
||||
|
||||
it("renders stage artwork inside the send button when artwork identification is active", () => {
|
||||
stageArtworkState.mode = "artwork";
|
||||
stageArtworkState.variant = "nightly";
|
||||
|
||||
const markup = renderSendButton();
|
||||
|
||||
expect(markup).toContain("stage-nightly");
|
||||
expect(markup).toContain("bg-transparent text-white");
|
||||
expect(markup).not.toContain("bg-message-action text-message-action-foreground");
|
||||
});
|
||||
|
||||
it("keeps the normal send-button fill when artwork identification is inactive", () => {
|
||||
stageArtworkState.variant = "nightly";
|
||||
|
||||
const markup = renderSendButton();
|
||||
|
||||
expect(markup).not.toContain("stage-nightly");
|
||||
expect(markup).toContain("bg-message-action text-message-action-foreground");
|
||||
});
|
||||
});
|
||||
@@ -1,6 +1,8 @@
|
||||
import { memo, type PointerEventHandler } from "react";
|
||||
import { ChevronDownIcon, ChevronLeftIcon } from "lucide-react";
|
||||
import { useEnvironmentIdentificationMode } from "~/hooks/useSettings";
|
||||
import { cn } from "~/lib/utils";
|
||||
import { StageBackdropButtonArt, useSidebarStageBackdropVariant } from "../SidebarStageBackdrop";
|
||||
import { Button } from "../ui/button";
|
||||
import { Menu, MenuItem, MenuPopup, MenuTrigger } from "../ui/menu";
|
||||
import { Spinner } from "../ui/spinner";
|
||||
@@ -73,7 +75,11 @@ export const ComposerPrimaryActions = memo(function ComposerPrimaryActions({
|
||||
const pointerFocusProps = preserveComposerFocusOnPointerDown
|
||||
? { onPointerDown: preventPointerFocus }
|
||||
: undefined;
|
||||
const environmentIdentificationMode = useEnvironmentIdentificationMode();
|
||||
const isSendDisabled = sendDisabledReason !== null;
|
||||
const stageBackdropVariant = useSidebarStageBackdropVariant(
|
||||
environmentIdentificationMode === "artwork",
|
||||
);
|
||||
|
||||
const renderStopGenerationButton = (insidePendingAction: boolean) => (
|
||||
<button
|
||||
@@ -212,8 +218,10 @@ export const ComposerPrimaryActions = memo(function ComposerPrimaryActions({
|
||||
<button
|
||||
type="submit"
|
||||
className={cn(
|
||||
"relative isolate flex h-9 w-9 items-center justify-center overflow-hidden rounded-full text-message-action-foreground shadow-xs transition-all duration-150 enabled:cursor-pointer enabled:inset-shadow-[0_1px_--theme(--color-white/16%)] hover:scale-105 active:inset-shadow-[0_1px_--theme(--color-black/8%)] active:shadow-none disabled:pointer-events-none disabled:opacity-30 disabled:shadow-none disabled:hover:scale-100 sm:h-8 sm:w-8",
|
||||
"bg-message-action enabled:shadow-message-action/24 hover:bg-message-action-hover",
|
||||
"relative isolate flex h-9 w-9 items-center justify-center overflow-hidden rounded-full shadow-xs transition-all duration-150 enabled:cursor-pointer enabled:inset-shadow-[0_1px_--theme(--color-white/16%)] hover:scale-105 active:inset-shadow-[0_1px_--theme(--color-black/8%)] active:shadow-none disabled:pointer-events-none disabled:opacity-30 disabled:shadow-none disabled:hover:scale-100 sm:h-8 sm:w-8",
|
||||
stageBackdropVariant
|
||||
? "bg-transparent text-white enabled:shadow-black/24 enabled:hover:brightness-110"
|
||||
: "bg-message-action text-message-action-foreground enabled:shadow-message-action/24 hover:bg-message-action-hover",
|
||||
)}
|
||||
{...pointerFocusProps}
|
||||
disabled={
|
||||
@@ -237,6 +245,11 @@ export const ComposerPrimaryActions = memo(function ComposerPrimaryActions({
|
||||
: "Send message"
|
||||
}
|
||||
>
|
||||
{stageBackdropVariant ? (
|
||||
<span className="absolute inset-0 -z-10" aria-hidden="true">
|
||||
<StageBackdropButtonArt variant={stageBackdropVariant} />
|
||||
</span>
|
||||
) : null}
|
||||
{isConnecting || isSendBusy ? (
|
||||
<Spinner className="size-3.5" aria-hidden="true" />
|
||||
) : (
|
||||
|
||||
@@ -165,7 +165,6 @@ export function ThemeEditorPanel({
|
||||
const isEditing = editingTheme !== null;
|
||||
const [name, setName] = useState("");
|
||||
const [activeAppearance, setActiveAppearance] = useState<ThemeAppearance>(initialAppearance);
|
||||
const [sidebarArtwork, setSidebarArtwork] = useState(false);
|
||||
const [isAdvanced, setIsAdvanced] = useState(false);
|
||||
const [colorsByAppearance, setColorsByAppearance] = useState<ThemeEditorColorsByAppearance>(() =>
|
||||
getThemeEditorColorsByAppearance(),
|
||||
@@ -179,7 +178,6 @@ export function ThemeEditorPanel({
|
||||
const [isInspecting, setIsInspecting] = useState(false);
|
||||
const [selectedRole, setSelectedRole] = useState<ThemeColorRole | null>(null);
|
||||
const [usageCount, setUsageCount] = useState<number | null>(null);
|
||||
const previousMergeTargetIdRef = useRef<string | null>(null);
|
||||
// Null parks the panel at its default corner; a value is a dragged spot,
|
||||
// kept clamped so the header can always be grabbed again.
|
||||
const [position, setPosition] = useState<{ x: number; y: number } | null>(null);
|
||||
@@ -230,7 +228,6 @@ export function ThemeEditorPanel({
|
||||
};
|
||||
window.addEventListener("resize", clamp);
|
||||
return () => window.removeEventListener("resize", clamp);
|
||||
// oxlint-disable-next-line exhaustive-deps -- clampPosition reads live layout only.
|
||||
}, [isMinimized, open]);
|
||||
|
||||
// The draft only reaches the live app once this open has been seeded;
|
||||
@@ -261,9 +258,6 @@ export function ThemeEditorPanel({
|
||||
|
||||
setName(editingTheme?.label ?? seedName ?? "");
|
||||
setActiveAppearance(nextAppearance);
|
||||
// Artwork is opt-in for new themes, including duplicates. Editing keeps
|
||||
// the theme's existing choice.
|
||||
setSidebarArtwork(editingTheme?.sidebarArtwork === true);
|
||||
// Themes saved by the guided editor carry the managed flag; anything
|
||||
// else (imports, hand-edited files, older saves) opens in advanced mode
|
||||
// so guided regeneration cannot silently discard hand-tuned colors. A
|
||||
@@ -320,18 +314,6 @@ export function ThemeEditorPanel({
|
||||
// an explanation instead.
|
||||
const mergeTargetId = mergeTarget?.id ?? null;
|
||||
const takenAppearancesKey = takenAppearances.join(",");
|
||||
useEffect(() => {
|
||||
if (previousMergeTargetIdRef.current === mergeTargetId) return;
|
||||
previousMergeTargetIdRef.current = mergeTargetId;
|
||||
// A matching name makes that existing theme the surviving merge target.
|
||||
// Seed theme-level options from it so adding a palette or renaming onto it
|
||||
// does not silently reset them. Leaving the merge restores the edited
|
||||
// theme's option (or the off-by-default choice for a new theme).
|
||||
setSidebarArtwork(
|
||||
mergeTarget ? mergeTarget.sidebarArtwork === true : editingTheme?.sidebarArtwork === true,
|
||||
);
|
||||
}, [editingTheme, mergeTarget, mergeTargetId]);
|
||||
|
||||
useEffect(() => {
|
||||
if (isEditing || mergeTargetId === null) return;
|
||||
const taken = takenAppearancesKey.split(",").filter(Boolean) as ThemeAppearance[];
|
||||
@@ -347,8 +329,8 @@ export function ThemeEditorPanel({
|
||||
// comes back when the editor closes, including on cancel.
|
||||
useEffect(() => {
|
||||
if (!open || !isDraftSeeded) return;
|
||||
applyThemeColorPreview(colorsByAppearance[activeAppearance], activeAppearance, sidebarArtwork);
|
||||
}, [activeAppearance, colorsByAppearance, isDraftSeeded, open, sidebarArtwork]);
|
||||
applyThemeColorPreview(colorsByAppearance[activeAppearance], activeAppearance);
|
||||
}, [activeAppearance, colorsByAppearance, isDraftSeeded, open]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) return;
|
||||
@@ -674,7 +656,6 @@ export function ThemeEditorPanel({
|
||||
...mergeTarget.variants,
|
||||
...Object.fromEntries(editedModes.map((mode) => [mode, colorsForSave[mode]])),
|
||||
},
|
||||
...(sidebarArtwork ? { sidebarArtwork: true } : {}),
|
||||
...(mergeTarget.managed === true && !isAdvanced ? { managed: true } : {}),
|
||||
}),
|
||||
);
|
||||
@@ -705,7 +686,6 @@ export function ThemeEditorPanel({
|
||||
...(getThemeModes(editingTheme).length > 1
|
||||
? { variants: { [variantAppearance]: colorsForSave[variantAppearance] } }
|
||||
: {}),
|
||||
...(sidebarArtwork ? { sidebarArtwork: true } : {}),
|
||||
...(isAdvanced ? {} : { managed: true }),
|
||||
}),
|
||||
);
|
||||
@@ -732,7 +712,6 @@ export function ThemeEditorPanel({
|
||||
...mergeTarget.variants,
|
||||
[activeAppearance]: colorsForSave[activeAppearance],
|
||||
},
|
||||
...(sidebarArtwork ? { sidebarArtwork: true } : {}),
|
||||
...(mergeTarget.managed === true && !isAdvanced ? { managed: true } : {}),
|
||||
}),
|
||||
);
|
||||
@@ -743,7 +722,6 @@ export function ThemeEditorPanel({
|
||||
name,
|
||||
appearance: activeAppearance,
|
||||
colors: colorsForSave[activeAppearance],
|
||||
...(sidebarArtwork ? { sidebarArtwork: true } : {}),
|
||||
...(isAdvanced ? {} : { managed: true }),
|
||||
}),
|
||||
);
|
||||
@@ -794,7 +772,6 @@ export function ThemeEditorPanel({
|
||||
name,
|
||||
onOpenChange,
|
||||
onSaved,
|
||||
sidebarArtwork,
|
||||
simpleColorsDirtyByAppearance,
|
||||
takenAppearances,
|
||||
]);
|
||||
@@ -854,20 +831,6 @@ export function ThemeEditorPanel({
|
||||
</div>
|
||||
);
|
||||
|
||||
const renderSidebarArtworkToggle = () => (
|
||||
<label className="grid cursor-pointer grid-cols-[minmax(0,1fr)_minmax(0,2fr)] items-center gap-3">
|
||||
<span className="text-sm font-medium">Sidebar artwork</span>
|
||||
<span className="flex items-center justify-between gap-3 text-xs text-muted-foreground">
|
||||
<span>Show T3 Code environment artwork</span>
|
||||
<Switch
|
||||
aria-label="Allow sidebar artwork with this theme"
|
||||
checked={sidebarArtwork}
|
||||
onCheckedChange={(checked) => setSidebarArtwork(Boolean(checked))}
|
||||
/>
|
||||
</span>
|
||||
</label>
|
||||
);
|
||||
|
||||
const renderColorsHeader = () => (
|
||||
<div className="grid grid-cols-[minmax(0,1fr)_minmax(0,2fr)] items-start gap-3">
|
||||
<div>
|
||||
@@ -1124,7 +1087,6 @@ export function ThemeEditorPanel({
|
||||
</p>
|
||||
) : null}
|
||||
{renderAppearanceButtons()}
|
||||
{renderSidebarArtworkToggle()}
|
||||
<div className="space-y-3">
|
||||
{renderColorsHeader()}
|
||||
{renderColorFields()}
|
||||
|
||||
@@ -8,6 +8,7 @@ import { usePrimaryEnvironment } from "../../state/environments";
|
||||
import {
|
||||
resolveEnvironmentIdentificationPillLabel,
|
||||
resolveSidebarStageBackdropVariant,
|
||||
resolveSidebarStageFocusRingOffsetClass,
|
||||
SidebarStageBackdrop,
|
||||
useEnvironmentStageLabel,
|
||||
} from "../SidebarStageBackdrop";
|
||||
@@ -52,7 +53,8 @@ export const SidebarChromeHeader = memo(function SidebarChromeHeader({
|
||||
className={cn(
|
||||
"relative z-10 md:hidden",
|
||||
backdropVariant &&
|
||||
"[:hover,[data-pressed]]:bg-white/15 focus-visible:ring-white/90 focus-visible:ring-offset-blue-700 [&_svg]:stroke-white/90! [&_svg]:opacity-100! [&_svg]:hover:stroke-white!",
|
||||
"focus-visible:ring-white/90 [&_svg]:stroke-white/90! [&_svg]:opacity-100! [&_svg]:hover:stroke-white! [:hover,[data-pressed]]:bg-white/15",
|
||||
backdropVariant && resolveSidebarStageFocusRingOffsetClass(backdropVariant),
|
||||
)}
|
||||
/>
|
||||
<SidebarBrand onBackdrop={backdropVariant !== null} />
|
||||
|
||||
@@ -31,6 +31,7 @@ import {
|
||||
getThemePreviewSidebarArtwork,
|
||||
resolveThemeHalf,
|
||||
subscribeToThemePreview,
|
||||
themeAllowsSidebarArtwork,
|
||||
} from "~/themePalette";
|
||||
import * as Struct from "effect/Struct";
|
||||
import { primaryServerSettingsAtom, serverEnvironment } from "~/state/server";
|
||||
@@ -236,8 +237,8 @@ export function resolveEnvironmentIdentificationMode(input: {
|
||||
}): EnvironmentIdentificationMode {
|
||||
// Avoid briefly rendering the default artwork before a persisted pill/none choice loads.
|
||||
if (!input.settingsHydrated) return "none";
|
||||
// Stage artwork has fixed colors that can clash with palette themes. Keep an
|
||||
// explicit "none", but use the theme-aware pill in place of artwork.
|
||||
// Artwork palettes are maintained for built-ins only. Keep an explicit
|
||||
// "none", but use the theme-aware pill for user-controlled palettes.
|
||||
return input.paletteThemeActive && !input.paletteThemeAllowsArtwork && input.mode === "artwork"
|
||||
? "pill"
|
||||
: input.mode;
|
||||
@@ -258,8 +259,7 @@ export function useEnvironmentIdentificationMode(): EnvironmentIdentificationMod
|
||||
mode,
|
||||
settingsHydrated,
|
||||
paletteThemeActive: previewSidebarArtwork !== null || activeThemeDefinition !== null,
|
||||
paletteThemeAllowsArtwork:
|
||||
previewSidebarArtwork ?? activeThemeDefinition?.sidebarArtwork === true,
|
||||
paletteThemeAllowsArtwork: previewSidebarArtwork ?? themeAllowsSidebarArtwork(activeTheme),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+161
-8
@@ -265,6 +265,39 @@ html[data-mobile-composer-route-transition="true"]::view-transition-old(t3-mobil
|
||||
}
|
||||
|
||||
@layer base {
|
||||
:root {
|
||||
/* Dev artwork defaults. Built-in themes override these seven pigments in
|
||||
the components layer; Nightly derives a darker matching palette. */
|
||||
--stage-art-top: #67c2ff;
|
||||
--stage-art-mid: #347ff8;
|
||||
--stage-art-bottom: #1538d0;
|
||||
--stage-art-highlight: #d4f6ff;
|
||||
--stage-art-secondary: #65c8ff;
|
||||
--stage-art-tertiary: #7c8bff;
|
||||
--stage-art-line: #ddf7ff;
|
||||
--stage-night-top: color-mix(in oklch, var(--stage-art-top) 38%, #32155b);
|
||||
--stage-night-mid: color-mix(in oklch, var(--stage-art-mid) 38%, #151443);
|
||||
--stage-night-bottom: color-mix(in oklch, var(--stage-art-bottom) 38%, #07152f);
|
||||
--stage-night-highlight: var(--stage-art-highlight);
|
||||
--stage-night-secondary: color-mix(
|
||||
in oklch,
|
||||
var(--stage-art-secondary) 55%,
|
||||
var(--stage-night-mid)
|
||||
);
|
||||
--stage-night-tertiary: color-mix(
|
||||
in oklch,
|
||||
var(--stage-art-tertiary) 60%,
|
||||
var(--stage-night-top)
|
||||
);
|
||||
--stage-night-line: color-mix(in oklch, var(--stage-art-line) 82%, white);
|
||||
}
|
||||
|
||||
.dark {
|
||||
--stage-art-top: #3a7ad1;
|
||||
--stage-art-mid: #2050ae;
|
||||
--stage-art-bottom: #101f6e;
|
||||
}
|
||||
|
||||
* {
|
||||
@apply border-border outline-ring/50;
|
||||
}
|
||||
@@ -335,16 +368,136 @@ html[data-mobile-composer-route-transition="true"]::view-transition-old(t3-mobil
|
||||
);
|
||||
}
|
||||
|
||||
.stage-blueprint {
|
||||
--stage-bp-top: #67c2ff;
|
||||
--stage-bp-mid: #347ff8;
|
||||
--stage-bp-bottom: #1538d0;
|
||||
/* Each maintainer palette gives the same line art its own material: rose
|
||||
vellum, forest drafting paper, marine cyanotype, copper, and violet ink.
|
||||
These colors stay deliberately deep at the top edge so the white stage
|
||||
wordmark and controls retain contrast in both appearance modes. */
|
||||
html[data-theme-id="t3-chat"] {
|
||||
--stage-art-top: #f28ac1;
|
||||
--stage-art-mid: #cb3e86;
|
||||
--stage-art-bottom: #73194f;
|
||||
--stage-art-highlight: #ffe6f6;
|
||||
--stage-art-secondary: #ff82bc;
|
||||
--stage-art-tertiary: #c67bf1;
|
||||
--stage-art-line: #ffe7f8;
|
||||
}
|
||||
|
||||
.dark .stage-blueprint {
|
||||
--stage-bp-top: #3a7ad1;
|
||||
--stage-bp-mid: #2050ae;
|
||||
--stage-bp-bottom: #101f6e;
|
||||
html.dark[data-theme-id="t3-chat"] {
|
||||
--stage-art-top: #a8467e;
|
||||
--stage-art-mid: #742253;
|
||||
--stage-art-bottom: #390e2d;
|
||||
--stage-art-highlight: #ffd8ee;
|
||||
--stage-art-secondary: #de639e;
|
||||
--stage-art-tertiary: #9c64cf;
|
||||
--stage-art-line: #ffe4f4;
|
||||
}
|
||||
|
||||
html[data-theme-id="grove"] {
|
||||
--stage-art-top: #6cc492;
|
||||
--stage-art-mid: #2d8a5e;
|
||||
--stage-art-bottom: #174a33;
|
||||
--stage-art-highlight: #e4fff0;
|
||||
--stage-art-secondary: #79d8a5;
|
||||
--stage-art-tertiary: #d5b563;
|
||||
--stage-art-line: #eafff2;
|
||||
--stage-night-top: #286548;
|
||||
--stage-night-mid: #174a35;
|
||||
--stage-night-bottom: #0a2c21;
|
||||
--stage-night-highlight: #c4eed5;
|
||||
--stage-night-secondary: #54a878;
|
||||
--stage-night-tertiary: #b79b4d;
|
||||
--stage-night-line: #d7f6e2;
|
||||
}
|
||||
|
||||
html.dark[data-theme-id="grove"] {
|
||||
--stage-art-top: #438e65;
|
||||
--stage-art-mid: #286447;
|
||||
--stage-art-bottom: #123525;
|
||||
--stage-art-highlight: #d2fbe2;
|
||||
--stage-art-secondary: #62bf88;
|
||||
--stage-art-tertiary: #c99b45;
|
||||
--stage-art-line: #e0fae9;
|
||||
--stage-night-top: #24523a;
|
||||
--stage-night-mid: #113323;
|
||||
--stage-night-bottom: #071d16;
|
||||
--stage-night-highlight: #b5dfc4;
|
||||
--stage-night-secondary: #478d66;
|
||||
--stage-night-tertiary: #a9853b;
|
||||
--stage-night-line: #d0ead9;
|
||||
}
|
||||
|
||||
html[data-theme-id="ocean"] {
|
||||
--stage-art-top: #77c9e3;
|
||||
--stage-art-mid: #3384bd;
|
||||
--stage-art-bottom: #174d7a;
|
||||
--stage-art-highlight: #e5faff;
|
||||
--stage-art-secondary: #70c9df;
|
||||
--stage-art-tertiary: #5cc7be;
|
||||
--stage-art-line: #e9fbff;
|
||||
}
|
||||
|
||||
html.dark[data-theme-id="ocean"] {
|
||||
--stage-art-top: #4288ac;
|
||||
--stage-art-mid: #285d84;
|
||||
--stage-art-bottom: #132e49;
|
||||
--stage-art-highlight: #d9f5ff;
|
||||
--stage-art-secondary: #61b5d4;
|
||||
--stage-art-tertiary: #51b8b3;
|
||||
--stage-art-line: #dff7ff;
|
||||
}
|
||||
|
||||
html[data-theme-id="ember"] {
|
||||
--stage-art-top: #f4a26e;
|
||||
--stage-art-mid: #d66036;
|
||||
--stage-art-bottom: #7c291e;
|
||||
--stage-art-highlight: #fff0df;
|
||||
--stage-art-secondary: #ffad77;
|
||||
--stage-art-tertiary: #ef6f69;
|
||||
--stage-art-line: #fff3e7;
|
||||
--stage-night-top: #8a442c;
|
||||
--stage-night-mid: #5c271c;
|
||||
--stage-night-bottom: #32100d;
|
||||
--stage-night-highlight: #ffd6ba;
|
||||
--stage-night-secondary: #cb7148;
|
||||
--stage-night-tertiary: #ad4b45;
|
||||
--stage-night-line: #ffe0c9;
|
||||
}
|
||||
|
||||
html.dark[data-theme-id="ember"] {
|
||||
--stage-art-top: #ba6540;
|
||||
--stage-art-mid: #803a29;
|
||||
--stage-art-bottom: #3c1916;
|
||||
--stage-art-highlight: #ffe1cd;
|
||||
--stage-art-secondary: #e68156;
|
||||
--stage-art-tertiary: #d85b58;
|
||||
--stage-art-line: #ffe8d7;
|
||||
--stage-night-top: #6a3425;
|
||||
--stage-night-mid: #3e1b15;
|
||||
--stage-night-bottom: #1d0d0b;
|
||||
--stage-night-highlight: #efc4a9;
|
||||
--stage-night-secondary: #a85e3f;
|
||||
--stage-night-tertiary: #8f413e;
|
||||
--stage-night-line: #f2d2bc;
|
||||
}
|
||||
|
||||
html[data-theme-id="iris"] {
|
||||
--stage-art-top: #b49ae8;
|
||||
--stage-art-mid: #7a5ac4;
|
||||
--stage-art-bottom: #422d80;
|
||||
--stage-art-highlight: #f2eaff;
|
||||
--stage-art-secondary: #b79af1;
|
||||
--stage-art-tertiary: #ec79c7;
|
||||
--stage-art-line: #f6eeff;
|
||||
}
|
||||
|
||||
html.dark[data-theme-id="iris"] {
|
||||
--stage-art-top: #8063c4;
|
||||
--stage-art-mid: #513990;
|
||||
--stage-art-bottom: #261c53;
|
||||
--stage-art-highlight: #e8ddff;
|
||||
--stage-art-secondary: #9e83dc;
|
||||
--stage-art-tertiary: #d96ab7;
|
||||
--stage-art-line: #eee7ff;
|
||||
}
|
||||
|
||||
.workspace-topbar {
|
||||
|
||||
@@ -20,6 +20,7 @@ import {
|
||||
serializeThemeFile,
|
||||
subscribeToThemePreview,
|
||||
subscribeToCustomThemes,
|
||||
themeAllowsSidebarArtwork,
|
||||
T3_CHAT_THEME,
|
||||
EMBER_THEME,
|
||||
GROVE_THEME,
|
||||
@@ -206,14 +207,8 @@ describe("theme files", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps sidebar artwork opt-in through theme files", () => {
|
||||
const withoutArtwork = parseThemeFile({
|
||||
version: THEME_FILE_VERSION,
|
||||
name: "Plain sidebar",
|
||||
appearance: "light",
|
||||
colors: { accent: "#5b6cff" },
|
||||
});
|
||||
const withArtwork = parseThemeFile({
|
||||
it("keeps sidebar artwork disabled for custom theme files", () => {
|
||||
const theme = parseThemeFile({
|
||||
version: THEME_FILE_VERSION,
|
||||
name: "Art sidebar",
|
||||
appearance: "light",
|
||||
@@ -221,12 +216,11 @@ describe("theme files", () => {
|
||||
sidebarArtwork: true,
|
||||
});
|
||||
|
||||
expect(withoutArtwork.sidebarArtwork).toBeUndefined();
|
||||
expect(withArtwork.sidebarArtwork).toBe(true);
|
||||
expect(JSON.parse(serializeThemeFile(withArtwork)).sidebarArtwork).toBe(true);
|
||||
expect(theme.sidebarArtwork).toBeUndefined();
|
||||
expect(JSON.parse(serializeThemeFile(theme))).not.toHaveProperty("sidebarArtwork");
|
||||
});
|
||||
|
||||
it("publishes sidebar artwork changes from the live theme preview", () => {
|
||||
it("suppresses sidebar artwork during a live custom-theme preview", () => {
|
||||
const listener = vi.fn();
|
||||
const unsubscribe = subscribeToThemePreview(listener);
|
||||
vi.stubGlobal("document", {
|
||||
@@ -237,8 +231,8 @@ describe("theme files", () => {
|
||||
},
|
||||
});
|
||||
|
||||
applyThemeColorPreview(T3_CHAT_THEME.colors, "light", true);
|
||||
expect(getThemePreviewSidebarArtwork()).toBe(true);
|
||||
applyThemeColorPreview(T3_CHAT_THEME.colors, "light");
|
||||
expect(getThemePreviewSidebarArtwork()).toBe(false);
|
||||
expect(listener).toHaveBeenCalledTimes(1);
|
||||
|
||||
applyThemePalette("system");
|
||||
@@ -325,6 +319,8 @@ describe("theme files", () => {
|
||||
for (const theme of [T3_CHAT_THEME, GROVE_THEME, OCEAN_THEME, EMBER_THEME, IRIS_THEME]) {
|
||||
expect(getThemeDefinition(theme.id)).toBe(theme);
|
||||
expect(getThemeModes(theme)).toEqual(["light", "dark"]);
|
||||
expect(theme.sidebarArtwork).toBe(true);
|
||||
expect(themeAllowsSidebarArtwork(theme.id)).toBe(true);
|
||||
expect(theme.colors.accent).toMatch(/^#[0-9a-f]{6}$/i);
|
||||
expect(theme.variants?.dark?.accent).toMatch(/^#[0-9a-f]{6}$/i);
|
||||
|
||||
@@ -359,6 +355,7 @@ describe("theme files", () => {
|
||||
);
|
||||
}
|
||||
}
|
||||
expect(themeAllowsSidebarArtwork("my-custom-theme")).toBe(false);
|
||||
});
|
||||
|
||||
it("rejects a variant that repeats the base appearance", () => {
|
||||
@@ -451,15 +448,17 @@ describe("theme files", () => {
|
||||
expect(updatedTheme).toMatchObject({
|
||||
id: "aurora",
|
||||
label: "Aurora Night",
|
||||
sidebarArtwork: true,
|
||||
});
|
||||
expect(updatedTheme).not.toHaveProperty("sidebarArtwork");
|
||||
invalidateCustomThemes();
|
||||
expect(getCustomThemes()).toEqual([updatedTheme]);
|
||||
expect(JSON.parse(stored.get(CUSTOM_THEMES_STORAGE_KEY) ?? "[]")[0]).toMatchObject({
|
||||
id: "aurora",
|
||||
label: "Aurora Night",
|
||||
sidebarArtwork: true,
|
||||
});
|
||||
expect(JSON.parse(stored.get(CUSTOM_THEMES_STORAGE_KEY) ?? "[]")[0]).not.toHaveProperty(
|
||||
"sidebarArtwork",
|
||||
);
|
||||
|
||||
vi.unstubAllGlobals();
|
||||
invalidateCustomThemes();
|
||||
|
||||
@@ -96,7 +96,7 @@ export type ThemeDefinition = Readonly<{
|
||||
appearance: ThemeAppearance;
|
||||
colors: ThemeColors;
|
||||
variants?: ThemeVariants;
|
||||
/** Allows fixed Dev/Nightly artwork to render over this theme's sidebar. */
|
||||
/** Allows Dev/Nightly artwork to render over a maintainer-controlled sidebar. */
|
||||
sidebarArtwork?: boolean;
|
||||
/** True when the palette was generated by the guided editor from its
|
||||
* canvas and accent; such themes reopen in guided mode. */
|
||||
@@ -109,7 +109,6 @@ export type ThemeFile = Readonly<{
|
||||
appearance: ThemeAppearance;
|
||||
colors: ThemeColorOverrides;
|
||||
variants?: ThemeVariantOverrides;
|
||||
sidebarArtwork?: boolean;
|
||||
managed?: boolean;
|
||||
}>;
|
||||
|
||||
@@ -223,7 +222,6 @@ function parseStoredTheme(value: unknown): ThemeDefinition | null {
|
||||
appearance: value.appearance,
|
||||
colors,
|
||||
...(variants ? { variants } : {}),
|
||||
...(value.sidebarArtwork === true ? { sidebarArtwork: true } : {}),
|
||||
...(value.managed === true ? { managed: true } : {}),
|
||||
};
|
||||
}
|
||||
@@ -1299,6 +1297,7 @@ export const T3_CHAT_THEME: ThemeDefinition = {
|
||||
variants: {
|
||||
dark: T3_CHAT_DARK_COLORS,
|
||||
},
|
||||
sidebarArtwork: true,
|
||||
};
|
||||
|
||||
/** Theme-file defaults follow the flagship palette for the requested mode. */
|
||||
@@ -1341,6 +1340,7 @@ export const GROVE_THEME: ThemeDefinition = {
|
||||
...themeActionColors("#e3b34e"),
|
||||
},
|
||||
},
|
||||
sidebarArtwork: true,
|
||||
};
|
||||
|
||||
export const OCEAN_THEME: ThemeDefinition = {
|
||||
@@ -1357,6 +1357,7 @@ export const OCEAN_THEME: ThemeDefinition = {
|
||||
...themeActionColors("#5bd0d6"),
|
||||
},
|
||||
},
|
||||
sidebarArtwork: true,
|
||||
};
|
||||
|
||||
export const EMBER_THEME: ThemeDefinition = {
|
||||
@@ -1373,6 +1374,7 @@ export const EMBER_THEME: ThemeDefinition = {
|
||||
...themeActionColors("#f78a7a"),
|
||||
},
|
||||
},
|
||||
sidebarArtwork: true,
|
||||
};
|
||||
|
||||
export const IRIS_THEME: ThemeDefinition = {
|
||||
@@ -1389,6 +1391,7 @@ export const IRIS_THEME: ThemeDefinition = {
|
||||
...themeActionColors("#f099d8"),
|
||||
},
|
||||
},
|
||||
sidebarArtwork: true,
|
||||
};
|
||||
|
||||
const BUILT_IN_THEME_DEFINITIONS: ReadonlyArray<ThemeDefinition> = [
|
||||
@@ -1408,6 +1411,15 @@ export function getThemeDefinition(theme: ThemePreference): ThemeDefinition | nu
|
||||
);
|
||||
}
|
||||
|
||||
/** Artwork palettes are reviewed alongside built-ins; user themes always use the pill fallback. */
|
||||
export function themeAllowsSidebarArtwork(theme: ThemePreference): boolean {
|
||||
const themeId = themeIdFromPreference(theme);
|
||||
return (
|
||||
BUILT_IN_THEME_DEFINITIONS.find((definition) => definition.id === themeId)?.sidebarArtwork ===
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
export function getThemeColorsForMode(
|
||||
theme: ThemeDefinition,
|
||||
mode: ThemeAppearance,
|
||||
@@ -1569,7 +1581,6 @@ export function parseThemeFile(value: unknown): ThemeDefinition {
|
||||
appearance,
|
||||
colors: { ...fallback, ...overrides },
|
||||
...(Object.keys(variants).length > 0 ? { variants } : {}),
|
||||
...(value.sidebarArtwork === true ? { sidebarArtwork: true } : {}),
|
||||
...(value.managed === true ? { managed: true } : {}),
|
||||
};
|
||||
}
|
||||
@@ -1582,7 +1593,6 @@ export function serializeThemeFile(theme: ThemeDefinition): string {
|
||||
appearance: theme.appearance,
|
||||
colors: theme.colors,
|
||||
...(theme.variants ? { variants: theme.variants } : {}),
|
||||
...(theme.sidebarArtwork ? { sidebarArtwork: true } : {}),
|
||||
...(theme.managed ? { managed: true } : {}),
|
||||
};
|
||||
return `${JSON.stringify(file, null, 2)}\n`;
|
||||
@@ -1660,16 +1670,14 @@ export const THEME_PREVIEW_ID = "__preview";
|
||||
* can be judged against the real interface instead of a miniature. Callers
|
||||
* restore the stored theme (refreshTheme) when the draft goes away.
|
||||
*/
|
||||
export function applyThemeColorPreview(
|
||||
colors: ThemeColors,
|
||||
appearance: ThemeAppearance,
|
||||
sidebarArtwork = false,
|
||||
): void {
|
||||
export function applyThemeColorPreview(colors: ThemeColors, appearance: ThemeAppearance): void {
|
||||
if (typeof document === "undefined") return;
|
||||
const root = document.documentElement;
|
||||
if (!root?.style) return;
|
||||
|
||||
setThemePreviewSidebarArtwork(sidebarArtwork);
|
||||
// Drafts become user-controlled themes when saved, so their preview keeps
|
||||
// the fixed stage artwork hidden even when it was seeded from a built-in.
|
||||
setThemePreviewSidebarArtwork(false);
|
||||
root.dataset.themeId = THEME_PREVIEW_ID;
|
||||
root.classList.toggle("dark", appearance === "dark");
|
||||
for (const [role, value] of Object.entries(colors) as Array<[ThemeColorRole, string]>) {
|
||||
|
||||
@@ -11,3 +11,10 @@ other connected devices.
|
||||
If reordering is unavailable for one environment, update the T3 Code server running in that
|
||||
environment. Older servers can still pin and unpin threads, but do not understand synced ordering;
|
||||
their pinned threads keep the default newest-first order below the ones you have arranged.
|
||||
|
||||
## Environment artwork
|
||||
|
||||
Dev and Nightly environments can identify themselves with artwork at the top of the sidebar and in
|
||||
the send button. Choose **Artwork**, **Version pill**, or **None** in Settings under environment
|
||||
identification. Artwork is recolored to match each built-in theme. Custom themes use the **Version
|
||||
pill** fallback because their colors are not controlled by T3 Code.
|
||||
Reference in new issue
Block a user