Skip to content

πŸ™Œ OpenHands: AI-Driven Development

fix: always load public skills on global Skills page (#263)

Hiep Le4683fa90ae3c
diff --git a/__tests__/api/skills-service.test.ts b/__tests__/api/skills-service.test.ts
new file mode 100644
index 0000000000..f2f8da1759
--- /dev/null
+++ b/__tests__/api/skills-service.test.ts
@@ -0,0 +1,76 @@
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
+import {
+ __resetActiveStoreForTests,
+ setActiveSelection,
+ setRegisteredBackends,
+} from "#/api/backend-registry/active-store";
+import type { Backend } from "#/api/backend-registry/types";
+import SkillsService from "#/api/skills-service";
+
+const { mockGetSkills, mockCreateSkillsClient } = vi.hoisted(() => ({
+ mockGetSkills: vi.fn(),
+ mockCreateSkillsClient: vi.fn(),
+}));
+
+vi.mock("#/api/typescript-client", () => ({
+ createSkillsClient: mockCreateSkillsClient,
+}));
+
+const localBackend: Backend = {
+ id: "local",
+ name: "Local",
+ host: "http://127.0.0.1:8000",
+ apiKey: "",
+ kind: "local",
+};
+
+beforeEach(() => {
+ window.localStorage.clear();
+ __resetActiveStoreForTests();
+ setRegisteredBackends([localBackend]);
+ setActiveSelection({ backendId: localBackend.id });
+ mockGetSkills.mockReset();
+ mockCreateSkillsClient.mockReset();
+ mockCreateSkillsClient.mockReturnValue({ getSkills: mockGetSkills });
+});
+
+afterEach(() => {
+ vi.unstubAllEnvs();
+ __resetActiveStoreForTests();
+});
+
+describe("SkillsService.getSkills against the agent-server backend", () => {
+ it("requests load_public:true for the global Skills page even when VITE_LOAD_PUBLIC_SKILLS is unset, so a fresh dev env still shows the public catalog", async () => {
+ // Arrange: the dev-default scenario that shipped the empty Skills page β€”
+ // VITE_LOAD_PUBLIC_SKILLS is not set, so shouldLoadPublicSkills() would
+ // return false. The agent-server has one public skill it can return.
+ vi.stubEnv("VITE_LOAD_PUBLIC_SKILLS", "");
+ mockGetSkills.mockResolvedValue({
+ skills: [
+ {
+ name: "alpha",
+ type: "knowledge",
+ content: "...",
+ triggers: [],
+ source: "public",
+ is_agentskills_format: false,
+ },
+ ],
+ sources: { sandbox: 0, sdk_base: 1, org: 0, project: 0 },
+ });
+
+ // Act
+ const skills = await SkillsService.getSkills();
+
+ // Assert: the request opts the user into public skills regardless of the
+ // perf-oriented VITE_LOAD_PUBLIC_SKILLS gate, and the page receives them.
+ expect(mockGetSkills).toHaveBeenCalledTimes(1);
+ expect(mockGetSkills.mock.calls[0]?.[0]).toMatchObject({
+ load_public: true,
+ load_user: true,
+ load_project: true,
+ load_org: false,
+ });
+ expect(skills.map((s) => s.name)).toEqual(["alpha"]);
+ });
+});
diff --git a/src/api/skills-service.ts b/src/api/skills-service.ts
index c7d2c13b47..4f89e044a1 100644
--- a/src/api/skills-service.ts
+++ b/src/api/skills-service.ts
@@ -1,8 +1,5 @@
import { SkillInfo } from "#/types/settings";
-import {
- getAgentServerWorkingDir,
- shouldLoadPublicSkills,
-} from "./agent-server-config";
+import { getAgentServerWorkingDir } from "./agent-server-config";
import { getActiveBackend } from "./backend-registry/active-store";
import { fetchCloudSkills } from "./cloud/skills-service.api";
import { createSkillsClient } from "./typescript-client";
@@ -13,8 +10,12 @@ class SkillsService {
return fetchCloudSkills();
}
+ // Always load public skills on the global Skills settings page so the user
+ // sees the available catalog even on a fresh dev environment with no local
+ // user/project skills. Conversation creation paths still gate on
+ // shouldLoadPublicSkills() to keep new-conversation latency low.
const response = await createSkillsClient().getSkills({
- load_public: shouldLoadPublicSkills(),
+ load_public: true,
load_user: true,
load_project: true,
load_org: false,