π OpenHands: AI-Driven Development
fix(mcp): use theme-aware secret selection (#18278)
Engel Nystfa1f724ab573
diff --git a/.agents/skills/frontend-development/references/guide.md b/.agents/skills/frontend-development/references/guide.mdindex 44e79a187d..4878de4000 100644--- a/.agents/skills/frontend-development/references/guide.md+++ b/.agents/skills/frontend-development/references/guide.md@@ -124,6 +124,7 @@ When adding code that needs a new string, decide up front which rule it falls un- 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.- Small form feedback uses the `feedback-error` / `feedback-success` text roles (`--oh-feedback-error` / `--oh-feedback-success`), separately from the general danger/success control palette. Their built-in values must meet 4.5:1 on modal surfaces; host overrides remain owned by the embedding root. See `src/themes/README.md` and the theme contrast tests when migrating raw feedback colors.- 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 CSS-isolation test in `tests/e2e/mock-llm/regressions/mock-llm-ui-regressions.spec.ts`.+- MCP credential selection: `SaveAsSecretToggle` keeps its native checkbox as the semantic control and uses `ToggleSwitchVisual` for the decorative track. Selection uses contrast/surface tokens. Keep both states' labels readable, allow long secret names to wrap with their help control, and preserve visible keyboard focus. See `specs/mcp-secret-selection.md` (MCP-005).- Conversation history is loaded lazily, REST-first then WebSocket:- `useConversationHistory` (in `src/hooks/query/use-conversation-history.ts`) fetches only the most recent `INITIAL_HISTORY_PAGE_SIZE` (default 50) events using `sort_order='TIMESTAMP_DESC'`, then reverses to chronological order. Older pages are paginated in via `useLoadOlderEvents` when the user scrolls near the top of the chat.diff --git a/__tests__/components/features/mcp-page/save-as-secret-toggle.test.tsx b/__tests__/components/features/mcp-page/save-as-secret-toggle.test.tsxindex 4ff4578c83..dc8132d351 100644--- a/__tests__/components/features/mcp-page/save-as-secret-toggle.test.tsx+++ b/__tests__/components/features/mcp-page/save-as-secret-toggle.test.tsx@@ -26,7 +26,11 @@ describe("SaveAsSecretToggle", () => {it("attaches data-testid to the label using fieldKey", () => {render(- <SaveAsSecretToggle fieldKey="MY_KEY" checked={false} onToggle={vi.fn()} />,+ <SaveAsSecretToggle+ fieldKey="MY_KEY"+ checked={false}+ onToggle={vi.fn()}+ />,);expect(screen.getByTestId("mcp-install-save-secret-MY_KEY"),@@ -35,7 +39,11 @@ describe("SaveAsSecretToggle", () => {it("renders the field key inside a <code> element", () => {render(- <SaveAsSecretToggle fieldKey="MY_KEY" checked={false} onToggle={vi.fn()} />,+ <SaveAsSecretToggle+ fieldKey="MY_KEY"+ checked={false}+ onToggle={vi.fn()}+ />,);const codeEl = screen.getByText("MY_KEY");expect(codeEl.tagName.toLowerCase()).toBe("code");@@ -57,16 +65,18 @@ describe("SaveAsSecretToggle", () => {// ββ accessibility ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ- it("the info button has an aria-label describing its purpose", () => {+ // @spec MCP-005 β Help stays independent of the native checkbox+ it("the labelled info button does not change the checkbox", () => {+ const onToggle = vi.fn();render(- <SaveAsSecretToggle fieldKey="KEY" checked={false} onToggle={vi.fn()} />,+ <SaveAsSecretToggle fieldKey="KEY" checked={false} onToggle={onToggle} />,);// t(key) => key in tests, so aria-label equals the raw i18n key.const infoBtn = screen.getByRole("button");- expect(infoBtn).toHaveAttribute(- "aria-label",- "MCP$SAVE_AS_SECRET_TOOLTIP",- );+ expect(infoBtn).toHaveAttribute("aria-label", "MCP$SAVE_AS_SECRET_TOOLTIP");+ fireEvent.click(infoBtn);+ expect(onToggle).not.toHaveBeenCalled();+ expect(screen.getByRole("checkbox")).not.toBeChecked();});it("the visual track is hidden from the accessibility tree (aria-hidden)", () => {diff --git a/specs/mcp-secret-selection.md b/specs/mcp-secret-selection.mdnew file mode 100644index 0000000000..c9b5e29b11--- /dev/null+++ b/specs/mcp-secret-selection.md@@ -0,0 +1,11 @@+# MCP credential selection++### MCP-005: Credential selection stays readable in every theme++- [x] The catalog's **Also save as secret** row follows the active palette,+ with readable labels and secret names in both checked and unchecked states.+- [x] The selected switch uses Canvas's shared toggle appearance; color alone+ does not communicate the checkbox state.+- [x] Long secret names and the help control remain inside the row on phones.+- [x] Label clicks and Space operate the native checkbox. Keyboard focus is+ visible, and opening help does not change the selection.diff --git a/src/components/features/mcp-page/save-as-secret-toggle.tsx b/src/components/features/mcp-page/save-as-secret-toggle.tsxindex fa591420e1..5a1eaf343d 100644--- a/src/components/features/mcp-page/save-as-secret-toggle.tsx+++ b/src/components/features/mcp-page/save-as-secret-toggle.tsx@@ -2,6 +2,7 @@ import { useTranslation } from "react-i18next";import { cn } from "#/utils/utils";import { StyledTooltip } from "#/components/shared/buttons/styled-tooltip";import { I18nKey } from "#/i18n/declaration";+import { ToggleSwitchVisual } from "#/ui/toggle-switch";interface SaveAsSecretToggleProps {fieldKey: string;@@ -16,13 +17,15 @@ export function SaveAsSecretToggle({}: SaveAsSecretToggleProps) {const { t } = useTranslation("openhands");+ // @spec MCP-005 β Credential selection stays readable in every themereturn (<labeldata-testid={`mcp-install-save-secret-${fieldKey}`}className={cn(- "flex items-center gap-2 px-3 py-2 mt-0.5 rounded-lg border cursor-pointer transition-colors",+ "flex flex-wrap items-center gap-2 px-3 py-2 mt-0.5 rounded-lg border cursor-pointer transition-colors",+ "has-focus-visible:outline-2 has-focus-visible:outline-offset-2 has-focus-visible:outline-focus",checked- ? "border-green-500/35 bg-green-500/10"+ ? "border-contrast/25 bg-contrast/5": "border-border bg-transparent hover:bg-contrast/[0.03]",)}>@@ -35,49 +38,34 @@ export function SaveAsSecretToggle({checked={checked}onChange={(e) => onToggle(e.target.checked)}/>- {/* aria-hidden: purely decorative β the checkbox above is the semantic control. */}- <span- aria-hidden="true"- className={cn(- "relative inline-flex h-5.5 w-10 shrink-0 items-center rounded-full border transition-colors duration-200",- checked- ? "border-green-500 bg-green-500"- : "border-border bg-surface-raised",- )}- >- <span+ <ToggleSwitchVisual enabled={checked} />+ <span className="text-sm text-contrast">+ {t(I18nKey.MCP$ALSO_SAVE_AS_SECRET)}+ </span>+ <span className="ml-auto flex min-w-0 max-w-full items-center gap-2">+ <codeclassName={cn(- "inline-block size-4 rounded-full transition-transform duration-200",- checked ? "translate-x-5.25 bg-white" : "translate-x-0.5 bg-muted",+ "min-w-0 break-all text-[11px] text-contrast font-mono tracking-tight border rounded px-1.5 py-0.5",+ checked ? "border-contrast/25 bg-contrast/4" : "border-border",)}- />- </span>- <span className="text-sm">{t(I18nKey.MCP$ALSO_SAVE_AS_SECRET)}</span>- <code- className={cn(- "ml-auto text-[11px] font-mono tracking-tight border rounded px-1.5 py-0.5",- checked- ? "text-green-500 border-green-500/35 bg-contrast/[0.04]"- : "text-tertiary-alt border-border",- )}- >- {fieldKey}- </code>- <StyledTooltip- content={t(I18nKey.MCP$SAVE_AS_SECRET_TOOLTIP)}- placement="top"- >- {/* button so the tooltip is keyboard-reachable; type=button prevents- accidental form submission when the user presses Enter. */}- <button- type="button"- aria-label={t(I18nKey.MCP$SAVE_AS_SECRET_TOOLTIP)}- className="flex items-center justify-center size-3.75 shrink-0 rounded-full border border-muted text-tertiary-alt text-[9px] font-bold cursor-help"- onClick={(e) => e.preventDefault()}>- ?- </button>- </StyledTooltip>+ {fieldKey}+ </code>+ <StyledTooltip+ content={t(I18nKey.MCP$SAVE_AS_SECRET_TOOLTIP)}+ placement="top"+ >+ {/* The help button must stay keyboard-reachable without toggling. */}+ <button+ type="button"+ aria-label={t(I18nKey.MCP$SAVE_AS_SECRET_TOOLTIP)}+ className="flex items-center justify-center size-3.75 shrink-0 rounded-full border border-muted text-contrast text-[9px] font-bold cursor-help"+ onClick={(e) => e.preventDefault()}+ >+ ?+ </button>+ </StyledTooltip>+ </span></label>);}