Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Studio: Skills pill stays with every skill unticked; its X or the + menu turns Skills off (#13687)

Michael Han61d17ec5fb41
diff --git a/studio/frontend/src/components/assistant-ui/thread.tsx b/studio/frontend/src/components/assistant-ui/thread.tsx
index 47e4668b7bb..776b960ddcd 100644
--- a/studio/frontend/src/components/assistant-ui/thread.tsx
+++ b/studio/frontend/src/components/assistant-ui/thread.tsx
@@ -88,7 +88,6 @@ import { WebSearchToolUI } from "@/components/assistant-ui/tool-ui-web-search";
import { ChatDictationBar } from "@/components/assistant-ui/chat-dictation-bar";
import {
ChatAudioUploadMount,
- ChatSkillsDialog,
composerSubmitIntent,
composerFollowUpBehavior,
composerShortcutLabels,
@@ -233,7 +232,10 @@ import {
watchAutoContinueRun,
} from "@/features/chat/utils/auto-continue-run-keeper";
import { McpComposerButton } from "@/features/chat/mcp-composer-button";
-import { SkillsComposerButton } from "@/features/chat/skills-composer-button";
+import {
+ SkillsComposerButton,
+ useSkillsSwitch,
+} from "@/features/chat/skills-composer-button";
import { pickerAcceptForTextBasenames } from "@/features/chat/text-attachment-accept";
import {
COMPOSER_INPUT_SELECTOR,
@@ -5651,6 +5653,8 @@ const Composer: FC<{
);
const queueContextValue: PromptQueueCallbacks = { startQueue, stopQueue };
+ // Skills off sends no read_skill, so a mention would load nothing.
+ const [skillsSwitchOn] = useSkillsSwitch();
const composerContent = (
<>
@@ -5845,7 +5849,7 @@ const Composer: FC<{
<ComposerPrimitive.Unstable_TriggerPopoverRoot>
<SkillMentionPopover
// mentions remain available without Code because each one offers read_skill.
- enabled={supportsTools}
+ enabled={supportsTools && skillsSwitchOn}
composerRef={editorRef}
onConsumesEnterChange={setMentionConsumesEnter}
onOpenChange={setMentionOpen}
@@ -6889,7 +6893,7 @@ const ComposerToolsMenu: FC<{
}, [navigate]);
const [newProjectOpen, setNewProjectOpen] = useState(false);
- const [skillsOpen, setSkillsOpen] = useState(false);
+ const [skillsOn, setSkillsOn] = useSkillsSwitch();
const [promptStorageOpen, setPromptStorageOpen] = useState(false);
const activeThreadId = useChatRuntimeStore((s) => s.activeThreadId);
const aui = useAui();
@@ -7025,9 +7029,15 @@ const ComposerToolsMenu: FC<{
</DropdownMenuItem>
),
skills: (
- <DropdownMenuItem onSelect={() => setSkillsOpen(true)}>
+ <DropdownMenuItem
+ className={skillsOn ? "text-primary font-medium" : undefined}
+ onSelect={() => setSkillsOn(!skillsOn)}
+ >
<HugeiconsIcon icon={Scroll01Icon} strokeWidth={2} />
Skills
+ {skillsOn ? (
+ <HugeiconsIcon icon={Tick02Icon} strokeWidth={2} className="ml-auto" />
+ ) : null}
</DropdownMenuItem>
),
savedPrompts: (
@@ -7168,7 +7178,6 @@ const ComposerToolsMenu: FC<{
return (
<>
- <ChatSkillsDialog open={skillsOpen} onOpenChange={setSkillsOpen} />
<PromptStorageDialog
open={promptStorageOpen}
onOpenChange={setPromptStorageOpen}
diff --git a/studio/frontend/src/features/chat/api/chat-adapter.ts b/studio/frontend/src/features/chat/api/chat-adapter.ts
index d06fb0f7453..013a58a90ff 100644
--- a/studio/frontend/src/features/chat/api/chat-adapter.ts
+++ b/studio/frontend/src/features/chat/api/chat-adapter.ts
@@ -52,6 +52,9 @@ import { resolveSpeculativeType } from "@/lib/speculative-modes";
import { getSkillsSnapshot, settleSkillsForText } from "./skills-api";
+const skillsForTools = () =>
+ useSkillsSwitchStore.getState().on === false ? [] : getSkillsSnapshot().skills;
+
function messageText(content: unknown): string {
if (typeof content === "string") return content;
if (!Array.isArray(content)) return "";
@@ -262,6 +265,7 @@ import {
} from "../provider-capabilities";
import { selectCodeToolNames } from "./code-tool-placement";
import { skillToolNames } from "./skill-tools";
+import { useSkillsSwitchStore } from "../stores/skills-switch-store";
import { ragScopeContextLength } from "./rag-context-length";
import {
type PendingImageEditReference,
@@ -2303,7 +2307,7 @@ export async function buildLocalTokenCountExtras(
// re-fetch for every counted user turn so skills created since page load match request pricing.
await settleSkillsForText(userTexts(messages).join("\n"));
const skillTools = skillToolNames(
- getSkillsSnapshot().skills,
+ skillsForTools(),
codeToolsEnabled,
userTexts(messages),
);
@@ -6679,7 +6683,7 @@ export function createOpenAIStreamAdapter(
await settleSkillsForText(userTexts(outboundMessages).join("\n"));
}
const skillTools = skillToolNames(
- getSkillsSnapshot().skills,
+ skillsForTools(),
codeToolsEnabled,
userTexts(outboundMessages),
);
diff --git a/studio/frontend/src/features/chat/api/skills-api.ts b/studio/frontend/src/features/chat/api/skills-api.ts
index 9dc02dcfdac..b5eefcc7e02 100644
--- a/studio/frontend/src/features/chat/api/skills-api.ts
+++ b/studio/frontend/src/features/chat/api/skills-api.ts
@@ -4,6 +4,7 @@
import { authFetch } from "@/features/auth";
import { AUTH_SESSION_CLEARED_EVENT } from "@/features/auth/session";
import { useEffect, useSyncExternalStore } from "react";
+import { useSkillsSwitchStore } from "../stores/skills-switch-store";
import { refreshContextUsage } from "../utils/refresh-context-usage";
import { SKILL_MENTION_PATTERN } from "./skill-tools";
@@ -126,10 +127,24 @@ export function listSkills(force = false): Promise<readonly SkillRecord[]> {
return request;
}
+// Pin an unset switch first, or unticking the last skill would read as Skills off.
+function pinSkillsSwitch(): void {
+ const { on, setOn } = useSkillsSwitchStore.getState();
+ if (on !== null) {
+ return;
+ }
+ setOn(
+ snapshot.skills.some(
+ (skill) => skill.valid && !skill.shadowed && skill.enabled,
+ ),
+ );
+}
+
export async function setSkillEnabled(
name: string,
enabled: boolean,
): Promise<SkillRecord> {
+ pinSkillsSwitch();
const response = await authFetch(
`/api/skills/${encodeURIComponent(name)}/enabled`,
{
@@ -152,6 +167,9 @@ export async function setSkillEnabled(
});
channel?.postMessage("changed");
void refreshContextUsage({ invalidate: true });
+ if (updated.enabled) {
+ useSkillsSwitchStore.getState().setOn(true);
+ }
return updated;
}
@@ -159,6 +177,7 @@ export async function setSkillEnabled(
export async function setAllSkillsEnabled(
enabled: boolean | null,
): Promise<readonly SkillRecord[]> {
+ pinSkillsSwitch();
const epoch = sessionEpoch;
const response = await authFetch("/api/skills", {
method: "PUT",
@@ -173,6 +192,10 @@ export async function setAllSkillsEnabled(
publish({ skills, loading: false, initialized: true, error: null });
channel?.postMessage("changed");
void refreshContextUsage({ invalidate: true });
+ // Reset to defaults (null) unsets it again.
+ if (enabled !== false) {
+ useSkillsSwitchStore.getState().setOn(enabled);
+ }
return skills;
}
@@ -219,6 +242,7 @@ export async function updateSkill(
}
export async function deleteSkill(name: string): Promise<void> {
+ pinSkillsSwitch();
const response = await authFetch(`/api/skills/${encodeURIComponent(name)}`, {
method: "DELETE",
});
diff --git a/studio/frontend/src/features/chat/shared-composer.tsx b/studio/frontend/src/features/chat/shared-composer.tsx
index e828add7d77..a747a107493 100644
--- a/studio/frontend/src/features/chat/shared-composer.tsx
+++ b/studio/frontend/src/features/chat/shared-composer.tsx
@@ -140,13 +140,12 @@ import {
} from "./api/prompts-api";
import { PromptCountBadge } from "./prompt-storage/prompt-count-badge";
import { McpComposerButton } from "./mcp-composer-button";
-import { SkillsComposerButton } from "./skills-composer-button";
+import { SkillsComposerButton, useSkillsSwitch } from "./skills-composer-button";
import { PermissionModeComposerPill } from "./permission-mode-select";
import { reasoningCapsFromLoad } from "./lib/apply-inference-status-to-store";
import { resyncInferenceStatusAfterServerModelChange } from "./hooks/use-chat-model-runtime";
import { KnowledgeBaseComposerButton } from "@/features/rag/components/knowledge-base-composer-button";
import { NewProjectDialog } from "./components/new-project-dialog";
-import { ChatSkillsDialog } from "./components/chat-skills-dialog";
import { ChatAudioUploadMount } from "./components/chat-audio-upload-mount";
import { useChatProjects } from "./hooks/use-chat-projects";
import { useChatAudioUpload } from "./hooks/use-chat-audio-upload";
@@ -680,7 +679,7 @@ export function SharedComposer({
const [dragging, setDragging] = useState(false);
const [isComposing, setIsComposing] = useState(false);
const [newProjectOpen, setNewProjectOpen] = useState(false);
- const [skillsOpen, setSkillsOpen] = useState(false);
+ const [skillsOn, setSkillsOn] = useSkillsSwitch();
const [promptStorageOpen, setPromptStorageOpen] = useState(false);
const [recentPrompts, setRecentPrompts] = useState<PromptEntry[]>([]);
const [recentLists, setRecentLists] = useState<PromptListEntry[]>([]);
@@ -784,6 +783,7 @@ export function SharedComposer({
const preserveThinking = useChatRuntimeStore((s) => s.preserveThinking);
const setPreserveThinking = useChatRuntimeStore((s) => s.setPreserveThinking);
const supportsTools = useChatRuntimeStore((s) => s.supportsTools);
+ const [skillsSwitchOn] = useSkillsSwitch();
const mentionOpenRef = useRef(false);
const skillMentions = useTextareaSkillMentions({
@@ -791,7 +791,7 @@ export function SharedComposer({
setText: setCurrentText,
inputRef: textareaRef,
composingRef,
- enabled: supportsTools,
+ enabled: supportsTools && skillsSwitchOn,
});
mentionOpenRef.current = skillMentions.inputProps["aria-expanded"];
const supportsBuiltinWebSearch = useChatRuntimeStore(
@@ -2578,9 +2578,15 @@ export function SharedComposer({
</DropdownMenuItem>
),
skills: (
- <DropdownMenuItem onSelect={() => setSkillsOpen(true)}>
+ <DropdownMenuItem
+ className={skillsOn ? "text-primary font-medium" : undefined}
+ onSelect={() => setSkillsOn(!skillsOn)}
+ >
<HugeiconsIcon icon={Scroll01Icon} strokeWidth={2} />
Skills
+ {skillsOn ? (
+ <HugeiconsIcon icon={MenuTickIcon} strokeWidth={2} className="ml-auto" />
+ ) : null}
</DropdownMenuItem>
),
savedPrompts: (
@@ -2715,7 +2721,6 @@ export function SharedComposer({
{...{ [FIND_SKIP_ATTRIBUTE]: "" }}
data-writing-expanded={isWritingExpanded ? "true" : undefined}
>
- <ChatSkillsDialog open={skillsOpen} onOpenChange={setSkillsOpen} />
<ChatAudioUploadMount audioUpload={audioUpload} />
<PromptStorageDialog
diff --git a/studio/frontend/src/features/chat/skills-composer-button.tsx b/studio/frontend/src/features/chat/skills-composer-button.tsx
index fff8883e8b3..05efbe610b0 100644
--- a/studio/frontend/src/features/chat/skills-composer-button.tsx
+++ b/studio/frontend/src/features/chat/skills-composer-button.tsx
@@ -3,7 +3,7 @@
import { Scroll01Icon } from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
-import { ChevronDownIcon } from "lucide-react";
+import { ChevronDownIcon, XIcon } from "lucide-react";
import { useState } from "react";
import { toast } from "sonner";
@@ -24,8 +24,19 @@ import {
useSkillsCatalog,
} from "./api/skills-api";
import { ChatSkillsDialog } from "./components/chat-skills-dialog";
+import { skillsSwitchedOn, useSkillsSwitchStore } from "./stores/skills-switch-store";
-/** Composer pill for the enabled skills, shown once any is on. Toggles them in place. */
+export function useSkillsSwitch(): [boolean, (on: boolean) => void] {
+ const { skills } = useSkillsCatalog();
+ const on = useSkillsSwitchStore((s) => s.on);
+ const setOn = useSkillsSwitchStore((s) => s.setOn);
+ const enabledCount = skills.filter(
+ (skill) => skill.valid && !skill.shadowed && skill.enabled,
+ ).length;
+ return [skillsSwitchedOn(on, enabledCount), setOn];
+}
+
+/** Composer pill for skills, shown while the Skills switch is on. Toggles them in place. */
export function SkillsComposerButton({
side = "bottom",
}: {
@@ -36,6 +47,7 @@ export function SkillsComposerButton({
const [menuOpen, setMenuOpen] = useState(false);
const [dialogOpen, setDialogOpen] = useState(false);
const [pending, setPending] = useState<ReadonlySet<string>>(() => new Set());
+ const [skillsOn, setSkillsOn] = useSkillsSwitch();
// Runnable skills only: shadowed or invalid ones stay in Manage skills.
const usable = skills.filter((skill) => skill.valid && !skill.shadowed);
@@ -61,8 +73,8 @@ export function SkillsComposerButton({
return (
<>
- {/* Stays while open, so turning off the last skill does not close it. */}
- {enabledCount > 0 || menuOpen ? (
+ {/* Stays with every skill unticked: only its X or the + menu turns Skills off. */}
+ {skillsOn || menuOpen ? (
<DropdownMenu
open={menuOpen}
onOpenChange={(open) => {
@@ -78,12 +90,32 @@ export function SkillsComposerButton({
data-active={enabledCount > 0 ? "true" : "false"}
aria-label={t("skills.title")}
>
- <span className="composer-pill-glyph">
+ {/* Outside compact mode, the hover X turns Skills off without opening the menu. */}
+ <span
+ role="button"
+ aria-label={t("skills.turnOff")}
+ tabIndex={-1}
+ onPointerDown={(e) => {
+ if (e.currentTarget.closest('[data-pill-compact="true"]')) {
+ return;
+ }
+ e.stopPropagation();
+ }}
+ onClick={(e) => {
+ if (e.currentTarget.closest('[data-pill-compact="true"]')) {
+ return;
+ }
+ e.stopPropagation();
+ setSkillsOn(false);
+ }}
+ className="composer-pill-glyph cursor-pointer"
+ >
<HugeiconsIcon
icon={Scroll01Icon}
className="size-[calc(15px*var(--ui-space-scale,1))]"
strokeWidth={2}
/>
+ <XIcon className="composer-pill-x" />
</span>
<span>{t("skills.title")}</span>
<ChevronDownIcon
diff --git a/studio/frontend/src/features/chat/stores/skills-switch-store.ts b/studio/frontend/src/features/chat/stores/skills-switch-store.ts
new file mode 100644
index 00000000000..8aad7b1ab53
--- /dev/null
+++ b/studio/frontend/src/features/chat/stores/skills-switch-store.ts
@@ -0,0 +1,25 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+import { create } from "zustand";
+import { persist } from "zustand/middleware";
+
+// The composer's Skills switch, apart from which skills are ticked: off hides the pill and sends no
+// skill tools. Unset follows whether any skill is ticked, as before the switch existed.
+interface SkillsSwitchState {
+ on: boolean | null;
+ setOn: (on: boolean | null) => void;
+}
+
+export const useSkillsSwitchStore = create<SkillsSwitchState>()(
+ persist((set) => ({ on: null, setOn: (on) => set({ on }) }), {
+ name: "unsloth_chat_skills_on",
+ }),
+);
+
+export function skillsSwitchedOn(
+ on: boolean | null,
+ enabledCount: number,
+): boolean {
+ return on ?? enabledCount > 0;
+}
diff --git a/studio/frontend/src/i18n/locales/en.ts b/studio/frontend/src/i18n/locales/en.ts
index 47644d917e1..aee301e1b6d 100644
--- a/studio/frontend/src/i18n/locales/en.ts
+++ b/studio/frontend/src/i18n/locales/en.ts
@@ -4018,6 +4018,7 @@ export const en = {
discard: "Discard",
mentions: "Skills",
manage: "Manage skills",
+ turnOff: "Turn off skills",
bulkActions: "Skill actions",
enableAll: "Enable all",
disableAll: "Disable all",
diff --git a/studio/frontend/tests/skill-load-event.test.ts b/studio/frontend/tests/skill-load-event.test.ts
index 3380e97879a..7932947d139 100644
--- a/studio/frontend/tests/skill-load-event.test.ts
+++ b/studio/frontend/tests/skill-load-event.test.ts
@@ -56,7 +56,7 @@ test("legacy and durable streams normalize preload, and history omits UI evidenc
const thread = readSrc("components/assistant-ui/thread.tsx");
assert.match(thread, /studio_load_skill: ReadSkillToolUIConfirmable/);
// read_skill remains available without Code, so the popover depends only on tool support.
- assert.match(thread, /<SkillMentionPopover[\s\S]*?enabled=\{supportsTools\}/);
+ assert.match(thread, /<SkillMentionPopover[\s\S]*?enabled=\{supportsTools && skillsSwitchOn\}/);
const ui = readSrc("components/assistant-ui/tool-ui-read-skill.tsx");
assert.match(ui, /Skill not loaded/);
assert.match(ui, /Loaded \$\{name\}/);
diff --git a/studio/frontend/tests/skills-composer-pill.test.ts b/studio/frontend/tests/skills-composer-pill.test.ts
index 468cfabfa43..a428e8f1c74 100644
--- a/studio/frontend/tests/skills-composer-pill.test.ts
+++ b/studio/frontend/tests/skills-composer-pill.test.ts
@@ -10,9 +10,9 @@ const PILL = await read("../src/features/chat/skills-composer-button.tsx");
const THREAD = await read("../src/components/assistant-ui/thread.tsx");
const SHARED = await read("../src/features/chat/shared-composer.tsx");
-test("the Skills pill shows once a usable skill is on, in both composers", () => {
+test("the Skills pill follows the Skills switch, in both composers", () => {
assert.match(PILL, /skills\.filter\(\(skill\) => skill\.valid && !skill\.shadowed\)/);
- assert.match(PILL, /\{enabledCount > 0 \|\| menuOpen \? \(/);
+ assert.match(PILL, /\{skillsOn \|\| menuOpen \? \(/);
assert.match(THREAD, /<SkillsComposerButton side=\{effectiveMenuSide\} \/>/);
assert.match(SHARED, /<SkillsComposerButton side="top" \/>/);
});
@@ -29,3 +29,35 @@ test("the Skills pill toggles in place and links to the full dialog", () => {
assert.match(PILL, /t\("skills\.manage"\)/);
assert.match(PILL, /<ChatSkillsDialog open=\{dialogOpen\} onOpenChange=\{setDialogOpen\} \/>/);
});
+
+test("unticking every skill keeps the pill; its X and the + menu switch Skills off", async () => {
+ const { skillsSwitchedOn } = await import("../src/features/chat/stores/skills-switch-store.ts");
+ assert.equal(skillsSwitchedOn(null, 0), false);
+ assert.equal(skillsSwitchedOn(null, 2), true);
+ assert.equal(skillsSwitchedOn(true, 0), true);
+ assert.equal(skillsSwitchedOn(false, 2), false);
+ assert.match(PILL, /role="button"[\s\S]*?setSkillsOn\(false\);[\s\S]*?<XIcon className="composer-pill-x" \/>/);
+ for (const source of [THREAD, SHARED]) {
+ assert.match(source, /onSelect=\{\(\) => setSkillsOn\(!skillsOn\)\}/);
+ }
+});
+
+test("Skills switched off sends no skill tools, and ticking a skill switches it back on", async () => {
+ const ADAPTER = await read("../src/features/chat/api/chat-adapter.ts");
+ const API = await read("../src/features/chat/api/skills-api.ts");
+ assert.match(ADAPTER, /useSkillsSwitchStore\.getState\(\)\.on === false \? \[\] : getSkillsSnapshot\(\)\.skills/);
+ assert.match(API, /if \(updated\.enabled\) \{\s*useSkillsSwitchStore\.getState\(\)\.setOn\(true\);/);
+});
+
+test("an unset switch is pinned before a change can untick, delete or bulk-disable the last skill", async () => {
+ const API = await read("../src/features/chat/api/skills-api.ts");
+ for (const fn of ["setSkillEnabled", "setAllSkillsEnabled", "deleteSkill"]) {
+ assert.match(API, new RegExp(`export async function ${fn}\\([\\s\\S]*?\\{\\s*pinSkillsSwitch\\(\\);`));
+ }
+ assert.match(API, /if \(on !== null\) \{\s*return;\s*\}\s*setOn\(\s*snapshot\.skills\.some\(/);
+});
+
+test("skill @mentions are offered only while Skills is on, in both composers", () => {
+ assert.match(THREAD, /<SkillMentionPopover[\s\S]*?enabled=\{supportsTools && skillsSwitchOn\}/);
+ assert.match(SHARED, /useTextareaSkillMentions\(\{[\s\S]*?enabled: supportsTools && skillsSwitchOn,/);
+});
diff --git a/studio/frontend/tests/skills-switch-pin.test.ts b/studio/frontend/tests/skills-switch-pin.test.ts
new file mode 100644
index 00000000000..c151f077ba1
--- /dev/null
+++ b/studio/frontend/tests/skills-switch-pin.test.ts
@@ -0,0 +1,110 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+import assert from "node:assert/strict";
+import test from "node:test";
+import { loadWithStubs } from "./helpers/module-stubs.ts";
+
+// The module opens a channel to other tabs when it can; an open one keeps the test process alive.
+(globalThis as { BroadcastChannel?: unknown }).BroadcastChannel = undefined;
+
+type Skill = {
+ name: string;
+ source: string;
+ valid: boolean;
+ shadowed: boolean;
+ enabled: boolean;
+};
+type Api = {
+ listSkills: (force?: boolean) => Promise<readonly Skill[]>;
+ setSkillEnabled: (name: string, enabled: boolean) => Promise<Skill>;
+ setAllSkillsEnabled: (enabled: boolean | null) => Promise<readonly Skill[]>;
+};
+
+const skill = (name: string, enabled: boolean): Skill => ({
+ name,
+ source: "user",
+ valid: true,
+ shadowed: false,
+ enabled,
+});
+
+function harness(initial: Skill[]) {
+ const sw = { on: null as boolean | null };
+ let server = initial;
+ const respond = (body: unknown) => ({
+ ok: true,
+ status: 200,
+ json: async () => body,
+ });
+ const api = loadWithStubs<Api>(
+ new URL("../src/features/chat/api/skills-api.ts", import.meta.url),
+ {
+ "@/features/auth": {
+ authFetch: async (
+ url: string,
+ init?: { method?: string; body?: string },
+ ) => {
+ const body = init?.body ? JSON.parse(init.body) : null;
+ if (init?.method === "PUT" && url === "/api/skills") {
+ // null restores defaults: user skills on.
+ server = server.map((s) => ({
+ ...s,
+ enabled: body.enabled ?? true,
+ }));
+ return respond(server);
+ }
+ if (init?.method === "PUT") {
+ const name = decodeURIComponent(url.split("/")[3]);
+ server = server.map((s) =>
+ s.name === name ? { ...s, enabled: body.enabled } : s,
+ );
+ return respond(server.find((s) => s.name === name));
+ }
+ return respond(server);
+ },
+ },
+ "@/features/auth/session": { AUTH_SESSION_CLEARED_EVENT: "cleared" },
+ react: { useEffect: () => undefined, useSyncExternalStore: () => null },
+ "../stores/skills-switch-store": {
+ useSkillsSwitchStore: {
+ getState: () => ({
+ on: sw.on,
+ setOn: (on: boolean | null) => {
+ sw.on = on;
+ },
+ }),
+ },
+ },
+ "../utils/refresh-context-usage": {
+ refreshContextUsage: async () => undefined,
+ },
+ "./skill-tools": { SKILL_MENTION_PATTERN: /@x/g },
+ },
+ );
+ return { api, sw };
+}
+
+test("unticking the only ticked skill on an unset switch keeps Skills on", async () => {
+ const { api, sw } = harness([skill("a", true), skill("b", false)]);
+ await api.listSkills(true);
+ await api.setSkillEnabled("a", false);
+ assert.equal(sw.on, true);
+});
+
+test("Reset to defaults returns an unset switch to unset, so the restored ticks show again", async () => {
+ const { api, sw } = harness([skill("a", false), skill("b", false)]);
+ await api.listSkills(true);
+ await api.setAllSkillsEnabled(null);
+ assert.equal(sw.on, null);
+});
+
+test("Disable all keeps Skills on; Enable all turns it on", async () => {
+ const { api, sw } = harness([skill("a", true)]);
+ await api.listSkills(true);
+ await api.setAllSkillsEnabled(false);
+ assert.equal(sw.on, true);
+ sw.on = false;
+ await api.setAllSkillsEnabled(true);
+ assert.equal(sw.on, true);
+});
diff --git a/studio/frontend/tests/skills-token-count-discovery.test.ts b/studio/frontend/tests/skills-token-count-discovery.test.ts
index 720e6164c83..b7163f33624 100644
--- a/studio/frontend/tests/skills-token-count-discovery.test.ts
+++ b/studio/frontend/tests/skills-token-count-discovery.test.ts
@@ -26,7 +26,7 @@ test("token counting waits for the initial skills discovery", () => {
assert.match(CHAT_ADAPTER_SOURCE, /await settleSkillsForText\(userTexts\(messages\)\.join\("\\n"\)\);/);
assert.match(
CHAT_ADAPTER_SOURCE,
- /const skillTools = skillToolNames\(\s*getSkillsSnapshot\(\)\.skills,\s*codeToolsEnabled,\s*userTexts\(messages\),\s*\);/,
+ /const skillTools = skillToolNames\(\s*skillsForTools\(\),\s*codeToolsEnabled,\s*userTexts\(messages\),\s*\);/,
);
});
@@ -63,7 +63,7 @@ test("request building waits for skills and preserves the launcher tool catalog"
);
assert.match(
payloadBuilder,
- /const skillTools = skillToolNames\(\s*getSkillsSnapshot\(\)\.skills,\s*codeToolsEnabled,\s*userTexts\(outboundMessages\),\s*\);/,
+ /const skillTools = skillToolNames\(\s*skillsForTools\(\),\s*codeToolsEnabled,\s*userTexts\(outboundMessages\),\s*\);/,
);
assert.match(
payloadBuilder,