feat(site): force-enable kyleosophy on dev.coder.com (#23892)

- Force-enable Kyleosophy on `dev.coder.com` via hostname check
- Toggle shows as checked + disabled with "Kyleosophy is mandatory on
`dev.coder.com`"
- `isKylesophyForced()` exported for UI and testability
- Tests for forced/non-forced hostname behavior

> 🤖 Written by a Coder Agent. Reviewed by a human.
This commit is contained in:
Cian Johnston
2026-04-01 11:39:04 +01:00
committed by GitHub
parent bec426b24f
commit 7ddde0887b
3 changed files with 67 additions and 1 deletions
@@ -13,7 +13,11 @@ import { DurationField } from "./components/DurationField/DurationField";
import { SectionHeader } from "./components/SectionHeader";
import { TextPreviewDialog } from "./components/TextPreviewDialog";
import { UserCompactionThresholdSettings } from "./components/UserCompactionThresholdSettings";
import { getKylesophyEnabled, setKylesophyEnabled } from "./utils/chime";
import {
getKylesophyEnabled,
isKylesophyForced,
setKylesophyEnabled,
} from "./utils/chime";
const textareaMaxHeight = 240;
const textareaBaseClassName =
@@ -125,6 +129,7 @@ export const AgentSettingsBehaviorPageView: FC<
const [isUserPromptOverflowing, setIsUserPromptOverflowing] = useState(false);
const [isSystemPromptOverflowing, setIsSystemPromptOverflowing] =
useState(false);
const kylesophyForced = isKylesophyForced();
const [kylesophyEnabled, setKylesophyLocal] = useState(getKylesophyEnabled);
// ── Derived state ──
@@ -521,6 +526,11 @@ export const AgentSettingsBehaviorPageView: FC<
<div className="flex items-center justify-between gap-4">
<p className="!mt-0.5 m-0 flex-1 text-xs text-content-secondary">
Replace the standard completion chime. IYKYK.
{kylesophyForced && (
<span className="ml-1 font-semibold">
Kyleosophy is mandatory on <code>dev.coder.com</code>.
</span>
)}
</p>
<Switch
checked={kylesophyEnabled}
@@ -529,6 +539,7 @@ export const AgentSettingsBehaviorPageView: FC<
setKylesophyLocal(checked);
}}
aria-label="Enable Kyleosophy"
disabled={kylesophyForced}
/>
</div>
</div>
@@ -2,6 +2,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import {
getChimeEnabled,
getKylesophyEnabled,
isKylesophyForced,
KYLEOSOPHY_SOUNDS,
LOCK_HOLD_MS,
maybePlayChime,
@@ -313,3 +314,38 @@ describe("maybePlayChime", () => {
expect(url).toBe("/chime.mp3");
});
});
// ---------------------------------------------------------------------------
// isKylesophyForced
// ---------------------------------------------------------------------------
describe("isKylesophyForced", () => {
const originalLocation = globalThis.location;
afterEach(() => {
Object.defineProperty(globalThis, "location", {
value: originalLocation,
writable: true,
configurable: true,
});
});
it("returns true on dev.coder.com", () => {
Object.defineProperty(globalThis, "location", {
value: { hostname: "dev.coder.com" },
writable: true,
configurable: true,
});
expect(isKylesophyForced()).toBe(true);
expect(getKylesophyEnabled()).toBe(true);
});
it("returns false on other hosts", () => {
Object.defineProperty(globalThis, "location", {
value: { hostname: "coder.example.com" },
writable: true,
configurable: true,
});
expect(isKylesophyForced()).toBe(false);
});
});
+19
View File
@@ -20,7 +20,14 @@ export function setChimeEnabled(enabled: boolean): void {
}
}
/**
* Whether Kyleosophy mode is active. Force-enabled on
* dev.coder.com because the people deserve Kyle.
*/
export function getKylesophyEnabled(): boolean {
if (isKylesophyForced()) {
return true;
}
try {
const stored = localStorage.getItem(KYLEOSOPHY_PREFERENCE_KEY);
return stored === null ? false : stored === "true";
@@ -29,6 +36,18 @@ export function getKylesophyEnabled(): boolean {
}
}
/**
* Whether the current deployment force-enables Kyleosophy,
* bypassing the user preference.
*/
export function isKylesophyForced(): boolean {
try {
return globalThis.location?.hostname === "dev.coder.com";
} catch {
return false;
}
}
export function setKylesophyEnabled(enabled: boolean): void {
try {
localStorage.setItem(KYLEOSOPHY_PREFERENCE_KEY, String(enabled));