Skip to content

πŸ™Œ OpenHands: AI-Driven Development

fix(themes): make Home mode toggle labels readable in light themes (#18402)

Engel Nyst8eca03636ac9
diff --git a/__tests__/themes/color-themes.test.tsx b/__tests__/themes/color-themes.test.tsx
index 357b1f9cfd..c516e00186 100644
--- a/__tests__/themes/color-themes.test.tsx
+++ b/__tests__/themes/color-themes.test.tsx
@@ -18,7 +18,7 @@ describe("color themes", () => {
// @spec MCP-004 β€” Form feedback follows readable theme text roles
// @spec WN-001 β€” Warning feedback also meets the small-text contrast contract
it.each(Object.entries(COLOR_THEMES))(
- "keeps small feedback text readable on the %s modal surface",
+ "keeps small text readable on the %s theme surfaces",
(_key, theme) => {
// Resolve the shipped palette, including stylesheet-owned defaults.
const variables: Record<string, string> = {
@@ -60,6 +60,15 @@ describe("color themes", () => {
).toBeGreaterThanOrEqual(4.5);
}
+ // @spec HL-001 β€” Home mode labels stay readable on the hover pill
+ expect(
+ contrast(
+ luminance(resolve("--oh-contrast")),
+ luminance(resolve("--oh-interactive-hover")),
+ ),
+ "--oh-contrast against the Home mode toggle pill",
+ ).toBeGreaterThanOrEqual(4.5);
+
const warningInk = luminance(resolve("--oh-feedback-warning"));
const trustBackground = channels(resolve("--oh-background"));
const warningTint = channels(resolve("--oh-warning"));
diff --git a/specs/home-launcher.md b/specs/home-launcher.md
new file mode 100644
index 0000000000..0f45078756
--- /dev/null
+++ b/specs/home-launcher.md
@@ -0,0 +1,5 @@
+# Home launcher specs
+
+### HL-001: Readable Code/Automate mode toggle
+
+- [x] The selected mode label, and an unselected label while hovered, shall use the `contrast` high-emphasis ink on the `--oh-interactive-hover` pill. The built-in palettes keep that pairing at 4.5:1 or better: white in dark palettes, dark ink in Light+ and Solarized Light. Embedding roots may override `--oh-contrast`, and the toggle follows the nearest `[data-agent-server-ui]` scope. Mode selection, keyboard and radio semantics, and the pill animation are unchanged.
diff --git a/src/components/features/home/home-launcher-mode-toggle.tsx b/src/components/features/home/home-launcher-mode-toggle.tsx
index b748f9d1a4..fb15a4bc48 100644
--- a/src/components/features/home/home-launcher-mode-toggle.tsx
+++ b/src/components/features/home/home-launcher-mode-toggle.tsx
@@ -153,9 +153,10 @@ export function HomeLauncherModeToggle({
className={cn(
"relative inline-flex items-center gap-2 rounded-full px-5 py-2",
"cursor-pointer transition-colors",
+ // @spec HL-001 β€” Labels on the hover pill use the theme's high-emphasis ink
isActive
- ? "text-white"
- : "text-[var(--oh-muted)] hover:text-white",
+ ? "text-contrast"
+ : "text-[var(--oh-muted)] hover:text-contrast",
disableAnimation &&
isActive &&
"bg-[var(--oh-interactive-hover)]",
diff --git a/tests/e2e/mock-llm/regressions/mock-llm-ui-regressions.spec.ts b/tests/e2e/mock-llm/regressions/mock-llm-ui-regressions.spec.ts
index c458852f33..906b929c62 100644
--- a/tests/e2e/mock-llm/regressions/mock-llm-ui-regressions.spec.ts
+++ b/tests/e2e/mock-llm/regressions/mock-llm-ui-regressions.spec.ts
@@ -757,4 +757,25 @@ test.describe("UI regressions", () => {
});
await expect(notice).toHaveCSS("color", "rgb(139, 16, 41)");
});
+
+ // @spec HL-001 β€” Home mode labels follow the embedding host's contrast ink
+ test("home mode toggle labels follow the host contrast color", async ({
+ page,
+ }) => {
+ await routeSessionApiKey(page);
+ await page.goto("/", { waitUntil: "domcontentloaded" });
+ const toggle = page.getByTestId("home-launcher-mode-toggle");
+ const selected = toggle.getByRole("radio", { checked: true });
+ const unselected = toggle.getByRole("radio", { checked: false });
+ await expect(selected).toBeVisible();
+ await toggle.evaluate((element) => {
+ const scope = element.closest("[data-agent-server-ui]");
+ if (!scope) throw new Error("Agent Server UI theme scope not found");
+ (scope as HTMLElement).style.setProperty("--oh-contrast", "#8b1029");
+ });
+
+ await expect(selected).toHaveCSS("color", "rgb(139, 16, 41)");
+ await unselected.hover();
+ await expect(unselected).toHaveCSS("color", "rgb(139, 16, 41)");
+ });
});