Files
openchamber/packages/ui/src/stores/skillVisibility.test.ts
T
Bohdan Triapitsyn f4743ea060 feat(chat): work-status panel, and MCP auth and settings fixes (#2776)
Adds a work-status panel beside the transcript. Context fill, model and
cost, todos, running subagents and the permission requests blocking
them, branch and working-tree state, MCP servers, pinned messages and
context sources were scattered across the header, the composer and the
context panel — a blocked subagent was reported nowhere at all. The
panel reads them from live channels rather than persisted history, and
becomes an overlay where the chat is too narrow to seat a column.

It is on by default, including for existing installs. Because it now
carries these readouts, the desktop header and composer drop the ones it
duplicates: todo and changed-files chips, usage and MCP tabs. VS Code
and mobile keep theirs — neither hosts the panel.

Fixes MCP authorization, which was broken from the panel, invalidated by
a directory switch through a redirect URI that encoded the working
directory, and left the desktop app in the background because browsers
will not follow a custom-protocol link without a user gesture. The
settings page no longer asks the user to understand the MCP spec before
adding a server: one field takes the command or the link, with the kind
inferred and a visible override, and client-registration fields appear
only when a server actually asks for its own credentials.

Also: skills load from the panel instead of only when the composer's
slash autocomplete opens; the header button names the current instance
rather than falling through to the word "Instance" for relay hosts.

Three new optional UI settings keys, all migrated. No change to stored
MCP server configuration.
2026-08-09 19:30:25 +03:00

76 lines
3.3 KiB
TypeScript

import { describe, expect, test } from 'bun:test';
import { filterSkillsByRuntimeFlags, resolveSkillRoot } from './skillVisibility';
const skill = (name: string, path: string) => ({ name, path });
const AGENTS = (name: string) => skill(name, `/repo/.agents/skills/${name}/SKILL.md`);
const CLAUDE = (name: string) => skill(name, `/repo/.claude/skills/${name}/SKILL.md`);
const OPENCODE = (name: string) => skill(name, `/home/u/.config/opencode/skill/${name}/SKILL.md`);
const ENABLED = { claudeDisabled: false, allDisabled: false };
describe('resolveSkillRoot', () => {
test('classifies the external roots and everything else', () => {
expect(resolveSkillRoot('/repo/.claude/skills/a/SKILL.md')).toBe('claude');
expect(resolveSkillRoot('/repo/.agents/skills/a/SKILL.md')).toBe('agents');
expect(resolveSkillRoot('/repo/.opencode/skills/a/SKILL.md')).toBe('opencode');
expect(resolveSkillRoot('/home/u/.config/opencode/skill/a/SKILL.md')).toBe('opencode');
});
test('does not match a directory that merely contains the name', () => {
expect(resolveSkillRoot('/repo/my.claude.backup/skills/a/SKILL.md')).toBe('opencode');
});
});
describe('filterSkillsByRuntimeFlags', () => {
test('passes everything through when the server reported no flags', () => {
// An older server or a failed read must not hide skills that do work.
const skills = [AGENTS('a'), CLAUDE('b'), OPENCODE('c')];
expect(filterSkillsByRuntimeFlags(skills, null)).toHaveLength(3);
});
test('keeps every root when nothing is disabled', () => {
const result = filterSkillsByRuntimeFlags([AGENTS('a'), CLAUDE('b'), OPENCODE('c')], ENABLED);
expect(result.map((s) => s.name).sort()).toEqual(['a', 'b', 'c']);
});
test('drops .claude but keeps .agents when claude skills are disabled', () => {
// The specific flag governs `.claude` alone; `.agents` is always scanned.
const result = filterSkillsByRuntimeFlags(
[AGENTS('a'), CLAUDE('b'), OPENCODE('c')],
{ claudeDisabled: true, allDisabled: false },
);
expect(result.map((s) => s.name).sort()).toEqual(['a', 'c']);
});
test('drops both external roots when external skills are disabled', () => {
const result = filterSkillsByRuntimeFlags(
[AGENTS('a'), CLAUDE('b'), OPENCODE('c')],
{ claudeDisabled: false, allDisabled: true },
);
expect(result.map((s) => s.name)).toEqual(['c']);
});
test('prefers the .agents copy when a name exists in both roots', () => {
// `.claude/skills` entries are commonly symlinks into `.agents/skills`;
// OpenCode scans `.agents` last, so it wins the collision.
const result = filterSkillsByRuntimeFlags([CLAUDE('dup'), AGENTS('dup')], ENABLED);
expect(result).toHaveLength(1);
expect(result[0].path).toContain('.agents');
});
test('keeps the single surviving copy of a duplicated name when .claude is disabled', () => {
const result = filterSkillsByRuntimeFlags(
[CLAUDE('dup'), AGENTS('dup')],
{ claudeDisabled: true, allDisabled: false },
);
expect(result).toHaveLength(1);
expect(result[0].path).toContain('.agents');
});
test('does not let dedup drop a name that only exists under .claude', () => {
const result = filterSkillsByRuntimeFlags([CLAUDE('only-claude'), AGENTS('other')], ENABLED);
expect(result.map((s) => s.name).sort()).toEqual(['only-claude', 'other']);
});
});