@bevel-software/platform-core-frontend 0.4.1 → 0.5.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.
- package/THIRD-PARTY-NOTICES.md +5366 -0
- package/package.json +7 -4
- package/src/core/CoreAppShell.tsx +195 -56
- package/src/core/__tests__/AppChrome.test.tsx +125 -0
- package/src/core/__tests__/ShellRoutes.test.tsx +37 -2
- package/src/core/__tests__/bootstrap.test.ts +63 -0
- package/src/core/bootstrap.ts +73 -0
- package/src/core/events.ts +12 -0
- package/src/core/registry.ts +58 -9
- package/src/index.css +100 -11
- package/src/index.ts +24 -23
- package/src/lib/utils.ts +93 -117
- package/src/modules/access/__tests__/ManageAccessDialog.placement.test.tsx +281 -0
- package/src/modules/access/__tests__/ManageAccessDialog.test.tsx +166 -1
- package/src/modules/access/api.ts +49 -0
- package/src/modules/access/components/ManageAccessDialog.tsx +786 -481
- package/src/modules/access/hooks/useFileAccess.ts +1 -1
- package/src/modules/admin/__tests__/AdminRolesPage.suggest.test.tsx +86 -0
- package/src/modules/admin/__tests__/UserAccountsPage.test.tsx +17 -1
- package/src/modules/admin/__tests__/admin.unread.test.tsx +61 -0
- package/src/modules/admin/components/AdminRolesPage.tsx +44 -38
- package/src/modules/admin/components/RolesCorruptedBanner.tsx +11 -10
- package/src/modules/admin/components/UserAccountsPage.tsx +36 -28
- package/src/modules/admin/state/admin.context.tsx +15 -6
- package/src/modules/auth/components/AccountPage.tsx +11 -11
- package/src/modules/auth/components/LoginScreen.tsx +12 -12
- package/src/modules/auth/services/sso.ts +47 -1
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.test.tsx +277 -0
- package/src/modules/change-requests/__tests__/author.test.ts +48 -0
- package/src/modules/change-requests/__tests__/conflict.test.ts +73 -0
- package/src/modules/change-requests/__tests__/diff.test.ts +134 -0
- package/src/modules/change-requests/__tests__/propose.test.ts +93 -0
- package/src/modules/change-requests/__tests__/useFileOnBranch.test.tsx +72 -0
- package/src/modules/change-requests/change-requests.css +22 -0
- package/src/modules/change-requests/components/ChangeBox.tsx +277 -0
- package/src/modules/change-requests/components/ChangeRequestDialog.tsx +713 -0
- package/src/modules/change-requests/components/ConflictHelp.tsx +47 -0
- package/src/modules/change-requests/components/CrFileTree.tsx +398 -0
- package/src/modules/change-requests/components/FileChangeBoxes.tsx +168 -0
- package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +236 -0
- package/src/modules/change-requests/hooks/useCrFileDiffs.ts +79 -0
- package/src/modules/change-requests/hooks/useFileOnBranch.ts +80 -0
- package/src/modules/change-requests/services/change-requests.api.ts +45 -0
- package/src/modules/change-requests/services/propose.api.ts +162 -0
- package/src/modules/change-requests/utils/author.ts +47 -0
- package/src/modules/change-requests/utils/conflict.ts +38 -0
- package/src/modules/change-requests/utils/diff.ts +80 -0
- package/src/modules/git/__tests__/BranchSwitcher.test.tsx +27 -18
- package/src/modules/git/__tests__/FileHistoryPanel.test.tsx +36 -83
- package/src/modules/git/__tests__/PullNeededBanner.test.tsx +5 -5
- package/src/modules/git/__tests__/PullRequestsForMe.test.tsx +147 -0
- package/src/modules/git/__tests__/useAutoPullUpdates.test.tsx +2 -8
- package/src/modules/git/components/BranchSwitcher.tsx +68 -31
- package/src/modules/git/components/DiffView.tsx +4 -4
- package/src/modules/git/components/FileComparisonPanel.tsx +20 -20
- package/src/modules/git/components/FileHistoryPanel.tsx +71 -107
- package/src/modules/git/components/PullNeededBanner.tsx +6 -13
- package/src/modules/git/components/PullRequestsForMe.tsx +71 -36
- package/src/modules/git/components/UnifiedDiffView.tsx +4 -4
- package/src/modules/git/hooks/__tests__/useGitState.deleteBranch.test.tsx +2 -2
- package/src/modules/git/hooks/useGitState.ts +15 -14
- package/src/modules/git/services/__tests__/error-messages.test.ts +4 -4
- package/src/modules/git/services/error-messages.ts +7 -7
- package/src/modules/git/services/git.api.ts +17 -11
- package/src/modules/git/services/pr-prompts.ts +2 -2
- package/src/modules/git/state/git.context.ts +10 -1
- package/src/modules/layout/__tests__/SidebarFrameResponsive.test.tsx +224 -0
- package/src/modules/layout/__tests__/SidebarToggle.test.tsx +242 -0
- package/src/modules/layout/__tests__/breakpoints.test.ts +56 -0
- package/src/modules/layout/breakpoints.ts +6 -0
- package/src/modules/layout/components/AppLayout.tsx +17 -5
- package/src/modules/layout/components/DemoBanner.tsx +10 -1
- package/src/modules/layout/components/MaintenanceOverlay.tsx +3 -3
- package/src/modules/layout/components/MobileChatLayout.tsx +31 -26
- package/src/modules/layout/components/ResizableThreePaneLayout.tsx +59 -24
- package/src/modules/layout/components/SidebarFrame.tsx +317 -0
- package/src/modules/layout/components/SidebarToggle.tsx +86 -0
- package/src/modules/layout/components/SlideOverlay.tsx +1 -1
- package/src/modules/layout/components/__tests__/MobileChatLayout.test.tsx +40 -2
- package/src/modules/layout/components/__tests__/ResizableThreePaneLayout.test.tsx +19 -3
- package/src/modules/layout/state/sidebar.ts +200 -0
- package/src/modules/library/__tests__/AddToGroupDialog.test.tsx +313 -0
- package/src/modules/library/__tests__/ChangeRequestDock.test.tsx +84 -0
- package/src/modules/library/__tests__/GroupJoinRequests.test.tsx +178 -0
- package/src/modules/library/__tests__/GroupPage.test.tsx +479 -0
- package/src/modules/library/__tests__/GroupsIndexPage.test.tsx +283 -0
- package/src/modules/library/__tests__/GroupsSidebar.contextmenu.test.tsx +175 -0
- package/src/modules/library/__tests__/GroupsSidebar.locked.test.tsx +96 -0
- package/src/modules/library/__tests__/GroupsSidebar.test.tsx +142 -0
- package/src/modules/library/__tests__/GroupsSidebarMenu.test.tsx +142 -0
- package/src/modules/library/__tests__/LibraryCard.test.tsx +149 -0
- package/src/modules/library/__tests__/LibraryRoutes.test.tsx +378 -0
- package/src/modules/library/__tests__/LibrarySidebarMenu.test.tsx +347 -0
- package/src/modules/library/__tests__/LockedGroupView.test.tsx +203 -0
- package/src/modules/library/__tests__/NewGroupDialog.test.tsx +114 -0
- package/src/modules/library/__tests__/PersonalAddDialog.test.tsx +177 -0
- package/src/modules/library/__tests__/SkillPage.test.tsx +1063 -0
- package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +259 -0
- package/src/modules/library/__tests__/ToolLogo.test.tsx +63 -0
- package/src/modules/library/__tests__/ToolPage.test.tsx +315 -0
- package/src/modules/library/__tests__/ToolSharePanel.test.tsx +36 -0
- package/src/modules/library/__tests__/ToolVarRow.test.tsx +260 -0
- package/src/modules/library/__tests__/WorkspaceItemRoute.test.tsx +197 -0
- package/src/modules/library/__tests__/auth-harness.tsx +37 -0
- package/src/modules/library/__tests__/oauth-fragment.test.ts +48 -0
- package/src/modules/library/__tests__/status.test.ts +113 -20
- package/src/modules/library/__tests__/useSkillDetail.test.tsx +102 -0
- package/src/modules/library/__tests__/useToolPage.test.tsx +146 -0
- package/src/modules/library/components/AccessRequestsBanner.tsx +101 -0
- package/src/modules/library/components/AddToGroupDialog.tsx +115 -0
- package/src/modules/library/components/ChangeRequestDock.tsx +52 -28
- package/src/modules/library/components/DeleteGroupDialog.tsx +87 -0
- package/src/modules/library/components/GroupIndexRow.tsx +63 -0
- package/src/modules/library/components/GroupJoinRequests.tsx +56 -0
- package/src/modules/library/components/GroupPage.tsx +373 -0
- package/src/modules/library/components/GroupsIndexPage.tsx +222 -0
- package/src/modules/library/components/GroupsSidebar.tsx +338 -0
- package/src/modules/library/components/GroupsSidebarMenu.tsx +160 -0
- package/src/modules/library/components/LibraryCard.tsx +123 -102
- package/src/modules/library/components/LibraryLayout.tsx +344 -0
- package/src/modules/library/components/LibraryPage.tsx +111 -227
- package/src/modules/library/components/LockGlyph.tsx +31 -0
- package/src/modules/library/components/LockedGroupView.tsx +159 -0
- package/src/modules/library/components/ManagedGroupRequests.tsx +70 -0
- package/src/modules/library/components/NewGroupDialog.tsx +112 -0
- package/src/modules/library/components/NewSkillPanel.tsx +151 -0
- package/src/modules/library/components/PageActions.tsx +156 -0
- package/src/modules/library/components/PendingSkillReview.tsx +63 -0
- package/src/modules/library/components/PersonalAddDialog.tsx +88 -0
- package/src/modules/library/components/PersonalGroupPage.tsx +125 -0
- package/src/modules/library/components/StatusDot.tsx +25 -0
- package/src/modules/library/components/ToolLogo.tsx +171 -0
- package/src/modules/library/components/group-page-parts.tsx +419 -0
- package/src/modules/library/components/skill-page/SkillFileEditor.tsx +134 -0
- package/src/modules/library/components/skill-page/SkillFilePane.tsx +117 -0
- package/src/modules/library/components/skill-page/SkillFileTabs.tsx +112 -0
- package/src/modules/library/components/skill-page/SkillPage.tsx +673 -0
- package/src/modules/library/components/skill-page/tab-ids.ts +33 -0
- package/src/modules/library/components/tool-page/ToolConnectionSection.tsx +175 -0
- package/src/modules/library/components/tool-page/ToolPage.tsx +228 -0
- package/src/modules/library/components/tool-page/ToolSharePanel.tsx +45 -0
- package/src/modules/library/components/tool-page/ToolVarRow.tsx +289 -0
- package/src/modules/library/hooks/useJoinRequests.ts +114 -0
- package/src/modules/library/hooks/useLibraryData.ts +134 -119
- package/src/modules/library/hooks/useSkillDetail.ts +119 -74
- package/src/modules/library/hooks/useToolPage.ts +145 -0
- package/src/modules/library/library.css +33 -245
- package/src/modules/library/routes/LibraryRoutes.tsx +134 -0
- package/src/modules/library/routes/WorkspaceItemRoute.tsx +74 -0
- package/src/modules/library/routes/library-paths.ts +191 -0
- package/src/modules/library/services/groups.api.ts +189 -0
- package/src/modules/library/services/library.api.ts +291 -164
- package/src/modules/library/services/tools.api.ts +60 -0
- package/src/modules/library/state/library-context.ts +22 -0
- package/src/modules/library/state/library-data.tsx +223 -0
- package/src/modules/library/state/toast.context.ts +32 -0
- package/src/modules/library/state/toast.tsx +84 -42
- package/src/modules/library/utils/clipboard.ts +33 -0
- package/src/modules/library/utils/group-summary.ts +68 -0
- package/src/modules/library/utils/names.ts +30 -0
- package/src/modules/library/utils/navigate-external.ts +15 -0
- package/src/modules/library/utils/oauth-fragment.ts +32 -0
- package/src/modules/library/utils/personal-group.ts +36 -0
- package/src/modules/library/utils/status.ts +108 -25
- package/src/modules/library/utils/toast-duration.ts +16 -0
- package/src/modules/onboarding/__tests__/onboarding.test.tsx +533 -0
- package/src/modules/onboarding/agent-clients.ts +48 -0
- package/src/modules/onboarding/components/ConnectAgentPill.tsx +133 -0
- package/src/modules/onboarding/components/RootLanding.tsx +54 -0
- package/src/modules/onboarding/components/WelcomePage.tsx +364 -0
- package/src/modules/onboarding/paths.ts +9 -0
- package/src/modules/onboarding/state/onboarding.ts +191 -0
- package/src/modules/pr/components/OpenChangeRequestDialog.tsx +10 -10
- package/src/modules/pr/services/pr-approvals.api.ts +19 -0
- package/src/modules/pr/services/pr-cancel.api.ts +11 -0
- package/src/modules/review/components/BinaryChangePlaceholder.tsx +3 -3
- package/src/modules/review/components/DiffViewer.tsx +4 -4
- package/src/modules/review/components/MarkdownDiffViewer.tsx +84 -26
- package/src/modules/review/components/ReviewFileRow.tsx +10 -10
- package/src/modules/review/components/ReviewPanel.tsx +49 -17
- package/src/modules/review/components/ReviewPanelSurface.tsx +1 -1
- package/src/modules/review/components/__tests__/MarkdownDiffViewer.test.tsx +122 -0
- package/src/modules/review/hooks/__tests__/useReviewState.test.ts +1 -1
- package/src/modules/secrets-vault/components/ConnectToolsPage.tsx +273 -171
- package/src/modules/secrets-vault/components/SecretsPage.tsx +147 -110
- package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +109 -92
- package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +35 -4
- package/src/modules/secrets-vault/services/connect.api.ts +24 -3
- package/src/modules/settings/components/DeploymentPage.tsx +90 -0
- package/src/modules/settings/components/SettingsLayout.tsx +135 -0
- package/src/modules/settings/components/SettingsNav.tsx +114 -0
- package/src/modules/settings/components/__tests__/DeploymentPage.test.tsx +110 -0
- package/src/modules/settings/components/__tests__/SettingsLayout.test.tsx +249 -0
- package/src/modules/settings/settings-nav-items.tsx +166 -0
- package/src/modules/setup/__tests__/setup.test.tsx +540 -0
- package/src/modules/setup/components/SetupGate.tsx +67 -0
- package/src/modules/setup/components/SetupScreen.tsx +573 -0
- package/src/modules/setup/services/setup.api.ts +106 -0
- package/src/modules/setup/utils/git-host.ts +34 -0
- package/src/modules/toolbar/components/AppSwitcher.tsx +38 -15
- package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +50 -50
- package/src/modules/toolbar/components/ProfileMenu.tsx +294 -0
- package/src/modules/toolbar/components/Toolbar.tsx +56 -54
- package/src/modules/toolbar/components/__tests__/AppSwitcher.test.tsx +176 -122
- package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +252 -77
- package/src/modules/tools/ToolsExplorerPage.tsx +45 -40
- package/src/modules/workspace/__tests__/design-system-parity.test.ts +133 -0
- package/src/modules/workspace/__tests__/testFixtures.ts +2 -0
- package/src/modules/workspace/components/EditorTabs.tsx +82 -50
- package/src/modules/workspace/components/FileExplorer.tsx +413 -189
- package/src/modules/workspace/components/FilePaneCard.tsx +53 -0
- package/src/modules/workspace/components/FileRoute.tsx +89 -84
- package/src/modules/workspace/components/FileViewer.tsx +700 -294
- package/src/modules/workspace/components/KbDocumentShell.tsx +138 -0
- package/src/modules/workspace/components/KbFileRail.tsx +128 -0
- package/src/modules/workspace/components/KbPageHeader.tsx +390 -0
- package/src/modules/workspace/components/__tests__/EditorTabs.test.tsx +87 -3
- package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +293 -39
- package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +1 -16
- package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +462 -44
- package/src/modules/workspace/components/__tests__/KbDocumentShell.test.tsx +84 -0
- package/src/modules/workspace/components/__tests__/KbFileRail.test.tsx +83 -0
- package/src/modules/workspace/components/__tests__/KbPageHeader.test.tsx +192 -0
- package/src/modules/workspace/components/renderers/CopyAnchorButton.tsx +64 -0
- package/src/modules/workspace/components/renderers/CsvRenderer.tsx +8 -8
- package/src/modules/workspace/components/renderers/DocxRenderer.tsx +18 -9
- package/src/modules/workspace/components/renderers/HtmlRenderer.tsx +14 -14
- package/src/modules/workspace/components/renderers/ImageRenderer.tsx +2 -2
- package/src/modules/workspace/components/renderers/KbMarkdownView.tsx +31 -165
- package/src/modules/workspace/components/renderers/MarkdownRenderer.tsx +18 -5
- package/src/modules/workspace/components/renderers/MermaidDiagram.tsx +27 -10
- package/src/modules/workspace/components/renderers/PdfRenderer.tsx +2 -2
- package/src/modules/workspace/components/renderers/TextRenderer.tsx +11 -5
- package/src/modules/workspace/components/renderers/ToolForm.tsx +24 -24
- package/src/modules/workspace/components/renderers/ToolRenderer.tsx +27 -27
- package/src/modules/workspace/components/renderers/XlsxRenderer.tsx +11 -11
- package/src/modules/workspace/components/renderers/__tests__/DocxRenderer.test.tsx +66 -0
- package/src/modules/workspace/components/renderers/__tests__/KbMarkdownView.test.tsx +17 -1
- package/src/modules/workspace/components/renderers/__tests__/MarkdownRenderer.test.tsx +1 -1
- package/src/modules/workspace/components/renderers/__tests__/MermaidDiagram.test.tsx +58 -0
- package/src/modules/workspace/components/renderers/__tests__/lazyRenderer.test.tsx +68 -0
- package/src/modules/workspace/components/renderers/__tests__/rendererLayout.test.ts +64 -0
- package/src/modules/workspace/components/renderers/__tests__/sanitizeDocxHtml.test.ts +0 -0
- package/src/modules/workspace/components/renderers/chunk-boundary.tsx +71 -0
- package/src/modules/workspace/components/renderers/index.ts +78 -2
- package/src/modules/workspace/components/renderers/kbMarkdownPipeline.tsx +241 -0
- package/src/modules/workspace/components/renderers/lazyRenderer.tsx +59 -0
- package/src/modules/workspace/components/renderers/sanitizeDocxHtml.ts +91 -0
- package/src/modules/workspace/hooks/__tests__/useLinksOut.test.ts +59 -0
- package/src/modules/workspace/hooks/__tests__/useOpenChangeRequests.test.tsx +237 -0
- package/src/modules/workspace/hooks/__tests__/useWorkspaceState.test.tsx +185 -0
- package/src/modules/workspace/hooks/useAutoGrowTextarea.ts +30 -0
- package/src/modules/workspace/hooks/useLastCommit.ts +66 -0
- package/src/modules/workspace/hooks/useLinksOut.ts +56 -0
- package/src/modules/workspace/hooks/useOpenChangeRequests.ts +20 -0
- package/src/modules/workspace/hooks/useWorkspaceState.ts +123 -14
- package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +1 -1
- package/src/modules/workspace/services/workspace.api.ts +9 -2
- package/src/modules/workspace/state/open-change-requests.context.ts +35 -0
- package/src/modules/workspace/state/open-change-requests.tsx +185 -0
- package/src/modules/workspace/state/workspace.context.ts +9 -0
- package/src/modules/workspace/utils/__tests__/diff.test.ts +87 -0
- package/src/modules/workspace/utils/diff.ts +130 -53
- package/src/modules/workspace/utils/fileTree.ts +7 -4
- package/src/modules/workspace/workspace.css +28 -0
- package/src/shared/components/Badge.tsx +62 -0
- package/src/shared/components/Banner.tsx +58 -0
- package/src/shared/components/Button.tsx +90 -0
- package/src/shared/components/Dialog.tsx +6 -6
- package/src/shared/components/Field.tsx +45 -0
- package/src/shared/components/IconButton.tsx +74 -0
- package/src/shared/components/ListRow.tsx +96 -0
- package/src/shared/components/Menu.tsx +88 -0
- package/src/shared/components/PageShell.tsx +8 -5
- package/src/shared/components/Surface.tsx +86 -0
- package/src/shared/components/__tests__/primitives.test.tsx +333 -0
- package/src/shared/components/index.ts +48 -0
- package/src/shared/components/useDismissableMenu.ts +71 -0
- package/src/shared/theme/__tests__/accent-contrast.test.ts +84 -0
- package/src/shared/theme/index.css +12 -0
- package/src/shared/theme/measure.ts +64 -0
- package/src/shared/theme/shadows.css +34 -0
- package/src/shared/theme/tokens.css +193 -0
- package/src/test-setup.ts +9 -0
- package/src/modules/access/components/AccessRestrictedBanner.tsx +0 -31
- package/src/modules/access/components/NodeOwnersBanner.tsx +0 -30
- package/src/modules/git/__tests__/ProtectedBranchBanner.test.tsx +0 -82
- package/src/modules/git/components/ProtectedBranchBanner.tsx +0 -42
- package/src/modules/library/__tests__/DetailDialog.test.tsx +0 -200
- package/src/modules/library/__tests__/diff.test.ts +0 -62
- package/src/modules/library/__tests__/loadout.test.tsx +0 -72
- package/src/modules/library/components/CompareView.tsx +0 -357
- package/src/modules/library/components/DetailDialog.tsx +0 -566
- package/src/modules/library/components/GearIcon.tsx +0 -12
- package/src/modules/library/components/LoadoutSidebar.tsx +0 -156
- package/src/modules/library/components/StatusGem.tsx +0 -21
- package/src/modules/library/components/SuggestChange.tsx +0 -171
- package/src/modules/library/components/particles.ts +0 -50
- package/src/modules/library/state/loadout.tsx +0 -129
- package/src/modules/library/utils/diff.ts +0 -102
- package/src/modules/pr/__tests__/PrApprovalBadge.test.tsx +0 -93
- package/src/modules/pr/__tests__/PrCancelButton.test.tsx +0 -158
- package/src/modules/pr/__tests__/PrCancelConfirmDialog.test.tsx +0 -44
- package/src/modules/pr/__tests__/PrMergeButton.test.tsx +0 -360
- package/src/modules/pr/__tests__/bucketize-comments.test.ts +0 -85
- package/src/modules/pr/__tests__/parsePatch.test.ts +0 -104
- package/src/modules/pr/__tests__/usePrViewerState.test.ts +0 -72
- package/src/modules/pr/components/PrApprovalBadge.tsx +0 -80
- package/src/modules/pr/components/PrCancelButton.tsx +0 -99
- package/src/modules/pr/components/PrCancelConfirmDialog.tsx +0 -119
- package/src/modules/pr/components/PrCommentComposer.tsx +0 -92
- package/src/modules/pr/components/PrCommentThread.tsx +0 -168
- package/src/modules/pr/components/PrCommentsPanel.tsx +0 -143
- package/src/modules/pr/components/PrDiffPane.tsx +0 -425
- package/src/modules/pr/components/PrFileRow.tsx +0 -164
- package/src/modules/pr/components/PrFilesList.tsx +0 -53
- package/src/modules/pr/components/PrHeader.tsx +0 -45
- package/src/modules/pr/components/PrHeaderOverflowMenu.tsx +0 -58
- package/src/modules/pr/components/PrMergeButton.tsx +0 -268
- package/src/modules/pr/components/PrMergeConfirmDialog.tsx +0 -112
- package/src/modules/pr/components/PrRefreshFromTargetButton.tsx +0 -110
- package/src/modules/pr/components/PrViewer.tsx +0 -364
- package/src/modules/pr/hooks/usePrViewerState.ts +0 -150
- package/src/modules/pr/state/pr-viewer.context.ts +0 -34
- package/src/modules/pr/utils/bucketize-comments.ts +0 -55
- package/src/modules/pr/utils/parsePatch.ts +0 -57
- package/src/modules/toolbar/components/AdminMenu.tsx +0 -271
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { useMemo,
|
|
2
|
-
import { Link2, Check } from 'lucide-react';
|
|
1
|
+
import { useMemo, type Ref } from 'react';
|
|
3
2
|
import Markdown from 'react-markdown';
|
|
4
|
-
import remarkGfm from 'remark-gfm';
|
|
5
|
-
import remarkFrontmatter from 'remark-frontmatter';
|
|
6
|
-
import rehypeRaw from 'rehype-raw';
|
|
7
|
-
import rehypeSanitize from 'rehype-sanitize';
|
|
8
|
-
import rehypeSlug from 'rehype-slug';
|
|
9
3
|
import { parseFrontmatter, labelFor } from '../../utils/frontmatter';
|
|
10
4
|
import { escapeSpacesInLinkDestinations } from '../../../../shared/markdown/Markdown';
|
|
11
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
KB_REMARK_PLUGINS,
|
|
7
|
+
KB_REHYPE_PLUGINS,
|
|
8
|
+
useKbMarkdownComponents,
|
|
9
|
+
} from './kbMarkdownPipeline';
|
|
12
10
|
|
|
13
11
|
// A frontmatter value that is a single markdown link, e.g.
|
|
14
12
|
// `nodeType: [Process](../../NodeTypes/Process.md)` (parseFrontmatter strips
|
|
@@ -17,65 +15,6 @@ import { MermaidDiagram } from './MermaidDiagram';
|
|
|
17
15
|
// whole-value link matches; everything else stays plain text.
|
|
18
16
|
const FRONTMATTER_LINK_RE = /^\[([^\]]+)\]\(<?([^)>]+)>?\)$/;
|
|
19
17
|
|
|
20
|
-
/**
|
|
21
|
-
* Copy text to the clipboard. Prefers the async Clipboard API; falls back to a
|
|
22
|
-
* hidden-textarea `execCommand('copy')` for contexts where the Clipboard API is
|
|
23
|
-
* blocked by Permissions Policy (e.g. some embedded iframes).
|
|
24
|
-
*/
|
|
25
|
-
async function copyToClipboard(text: string): Promise<boolean> {
|
|
26
|
-
try {
|
|
27
|
-
await navigator.clipboard.writeText(text);
|
|
28
|
-
return true;
|
|
29
|
-
} catch {
|
|
30
|
-
let ta: HTMLTextAreaElement | null = null;
|
|
31
|
-
try {
|
|
32
|
-
ta = document.createElement('textarea');
|
|
33
|
-
ta.value = text;
|
|
34
|
-
ta.style.position = 'fixed';
|
|
35
|
-
ta.style.opacity = '0';
|
|
36
|
-
document.body.appendChild(ta);
|
|
37
|
-
ta.select();
|
|
38
|
-
return document.execCommand('copy');
|
|
39
|
-
} catch {
|
|
40
|
-
return false;
|
|
41
|
-
} finally {
|
|
42
|
-
// Always remove the textarea, even if select()/execCommand threw.
|
|
43
|
-
if (ta?.parentNode) document.body.removeChild(ta);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Hover-revealed "copy link to this heading" button — mirrors the FileViewer's
|
|
50
|
-
* "copy link to this file" affordance (same `Link2` icon + 1.5s copied state),
|
|
51
|
-
* but copies the heading's deep-link (URL + `#slug`) so a reader can cite a
|
|
52
|
-
* specific section.
|
|
53
|
-
*/
|
|
54
|
-
function CopyAnchorButton({ url }: { url: string }) {
|
|
55
|
-
const [copied, setCopied] = useState(false);
|
|
56
|
-
return (
|
|
57
|
-
<button
|
|
58
|
-
type="button"
|
|
59
|
-
onClick={async (e) => {
|
|
60
|
-
e.preventDefault();
|
|
61
|
-
if (await copyToClipboard(url)) {
|
|
62
|
-
setCopied(true);
|
|
63
|
-
window.setTimeout(() => setCopied(false), 1500);
|
|
64
|
-
} else {
|
|
65
|
-
console.error('Failed to copy heading link');
|
|
66
|
-
}
|
|
67
|
-
}}
|
|
68
|
-
// `align-middle` keeps it on the heading baseline; hidden until the
|
|
69
|
-
// heading is hovered (or the button is focused for keyboard users).
|
|
70
|
-
className="ml-1.5 inline-flex align-middle p-0.5 rounded text-slate-400 no-underline opacity-0 transition-opacity hover:bg-slate-100 hover:text-slate-700 focus:opacity-100 group-hover/anchor:opacity-100"
|
|
71
|
-
title={copied ? 'Link copied' : 'Copy link to this heading'}
|
|
72
|
-
aria-label="Copy link to this heading"
|
|
73
|
-
>
|
|
74
|
-
{copied ? <Check size={13} /> : <Link2 size={13} />}
|
|
75
|
-
</button>
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
18
|
/**
|
|
80
19
|
* Render a single frontmatter value. A value that is a markdown link (notably
|
|
81
20
|
* `nodeType`) renders as a clickable link; everything else is plain text.
|
|
@@ -99,7 +38,7 @@ function FrontmatterValue({
|
|
|
99
38
|
e.preventDefault();
|
|
100
39
|
onOpenFile(href);
|
|
101
40
|
}}
|
|
102
|
-
className="text-
|
|
41
|
+
className="text-accent hover:text-accent-hover hover:underline cursor-pointer"
|
|
103
42
|
>
|
|
104
43
|
{label}
|
|
105
44
|
</a>
|
|
@@ -122,11 +61,11 @@ function FrontmatterPanel({
|
|
|
122
61
|
if (entries.length === 0) return null;
|
|
123
62
|
|
|
124
63
|
return (
|
|
125
|
-
<div className="mb-4 rounded-lg border border-
|
|
64
|
+
<div className="mb-4 rounded-lg border border-line-strong bg-sunken divide-y divide-line">
|
|
126
65
|
{entries.map(([key, value]) => (
|
|
127
66
|
<div key={key} className="flex items-start gap-3 px-3 py-2 text-xs">
|
|
128
|
-
<span className="shrink-0 text-
|
|
129
|
-
<span className="text-
|
|
67
|
+
<span className="shrink-0 text-ink-muted w-28">{labelFor(key)}</span>
|
|
68
|
+
<span className="text-ink break-words">
|
|
130
69
|
{Array.isArray(value) ? (
|
|
131
70
|
value.join(', ')
|
|
132
71
|
) : (
|
|
@@ -161,8 +100,20 @@ interface KbMarkdownViewProps {
|
|
|
161
100
|
* rehype-slug anchor id. Omit it (e.g. in the embed) to hide the buttons.
|
|
162
101
|
*/
|
|
163
102
|
headingLink?: (slug: string) => string;
|
|
164
|
-
/** Optional
|
|
103
|
+
/** Optional container ref (used by the file viewer for deep-link scroll). */
|
|
165
104
|
containerRef?: Ref<HTMLDivElement>;
|
|
105
|
+
/**
|
|
106
|
+
* Whether this view owns a scroller. `true` (the default) keeps the
|
|
107
|
+
* `flex-1 overflow-auto` box every caller relied on before the Knowledge
|
|
108
|
+
* document column existed — the Atlassian embed and the library's detail
|
|
109
|
+
* dialog still do.
|
|
110
|
+
*
|
|
111
|
+
* The file viewer passes `false`: inside `KbDocumentShell` the COLUMN
|
|
112
|
+
* scrolls, and a nested scroller there would break the measure (the
|
|
113
|
+
* document would scroll inside a fixed-height well) and hide the shell's
|
|
114
|
+
* scroll events from the file lock's activity listener.
|
|
115
|
+
*/
|
|
116
|
+
scroll?: boolean;
|
|
166
117
|
className?: string;
|
|
167
118
|
}
|
|
168
119
|
|
|
@@ -173,110 +124,25 @@ interface KbMarkdownViewProps {
|
|
|
173
124
|
* frontmatter panel, with navigation injected via `onOpenFile` so it carries no
|
|
174
125
|
* dependency on workspace routing or context.
|
|
175
126
|
*/
|
|
176
|
-
export function KbMarkdownView({ source, onOpenFile, onOpenNodeId, headingLink, containerRef, className }: KbMarkdownViewProps) {
|
|
127
|
+
export function KbMarkdownView({ source, onOpenFile, onOpenNodeId, headingLink, containerRef, scroll = true, className }: KbMarkdownViewProps) {
|
|
177
128
|
const { data: frontmatter, body } = useMemo(() => parseFrontmatter(source), [source]);
|
|
178
129
|
// CommonMark rejects unescaped spaces in link destinations, so a KB link like
|
|
179
130
|
// `[Foo](Some File.md)` would render as plain text. Wrap space-bearing
|
|
180
131
|
// destinations in `<...>` so links to files with spaces resolve.
|
|
181
132
|
const normalizedBody = useMemo(() => escapeSpacesInLinkDestinations(body), [body]);
|
|
182
133
|
|
|
183
|
-
const components =
|
|
184
|
-
// One renderer for h1–h6: reads its level from the hast node's tagName,
|
|
185
|
-
// re-attaches the rehype-slug `id`, and appends the copy-anchor button.
|
|
186
|
-
const Heading = ({ node, id, children, className: cls, ...props }: {
|
|
187
|
-
node?: { tagName?: string };
|
|
188
|
-
id?: string;
|
|
189
|
-
children?: React.ReactNode;
|
|
190
|
-
className?: string;
|
|
191
|
-
}) => {
|
|
192
|
-
const Tag = (node?.tagName ?? 'h2') as keyof React.JSX.IntrinsicElements;
|
|
193
|
-
return (
|
|
194
|
-
<Tag id={id} className={`group/anchor ${cls ?? ''}`.trim()} {...props}>
|
|
195
|
-
{children}
|
|
196
|
-
{headingLink && id ? <CopyAnchorButton url={headingLink(id)} /> : null}
|
|
197
|
-
</Tag>
|
|
198
|
-
);
|
|
199
|
-
};
|
|
200
|
-
return {
|
|
201
|
-
h1: Heading, h2: Heading, h3: Heading, h4: Heading, h5: Heading, h6: Heading,
|
|
202
|
-
a({ href, children, ...props }: { href?: string; children?: React.ReactNode }) {
|
|
203
|
-
// id-link: `[text](some-id)` or `[text](some-id#heading)` — a bare node
|
|
204
|
-
// id (the post-migration link form), optionally with a heading anchor
|
|
205
|
-
// (the `cite_kb_node` citation form). Resolve via onOpenNodeId, which
|
|
206
|
-
// splits off the heading. id grammar = lowercase alphanumeric + hyphens
|
|
207
|
-
// + underscores (snake_case tool/skill ids resolve too); the `#…` tail
|
|
208
|
-
// forbids `/` so a `.md` path link never matches. Keep in sync with
|
|
209
|
-
// `NODE_ID_LINK_RE` in kb-routes (kept inline here to avoid pulling the
|
|
210
|
-
// routing/hooks module into the embed bundle).
|
|
211
|
-
if (href && /^[a-z0-9][a-z0-9_-]*(#[^/]+)?$/.test(href)) {
|
|
212
|
-
// No resolver (e.g. the embed) → render inert, never a navigable
|
|
213
|
-
// anchor, so a bare id can't fall through as a relative-URL link.
|
|
214
|
-
if (!onOpenNodeId) return <span {...props}>{children}</span>;
|
|
215
|
-
return (
|
|
216
|
-
<a
|
|
217
|
-
{...props}
|
|
218
|
-
href={href}
|
|
219
|
-
onClick={(e) => {
|
|
220
|
-
e.preventDefault();
|
|
221
|
-
onOpenNodeId(href);
|
|
222
|
-
}}
|
|
223
|
-
className="cursor-pointer"
|
|
224
|
-
>
|
|
225
|
-
{children}
|
|
226
|
-
</a>
|
|
227
|
-
);
|
|
228
|
-
}
|
|
229
|
-
// Legacy/internal path link: a `.md` destination, optionally with a
|
|
230
|
-
// heading anchor (`Node.md#goal`) — still used by frontmatter `nodeType`.
|
|
231
|
-
// External (`http…`) and same-page (`#…`) links fall through to <a>.
|
|
232
|
-
if (href && !href.startsWith('http') && !href.startsWith('#') && /\.md(#|$)/.test(href)) {
|
|
233
|
-
return (
|
|
234
|
-
<a
|
|
235
|
-
{...props}
|
|
236
|
-
href={href}
|
|
237
|
-
onClick={(e) => {
|
|
238
|
-
e.preventDefault();
|
|
239
|
-
onOpenFile(href);
|
|
240
|
-
}}
|
|
241
|
-
className="cursor-pointer"
|
|
242
|
-
>
|
|
243
|
-
{children}
|
|
244
|
-
</a>
|
|
245
|
-
);
|
|
246
|
-
}
|
|
247
|
-
if (href && /^https?:\/\//i.test(href)) {
|
|
248
|
-
return <a href={href} {...props} target="_blank" rel="noopener noreferrer">{children}</a>;
|
|
249
|
-
}
|
|
250
|
-
return <a href={href} {...props}>{children}</a>;
|
|
251
|
-
},
|
|
252
|
-
pre({ children, ...props }: { children?: React.ReactNode }) {
|
|
253
|
-
// Render a mermaid code block as a diagram.
|
|
254
|
-
const child = Array.isArray(children) ? children[0] : children;
|
|
255
|
-
if (
|
|
256
|
-
child && typeof child === 'object' && 'props' in child &&
|
|
257
|
-
typeof child.props.className === 'string' &&
|
|
258
|
-
child.props.className.includes('language-mermaid')
|
|
259
|
-
) {
|
|
260
|
-
const code = String(child.props.children).replace(/\n$/, '');
|
|
261
|
-
return <MermaidDiagram code={code} />;
|
|
262
|
-
}
|
|
263
|
-
return <pre {...props}>{children}</pre>;
|
|
264
|
-
},
|
|
265
|
-
};
|
|
266
|
-
}, [onOpenFile, onOpenNodeId, headingLink]);
|
|
134
|
+
const components = useKbMarkdownComponents({ onOpenFile, onOpenNodeId, headingLink });
|
|
267
135
|
|
|
268
136
|
return (
|
|
269
|
-
<div
|
|
137
|
+
<div
|
|
138
|
+
className={`${scroll ? 'flex-1 overflow-auto' : 'min-w-0'} ${className ?? ''}`}
|
|
139
|
+
ref={containerRef}
|
|
140
|
+
>
|
|
270
141
|
<FrontmatterPanel data={frontmatter} onOpenFile={onOpenFile} />
|
|
271
142
|
<div className="prose prose-sm max-w-none">
|
|
272
143
|
<Markdown
|
|
273
|
-
remarkPlugins={
|
|
274
|
-
|
|
275
|
-
// Information" blocks in KB nodes) into real elements; rehype-sanitize
|
|
276
|
-
// runs after so enabling HTML doesn't open an XSS hole. rehype-slug
|
|
277
|
-
// runs LAST so the heading ids it adds survive sanitize's
|
|
278
|
-
// `user-content-` clobber prefix (which would break citation anchors).
|
|
279
|
-
rehypePlugins={[rehypeRaw, rehypeSanitize, rehypeSlug]}
|
|
144
|
+
remarkPlugins={KB_REMARK_PLUGINS}
|
|
145
|
+
rehypePlugins={KB_REHYPE_PLUGINS}
|
|
280
146
|
components={components}
|
|
281
147
|
>
|
|
282
148
|
{normalizedBody}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useState, useCallback, useEffect, useRef } from 'react';
|
|
2
2
|
import { useLocation } from 'react-router-dom';
|
|
3
3
|
import { KbMarkdownView } from './KbMarkdownView';
|
|
4
|
+
import { useAutoGrowTextarea } from '../../hooks/useAutoGrowTextarea';
|
|
4
5
|
import {
|
|
5
6
|
useFileNav,
|
|
6
7
|
useNodeIdNav,
|
|
@@ -70,6 +71,7 @@ export function MarkdownRenderer({
|
|
|
70
71
|
// rendered content is in the DOM.
|
|
71
72
|
const location = useLocation();
|
|
72
73
|
const scrollContainerRef = useRef<HTMLDivElement>(null);
|
|
74
|
+
const textareaRef = useRef<HTMLTextAreaElement>(null);
|
|
73
75
|
const [value, setValue] = useState(content);
|
|
74
76
|
// savedContent is the on-disk baseline; falls back to content when the
|
|
75
77
|
// caller doesn't track a separate saved version (single-file legacy).
|
|
@@ -202,16 +204,20 @@ export function MarkdownRenderer({
|
|
|
202
204
|
// surface (mid-save spinner or an error message), so view mode stays clean.
|
|
203
205
|
const showStatusStrip = saveState === 'saving' || (saveState === 'error' && saveError);
|
|
204
206
|
|
|
207
|
+
useAutoGrowTextarea(textareaRef, value, !readOnly);
|
|
208
|
+
|
|
205
209
|
return (
|
|
206
|
-
|
|
210
|
+
// Auto-height, not `h-full`: `KbDocumentShell` is the scroller now, and a
|
|
211
|
+
// document has no natural height — it is as tall as it is.
|
|
212
|
+
<div className="flex min-w-0 flex-col">
|
|
207
213
|
{showStatusStrip && (
|
|
208
|
-
<div className="flex items-center gap-2 pb-2 mb-2 border-b border-
|
|
214
|
+
<div className="flex items-center gap-2 pb-2 mb-2 border-b border-line shrink-0">
|
|
209
215
|
{saveState === 'saving' && (
|
|
210
216
|
<span
|
|
211
217
|
role="status"
|
|
212
218
|
aria-live="polite"
|
|
213
219
|
aria-atomic="true"
|
|
214
|
-
className="text-xs text-
|
|
220
|
+
className="text-xs text-ink-muted"
|
|
215
221
|
>
|
|
216
222
|
Saving…
|
|
217
223
|
</span>
|
|
@@ -221,7 +227,7 @@ export function MarkdownRenderer({
|
|
|
221
227
|
role="alert"
|
|
222
228
|
aria-live="assertive"
|
|
223
229
|
aria-atomic="true"
|
|
224
|
-
className="text-xs text-
|
|
230
|
+
className="text-xs text-danger"
|
|
225
231
|
>
|
|
226
232
|
Couldn't save your changes. Try again in a moment.
|
|
227
233
|
</span>
|
|
@@ -236,10 +242,17 @@ export function MarkdownRenderer({
|
|
|
236
242
|
onOpenNodeId={openNodeId}
|
|
237
243
|
headingLink={headingLink}
|
|
238
244
|
containerRef={scrollContainerRef}
|
|
245
|
+
// The document column scrolls; this view does not. See the prop's
|
|
246
|
+
// docstring — the embed and the library dialog keep the default.
|
|
247
|
+
scroll={false}
|
|
239
248
|
/>
|
|
240
249
|
) : (
|
|
241
250
|
<textarea
|
|
242
|
-
|
|
251
|
+
ref={textareaRef}
|
|
252
|
+
// Grows with its content so the column keeps the only scrollbar on
|
|
253
|
+
// the page — see `useAutoGrowTextarea`. `min-h-[50vh]` is the empty
|
|
254
|
+
// file's height, so a new document is a page rather than a slot.
|
|
255
|
+
className="w-full min-h-[50vh] resize-none overflow-hidden bg-transparent text-sm text-ink font-mono whitespace-pre-wrap break-words leading-relaxed outline-none"
|
|
243
256
|
value={value}
|
|
244
257
|
onChange={handleChange}
|
|
245
258
|
onKeyDown={handleKeyDown}
|
|
@@ -23,13 +23,29 @@ let diagramCounter = 0;
|
|
|
23
23
|
|
|
24
24
|
interface MermaidDiagramProps {
|
|
25
25
|
code: string;
|
|
26
|
+
/**
|
|
27
|
+
* What to render instead of the error box when `code` fails to parse.
|
|
28
|
+
*
|
|
29
|
+
* Exists for the diff viewer. A diff is rendered as independent fragments
|
|
30
|
+
* split at change boundaries, so an EDITED diagram arrives here with its
|
|
31
|
+
* ```mermaid fence truncated — it cannot parse, by construction, every time.
|
|
32
|
+
* The error box would then replace the red/green source lines, which are the
|
|
33
|
+
* only useful content in that block, with a message about syntax. Passing
|
|
34
|
+
* the original fenced code block back means an edited diagram shows its
|
|
35
|
+
* changed source and an untouched one (wholly inside a single unchanged
|
|
36
|
+
* fragment) still renders as a diagram.
|
|
37
|
+
*
|
|
38
|
+
* Omitted → the error box, which is right for a document view: there a
|
|
39
|
+
* broken diagram is a real defect the author wants to see.
|
|
40
|
+
*/
|
|
41
|
+
errorFallback?: React.ReactNode;
|
|
26
42
|
}
|
|
27
43
|
|
|
28
44
|
const MIN_SCALE = 0.1;
|
|
29
45
|
const MAX_SCALE = 20;
|
|
30
46
|
const ZOOM_FACTOR = 0.15;
|
|
31
47
|
|
|
32
|
-
export const MermaidDiagram = memo(function MermaidDiagram({ code }: MermaidDiagramProps) {
|
|
48
|
+
export const MermaidDiagram = memo(function MermaidDiagram({ code, errorFallback }: MermaidDiagramProps) {
|
|
33
49
|
const viewportRef = useRef<HTMLDivElement>(null);
|
|
34
50
|
const svgContainerRef = useRef<HTMLDivElement>(null);
|
|
35
51
|
const [error, setError] = useState<string | null>(null);
|
|
@@ -194,11 +210,12 @@ export const MermaidDiagram = memo(function MermaidDiagram({ code }: MermaidDiag
|
|
|
194
210
|
}, [rerender]);
|
|
195
211
|
|
|
196
212
|
if (error) {
|
|
213
|
+
if (errorFallback !== undefined) return <>{errorFallback}</>;
|
|
197
214
|
return (
|
|
198
|
-
<div className="rounded-lg border border-
|
|
199
|
-
<p className="text-xs text-
|
|
200
|
-
<pre className="text-xs text-
|
|
201
|
-
<pre className="mt-2 text-xs text-
|
|
215
|
+
<div className="rounded-lg border border-danger/30 bg-danger-soft p-4 my-4">
|
|
216
|
+
<p className="text-xs text-danger font-medium mb-1">Mermaid diagram error</p>
|
|
217
|
+
<pre className="text-xs text-danger/70 whitespace-pre-wrap">{error}</pre>
|
|
218
|
+
<pre className="mt-2 text-xs text-ink-muted whitespace-pre-wrap">{code}</pre>
|
|
202
219
|
</div>
|
|
203
220
|
);
|
|
204
221
|
}
|
|
@@ -207,29 +224,29 @@ export const MermaidDiagram = memo(function MermaidDiagram({ code }: MermaidDiag
|
|
|
207
224
|
const translate = translateRef.current;
|
|
208
225
|
|
|
209
226
|
return (
|
|
210
|
-
<div className="relative my-4 rounded-lg border border-
|
|
227
|
+
<div className="relative my-4 rounded-lg border border-line-strong bg-white overflow-hidden group">
|
|
211
228
|
{/* Zoom controls */}
|
|
212
229
|
<div className="absolute top-2 right-2 z-10 flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity">
|
|
213
230
|
<button
|
|
214
231
|
onClick={zoomOut}
|
|
215
|
-
className="p-1.5 rounded bg-
|
|
232
|
+
className="p-1.5 rounded-xs bg-sunken hover:bg-hover text-ink-muted hover:text-ink transition-colors"
|
|
216
233
|
title="Zoom out"
|
|
217
234
|
>
|
|
218
235
|
<ZoomOut size={14} />
|
|
219
236
|
</button>
|
|
220
|
-
<span className="text-xs text-
|
|
237
|
+
<span className="text-xs text-ink-muted min-w-[3rem] text-center tabular-nums">
|
|
221
238
|
{Math.round(scale * 100)}%
|
|
222
239
|
</span>
|
|
223
240
|
<button
|
|
224
241
|
onClick={zoomIn}
|
|
225
|
-
className="p-1.5 rounded bg-
|
|
242
|
+
className="p-1.5 rounded-xs bg-sunken hover:bg-hover text-ink-muted hover:text-ink transition-colors"
|
|
226
243
|
title="Zoom in"
|
|
227
244
|
>
|
|
228
245
|
<ZoomIn size={14} />
|
|
229
246
|
</button>
|
|
230
247
|
<button
|
|
231
248
|
onClick={resetView}
|
|
232
|
-
className="p-1.5 rounded bg-
|
|
249
|
+
className="p-1.5 rounded-xs bg-sunken hover:bg-hover text-ink-muted hover:text-ink transition-colors"
|
|
233
250
|
title="Reset view"
|
|
234
251
|
>
|
|
235
252
|
<Maximize2 size={14} />
|
|
@@ -57,7 +57,7 @@ export function PdfRenderer({ filePath }: FileRendererProps) {
|
|
|
57
57
|
|
|
58
58
|
if (error) {
|
|
59
59
|
return (
|
|
60
|
-
<div className="flex items-center justify-center h-full text-
|
|
60
|
+
<div className="flex items-center justify-center h-full text-danger text-sm">
|
|
61
61
|
{error}
|
|
62
62
|
</div>
|
|
63
63
|
);
|
|
@@ -65,7 +65,7 @@ export function PdfRenderer({ filePath }: FileRendererProps) {
|
|
|
65
65
|
|
|
66
66
|
if (!objectUrl) {
|
|
67
67
|
return (
|
|
68
|
-
<div className="flex items-center justify-center h-full text-
|
|
68
|
+
<div className="flex items-center justify-center h-full text-ink-muted text-sm">
|
|
69
69
|
Loading PDF...
|
|
70
70
|
</div>
|
|
71
71
|
);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { useState, useCallback, useEffect } from 'react';
|
|
1
|
+
import { useState, useCallback, useEffect, useRef } from 'react';
|
|
2
|
+
import { useAutoGrowTextarea } from '../../hooks/useAutoGrowTextarea';
|
|
2
3
|
import type { FileRendererProps, RendererSaveState } from './types';
|
|
3
4
|
|
|
4
5
|
export function TextRenderer({
|
|
@@ -15,6 +16,8 @@ export function TextRenderer({
|
|
|
15
16
|
const [savedValue, setSavedValue] = useState(savedContent ?? content);
|
|
16
17
|
const [saveState, setSaveState] = useState<RendererSaveState>('idle');
|
|
17
18
|
const [saveError, setSaveError] = useState<string | null>(null);
|
|
19
|
+
const textareaRef = useRef<HTMLTextAreaElement>(null);
|
|
20
|
+
useAutoGrowTextarea(textareaRef, value);
|
|
18
21
|
|
|
19
22
|
const dirty = !readOnly && value !== savedValue;
|
|
20
23
|
|
|
@@ -66,9 +69,12 @@ export function TextRenderer({
|
|
|
66
69
|
}, [save]);
|
|
67
70
|
|
|
68
71
|
return (
|
|
69
|
-
|
|
72
|
+
// Auto-height: `KbDocumentShell` owns the scroll, and the textarea grows
|
|
73
|
+
// to its content so the page keeps exactly one scrollbar.
|
|
74
|
+
<div className="flex min-w-0 flex-col">
|
|
70
75
|
<textarea
|
|
71
|
-
|
|
76
|
+
ref={textareaRef}
|
|
77
|
+
className="w-full min-h-[50vh] resize-none overflow-hidden bg-transparent text-sm text-ink font-mono whitespace-pre-wrap break-words leading-relaxed outline-none"
|
|
72
78
|
value={value}
|
|
73
79
|
onChange={readOnly ? undefined : handleChange}
|
|
74
80
|
onKeyDown={readOnly ? undefined : handleKeyDown}
|
|
@@ -77,8 +83,8 @@ export function TextRenderer({
|
|
|
77
83
|
/>
|
|
78
84
|
{!readOnly && (
|
|
79
85
|
<div className="pt-2 text-xs min-h-5">
|
|
80
|
-
{saveState === 'saving' && <span className="text-
|
|
81
|
-
{saveState === 'error' && saveError && <span className="text-
|
|
86
|
+
{saveState === 'saving' && <span className="text-ink-muted">Saving…</span>}
|
|
87
|
+
{saveState === 'error' && saveError && <span className="text-danger">{saveError}</span>}
|
|
82
88
|
</div>
|
|
83
89
|
)}
|
|
84
90
|
</div>
|
|
@@ -17,7 +17,7 @@ type ToolType = 'inline' | 'http' | 'mcp';
|
|
|
17
17
|
|
|
18
18
|
const ACCESS_VERBS = ['read', 'write', 'owner', 'download'] as const;
|
|
19
19
|
const inputCls =
|
|
20
|
-
'w-full rounded border border-
|
|
20
|
+
'w-full rounded-md border border-line-strong px-2 py-1 text-xs focus:border-accent focus:outline-none disabled:bg-sunken disabled:text-ink-muted';
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Parse the tool object — the `---` fence's contents, or the whole file when
|
|
@@ -76,8 +76,8 @@ export function ToolForm({
|
|
|
76
76
|
const { model, notes } = parsed;
|
|
77
77
|
if (!model) {
|
|
78
78
|
return (
|
|
79
|
-
<p className="text-
|
|
80
|
-
This file isn’t valid JSON/YAML
|
|
79
|
+
<p className="text-meta text-wait">
|
|
80
|
+
This file isn’t valid JSON/YAML. Switch to Code to {readOnly ? 'view' : 'fix'} it.
|
|
81
81
|
</p>
|
|
82
82
|
);
|
|
83
83
|
}
|
|
@@ -104,7 +104,7 @@ export function ToolForm({
|
|
|
104
104
|
|
|
105
105
|
return (
|
|
106
106
|
<div className="space-y-3">
|
|
107
|
-
<Field label="Id (the tool's stable name / secret namespace
|
|
107
|
+
<Field label="Id (the tool's stable name / secret namespace. Lowercase snake_case)">
|
|
108
108
|
<input
|
|
109
109
|
className={inputCls}
|
|
110
110
|
disabled={readOnly}
|
|
@@ -116,16 +116,16 @@ export function ToolForm({
|
|
|
116
116
|
|
|
117
117
|
<Field label="Type">
|
|
118
118
|
<select className={inputCls} disabled={readOnly} value={type} onChange={(e) => setBody({ type: e.target.value })}>
|
|
119
|
-
<option value="inline">inline
|
|
120
|
-
<option value="http">http
|
|
121
|
-
<option value="mcp">mcp
|
|
119
|
+
<option value="inline">inline: tools embedded in this file</option>
|
|
120
|
+
<option value="http">http: URL returning a UTCP manual</option>
|
|
121
|
+
<option value="mcp">mcp: remote MCP server</option>
|
|
122
122
|
</select>
|
|
123
123
|
</Field>
|
|
124
124
|
|
|
125
|
-
<label className="flex items-center gap-2 text-
|
|
125
|
+
<label className="flex items-center gap-2 text-meta text-ink-muted">
|
|
126
126
|
<input type="checkbox" disabled={readOnly} checked={remote} onChange={(e) => setBody({ remote: e.target.checked })} />
|
|
127
127
|
Available to remote agents
|
|
128
|
-
<span className="text-
|
|
128
|
+
<span className="text-ink-faint">(uncheck for local-only tools, e.g. a localhost MCP server)</span>
|
|
129
129
|
</label>
|
|
130
130
|
|
|
131
131
|
{(type === 'http' || type === 'mcp') && (
|
|
@@ -188,13 +188,13 @@ function AccessSection({ frontmatter, readOnly, onChange }: { frontmatter: Obj;
|
|
|
188
188
|
const [drafts, setDrafts] = useState<Partial<Record<string, string>>>({});
|
|
189
189
|
return (
|
|
190
190
|
<div>
|
|
191
|
-
<span className="mb-0.5 block text-
|
|
192
|
-
Access <span className="font-normal text-
|
|
191
|
+
<span className="mb-0.5 block text-meta font-medium text-ink-muted">
|
|
192
|
+
Access <span className="font-normal text-ink-faint">(one role or `Name <email>` per line; prefix `deny ` to remove)</span>
|
|
193
193
|
</span>
|
|
194
194
|
<div className="grid grid-cols-2 gap-2">
|
|
195
195
|
{ACCESS_VERBS.map((verb) => (
|
|
196
196
|
<label key={verb} className="block">
|
|
197
|
-
<span className="mb-0.5 block text-
|
|
197
|
+
<span className="mb-0.5 block text-label uppercase text-ink-faint">{verb}</span>
|
|
198
198
|
<textarea
|
|
199
199
|
disabled={readOnly}
|
|
200
200
|
rows={2}
|
|
@@ -210,7 +210,7 @@ function AccessSection({ frontmatter, readOnly, onChange }: { frontmatter: Obj;
|
|
|
210
210
|
return rest;
|
|
211
211
|
})
|
|
212
212
|
}
|
|
213
|
-
className="w-full resize-y rounded border border-
|
|
213
|
+
className="w-full resize-y rounded-md border border-line-strong px-1.5 py-1 text-meta focus:border-accent focus:outline-none disabled:bg-sunken disabled:text-ink-muted"
|
|
214
214
|
placeholder={verb === 'read' ? 'everyone' : 'Role Name'}
|
|
215
215
|
/>
|
|
216
216
|
</label>
|
|
@@ -223,7 +223,7 @@ function AccessSection({ frontmatter, readOnly, onChange }: { frontmatter: Obj;
|
|
|
223
223
|
function Field({ label, children }: { label: string; children: React.ReactNode }) {
|
|
224
224
|
return (
|
|
225
225
|
<label className="block">
|
|
226
|
-
<span className="mb-0.5 block text-
|
|
226
|
+
<span className="mb-0.5 block text-meta font-medium text-ink-muted">{label}</span>
|
|
227
227
|
{children}
|
|
228
228
|
</label>
|
|
229
229
|
);
|
|
@@ -247,9 +247,9 @@ function KeyValueRows({
|
|
|
247
247
|
const editAt = (i: number, next: [string, string]) => onChange(entries.map((e, j) => (j === i ? next : e)));
|
|
248
248
|
return (
|
|
249
249
|
<div>
|
|
250
|
-
<span className="mb-0.5 block text-
|
|
250
|
+
<span className="mb-0.5 block text-meta font-medium text-ink-muted">{label}</span>
|
|
251
251
|
<div className="space-y-1">
|
|
252
|
-
{entries.length === 0 && readOnly && <p className="text-
|
|
252
|
+
{entries.length === 0 && readOnly && <p className="text-meta text-ink-faint">None.</p>}
|
|
253
253
|
{entries.map(([k, v], i) => (
|
|
254
254
|
<div key={i} className="flex gap-1">
|
|
255
255
|
<input
|
|
@@ -287,11 +287,11 @@ function VariableRows({
|
|
|
287
287
|
const editAt = (i: number, patch: Obj) => onChange(variables.map((v, j) => (j === i ? { ...v, ...patch } : v)));
|
|
288
288
|
return (
|
|
289
289
|
<div>
|
|
290
|
-
<span className="mb-0.5 block text-
|
|
291
|
-
Variables <span className="font-normal text-
|
|
290
|
+
<span className="mb-0.5 block text-meta font-medium text-ink-muted">
|
|
291
|
+
Variables <span className="font-normal text-ink-faint">(who provisions each secret)</span>
|
|
292
292
|
</span>
|
|
293
293
|
<div className="space-y-1">
|
|
294
|
-
{variables.length === 0 && readOnly && <p className="text-
|
|
294
|
+
{variables.length === 0 && readOnly && <p className="text-meta text-ink-faint">None.</p>}
|
|
295
295
|
{variables.map((v, i) => (
|
|
296
296
|
<div key={i} className="flex gap-1">
|
|
297
297
|
<input
|
|
@@ -364,16 +364,16 @@ function InlineToolsEditor({
|
|
|
364
364
|
|
|
365
365
|
return (
|
|
366
366
|
<div>
|
|
367
|
-
<span className="mb-0.5 block text-
|
|
367
|
+
<span className="mb-0.5 block text-meta font-medium text-ink-muted">Inline tools (advanced, raw JSON)</span>
|
|
368
368
|
<textarea
|
|
369
369
|
value={readOnly ? external : text}
|
|
370
370
|
readOnly={readOnly}
|
|
371
371
|
onChange={(e) => onEdit(e.target.value)}
|
|
372
372
|
spellCheck={false}
|
|
373
373
|
rows={8}
|
|
374
|
-
className="w-full resize-y rounded border border-
|
|
374
|
+
className="w-full resize-y rounded-md border border-line-strong bg-sunken p-2 font-mono text-meta focus:border-accent focus:outline-none"
|
|
375
375
|
/>
|
|
376
|
-
{!readOnly && error && <p className="mt-0.5 text-
|
|
376
|
+
{!readOnly && error && <p className="mt-0.5 text-micro text-danger">Inline tools: {error}</p>}
|
|
377
377
|
</div>
|
|
378
378
|
);
|
|
379
379
|
}
|
|
@@ -383,7 +383,7 @@ function AddButton({ label, onClick }: { label: string; onClick: () => void }) {
|
|
|
383
383
|
<button
|
|
384
384
|
type="button"
|
|
385
385
|
onClick={onClick}
|
|
386
|
-
className="flex items-center gap-1 rounded px-1.5 py-0.5 text-
|
|
386
|
+
className="flex items-center gap-1 rounded-sm px-1.5 py-0.5 text-meta text-ink-muted hover:bg-hover"
|
|
387
387
|
>
|
|
388
388
|
<Plus size={11} /> {label}
|
|
389
389
|
</button>
|
|
@@ -395,7 +395,7 @@ function RemoveButton({ onClick }: { onClick: () => void }) {
|
|
|
395
395
|
<button
|
|
396
396
|
type="button"
|
|
397
397
|
onClick={onClick}
|
|
398
|
-
className="rounded p-1 text-
|
|
398
|
+
className="rounded-sm p-1 text-ink-faint hover:bg-danger-soft hover:text-danger"
|
|
399
399
|
aria-label="Remove"
|
|
400
400
|
>
|
|
401
401
|
<X size={12} />
|