🙌 OpenHands: AI-Driven Development
feat(skills): filter the skills page with a faceted rail (#16124)
Sleeyaxb09a3c1c598d
diff --git a/__tests__/components/automations/recommended-automations.test.tsx b/__tests__/components/automations/recommended-automations.test.tsxindex 10ca335ffc..31d3334661 100644--- a/__tests__/components/automations/recommended-automations.test.tsx+++ b/__tests__/components/automations/recommended-automations.test.tsx@@ -171,6 +171,7 @@ describe("recommended automations", () => {"linear-triage-assistant","jira-issue-to-pr","research-brief-writer",+ "upstream-fork-sync","incident-retrospective-drafter",]);});@@ -195,7 +196,7 @@ describe("recommended automations", () => {expect(betaHeading).toHaveTextContent(I18nKey.RECOMMENDED_AUTOMATIONS$BETA_LABEL,);- expect(within(betaHeading).getByText("5")).toBeInTheDocument();+ expect(within(betaHeading).getByText("6")).toBeInTheDocument();const betaSection = screen.getByTestId("recommended-automations-beta-section",diff --git a/__tests__/components/features/skills/build-skill-pills.test.tsx b/__tests__/components/features/skills/build-skill-pills.test.tsxnew file mode 100644index 0000000000..434a240e3a--- /dev/null+++ b/__tests__/components/features/skills/build-skill-pills.test.tsx@@ -0,0 +1,57 @@+import { render, screen } from "@testing-library/react";+import { describe, expect, it } from "vitest";+import type { TFunction } from "i18next";+import { buildSkillPills } from "#/components/features/skills/build-skill-pills";+import type { SkillCardPill } from "#/components/features/skills/skill-card-pill-row";+import type { SkillInfo } from "#/types/settings";++/** Returns its key unchanged, for assertions that do not care about copy. */+const translate = ((key: string) => key) as TFunction;++function buildSkill(overrides: Partial<SkillInfo> = {}): SkillInfo {+ return {+ name: "deno",+ type: "knowledge",+ source: "public",+ category: "environment",+ triggers: [],+ ...overrides,+ };+}++/** Mounts the built pills so their rendered output can be asserted. */+function renderPills(pills: SkillCardPill[]) {+ render(+ <div>+ {pills.map((pill) => (+ <span key={pill.id}>{pill.node}</span>+ ))}+ </div>,+ );+}++describe("buildSkillPills category pill", () => {+ it("renders the catalog category", () => {+ renderPills(+ buildSkillPills(buildSkill({ category: "environment" }), translate),+ );++ expect(screen.getByTestId("skill-category-deno")).toHaveTextContent(+ "SETTINGS$SKILLS_CATEGORY_ENVIRONMENT",+ );+ });++ it("omits the pill when the skill is uncategorized", () => {+ renderPills(buildSkillPills(buildSkill({ category: null }), translate));++ expect(screen.queryByTestId("skill-category-deno")).not.toBeInTheDocument();+ });++ it("places the category pill directly after the type badge", () => {+ // Order is asserted on pill ids, so no rendering is needed here.+ const pills = buildSkillPills(buildSkill(), translate);++ expect(pills[0]!.id).toBe("type-knowledge");+ expect(pills[1]!.id).toBe("category-environment");+ });+});diff --git a/__tests__/components/features/skills/skill-facet-rail.test.tsx b/__tests__/components/features/skills/skill-facet-rail.test.tsxnew file mode 100644index 0000000000..0514f669ab--- /dev/null+++ b/__tests__/components/features/skills/skill-facet-rail.test.tsx@@ -0,0 +1,69 @@+import { render, screen } from "@testing-library/react";+import userEvent from "@testing-library/user-event";+import { describe, expect, it, vi } from "vitest";+import { I18nKey } from "#/i18n/declaration";+import { SkillFacetRail } from "#/components/features/skills/skill-facet-rail";+import type { SkillFacetGroup } from "#/components/features/skills/skill-filter";++function buildGroups(): SkillFacetGroup[] {+ return [+ {+ id: "category",+ labelKey: I18nKey.SETTINGS$SKILLS_FACET_CATEGORY,+ rows: [+ {+ value: "environment",+ labelKey: I18nKey.SETTINGS$SKILLS_CATEGORY_ENVIRONMENT,+ count: 10,+ checked: false,+ disabled: false,+ },+ {+ value: "writing",+ labelKey: I18nKey.SETTINGS$SKILLS_CATEGORY_WRITING,+ count: 0,+ checked: false,+ disabled: true,+ },+ ],+ },+ ];+}++describe("SkillFacetRail", () => {+ it("renders nothing when no group is visible", () => {+ render(<SkillFacetRail groups={[]} onToggle={vi.fn()} />);+ expect(screen.queryByTestId("skill-facet-rail")).not.toBeInTheDocument();+ });++ it("renders each row with its count and checked state", () => {+ render(<SkillFacetRail groups={buildGroups()} onToggle={vi.fn()} />);++ const row = screen.getByTestId("skill-facet-category-environment");+ expect(row).toHaveAttribute("aria-checked", "false");+ expect(row).toHaveTextContent("10");+ expect(+ screen.getByTestId("skill-facet-group-category"),+ ).toBeInTheDocument();+ });++ it("reports the group and value when a row is clicked", async () => {+ const user = userEvent.setup();+ const onToggle = vi.fn();+ render(<SkillFacetRail groups={buildGroups()} onToggle={onToggle} />);++ await user.click(screen.getByTestId("skill-facet-category-environment"));++ expect(onToggle).toHaveBeenCalledWith("category", "environment");+ });++ it("does not report clicks on a disabled zero-count row", async () => {+ const user = userEvent.setup();+ const onToggle = vi.fn();+ render(<SkillFacetRail groups={buildGroups()} onToggle={onToggle} />);++ await user.click(screen.getByTestId("skill-facet-category-writing"));++ expect(onToggle).not.toHaveBeenCalled();+ });+});diff --git a/__tests__/components/features/skills/skill-filter.test.ts b/__tests__/components/features/skills/skill-filter.test.tsnew file mode 100644index 0000000000..00e7f8b9fd--- /dev/null+++ b/__tests__/components/features/skills/skill-filter.test.ts@@ -0,0 +1,362 @@+import { describe, expect, it } from "vitest";+import { I18nKey } from "#/i18n/declaration";+import type { SkillInfo } from "#/types/settings";+import {+ applySkillFilters,+ buildSkillFacetGroups,+ clearSkillFilterFacets,+ countActiveFilters,+ EMPTY_SKILL_FILTER_STATE,+ parseSkillFilterState,+ toggleSkillFilterValue,+ toSkillFilterSearchParams,+ type SkillFilterState,+} from "#/components/features/skills/skill-filter";++function buildSkill(overrides: Partial<SkillInfo> = {}): SkillInfo {+ return {+ name: "deno",+ type: "knowledge",+ source: "public",+ category: "environment",+ description: "Initialize and work with Deno projects.",+ triggers: ["deno"],+ ...overrides,+ };+}++/** Public env skill, public writing skill, personal repo skill. */+function buildMixedSkills(): SkillInfo[] {+ return [+ buildSkill({ name: "deno", category: "environment", type: "knowledge" }),+ buildSkill({+ name: "prd",+ category: "writing",+ type: "knowledge",+ description: "Generate a Product Requirements Document.",+ triggers: [],+ }),+ buildSkill({+ name: "house-rules",+ category: null,+ type: "repo",+ source: "/home/dev/.agents/skills/house-rules/SKILL.md",+ description: "Local conventions.",+ triggers: [],+ }),+ ];+}++function stateWith(+ overrides: Partial<SkillFilterState> = {},+): SkillFilterState {+ return { ...EMPTY_SKILL_FILTER_STATE, ...overrides };+}++describe("parseSkillFilterState", () => {+ it("reads every facet plus the query", () => {+ const state = parseSkillFilterState(+ new URLSearchParams(+ "q=deno&source=personal&source=public&category=environment&type=repo&state=disabled",+ ),+ );++ expect(state.query).toBe("deno");+ expect([...state.sources]).toEqual(["personal", "public"]);+ expect([...state.categories]).toEqual(["environment"]);+ expect([...state.types]).toEqual(["repo"]);+ expect([...state.states]).toEqual(["disabled"]);+ });++ it.each([+ ["source", "source=nonsense"],+ ["category", "category=code-hostig"],+ ["type", "type=bogus"],+ ["state", "state=maybe"],+ ])("drops unknown %s values instead of erroring", (_label, search) => {+ const state = parseSkillFilterState(new URLSearchParams(search));+ expect(countActiveFilters(state)).toBe(0);+ });++ it("round-trips through toSkillFilterSearchParams in canonical order", () => {+ const search =+ "q=deno&source=project&source=public&category=environment&category=writing";+ const state = parseSkillFilterState(new URLSearchParams(search));++ expect(toSkillFilterSearchParams(state).toString()).toBe(+ new URLSearchParams(search).toString(),+ );+ });++ it("omits empty facets so an unfiltered page has a bare URL", () => {+ expect(toSkillFilterSearchParams(EMPTY_SKILL_FILTER_STATE).toString()).toBe(+ "",+ );+ });+});++describe("applySkillFilters", () => {+ const skills = buildMixedSkills();+ const disabled = new Set(["prd"]);++ it("ORs values within a group", () => {+ const result = applySkillFilters(+ skills,+ disabled,+ stateWith({ categories: new Set(["environment", "writing"]) }),+ );+ expect(result.map((s) => s.name)).toEqual(["deno", "prd"]);+ });++ it("ANDs across groups", () => {+ const result = applySkillFilters(+ skills,+ disabled,+ stateWith({+ categories: new Set(["environment", "writing"]),+ states: new Set(["disabled"]),+ }),+ );+ expect(result.map((s) => s.name)).toEqual(["prd"]);+ });++ it("treats a category-less skill as other", () => {+ const result = applySkillFilters(+ skills,+ disabled,+ stateWith({ categories: new Set(["other"]) }),+ );+ expect(result.map((s) => s.name)).toEqual(["house-rules"]);+ });++ it("matches the query against name, description, and triggers", () => {+ expect(+ applySkillFilters(+ skills,+ disabled,+ stateWith({ query: "Requirements" }),+ ).map((s) => s.name),+ ).toEqual(["prd"]);+ expect(+ applySkillFilters(skills, disabled, stateWith({ query: "deno" })).map(+ (s) => s.name,+ ),+ ).toEqual(["deno"]);+ });++ it("returns everything when no facet is selected", () => {+ expect(+ applySkillFilters(skills, disabled, EMPTY_SKILL_FILTER_STATE),+ ).toHaveLength(3);+ });+});++describe("buildSkillFacetGroups", () => {+ it("hides a group whose values cannot discriminate", () => {+ const publicOnly = [+ buildSkill({ name: "deno", category: "environment" }),+ buildSkill({ name: "uv", category: "environment" }),+ ];++ const groups = buildSkillFacetGroups(+ publicOnly,+ new Set(),+ EMPTY_SKILL_FILTER_STATE,+ );++ // Every skill is public, knowledge-typed, environment-categorised and+ // enabled, so no group has two non-empty values.+ expect(groups).toEqual([]);+ });++ it("keeps a group visible when its only selected value has no matches for this user", () => {+ // Reproduces sharing a `?source=project` URL with someone who has no project skills: hiding the group would enforce the filter with no row left to undo it.+ const publicOnly = [+ buildSkill({ name: "deno", source: "public" }),+ buildSkill({ name: "uv", source: "public" }),+ ];++ const groups = buildSkillFacetGroups(+ publicOnly,+ new Set(),+ stateWith({ sources: new Set(["project"]) }),+ );++ const source = groups.find((g) => g.id === "source");+ expect(source).toBeDefined();+ expect(source!.rows.find((r) => r.value === "project")).toMatchObject({+ checked: true,+ count: 0,+ });+ });++ it("shows groups once a second value exists", () => {+ const groups = buildSkillFacetGroups(+ buildMixedSkills(),+ new Set(["prd"]),+ EMPTY_SKILL_FILTER_STATE,+ );++ expect(groups.map((g) => g.id)).toEqual([+ "state",+ "source",+ "category",+ "type",+ ]);+ });++ it("labels rows with i18n keys rather than translated text", () => {+ const groups = buildSkillFacetGroups(+ buildMixedSkills(),+ new Set(["prd"]),+ EMPTY_SKILL_FILTER_STATE,+ );+ const category = groups.find((g) => g.id === "category")!;++ expect(category.labelKey).toBe(I18nKey.SETTINGS$SKILLS_FACET_CATEGORY);+ expect(category.rows.map((r) => r.value)).toEqual([+ "environment",+ "writing",+ "other",+ ]);+ expect(category.rows[0]!.labelKey).toBe(+ I18nKey.SETTINGS$SKILLS_CATEGORY_ENVIRONMENT,+ );+ });++ it("counts rows against other groups but not the group's own selection", () => {+ const groups = buildSkillFacetGroups(+ buildMixedSkills(),+ new Set(["prd"]),+ stateWith({ states: new Set(["enabled"]) }),+ );++ const category = groups.find((g) => g.id === "category")!;+ const byValue = Object.fromEntries(+ category.rows.map((r) => [r.value, r.count]),+ );++ // The `state` selection narrows Category, dropping the disabled `prd`.+ expect(byValue).toEqual({ environment: 1, writing: 0, other: 1 });++ // The `state` group ignores its own selection, so both rows keep counts.+ const state = groups.find((g) => g.id === "state")!;+ expect(state.rows.map((r) => r.count)).toEqual([2, 1]);+ });++ it("keeps a different group's visibility stable while one facet narrows", () => {+ const skills = buildMixedSkills();+ const disabled = new Set(["prd"]);++ const narrowed = buildSkillFacetGroups(+ skills,+ disabled,+ stateWith({ categories: new Set(["environment"]) }),+ );++ // Only `deno` survives, leaving Source and Type one value each among the matches; visibility comes from the raw list, so both groups still render.+ expect(narrowed.map((g) => g.id)).toEqual(+ expect.arrayContaining(["source", "type"]),+ );+ });++ it("keeps group visibility stable while a search query narrows results", () => {+ const skills = buildMixedSkills();+ const disabled = new Set(["prd"]);+ const unfiltered = buildSkillFacetGroups(+ skills,+ disabled,+ EMPTY_SKILL_FILTER_STATE,+ );++ // "Requirements" matches only `prd`, so a query-filtered denominator would collapse every group to one value.+ const narrowed = buildSkillFacetGroups(+ skills,+ disabled,+ stateWith({ query: "Requirements" }),+ );++ expect(narrowed.map((g) => g.id)).toEqual(unfiltered.map((g) => g.id));+ });++ it("disables a zero-count row unless it is checked", () => {+ const groups = buildSkillFacetGroups(+ buildMixedSkills(),+ new Set(["prd"]),+ stateWith({ states: new Set(["enabled"]) }),+ );+ const rows = groups.find((g) => g.id === "category")!.rows;++ expect(rows.find((r) => r.value === "writing")).toMatchObject({+ count: 0,+ checked: false,+ disabled: true,+ });+ });+});++describe("toggleSkillFilterValue", () => {+ it("adds then removes a value without mutating the input", () => {+ const initial = EMPTY_SKILL_FILTER_STATE;+ const added = toggleSkillFilterValue(initial, "category", "writing");+ const removed = toggleSkillFilterValue(added, "category", "writing");++ expect([...added.categories]).toEqual(["writing"]);+ expect([...removed.categories]).toEqual([]);+ expect([...initial.categories]).toEqual([]);+ });++ it("ignores a value that is not legal for the group", () => {+ const next = toggleSkillFilterValue(+ EMPTY_SKILL_FILTER_STATE,+ "type",+ "nonsense",+ );+ expect(countActiveFilters(next)).toBe(0);+ });++ it.each([+ ["source", "sources", "project"],+ ["state", "states", "disabled"],+ ] as const)(+ "toggles a %s value into its own set, leaving the rest empty",+ (groupId, key, value) => {+ const next = toggleSkillFilterValue(+ EMPTY_SKILL_FILTER_STATE,+ groupId,+ value,+ );++ // Catches a branch writing to the wrong field: either the intended set stays empty, or an unintended one gains the value.+ const collections = ["sources", "categories", "types", "states"] as const;+ for (const collection of collections) {+ const expected = collection === key ? [value] : [];+ expect([...next[collection]]).toEqual(expected);+ }+ },+ );+});++describe("clearSkillFilterFacets and countActiveFilters", () => {+ it("clears facets but keeps the query", () => {+ const state = stateWith({+ query: "deno",+ categories: new Set(["writing"]),+ types: new Set(["repo"]),+ });++ const cleared = clearSkillFilterFacets(state);++ expect(cleared.query).toBe("deno");+ expect(countActiveFilters(cleared)).toBe(0);+ });++ it("does not count the query as a filter", () => {+ expect(countActiveFilters(stateWith({ query: "deno" }))).toBe(0);+ expect(+ countActiveFilters(+ stateWith({ query: "deno", categories: new Set(["writing"]) }),+ ),+ ).toBe(1);+ });+});diff --git a/__tests__/components/features/skills/skill-filters-modal.test.tsx b/__tests__/components/features/skills/skill-filters-modal.test.tsxnew file mode 100644index 0000000000..87f44412f5--- /dev/null+++ b/__tests__/components/features/skills/skill-filters-modal.test.tsx@@ -0,0 +1,90 @@+import { render, screen } from "@testing-library/react";+import userEvent from "@testing-library/user-event";+import { describe, expect, it, vi } from "vitest";+import { I18nKey } from "#/i18n/declaration";+import { SkillFiltersModal } from "#/components/features/skills/skill-filters-modal";+import type { SkillFacetGroup } from "#/components/features/skills/skill-filter";++function buildGroups(): SkillFacetGroup[] {+ return [+ {+ id: "type",+ labelKey: I18nKey.SETTINGS$SKILLS_FACET_TYPE,+ rows: [+ {+ value: "repo",+ labelKey: I18nKey.SETTINGS$SKILLS_TYPE_REPO,+ count: 1,+ checked: false,+ disabled: false,+ },+ {+ value: "knowledge",+ labelKey: I18nKey.SETTINGS$SKILLS_TYPE_KNOWLEDGE,+ count: 2,+ checked: false,+ disabled: false,+ },+ ],+ },+ ];+}++describe("SkillFiltersModal", () => {+ it("toggles a facet through the same rail the desktop uses", async () => {+ const user = userEvent.setup();+ const onToggle = vi.fn();++ render(+ <SkillFiltersModal+ groups={buildGroups()}+ activeCount={0}+ onToggle={onToggle}+ onClearAll={vi.fn()}+ onClose={vi.fn()}+ />,+ );++ await user.click(screen.getByTestId("skill-facet-type-repo"));++ expect(onToggle).toHaveBeenCalledWith("type", "repo");+ });++ it("hides the clear action when nothing is filtered", () => {+ render(+ <SkillFiltersModal+ groups={buildGroups()}+ activeCount={0}+ onToggle={vi.fn()}+ onClearAll={vi.fn()}+ onClose={vi.fn()}+ />,+ );++ expect(+ screen.queryByTestId("skill-filters-modal-clear"),+ ).not.toBeInTheDocument();+ });++ it("clears filters and closes on demand", async () => {+ const user = userEvent.setup();+ const onClearAll = vi.fn();+ const onClose = vi.fn();++ render(+ <SkillFiltersModal+ groups={buildGroups()}+ activeCount={2}+ onToggle={vi.fn()}+ onClearAll={onClearAll}+ onClose={onClose}+ />,+ );++ await user.click(screen.getByTestId("skill-filters-modal-clear"));+ expect(onClearAll).toHaveBeenCalled();++ await user.click(screen.getByTestId("skill-filters-modal-done"));+ expect(onClose).toHaveBeenCalled();+ });+});diff --git a/__tests__/routes/skills-settings.test.tsx b/__tests__/routes/skills-settings.test.tsxindex 224e9beb12..70dc7cd5e8 100644--- a/__tests__/routes/skills-settings.test.tsx+++ b/__tests__/routes/skills-settings.test.tsx@@ -1,6 +1,14 @@import { QueryClient, QueryClientProvider } from "@tanstack/react-query";-import { render, screen, within, fireEvent, waitFor } from "@testing-library/react";+import {+ act,+ render,+ screen,+ within,+ fireEvent,+ waitFor,+} from "@testing-library/react";import userEvent from "@testing-library/user-event";+import { RouterProvider, createMemoryRouter } from "react-router";import { beforeEach, describe, expect, it, vi } from "vitest";import SkillsSettingsScreen from "#/routes/skills-settings";import SettingsService from "#/api/settings-service/settings-service.api";@@ -40,7 +48,8 @@ function buildSkill(overrides: Partial<SkillInfo> = {}): SkillInfo {return {name: "deno",type: "knowledge",- source: "/Users/test/.openhands/cache/skills/public-skills/skills/deno/SKILL.md",+ source:+ "/Users/test/.openhands/cache/skills/public-skills/skills/deno/SKILL.md",description:"If the project uses deno, use this skill to initialize Deno projects.",triggers: ["deno", "deno.json", "deno.lock"],@@ -55,8 +64,22 @@ function buildSkill(overrides: Partial<SkillInfo> = {}): SkillInfo {};}-function renderSkillsSettingsScreen() {- return render(<SkillsSettingsScreen />, {+function renderSkillsSettingsScreen(initialEntry = "/skills") {+ const router = createMemoryRouter(+ [+ {+ path: "/skills",+ Component: () => (+ <ActiveBackendProvider>+ <SkillsSettingsScreen />+ </ActiveBackendProvider>+ ),+ },+ ],+ { initialEntries: [initialEntry] },+ );++ render(<RouterProvider router={router} />, {wrapper: ({ children }) => (<QueryClientProviderclient={@@ -65,10 +88,12 @@ function renderSkillsSettingsScreen() {})}>- <ActiveBackendProvider>{children}</ActiveBackendProvider>+ {children}</QueryClientProvider>),});++ return router;}describe("SkillsSettingsScreen", () => {@@ -118,7 +143,9 @@ Full skill body.`,expect(within(card).getByTestId(`skill-description-${skill.name}`),- ).toHaveTextContent("Connect and run commands on remote machines over SSH.");+ ).toHaveTextContent(+ "Connect and run commands on remote machines over SSH.",+ );});it("surfaces the YAML description under the card title with the source path beneath it", async () => {@@ -196,7 +223,71 @@ Full skill body.`,expect(screen.getByTestId("skill-card-vercel")).toBeInTheDocument();});- it("narrows the visible skills when a type filter chip is selected", async () => {+ it("narrows the visible skills when a facet row is selected", async () => {+ const user = userEvent.setup();+ vi.spyOn(SkillsService, "getSkills").mockResolvedValue([+ buildSkill({ name: "deno", type: "knowledge" }),+ buildSkill({+ name: "global-rules",+ type: "repo",+ triggers: [],+ source: "/skills/global-rules.md",+ }),+ ]);++ const router = renderSkillsSettingsScreen();+ await screen.findByTestId("skill-card-deno");++ await user.click(screen.getByTestId("skill-facet-type-repo"));++ expect(screen.queryByTestId("skill-card-deno")).not.toBeInTheDocument();+ expect(screen.getByTestId("skill-card-global-rules")).toBeInTheDocument();+ expect(router.state.location.search).toBe("?type=repo");+ });++ it("seeds the filter state from the URL on load", async () => {+ vi.spyOn(SkillsService, "getSkills").mockResolvedValue([+ buildSkill({ name: "deno", category: "environment" }),+ buildSkill({ name: "prd", category: "writing", triggers: [] }),+ ]);++ renderSkillsSettingsScreen("/skills?category=writing");++ await screen.findByTestId("skill-card-prd");+ expect(screen.queryByTestId("skill-card-deno")).not.toBeInTheDocument();+ });++ it("restores the search text when history navigation changes the query", async () => {+ const user = userEvent.setup();+ vi.spyOn(SkillsService, "getSkills").mockResolvedValue([+ buildSkill({ name: "deno", type: "knowledge", description: "A helper" }),+ buildSkill({+ name: "global-rules",+ type: "repo",+ description: "A helper",+ triggers: [],+ source: "/skills/global-rules.md",+ }),+ ]);++ const router = renderSkillsSettingsScreen("/skills?q=helper");+ await screen.findByTestId("skill-card-deno");+ const search = screen.getByTestId("skills-search-input");++ // Push a second entry, then drop the query from it, so going back lands on a URL whose `q` differs from the input.+ await user.click(screen.getByTestId("skill-facet-type-repo"));+ fireEvent.change(search, { target: { value: "" } });+ await waitFor(() =>+ expect(router.state.location.search).toBe("?type=repo"),+ );++ await act(() => router.navigate(-1));++ await waitFor(() => expect(search).toHaveValue("helper"));+ expect(router.state.location.search).toBe("?q=helper");+ });++ it("filters through the mobile filters modal", async () => {const user = userEvent.setup();vi.spyOn(SkillsService, "getSkills").mockResolvedValue([buildSkill({ name: "deno", type: "knowledge" }),@@ -211,9 +302,9 @@ Full skill body.`,renderSkillsSettingsScreen();await screen.findByTestId("skill-card-deno");- const filter = screen.getByTestId("skills-type-filter");- await user.click(within(filter).getByTestId("dropdown-trigger"));- await user.click(screen.getByTestId("skills-type-filter-repo"));+ await user.click(screen.getByTestId("skills-filters-button"));+ const modal = await screen.findByTestId("skill-filters-modal");+ await user.click(within(modal).getByTestId("skill-facet-type-repo"));expect(screen.queryByTestId("skill-card-deno")).not.toBeInTheDocument();expect(screen.getByTestId("skill-card-global-rules")).toBeInTheDocument();@@ -247,7 +338,9 @@ Full skill body.`,within(modal).getByTestId(`skill-modal-pill-${skill.name}-tool-bash`),).toHaveTextContent("bash");expect(- within(modal).getByTestId(`skill-modal-pill-${skill.name}-tool-execute_bash`),+ within(modal).getByTestId(+ `skill-modal-pill-${skill.name}-tool-execute_bash`,+ ),).toHaveTextContent("execute_bash");expect(within(modal).getByTestId(`skill-modal-toggle-${skill.name}`),@@ -264,7 +357,9 @@ Full skill body.`,await user.click(card);const modal = await screen.findByTestId("skill-detail-modal");- expect(within(modal).getByText("SETTINGS$SKILLS_ENABLED")).toBeInTheDocument();+ expect(+ within(modal).getByText("SETTINGS$SKILLS_ENABLED"),+ ).toBeInTheDocument();await user.click(within(modal).getByTestId(`skill-modal-toggle-${skill.name}`),@@ -274,7 +369,9 @@ Full skill body.`,expect(within(card).getByTestId(`skill-toggle-${skill.name}`),).toHaveAttribute("aria-checked", "false");- expect(within(modal).getByText("SETTINGS$SKILLS_DISABLED")).toBeInTheDocument();+ expect(+ within(modal).getByText("SETTINGS$SKILLS_DISABLED"),+ ).toBeInTheDocument();});it("saves disabled_skills to the server when a skill is toggled off and settings has no prior disabled_skills field", async () => {diff --git a/__tests__/utils/skill-category.test.ts b/__tests__/utils/skill-category.test.tsnew file mode 100644index 0000000000..b48587d086--- /dev/null+++ b/__tests__/utils/skill-category.test.ts@@ -0,0 +1,36 @@+import { describe, expect, it } from "vitest";+import { SKILL_CATEGORY_IDS } from "@openhands/extensions/skills";+import type { SkillInfo } from "#/types/settings";+import {+ getSkillCategory,+ SKILL_CATEGORY_ICONS,+ SKILL_CATEGORY_LABEL_KEYS,+ SKILL_CATEGORY_ORDER,+} from "#/utils/skill-category";++function buildSkill(overrides: Partial<SkillInfo> = {}): SkillInfo {+ return { name: "test-skill", type: "knowledge", source: null, ...overrides };+}++describe("skill-category", () => {+ it("returns the catalog category when it is known", () => {+ expect(getSkillCategory(buildSkill({ category: "environment" }))).toBe(+ "environment",+ );+ });++ it.each([+ ["missing", undefined],+ ["null", null],+ ["unknown to this build", "code-hostig" as never],+ ])("falls back to other when the category is %s", (_label, category) => {+ expect(getSkillCategory(buildSkill({ category }))).toBe("other");+ });++ it("covers every catalog category in the rail order, labels, and icons", () => {+ const ids = [...SKILL_CATEGORY_IDS].sort();+ expect([...SKILL_CATEGORY_ORDER].sort()).toEqual(ids);+ expect(Object.keys(SKILL_CATEGORY_LABEL_KEYS).sort()).toEqual(ids);+ expect(Object.keys(SKILL_CATEGORY_ICONS).sort()).toEqual(ids);+ });+});diff --git a/package-lock.json b/package-lock.jsonindex 36d267fc50..10be4a5121 100644--- a/package-lock.json+++ b/package-lock.json@@ -12,7 +12,7 @@"@heroui/react": "2.8.10","@microlink/react-json-view": "1.31.20","@monaco-editor/react": "4.7.0",- "@openhands/extensions": "0.13.0",+ "@openhands/extensions": "0.15.0","@openhands/typescript-client": "1.36.1","@react-router/node": "7.18.2","@react-router/serve": "7.18.2",@@ -4164,9 +4164,9 @@"license": "MIT"},"node_modules/@openhands/extensions": {- "version": "0.13.0",- "resolved": "https://registry.npmjs.org/@openhands/extensions/-/extensions-0.13.0.tgz",- "integrity": "sha512-+pHEyd2rOdFuLR35yg+M33nQbaDAcIZRWe+yErSkHmTn3wM1hpkgQmG1E0jBgkOTUXMScxDMJAHChrna2GFgHg==",+ "version": "0.15.0",+ "resolved": "https://registry.npmjs.org/@openhands/extensions/-/extensions-0.15.0.tgz",+ "integrity": "sha512-fDzLys9hFLL2CcJVqgN9qHLtkO/1ZZC0P7bm/AezHBUsEws4N2EhbGa/zd+0NwPQel/aUmz6zhCVWeHLTDh2ug==","license": "MIT","engines": {"node": ">=18.20.0"@@ -4196,18 +4196,6 @@"zod": "^3.25.0 || ^4.0.0"}},- "node_modules/@opentelemetry/api": {- "version": "1.9.1",- "resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.9.1.tgz",- "integrity": "sha512-gLyJlPHPZYdAk1JENA9LeHejZe1Ti77/pTeFm/nMXmQH/HFZlcS/O2XJB+L8fkbrNSqhdtlvjBVjxwUYanNH5Q==",- "dev": true,- "license": "Apache-2.0",- "optional": true,- "peer": true,- "engines": {- "node": ">=8.0.0"- }- },"node_modules/@oxc-project/types": {"version": "0.133.0","resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.133.0.tgz",diff --git a/package.json b/package.jsonindex e209c5d6fe..7d3173c4ef 100644--- a/package.json+++ b/package.json@@ -23,7 +23,7 @@"@heroui/react": "2.8.10","@microlink/react-json-view": "1.31.20","@monaco-editor/react": "4.7.0",- "@openhands/extensions": "0.13.0",+ "@openhands/extensions": "0.15.0","@openhands/typescript-client": "1.36.1","@react-router/node": "7.18.2","@react-router/serve": "7.18.2",diff --git a/src/api/skills-service.ts b/src/api/skills-service.tsindex f2b9fa7298..4b1ef8ba82 100644--- a/src/api/skills-service.ts+++ b/src/api/skills-service.ts@@ -16,6 +16,7 @@ function catalogEntryToSkillInfo(entry: SkillCatalogEntry): SkillInfo {source: "public",description: entry.description,triggers: entry.triggers,+ category: entry.category,content: entry.content,license: entry.license ?? null,compatibility: entry.compatibility ?? null,diff --git a/src/components/features/skills/build-skill-pills.tsx b/src/components/features/skills/build-skill-pills.tsxindex 23a36d6c91..68501cc332 100644--- a/src/components/features/skills/build-skill-pills.tsx+++ b/src/components/features/skills/build-skill-pills.tsx@@ -8,6 +8,11 @@ import {SKILL_CARD_PILL_CLASS,type SkillCardPill,} from "./skill-card-pill-row";+import {+ getSkillCategory,+ SKILL_CATEGORY_LABEL_KEYS,+ UNCATEGORIZED_SKILL_CATEGORY,+} from "#/utils/skill-category";type SkillPillVariant = "card" | "detail";@@ -33,6 +38,7 @@ export function buildSkillPills(options: BuildSkillPillsOptions = {},): SkillCardPill[] {const { variant = "card", testIdPrefix } = options;+ const category = getSkillCategory(skill);const pills: SkillCardPill[] = [{id: `type-${skill.type}`,@@ -40,6 +46,25 @@ export function buildSkillPills(},];+ // An "Other" pill says nothing, and every local skill would carry one:+ // only the catalog assigns categories.+ if (category !== UNCATEGORIZED_SKILL_CATEGORY) {+ pills.push({+ id: `category-${category}`,+ node: (+ <span+ data-testid={+ pillTestId(testIdPrefix, skill.name, "category") ??+ `skill-category-${skill.name}`+ }+ className={SKILL_CARD_PILL_CLASS}+ >+ {translate(SKILL_CATEGORY_LABEL_KEYS[category])}+ </span>+ ),+ });+ }+if (skill.version) {pills.push({id: `version-${skill.version}`,diff --git a/src/components/features/skills/skill-facet-rail.tsx b/src/components/features/skills/skill-facet-rail.tsxnew file mode 100644index 0000000000..cb96cd726e--- /dev/null+++ b/src/components/features/skills/skill-facet-rail.tsx@@ -0,0 +1,71 @@+import type { SkillCategoryId } from "@openhands/extensions/skills";+import type { LucideIcon } from "lucide-react";+import { useTranslation } from "react-i18next";+import { cn } from "#/utils/utils";+import { SKILL_CATEGORY_ICONS } from "#/utils/skill-category";+import { SkillFacetRow } from "./skill-facet-row";+import type { SkillFacetGroup, SkillFacetGroupId } from "./skill-filter";++interface SkillFacetRailProps {+ groups: SkillFacetGroup[];+ onToggle: (groupId: SkillFacetGroupId, value: string) => void;+ className?: string;+}++/** Only the category group carries an icon; the rest are plain rows. */+function iconFor(+ groupId: SkillFacetGroupId,+ value: string,+): LucideIcon | undefined {+ if (groupId !== "category") return undefined;+ return SKILL_CATEGORY_ICONS[value as SkillCategoryId];+}++export function SkillFacetRail({+ groups,+ onToggle,+ className,+}: SkillFacetRailProps) {+ const { t } = useTranslation("openhands");++ if (groups.length === 0) return null;++ return (+ <div+ data-testid="skill-facet-rail"+ className={cn("flex min-w-0 flex-col gap-5", className)}+ >+ {groups.map((group) => {+ const titleId = `skill-facet-group-${group.id}-title`;+ return (+ <div+ key={group.id}+ data-testid={`skill-facet-group-${group.id}`}+ role="group"+ aria-labelledby={titleId}+ className="flex flex-col gap-1.5"+ >+ <span+ id={titleId}+ className="px-1 text-[11px] font-semibold uppercase tracking-wider text-tertiary-alt"+ >+ {t(group.labelKey)}+ </span>+ {group.rows.map((row) => (+ <SkillFacetRow+ key={row.value}+ testId={`skill-facet-${group.id}-${row.value}`}+ labelKey={row.labelKey}+ count={row.count}+ checked={row.checked}+ disabled={row.disabled}+ icon={iconFor(group.id, row.value)}+ onToggle={() => onToggle(group.id, row.value)}+ />+ ))}+ </div>+ );+ })}+ </div>+ );+}diff --git a/src/components/features/skills/skill-facet-row.tsx b/src/components/features/skills/skill-facet-row.tsxnew file mode 100644index 0000000000..a224aeb3e6--- /dev/null+++ b/src/components/features/skills/skill-facet-row.tsx@@ -0,0 +1,65 @@+import { Check, type LucideIcon } from "lucide-react";+import { useTranslation } from "react-i18next";+import { I18nKey } from "#/i18n/declaration";+import { cn } from "#/utils/utils";++interface SkillFacetRowProps {+ labelKey: I18nKey;+ count: number;+ checked: boolean;+ disabled: boolean;+ icon?: LucideIcon;+ testId: string;+ onToggle: () => void;+}++export function SkillFacetRow({+ labelKey,+ count,+ checked,+ disabled,+ icon: Icon,+ testId,+ onToggle,+}: SkillFacetRowProps) {+ const { t } = useTranslation("openhands");+ const label = t(labelKey);++ return (+ <button+ type="button"+ role="checkbox"+ aria-checked={checked}+ data-testid={testId}+ disabled={disabled}+ onClick={onToggle}+ className={cn(+ "flex w-full items-center gap-2 rounded-md px-1.5 py-1 text-left text-sm",+ disabled+ ? "cursor-default text-tertiary-alt/40"+ : // Same hover pair as the extensions nav links: a raised surface the+ // label brightens against, rather than a light fill it sinks into.+ "cursor-pointer hover:bg-[var(--oh-surface-raised)] hover:text-white",+ checked ? "text-white" : "text-tertiary-light",+ )}+ >+ <span+ aria-hidden+ className={cn(+ "flex size-3.5 shrink-0 items-center justify-center rounded-[3px] border",+ checked+ ? "border-white bg-white text-black"+ : "border-[var(--oh-border)]",+ )}+ >+ {checked ? <Check className="size-2.5" strokeWidth={3} /> : null}+ </span>+ {Icon ? <Icon className="size-3.5 shrink-0" aria-hidden /> : null}+ {/* The rail cannot be wide enough for every locale, so a truncated label stays readable on hover. */}+ <span title={label} className="min-w-0 flex-1 truncate">+ {label}+ </span>+ <span className="shrink-0 text-xs text-tertiary-alt">{count}</span>+ </button>+ );+}diff --git a/src/components/features/skills/skill-filter.ts b/src/components/features/skills/skill-filter.tsnew file mode 100644index 0000000000..cb6e26048b--- /dev/null+++ b/src/components/features/skills/skill-filter.ts@@ -0,0 +1,364 @@+import type { SkillCategoryId } from "@openhands/extensions/skills";+import { I18nKey } from "#/i18n/declaration";+import type { SkillInfo, SkillType } from "#/types/settings";+import {+ getSkillCategory,+ SKILL_CATEGORY_LABEL_KEYS,+ SKILL_CATEGORY_ORDER,+} from "#/utils/skill-category";+import {+ getSkillScope,+ SKILL_SCOPE_ORDER,+ type SkillScope,+} from "#/utils/skill-scope";+import { getSkillCardDescription } from "./get-skill-card-description";++export const SKILL_FILTER_QUERY_PARAM = "q";+const SOURCE_PARAM = "source";+const CATEGORY_PARAM = "category";+const TYPE_PARAM = "type";+const STATE_PARAM = "state";++export type SkillEnabledState = "enabled" | "disabled";+export type SkillFacetGroupId = "state" | "source" | "category" | "type";++const SKILL_ENABLED_STATE_ORDER: readonly SkillEnabledState[] = [+ "enabled",+ "disabled",+];+const SKILL_TYPE_ORDER: readonly SkillType[] = [+ "agentskills",+ "knowledge",+ "repo",+];++export interface SkillFilterState {+ query: string;+ sources: Set<SkillScope>;+ categories: Set<SkillCategoryId>;+ types: Set<SkillType>;+ states: Set<SkillEnabledState>;+}++export interface SkillFacetRowModel {+ value: string;+ labelKey: I18nKey;+ count: number;+ checked: boolean;+ disabled: boolean;+}++export interface SkillFacetGroup {+ id: SkillFacetGroupId;+ labelKey: I18nKey;+ rows: SkillFacetRowModel[];+}++export const EMPTY_SKILL_FILTER_STATE: SkillFilterState = {+ query: "",+ sources: new Set(),+ categories: new Set(),+ types: new Set(),+ states: new Set(),+};++/** Carrying `labelKey`s rather than translated strings keeps this module pure, so its tests need no i18n. */+interface GroupValue {+ value: string;+ labelKey: I18nKey;+}++function labelledValues<TValue extends string>(+ order: readonly TValue[],+ labelKeys: Record<TValue, I18nKey>,+): readonly GroupValue[] {+ return order.map((value) => ({ value, labelKey: labelKeys[value] }));+}++/** A new facet group is declared here and nowhere else: `selected` / `withSelected` are what keep every operation below driven by this table alone. */+interface GroupDef {+ id: SkillFacetGroupId;+ labelKey: I18nKey;+ param: string;+ values: readonly GroupValue[];+ valueOf: (skill: SkillInfo, disabledSet: Set<string>) => string;+ selected: (state: SkillFilterState) => Set<string>;+ withSelected: (+ state: SkillFilterState,+ next: Set<string>,+ ) => SkillFilterState;+}++/** Rebuilding rather than casting keeps every writer below cast-free: a value the group does not declare cannot survive. */+function narrowSet<TValue extends string>(+ order: readonly TValue[],+ next: Set<string>,+): Set<TValue> {+ return new Set(order.filter((value) => next.has(value)));+}++const SOURCE_LABEL_KEYS: Record<SkillScope, I18nKey> = {+ project: I18nKey.SETTINGS$SKILLS_SOURCE_PROJECT,+ personal: I18nKey.SETTINGS$SKILLS_SOURCE_PERSONAL,+ public: I18nKey.SETTINGS$SKILLS_SOURCE_PUBLIC,+};++const TYPE_LABEL_KEYS: Record<SkillType, I18nKey> = {+ agentskills: I18nKey.SETTINGS$SKILLS_TYPE_AGENTSKILLS,+ knowledge: I18nKey.SETTINGS$SKILLS_TYPE_KNOWLEDGE,+ repo: I18nKey.SETTINGS$SKILLS_TYPE_REPO,+};++const STATE_LABEL_KEYS: Record<SkillEnabledState, I18nKey> = {+ enabled: I18nKey.SETTINGS$SKILLS_ENABLED,+ disabled: I18nKey.SETTINGS$SKILLS_DISABLED,+};++const GROUP_DEFS: readonly GroupDef[] = [+ {+ id: "state",+ labelKey: I18nKey.SETTINGS$SKILLS_FACET_STATE,+ param: STATE_PARAM,+ values: labelledValues(SKILL_ENABLED_STATE_ORDER, STATE_LABEL_KEYS),+ valueOf: (skill, disabledSet) =>+ disabledSet.has(skill.name) ? "disabled" : "enabled",+ selected: (state) => state.states,+ withSelected: (state, next) => ({+ ...state,+ states: narrowSet(SKILL_ENABLED_STATE_ORDER, next),+ }),+ },+ {+ id: "source",+ labelKey: I18nKey.SETTINGS$SKILLS_FACET_SOURCE,+ param: SOURCE_PARAM,+ values: labelledValues(SKILL_SCOPE_ORDER, SOURCE_LABEL_KEYS),+ valueOf: (skill) => getSkillScope(skill),+ selected: (state) => state.sources,+ withSelected: (state, next) => ({+ ...state,+ sources: narrowSet(SKILL_SCOPE_ORDER, next),+ }),+ },+ {+ id: "category",+ labelKey: I18nKey.SETTINGS$SKILLS_FACET_CATEGORY,+ param: CATEGORY_PARAM,+ values: labelledValues(SKILL_CATEGORY_ORDER, SKILL_CATEGORY_LABEL_KEYS),+ valueOf: (skill) => getSkillCategory(skill),+ selected: (state) => state.categories,+ withSelected: (state, next) => ({+ ...state,+ categories: narrowSet(SKILL_CATEGORY_ORDER, next),+ }),+ },+ {+ id: "type",+ labelKey: I18nKey.SETTINGS$SKILLS_FACET_TYPE,+ param: TYPE_PARAM,+ values: labelledValues(SKILL_TYPE_ORDER, TYPE_LABEL_KEYS),+ valueOf: (skill) => skill.type,+ selected: (state) => state.types,+ withSelected: (state, next) => ({+ ...state,+ types: narrowSet(SKILL_TYPE_ORDER, next),+ }),+ },+];++function groupDef(id: SkillFacetGroupId): GroupDef {+ const def = GROUP_DEFS.find((candidate) => candidate.id === id);+ if (!def) throw new Error(`Unknown skill facet group: ${id}`);+ return def;+}++/** Unknown values are dropped, so a hand-edited URL cannot smuggle one in. */+function parseSet(raw: string[], def: GroupDef): Set<string> {+ const legal = new Set(def.values.map(({ value }) => value));+ return new Set(+ raw.map((value) => value.trim()).filter((value) => legal.has(value)),+ );+}++export function parseSkillFilterState(+ params: URLSearchParams,+): SkillFilterState {+ return GROUP_DEFS.reduce<SkillFilterState>(+ (state, def) =>+ def.withSelected(state, parseSet(params.getAll(def.param), def)),+ {+ ...EMPTY_SKILL_FILTER_STATE,+ query: params.get(SKILL_FILTER_QUERY_PARAM) ?? "",+ },+ );+}++export function toSkillFilterSearchParams(+ state: SkillFilterState,+): URLSearchParams {+ const params = new URLSearchParams();+ if (state.query) params.set(SKILL_FILTER_QUERY_PARAM, state.query);++ // Canonical order keeps URLs deterministic regardless of click order.+ for (const def of GROUP_DEFS) {+ const selected = def.selected(state);+ for (const { value } of def.values) {+ if (selected.has(value)) params.append(def.param, value);+ }+ }++ return params;+}++function matchesQuery(skill: SkillInfo, query: string): boolean {+ const trimmed = query.trim();+ if (!trimmed) return true;++ const haystacks = [+ skill.name,+ getSkillCardDescription(skill),+ skill.description ?? "",+ skill.content ?? "",+ skill.license ?? "",+ skill.compatibility ?? "",+ ...(skill.triggers ?? []),+ ...(skill.allowed_tools ?? []),+ ];++ const lowered = trimmed.toLowerCase();+ return haystacks.some((value) => value.toLowerCase().includes(lowered));+}++/**+ * `exclude` omits one group's own selection so its rows stay counted against the other groups alone.+ * A row therefore reads "this many skills carry this value, under your other filters" — the usual disjunctive facet count — and not "your result set will be this big": the group ORs its values together, so on a group that already has a selection the two differ.+ */+function matchesFacets(+ skill: SkillInfo,+ disabledSet: Set<string>,+ state: SkillFilterState,+ exclude?: SkillFacetGroupId,+): boolean {+ return GROUP_DEFS.every((def) => {+ if (def.id === exclude) return true;+ const selected = def.selected(state);+ if (selected.size === 0) return true;+ return selected.has(def.valueOf(skill, disabledSet));+ });+}++export function applySkillFilters(+ skills: SkillInfo[],+ disabledSet: Set<string>,+ state: SkillFilterState,+): SkillInfo[] {+ return skills.filter(+ (skill) =>+ matchesQuery(skill, state.query) &&+ matchesFacets(skill, disabledSet, state),+ );+}++function countByValue(+ skills: SkillInfo[],+ def: GroupDef,+ disabledSet: Set<string>,+): Record<string, number> {+ const counts: Record<string, number> = {};+ for (const skill of skills) {+ const value = def.valueOf(skill, disabledSet);+ counts[value] = (counts[value] ?? 0) + 1;+ }+ return counts;+}++function buildGroup(+ def: GroupDef,+ allSkills: SkillInfo[],+ searched: SkillInfo[],+ disabledSet: Set<string>,+ state: SkillFilterState,+): SkillFacetGroup | null {+ // Visibility and the row set come from the raw list so the rail's shape+ // depends only on what the user has, never on the active filters. If they+ // tracked filtered counts, narrowing could make a group vanish mid-click.+ const rawCounts = countByValue(allSkills, def, disabledSet);+ const discriminating = def.values.filter(+ ({ value }) => (rawCounts[value] ?? 0) > 0,+ );+ const selected = def.selected(state);+ // A group with only one (or zero) discriminating values is normally hidden,+ // but a selection can still be carried in from the URL for a value that has+ // no matches for this user. Hiding the group then would enforce the filter+ // invisibly, with no row left to explain or undo it.+ if (discriminating.length < 2 && selected.size === 0) return null;++ const visibleValues = def.values.filter(+ ({ value }) => (rawCounts[value] ?? 0) > 0 || selected.has(value),+ );++ const candidates = searched.filter((skill) =>+ matchesFacets(skill, disabledSet, state, def.id),+ );+ const counts = countByValue(candidates, def, disabledSet);++ return {+ id: def.id,+ labelKey: def.labelKey,+ rows: visibleValues.map(({ value, labelKey }) => {+ const count = counts[value] ?? 0;+ const checked = selected.has(value);+ return {+ value,+ labelKey,+ count,+ checked,+ disabled: count === 0 && !checked,+ };+ }),+ };+}++export function buildSkillFacetGroups(+ skills: SkillInfo[],+ disabledSet: Set<string>,+ state: SkillFilterState,+): SkillFacetGroup[] {+ const searched = skills.filter((skill) => matchesQuery(skill, state.query));++ return GROUP_DEFS.map((def) =>+ buildGroup(def, skills, searched, disabledSet, state),+ ).filter((group): group is SkillFacetGroup => group !== null);+}++export function toggleSkillFilterValue(+ state: SkillFilterState,+ groupId: SkillFacetGroupId,+ value: string,+): SkillFilterState {+ const def = groupDef(groupId);+ // `withSelected` would drop an unknown value anyway; returning the same+ // state object keeps a no-op toggle from re-rendering or rewriting the URL.+ if (!def.values.some((candidate) => candidate.value === value)) return state;++ const next = new Set(def.selected(state));+ if (next.has(value)) {+ next.delete(value);+ } else {+ next.add(value);+ }++ return def.withSelected(state, next);+}++export function clearSkillFilterFacets(+ state: SkillFilterState,+): SkillFilterState {+ return { ...EMPTY_SKILL_FILTER_STATE, query: state.query };+}++export function countActiveFilters(state: SkillFilterState): number {+ // The query is excluded: it is already visible in its own input, so counting+ // it would double-report in both the Filters badge and the summary row.+ return GROUP_DEFS.reduce((total, def) => total + def.selected(state).size, 0);+}diff --git a/src/components/features/skills/skill-filters-modal.tsx b/src/components/features/skills/skill-filters-modal.tsxnew file mode 100644index 0000000000..f2c26394a1--- /dev/null+++ b/src/components/features/skills/skill-filters-modal.tsx@@ -0,0 +1,70 @@+import { useTranslation } from "react-i18next";+import { BrandButton } from "#/components/features/settings/brand-button";+import { ModalBackdrop } from "#/components/shared/modals/modal-backdrop";+import {+ MODAL_MAX_WIDTH_VIEWPORT,+ ModalBody,+} from "#/components/shared/modals/modal-body";+import { I18nKey } from "#/i18n/declaration";+import { cn } from "#/utils/utils";+import { SkillFacetRail } from "./skill-facet-rail";+import type { SkillFacetGroup, SkillFacetGroupId } from "./skill-filter";++interface SkillFiltersModalProps {+ groups: SkillFacetGroup[];+ activeCount: number;+ onToggle: (groupId: SkillFacetGroupId, value: string) => void;+ onClearAll: () => void;+ onClose: () => void;+}++export function SkillFiltersModal({+ groups,+ activeCount,+ onToggle,+ onClearAll,+ onClose,+}: SkillFiltersModalProps) {+ const { t } = useTranslation("openhands");++ return (+ <ModalBackdrop+ onClose={onClose}+ aria-label={t(I18nKey.SETTINGS$SKILLS_FILTERS_MODAL_TITLE)}+ >+ <ModalBody+ testID="skill-filters-modal"+ className={cn("items-stretch", MODAL_MAX_WIDTH_VIEWPORT)}+ >+ <h3 className="text-lg font-semibold text-foreground">+ {t(I18nKey.SETTINGS$SKILLS_FILTERS_MODAL_TITLE)}+ </h3>++ <div className="max-h-[60vh] overflow-y-auto custom-scrollbar-always">+ <SkillFacetRail groups={groups} onToggle={onToggle} />+ </div>++ <div className="flex items-center justify-end gap-2">+ {activeCount > 0 ? (+ <BrandButton+ type="button"+ variant="secondary"+ testId="skill-filters-modal-clear"+ onClick={onClearAll}+ >+ {t(I18nKey.SETTINGS$SKILLS_CLEAR_FILTERS)}+ </BrandButton>+ ) : null}+ <BrandButton+ type="button"+ variant="primary"+ testId="skill-filters-modal-done"+ onClick={onClose}+ >+ {t(I18nKey.BUTTON$CLOSE)}+ </BrandButton>+ </div>+ </ModalBody>+ </ModalBackdrop>+ );+}diff --git a/src/components/features/skills/skill-type-filter.ts b/src/components/features/skills/skill-type-filter.tsdeleted file mode 100644index 94e7998c4e..0000000000--- a/src/components/features/skills/skill-type-filter.ts+++ /dev/null@@ -1,10 +0,0 @@-import type { SkillType } from "#/types/settings";--export type SkillTypeFilter = "all" | SkillType;--export const SKILL_TYPE_FILTER_OPTIONS: SkillTypeFilter[] = [- "all",- "agentskills",- "knowledge",- "repo",-];diff --git a/src/components/features/skills/skills-toolbar.tsx b/src/components/features/skills/skills-toolbar.tsxindex d560810f54..8ca117c52a 100644--- a/src/components/features/skills/skills-toolbar.tsx+++ b/src/components/features/skills/skills-toolbar.tsx@@ -1,22 +1,20 @@-import { Search, X } from "lucide-react";+import { ListFilter, Search, X } from "lucide-react";import { useTranslation } from "react-i18next";import { I18nKey } from "#/i18n/declaration";import { cn } from "#/utils/utils";-import type { SkillTypeFilter } from "./skill-type-filter";-import { SkillsTypeFilterDropdown } from "./skills-type-filter-dropdown";interface SkillsToolbarProps {search: string;onSearchChange: (value: string) => void;- typeFilter: SkillTypeFilter;- onTypeFilterChange: (filter: SkillTypeFilter) => void;+ activeFilterCount: number;+ onOpenFilters: () => void;}export function SkillsToolbar({search,onSearchChange,- typeFilter,- onTypeFilterChange,+ activeFilterCount,+ onOpenFilters,}: SkillsToolbarProps) {const { t } = useTranslation("openhands");@@ -59,10 +57,25 @@ export function SkillsToolbar({) : null}</div>- <SkillsTypeFilterDropdown- value={typeFilter}- onChange={onTypeFilterChange}- />+ {/* The facet rail is desktop-only, so below md this is the only way in. */}+ <button+ type="button"+ data-testid="skills-filters-button"+ onClick={onOpenFilters}+ className={cn(+ "flex shrink-0 items-center gap-2 rounded-lg px-3 py-2 text-sm md:hidden",+ "border border-[var(--oh-border)] bg-base-secondary text-white",+ "cursor-pointer hover:bg-[var(--oh-interactive-hover)]",+ )}+ >+ <ListFilter className="size-4 shrink-0" aria-hidden />+ {t(I18nKey.SETTINGS$SKILLS_FILTERS_BUTTON)}+ {activeFilterCount > 0 ? (+ <span className="rounded-full bg-white px-1.5 text-[11px] font-medium text-black">+ {activeFilterCount}+ </span>+ ) : null}+ </button></div>);}diff --git a/src/components/features/skills/skills-type-filter-dropdown.tsx b/src/components/features/skills/skills-type-filter-dropdown.tsxdeleted file mode 100644index e37568cc9c..0000000000--- a/src/components/features/skills/skills-type-filter-dropdown.tsx+++ /dev/null@@ -1,33 +0,0 @@-import { I18nKey } from "#/i18n/declaration";-import { EnumFilterDropdown } from "#/components/shared/filters/enum-filter-dropdown";-import {- SKILL_TYPE_FILTER_OPTIONS,- type SkillTypeFilter,-} from "./skill-type-filter";--const FILTER_LABEL_KEY: Record<SkillTypeFilter, I18nKey> = {- all: I18nKey.SETTINGS$SKILLS_TYPE_ALL,- agentskills: I18nKey.SETTINGS$SKILLS_TYPE_AGENTSKILLS,- knowledge: I18nKey.SETTINGS$SKILLS_TYPE_KNOWLEDGE,- repo: I18nKey.SETTINGS$SKILLS_TYPE_REPO,-};--interface SkillsTypeFilterDropdownProps {- value: SkillTypeFilter;- onChange: (filter: SkillTypeFilter) => void;-}--export function SkillsTypeFilterDropdown({- value,- onChange,-}: SkillsTypeFilterDropdownProps) {- return (- <EnumFilterDropdown- testId="skills-type-filter"- value={value}- onChange={onChange}- options={SKILL_TYPE_FILTER_OPTIONS}- labelKeyByValue={FILTER_LABEL_KEY}- />- );-}diff --git a/src/i18n/translation.json b/src/i18n/translation.jsonindex 1129b79683..2b88ba105c 100644--- a/src/i18n/translation.json+++ b/src/i18n/translation.json@@ -27233,23 +27233,6 @@"uk": "Шукати навички за назвою, описом або тригером","ca": "Cerca habilitats per nom, descripció o activador"},- "SETTINGS$SKILLS_TYPE_ALL": {- "en": "All",- "ja": "すべて",- "zh-CN": "全部",- "zh-TW": "全部",- "ko-KR": "전체",- "no": "Alle",- "ar": "الكل",- "de": "Alle",- "fr": "Tout",- "it": "Tutti",- "pt": "Todos",- "es": "Todos",- "tr": "Tümü",- "uk": "Усі",- "ca": "Tot"- },"SETTINGS$SKILLS_TYPE_AGENTSKILLS": {"en": "Auto-discovery","ja": "自動検出",@@ -33132,6 +33115,346 @@"uk": "Прочитайте повний посібник з додавання навичок →","ca": "Llegiu la guia completa per afegir habilitats →"},+ "SETTINGS$SKILLS_CATEGORY_AUTOMATIONS": {+ "en": "Automation recipes",+ "ja": "自動化レシピ",+ "zh-CN": "自动化方案",+ "zh-TW": "自動化方案",+ "ko-KR": "자동화 레시피",+ "no": "Automatiseringsoppskrifter",+ "ar": "وصفات التشغيل الآلي",+ "de": "Automatisierungsrezepte",+ "fr": "Recettes d'automatisation",+ "it": "Ricette di automazione",+ "pt": "Receitas de automação",+ "es": "Recetas de automatización",+ "tr": "Otomasyon tarifleri",+ "uk": "Рецепти автоматизації",+ "ca": "Receptes d'automatització"+ },+ "SETTINGS$SKILLS_CATEGORY_ENVIRONMENT": {+ "en": "Environment & tooling",+ "ja": "環境とツール",+ "zh-CN": "环境与工具",+ "zh-TW": "環境與工具",+ "ko-KR": "환경 및 도구",+ "no": "Miljø og verktøy",+ "ar": "البيئة والأدوات",+ "de": "Umgebung & Werkzeuge",+ "fr": "Environnement et outils",+ "it": "Ambiente e strumenti",+ "pt": "Ambiente e ferramentas",+ "es": "Entorno y herramientas",+ "tr": "Ortam ve araçlar",+ "uk": "Середовище та інструменти",+ "ca": "Entorn i eines"+ },+ "SETTINGS$SKILLS_CATEGORY_CODE_HOSTING": {+ "en": "Code hosting & CI",+ "ja": "コードホスティングとCI",+ "zh-CN": "代码托管与 CI",+ "zh-TW": "程式碼託管與 CI",+ "ko-KR": "코드 호스팅 및 CI",+ "no": "Kodehosting og CI",+ "ar": "استضافة الشيفرة والتكامل المستمر",+ "de": "Code-Hosting & CI",+ "fr": "Hébergement de code et CI",+ "it": "Hosting del codice e CI",+ "pt": "Hospedagem de código e CI",+ "es": "Alojamiento de código y CI",+ "tr": "Kod barındırma ve CI",+ "uk": "Хостинг коду та CI",+ "ca": "Allotjament de codi i CI"+ },+ "SETTINGS$SKILLS_CATEGORY_AGENT_AUTHORING": {+ "en": "Agent authoring",+ "ja": "エージェント作成",+ "zh-CN": "智能体创作",+ "zh-TW": "代理程式創作",+ "ko-KR": "에이전트 작성",+ "no": "Agentutvikling",+ "ar": "تأليف الوكلاء",+ "de": "Agentenerstellung",+ "fr": "Création d'agents",+ "it": "Creazione di agenti",+ "pt": "Criação de agentes",+ "es": "Creación de agentes",+ "tr": "Aracı oluşturma",+ "uk": "Створення агентів",+ "ca": "Creació d'agents"+ },+ "SETTINGS$SKILLS_CATEGORY_CODE_QUALITY": {+ "en": "Code quality & review",+ "ja": "コード品質とレビュー",+ "zh-CN": "代码质量与审查",+ "zh-TW": "程式碼品質與審查",+ "ko-KR": "코드 품질 및 검토",+ "no": "Kodekvalitet og gjennomgang",+ "ar": "جودة الشيفرة والمراجعة",+ "de": "Codequalität & Review",+ "fr": "Qualité du code et revue",+ "it": "Qualità del codice e revisione",+ "pt": "Qualidade de código e revisão",+ "es": "Calidad de código y revisión",+ "tr": "Kod kalitesi ve inceleme",+ "uk": "Якість коду та рецензування",+ "ca": "Qualitat del codi i revisió"+ },+ "SETTINGS$SKILLS_CATEGORY_INTEGRATIONS": {+ "en": "Service integrations",+ "ja": "サービス連携",+ "zh-CN": "服务集成",+ "zh-TW": "服務整合",+ "ko-KR": "서비스 연동",+ "no": "Tjenesteintegrasjoner",+ "ar": "تكاملات الخدمات",+ "de": "Dienstintegrationen",+ "fr": "Intégrations de services",+ "it": "Integrazioni di servizi",+ "pt": "Integrações de serviços",+ "es": "Integraciones de servicios",+ "tr": "Hizmet entegrasyonları",+ "uk": "Інтеграції сервісів",+ "ca": "Integracions de serveis"+ },+ "SETTINGS$SKILLS_CATEGORY_WRITING": {+ "en": "Writing & docs",+ "ja": "執筆とドキュメント",+ "zh-CN": "写作与文档",+ "zh-TW": "寫作與文件",+ "ko-KR": "작성 및 문서",+ "no": "Skriving og dokumentasjon",+ "ar": "الكتابة والمستندات",+ "de": "Schreiben & Dokumentation",+ "fr": "Rédaction et documentation",+ "it": "Scrittura e documentazione",+ "pt": "Escrita e documentação",+ "es": "Redacción y documentación",+ "tr": "Yazım ve dokümantasyon",+ "uk": "Написання та документація",+ "ca": "Redacció i documentació"+ },+ "SETTINGS$SKILLS_CATEGORY_DESIGN": {+ "en": "Design & frontend",+ "ja": "デザインとフロントエンド",+ "zh-CN": "设计与前端",+ "zh-TW": "設計與前端",+ "ko-KR": "디자인 및 프런트엔드",+ "no": "Design og frontend",+ "ar": "التصميم والواجهة الأمامية",+ "de": "Design & Frontend",+ "fr": "Design et frontend",+ "it": "Design e frontend",+ "pt": "Design e frontend",+ "es": "Diseño y frontend",+ "tr": "Tasarım ve ön yüz",+ "uk": "Дизайн та фронтенд",+ "ca": "Disseny i frontend"+ },+ "SETTINGS$SKILLS_CATEGORY_OTHER": {+ "en": "Uncategorized",+ "ja": "未分類",+ "zh-CN": "未分类",+ "zh-TW": "未分類",+ "ko-KR": "미분류",+ "no": "Ukategorisert",+ "ar": "غير مصنّف",+ "de": "Nicht kategorisiert",+ "fr": "Non catégorisé",+ "it": "Non categorizzato",+ "pt": "Sem categoria",+ "es": "Sin categoría",+ "tr": "Kategorisiz",+ "uk": "Без категорії",+ "ca": "Sense categoria"+ },+ "SETTINGS$SKILLS_FACET_STATE": {+ "en": "State",+ "ja": "状態",+ "zh-CN": "状态",+ "zh-TW": "狀態",+ "ko-KR": "상태",+ "no": "Tilstand",+ "ar": "الحالة",+ "de": "Status",+ "fr": "État",+ "it": "Stato",+ "pt": "Estado",+ "es": "Estado",+ "tr": "Durum",+ "uk": "Стан",+ "ca": "Estat"+ },+ "SETTINGS$SKILLS_FACET_SOURCE": {+ "en": "Source",+ "ja": "ソース",+ "zh-CN": "来源",+ "zh-TW": "來源",+ "ko-KR": "출처",+ "no": "Kilde",+ "ar": "المصدر",+ "de": "Quelle",+ "fr": "Source",+ "it": "Origine",+ "pt": "Origem",+ "es": "Origen",+ "tr": "Kaynak",+ "uk": "Джерело",+ "ca": "Origen"+ },+ "SETTINGS$SKILLS_FACET_CATEGORY": {+ "en": "Category",+ "ja": "カテゴリ",+ "zh-CN": "类别",+ "zh-TW": "類別",+ "ko-KR": "카테고리",+ "no": "Kategori",+ "ar": "الفئة",+ "de": "Kategorie",+ "fr": "Catégorie",+ "it": "Categoria",+ "pt": "Categoria",+ "es": "Categoría",+ "tr": "Kategori",+ "uk": "Категорія",+ "ca": "Categoria"+ },+ "SETTINGS$SKILLS_FACET_TYPE": {+ "en": "Type",+ "ja": "タイプ",+ "zh-CN": "类型",+ "zh-TW": "類型",+ "ko-KR": "유형",+ "no": "Type",+ "ar": "النوع",+ "de": "Typ",+ "fr": "Type",+ "it": "Tipo",+ "pt": "Tipo",+ "es": "Tipo",+ "tr": "Tür",+ "uk": "Тип",+ "ca": "Tipus"+ },+ "SETTINGS$SKILLS_SOURCE_PROJECT": {+ "en": "This project",+ "ja": "このプロジェクト",+ "zh-CN": "此项目",+ "zh-TW": "此專案",+ "ko-KR": "이 프로젝트",+ "no": "Dette prosjektet",+ "ar": "هذا المشروع",+ "de": "Dieses Projekt",+ "fr": "Ce projet",+ "it": "Questo progetto",+ "pt": "Este projeto",+ "es": "Este proyecto",+ "tr": "Bu proje",+ "uk": "Цей проєкт",+ "ca": "Aquest projecte"+ },+ "SETTINGS$SKILLS_SOURCE_PERSONAL": {+ "en": "Personal",+ "ja": "個人",+ "zh-CN": "个人",+ "zh-TW": "個人",+ "ko-KR": "개인",+ "no": "Personlig",+ "ar": "شخصي",+ "de": "Persönlich",+ "fr": "Personnel",+ "it": "Personale",+ "pt": "Pessoal",+ "es": "Personal",+ "tr": "Kişisel",+ "uk": "Особисті",+ "ca": "Personal"+ },+ "SETTINGS$SKILLS_SOURCE_PUBLIC": {+ "en": "Built in",+ "ja": "組み込み",+ "zh-CN": "内置",+ "zh-TW": "內建",+ "ko-KR": "기본 제공",+ "no": "Innebygd",+ "ar": "مضمّن",+ "de": "Integriert",+ "fr": "Intégré",+ "it": "Integrato",+ "pt": "Integrado",+ "es": "Integrado",+ "tr": "Yerleşik",+ "uk": "Вбудовані",+ "ca": "Integrat"+ },+ "SETTINGS$SKILLS_FILTERS_BUTTON": {+ "en": "Filters",+ "ja": "フィルター",+ "zh-CN": "筛选",+ "zh-TW": "篩選",+ "ko-KR": "필터",+ "no": "Filtre",+ "ar": "عوامل التصفية",+ "de": "Filter",+ "fr": "Filtres",+ "it": "Filtri",+ "pt": "Filtros",+ "es": "Filtros",+ "tr": "Filtreler",+ "uk": "Фільтри",+ "ca": "Filtres"+ },+ "SETTINGS$SKILLS_CLEAR_FILTERS": {+ "en": "Clear filters",+ "ja": "フィルターをクリア",+ "zh-CN": "清除筛选",+ "zh-TW": "清除篩選",+ "ko-KR": "필터 지우기",+ "no": "Fjern filtre",+ "ar": "مسح عوامل التصفية",+ "de": "Filter zurücksetzen",+ "fr": "Effacer les filtres",+ "it": "Cancella filtri",+ "pt": "Limpar filtros",+ "es": "Borrar filtros",+ "tr": "Filtreleri temizle",+ "uk": "Очистити фільтри",+ "ca": "Esborra els filtres"+ },+ "SETTINGS$SKILLS_FILTERS_MODAL_TITLE": {+ "en": "Filter skills",+ "ja": "スキルを絞り込む",+ "zh-CN": "筛选技能",+ "zh-TW": "篩選技能",+ "ko-KR": "스킬 필터",+ "no": "Filtrer ferdigheter",+ "ar": "تصفية المهارات",+ "de": "Skills filtern",+ "fr": "Filtrer les compétences",+ "it": "Filtra competenze",+ "pt": "Filtrar habilidades",+ "es": "Filtrar habilidades",+ "tr": "Becerileri filtrele",+ "uk": "Фільтрувати навички",+ "ca": "Filtra les habilitats"+ },+ "SETTINGS$SKILLS_RESULT_COUNT": {+ "en": "{{count}} result(s)",+ "ja": "{{count}} 件の結果",+ "zh-CN": "{{count}} 个结果",+ "zh-TW": "{{count}} 個結果",+ "ko-KR": "{{count}}개 결과",+ "no": "{{count}} treff",+ "ar": "{{count}} نتيجة",+ "de": "{{count}} Ergebnisse",+ "fr": "{{count}} résultats",+ "it": "{{count}} risultati",+ "pt": "{{count}} resultados",+ "es": "{{count}} resultados",+ "tr": "{{count}} sonuç",+ "uk": "{{count}} результатів",+ "ca": "{{count}} resultats"+ },"RECOMMENDED_AUTOMATIONS$SECTION_LABEL": {"en": "Recommended automations","ja": "おすすめの自動化",diff --git a/src/routes/skills-settings.tsx b/src/routes/skills-settings.tsxindex cfad808b65..832dbcd8c5 100644--- a/src/routes/skills-settings.tsx+++ b/src/routes/skills-settings.tsx@@ -1,43 +1,42 @@import React from "react";import { useTranslation } from "react-i18next";-import { useSaveSettings } from "#/hooks/mutation/use-save-settings";-import { useSettings } from "#/hooks/query/use-settings";-import { useSkills } from "#/hooks/query/use-skills";+import { useSearchParams } from "react-router";+import { BrandButton } from "#/components/features/settings/brand-button";import { ExtensionsNavigation } from "#/components/features/skills/extensions-navigation";+import { AddSkillModal } from "#/components/features/skills/add-skill-modal";import { SkillCard } from "#/components/features/skills/skill-card";import { SkillDetailModal } from "#/components/features/skills/skill-detail-modal";-import { AddSkillModal } from "#/components/features/skills/add-skill-modal";+import { SkillFacetRail } from "#/components/features/skills/skill-facet-rail";+import { SkillFiltersModal } from "#/components/features/skills/skill-filters-modal";+import {+ applySkillFilters,+ buildSkillFacetGroups,+ clearSkillFilterFacets,+ countActiveFilters,+ parseSkillFilterState,+ SKILL_FILTER_QUERY_PARAM,+ toggleSkillFilterValue,+ toSkillFilterSearchParams,+ type SkillFacetGroupId,+ type SkillFilterState,+} from "#/components/features/skills/skill-filter";import { SkillsToolbar } from "#/components/features/skills/skills-toolbar";-import { BrandButton } from "#/components/features/settings/brand-button";-import type { SkillTypeFilter } from "#/components/features/skills/skill-type-filter";+import { useSaveSettings } from "#/hooks/mutation/use-save-settings";+import { useSettings } from "#/hooks/query/use-settings";+import { useSkills } from "#/hooks/query/use-skills";import { I18nKey } from "#/i18n/declaration";+import type { SkillInfo } from "#/types/settings";import { displayErrorToast } from "#/utils/custom-toast-handlers";-import { retrieveAxiosErrorMessage } from "#/utils/retrieve-axios-error-message";-import { cn } from "#/utils/utils";-import { settingsLikeMainScrollClassName } from "#/utils/settings-like-page-layout-classes";import {extensionModuleCardGridClassName,extensionModuleCardGridContainerClassName,extensionModuleEmptyStateClassName,} from "#/utils/extension-module-card-classes";-import type { SkillInfo } from "#/types/settings";-import { getSkillCardDescription } from "#/components/features/skills/get-skill-card-description";--function matchesSearch(skill: SkillInfo, query: string): boolean {- if (!query) return true;- const haystacks = [- skill.name,- getSkillCardDescription(skill),- skill.description ?? "",- skill.content ?? "",- skill.license ?? "",- skill.compatibility ?? "",- ...(skill.triggers ?? []),- ...(skill.allowed_tools ?? []),- ];- const lowered = query.toLowerCase();- return haystacks.some((value) => value.toLowerCase().includes(lowered));-}+import { retrieveAxiosErrorMessage } from "#/utils/retrieve-axios-error-message";+import { settingsLikeMainScrollClassName } from "#/utils/settings-like-page-layout-classes";+import { cn } from "#/utils/utils";++const SEARCH_URL_SYNC_DELAY_MS = 300;function SkillsSettingsScreen() {const { t } = useTranslation("openhands");@@ -46,15 +45,41 @@ function SkillsSettingsScreen() {const { data: settings, isLoading: settingsLoading } = useSettings();const { data: skills, isLoading: skillsLoading } = useSkills();+ const [searchParams, setSearchParams] = useSearchParams();+ const [queryInput, setQueryInput] = React.useState(+ () => searchParams.get(SKILL_FILTER_QUERY_PARAM) ?? "",+ );+ // The last `q` this component put in the URL, which is what lets the sync effect below tell a history navigation apart from the lagging echo of its own debounced write.+ const lastWrittenQuery = React.useRef(queryInput);+const [disabledSet, setDisabledSet] = React.useState<Set<string>>(new Set());const [hasHydratedInitialSettings, setHasHydratedInitialSettings] =React.useState(false);- const [searchQuery, setSearchQuery] = React.useState("");- const [typeFilter, setTypeFilter] = React.useState<SkillTypeFilter>("all");const [selectedSkill, setSelectedSkill] = React.useState<SkillInfo | null>(null,);const [showAddSkillModal, setShowAddSkillModal] = React.useState(false);+ const [isFiltersModalOpen, setIsFiltersModalOpen] = React.useState(false);++ const isLoading = settingsLoading || skillsLoading || !settings;+ const allSkills = skills ?? [];++ const filter = React.useMemo<SkillFilterState>(+ () => ({ ...parseSkillFilterState(searchParams), query: queryInput }),+ [searchParams, queryInput],+ );++ const groups = React.useMemo(+ () => buildSkillFacetGroups(allSkills, disabledSet, filter),+ [allSkills, disabledSet, filter],+ );++ const visibleSkills = React.useMemo(+ () => applySkillFilters(allSkills, disabledSet, filter),+ [allSkills, disabledSet, filter],+ );++ const activeFilterCount = countActiveFilters(filter);// Sync local state with server settings when data first arrivesReact.useEffect(() => {@@ -63,18 +88,6 @@ function SkillsSettingsScreen() {setHasHydratedInitialSettings(true);}, [settingsLoading, settings?.disabled_skills]);- const handleToggle = (skillName: string, enabled: boolean) => {- setDisabledSet((prev) => {- const next = new Set(prev);- if (enabled) {- next.delete(skillName);- } else {- next.add(skillName);- }- return next;- });- };-// Auto-save skill toggles once initial settings are loaded.React.useEffect(() => {if (!hasHydratedInitialSettings) return;@@ -89,16 +102,65 @@ function SkillsSettingsScreen() {);}, [disabledSet, hasHydratedInitialSettings, saveSettings, t]);- const isLoading = settingsLoading || skillsLoading || !settings;+ // Back and forward move `q` under a route that stays mounted, so the input has to take the URL's value back or it would keep showing — and debounce back — a query the user has already navigated away from.+ React.useEffect(() => {+ const current = searchParams.get(SKILL_FILTER_QUERY_PARAM) ?? "";+ if (current === lastWrittenQuery.current) return;+ lastWrittenQuery.current = current;+ setQueryInput(current);+ }, [searchParams]);- const filteredSkills = React.useMemo(() => {- if (!skills) return [];- return skills.filter(- (skill) =>- (typeFilter === "all" || skill.type === typeFilter) &&- matchesSearch(skill, searchQuery),- );- }, [skills, typeFilter, searchQuery]);+ // The search input owns its value and the URL only mirrors it, debounced: writing on every keystroke would push a history entry per character, and reading `q` back out mid-typing would bounce a stale value into the input.+ React.useEffect(() => {+ const current = searchParams.get(SKILL_FILTER_QUERY_PARAM) ?? "";+ if (current === queryInput) return undefined;++ const timeout = setTimeout(() => {+ lastWrittenQuery.current = queryInput;+ setSearchParams(+ (previous) => {+ const next = new URLSearchParams(previous);+ if (queryInput) {+ next.set(SKILL_FILTER_QUERY_PARAM, queryInput);+ } else {+ next.delete(SKILL_FILTER_QUERY_PARAM);+ }+ return next;+ },+ { replace: true },+ );+ }, SEARCH_URL_SYNC_DELAY_MS);++ return () => clearTimeout(timeout);+ }, [queryInput, searchParams, setSearchParams]);++ const handleFilterChange = (next: SkillFilterState) => {+ if (next.query !== filter.query) setQueryInput(next.query);++ // Compare facets only, so a pure query change does not bypass the debounce.+ const facetsChanged =+ toSkillFilterSearchParams({ ...next, query: "" }).toString() !==+ toSkillFilterSearchParams({ ...filter, query: "" }).toString();+ if (facetsChanged) setSearchParams(toSkillFilterSearchParams(next));+ };++ const handleToggleFacet = (groupId: SkillFacetGroupId, value: string) =>+ handleFilterChange(toggleSkillFilterValue(filter, groupId, value));++ const handleClearFacets = () =>+ handleFilterChange(clearSkillFilterFacets(filter));++ const handleToggle = (skillName: string, enabled: boolean) => {+ setDisabledSet((prev) => {+ const next = new Set(prev);+ if (enabled) {+ next.delete(skillName);+ } else {+ next.add(skillName);+ }+ return next;+ });+ };return (<div@@ -107,7 +169,10 @@ function SkillsSettingsScreen() {><ExtensionsNavigation /><main className={cn(settingsLikeMainScrollClassName, "h-full")}>- <div className="mx-auto flex w-full min-w-0 max-w-[800px] flex-col gap-6">+ <div+ data-testid="skills-page"+ className="mx-auto flex w-full min-w-0 max-w-[1100px] flex-col gap-6"+ ><div className="flex min-w-0 items-start justify-between gap-4"><div className="min-w-0 space-y-1"><h2 className="text-xl font-semibold leading-6 text-foreground">@@ -131,7 +196,7 @@ function SkillsSettingsScreen() {</BrandButton></div>- {isLoading && (+ {isLoading ? (<div className="flex flex-col gap-4">{[1, 2, 3].map((i) => (<div@@ -140,9 +205,9 @@ function SkillsSettingsScreen() {/>))}</div>- )}+ ) : null}- {!isLoading && (!skills || skills.length === 0) && (+ {!isLoading && allSkills.length === 0 ? (<divdata-testid="skills-empty"className={extensionModuleEmptyStateClassName}@@ -151,63 +216,101 @@ function SkillsSettingsScreen() {{t(I18nKey.SETTINGS$SKILLS_NO_SKILLS)}</p></div>- )}+ ) : null}- {!isLoading && skills && skills.length > 0 && (+ {!isLoading && allSkills.length > 0 ? (<><SkillsToolbar- search={searchQuery}- onSearchChange={setSearchQuery}- typeFilter={typeFilter}- onTypeFilterChange={setTypeFilter}+ search={filter.query}+ onSearchChange={(query) =>+ handleFilterChange({ ...filter, query })+ }+ activeFilterCount={activeFilterCount}+ onOpenFilters={() => setIsFiltersModalOpen(true)}/>- {filteredSkills.length === 0 ? (- <div- data-testid="skills-no-match"- className={extensionModuleEmptyStateClassName}- >- <p className="text-sm text-tertiary-light">- {t(I18nKey.SETTINGS$SKILLS_NO_MATCH)}- </p>- </div>- ) : (- <section- className={cn(- "flex min-w-0 flex-col gap-3",- extensionModuleCardGridContainerClassName,- )}- >- <div className={extensionModuleCardGridClassName}>- {filteredSkills.map((skill) => (- <SkillCard- key={skill.name}- skill={skill}- enabled={!disabledSet.has(skill.name)}- onOpen={() => setSelectedSkill(skill)}- onToggle={(enabled) =>- handleToggle(skill.name, enabled)- }- />- ))}++ <div className="flex min-w-0 gap-6">+ <SkillFacetRail+ groups={groups}+ onToggle={handleToggleFacet}+ className="hidden w-[240px] shrink-0 self-start md:flex"+ />++ <section className="flex min-w-0 flex-1 flex-col gap-3">+ <div className="flex items-center justify-between gap-3 text-xs text-tertiary-light">+ <span data-testid="skills-result-summary">+ {t(I18nKey.SETTINGS$SKILLS_RESULT_COUNT, {+ count: visibleSkills.length,+ })}+ </span>+ {activeFilterCount > 0 ? (+ <button+ type="button"+ data-testid="skills-clear-filters"+ onClick={handleClearFacets}+ className="cursor-pointer underline hover:text-white"+ >+ {t(I18nKey.SETTINGS$SKILLS_CLEAR_FILTERS)}+ </button>+ ) : null}</div>++ {visibleSkills.length === 0 ? (+ <div+ data-testid="skills-no-match"+ className={extensionModuleEmptyStateClassName}+ >+ <p className="text-sm text-tertiary-light">+ {t(I18nKey.SETTINGS$SKILLS_NO_MATCH)}+ </p>+ </div>+ ) : (+ <div+ className={cn(extensionModuleCardGridContainerClassName)}+ >+ <div className={extensionModuleCardGridClassName}>+ {visibleSkills.map((skill) => (+ <SkillCard+ key={skill.name}+ skill={skill}+ enabled={!disabledSet.has(skill.name)}+ onOpen={() => setSelectedSkill(skill)}+ onToggle={(enabled) =>+ handleToggle(skill.name, enabled)+ }+ />+ ))}+ </div>+ </div>+ )}</section>- )}+ </div>++ {isFiltersModalOpen ? (+ <SkillFiltersModal+ groups={groups}+ activeCount={activeFilterCount}+ onToggle={handleToggleFacet}+ onClearAll={handleClearFacets}+ onClose={() => setIsFiltersModalOpen(false)}+ />+ ) : null}</>- )}-- {selectedSkill && (- <SkillDetailModal- skill={selectedSkill}- enabled={!disabledSet.has(selectedSkill.name)}- onToggle={(enabled) => handleToggle(selectedSkill.name, enabled)}- onClose={() => setSelectedSkill(null)}- />- )}-- {showAddSkillModal && (- <AddSkillModal onClose={() => setShowAddSkillModal(false)} />- )}+ ) : null}</div>++ {selectedSkill && (+ <SkillDetailModal+ skill={selectedSkill}+ enabled={!disabledSet.has(selectedSkill.name)}+ onToggle={(enabled) => handleToggle(selectedSkill.name, enabled)}+ onClose={() => setSelectedSkill(null)}+ />+ )}++ {showAddSkillModal && (+ <AddSkillModal onClose={() => setShowAddSkillModal(false)} />+ )}</main></div>);diff --git a/src/types/settings.ts b/src/types/settings.tsindex cd761712f1..286829f6ee 100644--- a/src/types/settings.ts+++ b/src/types/settings.ts@@ -1,3 +1,4 @@+import type { SkillCategoryId } from "@openhands/extensions/skills";import type { MCPAuthCredential } from "./mcp-auth";export const ProviderOptions = {@@ -106,6 +107,11 @@ export type SkillInfo = {source: string | null;description?: string | null;triggers?: string[];+ /**+ * Topical category from the bundled `@openhands/extensions` catalog.+ * Always absent for user/project skills: the agent-server's `/api/skills` response drops SKILL.md frontmatter metadata, so a local `category` cannot reach us.+ */+ category?: SkillCategoryId | null;version?: string;license?: string | null;compatibility?: string | null;diff --git a/src/utils/settings-like-page-layout-classes.ts b/src/utils/settings-like-page-layout-classes.tsindex a313ec0367..cfb68f418d 100644--- a/src/utils/settings-like-page-layout-classes.ts+++ b/src/utils/settings-like-page-layout-classes.ts@@ -2,10 +2,14 @@* Shared layout tokens for /settings/* and extensions pages (/skills, /mcp,* /plugins) so mobile gets horizontal inset while desktop keeps the aside +* `gap-10` + right gutter pattern.+ *+ * `scrollbar-gutter: stable` keeps the gutter reserved when the page stops+ * overflowing. Without it, filtering a list short enough to fit drops the+ * scrollbar and the centered content jumps sideways into the freed space.*/export const settingsLikeMainScrollClassName =- "flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden overflow-y-auto custom-scrollbar-always px-4 pt-8 pb-12 md:px-0 md:pr-[14px]";+ "flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden overflow-y-auto [scrollbar-gutter:stable] custom-scrollbar-always px-4 pt-8 pb-12 md:px-0 md:pr-[14px]";/** Same scroll shell as {@link settingsLikeMainScrollClassName} but desktop top padding comes from the outer `md:pt-8` wrapper ({@link SettingsLayout}). */export const settingsLayoutMainScrollClassName =- "flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden overflow-y-auto custom-scrollbar-always px-4 pt-8 pb-12 md:px-0 md:pt-0 md:pr-[14px]";+ "flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden overflow-y-auto [scrollbar-gutter:stable] custom-scrollbar-always px-4 pt-8 pb-12 md:px-0 md:pt-0 md:pr-[14px]";diff --git a/src/utils/skill-category.ts b/src/utils/skill-category.tsnew file mode 100644index 0000000000..afb61baed7--- /dev/null+++ b/src/utils/skill-category.ts@@ -0,0 +1,69 @@+import {+ Bot,+ GitPullRequest,+ Package,+ Palette,+ PenLine,+ Plug,+ ShieldCheck,+ Workflow,+ Wrench,+ type LucideIcon,+} from "lucide-react";+import {+ SKILL_CATEGORY_IDS,+ type SkillCategoryId,+} from "@openhands/extensions/skills";+import { I18nKey } from "#/i18n/declaration";+import type { SkillInfo } from "#/types/settings";++/** Display order in the facet rail. `other` last. */+export const SKILL_CATEGORY_ORDER: readonly SkillCategoryId[] = [+ "automations",+ "environment",+ "code-hosting",+ "agent-authoring",+ "code-quality",+ "integrations",+ "writing",+ "design",+ "other",+];++export const SKILL_CATEGORY_LABEL_KEYS: Record<SkillCategoryId, I18nKey> = {+ automations: I18nKey.SETTINGS$SKILLS_CATEGORY_AUTOMATIONS,+ environment: I18nKey.SETTINGS$SKILLS_CATEGORY_ENVIRONMENT,+ "code-hosting": I18nKey.SETTINGS$SKILLS_CATEGORY_CODE_HOSTING,+ "agent-authoring": I18nKey.SETTINGS$SKILLS_CATEGORY_AGENT_AUTHORING,+ "code-quality": I18nKey.SETTINGS$SKILLS_CATEGORY_CODE_QUALITY,+ integrations: I18nKey.SETTINGS$SKILLS_CATEGORY_INTEGRATIONS,+ writing: I18nKey.SETTINGS$SKILLS_CATEGORY_WRITING,+ design: I18nKey.SETTINGS$SKILLS_CATEGORY_DESIGN,+ other: I18nKey.SETTINGS$SKILLS_CATEGORY_OTHER,+};++export const SKILL_CATEGORY_ICONS: Record<SkillCategoryId, LucideIcon> = {+ automations: Workflow,+ environment: Wrench,+ "code-hosting": GitPullRequest,+ "agent-authoring": Bot,+ "code-quality": ShieldCheck,+ integrations: Plug,+ writing: PenLine,+ design: Palette,+ other: Package,+};++/** The catalog uses `other` for a skill with no marketplace entry, so it means "uncategorized" there exactly as it does for a local skill. */+export const UNCATEGORIZED_SKILL_CATEGORY: SkillCategoryId = "other";++const KNOWN_CATEGORIES = new Set<string>(SKILL_CATEGORY_IDS);++/** Local skills carry no category and a stale bundled catalog could carry one this build does not know; both degrade to `other` rather than an unrenderable facet value. */+export function getSkillCategory(skill: SkillInfo): SkillCategoryId {+ const raw = skill.category;+ if (raw && KNOWN_CATEGORIES.has(raw)) {+ return raw;+ }+ return UNCATEGORIZED_SKILL_CATEGORY;+}