Skip to content

πŸ™Œ OpenHands: AI-Driven Development

fix(chat): show git chip icons in light themes (#18660)

Engel Nyst1f7b1e69a19c
diff --git a/.pr/git-chip-icons/README.md b/.pr/git-chip-icons/README.md
new file mode 100644
index 0000000000..967a92bdcb
--- /dev/null
+++ b/.pr/git-chip-icons/README.md
@@ -0,0 +1,44 @@
+# Git chip icons in light themes (#18657)
+
+Before/after evidence for the workspace, branch, external-link and
+workspace-mode chip icons. `before-*` was served from main (product source
+identical to `79abd32d8`); `after-*` from this branch.
+
+## Commands
+
+```sh
+export OH_VERIFY_RUN=$(control-openhands launch --new --print-run) # once per checkout
+control-openhands doctor
+# <run>/private/home/.config/uv/uv.toml pins litellm (SDK#6088), then:
+control-openhands restart
+control-openhands llm preset deepseek && control-openhands onboard --skip
+control-openhands fixture git-repo --name qa-repo
+control-openhands fixture git-repo --name qa-gh --remote https://github.com/qa-example/qa-gh.git
+control-openhands conversation start --workspace qa-repo --prompt "Reply with only the word OK. Do not run any tools." --wait
+control-openhands conversation start --workspace qa-gh --prompt "Reply with only the word OK. Do not run any tools." --wait
+# For each of Light+, Solarized Light, OpenHands-Neutral (default):
+control-openhands browser goto /settings/app
+control-openhands browser choose 'testid=color-theme-input' "<theme>"
+control-openhands browser goto /conversations/<id> # desktop and `viewport phone` (390x844)
+control-openhands browser eval "<getComputedStyle(svg).color vs nearest opaque background, WCAG ratio>"
+control-openhands browser screenshot --feature F07.git-control-bar --name <tag>-<theme>-<viewport>
+# GitHub-origin chip: hover the repo link so the external-link icon shows.
+# Home composer: `workspace open <run>/workspace/qa-repo` shows the workspace-mode chip.
+```
+
+## Measured icon contrast
+
+| Chip icon | Theme | Before | After |
+|---|---|---|---|
+| workspace + branch (conversation, desktop and 390x844) | Light+ | `#FFF` on `#FFF`, 1.00:1 | `rgb(31,31,31)` on `#FFF`, 16.48:1 |
+| workspace + branch (conversation, desktop and 390x844) | Solarized Light | `#FFF` on `rgb(253,246,227)`, 1.08:1 | `rgb(0,43,54)`, 13.92:1 |
+| workspace + branch (conversation, desktop and 390x844) | Default dark | `#FFF` on `rgb(24,24,24)`, 17.76:1 | unchanged, 17.76:1 |
+| external link (GitHub chip, hover gradient end) | Light+ | `#FFF` on `rgb(229,229,229)`, 1.26:1 | 13.08:1 |
+| external link (GitHub chip, hover gradient end) | Solarized Light | `#FFF` on `rgb(230,223,204)`, 1.33:1 | 11.29:1 |
+| external link (GitHub chip, hover gradient end) | Default dark | `#FFF` on `rgb(49,49,49)`, 13.01:1 | unchanged, 13.01:1 |
+| workspace-mode "Local Repo" (home composer) | Light+ | 1.00:1 | 16.48:1 |
+| workspace-mode "Local Repo" (home composer) | Solarized Light | 1.08:1 | 13.92:1 |
+| workspace-mode "Local Repo" (home composer) | Default dark | 17.76:1 | unchanged, 17.76:1 |
+
+No chip icon in `chat-git-control-bar` or `home-git-control-bar-preview` has a
+`color` attribute after the fix.
diff --git a/.pr/git-chip-icons/after-default-desktop.png b/.pr/git-chip-icons/after-default-desktop.png
new file mode 100644
index 0000000000..0622e516a6
Binary files /dev/null and b/.pr/git-chip-icons/after-default-desktop.png differ
diff --git a/.pr/git-chip-icons/after-default-github-hover.png b/.pr/git-chip-icons/after-default-github-hover.png
new file mode 100644
index 0000000000..74874f8201
Binary files /dev/null and b/.pr/git-chip-icons/after-default-github-hover.png differ
diff --git a/.pr/git-chip-icons/after-default-home-chips.png b/.pr/git-chip-icons/after-default-home-chips.png
new file mode 100644
index 0000000000..f944f345a5
Binary files /dev/null and b/.pr/git-chip-icons/after-default-home-chips.png differ
diff --git a/.pr/git-chip-icons/after-default-phone.png b/.pr/git-chip-icons/after-default-phone.png
new file mode 100644
index 0000000000..791ad642dd
Binary files /dev/null and b/.pr/git-chip-icons/after-default-phone.png differ
diff --git a/.pr/git-chip-icons/after-lightplus-desktop.png b/.pr/git-chip-icons/after-lightplus-desktop.png
new file mode 100644
index 0000000000..82e22f4505
Binary files /dev/null and b/.pr/git-chip-icons/after-lightplus-desktop.png differ
diff --git a/.pr/git-chip-icons/after-lightplus-github-hover.png b/.pr/git-chip-icons/after-lightplus-github-hover.png
new file mode 100644
index 0000000000..706287b7a8
Binary files /dev/null and b/.pr/git-chip-icons/after-lightplus-github-hover.png differ
diff --git a/.pr/git-chip-icons/after-lightplus-home-chips.png b/.pr/git-chip-icons/after-lightplus-home-chips.png
new file mode 100644
index 0000000000..d8fbb81c1a
Binary files /dev/null and b/.pr/git-chip-icons/after-lightplus-home-chips.png differ
diff --git a/.pr/git-chip-icons/after-lightplus-phone.png b/.pr/git-chip-icons/after-lightplus-phone.png
new file mode 100644
index 0000000000..a03760162b
Binary files /dev/null and b/.pr/git-chip-icons/after-lightplus-phone.png differ
diff --git a/.pr/git-chip-icons/after-solarized-desktop.png b/.pr/git-chip-icons/after-solarized-desktop.png
new file mode 100644
index 0000000000..f1486312d2
Binary files /dev/null and b/.pr/git-chip-icons/after-solarized-desktop.png differ
diff --git a/.pr/git-chip-icons/after-solarized-github-hover.png b/.pr/git-chip-icons/after-solarized-github-hover.png
new file mode 100644
index 0000000000..4e5577543d
Binary files /dev/null and b/.pr/git-chip-icons/after-solarized-github-hover.png differ
diff --git a/.pr/git-chip-icons/after-solarized-home-chips.png b/.pr/git-chip-icons/after-solarized-home-chips.png
new file mode 100644
index 0000000000..80935ad54c
Binary files /dev/null and b/.pr/git-chip-icons/after-solarized-home-chips.png differ
diff --git a/.pr/git-chip-icons/after-solarized-phone.png b/.pr/git-chip-icons/after-solarized-phone.png
new file mode 100644
index 0000000000..0d15a36a68
Binary files /dev/null and b/.pr/git-chip-icons/after-solarized-phone.png differ
diff --git a/.pr/git-chip-icons/before-default-desktop.png b/.pr/git-chip-icons/before-default-desktop.png
new file mode 100644
index 0000000000..37f95e1e67
Binary files /dev/null and b/.pr/git-chip-icons/before-default-desktop.png differ
diff --git a/.pr/git-chip-icons/before-default-github-hover.png b/.pr/git-chip-icons/before-default-github-hover.png
new file mode 100644
index 0000000000..c89c545693
Binary files /dev/null and b/.pr/git-chip-icons/before-default-github-hover.png differ
diff --git a/.pr/git-chip-icons/before-default-home-chips.png b/.pr/git-chip-icons/before-default-home-chips.png
new file mode 100644
index 0000000000..f944f345a5
Binary files /dev/null and b/.pr/git-chip-icons/before-default-home-chips.png differ
diff --git a/.pr/git-chip-icons/before-default-phone.png b/.pr/git-chip-icons/before-default-phone.png
new file mode 100644
index 0000000000..9e69df8909
Binary files /dev/null and b/.pr/git-chip-icons/before-default-phone.png differ
diff --git a/.pr/git-chip-icons/before-lightplus-desktop.png b/.pr/git-chip-icons/before-lightplus-desktop.png
new file mode 100644
index 0000000000..7de51ae7ff
Binary files /dev/null and b/.pr/git-chip-icons/before-lightplus-desktop.png differ
diff --git a/.pr/git-chip-icons/before-lightplus-github-hover.png b/.pr/git-chip-icons/before-lightplus-github-hover.png
new file mode 100644
index 0000000000..c9fee6cfbc
Binary files /dev/null and b/.pr/git-chip-icons/before-lightplus-github-hover.png differ
diff --git a/.pr/git-chip-icons/before-lightplus-home-chips.png b/.pr/git-chip-icons/before-lightplus-home-chips.png
new file mode 100644
index 0000000000..ca4b261168
Binary files /dev/null and b/.pr/git-chip-icons/before-lightplus-home-chips.png differ
diff --git a/.pr/git-chip-icons/before-lightplus-phone.png b/.pr/git-chip-icons/before-lightplus-phone.png
new file mode 100644
index 0000000000..38e4294947
Binary files /dev/null and b/.pr/git-chip-icons/before-lightplus-phone.png differ
diff --git a/.pr/git-chip-icons/before-solarized-desktop.png b/.pr/git-chip-icons/before-solarized-desktop.png
new file mode 100644
index 0000000000..6a2a339024
Binary files /dev/null and b/.pr/git-chip-icons/before-solarized-desktop.png differ
diff --git a/.pr/git-chip-icons/before-solarized-github-hover.png b/.pr/git-chip-icons/before-solarized-github-hover.png
new file mode 100644
index 0000000000..5268211128
Binary files /dev/null and b/.pr/git-chip-icons/before-solarized-github-hover.png differ
diff --git a/.pr/git-chip-icons/before-solarized-home-chips.png b/.pr/git-chip-icons/before-solarized-home-chips.png
new file mode 100644
index 0000000000..55b4261f8e
Binary files /dev/null and b/.pr/git-chip-icons/before-solarized-home-chips.png differ
diff --git a/.pr/git-chip-icons/before-solarized-phone.png b/.pr/git-chip-icons/before-solarized-phone.png
new file mode 100644
index 0000000000..d48d413407
Binary files /dev/null and b/.pr/git-chip-icons/before-solarized-phone.png differ
diff --git a/__tests__/components/features/chat/git-chip-icons.test.tsx b/__tests__/components/features/chat/git-chip-icons.test.tsx
new file mode 100644
index 0000000000..92386ca9e9
--- /dev/null
+++ b/__tests__/components/features/chat/git-chip-icons.test.tsx
@@ -0,0 +1,107 @@
+import type { ReactElement } from "react";
+import { render } from "@testing-library/react";
+import { describe, it, expect, vi } from "vitest";
+import { GitControlBarBranchButton } from "#/components/features/chat/git-control-bar-branch-button";
+import { GitControlBarRepoButton } from "#/components/features/chat/git-control-bar-repo-button";
+import { WorkspaceModeSelector } from "#/components/features/chat/workspace-mode-selector";
+
+vi.mock("react-i18next", () => ({
+ useTranslation: () => ({ t: (key: string) => key }),
+}));
+
+vi.mock("#/hooks/query/use-settings", () => ({
+ useSettings: () => ({ data: { provider_tokens_set: {} } }),
+}));
+
+// Chip icons must take the theme's ink through `currentColor`, from the same
+// colour class as the chip label. A fixed `color` (or fill/stroke) on the SVG
+// overrides that inheritance and made the icons white-on-white in light themes
+// (#18657).
+const INK_CLASS =
+ /^text-(contrast|muted|white|black|current|foreground|feedback-[a-z-]+|status-[a-z-]+|\[[^\]]+\])$/;
+
+// The colour class an element's text and `currentColor` resolve from: the
+// nearest ancestor-or-self class that sets the text colour.
+function inkClass(element: Element): string | null {
+ for (let node: Element | null = element; node; node = node.parentElement) {
+ const ink = Array.from(node.classList).find((name) => INK_CLASS.test(name));
+ if (ink) return ink;
+ }
+ return null;
+}
+
+function expectNoFixedColour(icon: SVGSVGElement) {
+ expect(icon).not.toHaveAttribute("color");
+ for (const node of [icon, ...Array.from(icon.querySelectorAll("*"))]) {
+ for (const attribute of ["fill", "stroke"]) {
+ const value = node.getAttribute(attribute);
+ if (value !== null) expect(["none", "currentColor"]).toContain(value);
+ }
+ }
+}
+
+describe("git control bar chip icons", () => {
+ it.each<[string, () => ReactElement, string]>([
+ [
+ "linked branch chip (branch and external-link icons)",
+ () => (
+ <GitControlBarBranchButton
+ selectedBranch="main"
+ selectedRepository="owner/repo"
+ gitProvider="github"
+ />
+ ),
+ "main",
+ ],
+ [
+ "unlinked branch chip",
+ () => (
+ <GitControlBarBranchButton
+ selectedBranch="main"
+ selectedRepository={null}
+ gitProvider={null}
+ />
+ ),
+ "main",
+ ],
+ [
+ "local workspace chip",
+ () => (
+ <GitControlBarRepoButton
+ selectedRepository={null}
+ gitProvider={null}
+ workspaceName="qa-repo"
+ />
+ ),
+ "qa-repo",
+ ],
+ [
+ "workspace mode chip",
+ () => (
+ <WorkspaceModeSelector
+ value="local_repo"
+ backendKind="local"
+ onChange={() => {}}
+ />
+ ),
+ "",
+ ],
+ ])(
+ "%s icons take the same theme ink as the label",
+ (_name, renderChip, labelText) => {
+ const { container, getByText } = render(renderChip());
+ const label = labelText
+ ? getByText(labelText)
+ : container.querySelector("button span.truncate")!;
+ const labelInk = inkClass(label);
+ expect(labelInk).toBe("text-contrast");
+
+ const icons = Array.from(container.querySelectorAll("svg"));
+ expect(icons.length).toBeGreaterThan(0);
+ for (const icon of icons) {
+ expectNoFixedColour(icon);
+ expect(inkClass(icon)).toBe(labelInk);
+ }
+ },
+ );
+});
diff --git a/src/components/features/chat/git-control-bar-branch-button.tsx b/src/components/features/chat/git-control-bar-branch-button.tsx
index 47fc80d5e9..314af0ad96 100644
--- a/src/components/features/chat/git-control-bar-branch-button.tsx
+++ b/src/components/features/chat/git-control-bar-branch-button.tsx
@@ -52,8 +52,8 @@ export function GitControlBarBranchButton({
: "border border-[rgba(71,74,84,0.50)] bg-transparent cursor-not-allowed min-w-27",
)}
>
- <div className="w-3 h-3 flex items-center justify-center flex-shrink-0">
- <BranchIcon width={12} height={12} color="white" />
+ <div className="w-3 h-3 flex items-center justify-center flex-shrink-0 text-contrast">
+ <BranchIcon width={12} height={12} />
</div>
<div
className="font-normal text-contrast text-sm leading-5 truncate"
diff --git a/src/components/features/chat/git-control-bar-repo-button.tsx b/src/components/features/chat/git-control-bar-repo-button.tsx
index 07e2a772bd..15b9aa557d 100644
--- a/src/components/features/chat/git-control-bar-repo-button.tsx
+++ b/src/components/features/chat/git-control-bar-repo-button.tsx
@@ -97,7 +97,7 @@ export function GitControlBarRepoButton({
data-testid="git-control-bar-connect-repo-icon"
/>
) : (
- <RepoForkedIcon width={12} height={12} color="white" />
+ <RepoForkedIcon width={12} height={12} />
)}
</div>
<div
diff --git a/src/components/features/chat/git-external-link-icon.tsx b/src/components/features/chat/git-external-link-icon.tsx
index c6d4ed2ea3..45b0e9461d 100644
--- a/src/components/features/chat/git-external-link-icon.tsx
+++ b/src/components/features/chat/git-external-link-icon.tsx
@@ -9,11 +9,11 @@ export function GitExternalLinkIcon({ className }: GitExternalLinkIconProps) {
return (
<div
className={cn(
- "w-3 h-3 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity duration-300 absolute right-0 top-1/2 -translate-y-1/2 h-full w-10.5 pr-2.5 justify-end git-external-link-icon",
+ "w-3 h-3 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity duration-300 absolute right-0 top-1/2 -translate-y-1/2 h-full w-10.5 pr-2.5 justify-end text-contrast git-external-link-icon",
className,
)}
>
- <LinkExternalIcon width={12} height={12} color="white" />
+ <LinkExternalIcon width={12} height={12} />
</div>
);
}
diff --git a/src/components/features/chat/workspace-mode-icon.tsx b/src/components/features/chat/workspace-mode-icon.tsx
index 56bc9bc2f4..c40d3c9db5 100644
--- a/src/components/features/chat/workspace-mode-icon.tsx
+++ b/src/components/features/chat/workspace-mode-icon.tsx
@@ -7,5 +7,5 @@ export function WorkspaceModeIcon({ mode }: { mode: WorkspaceMode }) {
return <GitBranch className="size-3" strokeWidth={2} aria-hidden />;
}
- return <RepoForkedIcon width={12} height={12} color="white" aria-hidden />;
+ return <RepoForkedIcon width={12} height={12} aria-hidden />;
}