@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,200 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
-
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
|
|
3
|
-
import { MemoryRouter } from 'react-router-dom';
|
|
4
|
-
import type { ReactNode } from 'react';
|
|
5
|
-
import {
|
|
6
|
-
WorkspaceContext,
|
|
7
|
-
type WorkspaceContextValue,
|
|
8
|
-
} from '../../workspace/state/workspace.context';
|
|
9
|
-
import { AuthContext, type AuthContextValue } from '../../auth/state/auth.context';
|
|
10
|
-
import type { ToolSecrets } from '../../secrets-vault/services/tool-secrets.api';
|
|
11
|
-
|
|
12
|
-
// Service mocks — the dialog's data loading goes through the module's api
|
|
13
|
-
// service (which wraps authFetch), so mocking here follows the same pattern
|
|
14
|
-
// as the other modules' tests.
|
|
15
|
-
const apiMock = vi.hoisted(() => ({
|
|
16
|
-
getSkill: vi.fn(),
|
|
17
|
-
getSkillFile: vi.fn(),
|
|
18
|
-
readFileOnBranch: vi.fn(),
|
|
19
|
-
suggestChange: vi.fn(),
|
|
20
|
-
}));
|
|
21
|
-
vi.mock('../services/library.api', () => ({
|
|
22
|
-
DEFAULT_WORKSPACE_ID: 'target-company-state',
|
|
23
|
-
getSkill: apiMock.getSkill,
|
|
24
|
-
getSkillFile: apiMock.getSkillFile,
|
|
25
|
-
readFileOnBranch: apiMock.readFileOnBranch,
|
|
26
|
-
suggestChange: apiMock.suggestChange,
|
|
27
|
-
listSkills: vi.fn(),
|
|
28
|
-
listOpenChangeRequests: vi.fn(),
|
|
29
|
-
listMyChangeRequests: vi.fn(),
|
|
30
|
-
suggestionBranchFor: vi.fn(),
|
|
31
|
-
}));
|
|
32
|
-
|
|
33
|
-
// Keep the markdown pipeline (mermaid etc.) out of this test — the stub
|
|
34
|
-
// renders the raw source so assertions can see the body text.
|
|
35
|
-
vi.mock('../../workspace/components/renderers/KbMarkdownView', () => ({
|
|
36
|
-
KbMarkdownView: ({ source }: { source: string }) => <div data-testid="md-view">{source}</div>,
|
|
37
|
-
}));
|
|
38
|
-
|
|
39
|
-
import { DetailDialog } from '../components/DetailDialog';
|
|
40
|
-
|
|
41
|
-
const workspace = {
|
|
42
|
-
workspaceId: 'target-company-state',
|
|
43
|
-
kbDirName: 'knowledge-base',
|
|
44
|
-
} as unknown as WorkspaceContextValue;
|
|
45
|
-
|
|
46
|
-
const auth = {
|
|
47
|
-
user: { id: 'u1', email: 'razvan@bevel.software', name: 'Razvan' },
|
|
48
|
-
token: 't',
|
|
49
|
-
isLoading: false,
|
|
50
|
-
login: async () => {},
|
|
51
|
-
logout: () => {},
|
|
52
|
-
} as AuthContextValue;
|
|
53
|
-
|
|
54
|
-
function wrap(children: ReactNode) {
|
|
55
|
-
return (
|
|
56
|
-
<MemoryRouter>
|
|
57
|
-
<AuthContext.Provider value={auth}>
|
|
58
|
-
<WorkspaceContext.Provider value={workspace}>{children}</WorkspaceContext.Provider>
|
|
59
|
-
</AuthContext.Provider>
|
|
60
|
-
</MemoryRouter>
|
|
61
|
-
);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const skillSummary = {
|
|
65
|
-
name: 'newsletter',
|
|
66
|
-
description: 'Drafts the Friday newsletter for review.',
|
|
67
|
-
path: 'Skills/newsletter',
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const skillDetail = {
|
|
71
|
-
...skillSummary,
|
|
72
|
-
body: '# Newsletter drafter\nCollect the news and draft the letter.',
|
|
73
|
-
allowedTools: ['slack_post_message'],
|
|
74
|
-
files: ['Skills/newsletter/sources.yaml'],
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
const slackTool: ToolSecrets = {
|
|
78
|
-
slug: 'slack',
|
|
79
|
-
name: 'slack',
|
|
80
|
-
path: 'Tools/slack.tool',
|
|
81
|
-
type: 'http',
|
|
82
|
-
setup: null,
|
|
83
|
-
canWrite: false,
|
|
84
|
-
variables: [
|
|
85
|
-
{
|
|
86
|
-
name: 'SIGNIN',
|
|
87
|
-
scope: 'user',
|
|
88
|
-
label: 'Slack sign-in',
|
|
89
|
-
key: 'slack_SIGNIN',
|
|
90
|
-
adminConfigured: true,
|
|
91
|
-
userConfigured: false,
|
|
92
|
-
oauth: true,
|
|
93
|
-
authorized: false,
|
|
94
|
-
},
|
|
95
|
-
],
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
function renderDialog(owned: boolean) {
|
|
99
|
-
return render(
|
|
100
|
-
wrap(
|
|
101
|
-
<DetailDialog
|
|
102
|
-
target={{ kind: 'skill', skill: skillSummary, owned }}
|
|
103
|
-
tools={[slackTool]}
|
|
104
|
-
skills={[skillSummary]}
|
|
105
|
-
allowedToolsBySkill={new Map([['newsletter', ['slack_post_message']]])}
|
|
106
|
-
crs={[]}
|
|
107
|
-
myCrNumbers={new Set()}
|
|
108
|
-
inLoadout={false}
|
|
109
|
-
onToggleLoadout={() => {}}
|
|
110
|
-
onClose={() => {}}
|
|
111
|
-
onDataChanged={() => {}}
|
|
112
|
-
/>,
|
|
113
|
-
),
|
|
114
|
-
);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
beforeEach(() => {
|
|
118
|
-
apiMock.getSkill.mockReset().mockResolvedValue(skillDetail);
|
|
119
|
-
apiMock.getSkillFile.mockReset().mockResolvedValue('watchlist:\n - topic: AI');
|
|
120
|
-
apiMock.readFileOnBranch.mockReset().mockResolvedValue('');
|
|
121
|
-
apiMock.suggestChange.mockReset();
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
describe('DetailDialog (skill)', () => {
|
|
125
|
-
it('loads the skill detail and shows description, needed integrations and files', async () => {
|
|
126
|
-
renderDialog(false);
|
|
127
|
-
|
|
128
|
-
expect(await screen.findByText('Drafts the Friday newsletter for review.')).toBeInTheDocument();
|
|
129
|
-
expect(apiMock.getSkill).toHaveBeenCalledWith('newsletter');
|
|
130
|
-
|
|
131
|
-
// Needed integration derived from allowed-tools, with its connection state.
|
|
132
|
-
expect(screen.getByText('slack')).toBeInTheDocument();
|
|
133
|
-
expect(screen.getByText('Needs your sign-in')).toBeInTheDocument();
|
|
134
|
-
expect(screen.getByRole('button', { name: /Connect/ })).toBeInTheDocument();
|
|
135
|
-
|
|
136
|
-
// File browser: SKILL.md tagged MAIN + the bundled file.
|
|
137
|
-
expect(screen.getAllByText('SKILL.md').length).toBeGreaterThan(0);
|
|
138
|
-
expect(screen.getByText('MAIN')).toBeInTheDocument();
|
|
139
|
-
expect(screen.getByText('sources.yaml')).toBeInTheDocument();
|
|
140
|
-
|
|
141
|
-
// SKILL.md body renders through the markdown view.
|
|
142
|
-
expect(screen.getByTestId('md-view').textContent).toContain('Collect the news');
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
it('loads a bundled file on click and renders it as code', async () => {
|
|
146
|
-
renderDialog(false);
|
|
147
|
-
await screen.findByText('sources.yaml');
|
|
148
|
-
|
|
149
|
-
fireEvent.click(screen.getByText('sources.yaml'));
|
|
150
|
-
await waitFor(() =>
|
|
151
|
-
expect(apiMock.getSkillFile).toHaveBeenCalledWith('newsletter', 'sources.yaml'),
|
|
152
|
-
);
|
|
153
|
-
expect(await screen.findByText(/topic: AI/)).toBeInTheDocument();
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
it('shows owner-only Edit and Manage access when the caller owns the skill', async () => {
|
|
157
|
-
renderDialog(true);
|
|
158
|
-
await screen.findByText('Drafts the Friday newsletter for review.');
|
|
159
|
-
|
|
160
|
-
expect(screen.getByRole('button', { name: 'Manage access' })).toBeInTheDocument();
|
|
161
|
-
expect(screen.getByRole('button', { name: 'Edit' })).toBeInTheDocument();
|
|
162
|
-
expect(screen.getByText('OWNER')).toBeInTheDocument();
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
it('hides Edit and Manage access for non-owners', async () => {
|
|
166
|
-
renderDialog(false);
|
|
167
|
-
await screen.findByText('Drafts the Friday newsletter for review.');
|
|
168
|
-
|
|
169
|
-
expect(screen.queryByRole('button', { name: 'Manage access' })).toBeNull();
|
|
170
|
-
expect(screen.queryByRole('button', { name: 'Edit' })).toBeNull();
|
|
171
|
-
expect(screen.queryByText('OWNER')).toBeNull();
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
describe('DetailDialog (integration)', () => {
|
|
176
|
-
it('shows per-connection status with a Connect action and the skills using it', async () => {
|
|
177
|
-
render(
|
|
178
|
-
wrap(
|
|
179
|
-
<DetailDialog
|
|
180
|
-
target={{ kind: 'integration', tool: slackTool }}
|
|
181
|
-
tools={[slackTool]}
|
|
182
|
-
skills={[skillSummary]}
|
|
183
|
-
allowedToolsBySkill={new Map([['newsletter', ['slack_post_message']]])}
|
|
184
|
-
crs={[]}
|
|
185
|
-
myCrNumbers={new Set()}
|
|
186
|
-
inLoadout={false}
|
|
187
|
-
onToggleLoadout={() => {}}
|
|
188
|
-
onClose={() => {}}
|
|
189
|
-
onDataChanged={() => {}}
|
|
190
|
-
/>,
|
|
191
|
-
),
|
|
192
|
-
);
|
|
193
|
-
|
|
194
|
-
expect(screen.getByText('Slack sign-in')).toBeInTheDocument();
|
|
195
|
-
expect(screen.getByText('Needs your sign-in')).toBeInTheDocument();
|
|
196
|
-
expect(screen.getByRole('button', { name: /Connect/ })).toBeInTheDocument();
|
|
197
|
-
// Used by: derived from the skills' allowed-tools.
|
|
198
|
-
expect(screen.getByText('newsletter')).toBeInTheDocument();
|
|
199
|
-
});
|
|
200
|
-
});
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { diffLines, hasChanges } from '../utils/diff';
|
|
3
|
-
|
|
4
|
-
describe('diffLines (LCS line differ)', () => {
|
|
5
|
-
it('reports identical content as all-same', () => {
|
|
6
|
-
const d = diffLines('a\nb\nc', 'a\nb\nc');
|
|
7
|
-
expect(d).toEqual([
|
|
8
|
-
{ kind: 'same', text: 'a' },
|
|
9
|
-
{ kind: 'same', text: 'b' },
|
|
10
|
-
{ kind: 'same', text: 'c' },
|
|
11
|
-
]);
|
|
12
|
-
expect(hasChanges(d)).toBe(false);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('marks a replaced line as removed-then-added in place', () => {
|
|
16
|
-
const d = diffLines('one\ntwo\nthree', 'one\nTWO\nthree');
|
|
17
|
-
expect(d).toEqual([
|
|
18
|
-
{ kind: 'same', text: 'one' },
|
|
19
|
-
{ kind: 'removed', text: 'two' },
|
|
20
|
-
{ kind: 'added', text: 'TWO' },
|
|
21
|
-
{ kind: 'same', text: 'three' },
|
|
22
|
-
]);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('handles pure insertions and deletions', () => {
|
|
26
|
-
expect(diffLines('a\nc', 'a\nb\nc')).toEqual([
|
|
27
|
-
{ kind: 'same', text: 'a' },
|
|
28
|
-
{ kind: 'added', text: 'b' },
|
|
29
|
-
{ kind: 'same', text: 'c' },
|
|
30
|
-
]);
|
|
31
|
-
expect(diffLines('a\nb\nc', 'a\nc')).toEqual([
|
|
32
|
-
{ kind: 'same', text: 'a' },
|
|
33
|
-
{ kind: 'removed', text: 'b' },
|
|
34
|
-
{ kind: 'same', text: 'c' },
|
|
35
|
-
]);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('keeps unrelated equal lines matched across a multi-line rewrite', () => {
|
|
39
|
-
const before = '# title\nstep 1\nstep 2\nstep 3\nfooter';
|
|
40
|
-
const after = '# title\nstep 1 tightened\nstep 3\nnew step 4\nfooter';
|
|
41
|
-
const d = diffLines(before, after);
|
|
42
|
-
expect(d.filter((l) => l.kind === 'same').map((l) => l.text)).toEqual([
|
|
43
|
-
'# title',
|
|
44
|
-
'step 3',
|
|
45
|
-
'footer',
|
|
46
|
-
]);
|
|
47
|
-
expect(d.filter((l) => l.kind === 'removed').map((l) => l.text)).toEqual([
|
|
48
|
-
'step 1',
|
|
49
|
-
'step 2',
|
|
50
|
-
]);
|
|
51
|
-
expect(d.filter((l) => l.kind === 'added').map((l) => l.text)).toEqual([
|
|
52
|
-
'step 1 tightened',
|
|
53
|
-
'new step 4',
|
|
54
|
-
]);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it('handles empty sides and trailing newlines', () => {
|
|
58
|
-
expect(diffLines('', 'a\n')).toEqual([{ kind: 'added', text: 'a' }]);
|
|
59
|
-
expect(diffLines('a\n', '')).toEqual([{ kind: 'removed', text: 'a' }]);
|
|
60
|
-
expect(diffLines('', '')).toEqual([]);
|
|
61
|
-
});
|
|
62
|
-
});
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { renderHook, act } from '@testing-library/react';
|
|
3
|
-
import type { ReactNode } from 'react';
|
|
4
|
-
import { LoadoutProvider, useLoadout, LOADOUT_STORAGE_KEY } from '../state/loadout';
|
|
5
|
-
|
|
6
|
-
const wrapper = ({ children }: { children: ReactNode }) => (
|
|
7
|
-
<LoadoutProvider>{children}</LoadoutProvider>
|
|
8
|
-
);
|
|
9
|
-
|
|
10
|
-
describe('loadout (client-side stub)', () => {
|
|
11
|
-
it('starts empty and adds/removes on toggle', () => {
|
|
12
|
-
const { result } = renderHook(() => useLoadout(), { wrapper });
|
|
13
|
-
expect(result.current.total).toBe(0);
|
|
14
|
-
|
|
15
|
-
let added = false;
|
|
16
|
-
act(() => {
|
|
17
|
-
added = result.current.toggle('skill', 'newsletter');
|
|
18
|
-
});
|
|
19
|
-
expect(added).toBe(true);
|
|
20
|
-
expect(result.current.isIn('skill', 'newsletter')).toBe(true);
|
|
21
|
-
expect(result.current.total).toBe(1);
|
|
22
|
-
|
|
23
|
-
act(() => {
|
|
24
|
-
result.current.toggle('integration', 'slack');
|
|
25
|
-
});
|
|
26
|
-
expect(result.current.total).toBe(2);
|
|
27
|
-
expect(result.current.integrations).toEqual(['slack']);
|
|
28
|
-
|
|
29
|
-
act(() => {
|
|
30
|
-
added = result.current.toggle('skill', 'newsletter');
|
|
31
|
-
});
|
|
32
|
-
expect(added).toBe(false);
|
|
33
|
-
expect(result.current.isIn('skill', 'newsletter')).toBe(false);
|
|
34
|
-
expect(result.current.total).toBe(1);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('remove drops only the targeted item', () => {
|
|
38
|
-
const { result } = renderHook(() => useLoadout(), { wrapper });
|
|
39
|
-
act(() => {
|
|
40
|
-
result.current.toggle('skill', 'a');
|
|
41
|
-
result.current.toggle('skill', 'b');
|
|
42
|
-
});
|
|
43
|
-
act(() => {
|
|
44
|
-
result.current.remove('skill', 'a');
|
|
45
|
-
});
|
|
46
|
-
expect(result.current.skills).toEqual(['b']);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('persists to localStorage under bevel-library-loadout-v1 and survives a remount', () => {
|
|
50
|
-
const first = renderHook(() => useLoadout(), { wrapper });
|
|
51
|
-
act(() => {
|
|
52
|
-
first.result.current.toggle('skill', 'rfi');
|
|
53
|
-
first.result.current.toggle('integration', 'github');
|
|
54
|
-
});
|
|
55
|
-
const raw = localStorage.getItem(LOADOUT_STORAGE_KEY);
|
|
56
|
-
expect(raw).not.toBeNull();
|
|
57
|
-
expect(JSON.parse(raw!)).toEqual({ skills: ['rfi'], integrations: ['github'] });
|
|
58
|
-
first.unmount();
|
|
59
|
-
|
|
60
|
-
// A fresh provider (new session) reads the persisted loadout back.
|
|
61
|
-
const second = renderHook(() => useLoadout(), { wrapper });
|
|
62
|
-
expect(second.result.current.isIn('skill', 'rfi')).toBe(true);
|
|
63
|
-
expect(second.result.current.isIn('integration', 'github')).toBe(true);
|
|
64
|
-
expect(second.result.current.total).toBe(2);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('tolerates corrupted stored state', () => {
|
|
68
|
-
localStorage.setItem(LOADOUT_STORAGE_KEY, '{not json');
|
|
69
|
-
const { result } = renderHook(() => useLoadout(), { wrapper });
|
|
70
|
-
expect(result.current.total).toBe(0);
|
|
71
|
-
});
|
|
72
|
-
});
|
|
@@ -1,357 +0,0 @@
|
|
|
1
|
-
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
-
import { useNavigate } from 'react-router-dom';
|
|
3
|
-
import {
|
|
4
|
-
DEFAULT_BRANCH,
|
|
5
|
-
protectedBranchDisplayName,
|
|
6
|
-
type PullRequestDetail,
|
|
7
|
-
type PullRequestSummary,
|
|
8
|
-
} from '@bevel-software/platform-shared';
|
|
9
|
-
import { useModalLayer } from '../../../shared/components/useModalLayer';
|
|
10
|
-
import { useWorkspace } from '../../workspace/state/workspace.context';
|
|
11
|
-
import { kbFileUrl } from '../../workspace/routing/kb-routes';
|
|
12
|
-
import { fetchPrDetail } from '../../pr/services/pr-detail.api';
|
|
13
|
-
import { mergePullRequest } from '../../pr/services/pr-merge.api';
|
|
14
|
-
import { cancelPullRequest } from '../../pr/services/pr-cancel.api';
|
|
15
|
-
import { postPrComment } from '../../pr/services/pr-comments.api';
|
|
16
|
-
import { readFileOnBranch, type LibrarySkill } from '../services/library.api';
|
|
17
|
-
import { diffLines, type DiffLine } from '../utils/diff';
|
|
18
|
-
|
|
19
|
-
interface CompareViewProps {
|
|
20
|
-
skill: LibrarySkill;
|
|
21
|
-
/** Content of a main-side file (SKILL.md body included), null while loading. */
|
|
22
|
-
mainContent(relFile: string): string | null;
|
|
23
|
-
loadMainFile(relFile: string): void;
|
|
24
|
-
cr: PullRequestSummary;
|
|
25
|
-
onClose(): void;
|
|
26
|
-
onResolved(kind: 'applied' | 'sent-back'): void;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Owner review = compare, not overlay: two panels side by side — left is the
|
|
31
|
-
* skill on the default branch, right is the change-request branch. Removed
|
|
32
|
-
* text tints red on the left, added text green on the right (via the module's
|
|
33
|
-
* line differ over real per-branch file contents); changed files get an amber
|
|
34
|
-
* dot in both lists, files new on the branch get a NEW row. Apply / Send back
|
|
35
|
-
* act through the existing change-request services. Esc exits the compare
|
|
36
|
-
* (registered as its own modal layer so the detail dialog beneath survives).
|
|
37
|
-
*/
|
|
38
|
-
export function CompareView({
|
|
39
|
-
skill,
|
|
40
|
-
mainContent,
|
|
41
|
-
loadMainFile,
|
|
42
|
-
cr,
|
|
43
|
-
onClose,
|
|
44
|
-
onResolved,
|
|
45
|
-
}: CompareViewProps) {
|
|
46
|
-
const navigate = useNavigate();
|
|
47
|
-
const { kbDirName } = useWorkspace();
|
|
48
|
-
const [detail, setDetail] = useState<PullRequestDetail | null>(null);
|
|
49
|
-
const [error, setError] = useState<string | null>(null);
|
|
50
|
-
const [branchContents, setBranchContents] = useState<Record<string, string | null>>({});
|
|
51
|
-
const [busy, setBusy] = useState(false);
|
|
52
|
-
const [sendBackOpen, setSendBackOpen] = useState(false);
|
|
53
|
-
const [sendBackNote, setSendBackNote] = useState('');
|
|
54
|
-
|
|
55
|
-
const isTop = useModalLayer(true);
|
|
56
|
-
useEffect(() => {
|
|
57
|
-
function onKeyDown(e: KeyboardEvent) {
|
|
58
|
-
if (e.key === 'Escape' && isTop()) {
|
|
59
|
-
e.stopPropagation();
|
|
60
|
-
onClose();
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
document.addEventListener('keydown', onKeyDown);
|
|
64
|
-
return () => document.removeEventListener('keydown', onKeyDown);
|
|
65
|
-
}, [isTop, onClose]);
|
|
66
|
-
|
|
67
|
-
useEffect(() => {
|
|
68
|
-
let cancelled = false;
|
|
69
|
-
fetchPrDetail(cr.number)
|
|
70
|
-
.then((d) => {
|
|
71
|
-
if (!cancelled) setDetail(d);
|
|
72
|
-
})
|
|
73
|
-
.catch((err) => {
|
|
74
|
-
if (!cancelled) setError(err instanceof Error ? err.message : "Couldn't load this change request.");
|
|
75
|
-
});
|
|
76
|
-
return () => {
|
|
77
|
-
cancelled = true;
|
|
78
|
-
};
|
|
79
|
-
}, [cr.number]);
|
|
80
|
-
|
|
81
|
-
const prefix = `${skill.path}/`;
|
|
82
|
-
const mainFiles = useMemo(
|
|
83
|
-
() => ['SKILL.md', ...skill.files.map((f) => f.slice(prefix.length))],
|
|
84
|
-
[skill.files, prefix],
|
|
85
|
-
);
|
|
86
|
-
const changedFiles = useMemo(() => {
|
|
87
|
-
const set = new Set<string>();
|
|
88
|
-
for (const f of detail?.files ?? []) {
|
|
89
|
-
if (f.path.startsWith(prefix)) set.add(f.path.slice(prefix.length));
|
|
90
|
-
}
|
|
91
|
-
return set;
|
|
92
|
-
}, [detail, prefix]);
|
|
93
|
-
const addedFiles = useMemo(
|
|
94
|
-
() =>
|
|
95
|
-
(detail?.files ?? [])
|
|
96
|
-
.filter((f) => f.status === 'added' && f.path.startsWith(prefix))
|
|
97
|
-
.map((f) => f.path.slice(prefix.length)),
|
|
98
|
-
[detail, prefix],
|
|
99
|
-
);
|
|
100
|
-
const outsideCount = useMemo(
|
|
101
|
-
() => (detail?.files ?? []).filter((f) => !f.path.startsWith(prefix)).length,
|
|
102
|
-
[detail, prefix],
|
|
103
|
-
);
|
|
104
|
-
const branchFiles = useMemo(
|
|
105
|
-
() => [...mainFiles, ...addedFiles.filter((f) => !mainFiles.includes(f))],
|
|
106
|
-
[mainFiles, addedFiles],
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
// Land on the first changed (or added) file once the detail is in.
|
|
110
|
-
const [selected, setSelected] = useState<string>('SKILL.md');
|
|
111
|
-
const landed = useRef(false);
|
|
112
|
-
useEffect(() => {
|
|
113
|
-
if (!detail || landed.current) return;
|
|
114
|
-
landed.current = true;
|
|
115
|
-
const first = branchFiles.find((f) => changedFiles.has(f));
|
|
116
|
-
if (first) setSelected(first);
|
|
117
|
-
}, [detail, branchFiles, changedFiles]);
|
|
118
|
-
|
|
119
|
-
const loadBranchFile = useCallback(
|
|
120
|
-
(rel: string) => {
|
|
121
|
-
if (branchContents[rel] !== undefined) return;
|
|
122
|
-
setBranchContents((c) => ({ ...c, [rel]: null }));
|
|
123
|
-
readFileOnBranch(cr.branch, `${skill.path}/${rel}`)
|
|
124
|
-
.then((content) => setBranchContents((c) => ({ ...c, [rel]: content })))
|
|
125
|
-
.catch(() => setBranchContents((c) => ({ ...c, [rel]: '' })));
|
|
126
|
-
},
|
|
127
|
-
[branchContents, cr.branch, skill.path],
|
|
128
|
-
);
|
|
129
|
-
|
|
130
|
-
useEffect(() => {
|
|
131
|
-
loadBranchFile(selected);
|
|
132
|
-
if (!addedFiles.includes(selected)) loadMainFile(selected);
|
|
133
|
-
}, [selected, loadBranchFile, loadMainFile, addedFiles]);
|
|
134
|
-
|
|
135
|
-
const isAdded = addedFiles.includes(selected);
|
|
136
|
-
const mainRaw = isAdded ? null : mainContent(selected);
|
|
137
|
-
const branchRaw = branchContents[selected] ?? null;
|
|
138
|
-
const diff: DiffLine[] | null =
|
|
139
|
-
!isAdded && mainRaw !== null && branchRaw !== null ? diffLines(mainRaw, branchRaw) : null;
|
|
140
|
-
|
|
141
|
-
async function applyChanges() {
|
|
142
|
-
setBusy(true);
|
|
143
|
-
setError(null);
|
|
144
|
-
try {
|
|
145
|
-
await mergePullRequest(cr.number);
|
|
146
|
-
onResolved('applied');
|
|
147
|
-
} catch (err) {
|
|
148
|
-
setError(err instanceof Error ? err.message : "Couldn't apply this change request.");
|
|
149
|
-
setBusy(false);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
async function sendBack() {
|
|
154
|
-
setBusy(true);
|
|
155
|
-
setError(null);
|
|
156
|
-
try {
|
|
157
|
-
const note = sendBackNote.trim();
|
|
158
|
-
if (note) await postPrComment(cr.number, { body: note });
|
|
159
|
-
await cancelPullRequest(cr.number);
|
|
160
|
-
onResolved('sent-back');
|
|
161
|
-
} catch (err) {
|
|
162
|
-
setError(err instanceof Error ? err.message : "Couldn't send this change request back.");
|
|
163
|
-
setBusy(false);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
const fileRow = (rel: string, side: 'main' | 'branch') => {
|
|
168
|
-
const added = addedFiles.includes(rel);
|
|
169
|
-
const active = selected === rel;
|
|
170
|
-
return (
|
|
171
|
-
<button
|
|
172
|
-
key={rel}
|
|
173
|
-
type="button"
|
|
174
|
-
className={`flex w-full items-center gap-2 rounded-[9px] border px-2.5 py-1.5 text-left transition-colors ${
|
|
175
|
-
active
|
|
176
|
-
? 'border-[#0d9488] bg-[#e6f7f4]'
|
|
177
|
-
: added
|
|
178
|
-
? 'border-[#a9e8cd] bg-[#f2fcf8] hover:border-[#7fd0c4]'
|
|
179
|
-
: 'border-slate-200 bg-[#fafbfd] hover:border-[#7fd0c4]'
|
|
180
|
-
}`}
|
|
181
|
-
onClick={() => setSelected(rel)}
|
|
182
|
-
>
|
|
183
|
-
<span className={`font-mono text-[11.5px] font-semibold ${active ? 'text-[#0f766e]' : 'text-slate-600'}`}>
|
|
184
|
-
{rel}
|
|
185
|
-
</span>
|
|
186
|
-
{rel === 'SKILL.md' && (
|
|
187
|
-
<span className="rounded-full bg-white px-1.5 text-[9.5px] font-bold tracking-[.04em] text-[#0f766e] shadow-[inset_0_0_0_1px_#d2e9e4]">
|
|
188
|
-
MAIN
|
|
189
|
-
</span>
|
|
190
|
-
)}
|
|
191
|
-
{added && side === 'branch' && (
|
|
192
|
-
<span className="rounded-full bg-[#e0f8ee] px-1.5 text-[9.5px] font-bold tracking-[.04em] text-[#0a8f60]">
|
|
193
|
-
NEW
|
|
194
|
-
</span>
|
|
195
|
-
)}
|
|
196
|
-
{!added && changedFiles.has(rel) && (
|
|
197
|
-
<span
|
|
198
|
-
className="h-[7px] w-[7px] shrink-0 rounded-full bg-[#f59e0b]"
|
|
199
|
-
title="Changed in this request"
|
|
200
|
-
/>
|
|
201
|
-
)}
|
|
202
|
-
</button>
|
|
203
|
-
);
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
const lineView = (lines: DiffLine[] | null, raw: string | null, hide: 'added' | 'removed') => {
|
|
207
|
-
if (raw === null && lines === null) {
|
|
208
|
-
return <div className="p-3 text-xs text-slate-400">Loading…</div>;
|
|
209
|
-
}
|
|
210
|
-
const rendered = lines
|
|
211
|
-
? lines.filter((l) => l.kind !== hide)
|
|
212
|
-
: (raw ?? '').split('\n').map((text) => ({ kind: 'same' as const, text }));
|
|
213
|
-
return (
|
|
214
|
-
<pre className="whitespace-pre-wrap break-words rounded-[13px] border border-slate-200 bg-[#f7f9fb] p-3 font-mono text-[11.5px] leading-relaxed text-slate-600">
|
|
215
|
-
{rendered.map((l, i) => (
|
|
216
|
-
<div
|
|
217
|
-
key={i}
|
|
218
|
-
className={
|
|
219
|
-
l.kind === 'removed'
|
|
220
|
-
? 'lib-line-removed rounded px-1'
|
|
221
|
-
: l.kind === 'added'
|
|
222
|
-
? 'lib-line-added rounded px-1'
|
|
223
|
-
: 'px-1'
|
|
224
|
-
}
|
|
225
|
-
>
|
|
226
|
-
{l.text || ' '}
|
|
227
|
-
</div>
|
|
228
|
-
))}
|
|
229
|
-
</pre>
|
|
230
|
-
);
|
|
231
|
-
};
|
|
232
|
-
|
|
233
|
-
return (
|
|
234
|
-
<div className="fixed inset-0 z-[60]" role="dialog" aria-modal="true" aria-label={`Compare change request: ${cr.title}`}>
|
|
235
|
-
<div className="absolute inset-0 bg-slate-950/40" onClick={onClose} />
|
|
236
|
-
<div className="absolute inset-x-4 bottom-[5vh] top-[5vh] flex gap-3.5">
|
|
237
|
-
{/* left: the default branch */}
|
|
238
|
-
<section className="relative flex min-w-0 flex-1 flex-col overflow-hidden rounded-[20px] border border-slate-200 bg-white shadow-[0_30px_80px_rgba(22,35,58,0.30)]">
|
|
239
|
-
<div className="absolute left-6 right-6 top-0 h-[3px] rounded-full bg-gradient-to-r from-transparent via-[#10b981] to-transparent" />
|
|
240
|
-
<div className="flex items-center gap-3 px-5 pb-3 pt-5">
|
|
241
|
-
<div className="min-w-0">
|
|
242
|
-
<div className="truncate text-[17px] font-bold text-slate-800">{skill.name}</div>
|
|
243
|
-
<div className="text-[11px] uppercase tracking-[.08em] text-slate-400">
|
|
244
|
-
Skill · {protectedBranchDisplayName(DEFAULT_BRANCH)}
|
|
245
|
-
</div>
|
|
246
|
-
</div>
|
|
247
|
-
</div>
|
|
248
|
-
<div className="flex-1 overflow-y-auto px-5 pb-5">
|
|
249
|
-
<h4 className="mb-2 text-[10.5px] font-bold uppercase tracking-[.09em] text-slate-400">
|
|
250
|
-
Files on {protectedBranchDisplayName(DEFAULT_BRANCH)}
|
|
251
|
-
</h4>
|
|
252
|
-
<div className="mb-4 flex flex-col gap-1.5">{mainFiles.map((f) => fileRow(f, 'main'))}</div>
|
|
253
|
-
<h4 className="mb-2 font-mono text-[11px] text-slate-500">{selected}</h4>
|
|
254
|
-
{isAdded ? (
|
|
255
|
-
<div className="rounded-[13px] border border-dashed border-slate-200 p-4 text-center text-xs text-slate-400">
|
|
256
|
-
This file doesn't exist here yet
|
|
257
|
-
</div>
|
|
258
|
-
) : (
|
|
259
|
-
lineView(diff, mainRaw, 'added')
|
|
260
|
-
)}
|
|
261
|
-
</div>
|
|
262
|
-
</section>
|
|
263
|
-
|
|
264
|
-
{/* right: the change-request branch */}
|
|
265
|
-
<section className="relative flex min-w-0 flex-1 flex-col overflow-hidden rounded-[20px] border border-slate-200 bg-white shadow-[0_30px_80px_rgba(22,35,58,0.30)]">
|
|
266
|
-
<div className="absolute left-6 right-6 top-0 h-[3px] rounded-full bg-gradient-to-r from-transparent via-[#0d9488] to-transparent" />
|
|
267
|
-
<div className="flex items-center gap-3 px-5 pb-3 pt-5">
|
|
268
|
-
<div className="min-w-0">
|
|
269
|
-
<div className="truncate text-[17px] font-bold text-slate-800">{cr.title}</div>
|
|
270
|
-
<div className="truncate text-[11px] text-slate-400">
|
|
271
|
-
<span className="font-mono">{cr.branch}</span>
|
|
272
|
-
{' · by '}
|
|
273
|
-
{cr.appAuthor?.name ?? cr.author.name ?? cr.author.login}
|
|
274
|
-
</div>
|
|
275
|
-
</div>
|
|
276
|
-
<div className="relative ml-auto flex shrink-0 items-center gap-2">
|
|
277
|
-
<button
|
|
278
|
-
type="button"
|
|
279
|
-
disabled={busy}
|
|
280
|
-
className="rounded-[10px] border border-[#f5c2c2] bg-[#fdecec] px-3.5 py-2 text-[12.5px] font-bold text-[#c53030] transition-transform hover:-translate-y-px disabled:opacity-60"
|
|
281
|
-
onClick={() => setSendBackOpen((o) => !o)}
|
|
282
|
-
>
|
|
283
|
-
Send back
|
|
284
|
-
</button>
|
|
285
|
-
<button
|
|
286
|
-
type="button"
|
|
287
|
-
disabled={busy}
|
|
288
|
-
className="rounded-[10px] bg-gradient-to-br from-[#0d9488] to-[#0f766e] px-3.5 py-2 text-[12.5px] font-bold text-white shadow-[0_4px_14px_rgba(13,148,136,0.22)] transition-transform hover:-translate-y-px disabled:opacity-60"
|
|
289
|
-
onClick={() => void applyChanges()}
|
|
290
|
-
>
|
|
291
|
-
{busy ? 'Working…' : 'Apply changes'}
|
|
292
|
-
</button>
|
|
293
|
-
<button
|
|
294
|
-
type="button"
|
|
295
|
-
aria-label="Close compare"
|
|
296
|
-
className="flex h-[30px] w-[30px] items-center justify-center rounded-full border border-slate-200 bg-white text-[13px] text-slate-500 hover:border-[#7fd0c4] hover:text-slate-800"
|
|
297
|
-
onClick={onClose}
|
|
298
|
-
>
|
|
299
|
-
✕
|
|
300
|
-
</button>
|
|
301
|
-
{sendBackOpen && (
|
|
302
|
-
<div className="absolute right-0 top-full z-10 mt-2 w-72 rounded-[14px] border border-slate-200 bg-white p-3.5 shadow-[0_16px_44px_rgba(22,35,58,0.24)]">
|
|
303
|
-
<label className="block text-[10px] font-bold uppercase tracking-[.07em] text-slate-400">
|
|
304
|
-
Note for the author (optional)
|
|
305
|
-
<textarea
|
|
306
|
-
rows={3}
|
|
307
|
-
className="mt-1 w-full resize-y rounded-lg border border-slate-200 px-2 py-1.5 text-xs font-normal normal-case tracking-normal text-slate-800 outline-none focus:border-[#0d9488]"
|
|
308
|
-
value={sendBackNote}
|
|
309
|
-
onChange={(e) => setSendBackNote(e.target.value)}
|
|
310
|
-
/>
|
|
311
|
-
</label>
|
|
312
|
-
<div className="mt-2 flex justify-end">
|
|
313
|
-
<button
|
|
314
|
-
type="button"
|
|
315
|
-
disabled={busy}
|
|
316
|
-
className="rounded-[10px] bg-[#fdecec] px-3.5 py-2 text-[12.5px] font-bold text-[#c53030] shadow-[inset_0_0_0_1px_#f3c4c4] disabled:opacity-60"
|
|
317
|
-
onClick={() => void sendBack()}
|
|
318
|
-
>
|
|
319
|
-
Send back
|
|
320
|
-
</button>
|
|
321
|
-
</div>
|
|
322
|
-
</div>
|
|
323
|
-
)}
|
|
324
|
-
</div>
|
|
325
|
-
</div>
|
|
326
|
-
{error && <div className="mx-5 mb-2 rounded-lg bg-[#fdecec] px-3 py-2 text-xs text-[#c53030]">{error}</div>}
|
|
327
|
-
<div className="flex-1 overflow-y-auto px-5 pb-5">
|
|
328
|
-
<h4 className="mb-2 text-[10.5px] font-bold uppercase tracking-[.09em] text-slate-400">
|
|
329
|
-
Files on this draft
|
|
330
|
-
{outsideCount > 0 && (
|
|
331
|
-
<span className="ml-2 normal-case tracking-normal text-[#6d28d9]">
|
|
332
|
-
+{outsideCount} file{outsideCount === 1 ? '' : 's'} outside this skill
|
|
333
|
-
</span>
|
|
334
|
-
)}
|
|
335
|
-
</h4>
|
|
336
|
-
<div className="mb-4 flex flex-col gap-1.5">{branchFiles.map((f) => fileRow(f, 'branch'))}</div>
|
|
337
|
-
<div className="mb-2 flex items-center justify-between">
|
|
338
|
-
<h4 className="font-mono text-[11px] text-slate-500">{selected}</h4>
|
|
339
|
-
<button
|
|
340
|
-
type="button"
|
|
341
|
-
className="rounded-lg bg-[#e0f8ee] px-3.5 py-1 text-[11.5px] font-bold text-[#0a8f60] shadow-[inset_0_0_0_1px_#a9e8cd] transition-transform hover:-translate-y-px"
|
|
342
|
-
onClick={() => {
|
|
343
|
-
if (kbDirName) {
|
|
344
|
-
navigate(kbFileUrl(cr.branch, `${kbDirName}/${skill.path}/${selected}`));
|
|
345
|
-
}
|
|
346
|
-
}}
|
|
347
|
-
>
|
|
348
|
-
Edit
|
|
349
|
-
</button>
|
|
350
|
-
</div>
|
|
351
|
-
{lineView(diff, branchRaw, 'removed')}
|
|
352
|
-
</div>
|
|
353
|
-
</section>
|
|
354
|
-
</div>
|
|
355
|
-
</div>
|
|
356
|
-
);
|
|
357
|
-
}
|