Skip to content

πŸ™Œ OpenHands: AI-Driven Development

Fix scoped UI root foreground inheritance (#66)

Graham Neubig25510608a155
diff --git a/.pr/issue-65/01-current-broken.png b/.pr/issue-65/01-current-broken.png
new file mode 100644
index 0000000000..474c3b4cb5
Binary files /dev/null and b/.pr/issue-65/01-current-broken.png differ
diff --git a/.pr/issue-65/02-old-correct.png b/.pr/issue-65/02-old-correct.png
new file mode 100644
index 0000000000..84313daf0d
Binary files /dev/null and b/.pr/issue-65/02-old-correct.png differ
diff --git a/.pr/issue-65/03-current-fixed.png b/.pr/issue-65/03-current-fixed.png
new file mode 100644
index 0000000000..27c0082656
Binary files /dev/null and b/.pr/issue-65/03-current-fixed.png differ
diff --git a/AGENTS.md b/AGENTS.md
index dbba176cd5..4e6a223d0b 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -96,6 +96,7 @@
- Test helper note: `test-utils.tsx` now wraps renders with a default `NavigationProvider` (`currentPath: "/"`, `conversationId: "test-conversation-id"`). Navigation-sensitive tests can override that via `renderWithProviders(..., { navigation: { ... } })`.
- CSS isolation for embeddable/hosted use now relies on a scoped wrapper attribute: all bundled CSS is prefixed under `[data-agent-server-ui]` via `postcss-prefix-selector` in `vite.config.ts`, with selector exceptions handled by `transformAgentServerUISelector()` in `src/styles/agent-server-ui-style-scope.ts`. That transform must remap global selectors like `:root`, `html`, and `body` directly onto the scoped shell instead of emitting impossible descendants such as `[data-agent-server-ui] :root`.
- Public embedding entry points should use `AgentServerUIProviders` (scoped root on by default) or `AgentServerUIRoot` for manual control. The standalone app already renders its own scoped root in `src/root.tsx`, so `src/entry.client.tsx` must pass `withStyleRoot={false}` to avoid nesting duplicate shells. Keep `AgentServerUIRoot` and the scoping constants re-exported from `src/lib/index.ts` so library consumers can customize the host wrapper without reaching into private paths.
+- `AgentServerUIRoot`'s themed inner wrapper must set a default `color: var(--foreground)` in addition to the `dark` / `data-theme` markers; otherwise inherited text and `currentColor` SVG icons fall back to dark browser defaults after CSS scoping, causing dark-on-dark regressions on pages like the home screen.
- Theme/customization tokens for the embedded shell are exposed as `--oh-*` CSS variables. Override them through `styleOverrides`, `style`, or host CSS targeting `[data-agent-server-ui]`; Tailwind theme tokens in `src/tailwind.css` should continue to reference those variables with `@theme inline` so host apps can restyle the UI without reworking component class names.
- Regression coverage for the CSS isolation work lives in `__tests__/agent-server-ui-providers.test.tsx`, `__tests__/agent-server-ui-style-scope.test.ts`, and the browser-level `tests/css-isolation.spec.ts` Playwright test.
diff --git a/__tests__/agent-server-ui-providers.test.tsx b/__tests__/agent-server-ui-providers.test.tsx
index 8ee2adb9d8..640a122ad4 100644
--- a/__tests__/agent-server-ui-providers.test.tsx
+++ b/__tests__/agent-server-ui-providers.test.tsx
@@ -215,6 +215,7 @@ describe("AgentServerUIProviders", () => {
scopeRoot?.firstElementChild as HTMLDivElement | null;
expect(themedContainer).toHaveAttribute("data-theme", "dark");
expect(themedContainer).toHaveClass("dark", "min-h-screen");
+ expect(themedContainer).toHaveStyle({ color: "var(--foreground)" });
expect(themedContainer).toContainElement(
screen.getByTestId("styled-child"),
);
diff --git a/src/components/providers/agent-server-ui-root.tsx b/src/components/providers/agent-server-ui-root.tsx
index 4707035da7..cb9d302a36 100644
--- a/src/components/providers/agent-server-ui-root.tsx
+++ b/src/components/providers/agent-server-ui-root.tsx
@@ -45,7 +45,11 @@ export function AgentServerUIRoot({
className={className}
style={scopedStyle}
>
- <div className={cn(theme, contentClassName)} data-theme={theme}>
+ <div
+ className={cn(theme, contentClassName)}
+ data-theme={theme}
+ style={{ color: "var(--foreground)" }}
+ >
{children}
</div>
</div>