@bevel-software/platform-core-frontend 0.12.1 → 0.13.3
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.
- package/package.json +2 -2
- package/src/modules/library/__tests__/McpServerSection.test.tsx +95 -0
- package/src/modules/library/__tests__/SkillPage.test.tsx +209 -5
- package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +31 -0
- package/src/modules/library/__tests__/ToolVarRow.test.tsx +18 -0
- package/src/modules/library/components/skill-page/SkillPage.tsx +178 -9
- package/src/modules/library/components/tool-page/McpServerSection.tsx +338 -65
- package/src/modules/library/components/tool-page/ToolConnectionSection.tsx +25 -9
- package/src/modules/library/components/tool-page/ToolVarRow.tsx +8 -0
- package/src/modules/library/services/tools.api.ts +23 -1
- package/src/modules/secrets-vault/components/SecretsPage.tsx +321 -313
- package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +20 -11
- package/src/modules/secrets-vault/services/secrets.api.ts +2 -0
- package/src/modules/secrets-vault/services/tool-secrets.api.ts +6 -3
- package/src/modules/workspace/components/EditorTabs.tsx +9 -17
- package/src/modules/workspace/components/FileExplorer.tsx +10 -4
- package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +170 -1
- package/src/modules/workspace/utils/__tests__/fileTree.test.ts +58 -0
- package/src/modules/workspace/utils/fileTree.ts +10 -1
- package/src/shared/components/__tests__/usePointerMenuPosition.test.tsx +50 -0
- package/src/shared/components/index.ts +2 -0
- package/src/shared/components/usePointerMenuPosition.ts +92 -0
|
@@ -1,14 +1,25 @@
|
|
|
1
|
-
import { useCallback, useEffect, useId, useMemo, useState, type ReactNode } from 'react';
|
|
1
|
+
import { useCallback, useEffect, useId, useMemo, useRef, useState, type ReactNode } from 'react';
|
|
2
2
|
import { useLocation, useNavigate, useParams } from 'react-router-dom';
|
|
3
|
+
import { ArrowLeft, History } from 'lucide-react';
|
|
3
4
|
import {
|
|
4
5
|
DEFAULT_BRANCH,
|
|
5
6
|
pluginOfPath,
|
|
6
7
|
type PullRequestSummary,
|
|
7
8
|
} from '@bevel-software/platform-shared';
|
|
8
9
|
import '../../library.css';
|
|
9
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
Badge,
|
|
12
|
+
Button,
|
|
13
|
+
IconButton,
|
|
14
|
+
MenuItem,
|
|
15
|
+
MenuPanel,
|
|
16
|
+
Surface,
|
|
17
|
+
useDismissableMenu,
|
|
18
|
+
} from '../../../../shared/components';
|
|
10
19
|
import { useAuth } from '../../../auth/state/auth.context';
|
|
11
20
|
import { useWorkspace } from '../../../workspace/state/workspace.context';
|
|
21
|
+
import { useGit } from '../../../git/state/git.context';
|
|
22
|
+
import { FileHistoryPanel } from '../../../git/components/FileHistoryPanel';
|
|
12
23
|
import { kbFileUrl, resolveRelativePath, useNodeIdNav } from '../../../workspace/routing/kb-routes';
|
|
13
24
|
import { cancelPullRequest } from '../../../pr/services/pr-cancel.api';
|
|
14
25
|
import { useFileAccess } from '../../../access/hooks/useFileAccess';
|
|
@@ -91,8 +102,27 @@ export function SkillPage({
|
|
|
91
102
|
const [selectedState, setSelected] = useState('SKILL.md');
|
|
92
103
|
const selected = activeFile ?? selectedState;
|
|
93
104
|
const [compareCr, setCompareCr] = useState<PullRequestSummary | null>(null);
|
|
105
|
+
/**
|
|
106
|
+
* The `⋯` menu's one destination: the git log for the file on screen,
|
|
107
|
+
* rendered in place of the reading pane. Local state rather than a URL,
|
|
108
|
+
* matching the Knowledge viewer's `activeTab` — a skill's canonical address
|
|
109
|
+
* names the FILE, and history is a lens on it, not a different file.
|
|
110
|
+
*
|
|
111
|
+
* Cleared whenever the file changes; see `historyKey` for why that is not a
|
|
112
|
+
* matter of taste.
|
|
113
|
+
*/
|
|
114
|
+
const [historyOpen, setHistoryOpen] = useState(false);
|
|
115
|
+
const [menuOpen, setMenuOpen] = useState(false);
|
|
116
|
+
const menuTriggerRef = useRef<HTMLButtonElement>(null);
|
|
117
|
+
const closeMenu = useCallback(() => setMenuOpen(false), []);
|
|
118
|
+
const menuRef = useDismissableMenu<HTMLDivElement>({
|
|
119
|
+
open: menuOpen,
|
|
120
|
+
onClose: closeMenu,
|
|
121
|
+
returnFocusTo: menuTriggerRef,
|
|
122
|
+
});
|
|
94
123
|
/** Ties the tabs to the panel they control; unique per mounted page. */
|
|
95
124
|
const tabsId = useId();
|
|
125
|
+
const git = useGit();
|
|
96
126
|
|
|
97
127
|
// Ownership is a property of the CATALOG entry, not of the skill document —
|
|
98
128
|
// it comes from the per-file ACL the provider already resolved, so the page
|
|
@@ -210,6 +240,64 @@ export function SkillPage({
|
|
|
210
240
|
Boolean((location.state as { startEditing?: boolean } | null)?.startEditing),
|
|
211
241
|
);
|
|
212
242
|
const [busyCr, setBusyCr] = useState<number | null>(null);
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* The workspace-relative path `FileHistoryPanel` reads the git log for — the
|
|
246
|
+
* same string the Knowledge viewer hands it, so a skill file's history is
|
|
247
|
+
* the file's history, not a second implementation of it. Null until the
|
|
248
|
+
* workspace and the skill have both resolved: the panel takes a path and
|
|
249
|
+
* asks immediately, so handing it a half-built one would ask about
|
|
250
|
+
* `undefined/SKILL.md`.
|
|
251
|
+
*/
|
|
252
|
+
const historyPath = kbDirName && skillPath ? `${kbDirName}/${fileRepoPath}` : null;
|
|
253
|
+
/**
|
|
254
|
+
* Whether `⋯` has anything behind it. Git not ready means there is no log to
|
|
255
|
+
* show, and an overflow that opens onto an empty panel is worse than no
|
|
256
|
+
* overflow at all — the same call `KbPageHeader` makes.
|
|
257
|
+
*
|
|
258
|
+
* `!editing` is the other half, and it is not cosmetic: `SkillFileEditor`
|
|
259
|
+
* holds the draft in its own state, so swapping it out for the history panel
|
|
260
|
+
* would throw away whatever the person had typed with no warning and no way
|
|
261
|
+
* back. The menu returns the moment they save or cancel.
|
|
262
|
+
*/
|
|
263
|
+
const historyAvailable = git.availability === 'ready' && historyPath !== null && !editing;
|
|
264
|
+
/**
|
|
265
|
+
* History closes when the file changes. It is a lens on ONE file, so a tab
|
|
266
|
+
* switch must land on that file's CONTENT — and it must stay landed: keying
|
|
267
|
+
* the open flag to the file it was opened for is not enough, because coming
|
|
268
|
+
* back to that tab then re-opens the log nobody asked for a second time.
|
|
269
|
+
*
|
|
270
|
+
* Adjusted during render rather than in an effect, so the new file's content
|
|
271
|
+
* paints on the first frame. An effect would show the old file's log under
|
|
272
|
+
* the new file's heading for one commit, which is the flicker the `active`
|
|
273
|
+
* derivation a few lines up exists to avoid.
|
|
274
|
+
*/
|
|
275
|
+
const [historyKey, setHistoryKey] = useState(fileRepoPath);
|
|
276
|
+
if (historyKey !== fileRepoPath) {
|
|
277
|
+
setHistoryKey(fileRepoPath);
|
|
278
|
+
if (historyOpen) setHistoryOpen(false);
|
|
279
|
+
}
|
|
280
|
+
// Losing the log CLOSES it, rather than parking it behind a flag. Git
|
|
281
|
+
// availability is re-derived from a polled status call, so a single failed
|
|
282
|
+
// poll flips it to `error` — which takes the panel off screen — and the next
|
|
283
|
+
// successful one flips it back. Left open, that second poll would put the
|
|
284
|
+
// log back over the file minutes after the reader returned to reading. Once
|
|
285
|
+
// it is gone they ask for it again, which is one click.
|
|
286
|
+
//
|
|
287
|
+
// BOTH flags, for one reason: the trigger and its panel live behind
|
|
288
|
+
// `historyAvailable` together, so an open menu unmounts with them and its
|
|
289
|
+
// flag is left set behind an element nobody can see. Closing only the log
|
|
290
|
+
// fixed the panel and left the menu to spring open by itself on the next
|
|
291
|
+
// good poll.
|
|
292
|
+
//
|
|
293
|
+
// `editing` is the second door into the same state, and it is reachable
|
|
294
|
+
// without a mouse: `useDismissableMenu` dismisses on outside POINTERDOWN, so
|
|
295
|
+
// tabbing from the open menu to Edit and pressing Enter never dismisses it.
|
|
296
|
+
// The editor then withdraws `historyAvailable`, and Cancel used to hand the
|
|
297
|
+
// menu back open.
|
|
298
|
+
if (historyOpen && !historyAvailable) setHistoryOpen(false);
|
|
299
|
+
if (menuOpen && !historyAvailable) setMenuOpen(false);
|
|
300
|
+
const viewingHistory = historyAvailable && historyOpen;
|
|
213
301
|
/**
|
|
214
302
|
* Change requests a merge attempt has REFUSED as unmergeable. Git is the only
|
|
215
303
|
* thing that can answer "does this still apply?", and it answers when asked
|
|
@@ -440,12 +528,58 @@ export function SkillPage({
|
|
|
440
528
|
|
|
441
529
|
<header className="mt-4">
|
|
442
530
|
<div className="flex items-center gap-3">
|
|
443
|
-
<h1 className="text-display font-semibold text-ink">{skill?.name ?? name}</h1>
|
|
531
|
+
<h1 className="min-w-0 text-display font-semibold text-ink">{skill?.name ?? name}</h1>
|
|
444
532
|
{skill && owned && (
|
|
445
533
|
<Badge tone="outline" size="xs" className="shrink-0 uppercase">
|
|
446
534
|
Owner
|
|
447
535
|
</Badge>
|
|
448
536
|
)}
|
|
537
|
+
|
|
538
|
+
{/* The same overflow a Knowledge page carries, for the same reason:
|
|
539
|
+
a skill is a file in the repository, and "who changed this, when"
|
|
540
|
+
is answerable about it exactly as it is about any other file. It
|
|
541
|
+
was unanswerable HERE and nowhere else, because this page is the
|
|
542
|
+
only surface a `Plugins/` file has — the shell routes those URLs
|
|
543
|
+
to the Library (`isLibraryLocation`) and the Knowledge tree does
|
|
544
|
+
not list `Plugins/` at all, so there was no viewer to fall back
|
|
545
|
+
to and no row to right-click.
|
|
546
|
+
|
|
547
|
+
Version history is the whole menu, so the trigger goes where the
|
|
548
|
+
menu goes — see `historyAvailable`. */}
|
|
549
|
+
{historyAvailable && (
|
|
550
|
+
<div className="relative ml-auto flex-none">
|
|
551
|
+
<IconButton
|
|
552
|
+
ref={menuTriggerRef}
|
|
553
|
+
aria-label="More actions"
|
|
554
|
+
aria-haspopup="menu"
|
|
555
|
+
aria-expanded={menuOpen}
|
|
556
|
+
active={menuOpen}
|
|
557
|
+
onClick={() => setMenuOpen((v) => !v)}
|
|
558
|
+
>
|
|
559
|
+
<span aria-hidden className="text-strong leading-none">
|
|
560
|
+
⋯
|
|
561
|
+
</span>
|
|
562
|
+
</IconButton>
|
|
563
|
+
{menuOpen && (
|
|
564
|
+
<div ref={menuRef} className="absolute right-0 top-[calc(100%+5px)] z-40">
|
|
565
|
+
<MenuPanel role="menu" aria-label="More actions" className="min-w-[212px]">
|
|
566
|
+
<MenuItem
|
|
567
|
+
role="menuitem"
|
|
568
|
+
onClick={() => {
|
|
569
|
+
closeMenu();
|
|
570
|
+
setHistoryOpen(true);
|
|
571
|
+
}}
|
|
572
|
+
>
|
|
573
|
+
<span className="flex items-center gap-2.5">
|
|
574
|
+
<History size={14} />
|
|
575
|
+
Version history
|
|
576
|
+
</span>
|
|
577
|
+
</MenuItem>
|
|
578
|
+
</MenuPanel>
|
|
579
|
+
</div>
|
|
580
|
+
)}
|
|
581
|
+
</div>
|
|
582
|
+
)}
|
|
449
583
|
</div>
|
|
450
584
|
{/* No description line here — the file pane renders the raw SKILL.md,
|
|
451
585
|
and its frontmatter panel already says what the skill is for.
|
|
@@ -476,16 +610,47 @@ export function SkillPage({
|
|
|
476
610
|
}}
|
|
477
611
|
/>
|
|
478
612
|
|
|
479
|
-
{/* The panel the tabs control. It wraps
|
|
480
|
-
|
|
481
|
-
rather than pointing at an
|
|
613
|
+
{/* The panel the tabs control. It wraps the reading pane, the editor
|
|
614
|
+
that replaces it and the history that replaces both, so
|
|
615
|
+
`aria-controls` resolves in every state rather than pointing at an
|
|
616
|
+
element that exists only some of the time. */}
|
|
482
617
|
<div
|
|
483
618
|
role="tabpanel"
|
|
484
619
|
id={skillPanelId(tabsId)}
|
|
485
620
|
aria-labelledby={skillTabId(tabsId, active)}
|
|
486
|
-
aria-busy={detail.loading || raw === null || undefined}
|
|
621
|
+
aria-busy={(!viewingHistory && (detail.loading || raw === null)) || undefined}
|
|
487
622
|
>
|
|
488
|
-
{
|
|
623
|
+
{viewingHistory && historyPath !== null ? (
|
|
624
|
+
<>
|
|
625
|
+
{/* An explicit way back. Without it the only route to the file would
|
|
626
|
+
be reopening it, since history is not in the URL. */}
|
|
627
|
+
<div className="mb-3 mt-4 flex items-center gap-2">
|
|
628
|
+
<Button
|
|
629
|
+
variant="quiet"
|
|
630
|
+
size="sm"
|
|
631
|
+
leadingIcon={<ArrowLeft size={13} />}
|
|
632
|
+
onClick={() => setHistoryOpen(false)}
|
|
633
|
+
>
|
|
634
|
+
Back to the file
|
|
635
|
+
</Button>
|
|
636
|
+
<span className="text-detail text-ink-faint">{`Version history: ${active}`}</span>
|
|
637
|
+
</div>
|
|
638
|
+
{/* A DEFINITE height, and a flex column to hold it. The panel is
|
|
639
|
+
built for the Knowledge viewer's full-height pane: its list and
|
|
640
|
+
its diff both scroll inside themselves, which needs a parent
|
|
641
|
+
whose height does not come from them. Dropped straight into this
|
|
642
|
+
reading column it would size to its own content instead, so a
|
|
643
|
+
long diff would stretch the page rather than scroll in place and
|
|
644
|
+
the empty state would collapse to a line. The measure matches the
|
|
645
|
+
editor's textarea, which is the same trade in the same column. */}
|
|
646
|
+
<Surface
|
|
647
|
+
radius="lg"
|
|
648
|
+
className="flex h-[60vh] min-h-80 flex-col overflow-hidden"
|
|
649
|
+
>
|
|
650
|
+
<FileHistoryPanel filePath={historyPath} />
|
|
651
|
+
</Surface>
|
|
652
|
+
</>
|
|
653
|
+
) : detail.loading ? (
|
|
489
654
|
<SkillFilePane
|
|
490
655
|
file={active}
|
|
491
656
|
raw={null}
|
|
@@ -568,8 +733,12 @@ export function SkillPage({
|
|
|
568
733
|
)}
|
|
569
734
|
|
|
570
735
|
{/* Every open proposal on this file, under the file it is about. The
|
|
571
|
-
owner decides here; the author can take theirs back.
|
|
736
|
+
owner decides here; the author can take theirs back. Not under the
|
|
737
|
+
history panel: a box asking "approve this?" needs the text it would
|
|
738
|
+
change above it, and the log is not that text. The dock below still
|
|
739
|
+
reaches every open request from either view. */}
|
|
572
740
|
{!editing &&
|
|
741
|
+
!viewingHistory &&
|
|
573
742
|
boxes.map((cr) => {
|
|
574
743
|
const mine = data.myCrNumbers.has(cr.number);
|
|
575
744
|
// `[]` is the hook's "overtaken" answer — the proposal and the file
|