Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions apps/web/src/components/Icons.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -700,25 +700,16 @@ export const ACPRegistryIcon: Icon = ({ className, ...props }) => (
export const MtModelIcon: Icon = ({ className, ...props }) => (
<svg
{...props}
viewBox="0 0 24 24"
viewBox="0 0 128 128"
fill="none"
className={cn("stroke-current", className)}
className={cn("fill-current", className)}
aria-hidden
>
{/* The Munim mark, same path the app icon draws. */}
<path
d="M12 3.2 13.7 8.3 19 10l-5.3 1.7L12 16.8l-1.7-5.1L5 10l5.3-1.7L12 3.2Z"
strokeWidth="1.7"
strokeLinejoin="round"
/>
<path
d="M18.2 15.4 19 17.8 21.4 18.6 19 19.4 18.2 21.8 17.4 19.4 15 18.6 17.4 17.8 18.2 15.4Z"
strokeWidth="1.4"
strokeLinejoin="round"
/>
<path
d="M5.4 14.8 6 16.6 7.8 17.2 6 17.8 5.4 19.6 4.8 17.8 3 17.2 4.8 16.6 5.4 14.8Z"
strokeWidth="1.4"
strokeLinejoin="round"
d="M52.547 87.884L52.710 88.313L51.914 88.231L-0.000 603.926L105.522 614.537L135.846 313.360L180.699 434.810L181.210 439.258L182.291 439.136L184.066 443.911L265.794 413.732L273.569 383.736L293.716 313.043L312.994 481.660L219.104 524.021L180.964 657.000L668.780 436.993L668.189 435.670L631.008 110.432L725.000 105.249L719.204 0.000L419.046 16.549L424.862 121.797L525.037 116.268L554.382 372.820L413.312 436.422L366.622 27.955L262.488 39.871L262.937 43.850L212.900 219.495L150.865 51.563Z"
fillRule="nonzero"
transform="translate(22.067 26.000) scale(0.115677)"
/>
</svg>
);
Expand Down
64 changes: 52 additions & 12 deletions apps/web/src/components/SidebarStageBackdrop.test.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,10 @@ import { describe, expect, it } from "vite-plus/test";
import { renderToStaticMarkup } from "react-dom/server";

import {
DEV_BACKDROP,
NIGHTLY_BACKDROP,
resolveEnvironmentIdentificationPillLabel,
resolveSidebarArtwork,
resolveSidebarStageBackdropVariant,
resolveSidebarStageFocusRingOffsetClass,
StageBackdropArt,
Expand All@@ -11,8 +14,8 @@ import {

describe("SidebarStageBackdrop", () => {
it("resolves stage artwork only when enabled", () => {
expect(resolveSidebarStageBackdropVariant("Dev")).toBe("dev");
expect(resolveSidebarStageBackdropVariant("Nightly")).toBe("nightly");
expect(resolveSidebarStageBackdropVariant("Dev")).toEqual(DEV_BACKDROP);
expect(resolveSidebarStageBackdropVariant("Nightly")).toEqual(NIGHTLY_BACKDROP);
expect(resolveSidebarStageBackdropVariant("Dev", false)).toBeNull();
expect(resolveSidebarStageBackdropVariant("Alpha")).toBeNull();
});
Expand All@@ -25,16 +28,16 @@ describe("SidebarStageBackdrop", () => {
});

it("matches the focus-ring offset to each artwork palette", () => {
expect(resolveSidebarStageFocusRingOffsetClass("nightly")).toBe(
expect(resolveSidebarStageFocusRingOffsetClass(NIGHTLY_BACKDROP)).toBe(
"focus-visible:ring-offset-(--stage-night-bottom)",
);
expect(resolveSidebarStageFocusRingOffsetClass("dev")).toBe(
expect(resolveSidebarStageFocusRingOffsetClass(DEV_BACKDROP)).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",
it.each([NIGHTLY_BACKDROP, DEV_BACKDROP] as const)(
"uses unique SVG definition ids when $kind artwork is rendered more than once",
(variant) => {
const markup = renderToStaticMarkup(
<>
Expand All@@ -50,8 +53,8 @@ describe("SidebarStageBackdrop", () => {
);

it("paints each artwork variant with theme-owned color tokens", () => {
const nightlyMarkup = renderToStaticMarkup(<StageBackdropArt variant="nightly" />);
const devMarkup = renderToStaticMarkup(<StageBackdropArt variant="dev" />);
const nightlyMarkup = renderToStaticMarkup(<StageBackdropArt variant={NIGHTLY_BACKDROP} />);
const devMarkup = renderToStaticMarkup(<StageBackdropArt variant={DEV_BACKDROP} />);

expect(nightlyMarkup).toContain("var(--stage-night-bottom)");
expect(nightlyMarkup).toContain("var(--stage-night-line)");
Expand All@@ -62,12 +65,49 @@ describe("SidebarStageBackdrop", () => {
});

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) => {
[NIGHTLY_BACKDROP, "96 0 8192 96"],
[DEV_BACKDROP, "64 0 8192 96"],
] as const)("uses the compact 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"}`);
expect(markup).toContain(`stage-${variant.kind === "dev" ? "blueprint" : "nightly"}`);
});
});

describe("resolveSidebarArtwork", () => {
const custom = [{ id: "art_1", name: "Skyline", image: "data:image/png;base64,AAAA" }];

it("defers to the build channel only for auto", () => {
expect(resolveSidebarArtwork({ selection: "auto", stageLabel: "Nightly", custom })).toEqual(
NIGHTLY_BACKDROP,
);
// A release build has no channel artwork, which is why picking one matters.
expect(resolveSidebarArtwork({ selection: "auto", stageLabel: "", custom })).toBeNull();
});

it("honours an explicit pick regardless of channel", () => {
expect(resolveSidebarArtwork({ selection: "night", stageLabel: "", custom })).toEqual(
NIGHTLY_BACKDROP,
);
expect(resolveSidebarArtwork({ selection: "day", stageLabel: "Nightly", custom })).toEqual(
DEV_BACKDROP,
);
expect(resolveSidebarArtwork({ selection: "none", stageLabel: "Nightly", custom })).toBeNull();
});

it("renders the account's own artwork, and nothing once it is deleted", () => {
expect(resolveSidebarArtwork({ selection: "art_1", stageLabel: "", custom })).toEqual({
kind: "custom",
image: custom[0]!.image,
name: custom[0]!.name,
});
expect(resolveSidebarArtwork({ selection: "art_1", stageLabel: "", custom: [] })).toBeNull();
});

it("stays out of the way when artwork is switched off entirely", () => {
expect(
resolveSidebarArtwork({ selection: "night", stageLabel: "", custom, enabled: false }),
).toBeNull();
});
});
79 changes: 72 additions & 7 deletions apps/web/src/components/SidebarStageBackdrop.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,10 +4,44 @@ import { useId } from "react";
import { APP_HAS_UPDATE_TRACKS, APP_STAGE_LABEL } from "../branding";
import { resolveServerBackedAppStageLabel } from "../branding.logic";
import { primaryServerConfigAtom } from "../state/server";
import { usePrimarySettings } from "../hooks/useSettings";

export type SidebarStageBackdropVariant = "nightly" | "dev";
export type SidebarStageBackdropVariant =
| { readonly kind: "nightly" }
| { readonly kind: "dev" }
| { readonly kind: "custom"; readonly image: string; readonly name: string };
export type EnvironmentIdentificationPillLabel = "Dev" | "Nightly";

export const NIGHTLY_BACKDROP: SidebarStageBackdropVariant = { kind: "nightly" };
export const DEV_BACKDROP: SidebarStageBackdropVariant = { kind: "dev" };

/**
* Resolve the artwork to draw from the account's choice.
*
* "auto" defers to the build channel the way upstream does; every other value
* is a deliberate pick and ignores the channel entirely, which is the point on
* a single-release build like MT Code.
*/
export function resolveSidebarArtwork(input: {
readonly selection: string;
readonly stageLabel: string;
readonly custom: ReadonlyArray<{ readonly id: string; readonly name: string; readonly image: string }>;
readonly enabled?: boolean;
}): SidebarStageBackdropVariant | null {
if (input.enabled === false) return null;
const selection = input.selection.trim();
if (selection === "none") return null;
if (selection === "night") return NIGHTLY_BACKDROP;
if (selection === "day") return DEV_BACKDROP;
if (selection !== "auto" && selection.length > 0) {
const artwork = input.custom.find((entry) => entry.id === selection);
// A deleted artwork leaves the header bare rather than silently falling
// back to a scene the user did not choose.
return artwork ? { kind: "custom", image: artwork.image, name: artwork.name } : null;
}
return resolveSidebarStageBackdropVariant(input.stageLabel);
}

// A wide viewBox keeps the 96-unit art height at a fixed scale while sidebar resizing reveals
// more horizontal canvas instead of zooming the scene.
const STAGE_BACKDROP_VIEW_BOX = "0 0 8192 96";
Expand All@@ -18,15 +52,15 @@ export function resolveSidebarStageBackdropVariant(
): SidebarStageBackdropVariant | null {
if (!enabled) return null;
const normalized = stageLabel.trim().toLowerCase();
if (normalized === "nightly") return "nightly";
if (normalized === "dev") return "dev";
if (normalized === "nightly") return NIGHTLY_BACKDROP;
if (normalized === "dev") return DEV_BACKDROP;
return null;
}

export function resolveSidebarStageFocusRingOffsetClass(
variant: SidebarStageBackdropVariant,
): string {
return variant === "nightly"
return variant.kind === "nightly"
? "focus-visible:ring-offset-(--stage-night-bottom)"
: "focus-visible:ring-offset-(--stage-art-bottom)";
}
Expand All@@ -52,7 +86,17 @@ export function useEnvironmentStageLabel(): string {
}

export function useSidebarStageBackdropVariant(enabled = true): SidebarStageBackdropVariant | null {
return resolveSidebarStageBackdropVariant(useEnvironmentStageLabel(), enabled);
const stageLabel = useEnvironmentStageLabel();
const artwork = usePrimarySettings((settings) => ({
selection: settings.sidebarArtwork,
custom: settings.customSidebarArtworks,
}));
return resolveSidebarArtwork({
selection: artwork.selection,
stageLabel,
custom: artwork.custom,
enabled,
});
}

/** Stage-channel header art; palettes mirror the per-channel app icons in `assets/`. */
Expand All@@ -68,11 +112,32 @@ export function SidebarStageBackdrop({ variant }: { variant: SidebarStageBackdro
}

export function StageBackdropArt({ variant }: { variant: SidebarStageBackdropVariant }) {
return variant === "nightly" ? <NightlySkyArt /> : <DevBlueprintArt />;
if (variant.kind === "custom") return <CustomArt variant={variant} />;
return variant.kind === "nightly" ? <NightlySkyArt /> : <DevBlueprintArt />;
}

export function StageBackdropButtonArt({ variant }: { variant: SidebarStageBackdropVariant }) {
return variant === "nightly" ? <NightlySkyArt compact /> : <DevBlueprintArt compact />;
if (variant.kind === "custom") return <CustomArt variant={variant} />;
return variant.kind === "nightly" ? <NightlySkyArt compact /> : <DevBlueprintArt compact />;
}

/**
* A user's own artwork. Drawn as a cover-cropped band so any aspect ratio
* fills the header the way the built-in scenes do.
*/
function CustomArt({
variant,
}: {
variant: Extract<SidebarStageBackdropVariant, { kind: "custom" }>;
}) {
return (
<div
role="img"
aria-label={variant.name}
className="stage-art h-full w-full bg-cover bg-center bg-no-repeat"
style={{ backgroundImage: `url(${JSON.stringify(variant.image)})` }}
/>
);
}

const NIGHTLY_STARS: ReadonlyArray<{
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,6 +16,8 @@ import { toastManager } from "../ui/toast.tsx";
import { SettingsRow, SettingsSection } from "./settingsLayout.tsx";
import { searchableSetting } from "./settingsSearch.ts";

import { APP_DISPLAY_NAME } from "~/branding";

const EVENT_OPTIONS: ReadonlyArray<{
readonly event: DesktopNotificationEvent;
readonly title: string;
Expand DownExpand Up@@ -158,14 +160,14 @@ function useDesktopNotificationSettingsModel() {
};

const masterDescription = isElectron
? "Notify me when T3 Code is in the background."
? `Notify me when ${APP_DISPLAY_NAME} is in the background.`
: browserPermission.permission === "denied"
? "Blocked in your browser settings."
: browserPermission.permission === "unsupported"
? "Not supported by this browser."
: browserPermission.permission === "default"
? "Allow notifications when T3 Code is in the background."
: "Notify me when T3 Code is in the background.";
? `Allow notifications when ${APP_DISPLAY_NAME} is in the background.`
: `Notify me when ${APP_DISPLAY_NAME} is in the background.`;

return {
settings,
Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions apps/web/src/components/Icons.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -700,25 +700,16 @@ export const ACPRegistryIcon: Icon = ({ className, ...props }) => (
export const MtModelIcon: Icon = ({ className, ...props }) => (
<svg
{...props}
viewBox="0 0 24 24"
viewBox="0 0 128 128"
fill="none"
className={cn("stroke-current", className)}
className={cn("fill-current", className)}
aria-hidden
>
{/* The Munim mark, same path the app icon draws. */}
<path
d="M12 3.2 13.7 8.3 19 10l-5.3 1.7L12 16.8l-1.7-5.1L5 10l5.3-1.7L12 3.2Z"
strokeWidth="1.7"
strokeLinejoin="round"
/>
<path
d="M18.2 15.4 19 17.8 21.4 18.6 19 19.4 18.2 21.8 17.4 19.4 15 18.6 17.4 17.8 18.2 15.4Z"
strokeWidth="1.4"
strokeLinejoin="round"
/>
<path
d="M5.4 14.8 6 16.6 7.8 17.2 6 17.8 5.4 19.6 4.8 17.8 3 17.2 4.8 16.6 5.4 14.8Z"
strokeWidth="1.4"
strokeLinejoin="round"
d="M52.547 87.884L52.710 88.313L51.914 88.231L-0.000 603.926L105.522 614.537L135.846 313.360L180.699 434.810L181.210 439.258L182.291 439.136L184.066 443.911L265.794 413.732L273.569 383.736L293.716 313.043L312.994 481.660L219.104 524.021L180.964 657.000L668.780 436.993L668.189 435.670L631.008 110.432L725.000 105.249L719.204 0.000L419.046 16.549L424.862 121.797L525.037 116.268L554.382 372.820L413.312 436.422L366.622 27.955L262.488 39.871L262.937 43.850L212.900 219.495L150.865 51.563Z"
fillRule="nonzero"
transform="translate(22.067 26.000) scale(0.115677)"
/>
</svg>
);
Expand Down
64 changes: 52 additions & 12 deletions apps/web/src/components/SidebarStageBackdrop.test.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,10 @@ import { describe, expect, it } from "vite-plus/test";
import { renderToStaticMarkup } from "react-dom/server";

import {
DEV_BACKDROP,
NIGHTLY_BACKDROP,
resolveEnvironmentIdentificationPillLabel,
resolveSidebarArtwork,
resolveSidebarStageBackdropVariant,
resolveSidebarStageFocusRingOffsetClass,
StageBackdropArt,
Expand All@@ -11,8 +14,8 @@ import {

describe("SidebarStageBackdrop", () => {
it("resolves stage artwork only when enabled", () => {
expect(resolveSidebarStageBackdropVariant("Dev")).toBe("dev");
expect(resolveSidebarStageBackdropVariant("Nightly")).toBe("nightly");
expect(resolveSidebarStageBackdropVariant("Dev")).toEqual(DEV_BACKDROP);
expect(resolveSidebarStageBackdropVariant("Nightly")).toEqual(NIGHTLY_BACKDROP);
expect(resolveSidebarStageBackdropVariant("Dev", false)).toBeNull();
expect(resolveSidebarStageBackdropVariant("Alpha")).toBeNull();
});
Expand All@@ -25,16 +28,16 @@ describe("SidebarStageBackdrop", () => {
});

it("matches the focus-ring offset to each artwork palette", () => {
expect(resolveSidebarStageFocusRingOffsetClass("nightly")).toBe(
expect(resolveSidebarStageFocusRingOffsetClass(NIGHTLY_BACKDROP)).toBe(
"focus-visible:ring-offset-(--stage-night-bottom)",
);
expect(resolveSidebarStageFocusRingOffsetClass("dev")).toBe(
expect(resolveSidebarStageFocusRingOffsetClass(DEV_BACKDROP)).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",
it.each([NIGHTLY_BACKDROP, DEV_BACKDROP] as const)(
"uses unique SVG definition ids when $kind artwork is rendered more than once",
(variant) => {
const markup = renderToStaticMarkup(
<>
Expand All@@ -50,8 +53,8 @@ describe("SidebarStageBackdrop", () => {
);

it("paints each artwork variant with theme-owned color tokens", () => {
const nightlyMarkup = renderToStaticMarkup(<StageBackdropArt variant="nightly" />);
const devMarkup = renderToStaticMarkup(<StageBackdropArt variant="dev" />);
const nightlyMarkup = renderToStaticMarkup(<StageBackdropArt variant={NIGHTLY_BACKDROP} />);
const devMarkup = renderToStaticMarkup(<StageBackdropArt variant={DEV_BACKDROP} />);

expect(nightlyMarkup).toContain("var(--stage-night-bottom)");
expect(nightlyMarkup).toContain("var(--stage-night-line)");
Expand All@@ -62,12 +65,49 @@ describe("SidebarStageBackdrop", () => {
});

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) => {
[NIGHTLY_BACKDROP, "96 0 8192 96"],
[DEV_BACKDROP, "64 0 8192 96"],
] as const)("uses the compact 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"}`);
expect(markup).toContain(`stage-${variant.kind === "dev" ? "blueprint" : "nightly"}`);
});
});

describe("resolveSidebarArtwork", () => {
const custom = [{ id: "art_1", name: "Skyline", image: "data:image/png;base64,AAAA" }];

it("defers to the build channel only for auto", () => {
expect(resolveSidebarArtwork({ selection: "auto", stageLabel: "Nightly", custom })).toEqual(
NIGHTLY_BACKDROP,
);
// A release build has no channel artwork, which is why picking one matters.
expect(resolveSidebarArtwork({ selection: "auto", stageLabel: "", custom })).toBeNull();
});

it("honours an explicit pick regardless of channel", () => {
expect(resolveSidebarArtwork({ selection: "night", stageLabel: "", custom })).toEqual(
NIGHTLY_BACKDROP,
);
expect(resolveSidebarArtwork({ selection: "day", stageLabel: "Nightly", custom })).toEqual(
DEV_BACKDROP,
);
expect(resolveSidebarArtwork({ selection: "none", stageLabel: "Nightly", custom })).toBeNull();
});

it("renders the account's own artwork, and nothing once it is deleted", () => {
expect(resolveSidebarArtwork({ selection: "art_1", stageLabel: "", custom })).toEqual({
kind: "custom",
image: custom[0]!.image,
name: custom[0]!.name,
});
expect(resolveSidebarArtwork({ selection: "art_1", stageLabel: "", custom: [] })).toBeNull();
});

it("stays out of the way when artwork is switched off entirely", () => {
expect(
resolveSidebarArtwork({ selection: "night", stageLabel: "", custom, enabled: false }),
).toBeNull();
});
});
79 changes: 72 additions & 7 deletions apps/web/src/components/SidebarStageBackdrop.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,10 +4,44 @@ import { useId } from "react";
import { APP_HAS_UPDATE_TRACKS, APP_STAGE_LABEL } from "../branding";
import { resolveServerBackedAppStageLabel } from "../branding.logic";
import { primaryServerConfigAtom } from "../state/server";
import { usePrimarySettings } from "../hooks/useSettings";

export type SidebarStageBackdropVariant = "nightly" | "dev";
export type SidebarStageBackdropVariant =
| { readonly kind: "nightly" }
| { readonly kind: "dev" }
| { readonly kind: "custom"; readonly image: string; readonly name: string };
export type EnvironmentIdentificationPillLabel = "Dev" | "Nightly";

export const NIGHTLY_BACKDROP: SidebarStageBackdropVariant = { kind: "nightly" };
export const DEV_BACKDROP: SidebarStageBackdropVariant = { kind: "dev" };

/**
* Resolve the artwork to draw from the account's choice.
*
* "auto" defers to the build channel the way upstream does; every other value
* is a deliberate pick and ignores the channel entirely, which is the point on
* a single-release build like MT Code.
*/
export function resolveSidebarArtwork(input: {
readonly selection: string;
readonly stageLabel: string;
readonly custom: ReadonlyArray<{ readonly id: string; readonly name: string; readonly image: string }>;
readonly enabled?: boolean;
}): SidebarStageBackdropVariant | null {
if (input.enabled === false) return null;
const selection = input.selection.trim();
if (selection === "none") return null;
if (selection === "night") return NIGHTLY_BACKDROP;
if (selection === "day") return DEV_BACKDROP;
if (selection !== "auto" && selection.length > 0) {
const artwork = input.custom.find((entry) => entry.id === selection);
// A deleted artwork leaves the header bare rather than silently falling
// back to a scene the user did not choose.
return artwork ? { kind: "custom", image: artwork.image, name: artwork.name } : null;
}
return resolveSidebarStageBackdropVariant(input.stageLabel);
}

// A wide viewBox keeps the 96-unit art height at a fixed scale while sidebar resizing reveals
// more horizontal canvas instead of zooming the scene.
const STAGE_BACKDROP_VIEW_BOX = "0 0 8192 96";
Expand All@@ -18,15 +52,15 @@ export function resolveSidebarStageBackdropVariant(
): SidebarStageBackdropVariant | null {
if (!enabled) return null;
const normalized = stageLabel.trim().toLowerCase();
if (normalized === "nightly") return "nightly";
if (normalized === "dev") return "dev";
if (normalized === "nightly") return NIGHTLY_BACKDROP;
if (normalized === "dev") return DEV_BACKDROP;
return null;
}

export function resolveSidebarStageFocusRingOffsetClass(
variant: SidebarStageBackdropVariant,
): string {
return variant === "nightly"
return variant.kind === "nightly"
? "focus-visible:ring-offset-(--stage-night-bottom)"
: "focus-visible:ring-offset-(--stage-art-bottom)";
}
Expand All@@ -52,7 +86,17 @@ export function useEnvironmentStageLabel(): string {
}

export function useSidebarStageBackdropVariant(enabled = true): SidebarStageBackdropVariant | null {
return resolveSidebarStageBackdropVariant(useEnvironmentStageLabel(), enabled);
const stageLabel = useEnvironmentStageLabel();
const artwork = usePrimarySettings((settings) => ({
selection: settings.sidebarArtwork,
custom: settings.customSidebarArtworks,
}));
return resolveSidebarArtwork({
selection: artwork.selection,
stageLabel,
custom: artwork.custom,
enabled,
});
}

/** Stage-channel header art; palettes mirror the per-channel app icons in `assets/`. */
Expand All@@ -68,11 +112,32 @@ export function SidebarStageBackdrop({ variant }: { variant: SidebarStageBackdro
}

export function StageBackdropArt({ variant }: { variant: SidebarStageBackdropVariant }) {
return variant === "nightly" ? <NightlySkyArt /> : <DevBlueprintArt />;
if (variant.kind === "custom") return <CustomArt variant={variant} />;
return variant.kind === "nightly" ? <NightlySkyArt /> : <DevBlueprintArt />;
}

export function StageBackdropButtonArt({ variant }: { variant: SidebarStageBackdropVariant }) {
return variant === "nightly" ? <NightlySkyArt compact /> : <DevBlueprintArt compact />;
if (variant.kind === "custom") return <CustomArt variant={variant} />;
return variant.kind === "nightly" ? <NightlySkyArt compact /> : <DevBlueprintArt compact />;
}

/**
* A user's own artwork. Drawn as a cover-cropped band so any aspect ratio
* fills the header the way the built-in scenes do.
*/
function CustomArt({
variant,
}: {
variant: Extract<SidebarStageBackdropVariant, { kind: "custom" }>;
}) {
return (
<div
role="img"
aria-label={variant.name}
className="stage-art h-full w-full bg-cover bg-center bg-no-repeat"
style={{ backgroundImage: `url(${JSON.stringify(variant.image)})` }}
/>
);
}

const NIGHTLY_STARS: ReadonlyArray<{
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,6 +16,8 @@ import { toastManager } from "../ui/toast.tsx";
import { SettingsRow, SettingsSection } from "./settingsLayout.tsx";
import { searchableSetting } from "./settingsSearch.ts";

import { APP_DISPLAY_NAME } from "~/branding";

const EVENT_OPTIONS: ReadonlyArray<{
readonly event: DesktopNotificationEvent;
readonly title: string;
Expand DownExpand Up@@ -158,14 +160,14 @@ function useDesktopNotificationSettingsModel() {
};

const masterDescription = isElectron
? "Notify me when T3 Code is in the background."
? `Notify me when ${APP_DISPLAY_NAME} is in the background.`
: browserPermission.permission === "denied"
? "Blocked in your browser settings."
: browserPermission.permission === "unsupported"
? "Not supported by this browser."
: browserPermission.permission === "default"
? "Allow notifications when T3 Code is in the background."
: "Notify me when T3 Code is in the background.";
? `Allow notifications when ${APP_DISPLAY_NAME} is in the background.`
: `Notify me when ${APP_DISPLAY_NAME} is in the background.`;

return {
settings,
Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions apps/web/src/components/Icons.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -700,25 +700,16 @@ export const ACPRegistryIcon: Icon = ({ className, ...props }) => (
export const MtModelIcon: Icon = ({ className, ...props }) => (
<svg
{...props}
viewBox="0 0 24 24"
viewBox="0 0 128 128"
fill="none"
className={cn("stroke-current", className)}
className={cn("fill-current", className)}
aria-hidden
>
{/* The Munim mark, same path the app icon draws. */}
<path
d="M12 3.2 13.7 8.3 19 10l-5.3 1.7L12 16.8l-1.7-5.1L5 10l5.3-1.7L12 3.2Z"
strokeWidth="1.7"
strokeLinejoin="round"
/>
<path
d="M18.2 15.4 19 17.8 21.4 18.6 19 19.4 18.2 21.8 17.4 19.4 15 18.6 17.4 17.8 18.2 15.4Z"
strokeWidth="1.4"
strokeLinejoin="round"
/>
<path
d="M5.4 14.8 6 16.6 7.8 17.2 6 17.8 5.4 19.6 4.8 17.8 3 17.2 4.8 16.6 5.4 14.8Z"
strokeWidth="1.4"
strokeLinejoin="round"
d="M52.547 87.884L52.710 88.313L51.914 88.231L-0.000 603.926L105.522 614.537L135.846 313.360L180.699 434.810L181.210 439.258L182.291 439.136L184.066 443.911L265.794 413.732L273.569 383.736L293.716 313.043L312.994 481.660L219.104 524.021L180.964 657.000L668.780 436.993L668.189 435.670L631.008 110.432L725.000 105.249L719.204 0.000L419.046 16.549L424.862 121.797L525.037 116.268L554.382 372.820L413.312 436.422L366.622 27.955L262.488 39.871L262.937 43.850L212.900 219.495L150.865 51.563Z"
fillRule="nonzero"
transform="translate(22.067 26.000) scale(0.115677)"
/>
</svg>
);
Expand Down
64 changes: 52 additions & 12 deletions apps/web/src/components/SidebarStageBackdrop.test.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,10 @@ import { describe, expect, it } from "vite-plus/test";
import { renderToStaticMarkup } from "react-dom/server";

import {
DEV_BACKDROP,
NIGHTLY_BACKDROP,
resolveEnvironmentIdentificationPillLabel,
resolveSidebarArtwork,
resolveSidebarStageBackdropVariant,
resolveSidebarStageFocusRingOffsetClass,
StageBackdropArt,
Expand All@@ -11,8 +14,8 @@ import {

describe("SidebarStageBackdrop", () => {
it("resolves stage artwork only when enabled", () => {
expect(resolveSidebarStageBackdropVariant("Dev")).toBe("dev");
expect(resolveSidebarStageBackdropVariant("Nightly")).toBe("nightly");
expect(resolveSidebarStageBackdropVariant("Dev")).toEqual(DEV_BACKDROP);
expect(resolveSidebarStageBackdropVariant("Nightly")).toEqual(NIGHTLY_BACKDROP);
expect(resolveSidebarStageBackdropVariant("Dev", false)).toBeNull();
expect(resolveSidebarStageBackdropVariant("Alpha")).toBeNull();
});
Expand All@@ -25,16 +28,16 @@ describe("SidebarStageBackdrop", () => {
});

it("matches the focus-ring offset to each artwork palette", () => {
expect(resolveSidebarStageFocusRingOffsetClass("nightly")).toBe(
expect(resolveSidebarStageFocusRingOffsetClass(NIGHTLY_BACKDROP)).toBe(
"focus-visible:ring-offset-(--stage-night-bottom)",
);
expect(resolveSidebarStageFocusRingOffsetClass("dev")).toBe(
expect(resolveSidebarStageFocusRingOffsetClass(DEV_BACKDROP)).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",
it.each([NIGHTLY_BACKDROP, DEV_BACKDROP] as const)(
"uses unique SVG definition ids when $kind artwork is rendered more than once",
(variant) => {
const markup = renderToStaticMarkup(
<>
Expand All@@ -50,8 +53,8 @@ describe("SidebarStageBackdrop", () => {
);

it("paints each artwork variant with theme-owned color tokens", () => {
const nightlyMarkup = renderToStaticMarkup(<StageBackdropArt variant="nightly" />);
const devMarkup = renderToStaticMarkup(<StageBackdropArt variant="dev" />);
const nightlyMarkup = renderToStaticMarkup(<StageBackdropArt variant={NIGHTLY_BACKDROP} />);
const devMarkup = renderToStaticMarkup(<StageBackdropArt variant={DEV_BACKDROP} />);

expect(nightlyMarkup).toContain("var(--stage-night-bottom)");
expect(nightlyMarkup).toContain("var(--stage-night-line)");
Expand All@@ -62,12 +65,49 @@ describe("SidebarStageBackdrop", () => {
});

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) => {
[NIGHTLY_BACKDROP, "96 0 8192 96"],
[DEV_BACKDROP, "64 0 8192 96"],
] as const)("uses the compact 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"}`);
expect(markup).toContain(`stage-${variant.kind === "dev" ? "blueprint" : "nightly"}`);
});
});

describe("resolveSidebarArtwork", () => {
const custom = [{ id: "art_1", name: "Skyline", image: "data:image/png;base64,AAAA" }];

it("defers to the build channel only for auto", () => {
expect(resolveSidebarArtwork({ selection: "auto", stageLabel: "Nightly", custom })).toEqual(
NIGHTLY_BACKDROP,
);
// A release build has no channel artwork, which is why picking one matters.
expect(resolveSidebarArtwork({ selection: "auto", stageLabel: "", custom })).toBeNull();
});

it("honours an explicit pick regardless of channel", () => {
expect(resolveSidebarArtwork({ selection: "night", stageLabel: "", custom })).toEqual(
NIGHTLY_BACKDROP,
);
expect(resolveSidebarArtwork({ selection: "day", stageLabel: "Nightly", custom })).toEqual(
DEV_BACKDROP,
);
expect(resolveSidebarArtwork({ selection: "none", stageLabel: "Nightly", custom })).toBeNull();
});

it("renders the account's own artwork, and nothing once it is deleted", () => {
expect(resolveSidebarArtwork({ selection: "art_1", stageLabel: "", custom })).toEqual({
kind: "custom",
image: custom[0]!.image,
name: custom[0]!.name,
});
expect(resolveSidebarArtwork({ selection: "art_1", stageLabel: "", custom: [] })).toBeNull();
});

it("stays out of the way when artwork is switched off entirely", () => {
expect(
resolveSidebarArtwork({ selection: "night", stageLabel: "", custom, enabled: false }),
).toBeNull();
});
});
79 changes: 72 additions & 7 deletions apps/web/src/components/SidebarStageBackdrop.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,10 +4,44 @@ import { useId } from "react";
import { APP_HAS_UPDATE_TRACKS, APP_STAGE_LABEL } from "../branding";
import { resolveServerBackedAppStageLabel } from "../branding.logic";
import { primaryServerConfigAtom } from "../state/server";
import { usePrimarySettings } from "../hooks/useSettings";

export type SidebarStageBackdropVariant = "nightly" | "dev";
export type SidebarStageBackdropVariant =
| { readonly kind: "nightly" }
| { readonly kind: "dev" }
| { readonly kind: "custom"; readonly image: string; readonly name: string };
export type EnvironmentIdentificationPillLabel = "Dev" | "Nightly";

export const NIGHTLY_BACKDROP: SidebarStageBackdropVariant = { kind: "nightly" };
export const DEV_BACKDROP: SidebarStageBackdropVariant = { kind: "dev" };

/**
* Resolve the artwork to draw from the account's choice.
*
* "auto" defers to the build channel the way upstream does; every other value
* is a deliberate pick and ignores the channel entirely, which is the point on
* a single-release build like MT Code.
*/
export function resolveSidebarArtwork(input: {
readonly selection: string;
readonly stageLabel: string;
readonly custom: ReadonlyArray<{ readonly id: string; readonly name: string; readonly image: string }>;
readonly enabled?: boolean;
}): SidebarStageBackdropVariant | null {
if (input.enabled === false) return null;
const selection = input.selection.trim();
if (selection === "none") return null;
if (selection === "night") return NIGHTLY_BACKDROP;
if (selection === "day") return DEV_BACKDROP;
if (selection !== "auto" && selection.length > 0) {
const artwork = input.custom.find((entry) => entry.id === selection);
// A deleted artwork leaves the header bare rather than silently falling
// back to a scene the user did not choose.
return artwork ? { kind: "custom", image: artwork.image, name: artwork.name } : null;
}
return resolveSidebarStageBackdropVariant(input.stageLabel);
}

// A wide viewBox keeps the 96-unit art height at a fixed scale while sidebar resizing reveals
// more horizontal canvas instead of zooming the scene.
const STAGE_BACKDROP_VIEW_BOX = "0 0 8192 96";
Expand All@@ -18,15 +52,15 @@ export function resolveSidebarStageBackdropVariant(
): SidebarStageBackdropVariant | null {
if (!enabled) return null;
const normalized = stageLabel.trim().toLowerCase();
if (normalized === "nightly") return "nightly";
if (normalized === "dev") return "dev";
if (normalized === "nightly") return NIGHTLY_BACKDROP;
if (normalized === "dev") return DEV_BACKDROP;
return null;
}

export function resolveSidebarStageFocusRingOffsetClass(
variant: SidebarStageBackdropVariant,
): string {
return variant === "nightly"
return variant.kind === "nightly"
? "focus-visible:ring-offset-(--stage-night-bottom)"
: "focus-visible:ring-offset-(--stage-art-bottom)";
}
Expand All@@ -52,7 +86,17 @@ export function useEnvironmentStageLabel(): string {
}

export function useSidebarStageBackdropVariant(enabled = true): SidebarStageBackdropVariant | null {
return resolveSidebarStageBackdropVariant(useEnvironmentStageLabel(), enabled);
const stageLabel = useEnvironmentStageLabel();
const artwork = usePrimarySettings((settings) => ({
selection: settings.sidebarArtwork,
custom: settings.customSidebarArtworks,
}));
return resolveSidebarArtwork({
selection: artwork.selection,
stageLabel,
custom: artwork.custom,
enabled,
});
}

/** Stage-channel header art; palettes mirror the per-channel app icons in `assets/`. */
Expand All@@ -68,11 +112,32 @@ export function SidebarStageBackdrop({ variant }: { variant: SidebarStageBackdro
}

export function StageBackdropArt({ variant }: { variant: SidebarStageBackdropVariant }) {
return variant === "nightly" ? <NightlySkyArt /> : <DevBlueprintArt />;
if (variant.kind === "custom") return <CustomArt variant={variant} />;
return variant.kind === "nightly" ? <NightlySkyArt /> : <DevBlueprintArt />;
}

export function StageBackdropButtonArt({ variant }: { variant: SidebarStageBackdropVariant }) {
return variant === "nightly" ? <NightlySkyArt compact /> : <DevBlueprintArt compact />;
if (variant.kind === "custom") return <CustomArt variant={variant} />;
return variant.kind === "nightly" ? <NightlySkyArt compact /> : <DevBlueprintArt compact />;
}

/**
* A user's own artwork. Drawn as a cover-cropped band so any aspect ratio
* fills the header the way the built-in scenes do.
*/
function CustomArt({
variant,
}: {
variant: Extract<SidebarStageBackdropVariant, { kind: "custom" }>;
}) {
return (
<div
role="img"
aria-label={variant.name}
className="stage-art h-full w-full bg-cover bg-center bg-no-repeat"
style={{ backgroundImage: `url(${JSON.stringify(variant.image)})` }}
/>
);
}

const NIGHTLY_STARS: ReadonlyArray<{
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,6 +16,8 @@ import { toastManager } from "../ui/toast.tsx";
import { SettingsRow, SettingsSection } from "./settingsLayout.tsx";
import { searchableSetting } from "./settingsSearch.ts";

import { APP_DISPLAY_NAME } from "~/branding";

const EVENT_OPTIONS: ReadonlyArray<{
readonly event: DesktopNotificationEvent;
readonly title: string;
Expand DownExpand Up@@ -158,14 +160,14 @@ function useDesktopNotificationSettingsModel() {
};

const masterDescription = isElectron
? "Notify me when T3 Code is in the background."
? `Notify me when ${APP_DISPLAY_NAME} is in the background.`
: browserPermission.permission === "denied"
? "Blocked in your browser settings."
: browserPermission.permission === "unsupported"
? "Not supported by this browser."
: browserPermission.permission === "default"
? "Allow notifications when T3 Code is in the background."
: "Notify me when T3 Code is in the background.";
? `Allow notifications when ${APP_DISPLAY_NAME} is in the background.`
: `Notify me when ${APP_DISPLAY_NAME} is in the background.`;

return {
settings,
Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions apps/web/src/components/Icons.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -700,25 +700,16 @@ export const ACPRegistryIcon: Icon = ({ className, ...props }) => (
export const MtModelIcon: Icon = ({ className, ...props }) => (
<svg
{...props}
viewBox="0 0 24 24"
viewBox="0 0 128 128"
fill="none"
className={cn("stroke-current", className)}
className={cn("fill-current", className)}
aria-hidden
>
{/* The Munim mark, same path the app icon draws. */}
<path
d="M12 3.2 13.7 8.3 19 10l-5.3 1.7L12 16.8l-1.7-5.1L5 10l5.3-1.7L12 3.2Z"
strokeWidth="1.7"
strokeLinejoin="round"
/>
<path
d="M18.2 15.4 19 17.8 21.4 18.6 19 19.4 18.2 21.8 17.4 19.4 15 18.6 17.4 17.8 18.2 15.4Z"
strokeWidth="1.4"
strokeLinejoin="round"
/>
<path
d="M5.4 14.8 6 16.6 7.8 17.2 6 17.8 5.4 19.6 4.8 17.8 3 17.2 4.8 16.6 5.4 14.8Z"
strokeWidth="1.4"
strokeLinejoin="round"
d="M52.547 87.884L52.710 88.313L51.914 88.231L-0.000 603.926L105.522 614.537L135.846 313.360L180.699 434.810L181.210 439.258L182.291 439.136L184.066 443.911L265.794 413.732L273.569 383.736L293.716 313.043L312.994 481.660L219.104 524.021L180.964 657.000L668.780 436.993L668.189 435.670L631.008 110.432L725.000 105.249L719.204 0.000L419.046 16.549L424.862 121.797L525.037 116.268L554.382 372.820L413.312 436.422L366.622 27.955L262.488 39.871L262.937 43.850L212.900 219.495L150.865 51.563Z"
fillRule="nonzero"
transform="translate(22.067 26.000) scale(0.115677)"
/>
</svg>
);
Expand Down
64 changes: 52 additions & 12 deletions apps/web/src/components/SidebarStageBackdrop.test.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,10 @@ import { describe, expect, it } from "vite-plus/test";
import { renderToStaticMarkup } from "react-dom/server";

import {
DEV_BACKDROP,
NIGHTLY_BACKDROP,
resolveEnvironmentIdentificationPillLabel,
resolveSidebarArtwork,
resolveSidebarStageBackdropVariant,
resolveSidebarStageFocusRingOffsetClass,
StageBackdropArt,
Expand All@@ -11,8 +14,8 @@ import {

describe("SidebarStageBackdrop", () => {
it("resolves stage artwork only when enabled", () => {
expect(resolveSidebarStageBackdropVariant("Dev")).toBe("dev");
expect(resolveSidebarStageBackdropVariant("Nightly")).toBe("nightly");
expect(resolveSidebarStageBackdropVariant("Dev")).toEqual(DEV_BACKDROP);
expect(resolveSidebarStageBackdropVariant("Nightly")).toEqual(NIGHTLY_BACKDROP);
expect(resolveSidebarStageBackdropVariant("Dev", false)).toBeNull();
expect(resolveSidebarStageBackdropVariant("Alpha")).toBeNull();
});
Expand All@@ -25,16 +28,16 @@ describe("SidebarStageBackdrop", () => {
});

it("matches the focus-ring offset to each artwork palette", () => {
expect(resolveSidebarStageFocusRingOffsetClass("nightly")).toBe(
expect(resolveSidebarStageFocusRingOffsetClass(NIGHTLY_BACKDROP)).toBe(
"focus-visible:ring-offset-(--stage-night-bottom)",
);
expect(resolveSidebarStageFocusRingOffsetClass("dev")).toBe(
expect(resolveSidebarStageFocusRingOffsetClass(DEV_BACKDROP)).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",
it.each([NIGHTLY_BACKDROP, DEV_BACKDROP] as const)(
"uses unique SVG definition ids when $kind artwork is rendered more than once",
(variant) => {
const markup = renderToStaticMarkup(
<>
Expand All@@ -50,8 +53,8 @@ describe("SidebarStageBackdrop", () => {
);

it("paints each artwork variant with theme-owned color tokens", () => {
const nightlyMarkup = renderToStaticMarkup(<StageBackdropArt variant="nightly" />);
const devMarkup = renderToStaticMarkup(<StageBackdropArt variant="dev" />);
const nightlyMarkup = renderToStaticMarkup(<StageBackdropArt variant={NIGHTLY_BACKDROP} />);
const devMarkup = renderToStaticMarkup(<StageBackdropArt variant={DEV_BACKDROP} />);

expect(nightlyMarkup).toContain("var(--stage-night-bottom)");
expect(nightlyMarkup).toContain("var(--stage-night-line)");
Expand All@@ -62,12 +65,49 @@ describe("SidebarStageBackdrop", () => {
});

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) => {
[NIGHTLY_BACKDROP, "96 0 8192 96"],
[DEV_BACKDROP, "64 0 8192 96"],
] as const)("uses the compact 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"}`);
expect(markup).toContain(`stage-${variant.kind === "dev" ? "blueprint" : "nightly"}`);
});
});

describe("resolveSidebarArtwork", () => {
const custom = [{ id: "art_1", name: "Skyline", image: "data:image/png;base64,AAAA" }];

it("defers to the build channel only for auto", () => {
expect(resolveSidebarArtwork({ selection: "auto", stageLabel: "Nightly", custom })).toEqual(
NIGHTLY_BACKDROP,
);
// A release build has no channel artwork, which is why picking one matters.
expect(resolveSidebarArtwork({ selection: "auto", stageLabel: "", custom })).toBeNull();
});

it("honours an explicit pick regardless of channel", () => {
expect(resolveSidebarArtwork({ selection: "night", stageLabel: "", custom })).toEqual(
NIGHTLY_BACKDROP,
);
expect(resolveSidebarArtwork({ selection: "day", stageLabel: "Nightly", custom })).toEqual(
DEV_BACKDROP,
);
expect(resolveSidebarArtwork({ selection: "none", stageLabel: "Nightly", custom })).toBeNull();
});

it("renders the account's own artwork, and nothing once it is deleted", () => {
expect(resolveSidebarArtwork({ selection: "art_1", stageLabel: "", custom })).toEqual({
kind: "custom",
image: custom[0]!.image,
name: custom[0]!.name,
});
expect(resolveSidebarArtwork({ selection: "art_1", stageLabel: "", custom: [] })).toBeNull();
});

it("stays out of the way when artwork is switched off entirely", () => {
expect(
resolveSidebarArtwork({ selection: "night", stageLabel: "", custom, enabled: false }),
).toBeNull();
});
});
79 changes: 72 additions & 7 deletions apps/web/src/components/SidebarStageBackdrop.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,10 +4,44 @@ import { useId } from "react";
import { APP_HAS_UPDATE_TRACKS, APP_STAGE_LABEL } from "../branding";
import { resolveServerBackedAppStageLabel } from "../branding.logic";
import { primaryServerConfigAtom } from "../state/server";
import { usePrimarySettings } from "../hooks/useSettings";

export type SidebarStageBackdropVariant = "nightly" | "dev";
export type SidebarStageBackdropVariant =
| { readonly kind: "nightly" }
| { readonly kind: "dev" }
| { readonly kind: "custom"; readonly image: string; readonly name: string };
export type EnvironmentIdentificationPillLabel = "Dev" | "Nightly";

export const NIGHTLY_BACKDROP: SidebarStageBackdropVariant = { kind: "nightly" };
export const DEV_BACKDROP: SidebarStageBackdropVariant = { kind: "dev" };

/**
* Resolve the artwork to draw from the account's choice.
*
* "auto" defers to the build channel the way upstream does; every other value
* is a deliberate pick and ignores the channel entirely, which is the point on
* a single-release build like MT Code.
*/
export function resolveSidebarArtwork(input: {
readonly selection: string;
readonly stageLabel: string;
readonly custom: ReadonlyArray<{ readonly id: string; readonly name: string; readonly image: string }>;
readonly enabled?: boolean;
}): SidebarStageBackdropVariant | null {
if (input.enabled === false) return null;
const selection = input.selection.trim();
if (selection === "none") return null;
if (selection === "night") return NIGHTLY_BACKDROP;
if (selection === "day") return DEV_BACKDROP;
if (selection !== "auto" && selection.length > 0) {
const artwork = input.custom.find((entry) => entry.id === selection);
// A deleted artwork leaves the header bare rather than silently falling
// back to a scene the user did not choose.
return artwork ? { kind: "custom", image: artwork.image, name: artwork.name } : null;
}
return resolveSidebarStageBackdropVariant(input.stageLabel);
}

// A wide viewBox keeps the 96-unit art height at a fixed scale while sidebar resizing reveals
// more horizontal canvas instead of zooming the scene.
const STAGE_BACKDROP_VIEW_BOX = "0 0 8192 96";
Expand All@@ -18,15 +52,15 @@ export function resolveSidebarStageBackdropVariant(
): SidebarStageBackdropVariant | null {
if (!enabled) return null;
const normalized = stageLabel.trim().toLowerCase();
if (normalized === "nightly") return "nightly";
if (normalized === "dev") return "dev";
if (normalized === "nightly") return NIGHTLY_BACKDROP;
if (normalized === "dev") return DEV_BACKDROP;
return null;
}

export function resolveSidebarStageFocusRingOffsetClass(
variant: SidebarStageBackdropVariant,
): string {
return variant === "nightly"
return variant.kind === "nightly"
? "focus-visible:ring-offset-(--stage-night-bottom)"
: "focus-visible:ring-offset-(--stage-art-bottom)";
}
Expand All@@ -52,7 +86,17 @@ export function useEnvironmentStageLabel(): string {
}

export function useSidebarStageBackdropVariant(enabled = true): SidebarStageBackdropVariant | null {
return resolveSidebarStageBackdropVariant(useEnvironmentStageLabel(), enabled);
const stageLabel = useEnvironmentStageLabel();
const artwork = usePrimarySettings((settings) => ({
selection: settings.sidebarArtwork,
custom: settings.customSidebarArtworks,
}));
return resolveSidebarArtwork({
selection: artwork.selection,
stageLabel,
custom: artwork.custom,
enabled,
});
}

/** Stage-channel header art; palettes mirror the per-channel app icons in `assets/`. */
Expand All@@ -68,11 +112,32 @@ export function SidebarStageBackdrop({ variant }: { variant: SidebarStageBackdro
}

export function StageBackdropArt({ variant }: { variant: SidebarStageBackdropVariant }) {
return variant === "nightly" ? <NightlySkyArt /> : <DevBlueprintArt />;
if (variant.kind === "custom") return <CustomArt variant={variant} />;
return variant.kind === "nightly" ? <NightlySkyArt /> : <DevBlueprintArt />;
}

export function StageBackdropButtonArt({ variant }: { variant: SidebarStageBackdropVariant }) {
return variant === "nightly" ? <NightlySkyArt compact /> : <DevBlueprintArt compact />;
if (variant.kind === "custom") return <CustomArt variant={variant} />;
return variant.kind === "nightly" ? <NightlySkyArt compact /> : <DevBlueprintArt compact />;
}

/**
* A user's own artwork. Drawn as a cover-cropped band so any aspect ratio
* fills the header the way the built-in scenes do.
*/
function CustomArt({
variant,
}: {
variant: Extract<SidebarStageBackdropVariant, { kind: "custom" }>;
}) {
return (
<div
role="img"
aria-label={variant.name}
className="stage-art h-full w-full bg-cover bg-center bg-no-repeat"
style={{ backgroundImage: `url(${JSON.stringify(variant.image)})` }}
/>
);
}

const NIGHTLY_STARS: ReadonlyArray<{
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,6 +16,8 @@ import { toastManager } from "../ui/toast.tsx";
import { SettingsRow, SettingsSection } from "./settingsLayout.tsx";
import { searchableSetting } from "./settingsSearch.ts";

import { APP_DISPLAY_NAME } from "~/branding";

const EVENT_OPTIONS: ReadonlyArray<{
readonly event: DesktopNotificationEvent;
readonly title: string;
Expand DownExpand Up@@ -158,14 +160,14 @@ function useDesktopNotificationSettingsModel() {
};

const masterDescription = isElectron
? "Notify me when T3 Code is in the background."
? `Notify me when ${APP_DISPLAY_NAME} is in the background.`
: browserPermission.permission === "denied"
? "Blocked in your browser settings."
: browserPermission.permission === "unsupported"
? "Not supported by this browser."
: browserPermission.permission === "default"
? "Allow notifications when T3 Code is in the background."
: "Notify me when T3 Code is in the background.";
? `Allow notifications when ${APP_DISPLAY_NAME} is in the background.`
: `Notify me when ${APP_DISPLAY_NAME} is in the background.`;

return {
settings,
Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions apps/web/src/components/Icons.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -700,25 +700,16 @@ export const ACPRegistryIcon: Icon = ({ className, ...props }) => (
export const MtModelIcon: Icon = ({ className, ...props }) => (
<svg
{...props}
viewBox="0 0 24 24"
viewBox="0 0 128 128"
fill="none"
className={cn("stroke-current", className)}
className={cn("fill-current", className)}
aria-hidden
>
{/* The Munim mark, same path the app icon draws. */}
<path
d="M12 3.2 13.7 8.3 19 10l-5.3 1.7L12 16.8l-1.7-5.1L5 10l5.3-1.7L12 3.2Z"
strokeWidth="1.7"
strokeLinejoin="round"
/>
<path
d="M18.2 15.4 19 17.8 21.4 18.6 19 19.4 18.2 21.8 17.4 19.4 15 18.6 17.4 17.8 18.2 15.4Z"
strokeWidth="1.4"
strokeLinejoin="round"
/>
<path
d="M5.4 14.8 6 16.6 7.8 17.2 6 17.8 5.4 19.6 4.8 17.8 3 17.2 4.8 16.6 5.4 14.8Z"
strokeWidth="1.4"
strokeLinejoin="round"
d="M52.547 87.884L52.710 88.313L51.914 88.231L-0.000 603.926L105.522 614.537L135.846 313.360L180.699 434.810L181.210 439.258L182.291 439.136L184.066 443.911L265.794 413.732L273.569 383.736L293.716 313.043L312.994 481.660L219.104 524.021L180.964 657.000L668.780 436.993L668.189 435.670L631.008 110.432L725.000 105.249L719.204 0.000L419.046 16.549L424.862 121.797L525.037 116.268L554.382 372.820L413.312 436.422L366.622 27.955L262.488 39.871L262.937 43.850L212.900 219.495L150.865 51.563Z"
fillRule="nonzero"
transform="translate(22.067 26.000) scale(0.115677)"
/>
</svg>
);
Expand Down
64 changes: 52 additions & 12 deletions apps/web/src/components/SidebarStageBackdrop.test.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,10 @@ import { describe, expect, it } from "vite-plus/test";
import { renderToStaticMarkup } from "react-dom/server";

import {
DEV_BACKDROP,
NIGHTLY_BACKDROP,
resolveEnvironmentIdentificationPillLabel,
resolveSidebarArtwork,
resolveSidebarStageBackdropVariant,
resolveSidebarStageFocusRingOffsetClass,
StageBackdropArt,
Expand All@@ -11,8 +14,8 @@ import {

describe("SidebarStageBackdrop", () => {
it("resolves stage artwork only when enabled", () => {
expect(resolveSidebarStageBackdropVariant("Dev")).toBe("dev");
expect(resolveSidebarStageBackdropVariant("Nightly")).toBe("nightly");
expect(resolveSidebarStageBackdropVariant("Dev")).toEqual(DEV_BACKDROP);
expect(resolveSidebarStageBackdropVariant("Nightly")).toEqual(NIGHTLY_BACKDROP);
expect(resolveSidebarStageBackdropVariant("Dev", false)).toBeNull();
expect(resolveSidebarStageBackdropVariant("Alpha")).toBeNull();
});
Expand All@@ -25,16 +28,16 @@ describe("SidebarStageBackdrop", () => {
});

it("matches the focus-ring offset to each artwork palette", () => {
expect(resolveSidebarStageFocusRingOffsetClass("nightly")).toBe(
expect(resolveSidebarStageFocusRingOffsetClass(NIGHTLY_BACKDROP)).toBe(
"focus-visible:ring-offset-(--stage-night-bottom)",
);
expect(resolveSidebarStageFocusRingOffsetClass("dev")).toBe(
expect(resolveSidebarStageFocusRingOffsetClass(DEV_BACKDROP)).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",
it.each([NIGHTLY_BACKDROP, DEV_BACKDROP] as const)(
"uses unique SVG definition ids when $kind artwork is rendered more than once",
(variant) => {
const markup = renderToStaticMarkup(
<>
Expand All@@ -50,8 +53,8 @@ describe("SidebarStageBackdrop", () => {
);

it("paints each artwork variant with theme-owned color tokens", () => {
const nightlyMarkup = renderToStaticMarkup(<StageBackdropArt variant="nightly" />);
const devMarkup = renderToStaticMarkup(<StageBackdropArt variant="dev" />);
const nightlyMarkup = renderToStaticMarkup(<StageBackdropArt variant={NIGHTLY_BACKDROP} />);
const devMarkup = renderToStaticMarkup(<StageBackdropArt variant={DEV_BACKDROP} />);

expect(nightlyMarkup).toContain("var(--stage-night-bottom)");
expect(nightlyMarkup).toContain("var(--stage-night-line)");
Expand All@@ -62,12 +65,49 @@ describe("SidebarStageBackdrop", () => {
});

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) => {
[NIGHTLY_BACKDROP, "96 0 8192 96"],
[DEV_BACKDROP, "64 0 8192 96"],
] as const)("uses the compact 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"}`);
expect(markup).toContain(`stage-${variant.kind === "dev" ? "blueprint" : "nightly"}`);
});
});

describe("resolveSidebarArtwork", () => {
const custom = [{ id: "art_1", name: "Skyline", image: "data:image/png;base64,AAAA" }];

it("defers to the build channel only for auto", () => {
expect(resolveSidebarArtwork({ selection: "auto", stageLabel: "Nightly", custom })).toEqual(
NIGHTLY_BACKDROP,
);
// A release build has no channel artwork, which is why picking one matters.
expect(resolveSidebarArtwork({ selection: "auto", stageLabel: "", custom })).toBeNull();
});

it("honours an explicit pick regardless of channel", () => {
expect(resolveSidebarArtwork({ selection: "night", stageLabel: "", custom })).toEqual(
NIGHTLY_BACKDROP,
);
expect(resolveSidebarArtwork({ selection: "day", stageLabel: "Nightly", custom })).toEqual(
DEV_BACKDROP,
);
expect(resolveSidebarArtwork({ selection: "none", stageLabel: "Nightly", custom })).toBeNull();
});

it("renders the account's own artwork, and nothing once it is deleted", () => {
expect(resolveSidebarArtwork({ selection: "art_1", stageLabel: "", custom })).toEqual({
kind: "custom",
image: custom[0]!.image,
name: custom[0]!.name,
});
expect(resolveSidebarArtwork({ selection: "art_1", stageLabel: "", custom: [] })).toBeNull();
});

it("stays out of the way when artwork is switched off entirely", () => {
expect(
resolveSidebarArtwork({ selection: "night", stageLabel: "", custom, enabled: false }),
).toBeNull();
});
});
79 changes: 72 additions & 7 deletions apps/web/src/components/SidebarStageBackdrop.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,10 +4,44 @@ import { useId } from "react";
import { APP_HAS_UPDATE_TRACKS, APP_STAGE_LABEL } from "../branding";
import { resolveServerBackedAppStageLabel } from "../branding.logic";
import { primaryServerConfigAtom } from "../state/server";
import { usePrimarySettings } from "../hooks/useSettings";

export type SidebarStageBackdropVariant = "nightly" | "dev";
export type SidebarStageBackdropVariant =
| { readonly kind: "nightly" }
| { readonly kind: "dev" }
| { readonly kind: "custom"; readonly image: string; readonly name: string };
export type EnvironmentIdentificationPillLabel = "Dev" | "Nightly";

export const NIGHTLY_BACKDROP: SidebarStageBackdropVariant = { kind: "nightly" };
export const DEV_BACKDROP: SidebarStageBackdropVariant = { kind: "dev" };

/**
* Resolve the artwork to draw from the account's choice.
*
* "auto" defers to the build channel the way upstream does; every other value
* is a deliberate pick and ignores the channel entirely, which is the point on
* a single-release build like MT Code.
*/
export function resolveSidebarArtwork(input: {
readonly selection: string;
readonly stageLabel: string;
readonly custom: ReadonlyArray<{ readonly id: string; readonly name: string; readonly image: string }>;
readonly enabled?: boolean;
}): SidebarStageBackdropVariant | null {
if (input.enabled === false) return null;
const selection = input.selection.trim();
if (selection === "none") return null;
if (selection === "night") return NIGHTLY_BACKDROP;
if (selection === "day") return DEV_BACKDROP;
if (selection !== "auto" && selection.length > 0) {
const artwork = input.custom.find((entry) => entry.id === selection);
// A deleted artwork leaves the header bare rather than silently falling
// back to a scene the user did not choose.
return artwork ? { kind: "custom", image: artwork.image, name: artwork.name } : null;
}
return resolveSidebarStageBackdropVariant(input.stageLabel);
}

// A wide viewBox keeps the 96-unit art height at a fixed scale while sidebar resizing reveals
// more horizontal canvas instead of zooming the scene.
const STAGE_BACKDROP_VIEW_BOX = "0 0 8192 96";
Expand All@@ -18,15 +52,15 @@ export function resolveSidebarStageBackdropVariant(
): SidebarStageBackdropVariant | null {
if (!enabled) return null;
const normalized = stageLabel.trim().toLowerCase();
if (normalized === "nightly") return "nightly";
if (normalized === "dev") return "dev";
if (normalized === "nightly") return NIGHTLY_BACKDROP;
if (normalized === "dev") return DEV_BACKDROP;
return null;
}

export function resolveSidebarStageFocusRingOffsetClass(
variant: SidebarStageBackdropVariant,
): string {
return variant === "nightly"
return variant.kind === "nightly"
? "focus-visible:ring-offset-(--stage-night-bottom)"
: "focus-visible:ring-offset-(--stage-art-bottom)";
}
Expand All@@ -52,7 +86,17 @@ export function useEnvironmentStageLabel(): string {
}

export function useSidebarStageBackdropVariant(enabled = true): SidebarStageBackdropVariant | null {
return resolveSidebarStageBackdropVariant(useEnvironmentStageLabel(), enabled);
const stageLabel = useEnvironmentStageLabel();
const artwork = usePrimarySettings((settings) => ({
selection: settings.sidebarArtwork,
custom: settings.customSidebarArtworks,
}));
return resolveSidebarArtwork({
selection: artwork.selection,
stageLabel,
custom: artwork.custom,
enabled,
});
}

/** Stage-channel header art; palettes mirror the per-channel app icons in `assets/`. */
Expand All@@ -68,11 +112,32 @@ export function SidebarStageBackdrop({ variant }: { variant: SidebarStageBackdro
}

export function StageBackdropArt({ variant }: { variant: SidebarStageBackdropVariant }) {
return variant === "nightly" ? <NightlySkyArt /> : <DevBlueprintArt />;
if (variant.kind === "custom") return <CustomArt variant={variant} />;
return variant.kind === "nightly" ? <NightlySkyArt /> : <DevBlueprintArt />;
}

export function StageBackdropButtonArt({ variant }: { variant: SidebarStageBackdropVariant }) {
return variant === "nightly" ? <NightlySkyArt compact /> : <DevBlueprintArt compact />;
if (variant.kind === "custom") return <CustomArt variant={variant} />;
return variant.kind === "nightly" ? <NightlySkyArt compact /> : <DevBlueprintArt compact />;
}

/**
* A user's own artwork. Drawn as a cover-cropped band so any aspect ratio
* fills the header the way the built-in scenes do.
*/
function CustomArt({
variant,
}: {
variant: Extract<SidebarStageBackdropVariant, { kind: "custom" }>;
}) {
return (
<div
role="img"
aria-label={variant.name}
className="stage-art h-full w-full bg-cover bg-center bg-no-repeat"
style={{ backgroundImage: `url(${JSON.stringify(variant.image)})` }}
/>
);
}

const NIGHTLY_STARS: ReadonlyArray<{
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,6 +16,8 @@ import { toastManager } from "../ui/toast.tsx";
import { SettingsRow, SettingsSection } from "./settingsLayout.tsx";
import { searchableSetting } from "./settingsSearch.ts";

import { APP_DISPLAY_NAME } from "~/branding";

const EVENT_OPTIONS: ReadonlyArray<{
readonly event: DesktopNotificationEvent;
readonly title: string;
Expand DownExpand Up@@ -158,14 +160,14 @@ function useDesktopNotificationSettingsModel() {
};

const masterDescription = isElectron
? "Notify me when T3 Code is in the background."
? `Notify me when ${APP_DISPLAY_NAME} is in the background.`
: browserPermission.permission === "denied"
? "Blocked in your browser settings."
: browserPermission.permission === "unsupported"
? "Not supported by this browser."
: browserPermission.permission === "default"
? "Allow notifications when T3 Code is in the background."
: "Notify me when T3 Code is in the background.";
? `Allow notifications when ${APP_DISPLAY_NAME} is in the background.`
: `Notify me when ${APP_DISPLAY_NAME} is in the background.`;

return {
settings,
Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions apps/web/src/components/Icons.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -700,25 +700,16 @@ export const ACPRegistryIcon: Icon = ({ className, ...props }) => (
export const MtModelIcon: Icon = ({ className, ...props }) => (
<svg
{...props}
viewBox="0 0 24 24"
viewBox="0 0 128 128"
fill="none"
className={cn("stroke-current", className)}
className={cn("fill-current", className)}
aria-hidden
>
{/* The Munim mark, same path the app icon draws. */}
<path
d="M12 3.2 13.7 8.3 19 10l-5.3 1.7L12 16.8l-1.7-5.1L5 10l5.3-1.7L12 3.2Z"
strokeWidth="1.7"
strokeLinejoin="round"
/>
<path
d="M18.2 15.4 19 17.8 21.4 18.6 19 19.4 18.2 21.8 17.4 19.4 15 18.6 17.4 17.8 18.2 15.4Z"
strokeWidth="1.4"
strokeLinejoin="round"
/>
<path
d="M5.4 14.8 6 16.6 7.8 17.2 6 17.8 5.4 19.6 4.8 17.8 3 17.2 4.8 16.6 5.4 14.8Z"
strokeWidth="1.4"
strokeLinejoin="round"
d="M52.547 87.884L52.710 88.313L51.914 88.231L-0.000 603.926L105.522 614.537L135.846 313.360L180.699 434.810L181.210 439.258L182.291 439.136L184.066 443.911L265.794 413.732L273.569 383.736L293.716 313.043L312.994 481.660L219.104 524.021L180.964 657.000L668.780 436.993L668.189 435.670L631.008 110.432L725.000 105.249L719.204 0.000L419.046 16.549L424.862 121.797L525.037 116.268L554.382 372.820L413.312 436.422L366.622 27.955L262.488 39.871L262.937 43.850L212.900 219.495L150.865 51.563Z"
fillRule="nonzero"
transform="translate(22.067 26.000) scale(0.115677)"
/>
</svg>
);
Expand Down
64 changes: 52 additions & 12 deletions apps/web/src/components/SidebarStageBackdrop.test.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,10 @@ import { describe, expect, it } from "vite-plus/test";
import { renderToStaticMarkup } from "react-dom/server";

import {
DEV_BACKDROP,
NIGHTLY_BACKDROP,
resolveEnvironmentIdentificationPillLabel,
resolveSidebarArtwork,
resolveSidebarStageBackdropVariant,
resolveSidebarStageFocusRingOffsetClass,
StageBackdropArt,
Expand All@@ -11,8 +14,8 @@ import {

describe("SidebarStageBackdrop", () => {
it("resolves stage artwork only when enabled", () => {
expect(resolveSidebarStageBackdropVariant("Dev")).toBe("dev");
expect(resolveSidebarStageBackdropVariant("Nightly")).toBe("nightly");
expect(resolveSidebarStageBackdropVariant("Dev")).toEqual(DEV_BACKDROP);
expect(resolveSidebarStageBackdropVariant("Nightly")).toEqual(NIGHTLY_BACKDROP);
expect(resolveSidebarStageBackdropVariant("Dev", false)).toBeNull();
expect(resolveSidebarStageBackdropVariant("Alpha")).toBeNull();
});
Expand All@@ -25,16 +28,16 @@ describe("SidebarStageBackdrop", () => {
});

it("matches the focus-ring offset to each artwork palette", () => {
expect(resolveSidebarStageFocusRingOffsetClass("nightly")).toBe(
expect(resolveSidebarStageFocusRingOffsetClass(NIGHTLY_BACKDROP)).toBe(
"focus-visible:ring-offset-(--stage-night-bottom)",
);
expect(resolveSidebarStageFocusRingOffsetClass("dev")).toBe(
expect(resolveSidebarStageFocusRingOffsetClass(DEV_BACKDROP)).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",
it.each([NIGHTLY_BACKDROP, DEV_BACKDROP] as const)(
"uses unique SVG definition ids when $kind artwork is rendered more than once",
(variant) => {
const markup = renderToStaticMarkup(
<>
Expand All@@ -50,8 +53,8 @@ describe("SidebarStageBackdrop", () => {
);

it("paints each artwork variant with theme-owned color tokens", () => {
const nightlyMarkup = renderToStaticMarkup(<StageBackdropArt variant="nightly" />);
const devMarkup = renderToStaticMarkup(<StageBackdropArt variant="dev" />);
const nightlyMarkup = renderToStaticMarkup(<StageBackdropArt variant={NIGHTLY_BACKDROP} />);
const devMarkup = renderToStaticMarkup(<StageBackdropArt variant={DEV_BACKDROP} />);

expect(nightlyMarkup).toContain("var(--stage-night-bottom)");
expect(nightlyMarkup).toContain("var(--stage-night-line)");
Expand All@@ -62,12 +65,49 @@ describe("SidebarStageBackdrop", () => {
});

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) => {
[NIGHTLY_BACKDROP, "96 0 8192 96"],
[DEV_BACKDROP, "64 0 8192 96"],
] as const)("uses the compact 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"}`);
expect(markup).toContain(`stage-${variant.kind === "dev" ? "blueprint" : "nightly"}`);
});
});

describe("resolveSidebarArtwork", () => {
const custom = [{ id: "art_1", name: "Skyline", image: "data:image/png;base64,AAAA" }];

it("defers to the build channel only for auto", () => {
expect(resolveSidebarArtwork({ selection: "auto", stageLabel: "Nightly", custom })).toEqual(
NIGHTLY_BACKDROP,
);
// A release build has no channel artwork, which is why picking one matters.
expect(resolveSidebarArtwork({ selection: "auto", stageLabel: "", custom })).toBeNull();
});

it("honours an explicit pick regardless of channel", () => {
expect(resolveSidebarArtwork({ selection: "night", stageLabel: "", custom })).toEqual(
NIGHTLY_BACKDROP,
);
expect(resolveSidebarArtwork({ selection: "day", stageLabel: "Nightly", custom })).toEqual(
DEV_BACKDROP,
);
expect(resolveSidebarArtwork({ selection: "none", stageLabel: "Nightly", custom })).toBeNull();
});

it("renders the account's own artwork, and nothing once it is deleted", () => {
expect(resolveSidebarArtwork({ selection: "art_1", stageLabel: "", custom })).toEqual({
kind: "custom",
image: custom[0]!.image,
name: custom[0]!.name,
});
expect(resolveSidebarArtwork({ selection: "art_1", stageLabel: "", custom: [] })).toBeNull();
});

it("stays out of the way when artwork is switched off entirely", () => {
expect(
resolveSidebarArtwork({ selection: "night", stageLabel: "", custom, enabled: false }),
).toBeNull();
});
});
79 changes: 72 additions & 7 deletions apps/web/src/components/SidebarStageBackdrop.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,10 +4,44 @@ import { useId } from "react";
import { APP_HAS_UPDATE_TRACKS, APP_STAGE_LABEL } from "../branding";
import { resolveServerBackedAppStageLabel } from "../branding.logic";
import { primaryServerConfigAtom } from "../state/server";
import { usePrimarySettings } from "../hooks/useSettings";

export type SidebarStageBackdropVariant = "nightly" | "dev";
export type SidebarStageBackdropVariant =
| { readonly kind: "nightly" }
| { readonly kind: "dev" }
| { readonly kind: "custom"; readonly image: string; readonly name: string };
export type EnvironmentIdentificationPillLabel = "Dev" | "Nightly";

export const NIGHTLY_BACKDROP: SidebarStageBackdropVariant = { kind: "nightly" };
export const DEV_BACKDROP: SidebarStageBackdropVariant = { kind: "dev" };

/**
* Resolve the artwork to draw from the account's choice.
*
* "auto" defers to the build channel the way upstream does; every other value
* is a deliberate pick and ignores the channel entirely, which is the point on
* a single-release build like MT Code.
*/
export function resolveSidebarArtwork(input: {
readonly selection: string;
readonly stageLabel: string;
readonly custom: ReadonlyArray<{ readonly id: string; readonly name: string; readonly image: string }>;
readonly enabled?: boolean;
}): SidebarStageBackdropVariant | null {
if (input.enabled === false) return null;
const selection = input.selection.trim();
if (selection === "none") return null;
if (selection === "night") return NIGHTLY_BACKDROP;
if (selection === "day") return DEV_BACKDROP;
if (selection !== "auto" && selection.length > 0) {
const artwork = input.custom.find((entry) => entry.id === selection);
// A deleted artwork leaves the header bare rather than silently falling
// back to a scene the user did not choose.
return artwork ? { kind: "custom", image: artwork.image, name: artwork.name } : null;
}
return resolveSidebarStageBackdropVariant(input.stageLabel);
}

// A wide viewBox keeps the 96-unit art height at a fixed scale while sidebar resizing reveals
// more horizontal canvas instead of zooming the scene.
const STAGE_BACKDROP_VIEW_BOX = "0 0 8192 96";
Expand All@@ -18,15 +52,15 @@ export function resolveSidebarStageBackdropVariant(
): SidebarStageBackdropVariant | null {
if (!enabled) return null;
const normalized = stageLabel.trim().toLowerCase();
if (normalized === "nightly") return "nightly";
if (normalized === "dev") return "dev";
if (normalized === "nightly") return NIGHTLY_BACKDROP;
if (normalized === "dev") return DEV_BACKDROP;
return null;
}

export function resolveSidebarStageFocusRingOffsetClass(
variant: SidebarStageBackdropVariant,
): string {
return variant === "nightly"
return variant.kind === "nightly"
? "focus-visible:ring-offset-(--stage-night-bottom)"
: "focus-visible:ring-offset-(--stage-art-bottom)";
}
Expand All@@ -52,7 +86,17 @@ export function useEnvironmentStageLabel(): string {
}

export function useSidebarStageBackdropVariant(enabled = true): SidebarStageBackdropVariant | null {
return resolveSidebarStageBackdropVariant(useEnvironmentStageLabel(), enabled);
const stageLabel = useEnvironmentStageLabel();
const artwork = usePrimarySettings((settings) => ({
selection: settings.sidebarArtwork,
custom: settings.customSidebarArtworks,
}));
return resolveSidebarArtwork({
selection: artwork.selection,
stageLabel,
custom: artwork.custom,
enabled,
});
}

/** Stage-channel header art; palettes mirror the per-channel app icons in `assets/`. */
Expand All@@ -68,11 +112,32 @@ export function SidebarStageBackdrop({ variant }: { variant: SidebarStageBackdro
}

export function StageBackdropArt({ variant }: { variant: SidebarStageBackdropVariant }) {
return variant === "nightly" ? <NightlySkyArt /> : <DevBlueprintArt />;
if (variant.kind === "custom") return <CustomArt variant={variant} />;
return variant.kind === "nightly" ? <NightlySkyArt /> : <DevBlueprintArt />;
}

export function StageBackdropButtonArt({ variant }: { variant: SidebarStageBackdropVariant }) {
return variant === "nightly" ? <NightlySkyArt compact /> : <DevBlueprintArt compact />;
if (variant.kind === "custom") return <CustomArt variant={variant} />;
return variant.kind === "nightly" ? <NightlySkyArt compact /> : <DevBlueprintArt compact />;
}

/**
* A user's own artwork. Drawn as a cover-cropped band so any aspect ratio
* fills the header the way the built-in scenes do.
*/
function CustomArt({
variant,
}: {
variant: Extract<SidebarStageBackdropVariant, { kind: "custom" }>;
}) {
return (
<div
role="img"
aria-label={variant.name}
className="stage-art h-full w-full bg-cover bg-center bg-no-repeat"
style={{ backgroundImage: `url(${JSON.stringify(variant.image)})` }}
/>
);
}

const NIGHTLY_STARS: ReadonlyArray<{
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,6 +16,8 @@ import { toastManager } from "../ui/toast.tsx";
import { SettingsRow, SettingsSection } from "./settingsLayout.tsx";
import { searchableSetting } from "./settingsSearch.ts";

import { APP_DISPLAY_NAME } from "~/branding";

const EVENT_OPTIONS: ReadonlyArray<{
readonly event: DesktopNotificationEvent;
readonly title: string;
Expand DownExpand Up@@ -158,14 +160,14 @@ function useDesktopNotificationSettingsModel() {
};

const masterDescription = isElectron
? "Notify me when T3 Code is in the background."
? `Notify me when ${APP_DISPLAY_NAME} is in the background.`
: browserPermission.permission === "denied"
? "Blocked in your browser settings."
: browserPermission.permission === "unsupported"
? "Not supported by this browser."
: browserPermission.permission === "default"
? "Allow notifications when T3 Code is in the background."
: "Notify me when T3 Code is in the background.";
? `Allow notifications when ${APP_DISPLAY_NAME} is in the background.`
: `Notify me when ${APP_DISPLAY_NAME} is in the background.`;

return {
settings,
Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions apps/web/src/components/Icons.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -700,25 +700,16 @@ export const ACPRegistryIcon: Icon = ({ className, ...props }) => (
export const MtModelIcon: Icon = ({ className, ...props }) => (
<svg
{...props}
viewBox="0 0 24 24"
viewBox="0 0 128 128"
fill="none"
className={cn("stroke-current", className)}
className={cn("fill-current", className)}
aria-hidden
>
{/* The Munim mark, same path the app icon draws. */}
<path
d="M12 3.2 13.7 8.3 19 10l-5.3 1.7L12 16.8l-1.7-5.1L5 10l5.3-1.7L12 3.2Z"
strokeWidth="1.7"
strokeLinejoin="round"
/>
<path
d="M18.2 15.4 19 17.8 21.4 18.6 19 19.4 18.2 21.8 17.4 19.4 15 18.6 17.4 17.8 18.2 15.4Z"
strokeWidth="1.4"
strokeLinejoin="round"
/>
<path
d="M5.4 14.8 6 16.6 7.8 17.2 6 17.8 5.4 19.6 4.8 17.8 3 17.2 4.8 16.6 5.4 14.8Z"
strokeWidth="1.4"
strokeLinejoin="round"
d="M52.547 87.884L52.710 88.313L51.914 88.231L-0.000 603.926L105.522 614.537L135.846 313.360L180.699 434.810L181.210 439.258L182.291 439.136L184.066 443.911L265.794 413.732L273.569 383.736L293.716 313.043L312.994 481.660L219.104 524.021L180.964 657.000L668.780 436.993L668.189 435.670L631.008 110.432L725.000 105.249L719.204 0.000L419.046 16.549L424.862 121.797L525.037 116.268L554.382 372.820L413.312 436.422L366.622 27.955L262.488 39.871L262.937 43.850L212.900 219.495L150.865 51.563Z"
fillRule="nonzero"
transform="translate(22.067 26.000) scale(0.115677)"
/>
</svg>
);
Expand Down
64 changes: 52 additions & 12 deletions apps/web/src/components/SidebarStageBackdrop.test.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,10 @@ import { describe, expect, it } from "vite-plus/test";
import { renderToStaticMarkup } from "react-dom/server";

import {
DEV_BACKDROP,
NIGHTLY_BACKDROP,
resolveEnvironmentIdentificationPillLabel,
resolveSidebarArtwork,
resolveSidebarStageBackdropVariant,
resolveSidebarStageFocusRingOffsetClass,
StageBackdropArt,
Expand All@@ -11,8 +14,8 @@ import {

describe("SidebarStageBackdrop", () => {
it("resolves stage artwork only when enabled", () => {
expect(resolveSidebarStageBackdropVariant("Dev")).toBe("dev");
expect(resolveSidebarStageBackdropVariant("Nightly")).toBe("nightly");
expect(resolveSidebarStageBackdropVariant("Dev")).toEqual(DEV_BACKDROP);
expect(resolveSidebarStageBackdropVariant("Nightly")).toEqual(NIGHTLY_BACKDROP);
expect(resolveSidebarStageBackdropVariant("Dev", false)).toBeNull();
expect(resolveSidebarStageBackdropVariant("Alpha")).toBeNull();
});
Expand All@@ -25,16 +28,16 @@ describe("SidebarStageBackdrop", () => {
});

it("matches the focus-ring offset to each artwork palette", () => {
expect(resolveSidebarStageFocusRingOffsetClass("nightly")).toBe(
expect(resolveSidebarStageFocusRingOffsetClass(NIGHTLY_BACKDROP)).toBe(
"focus-visible:ring-offset-(--stage-night-bottom)",
);
expect(resolveSidebarStageFocusRingOffsetClass("dev")).toBe(
expect(resolveSidebarStageFocusRingOffsetClass(DEV_BACKDROP)).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",
it.each([NIGHTLY_BACKDROP, DEV_BACKDROP] as const)(
"uses unique SVG definition ids when $kind artwork is rendered more than once",
(variant) => {
const markup = renderToStaticMarkup(
<>
Expand All@@ -50,8 +53,8 @@ describe("SidebarStageBackdrop", () => {
);

it("paints each artwork variant with theme-owned color tokens", () => {
const nightlyMarkup = renderToStaticMarkup(<StageBackdropArt variant="nightly" />);
const devMarkup = renderToStaticMarkup(<StageBackdropArt variant="dev" />);
const nightlyMarkup = renderToStaticMarkup(<StageBackdropArt variant={NIGHTLY_BACKDROP} />);
const devMarkup = renderToStaticMarkup(<StageBackdropArt variant={DEV_BACKDROP} />);

expect(nightlyMarkup).toContain("var(--stage-night-bottom)");
expect(nightlyMarkup).toContain("var(--stage-night-line)");
Expand All@@ -62,12 +65,49 @@ describe("SidebarStageBackdrop", () => {
});

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) => {
[NIGHTLY_BACKDROP, "96 0 8192 96"],
[DEV_BACKDROP, "64 0 8192 96"],
] as const)("uses the compact 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"}`);
expect(markup).toContain(`stage-${variant.kind === "dev" ? "blueprint" : "nightly"}`);
});
});

describe("resolveSidebarArtwork", () => {
const custom = [{ id: "art_1", name: "Skyline", image: "data:image/png;base64,AAAA" }];

it("defers to the build channel only for auto", () => {
expect(resolveSidebarArtwork({ selection: "auto", stageLabel: "Nightly", custom })).toEqual(
NIGHTLY_BACKDROP,
);
// A release build has no channel artwork, which is why picking one matters.
expect(resolveSidebarArtwork({ selection: "auto", stageLabel: "", custom })).toBeNull();
});

it("honours an explicit pick regardless of channel", () => {
expect(resolveSidebarArtwork({ selection: "night", stageLabel: "", custom })).toEqual(
NIGHTLY_BACKDROP,
);
expect(resolveSidebarArtwork({ selection: "day", stageLabel: "Nightly", custom })).toEqual(
DEV_BACKDROP,
);
expect(resolveSidebarArtwork({ selection: "none", stageLabel: "Nightly", custom })).toBeNull();
});

it("renders the account's own artwork, and nothing once it is deleted", () => {
expect(resolveSidebarArtwork({ selection: "art_1", stageLabel: "", custom })).toEqual({
kind: "custom",
image: custom[0]!.image,
name: custom[0]!.name,
});
expect(resolveSidebarArtwork({ selection: "art_1", stageLabel: "", custom: [] })).toBeNull();
});

it("stays out of the way when artwork is switched off entirely", () => {
expect(
resolveSidebarArtwork({ selection: "night", stageLabel: "", custom, enabled: false }),
).toBeNull();
});
});
79 changes: 72 additions & 7 deletions apps/web/src/components/SidebarStageBackdrop.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,10 +4,44 @@ import { useId } from "react";
import { APP_HAS_UPDATE_TRACKS, APP_STAGE_LABEL } from "../branding";
import { resolveServerBackedAppStageLabel } from "../branding.logic";
import { primaryServerConfigAtom } from "../state/server";
import { usePrimarySettings } from "../hooks/useSettings";

export type SidebarStageBackdropVariant = "nightly" | "dev";
export type SidebarStageBackdropVariant =
| { readonly kind: "nightly" }
| { readonly kind: "dev" }
| { readonly kind: "custom"; readonly image: string; readonly name: string };
export type EnvironmentIdentificationPillLabel = "Dev" | "Nightly";

export const NIGHTLY_BACKDROP: SidebarStageBackdropVariant = { kind: "nightly" };
export const DEV_BACKDROP: SidebarStageBackdropVariant = { kind: "dev" };

/**
* Resolve the artwork to draw from the account's choice.
*
* "auto" defers to the build channel the way upstream does; every other value
* is a deliberate pick and ignores the channel entirely, which is the point on
* a single-release build like MT Code.
*/
export function resolveSidebarArtwork(input: {
readonly selection: string;
readonly stageLabel: string;
readonly custom: ReadonlyArray<{ readonly id: string; readonly name: string; readonly image: string }>;
readonly enabled?: boolean;
}): SidebarStageBackdropVariant | null {
if (input.enabled === false) return null;
const selection = input.selection.trim();
if (selection === "none") return null;
if (selection === "night") return NIGHTLY_BACKDROP;
if (selection === "day") return DEV_BACKDROP;
if (selection !== "auto" && selection.length > 0) {
const artwork = input.custom.find((entry) => entry.id === selection);
// A deleted artwork leaves the header bare rather than silently falling
// back to a scene the user did not choose.
return artwork ? { kind: "custom", image: artwork.image, name: artwork.name } : null;
}
return resolveSidebarStageBackdropVariant(input.stageLabel);
}

// A wide viewBox keeps the 96-unit art height at a fixed scale while sidebar resizing reveals
// more horizontal canvas instead of zooming the scene.
const STAGE_BACKDROP_VIEW_BOX = "0 0 8192 96";
Expand All@@ -18,15 +52,15 @@ export function resolveSidebarStageBackdropVariant(
): SidebarStageBackdropVariant | null {
if (!enabled) return null;
const normalized = stageLabel.trim().toLowerCase();
if (normalized === "nightly") return "nightly";
if (normalized === "dev") return "dev";
if (normalized === "nightly") return NIGHTLY_BACKDROP;
if (normalized === "dev") return DEV_BACKDROP;
return null;
}

export function resolveSidebarStageFocusRingOffsetClass(
variant: SidebarStageBackdropVariant,
): string {
return variant === "nightly"
return variant.kind === "nightly"
? "focus-visible:ring-offset-(--stage-night-bottom)"
: "focus-visible:ring-offset-(--stage-art-bottom)";
}
Expand All@@ -52,7 +86,17 @@ export function useEnvironmentStageLabel(): string {
}

export function useSidebarStageBackdropVariant(enabled = true): SidebarStageBackdropVariant | null {
return resolveSidebarStageBackdropVariant(useEnvironmentStageLabel(), enabled);
const stageLabel = useEnvironmentStageLabel();
const artwork = usePrimarySettings((settings) => ({
selection: settings.sidebarArtwork,
custom: settings.customSidebarArtworks,
}));
return resolveSidebarArtwork({
selection: artwork.selection,
stageLabel,
custom: artwork.custom,
enabled,
});
}

/** Stage-channel header art; palettes mirror the per-channel app icons in `assets/`. */
Expand All@@ -68,11 +112,32 @@ export function SidebarStageBackdrop({ variant }: { variant: SidebarStageBackdro
}

export function StageBackdropArt({ variant }: { variant: SidebarStageBackdropVariant }) {
return variant === "nightly" ? <NightlySkyArt /> : <DevBlueprintArt />;
if (variant.kind === "custom") return <CustomArt variant={variant} />;
return variant.kind === "nightly" ? <NightlySkyArt /> : <DevBlueprintArt />;
}

export function StageBackdropButtonArt({ variant }: { variant: SidebarStageBackdropVariant }) {
return variant === "nightly" ? <NightlySkyArt compact /> : <DevBlueprintArt compact />;
if (variant.kind === "custom") return <CustomArt variant={variant} />;
return variant.kind === "nightly" ? <NightlySkyArt compact /> : <DevBlueprintArt compact />;
}

/**
* A user's own artwork. Drawn as a cover-cropped band so any aspect ratio
* fills the header the way the built-in scenes do.
*/
function CustomArt({
variant,
}: {
variant: Extract<SidebarStageBackdropVariant, { kind: "custom" }>;
}) {
return (
<div
role="img"
aria-label={variant.name}
className="stage-art h-full w-full bg-cover bg-center bg-no-repeat"
style={{ backgroundImage: `url(${JSON.stringify(variant.image)})` }}
/>
);
}

const NIGHTLY_STARS: ReadonlyArray<{
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,6 +16,8 @@ import { toastManager } from "../ui/toast.tsx";
import { SettingsRow, SettingsSection } from "./settingsLayout.tsx";
import { searchableSetting } from "./settingsSearch.ts";

import { APP_DISPLAY_NAME } from "~/branding";

const EVENT_OPTIONS: ReadonlyArray<{
readonly event: DesktopNotificationEvent;
readonly title: string;
Expand DownExpand Up@@ -158,14 +160,14 @@ function useDesktopNotificationSettingsModel() {
};

const masterDescription = isElectron
? "Notify me when T3 Code is in the background."
? `Notify me when ${APP_DISPLAY_NAME} is in the background.`
: browserPermission.permission === "denied"
? "Blocked in your browser settings."
: browserPermission.permission === "unsupported"
? "Not supported by this browser."
: browserPermission.permission === "default"
? "Allow notifications when T3 Code is in the background."
: "Notify me when T3 Code is in the background.";
? `Allow notifications when ${APP_DISPLAY_NAME} is in the background.`
: `Notify me when ${APP_DISPLAY_NAME} is in the background.`;

return {
settings,
Expand Down
Loading
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions apps/web/src/components/Icons.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -700,25 +700,16 @@ export const ACPRegistryIcon: Icon = ({ className, ...props }) => (
export const MtModelIcon: Icon = ({ className, ...props }) => (
<svg
{...props}
viewBox="0 0 24 24"
viewBox="0 0 128 128"
fill="none"
className={cn("stroke-current", className)}
className={cn("fill-current", className)}
aria-hidden
>
{/* The Munim mark, same path the app icon draws. */}
<path
d="M12 3.2 13.7 8.3 19 10l-5.3 1.7L12 16.8l-1.7-5.1L5 10l5.3-1.7L12 3.2Z"
strokeWidth="1.7"
strokeLinejoin="round"
/>
<path
d="M18.2 15.4 19 17.8 21.4 18.6 19 19.4 18.2 21.8 17.4 19.4 15 18.6 17.4 17.8 18.2 15.4Z"
strokeWidth="1.4"
strokeLinejoin="round"
/>
<path
d="M5.4 14.8 6 16.6 7.8 17.2 6 17.8 5.4 19.6 4.8 17.8 3 17.2 4.8 16.6 5.4 14.8Z"
strokeWidth="1.4"
strokeLinejoin="round"
d="M52.547 87.884L52.710 88.313L51.914 88.231L-0.000 603.926L105.522 614.537L135.846 313.360L180.699 434.810L181.210 439.258L182.291 439.136L184.066 443.911L265.794 413.732L273.569 383.736L293.716 313.043L312.994 481.660L219.104 524.021L180.964 657.000L668.780 436.993L668.189 435.670L631.008 110.432L725.000 105.249L719.204 0.000L419.046 16.549L424.862 121.797L525.037 116.268L554.382 372.820L413.312 436.422L366.622 27.955L262.488 39.871L262.937 43.850L212.900 219.495L150.865 51.563Z"
fillRule="nonzero"
transform="translate(22.067 26.000) scale(0.115677)"
/>
</svg>
);
Expand Down
64 changes: 52 additions & 12 deletions apps/web/src/components/SidebarStageBackdrop.test.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,7 +2,10 @@ import { describe, expect, it } from "vite-plus/test";
import { renderToStaticMarkup } from "react-dom/server";

import {
DEV_BACKDROP,
NIGHTLY_BACKDROP,
resolveEnvironmentIdentificationPillLabel,
resolveSidebarArtwork,
resolveSidebarStageBackdropVariant,
resolveSidebarStageFocusRingOffsetClass,
StageBackdropArt,
Expand All@@ -11,8 +14,8 @@ import {

describe("SidebarStageBackdrop", () => {
it("resolves stage artwork only when enabled", () => {
expect(resolveSidebarStageBackdropVariant("Dev")).toBe("dev");
expect(resolveSidebarStageBackdropVariant("Nightly")).toBe("nightly");
expect(resolveSidebarStageBackdropVariant("Dev")).toEqual(DEV_BACKDROP);
expect(resolveSidebarStageBackdropVariant("Nightly")).toEqual(NIGHTLY_BACKDROP);
expect(resolveSidebarStageBackdropVariant("Dev", false)).toBeNull();
expect(resolveSidebarStageBackdropVariant("Alpha")).toBeNull();
});
Expand All@@ -25,16 +28,16 @@ describe("SidebarStageBackdrop", () => {
});

it("matches the focus-ring offset to each artwork palette", () => {
expect(resolveSidebarStageFocusRingOffsetClass("nightly")).toBe(
expect(resolveSidebarStageFocusRingOffsetClass(NIGHTLY_BACKDROP)).toBe(
"focus-visible:ring-offset-(--stage-night-bottom)",
);
expect(resolveSidebarStageFocusRingOffsetClass("dev")).toBe(
expect(resolveSidebarStageFocusRingOffsetClass(DEV_BACKDROP)).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",
it.each([NIGHTLY_BACKDROP, DEV_BACKDROP] as const)(
"uses unique SVG definition ids when $kind artwork is rendered more than once",
(variant) => {
const markup = renderToStaticMarkup(
<>
Expand All@@ -50,8 +53,8 @@ describe("SidebarStageBackdrop", () => {
);

it("paints each artwork variant with theme-owned color tokens", () => {
const nightlyMarkup = renderToStaticMarkup(<StageBackdropArt variant="nightly" />);
const devMarkup = renderToStaticMarkup(<StageBackdropArt variant="dev" />);
const nightlyMarkup = renderToStaticMarkup(<StageBackdropArt variant={NIGHTLY_BACKDROP} />);
const devMarkup = renderToStaticMarkup(<StageBackdropArt variant={DEV_BACKDROP} />);

expect(nightlyMarkup).toContain("var(--stage-night-bottom)");
expect(nightlyMarkup).toContain("var(--stage-night-line)");
Expand All@@ -62,12 +65,49 @@ describe("SidebarStageBackdrop", () => {
});

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) => {
[NIGHTLY_BACKDROP, "96 0 8192 96"],
[DEV_BACKDROP, "64 0 8192 96"],
] as const)("uses the compact 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"}`);
expect(markup).toContain(`stage-${variant.kind === "dev" ? "blueprint" : "nightly"}`);
});
});

describe("resolveSidebarArtwork", () => {
const custom = [{ id: "art_1", name: "Skyline", image: "data:image/png;base64,AAAA" }];

it("defers to the build channel only for auto", () => {
expect(resolveSidebarArtwork({ selection: "auto", stageLabel: "Nightly", custom })).toEqual(
NIGHTLY_BACKDROP,
);
// A release build has no channel artwork, which is why picking one matters.
expect(resolveSidebarArtwork({ selection: "auto", stageLabel: "", custom })).toBeNull();
});

it("honours an explicit pick regardless of channel", () => {
expect(resolveSidebarArtwork({ selection: "night", stageLabel: "", custom })).toEqual(
NIGHTLY_BACKDROP,
);
expect(resolveSidebarArtwork({ selection: "day", stageLabel: "Nightly", custom })).toEqual(
DEV_BACKDROP,
);
expect(resolveSidebarArtwork({ selection: "none", stageLabel: "Nightly", custom })).toBeNull();
});

it("renders the account's own artwork, and nothing once it is deleted", () => {
expect(resolveSidebarArtwork({ selection: "art_1", stageLabel: "", custom })).toEqual({
kind: "custom",
image: custom[0]!.image,
name: custom[0]!.name,
});
expect(resolveSidebarArtwork({ selection: "art_1", stageLabel: "", custom: [] })).toBeNull();
});

it("stays out of the way when artwork is switched off entirely", () => {
expect(
resolveSidebarArtwork({ selection: "night", stageLabel: "", custom, enabled: false }),
).toBeNull();
});
});
79 changes: 72 additions & 7 deletions apps/web/src/components/SidebarStageBackdrop.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,10 +4,44 @@ import { useId } from "react";
import { APP_HAS_UPDATE_TRACKS, APP_STAGE_LABEL } from "../branding";
import { resolveServerBackedAppStageLabel } from "../branding.logic";
import { primaryServerConfigAtom } from "../state/server";
import { usePrimarySettings } from "../hooks/useSettings";

export type SidebarStageBackdropVariant = "nightly" | "dev";
export type SidebarStageBackdropVariant =
| { readonly kind: "nightly" }
| { readonly kind: "dev" }
| { readonly kind: "custom"; readonly image: string; readonly name: string };
export type EnvironmentIdentificationPillLabel = "Dev" | "Nightly";

export const NIGHTLY_BACKDROP: SidebarStageBackdropVariant = { kind: "nightly" };
export const DEV_BACKDROP: SidebarStageBackdropVariant = { kind: "dev" };

/**
* Resolve the artwork to draw from the account's choice.
*
* "auto" defers to the build channel the way upstream does; every other value
* is a deliberate pick and ignores the channel entirely, which is the point on
* a single-release build like MT Code.
*/
export function resolveSidebarArtwork(input: {
readonly selection: string;
readonly stageLabel: string;
readonly custom: ReadonlyArray<{ readonly id: string; readonly name: string; readonly image: string }>;
readonly enabled?: boolean;
}): SidebarStageBackdropVariant | null {
if (input.enabled === false) return null;
const selection = input.selection.trim();
if (selection === "none") return null;
if (selection === "night") return NIGHTLY_BACKDROP;
if (selection === "day") return DEV_BACKDROP;
if (selection !== "auto" && selection.length > 0) {
const artwork = input.custom.find((entry) => entry.id === selection);
// A deleted artwork leaves the header bare rather than silently falling
// back to a scene the user did not choose.
return artwork ? { kind: "custom", image: artwork.image, name: artwork.name } : null;
}
return resolveSidebarStageBackdropVariant(input.stageLabel);
}

// A wide viewBox keeps the 96-unit art height at a fixed scale while sidebar resizing reveals
// more horizontal canvas instead of zooming the scene.
const STAGE_BACKDROP_VIEW_BOX = "0 0 8192 96";
Expand All@@ -18,15 +52,15 @@ export function resolveSidebarStageBackdropVariant(
): SidebarStageBackdropVariant | null {
if (!enabled) return null;
const normalized = stageLabel.trim().toLowerCase();
if (normalized === "nightly") return "nightly";
if (normalized === "dev") return "dev";
if (normalized === "nightly") return NIGHTLY_BACKDROP;
if (normalized === "dev") return DEV_BACKDROP;
return null;
}

export function resolveSidebarStageFocusRingOffsetClass(
variant: SidebarStageBackdropVariant,
): string {
return variant === "nightly"
return variant.kind === "nightly"
? "focus-visible:ring-offset-(--stage-night-bottom)"
: "focus-visible:ring-offset-(--stage-art-bottom)";
}
Expand All@@ -52,7 +86,17 @@ export function useEnvironmentStageLabel(): string {
}

export function useSidebarStageBackdropVariant(enabled = true): SidebarStageBackdropVariant | null {
return resolveSidebarStageBackdropVariant(useEnvironmentStageLabel(), enabled);
const stageLabel = useEnvironmentStageLabel();
const artwork = usePrimarySettings((settings) => ({
selection: settings.sidebarArtwork,
custom: settings.customSidebarArtworks,
}));
return resolveSidebarArtwork({
selection: artwork.selection,
stageLabel,
custom: artwork.custom,
enabled,
});
}

/** Stage-channel header art; palettes mirror the per-channel app icons in `assets/`. */
Expand All@@ -68,11 +112,32 @@ export function SidebarStageBackdrop({ variant }: { variant: SidebarStageBackdro
}

export function StageBackdropArt({ variant }: { variant: SidebarStageBackdropVariant }) {
return variant === "nightly" ? <NightlySkyArt /> : <DevBlueprintArt />;
if (variant.kind === "custom") return <CustomArt variant={variant} />;
return variant.kind === "nightly" ? <NightlySkyArt /> : <DevBlueprintArt />;
}

export function StageBackdropButtonArt({ variant }: { variant: SidebarStageBackdropVariant }) {
return variant === "nightly" ? <NightlySkyArt compact /> : <DevBlueprintArt compact />;
if (variant.kind === "custom") return <CustomArt variant={variant} />;
return variant.kind === "nightly" ? <NightlySkyArt compact /> : <DevBlueprintArt compact />;
}

/**
* A user's own artwork. Drawn as a cover-cropped band so any aspect ratio
* fills the header the way the built-in scenes do.
*/
function CustomArt({
variant,
}: {
variant: Extract<SidebarStageBackdropVariant, { kind: "custom" }>;
}) {
return (
<div
role="img"
aria-label={variant.name}
className="stage-art h-full w-full bg-cover bg-center bg-no-repeat"
style={{ backgroundImage: `url(${JSON.stringify(variant.image)})` }}
/>
);
}

const NIGHTLY_STARS: ReadonlyArray<{
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,6 +16,8 @@ import { toastManager } from "../ui/toast.tsx";
import { SettingsRow, SettingsSection } from "./settingsLayout.tsx";
import { searchableSetting } from "./settingsSearch.ts";

import { APP_DISPLAY_NAME } from "~/branding";

const EVENT_OPTIONS: ReadonlyArray<{
readonly event: DesktopNotificationEvent;
readonly title: string;
Expand DownExpand Up@@ -158,14 +160,14 @@ function useDesktopNotificationSettingsModel() {
};

const masterDescription = isElectron
? "Notify me when T3 Code is in the background."
? `Notify me when ${APP_DISPLAY_NAME} is in the background.`
: browserPermission.permission === "denied"
? "Blocked in your browser settings."
: browserPermission.permission === "unsupported"
? "Not supported by this browser."
: browserPermission.permission === "default"
? "Allow notifications when T3 Code is in the background."
: "Notify me when T3 Code is in the background.";
? `Allow notifications when ${APP_DISPLAY_NAME} is in the background.`
: `Notify me when ${APP_DISPLAY_NAME} is in the background.`;

return {
settings,
Expand Down
Loading
Loading