Skip to content

πŸ™Œ OpenHands: AI-Driven Development

chore(lint): protect caret appearance and state rotation (#18274)

Engel Nyst2d174175cede
diff --git a/.agents/skills/frontend-development/references/guide.md b/.agents/skills/frontend-development/references/guide.md
index 8307431432..44e79a187d 100644
--- a/.agents/skills/frontend-development/references/guide.md
+++ b/.agents/skills/frontend-development/references/guide.md
@@ -22,6 +22,16 @@ Bundled catalog skills use the persisted `enabled_skills` allow-list defaulted f
Local Files discovery preferences belong to `misc_settings.app_preferences.workspace_file_discovery`, keyed by working directory on the active backend. `useWorkspaceFileDiscovery` reads the settings cache and saves sparse workspace patches. Preserve default exclusions and the 2,000-file cap when no configuration exists. Fetch one extra result to distinguish truncation from an exact-size list. Cloud keeps its server-side listing contract without these controls. See `specs/workspace-file-discovery.md`.
+## Caret appearance contracts
+
+`shadcn/no-restyle` recognizes direct, aliased, and namespaced imports from
+`#/ui/combobox-caret`. Caret callers retain layout, icon sizing, and text-color
+utilities; padding, background, shape, and effects belong to the primitive.
+Use `isOpen` for rotation on `ComboboxCaretButton` and `ComboboxCaretInline`.
+`ComboboxCaretIcon` is the generic SVG and still permits caller orientation.
+Primitive implementations remain exempt from no-restyle. The existing narrow
+static-class exceptions do not imply that opaque values are checked by no-restyle.
+
## No Magic Strings
Avoid inline string literals when they represent reusable user-facing copy or shared program identifiers. The `i18next/no-literal-string` rule is set to `"error"` for configured JSX text and attributes, and targeted `no-restricted-syntax` rules enforce shared translation and query-key patterns. Do not claim broader lint enforcement than `eslint.config.js` provides.
diff --git a/__tests__/scripts/restyle-lint.test.ts b/__tests__/scripts/restyle-lint.test.ts
index c4721a104b..328d371f28 100644
--- a/__tests__/scripts/restyle-lint.test.ts
+++ b/__tests__/scripts/restyle-lint.test.ts
@@ -31,7 +31,55 @@ export function Probe() {
}
`;
-describe("Canvas divider and toggle appearance contracts", () => {
+const caretCases = [
+ { component: "Arrow", classes: "ml-2 size-4 text-muted", allowed: true },
+ { component: "Arrow", classes: "rotate-90", allowed: true },
+ { component: "StateArrow", classes: "mr-1 text-danger", allowed: true },
+ {
+ component: "Carets.ComboboxCaretButton",
+ classes: "self-center",
+ allowed: true,
+ },
+ { component: "Arrow", classes: "p-2", allowed: false },
+ { component: "StateArrow", classes: "bg-danger", allowed: false },
+ {
+ component: "Carets.ComboboxCaretButton",
+ classes: "rounded-md",
+ allowed: false,
+ },
+ { component: "StateArrow", classes: "rotate-90", allowed: false },
+ {
+ component: "Carets.ComboboxCaretButton",
+ classes: "hover:-rotate-90",
+ allowed: false,
+ },
+];
+const caretRows = caretCases.map(
+ ({ component, classes }) =>
+ `<${component} className=${JSON.stringify(classes)} />`,
+);
+const caretProbe = `import { ComboboxCaretIcon as Arrow, ComboboxCaretInline as StateArrow } from "#/ui/combobox-caret";
+import * as Carets from "#/ui/combobox-caret";
+export function CaretProbe() { return <>\n${caretRows.join("\n")}\n</>; }`;
+
+describe("Canvas UI appearance contracts", () => {
+ it("keeps caret layout and text color public while protecting appearance and state rotation", async () => {
+ const [result] = await eslint.lintText(caretProbe, {
+ filePath: "src/routes/caret-restyle-probe.tsx",
+ });
+ expect(result.fatalErrorCount).toBe(0);
+ const findings = result.messages.filter(
+ (message) => message.ruleId === "shadcn/no-restyle",
+ );
+ // Cases start on line 4. Compare behavior by row, without mirroring
+ // fixture class strings or relying on diagnostic order/per-class counts.
+ expect(new Set(findings.map(({ line }) => line - 4))).toEqual(
+ new Set(
+ caretCases.flatMap(({ allowed }, index) => (allowed ? [] : [index])),
+ ),
+ );
+ expect(findings.every(({ severity }) => severity === 2)).toBe(true);
+ });
it("rejects restyling through aliases and re-exports while keeping allowed usage", async () => {
// Layout and caller-owned wrapper opacity remain supported. Other Canvas
// primitives and HTML are deliberately outside this first rollout.
@@ -58,7 +106,7 @@ describe("Canvas divider and toggle appearance contracts", () => {
});
it("allows primitive implementations to own their appearance", async () => {
- const [result] = await eslint.lintText(probe, {
+ const [result] = await eslint.lintText(`${probe}\n${caretProbe}`, {
filePath: "src/ui/restyle-probe.tsx",
});
diff --git a/eslint.config.js b/eslint.config.js
index a8909b30de..517c22ea83 100644
--- a/eslint.config.js
+++ b/eslint.config.js
@@ -404,6 +404,8 @@ export default [
// and checked across themes (#18004). Keep verified plugin/config tokens exempt below.
// no-restyle first protects divider/toggle appearances; layout remains public,
// and ToggleSwitch callers can dim the control for disabled/pending states.
+ // Carets expose layout and text color; their padding/shape stay internal.
+ // Stateful carets own rotation through isOpen; generic icons retain orientation.
// Next: finish the color migration before promoting to error; define contracts
// for the remaining UI primitives and audit dynamic styles for no-inline-styles.
// 0.2.0 also improves render-prop, destructuring, barrel-export, and custom
@@ -418,9 +420,9 @@ export default [
"error",
{
// Adopt only primitives whose appearance contract is already settled.
- // Typography, menus, Pre, and caret slots need a separate design audit.
+ // Typography, menus, and Pre need a separate design audit.
componentImports: [
- "^#/ui/(divider|toggle-switch)$",
+ "^#/ui/(divider|toggle-switch|combobox-caret)$",
// 0.2.0 needs the existing re-export path matched explicitly too.
"^#/components/features/automations/toggle-switch$",
],
@@ -429,6 +431,19 @@ export default [
// The button wrapper can express caller-owned disabled/pending state.
// ToggleSwitchVisual still owns the track/thumb color, shape, and effects.
{ pattern: "^ToggleSwitch$", allow: ["layout", "opacity"] },
+ {
+ pattern: "^ComboboxCaretIcon$",
+ allow: ["layout", "text-color"],
+ message:
+ "Keep caret classes to layout and text color; the SVG owns its appearance.",
+ },
+ {
+ pattern: "^ComboboxCaret(Button|Inline)$",
+ allow: ["layout", "text-color"],
+ deny: ["rotate-*"],
+ message:
+ "Use isOpen for caret rotation; keep caller classes to layout and text color.",
+ },
],
},
],