@bevel-software/platform-core-frontend 0.3.2 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/package.json +2 -2
  2. package/src/core/__tests__/ShellRoutes.test.tsx +95 -95
  3. package/src/lib/utils.ts +138 -138
  4. package/src/modules/admin/__tests__/UserAccountsPage.test.tsx +156 -156
  5. package/src/modules/admin/components/UserAccountsPage.tsx +353 -353
  6. package/src/modules/layout/components/MaintenanceOverlay.tsx +104 -104
  7. package/src/modules/library/__tests__/DetailDialog.test.tsx +200 -200
  8. package/src/modules/library/__tests__/loadout.test.tsx +72 -72
  9. package/src/modules/library/__tests__/status.test.ts +117 -117
  10. package/src/modules/library/components/ChangeRequestDock.tsx +47 -47
  11. package/src/modules/library/components/CompareView.tsx +357 -357
  12. package/src/modules/library/components/DetailDialog.tsx +566 -566
  13. package/src/modules/library/components/GearIcon.tsx +12 -12
  14. package/src/modules/library/components/LibraryCard.tsx +132 -132
  15. package/src/modules/library/components/LibraryPage.tsx +254 -254
  16. package/src/modules/library/components/LoadoutSidebar.tsx +156 -156
  17. package/src/modules/library/components/StatusGem.tsx +21 -21
  18. package/src/modules/library/components/SuggestChange.tsx +171 -171
  19. package/src/modules/library/components/particles.ts +50 -50
  20. package/src/modules/library/library.css +320 -320
  21. package/src/modules/library/state/loadout.tsx +129 -129
  22. package/src/modules/library/utils/status.ts +116 -116
  23. package/src/modules/secrets-vault/components/SecretsPage.tsx +276 -276
  24. package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +51 -51
  25. package/src/modules/toolbar/components/AppSwitcher.tsx +108 -108
  26. package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +548 -548
  27. package/src/modules/workspace/components/FileExplorer.tsx +1068 -1068
  28. package/src/modules/workspace/components/FileViewer.tsx +906 -906
  29. package/src/modules/workspace/utils/fileTree.ts +179 -179
  30. package/src/shared/components/PageShell.tsx +51 -51
@@ -1,72 +1,72 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { renderHook, act } from '@testing-library/react';
3
- import type { ReactNode } from 'react';
4
- import { LoadoutProvider, useLoadout, LOADOUT_STORAGE_KEY } from '../state/loadout';
5
-
6
- const wrapper = ({ children }: { children: ReactNode }) => (
7
- <LoadoutProvider>{children}</LoadoutProvider>
8
- );
9
-
10
- describe('loadout (client-side stub)', () => {
11
- it('starts empty and adds/removes on toggle', () => {
12
- const { result } = renderHook(() => useLoadout(), { wrapper });
13
- expect(result.current.total).toBe(0);
14
-
15
- let added = false;
16
- act(() => {
17
- added = result.current.toggle('skill', 'newsletter');
18
- });
19
- expect(added).toBe(true);
20
- expect(result.current.isIn('skill', 'newsletter')).toBe(true);
21
- expect(result.current.total).toBe(1);
22
-
23
- act(() => {
24
- result.current.toggle('integration', 'slack');
25
- });
26
- expect(result.current.total).toBe(2);
27
- expect(result.current.integrations).toEqual(['slack']);
28
-
29
- act(() => {
30
- added = result.current.toggle('skill', 'newsletter');
31
- });
32
- expect(added).toBe(false);
33
- expect(result.current.isIn('skill', 'newsletter')).toBe(false);
34
- expect(result.current.total).toBe(1);
35
- });
36
-
37
- it('remove drops only the targeted item', () => {
38
- const { result } = renderHook(() => useLoadout(), { wrapper });
39
- act(() => {
40
- result.current.toggle('skill', 'a');
41
- result.current.toggle('skill', 'b');
42
- });
43
- act(() => {
44
- result.current.remove('skill', 'a');
45
- });
46
- expect(result.current.skills).toEqual(['b']);
47
- });
48
-
49
- it('persists to localStorage under bevel-library-loadout-v1 and survives a remount', () => {
50
- const first = renderHook(() => useLoadout(), { wrapper });
51
- act(() => {
52
- first.result.current.toggle('skill', 'rfi');
53
- first.result.current.toggle('integration', 'github');
54
- });
55
- const raw = localStorage.getItem(LOADOUT_STORAGE_KEY);
56
- expect(raw).not.toBeNull();
57
- expect(JSON.parse(raw!)).toEqual({ skills: ['rfi'], integrations: ['github'] });
58
- first.unmount();
59
-
60
- // A fresh provider (new session) reads the persisted loadout back.
61
- const second = renderHook(() => useLoadout(), { wrapper });
62
- expect(second.result.current.isIn('skill', 'rfi')).toBe(true);
63
- expect(second.result.current.isIn('integration', 'github')).toBe(true);
64
- expect(second.result.current.total).toBe(2);
65
- });
66
-
67
- it('tolerates corrupted stored state', () => {
68
- localStorage.setItem(LOADOUT_STORAGE_KEY, '{not json');
69
- const { result } = renderHook(() => useLoadout(), { wrapper });
70
- expect(result.current.total).toBe(0);
71
- });
72
- });
1
+ import { describe, it, expect } from 'vitest';
2
+ import { renderHook, act } from '@testing-library/react';
3
+ import type { ReactNode } from 'react';
4
+ import { LoadoutProvider, useLoadout, LOADOUT_STORAGE_KEY } from '../state/loadout';
5
+
6
+ const wrapper = ({ children }: { children: ReactNode }) => (
7
+ <LoadoutProvider>{children}</LoadoutProvider>
8
+ );
9
+
10
+ describe('loadout (client-side stub)', () => {
11
+ it('starts empty and adds/removes on toggle', () => {
12
+ const { result } = renderHook(() => useLoadout(), { wrapper });
13
+ expect(result.current.total).toBe(0);
14
+
15
+ let added = false;
16
+ act(() => {
17
+ added = result.current.toggle('skill', 'newsletter');
18
+ });
19
+ expect(added).toBe(true);
20
+ expect(result.current.isIn('skill', 'newsletter')).toBe(true);
21
+ expect(result.current.total).toBe(1);
22
+
23
+ act(() => {
24
+ result.current.toggle('integration', 'slack');
25
+ });
26
+ expect(result.current.total).toBe(2);
27
+ expect(result.current.integrations).toEqual(['slack']);
28
+
29
+ act(() => {
30
+ added = result.current.toggle('skill', 'newsletter');
31
+ });
32
+ expect(added).toBe(false);
33
+ expect(result.current.isIn('skill', 'newsletter')).toBe(false);
34
+ expect(result.current.total).toBe(1);
35
+ });
36
+
37
+ it('remove drops only the targeted item', () => {
38
+ const { result } = renderHook(() => useLoadout(), { wrapper });
39
+ act(() => {
40
+ result.current.toggle('skill', 'a');
41
+ result.current.toggle('skill', 'b');
42
+ });
43
+ act(() => {
44
+ result.current.remove('skill', 'a');
45
+ });
46
+ expect(result.current.skills).toEqual(['b']);
47
+ });
48
+
49
+ it('persists to localStorage under bevel-library-loadout-v1 and survives a remount', () => {
50
+ const first = renderHook(() => useLoadout(), { wrapper });
51
+ act(() => {
52
+ first.result.current.toggle('skill', 'rfi');
53
+ first.result.current.toggle('integration', 'github');
54
+ });
55
+ const raw = localStorage.getItem(LOADOUT_STORAGE_KEY);
56
+ expect(raw).not.toBeNull();
57
+ expect(JSON.parse(raw!)).toEqual({ skills: ['rfi'], integrations: ['github'] });
58
+ first.unmount();
59
+
60
+ // A fresh provider (new session) reads the persisted loadout back.
61
+ const second = renderHook(() => useLoadout(), { wrapper });
62
+ expect(second.result.current.isIn('skill', 'rfi')).toBe(true);
63
+ expect(second.result.current.isIn('integration', 'github')).toBe(true);
64
+ expect(second.result.current.total).toBe(2);
65
+ });
66
+
67
+ it('tolerates corrupted stored state', () => {
68
+ localStorage.setItem(LOADOUT_STORAGE_KEY, '{not json');
69
+ const { result } = renderHook(() => useLoadout(), { wrapper });
70
+ expect(result.current.total).toBe(0);
71
+ });
72
+ });
@@ -1,117 +1,117 @@
1
- import { describe, it, expect } from 'vitest';
2
- import type { ToolSecrets } from '../../secrets-vault/services/tool-secrets.api';
3
- import {
4
- filterLibraryItems,
5
- neededToolsFor,
6
- skillStatus,
7
- toolStatus,
8
- type LibraryFilterable,
9
- } from '../utils/status';
10
-
11
- function tool(overrides: Partial<ToolSecrets>): ToolSecrets {
12
- return {
13
- slug: 'slack',
14
- name: 'slack',
15
- path: 'Tools/slack.tool',
16
- type: 'http',
17
- setup: null,
18
- canWrite: false,
19
- variables: [],
20
- ...overrides,
21
- };
22
- }
23
-
24
- describe('toolStatus', () => {
25
- it('is ok when every variable is satisfied', () => {
26
- const t = tool({
27
- variables: [
28
- { name: 'API_KEY', scope: 'admin', label: null, key: 'slack_API_KEY', adminConfigured: true, userConfigured: false },
29
- { name: 'TOKEN', scope: 'user', label: null, key: 'slack_TOKEN', adminConfigured: false, userConfigured: true },
30
- ],
31
- });
32
- expect(toolStatus(t).state).toBe('ok');
33
- });
34
-
35
- it('flags a missing user sign-in as warn (oauth) and an expired one as err', () => {
36
- const pending = tool({
37
- variables: [
38
- { name: 'SIGNIN', scope: 'user', label: null, key: 'k', adminConfigured: true, userConfigured: false, oauth: true, authorized: false },
39
- ],
40
- });
41
- expect(toolStatus(pending)).toEqual({ state: 'warn', text: 'Needs your sign-in' });
42
-
43
- const expired = tool({
44
- variables: [
45
- { name: 'SIGNIN', scope: 'user', label: null, key: 'k', adminConfigured: true, userConfigured: true, oauth: true, authorized: true, needsReauth: true },
46
- ],
47
- });
48
- expect(toolStatus(expired).state).toBe('err');
49
- });
50
-
51
- it('flags a missing shared value as off (not set up yet)', () => {
52
- const t = tool({
53
- variables: [
54
- { name: 'API_KEY', scope: 'admin', label: null, key: 'k', adminConfigured: false, userConfigured: false },
55
- ],
56
- });
57
- expect(toolStatus(t)).toEqual({ state: 'off', text: 'Not set up yet' });
58
- expect(toolStatus(tool({ ...t, canWrite: true })).text).toContain('you maintain');
59
- });
60
- });
61
-
62
- describe('neededToolsFor / skillStatus', () => {
63
- const slack = tool({ name: 'slack', slug: 'slack' });
64
- const notion = tool({
65
- name: 'notion',
66
- slug: 'notion',
67
- variables: [
68
- { name: 'SIGNIN', scope: 'user', label: null, key: 'k', adminConfigured: true, userConfigured: false, oauth: true, authorized: false },
69
- ],
70
- });
71
-
72
- it('matches manual-namespaced allowed-tools entries and ignores generic agent tools', () => {
73
- const needed = neededToolsFor({ allowedTools: ['Bash', 'slack_post_message', 'notion.notion_search'] }, [slack, notion]);
74
- expect(needed.map((t) => t.name)).toEqual(['slack', 'notion']);
75
- expect(neededToolsFor({ allowedTools: ['Read', 'Bash'] }, [slack, notion])).toEqual([]);
76
- });
77
-
78
- it('skill is ready only when every needed integration is connected', () => {
79
- expect(skillStatus([slack]).state).toBe('ok');
80
- expect(skillStatus([slack, notion])).toEqual({ state: 'warn', text: 'Needs setup' });
81
- expect(skillStatus([]).state).toBe('ok');
82
- });
83
- });
84
-
85
- describe('filterLibraryItems (category chips + search)', () => {
86
- const items: LibraryFilterable[] = [
87
- { kind: 'skill', name: 'Weekly newsletter', description: 'drafts the Friday newsletter', owned: true },
88
- { kind: 'skill', name: 'RFI responder', description: 'answers requests', owned: false },
89
- { kind: 'integration', name: 'Slack', description: 'messages', owned: false },
90
- { kind: 'integration', name: 'GitHub', description: 'code and change requests', owned: true },
91
- ];
92
-
93
- it('narrows by category', () => {
94
- expect(filterLibraryItems(items, 'skills', '').map((i) => i.name)).toEqual([
95
- 'Weekly newsletter',
96
- 'RFI responder',
97
- ]);
98
- expect(filterLibraryItems(items, 'integrations', '').map((i) => i.name)).toEqual([
99
- 'Slack',
100
- 'GitHub',
101
- ]);
102
- expect(filterLibraryItems(items, 'owned', '').map((i) => i.name)).toEqual([
103
- 'Weekly newsletter',
104
- 'GitHub',
105
- ]);
106
- });
107
-
108
- it('search matches name or description within the category, case-insensitively', () => {
109
- expect(filterLibraryItems(items, 'skills', 'friday').map((i) => i.name)).toEqual([
110
- 'Weekly newsletter',
111
- ]);
112
- expect(filterLibraryItems(items, 'integrations', 'CHANGE').map((i) => i.name)).toEqual([
113
- 'GitHub',
114
- ]);
115
- expect(filterLibraryItems(items, 'skills', 'slack')).toEqual([]);
116
- });
117
- });
1
+ import { describe, it, expect } from 'vitest';
2
+ import type { ToolSecrets } from '../../secrets-vault/services/tool-secrets.api';
3
+ import {
4
+ filterLibraryItems,
5
+ neededToolsFor,
6
+ skillStatus,
7
+ toolStatus,
8
+ type LibraryFilterable,
9
+ } from '../utils/status';
10
+
11
+ function tool(overrides: Partial<ToolSecrets>): ToolSecrets {
12
+ return {
13
+ slug: 'slack',
14
+ name: 'slack',
15
+ path: 'Tools/slack.tool',
16
+ type: 'http',
17
+ setup: null,
18
+ canWrite: false,
19
+ variables: [],
20
+ ...overrides,
21
+ };
22
+ }
23
+
24
+ describe('toolStatus', () => {
25
+ it('is ok when every variable is satisfied', () => {
26
+ const t = tool({
27
+ variables: [
28
+ { name: 'API_KEY', scope: 'admin', label: null, key: 'slack_API_KEY', adminConfigured: true, userConfigured: false },
29
+ { name: 'TOKEN', scope: 'user', label: null, key: 'slack_TOKEN', adminConfigured: false, userConfigured: true },
30
+ ],
31
+ });
32
+ expect(toolStatus(t).state).toBe('ok');
33
+ });
34
+
35
+ it('flags a missing user sign-in as warn (oauth) and an expired one as err', () => {
36
+ const pending = tool({
37
+ variables: [
38
+ { name: 'SIGNIN', scope: 'user', label: null, key: 'k', adminConfigured: true, userConfigured: false, oauth: true, authorized: false },
39
+ ],
40
+ });
41
+ expect(toolStatus(pending)).toEqual({ state: 'warn', text: 'Needs your sign-in' });
42
+
43
+ const expired = tool({
44
+ variables: [
45
+ { name: 'SIGNIN', scope: 'user', label: null, key: 'k', adminConfigured: true, userConfigured: true, oauth: true, authorized: true, needsReauth: true },
46
+ ],
47
+ });
48
+ expect(toolStatus(expired).state).toBe('err');
49
+ });
50
+
51
+ it('flags a missing shared value as off (not set up yet)', () => {
52
+ const t = tool({
53
+ variables: [
54
+ { name: 'API_KEY', scope: 'admin', label: null, key: 'k', adminConfigured: false, userConfigured: false },
55
+ ],
56
+ });
57
+ expect(toolStatus(t)).toEqual({ state: 'off', text: 'Not set up yet' });
58
+ expect(toolStatus(tool({ ...t, canWrite: true })).text).toContain('you maintain');
59
+ });
60
+ });
61
+
62
+ describe('neededToolsFor / skillStatus', () => {
63
+ const slack = tool({ name: 'slack', slug: 'slack' });
64
+ const notion = tool({
65
+ name: 'notion',
66
+ slug: 'notion',
67
+ variables: [
68
+ { name: 'SIGNIN', scope: 'user', label: null, key: 'k', adminConfigured: true, userConfigured: false, oauth: true, authorized: false },
69
+ ],
70
+ });
71
+
72
+ it('matches manual-namespaced allowed-tools entries and ignores generic agent tools', () => {
73
+ const needed = neededToolsFor({ allowedTools: ['Bash', 'slack_post_message', 'notion.notion_search'] }, [slack, notion]);
74
+ expect(needed.map((t) => t.name)).toEqual(['slack', 'notion']);
75
+ expect(neededToolsFor({ allowedTools: ['Read', 'Bash'] }, [slack, notion])).toEqual([]);
76
+ });
77
+
78
+ it('skill is ready only when every needed integration is connected', () => {
79
+ expect(skillStatus([slack]).state).toBe('ok');
80
+ expect(skillStatus([slack, notion])).toEqual({ state: 'warn', text: 'Needs setup' });
81
+ expect(skillStatus([]).state).toBe('ok');
82
+ });
83
+ });
84
+
85
+ describe('filterLibraryItems (category chips + search)', () => {
86
+ const items: LibraryFilterable[] = [
87
+ { kind: 'skill', name: 'Weekly newsletter', description: 'drafts the Friday newsletter', owned: true },
88
+ { kind: 'skill', name: 'RFI responder', description: 'answers requests', owned: false },
89
+ { kind: 'integration', name: 'Slack', description: 'messages', owned: false },
90
+ { kind: 'integration', name: 'GitHub', description: 'code and change requests', owned: true },
91
+ ];
92
+
93
+ it('narrows by category', () => {
94
+ expect(filterLibraryItems(items, 'skills', '').map((i) => i.name)).toEqual([
95
+ 'Weekly newsletter',
96
+ 'RFI responder',
97
+ ]);
98
+ expect(filterLibraryItems(items, 'integrations', '').map((i) => i.name)).toEqual([
99
+ 'Slack',
100
+ 'GitHub',
101
+ ]);
102
+ expect(filterLibraryItems(items, 'owned', '').map((i) => i.name)).toEqual([
103
+ 'Weekly newsletter',
104
+ 'GitHub',
105
+ ]);
106
+ });
107
+
108
+ it('search matches name or description within the category, case-insensitively', () => {
109
+ expect(filterLibraryItems(items, 'skills', 'friday').map((i) => i.name)).toEqual([
110
+ 'Weekly newsletter',
111
+ ]);
112
+ expect(filterLibraryItems(items, 'integrations', 'CHANGE').map((i) => i.name)).toEqual([
113
+ 'GitHub',
114
+ ]);
115
+ expect(filterLibraryItems(items, 'skills', 'slack')).toEqual([]);
116
+ });
117
+ });
@@ -1,47 +1,47 @@
1
- import type { PullRequestSummary } from '@bevel-software/platform-shared';
2
-
3
- interface ChangeRequestDockProps {
4
- crs: PullRequestSummary[];
5
- onSelect(cr: PullRequestSummary): void;
6
- }
7
-
8
- /**
9
- * Owner-only panel docked left of the detail dialog: a minimal name-list of
10
- * the open change requests touching this skill — nothing else (approved
11
- * design). Selecting one opens the side-by-side compare. Rendered `fixed`
12
- * from inside the Dialog so it escapes the panel's overflow (the Dialog panel
13
- * carries no transform, so fixed positioning stays viewport-relative).
14
- */
15
- export function ChangeRequestDock({ crs, onSelect }: ChangeRequestDockProps) {
16
- return (
17
- <div
18
- className="lib-cr-dock fixed top-1/2 z-[55] flex max-h-[72vh] w-[232px] -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-[0_20px_60px_rgba(22,35,58,0.20)]"
19
- style={{ right: 'calc(50% + 22.5rem)' }}
20
- aria-label="Change requests for this skill"
21
- >
22
- <div className="flex items-center gap-2 px-4 pb-2.5 pt-3.5 text-[11px] font-bold uppercase tracking-[.08em] text-slate-500">
23
- Change requests
24
- <span className="rounded-full bg-[#e6f7f4] px-2 text-[10.5px] text-[#0f766e]">{crs.length}</span>
25
- </div>
26
- <div className="flex flex-col gap-2 overflow-y-auto px-2.5 pb-3">
27
- {crs.length === 0 ? (
28
- <div className="p-3 text-center text-xs text-slate-400">No open change requests</div>
29
- ) : (
30
- crs.map((cr) => (
31
- <button
32
- key={cr.number}
33
- type="button"
34
- className="rounded-[10px] border border-slate-200 bg-[#fafbfd] px-3 py-2.5 text-left text-[12.5px] font-semibold text-slate-700 transition-colors hover:border-[#7fd0c4]"
35
- onClick={() => onSelect(cr)}
36
- >
37
- {cr.title}
38
- <span className="mt-0.5 block text-[10px] font-normal text-slate-400">
39
- {cr.appAuthor?.name ?? cr.author.name ?? cr.author.login}
40
- </span>
41
- </button>
42
- ))
43
- )}
44
- </div>
45
- </div>
46
- );
47
- }
1
+ import type { PullRequestSummary } from '@bevel-software/platform-shared';
2
+
3
+ interface ChangeRequestDockProps {
4
+ crs: PullRequestSummary[];
5
+ onSelect(cr: PullRequestSummary): void;
6
+ }
7
+
8
+ /**
9
+ * Owner-only panel docked left of the detail dialog: a minimal name-list of
10
+ * the open change requests touching this skill — nothing else (approved
11
+ * design). Selecting one opens the side-by-side compare. Rendered `fixed`
12
+ * from inside the Dialog so it escapes the panel's overflow (the Dialog panel
13
+ * carries no transform, so fixed positioning stays viewport-relative).
14
+ */
15
+ export function ChangeRequestDock({ crs, onSelect }: ChangeRequestDockProps) {
16
+ return (
17
+ <div
18
+ className="lib-cr-dock fixed top-1/2 z-[55] flex max-h-[72vh] w-[232px] -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-[0_20px_60px_rgba(22,35,58,0.20)]"
19
+ style={{ right: 'calc(50% + 22.5rem)' }}
20
+ aria-label="Change requests for this skill"
21
+ >
22
+ <div className="flex items-center gap-2 px-4 pb-2.5 pt-3.5 text-[11px] font-bold uppercase tracking-[.08em] text-slate-500">
23
+ Change requests
24
+ <span className="rounded-full bg-[#e6f7f4] px-2 text-[10.5px] text-[#0f766e]">{crs.length}</span>
25
+ </div>
26
+ <div className="flex flex-col gap-2 overflow-y-auto px-2.5 pb-3">
27
+ {crs.length === 0 ? (
28
+ <div className="p-3 text-center text-xs text-slate-400">No open change requests</div>
29
+ ) : (
30
+ crs.map((cr) => (
31
+ <button
32
+ key={cr.number}
33
+ type="button"
34
+ className="rounded-[10px] border border-slate-200 bg-[#fafbfd] px-3 py-2.5 text-left text-[12.5px] font-semibold text-slate-700 transition-colors hover:border-[#7fd0c4]"
35
+ onClick={() => onSelect(cr)}
36
+ >
37
+ {cr.title}
38
+ <span className="mt-0.5 block text-[10px] font-normal text-slate-400">
39
+ {cr.appAuthor?.name ?? cr.author.name ?? cr.author.login}
40
+ </span>
41
+ </button>
42
+ ))
43
+ )}
44
+ </div>
45
+ </div>
46
+ );
47
+ }