Skip to content

πŸ™Œ OpenHands: AI-Driven Development

fix(theme): keep Markdown links readable across themes (#18530)

Engel Nyst9c99443a7e75
diff --git a/__tests__/themes/color-themes.test.tsx b/__tests__/themes/color-themes.test.tsx
index f5ae5e1578..5e3595b4fe 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 feedback and keyboard focus readable on the %s theme surfaces",
+ "keeps feedback, links, and keyboard focus readable on the %s theme surfaces",
(_key, theme) => {
// Resolve the shipped palette, including stylesheet-owned defaults.
const variables: Record<string, string> = {
@@ -60,6 +60,41 @@ describe("color themes", () => {
).toBeGreaterThanOrEqual(4.5);
}
+ // Markdown links appear in chat, user bubbles, and file/plan previews.
+ for (const surfaceRole of [
+ "--oh-color-base",
+ "--oh-color-base-secondary",
+ "--oh-surface-raised",
+ "--oh-color-tertiary",
+ ]) {
+ expect(
+ contrast(
+ luminance(resolve("--oh-link")),
+ luminance(resolve(surfaceRole)),
+ ),
+ `--oh-link against ${surfaceRole}`,
+ ).toBeGreaterThanOrEqual(4.5);
+
+ // Single GitHub alert panels tint each Markdown host surface at 10%.
+ // These are the shipped Tailwind v4 alert colors resolved to sRGB.
+ for (const [alert, color] of [
+ ["Note", "#2b7fff"],
+ ["Tip", "#00bc7d"],
+ ["Important", "#ad46ff"],
+ ["Warning", "#efb100"],
+ ["Caution", "#ff2056"],
+ ]) {
+ const host = channels(resolve(surfaceRole));
+ const alertSurface = channels(color).map(
+ (channel, index) => channel * 0.1 + host[index] * 0.9,
+ );
+ expect(
+ contrast(luminance(resolve("--oh-link")), luminance(alertSurface)),
+ `--oh-link against ${alert} tint over ${surfaceRole}`,
+ ).toBeGreaterThanOrEqual(4.5);
+ }
+ }
+
const statusSurfaces = ["--oh-color-base", "--oh-color-base-secondary"];
const statusTextRoles = [
["--oh-feedback-success", "--oh-status-success"],
diff --git a/src/components/features/markdown/anchor.tsx b/src/components/features/markdown/anchor.tsx
index 519d5e9a78..e3d8510372 100644
--- a/src/components/features/markdown/anchor.tsx
+++ b/src/components/features/markdown/anchor.tsx
@@ -9,7 +9,7 @@ export function anchor({
ExtraProps) {
return (
<a
- className="text-blue-500 hover:underline"
+ className="text-link underline"
href={href}
target="_blank"
rel="noopener noreferrer"
diff --git a/src/components/features/markdown/plan-components.tsx b/src/components/features/markdown/plan-components.tsx
index 7034ae6d3f..38a967428b 100644
--- a/src/components/features/markdown/plan-components.tsx
+++ b/src/components/features/markdown/plan-components.tsx
@@ -121,11 +121,7 @@ export function createPlanComponents(extraClassName?: string) {
),
a: ({ children, className, href }: AnchorProps) => (
<a
- className={cn(
- "text-blue-500 hover:underline",
- className,
- extraClassName,
- )}
+ className={cn("text-link underline", className, extraClassName)}
href={href}
target="_blank"
rel="noopener noreferrer"
diff --git a/src/tailwind.css b/src/tailwind.css
index f02b8a75ac..ce0df66bdc 100644
--- a/src/tailwind.css
+++ b/src/tailwind.css
@@ -42,6 +42,7 @@
--color-text-secondary: var(--oh-text-secondary);
--color-text-tertiary: var(--oh-text-tertiary);
--color-muted: var(--oh-muted);
+ --color-link: var(--oh-link);
--color-text-dim: var(--oh-text-dim);
--color-text-subtle: var(--oh-text-subtle);
--color-modal-title: var(--oh-modal-title-foreground);
diff --git a/src/themes/color-theme/definitions/light-plus.ts b/src/themes/color-theme/definitions/light-plus.ts
index 44735c8d59..7542a0b362 100644
--- a/src/themes/color-theme/definitions/light-plus.ts
+++ b/src/themes/color-theme/definitions/light-plus.ts
@@ -115,7 +115,7 @@ export const LIGHT_PLUS_TOKENS: Partial<
"--oh-focus": "#007ACC",
"--oh-status-success": "#16825D",
"--oh-status-error": "#D13438",
- "--oh-link": "#006AB1",
+ "--oh-link": "#005A99",
"--oh-bg-dark": "#FFFFFF",
"--oh-bg-light": "#F3F3F3",
"--oh-bg-input": "#FFFFFF",
diff --git a/src/themes/color-theme/definitions/solarized-light.ts b/src/themes/color-theme/definitions/solarized-light.ts
index 51fbe62a69..078b646261 100644
--- a/src/themes/color-theme/definitions/solarized-light.ts
+++ b/src/themes/color-theme/definitions/solarized-light.ts
@@ -118,7 +118,7 @@ const SOLARIZED_LIGHT_TOKENS: Partial<
"--oh-focus": "#227FBE",
"--oh-status-success": "#859900",
"--oh-status-error": "#DC322F",
- "--oh-link": "#268BD2",
+ "--oh-link": "#005A88",
"--oh-bg-dark": "#FDF6E3",
"--oh-bg-light": "#EEE8D5",
"--oh-bg-input": "#FDF6E3",