@bevel-software/platform-core-frontend 0.4.1 → 0.5.0
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 +5 -3
- 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
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { useContext, useSyncExternalStore } from 'react';
|
|
2
|
+
import { AuthContext } from '../../auth/state/auth.context';
|
|
3
|
+
import { authFetch } from '../../../lib/api';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The connect-your-agent onboarding, backed by ONE server-side field:
|
|
7
|
+
* `users.onboarding_done`.
|
|
8
|
+
*
|
|
9
|
+
* The pill shows exactly while that field is `false` — across sign-ins,
|
|
10
|
+
* across browsers — and two things end it: the welcome page's Done and the
|
|
11
|
+
* pill's ×. Both call {@link markOnboardingDone}; the write is one-way and
|
|
12
|
+
* idempotent, so neither caller has to know about the other.
|
|
13
|
+
*
|
|
14
|
+
* Only an EXPLICIT `false` counts as "still onboarding". The field is
|
|
15
|
+
* optional on {@link AuthUser} for old fixtures and cached sessions, and an
|
|
16
|
+
* absent field must never resurrect the welcome flow for an account that
|
|
17
|
+
* finished it.
|
|
18
|
+
*
|
|
19
|
+
* Two small client-side pieces around the server truth:
|
|
20
|
+
*
|
|
21
|
+
* - `doneLocally` — an optimistic session override. The auth context's user
|
|
22
|
+
* object is a snapshot from sign-in; after POSTing we don't refetch it,
|
|
23
|
+
* we just remember the answer. A failed POST logs and DROPS the override
|
|
24
|
+
* at once, so the pill comes back immediately rather than reappearing at
|
|
25
|
+
* the next sign-in with no account of why it left.
|
|
26
|
+
* - `welcomed` (localStorage, per account) — "the welcome page was shown
|
|
27
|
+
* once". The auto-redirect there happens on the FIRST sign-in only;
|
|
28
|
+
* the pill, not the router, is the standing reminder. Per-browser by
|
|
29
|
+
* nature, which is fine: being greeted once per new machine is a welcome,
|
|
30
|
+
* not a bug.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
const WELCOMED_PREFIX = 'bevel.onboarding.welcomed.';
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The storage key holding "this account has seen the welcome page", keyed by
|
|
37
|
+
* lower-cased email so `Juan@…` and `juan@…` are one person rather than two
|
|
38
|
+
* greetings.
|
|
39
|
+
*/
|
|
40
|
+
const welcomedKey = (email: string) => `${WELCOMED_PREFIX}${email.toLowerCase()}`;
|
|
41
|
+
|
|
42
|
+
const doneLocally = new Set<string>();
|
|
43
|
+
const welcomedLocally = new Set<string>();
|
|
44
|
+
const listeners = new Set<() => void>();
|
|
45
|
+
|
|
46
|
+
/** Tell every mounted `useOnboarding` that the overrides above moved. */
|
|
47
|
+
function emit(): void {
|
|
48
|
+
listeners.forEach((l) => l());
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The `useSyncExternalStore` half of the subscription: register a listener and
|
|
53
|
+
* hand back its unsubscribe, so a hook that unmounts stops being notified.
|
|
54
|
+
*/
|
|
55
|
+
function subscribe(listener: () => void): () => void {
|
|
56
|
+
listeners.add(listener);
|
|
57
|
+
return () => listeners.delete(listener);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Storage is best-effort: private-mode Safari throws, and a forgotten
|
|
61
|
+
* "welcomed" costs one extra greeting, not a failure. */
|
|
62
|
+
function hasBeenWelcomed(email: string): boolean {
|
|
63
|
+
if (welcomedLocally.has(email)) return true;
|
|
64
|
+
try {
|
|
65
|
+
return window.localStorage.getItem(welcomedKey(email)) === '1';
|
|
66
|
+
} catch {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Note that this account has now been greeted, which is what makes the
|
|
73
|
+
* welcome redirect one-time. Idempotent: already-welcomed returns without
|
|
74
|
+
* touching storage or waking listeners.
|
|
75
|
+
*/
|
|
76
|
+
export function markWelcomed(email: string): void {
|
|
77
|
+
if (hasBeenWelcomed(email)) return;
|
|
78
|
+
welcomedLocally.add(email);
|
|
79
|
+
try {
|
|
80
|
+
window.localStorage.setItem(welcomedKey(email), '1');
|
|
81
|
+
} catch {
|
|
82
|
+
/* one extra greeting next boot */
|
|
83
|
+
}
|
|
84
|
+
emit();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Conclude the connect-your-agent onboarding — the shared act behind the
|
|
89
|
+
* welcome page's Done and the pill's ×.
|
|
90
|
+
*
|
|
91
|
+
* Optimistic: the pill disappears on the click, before the server answers,
|
|
92
|
+
* because a reminder that lingers while a request flies reads as a control
|
|
93
|
+
* that did not work. The override is dropped again if the write fails, so the
|
|
94
|
+
* UI never keeps claiming something the server refused.
|
|
95
|
+
*/
|
|
96
|
+
export function markOnboardingDone(userId: string, email: string): void {
|
|
97
|
+
if (doneLocally.has(email)) return;
|
|
98
|
+
doneLocally.add(email);
|
|
99
|
+
emit();
|
|
100
|
+
// `userId` states WHICH account this click meant. The bearer token is one
|
|
101
|
+
// shared localStorage key, so a tab still rendering account A after account
|
|
102
|
+
// B signed in elsewhere would otherwise conclude B's onboarding with A's
|
|
103
|
+
// intent. The server refuses the mismatch (409) rather than applying it.
|
|
104
|
+
void authFetch('/api/auth/onboarding-done', {
|
|
105
|
+
method: 'POST',
|
|
106
|
+
headers: { 'Content-Type': 'application/json' },
|
|
107
|
+
body: JSON.stringify({ userId }),
|
|
108
|
+
})
|
|
109
|
+
.then((res) => {
|
|
110
|
+
if (res.ok) return;
|
|
111
|
+
console.error('onboarding-done failed:', res.status);
|
|
112
|
+
// The write did not land, so the UI must stop claiming it did — the
|
|
113
|
+
// pill comes back now rather than mysteriously reappearing on the next
|
|
114
|
+
// sign-in. A 409 in particular means this tab is stale.
|
|
115
|
+
doneLocally.delete(email);
|
|
116
|
+
emit();
|
|
117
|
+
})
|
|
118
|
+
.catch((err) => {
|
|
119
|
+
console.error('onboarding-done failed:', err);
|
|
120
|
+
doneLocally.delete(email);
|
|
121
|
+
emit();
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Test seam: forget the session overrides and the welcomed notes.
|
|
127
|
+
*
|
|
128
|
+
* Scans storage by PREFIX rather than walking `welcomedLocally`, because that
|
|
129
|
+
* set is not a record of what is in storage. `markWelcomed` returns early when
|
|
130
|
+
* the key is already there, so an email welcomed by an earlier test file — or
|
|
131
|
+
* by an earlier run against the same jsdom `localStorage` — never enters the
|
|
132
|
+
* set, and its key would survive a reset that only knew about the set. The
|
|
133
|
+
* next "greets ONCE" assertion would then read "already welcomed" and fail on
|
|
134
|
+
* a state no test put there.
|
|
135
|
+
*/
|
|
136
|
+
export function resetOnboardingForTests(): void {
|
|
137
|
+
try {
|
|
138
|
+
for (const key of Object.keys(window.localStorage)) {
|
|
139
|
+
if (key.startsWith(WELCOMED_PREFIX)) window.localStorage.removeItem(key);
|
|
140
|
+
}
|
|
141
|
+
} catch {
|
|
142
|
+
/* ignore */
|
|
143
|
+
}
|
|
144
|
+
doneLocally.clear();
|
|
145
|
+
welcomedLocally.clear();
|
|
146
|
+
emit();
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export interface OnboardingController {
|
|
150
|
+
/** The reminder is alive: the server says onboarding is not done. */
|
|
151
|
+
showPill: boolean;
|
|
152
|
+
/** First sign-in, still unanswered: drives the ONE-TIME redirect to the welcome page. */
|
|
153
|
+
shouldWelcome: boolean;
|
|
154
|
+
markWelcomed(): void;
|
|
155
|
+
markDone(): void;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const SIGNED_OUT: OnboardingController = {
|
|
159
|
+
showPill: false,
|
|
160
|
+
shouldWelcome: false,
|
|
161
|
+
markWelcomed: () => {},
|
|
162
|
+
markDone: () => {},
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Reads `AuthContext` directly (tolerantly) rather than through `useAuth`,
|
|
167
|
+
* which throws outside a provider: this hook is consumed at the shell's root
|
|
168
|
+
* route, and `ShellRoutes` is deliberately testable without the full provider
|
|
169
|
+
* stack. Signed out — or providerless — there is nobody to onboard, and the
|
|
170
|
+
* answer is simply "nothing pending".
|
|
171
|
+
*/
|
|
172
|
+
export function useOnboarding(): OnboardingController {
|
|
173
|
+
const auth = useContext(AuthContext);
|
|
174
|
+
const user = auth?.user ?? null;
|
|
175
|
+
// The subscription's version counter: overrides and welcomed notes change
|
|
176
|
+
// under it. The snapshot is a cheap string so identity comparison is exact.
|
|
177
|
+
useSyncExternalStore(
|
|
178
|
+
subscribe,
|
|
179
|
+
() => `${doneLocally.size}:${welcomedLocally.size}`,
|
|
180
|
+
() => '0:0',
|
|
181
|
+
);
|
|
182
|
+
if (!user) return SIGNED_OUT;
|
|
183
|
+
const email = user.email;
|
|
184
|
+
const done = user.onboardingDone !== false || doneLocally.has(email);
|
|
185
|
+
return {
|
|
186
|
+
showPill: !done,
|
|
187
|
+
shouldWelcome: !done && !hasBeenWelcomed(email),
|
|
188
|
+
markWelcomed: () => markWelcomed(email),
|
|
189
|
+
markDone: () => markOnboardingDone(user.id, email),
|
|
190
|
+
};
|
|
191
|
+
}
|
|
@@ -107,7 +107,7 @@ export function OpenChangeRequestDialog({
|
|
|
107
107
|
type="button"
|
|
108
108
|
onClick={onClose}
|
|
109
109
|
disabled={busy}
|
|
110
|
-
className="px-3 py-1.5 text-xs rounded hover:bg-
|
|
110
|
+
className="px-3 py-1.5 text-xs rounded hover:bg-hover text-ink disabled:opacity-50"
|
|
111
111
|
>
|
|
112
112
|
Cancel
|
|
113
113
|
</button>
|
|
@@ -123,16 +123,16 @@ export function OpenChangeRequestDialog({
|
|
|
123
123
|
}
|
|
124
124
|
>
|
|
125
125
|
<div className="flex flex-col gap-3 text-sm">
|
|
126
|
-
<p className="text-xs text-
|
|
126
|
+
<p className="text-xs text-ink-muted">
|
|
127
127
|
Propose your shared draft{' '}
|
|
128
|
-
<span className="font-mono font-medium text-
|
|
128
|
+
<span className="font-mono font-medium text-ink">
|
|
129
129
|
{sourceBranch}
|
|
130
130
|
</span>{' '}
|
|
131
131
|
as a change request. Approvers can review it before it's applied.
|
|
132
132
|
</p>
|
|
133
133
|
|
|
134
134
|
<label className="flex flex-col gap-1">
|
|
135
|
-
<span className="text-xs font-medium text-
|
|
135
|
+
<span className="text-xs font-medium text-ink">
|
|
136
136
|
What did you change?
|
|
137
137
|
</span>
|
|
138
138
|
<input
|
|
@@ -144,29 +144,29 @@ export function OpenChangeRequestDialog({
|
|
|
144
144
|
if (e.key === 'Enter') void submit();
|
|
145
145
|
}}
|
|
146
146
|
placeholder="e.g. Add owner to Checkout process"
|
|
147
|
-
className="w-full bg-white border border-
|
|
147
|
+
className="w-full bg-white border border-line-strong rounded px-2 py-1.5 text-sm focus:outline-none focus:border-accent"
|
|
148
148
|
/>
|
|
149
149
|
</label>
|
|
150
150
|
|
|
151
151
|
<label className="flex flex-col gap-1">
|
|
152
|
-
<span className="text-xs font-medium text-
|
|
152
|
+
<span className="text-xs font-medium text-ink">
|
|
153
153
|
Anything approvers should know?{' '}
|
|
154
|
-
<span className="font-normal text-
|
|
154
|
+
<span className="font-normal text-ink-muted">(optional)</span>
|
|
155
155
|
</span>
|
|
156
156
|
<textarea
|
|
157
157
|
value={description}
|
|
158
158
|
onChange={(e) => setDescription(e.target.value)}
|
|
159
159
|
rows={3}
|
|
160
|
-
className="w-full bg-white border border-
|
|
160
|
+
className="w-full bg-white border border-line-strong rounded px-2 py-1.5 text-sm focus:outline-none focus:border-accent resize-y"
|
|
161
161
|
/>
|
|
162
162
|
</label>
|
|
163
163
|
|
|
164
164
|
<label className="flex flex-col gap-1">
|
|
165
|
-
<span className="text-xs font-medium text-
|
|
165
|
+
<span className="text-xs font-medium text-ink">Apply to</span>
|
|
166
166
|
<select
|
|
167
167
|
value={targetBranch}
|
|
168
168
|
onChange={(e) => setTargetBranch(e.target.value)}
|
|
169
|
-
className="w-full bg-white border border-
|
|
169
|
+
className="w-full bg-white border border-line-strong rounded px-2 py-1.5 text-sm focus:outline-none focus:border-accent"
|
|
170
170
|
>
|
|
171
171
|
{targets.length === 0 && (
|
|
172
172
|
<option value={targetBranch}>
|
|
@@ -16,6 +16,25 @@ export async function approvePrFile(
|
|
|
16
16
|
return data.approvals;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Decline one file of a change request: the backend restores its merge-base
|
|
21
|
+
* version on the source branch, dropping it from the request's diff. Same
|
|
22
|
+
* permission as approving. `closed` is true when this was the LAST file and
|
|
23
|
+
* the request closed itself (its branch is retired with it).
|
|
24
|
+
*/
|
|
25
|
+
export async function revertPrFile(
|
|
26
|
+
prNumber: number,
|
|
27
|
+
path: string,
|
|
28
|
+
): Promise<{ closed: boolean; remainingPaths: string[] }> {
|
|
29
|
+
return handleApiResponse<{ closed: boolean; remainingPaths: string[] }>(
|
|
30
|
+
await authFetch(`/api/workflow/change-requests/${prNumber}/files/revert`, {
|
|
31
|
+
method: 'POST',
|
|
32
|
+
headers: { 'Content-Type': 'application/json' },
|
|
33
|
+
body: JSON.stringify({ path }),
|
|
34
|
+
}),
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
19
38
|
export async function unapprovePrFile(
|
|
20
39
|
prNumber: number,
|
|
21
40
|
path: string,
|
|
@@ -17,3 +17,14 @@ export async function cancelPullRequest(prNumber: number): Promise<CancelPrResul
|
|
|
17
17
|
}),
|
|
18
18
|
);
|
|
19
19
|
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Delete a change request outright: close it AND retire its source branch.
|
|
23
|
+
* Admin-only — the server refuses everyone else; callers gate the button on
|
|
24
|
+
* `detail.viewerCanBypassMerge`, the same admin verdict.
|
|
25
|
+
*/
|
|
26
|
+
export async function deleteChangeRequest(prNumber: number): Promise<void> {
|
|
27
|
+
await handleApiResponse(
|
|
28
|
+
await authFetch(`/api/workflow/change-requests/${prNumber}`, { method: 'DELETE' }),
|
|
29
|
+
);
|
|
30
|
+
}
|
|
@@ -3,9 +3,9 @@ import type { FileDiffPayload } from '@bevel-software/platform-shared';
|
|
|
3
3
|
|
|
4
4
|
export function BinaryChangePlaceholder({ payload }: { payload: FileDiffPayload }) {
|
|
5
5
|
return (
|
|
6
|
-
<div className="h-full flex flex-col items-center justify-center gap-2 text-
|
|
7
|
-
<FileQuestion size={32} className="text-
|
|
8
|
-
<div className="font-medium text-
|
|
6
|
+
<div className="h-full flex flex-col items-center justify-center gap-2 text-ink-muted text-xs px-6 text-center">
|
|
7
|
+
<FileQuestion size={32} className="text-ink-muted" />
|
|
8
|
+
<div className="font-medium text-ink">Binary file. Preview not available</div>
|
|
9
9
|
<div className="font-mono truncate max-w-full" title={payload.path}>
|
|
10
10
|
{payload.path}
|
|
11
11
|
</div>
|
|
@@ -16,7 +16,7 @@ export function DiffViewer({ payload }: { payload: FileDiffPayload }) {
|
|
|
16
16
|
|
|
17
17
|
if (lines.length > MAX_RENDERED_LINES) {
|
|
18
18
|
return (
|
|
19
|
-
<div className="h-full flex items-center justify-center text-xs text-
|
|
19
|
+
<div className="h-full flex items-center justify-center text-xs text-ink-muted px-6 text-center">
|
|
20
20
|
Diff is too large to render ({lines.length.toLocaleString()} lines).
|
|
21
21
|
Accept or reject from the file list.
|
|
22
22
|
</div>
|
|
@@ -35,7 +35,7 @@ export function DiffViewer({ payload }: { payload: FileDiffPayload }) {
|
|
|
35
35
|
{lines.map((l, i) => {
|
|
36
36
|
let marker = ' ';
|
|
37
37
|
let bg = '';
|
|
38
|
-
let textColor = 'text-
|
|
38
|
+
let textColor = 'text-ink';
|
|
39
39
|
let left: number | '' = '';
|
|
40
40
|
let right: number | '' = '';
|
|
41
41
|
if (l.type === 'same') {
|
|
@@ -58,10 +58,10 @@ export function DiffViewer({ payload }: { payload: FileDiffPayload }) {
|
|
|
58
58
|
}
|
|
59
59
|
return (
|
|
60
60
|
<tr key={i} className={bg}>
|
|
61
|
-
<td className="w-12 text-right pr-2 text-
|
|
61
|
+
<td className="w-12 text-right pr-2 text-ink-muted select-none border-r border-line">
|
|
62
62
|
{left}
|
|
63
63
|
</td>
|
|
64
|
-
<td className="w-12 text-right pr-2 text-
|
|
64
|
+
<td className="w-12 text-right pr-2 text-ink-muted select-none border-r border-line">
|
|
65
65
|
{right}
|
|
66
66
|
</td>
|
|
67
67
|
<td className={`w-4 text-center ${textColor} select-none`}>{marker}</td>
|
|
@@ -1,19 +1,35 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
import Markdown from 'react-markdown';
|
|
3
|
-
import remarkGfm from 'remark-gfm';
|
|
4
|
-
import remarkFrontmatter from 'remark-frontmatter';
|
|
5
3
|
import type { FileDiffPayload } from '@bevel-software/platform-shared';
|
|
6
4
|
import { computeDiff, type DiffLine } from '../../workspace/utils/diff';
|
|
7
5
|
import { parseFrontmatter, labelFor, type FrontmatterData } from '../../workspace/utils/frontmatter';
|
|
6
|
+
import { escapeSpacesInLinkDestinations } from '../../../shared/markdown/Markdown';
|
|
7
|
+
import {
|
|
8
|
+
KB_REMARK_PLUGINS,
|
|
9
|
+
KB_DIFF_REHYPE_PLUGINS,
|
|
10
|
+
useKbMarkdownComponents,
|
|
11
|
+
} from '../../workspace/components/renderers/kbMarkdownPipeline';
|
|
8
12
|
|
|
9
13
|
const MAX_RENDERED_LINES = 5000;
|
|
10
14
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
interface MarkdownDiffViewerProps {
|
|
16
|
+
payload: FileDiffPayload;
|
|
17
|
+
/**
|
|
18
|
+
* Resolver for an internal `.md` link inside the diff. Omitted → such links
|
|
19
|
+
* render as inert anchors, which is the right default for a view of a PAST
|
|
20
|
+
* state: the file history panel shows a commit, and there is no meaningful
|
|
21
|
+
* "current" document for a relative link to resolve against.
|
|
22
|
+
*
|
|
23
|
+
* A caller that DOES pass one must bind it to the branch the diff is OF —
|
|
24
|
+
* the change request's branch, not whatever branch is checked out. The
|
|
25
|
+
* navigation hooks in `kb-routes` resolve against `git.status.branch`, so
|
|
26
|
+
* handing them through unbound would silently send a reviewer to a different
|
|
27
|
+
* branch's copy of the file they just clicked.
|
|
28
|
+
*/
|
|
29
|
+
onOpenFile?: (href: string) => void;
|
|
30
|
+
/** Same contract as {@link onOpenFile}, for bare node-id links. */
|
|
31
|
+
onOpenNodeId?: (id: string) => void;
|
|
32
|
+
}
|
|
17
33
|
|
|
18
34
|
/**
|
|
19
35
|
* Frontmatter-aware diff renderer for markdown files. Splits the diff into
|
|
@@ -21,8 +37,20 @@ const MD_COMPONENTS = {
|
|
|
21
37
|
* key-by-key red/green panel (rather than raw `key: value` lines), and the
|
|
22
38
|
* body as either a markdown-rendered preview with red/green change blocks or
|
|
23
39
|
* a git-conflict-marker view for side-by-side text inspection.
|
|
40
|
+
*
|
|
41
|
+
* The body renders through the shared KB markdown pipeline
|
|
42
|
+
* (`kbMarkdownPipeline`), so a diff reads like the document it is a diff of:
|
|
43
|
+
* id-links, `<details>` blocks and mermaid diagrams behave as they do in the
|
|
44
|
+
* knowledge view rather than as raw text.
|
|
45
|
+
*
|
|
46
|
+
* Resolvers arrive as PROPS and no hook is called here. That is deliberate:
|
|
47
|
+
* this component renders inside the change-request dialog and the file-history
|
|
48
|
+
* panel, both of which are mounted in places (and tested in ways) that have no
|
|
49
|
+
* Router and no Git/Workspace context — and it is reachable from the embed
|
|
50
|
+
* routes, which sit outside those providers entirely. A `useNavigate()` in
|
|
51
|
+
* here would be a runtime crash in all three.
|
|
24
52
|
*/
|
|
25
|
-
export function MarkdownDiffViewer({ payload
|
|
53
|
+
export function MarkdownDiffViewer({ payload, onOpenFile, onOpenNodeId }: MarkdownDiffViewerProps) {
|
|
26
54
|
const data = useMemo(() => {
|
|
27
55
|
const baseline = payload.baseline ?? '';
|
|
28
56
|
const current = payload.current ?? '';
|
|
@@ -60,7 +88,7 @@ export function MarkdownDiffViewer({ payload }: { payload: FileDiffPayload }) {
|
|
|
60
88
|
if (data.tooLarge || data.lines.length > MAX_RENDERED_LINES) {
|
|
61
89
|
const shown = data.tooLarge ? data.rawLineCount : data.lines.length;
|
|
62
90
|
return (
|
|
63
|
-
<div className="h-full flex items-center justify-center text-xs text-
|
|
91
|
+
<div className="h-full flex items-center justify-center text-xs text-ink-muted px-6 text-center">
|
|
64
92
|
Diff is too large to render ({shown.toLocaleString()} lines).
|
|
65
93
|
Accept or reject from the file list.
|
|
66
94
|
</div>
|
|
@@ -75,7 +103,11 @@ export function MarkdownDiffViewer({ payload }: { payload: FileDiffPayload }) {
|
|
|
75
103
|
newData={data.newFrontmatter}
|
|
76
104
|
/>
|
|
77
105
|
)}
|
|
78
|
-
<DiffPreview
|
|
106
|
+
<DiffPreview
|
|
107
|
+
blocks={data.bodyBlocks}
|
|
108
|
+
onOpenFile={onOpenFile}
|
|
109
|
+
onOpenNodeId={onOpenNodeId}
|
|
110
|
+
/>
|
|
79
111
|
</div>
|
|
80
112
|
);
|
|
81
113
|
}
|
|
@@ -163,14 +195,14 @@ function FrontmatterDiffPanel({
|
|
|
163
195
|
};
|
|
164
196
|
|
|
165
197
|
return (
|
|
166
|
-
<div className="mb-4 rounded-lg border border-
|
|
198
|
+
<div className="mb-4 rounded-lg border border-line-strong bg-sunken divide-y divide-line">
|
|
167
199
|
{visible.map((key) => {
|
|
168
200
|
const oldVal = formatValue(oldData[key]);
|
|
169
201
|
const newVal = formatValue(newData[key]);
|
|
170
202
|
const changed = oldVal !== newVal;
|
|
171
203
|
return (
|
|
172
204
|
<div key={key} className="flex items-start gap-3 px-3 py-2 text-xs">
|
|
173
|
-
<span className="shrink-0 text-
|
|
205
|
+
<span className="shrink-0 text-ink-muted w-28">{labelFor(key)}</span>
|
|
174
206
|
{changed ? (
|
|
175
207
|
<div className="flex-1 space-y-1 break-words">
|
|
176
208
|
{oldVal && (
|
|
@@ -181,7 +213,7 @@ function FrontmatterDiffPanel({
|
|
|
181
213
|
)}
|
|
182
214
|
</div>
|
|
183
215
|
) : (
|
|
184
|
-
<span className="text-
|
|
216
|
+
<span className="text-ink break-words">{oldVal}</span>
|
|
185
217
|
)}
|
|
186
218
|
</div>
|
|
187
219
|
);
|
|
@@ -228,31 +260,57 @@ function groupDiffBlocks(lines: DiffLine[]): DisplayBlock[] {
|
|
|
228
260
|
return result;
|
|
229
261
|
}
|
|
230
262
|
|
|
231
|
-
function DiffPreview({
|
|
263
|
+
function DiffPreview({
|
|
264
|
+
blocks,
|
|
265
|
+
onOpenFile,
|
|
266
|
+
onOpenNodeId,
|
|
267
|
+
}: {
|
|
268
|
+
blocks: DisplayBlock[];
|
|
269
|
+
onOpenFile?: (href: string) => void;
|
|
270
|
+
onOpenNodeId?: (id: string) => void;
|
|
271
|
+
}) {
|
|
272
|
+
// `'source'`: a diagram whose ```mermaid fence straddles a change boundary
|
|
273
|
+
// reaches the renderer truncated and cannot parse, so the error box would
|
|
274
|
+
// replace the red/green source — the only useful content in that block — on
|
|
275
|
+
// every EDITED diagram. Untouched ones sit whole inside a single unchanged
|
|
276
|
+
// fragment and still render as diagrams.
|
|
277
|
+
//
|
|
278
|
+
// No `headingLink`: a diff shows no copy-anchor buttons, and the slug ids
|
|
279
|
+
// they depend on are deliberately absent (see KB_DIFF_REHYPE_PLUGINS).
|
|
280
|
+
const components = useKbMarkdownComponents({
|
|
281
|
+
onOpenFile,
|
|
282
|
+
onOpenNodeId,
|
|
283
|
+
onMermaidError: 'source',
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
// Each block is parsed as a standalone document, so the space-escaping that
|
|
287
|
+
// makes `[Foo](Some File.md)` resolve has to be applied per fragment.
|
|
288
|
+
const fragment = (text: string) => (
|
|
289
|
+
<Markdown
|
|
290
|
+
remarkPlugins={KB_REMARK_PLUGINS}
|
|
291
|
+
rehypePlugins={KB_DIFF_REHYPE_PLUGINS}
|
|
292
|
+
components={components}
|
|
293
|
+
>
|
|
294
|
+
{escapeSpacesInLinkDestinations(text)}
|
|
295
|
+
</Markdown>
|
|
296
|
+
);
|
|
297
|
+
|
|
232
298
|
return (
|
|
233
299
|
<div className="prose prose-sm max-w-none">
|
|
234
300
|
{blocks.map((block, i) => {
|
|
235
301
|
if (block.type === 'same') {
|
|
236
|
-
return (
|
|
237
|
-
<Markdown key={i} remarkPlugins={[remarkGfm, remarkFrontmatter]} components={MD_COMPONENTS}>
|
|
238
|
-
{block.lines.join('\n')}
|
|
239
|
-
</Markdown>
|
|
240
|
-
);
|
|
302
|
+
return <div key={i}>{fragment(block.lines.join('\n'))}</div>;
|
|
241
303
|
}
|
|
242
304
|
return (
|
|
243
305
|
<div key={i} className="my-2">
|
|
244
306
|
{block.removed.length > 0 && (
|
|
245
307
|
<div className="bg-red-50 border-l-2 border-red-700 px-3 py-1 rounded-sm">
|
|
246
|
-
|
|
247
|
-
{block.removed.join('\n')}
|
|
248
|
-
</Markdown>
|
|
308
|
+
{fragment(block.removed.join('\n'))}
|
|
249
309
|
</div>
|
|
250
310
|
)}
|
|
251
311
|
{block.added.length > 0 && (
|
|
252
312
|
<div className="bg-emerald-50 border-l-2 border-emerald-700 px-3 py-1 rounded-sm mt-1">
|
|
253
|
-
|
|
254
|
-
{block.added.join('\n')}
|
|
255
|
-
</Markdown>
|
|
313
|
+
{fragment(block.added.join('\n'))}
|
|
256
314
|
</div>
|
|
257
315
|
)}
|
|
258
316
|
</div>
|
|
@@ -24,7 +24,7 @@ function KindIcon({ kind }: { kind: PendingChange['kind'] }) {
|
|
|
24
24
|
switch (kind) {
|
|
25
25
|
case 'added': return <FilePlus2 size={size} className="text-emerald-600" />;
|
|
26
26
|
case 'deleted': return <FileX2 size={size} className="text-red-600" />;
|
|
27
|
-
case 'renamed': return <ArrowRightLeft size={size} className="text-
|
|
27
|
+
case 'renamed': return <ArrowRightLeft size={size} className="text-accent" />;
|
|
28
28
|
case 'modified': return <FileEdit size={size} className="text-amber-600" />;
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -49,20 +49,20 @@ export function ReviewFileRow({ change, active, busy, onSelect, onAccept, onReje
|
|
|
49
49
|
}}
|
|
50
50
|
className={`group flex items-center gap-2 px-2 py-1.5 rounded cursor-pointer transition-colors border ${
|
|
51
51
|
active
|
|
52
|
-
? 'bg-
|
|
53
|
-
: 'bg-white border-transparent hover:bg-
|
|
52
|
+
? 'bg-sunken border-line-strong'
|
|
53
|
+
: 'bg-white border-transparent hover:bg-hover hover:border-line'
|
|
54
54
|
}`}
|
|
55
55
|
>
|
|
56
56
|
<KindIcon kind={kind} />
|
|
57
57
|
|
|
58
58
|
<div className="flex-1 min-w-0">
|
|
59
|
-
<div className="flex items-center gap-1.5 text-xs text-
|
|
59
|
+
<div className="flex items-center gap-1.5 text-xs text-ink truncate">
|
|
60
60
|
<span className="truncate font-mono" title={path}>{path}</span>
|
|
61
|
-
<span className="text-[10px] uppercase tracking-wider text-
|
|
61
|
+
<span className="text-[10px] uppercase tracking-wider text-ink-muted shrink-0">
|
|
62
62
|
{kindLabel(kind)}
|
|
63
63
|
</span>
|
|
64
64
|
</div>
|
|
65
|
-
<div className="flex items-center gap-2 text-[10px] text-
|
|
65
|
+
<div className="flex items-center gap-2 text-[10px] text-ink-muted mt-0.5">
|
|
66
66
|
{oldPath && kind === 'renamed' && (
|
|
67
67
|
<span className="font-mono truncate" title={oldPath}>from {oldPath}</span>
|
|
68
68
|
)}
|
|
@@ -89,9 +89,9 @@ export function ReviewFileRow({ change, active, busy, onSelect, onAccept, onReje
|
|
|
89
89
|
e.stopPropagation();
|
|
90
90
|
onReject();
|
|
91
91
|
}}
|
|
92
|
-
title="Reject
|
|
92
|
+
title="Reject: restore the original"
|
|
93
93
|
aria-label={`Reject change to ${path}`}
|
|
94
|
-
className="p-1 rounded text-
|
|
94
|
+
className="p-1 rounded text-ink-muted hover:text-red-700 hover:bg-red-100 disabled:opacity-40 disabled:cursor-not-allowed"
|
|
95
95
|
>
|
|
96
96
|
<X size={13} />
|
|
97
97
|
</button>
|
|
@@ -102,9 +102,9 @@ export function ReviewFileRow({ change, active, busy, onSelect, onAccept, onReje
|
|
|
102
102
|
e.stopPropagation();
|
|
103
103
|
onAccept();
|
|
104
104
|
}}
|
|
105
|
-
title="Accept
|
|
105
|
+
title="Accept: keep this change"
|
|
106
106
|
aria-label={`Accept change to ${path}`}
|
|
107
|
-
className="p-1 rounded text-
|
|
107
|
+
className="p-1 rounded text-ink-muted hover:text-emerald-700 hover:bg-emerald-100 disabled:opacity-40 disabled:cursor-not-allowed"
|
|
108
108
|
>
|
|
109
109
|
<Check size={13} />
|
|
110
110
|
</button>
|