@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
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
-
import { History,
|
|
3
|
-
import type { CommitAttribution } from '@bevel-software/platform-shared';
|
|
2
|
+
import { History, AlertTriangle, Loader2 } from 'lucide-react';
|
|
3
|
+
import type { CommitAttribution, FileDiffPayload } from '@bevel-software/platform-shared';
|
|
4
4
|
import { useGit } from '../state/git.context';
|
|
5
|
+
import { formatRelativeTime } from '../../../lib/utils';
|
|
5
6
|
import { UnifiedDiffView } from './UnifiedDiffView';
|
|
7
|
+
import { MarkdownDiffViewer } from '../../review/components/MarkdownDiffViewer';
|
|
6
8
|
import { friendlyGitError } from '../services/error-messages';
|
|
7
|
-
import { useFileAccess } from '../../access/hooks/useFileAccess';
|
|
8
9
|
import { useEventBus, canonicalizeWorkspaceId } from '../../workflow/state/event-bus.context';
|
|
9
10
|
import { useWorkspace } from '../../workspace/state/workspace.context';
|
|
10
11
|
|
|
@@ -12,26 +13,8 @@ function shortSha(sha: string): string {
|
|
|
12
13
|
return sha.slice(0, 7);
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
* an absolute date once we cross ~a month so the label doesn't become meaningless.
|
|
18
|
-
*/
|
|
19
|
-
function formatRelativeTime(iso: string): string {
|
|
20
|
-
if (!iso) return '';
|
|
21
|
-
const d = new Date(iso);
|
|
22
|
-
if (Number.isNaN(d.getTime())) return iso;
|
|
23
|
-
const diffMs = Date.now() - d.getTime();
|
|
24
|
-
if (diffMs < 0) return d.toLocaleDateString(undefined, { year: 'numeric', month: 'short', day: 'numeric' });
|
|
25
|
-
const mins = Math.floor(diffMs / 60000);
|
|
26
|
-
if (mins < 1) return 'just now';
|
|
27
|
-
if (mins < 60) return `${mins}m ago`;
|
|
28
|
-
const hours = Math.floor(mins / 60);
|
|
29
|
-
if (hours < 24) return `${hours}h ago`;
|
|
30
|
-
const days = Math.floor(hours / 24);
|
|
31
|
-
if (days < 7) return `${days}d ago`;
|
|
32
|
-
const weeks = Math.floor(days / 7);
|
|
33
|
-
if (weeks < 5) return `${weeks}w ago`;
|
|
34
|
-
return d.toLocaleDateString(undefined, { year: 'numeric', month: 'short', day: 'numeric' });
|
|
16
|
+
function isMarkdownPath(p: string): boolean {
|
|
17
|
+
return /\.md$/i.test(p);
|
|
35
18
|
}
|
|
36
19
|
|
|
37
20
|
function formatAbsoluteTime(iso: string): string {
|
|
@@ -43,52 +26,34 @@ function formatAbsoluteTime(iso: string): string {
|
|
|
43
26
|
|
|
44
27
|
interface Props {
|
|
45
28
|
filePath: string;
|
|
46
|
-
/**
|
|
47
|
-
* Called after a successful undo so the parent can reconcile (reopen the file, refresh
|
|
48
|
-
* the tree, refetch status). Returning a Promise lets the panel await reconciliation
|
|
49
|
-
* before clearing its `reverting` flag so buttons don't re-enable while reload is in
|
|
50
|
-
* progress.
|
|
51
|
-
*/
|
|
52
|
-
onRevertCompleted(): Promise<void>;
|
|
53
29
|
}
|
|
54
30
|
|
|
55
|
-
export function FileHistoryPanel({ filePath
|
|
31
|
+
export function FileHistoryPanel({ filePath }: Props) {
|
|
56
32
|
const git = useGit();
|
|
57
33
|
const [commits, setCommits] = useState<CommitAttribution[] | null>(null);
|
|
58
34
|
const [selected, setSelected] = useState<CommitAttribution | null>(null);
|
|
59
35
|
const [diff, setDiff] = useState<string | null>(null);
|
|
36
|
+
// Markdown files render through the same viewer as "Review agent changes":
|
|
37
|
+
// full before/after contents diffed client-side into a rendered-markdown
|
|
38
|
+
// red/green view. `diff` (the raw patch) stays the path for everything else.
|
|
39
|
+
const [mdPayload, setMdPayload] = useState<FileDiffPayload | null>(null);
|
|
60
40
|
const [loading, setLoading] = useState(true);
|
|
61
41
|
const [diffLoading, setDiffLoading] = useState(false);
|
|
62
|
-
const [reverting, setReverting] = useState(false);
|
|
63
42
|
const [error, setError] = useState<string | null>(null);
|
|
64
|
-
const [notice, setNotice] = useState<string | null>(null);
|
|
65
43
|
const latestDiffRequestRef = useRef<string | null>(null);
|
|
66
44
|
|
|
67
|
-
// Revert (the backend's `git revert` flow) is gated by per-path write
|
|
68
|
-
// access on protected branches only — draft branches are free-for-all,
|
|
69
|
-
// mirroring the backend's revertCommit gate. The hook returns
|
|
70
|
-
// canWrite=true on drafts without a network call, so the button stays
|
|
71
|
-
// enabled. On protected branches, default-allow on loading / API failure
|
|
72
|
-
// so a transient hiccup doesn't grey out the button for users who
|
|
73
|
-
// actually have access — the backend will refuse with AccessDenied at
|
|
74
|
-
// click time if not. (Edge case: a commit may have touched other files
|
|
75
|
-
// the caller can't write. The backend checks all of them; the user sees
|
|
76
|
-
// a click-then-error for that, which is acceptable.)
|
|
77
|
-
const access = useFileAccess(filePath, git.status?.branch ?? null);
|
|
78
|
-
const cannotRevert = access.canWrite === false;
|
|
79
|
-
|
|
80
45
|
// Pull the stable callbacks out so the effect's deps don't include the whole
|
|
81
46
|
// `git` object — that object is a useMemo result that changes on every status
|
|
82
47
|
// poll, which would otherwise wipe local state (selection, loading) every 30s.
|
|
83
|
-
const { fetchFileHistory, fetchFileDiff,
|
|
48
|
+
const { fetchFileHistory, fetchFileDiff, fetchFileAtChange } = git;
|
|
84
49
|
|
|
85
50
|
useEffect(() => {
|
|
86
51
|
let cancelled = false;
|
|
87
52
|
setLoading(true);
|
|
88
53
|
setError(null);
|
|
89
|
-
setNotice(null);
|
|
90
54
|
setSelected(null);
|
|
91
55
|
setDiff(null);
|
|
56
|
+
setMdPayload(null);
|
|
92
57
|
setCommits(null);
|
|
93
58
|
latestDiffRequestRef.current = null;
|
|
94
59
|
fetchFileHistory(filePath, 20)
|
|
@@ -147,12 +112,35 @@ export function FileHistoryPanel({ filePath, onRevertCompleted }: Props) {
|
|
|
147
112
|
const selectCommit = useCallback(
|
|
148
113
|
(commit: CommitAttribution) => {
|
|
149
114
|
setSelected(commit);
|
|
150
|
-
// Clear any banner left over from a previous failed diff
|
|
115
|
+
// Clear any banner left over from a previous failed diff so the UI
|
|
151
116
|
// reflects only the currently-selected save's state.
|
|
152
117
|
setError(null);
|
|
153
118
|
setDiff(null);
|
|
119
|
+
setMdPayload(null);
|
|
154
120
|
setDiffLoading(true);
|
|
155
121
|
latestDiffRequestRef.current = commit.sha;
|
|
122
|
+
if (isMarkdownPath(filePath)) {
|
|
123
|
+
fetchFileAtChange(filePath, commit.sha)
|
|
124
|
+
.then(({ baseline, current }) => {
|
|
125
|
+
if (latestDiffRequestRef.current !== commit.sha) return;
|
|
126
|
+
setMdPayload({
|
|
127
|
+
path: filePath,
|
|
128
|
+
kind: baseline === null ? 'added' : current === null ? 'deleted' : 'modified',
|
|
129
|
+
baseline,
|
|
130
|
+
current,
|
|
131
|
+
isBinary: false,
|
|
132
|
+
});
|
|
133
|
+
})
|
|
134
|
+
.catch((err) => {
|
|
135
|
+
if (latestDiffRequestRef.current === commit.sha) {
|
|
136
|
+
setError(friendlyGitError(err));
|
|
137
|
+
}
|
|
138
|
+
})
|
|
139
|
+
.finally(() => {
|
|
140
|
+
if (latestDiffRequestRef.current === commit.sha) setDiffLoading(false);
|
|
141
|
+
});
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
156
144
|
fetchFileDiff(filePath, commit.sha)
|
|
157
145
|
.then((d) => {
|
|
158
146
|
if (latestDiffRequestRef.current === commit.sha) setDiff(d);
|
|
@@ -166,30 +154,14 @@ export function FileHistoryPanel({ filePath, onRevertCompleted }: Props) {
|
|
|
166
154
|
if (latestDiffRequestRef.current === commit.sha) setDiffLoading(false);
|
|
167
155
|
});
|
|
168
156
|
},
|
|
169
|
-
[filePath, fetchFileDiff],
|
|
157
|
+
[filePath, fetchFileDiff, fetchFileAtChange],
|
|
170
158
|
);
|
|
171
159
|
|
|
172
|
-
const handleRevert = useCallback(async () => {
|
|
173
|
-
if (!selected || reverting) return;
|
|
174
|
-
setError(null);
|
|
175
|
-
setNotice(null);
|
|
176
|
-
setReverting(true);
|
|
177
|
-
try {
|
|
178
|
-
const attr = await revert(selected.sha);
|
|
179
|
-
setNotice(`Undone. Created a new save (${shortSha(attr.sha)}) that reverses ${shortSha(selected.sha)}.`);
|
|
180
|
-
await onRevertCompleted();
|
|
181
|
-
} catch (err) {
|
|
182
|
-
setError(friendlyGitError(err));
|
|
183
|
-
} finally {
|
|
184
|
-
setReverting(false);
|
|
185
|
-
}
|
|
186
|
-
}, [revert, selected, reverting, onRevertCompleted]);
|
|
187
|
-
|
|
188
160
|
return (
|
|
189
161
|
<div className="flex-1 flex flex-col min-h-0 bg-white">
|
|
190
|
-
<div className="flex items-center gap-2 px-3 py-2 border-b border-
|
|
191
|
-
<History size={14} className="text-
|
|
192
|
-
<span className="text-xs text-
|
|
162
|
+
<div className="flex items-center gap-2 px-3 py-2 border-b border-line shrink-0">
|
|
163
|
+
<History size={14} className="text-ink-muted shrink-0" />
|
|
164
|
+
<span className="text-xs text-ink-muted truncate">Timeline: {filePath}</span>
|
|
193
165
|
</div>
|
|
194
166
|
|
|
195
167
|
{error && (
|
|
@@ -198,23 +170,17 @@ export function FileHistoryPanel({ filePath, onRevertCompleted }: Props) {
|
|
|
198
170
|
<span className="flex-1">{error}</span>
|
|
199
171
|
</div>
|
|
200
172
|
)}
|
|
201
|
-
{notice && !error && (
|
|
202
|
-
<div className="px-3 py-2 bg-emerald-50 border-b border-emerald-200/60 text-xs text-emerald-700 shrink-0">
|
|
203
|
-
{notice}
|
|
204
|
-
</div>
|
|
205
|
-
)}
|
|
206
|
-
|
|
207
173
|
<div className="flex-1 flex min-h-0">
|
|
208
174
|
{/* Left: commit list */}
|
|
209
|
-
<div className="w-72 shrink-0 overflow-y-auto border-r border-
|
|
175
|
+
<div className="w-72 shrink-0 overflow-y-auto border-r border-line">
|
|
210
176
|
{loading && (
|
|
211
|
-
<div className="flex items-center gap-2 px-3 py-3 text-xs text-
|
|
177
|
+
<div className="flex items-center gap-2 px-3 py-3 text-xs text-ink-muted">
|
|
212
178
|
<Loader2 size={13} className="animate-spin" />
|
|
213
179
|
Loading timeline…
|
|
214
180
|
</div>
|
|
215
181
|
)}
|
|
216
182
|
{!loading && commits && commits.length === 0 && (
|
|
217
|
-
<div className="px-3 py-3 text-xs text-
|
|
183
|
+
<div className="px-3 py-3 text-xs text-ink-muted">
|
|
218
184
|
Nothing has been saved to this file yet.
|
|
219
185
|
</div>
|
|
220
186
|
)}
|
|
@@ -228,10 +194,10 @@ export function FileHistoryPanel({ filePath, onRevertCompleted }: Props) {
|
|
|
228
194
|
<button
|
|
229
195
|
type="button"
|
|
230
196
|
onClick={() => selectCommit(c)}
|
|
231
|
-
className={`w-full text-left px-3 py-2 border-b border-
|
|
197
|
+
className={`w-full text-left px-3 py-2 border-b border-line text-xs transition-colors ${
|
|
232
198
|
isSelected
|
|
233
|
-
? 'bg-
|
|
234
|
-
: 'text-
|
|
199
|
+
? 'bg-sunken text-ink'
|
|
200
|
+
: 'text-ink hover:bg-hover'
|
|
235
201
|
}`}
|
|
236
202
|
>
|
|
237
203
|
{/* Subject leads; SHA moves to a muted pill so non-technical users aren't
|
|
@@ -239,14 +205,14 @@ export function FileHistoryPanel({ filePath, onRevertCompleted }: Props) {
|
|
|
239
205
|
<div className="flex items-start gap-2">
|
|
240
206
|
<span className="flex-1 truncate">{c.subject || '(no message)'}</span>
|
|
241
207
|
<span
|
|
242
|
-
className="shrink-0 font-mono text-[9px] text-
|
|
208
|
+
className="shrink-0 font-mono text-[9px] text-ink-muted bg-white border border-line rounded px-1 py-[1px]"
|
|
243
209
|
title={`Save id: ${c.sha}`}
|
|
244
210
|
>
|
|
245
211
|
{shortSha(c.sha)}
|
|
246
212
|
</span>
|
|
247
213
|
</div>
|
|
248
214
|
<div
|
|
249
|
-
className="mt-0.5 text-[10px] text-
|
|
215
|
+
className="mt-0.5 text-[10px] text-ink-muted truncate"
|
|
250
216
|
title={formatAbsoluteTime(c.committedAt)}
|
|
251
217
|
>
|
|
252
218
|
{who} · {formatRelativeTime(c.committedAt)}
|
|
@@ -259,51 +225,49 @@ export function FileHistoryPanel({ filePath, onRevertCompleted }: Props) {
|
|
|
259
225
|
)}
|
|
260
226
|
</div>
|
|
261
227
|
|
|
262
|
-
{/* Right:
|
|
228
|
+
{/* Right: the selected save's changes */}
|
|
263
229
|
<div className="flex-1 flex flex-col min-w-0">
|
|
264
230
|
{!selected && (
|
|
265
|
-
<div className="flex-1 flex items-center justify-center px-6 text-xs text-
|
|
231
|
+
<div className="flex-1 flex items-center justify-center px-6 text-xs text-ink-muted">
|
|
266
232
|
Pick a save to see what changed.
|
|
267
233
|
</div>
|
|
268
234
|
)}
|
|
269
235
|
{selected && (
|
|
270
236
|
<>
|
|
271
|
-
<div className="flex items-center gap-2 px-3 py-2 border-b border-
|
|
272
|
-
<span className="text-xs text-
|
|
237
|
+
<div className="flex items-center gap-2 px-3 py-2 border-b border-line shrink-0">
|
|
238
|
+
<span className="text-xs text-ink truncate flex-1">
|
|
273
239
|
{selected.subject || '(no message)'}
|
|
274
240
|
</span>
|
|
275
241
|
<span
|
|
276
|
-
className="font-mono text-[10px] text-
|
|
242
|
+
className="font-mono text-[10px] text-ink-muted shrink-0"
|
|
277
243
|
title={`Save id: ${selected.sha}`}
|
|
278
244
|
>
|
|
279
245
|
{shortSha(selected.sha)}
|
|
280
246
|
</span>
|
|
281
|
-
<button
|
|
282
|
-
type="button"
|
|
283
|
-
onClick={handleRevert}
|
|
284
|
-
disabled={reverting || cannotRevert || git.availability !== 'ready'}
|
|
285
|
-
title={
|
|
286
|
-
cannotRevert
|
|
287
|
-
? "You don't have permission to edit this file"
|
|
288
|
-
: 'Creates a new save that reverses this one'
|
|
289
|
-
}
|
|
290
|
-
className="flex items-center gap-1.5 px-2.5 py-1 rounded text-xs font-medium bg-slate-100 hover:bg-slate-200 text-slate-900 border border-slate-300 transition-colors disabled:opacity-50 disabled:cursor-not-allowed"
|
|
291
|
-
>
|
|
292
|
-
{reverting ? (
|
|
293
|
-
<Loader2 size={12} className="animate-spin" />
|
|
294
|
-
) : (
|
|
295
|
-
<Undo2 size={12} />
|
|
296
|
-
)}
|
|
297
|
-
Undo this save
|
|
298
|
-
</button>
|
|
299
247
|
</div>
|
|
300
248
|
<div className="flex-1 overflow-auto">
|
|
301
249
|
{diffLoading && (
|
|
302
|
-
<div className="flex items-center gap-2 px-3 py-3 text-xs text-
|
|
250
|
+
<div className="flex items-center gap-2 px-3 py-3 text-xs text-ink-muted">
|
|
303
251
|
<Loader2 size={13} className="animate-spin" />
|
|
304
252
|
Loading changes…
|
|
305
253
|
</div>
|
|
306
254
|
)}
|
|
255
|
+
{!diffLoading && mdPayload !== null && (
|
|
256
|
+
mdPayload.baseline === null && mdPayload.current === null ? (
|
|
257
|
+
// The commit exists in the file's log but the file is
|
|
258
|
+
// absent on both sides (e.g. a pure rename elsewhere in
|
|
259
|
+
// the commit) — mirror the raw view's empty state.
|
|
260
|
+
<div className="px-3 py-3 text-xs text-ink-muted">
|
|
261
|
+
No file changes in this save.
|
|
262
|
+
</div>
|
|
263
|
+
) : (
|
|
264
|
+
// No link resolvers: this is a diff of a PAST commit, and a
|
|
265
|
+
// relative link in it has no meaningful "current" document
|
|
266
|
+
// to resolve against — the target may have moved or stopped
|
|
267
|
+
// existing since. Links render inert.
|
|
268
|
+
<MarkdownDiffViewer payload={mdPayload} />
|
|
269
|
+
)
|
|
270
|
+
)}
|
|
307
271
|
{!diffLoading && diff !== null && (
|
|
308
272
|
<UnifiedDiffView
|
|
309
273
|
diff={diff}
|
|
@@ -7,6 +7,7 @@ import { useCrCreationPort } from '../../../core/registry';
|
|
|
7
7
|
import { PR_STALE_EVENT } from '../../../core/events';
|
|
8
8
|
import { useWorkspace } from '../../workspace/state/workspace.context';
|
|
9
9
|
import { sanitizeErrorText } from '../services/error-messages';
|
|
10
|
+
import { Button } from '../../../shared/components';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Classify a pull failure into a short, user-safe phrase. Returned strings
|
|
@@ -172,7 +173,7 @@ export function PullNeededBanner() {
|
|
|
172
173
|
return (
|
|
173
174
|
<div
|
|
174
175
|
role="status"
|
|
175
|
-
className="px-3 py-1.5 bg-
|
|
176
|
+
className="px-3 py-1.5 bg-sunken border-b border-line text-xs text-ink shrink-0"
|
|
176
177
|
>
|
|
177
178
|
<div className="flex items-center gap-2">
|
|
178
179
|
<GitMerge size={13} className="shrink-0" />
|
|
@@ -180,22 +181,14 @@ export function PullNeededBanner() {
|
|
|
180
181
|
{message} (<span className="font-mono font-semibold">{status.branch}</span>).
|
|
181
182
|
</span>
|
|
182
183
|
{showAction && (
|
|
183
|
-
<
|
|
184
|
-
onClick={handleClick}
|
|
185
|
-
disabled={pending}
|
|
186
|
-
className="px-2 py-0.5 rounded bg-sky-600 hover:bg-sky-700 disabled:opacity-50 disabled:cursor-not-allowed text-white font-medium"
|
|
187
|
-
>
|
|
184
|
+
<Button variant="primary" size="tiny" onClick={handleClick} disabled={pending}>
|
|
188
185
|
{buttonLabel}
|
|
189
|
-
</
|
|
186
|
+
</Button>
|
|
190
187
|
)}
|
|
191
188
|
</div>
|
|
192
|
-
{guidance &&
|
|
193
|
-
<div className="mt-1 ml-5 text-sky-700">
|
|
194
|
-
{guidance}
|
|
195
|
-
</div>
|
|
196
|
-
)}
|
|
189
|
+
{guidance && <div className="mt-1 ml-5 text-ink-muted">{guidance}</div>}
|
|
197
190
|
{error && (
|
|
198
|
-
<div role="alert" className="mt-1 ml-5 text-
|
|
191
|
+
<div role="alert" className="mt-1 ml-5 text-danger">
|
|
199
192
|
{error}
|
|
200
193
|
</div>
|
|
201
194
|
)}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { useEffect, useRef, useState } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { ChevronRight, Check, X, Clock } from 'lucide-react';
|
|
3
3
|
import type { PullRequestSummary } from '@bevel-software/platform-shared';
|
|
4
|
+
import { cn } from '../../../lib/utils';
|
|
5
|
+
import { Badge } from '../../../shared/components';
|
|
4
6
|
import { listPullRequestsForMe } from '../services/pr.api';
|
|
5
7
|
import { friendlyGitError } from '../services/error-messages';
|
|
6
8
|
import { useGit } from '../state/git.context';
|
|
7
|
-
import {
|
|
9
|
+
import { ChangeRequestDialog } from '../../change-requests/components/ChangeRequestDialog';
|
|
8
10
|
import { PR_STALE_EVENT } from '../../../core/events';
|
|
9
11
|
|
|
10
12
|
const POLL_INTERVAL_MS = 60_000;
|
|
@@ -15,6 +17,8 @@ export function PullRequestsForMe() {
|
|
|
15
17
|
const [loading, setLoading] = useState(true);
|
|
16
18
|
const [error, setError] = useState<string | null>(null);
|
|
17
19
|
const [expanded, setExpanded] = useState(true);
|
|
20
|
+
/** The request opened full-screen in the shared change-request dialog. */
|
|
21
|
+
const [openCr, setOpenCr] = useState<PullRequestSummary | null>(null);
|
|
18
22
|
const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
19
23
|
const mountedRef = useRef(false);
|
|
20
24
|
// Snapshot of branches from the previous PR list so we can detect which
|
|
@@ -140,73 +144,104 @@ export function PullRequestsForMe() {
|
|
|
140
144
|
}, [available, deleteBranch, refreshBranches]);
|
|
141
145
|
|
|
142
146
|
if (!available) return null;
|
|
147
|
+
// A queue you notice, not one you live in. With nothing waiting there is
|
|
148
|
+
// nothing to notice, so the dock stays out of the tree's way entirely — the
|
|
149
|
+
// permanent "Nothing waiting for your review." row was a line of chrome that
|
|
150
|
+
// was true almost all of the time. An error still shows: "we could not ask"
|
|
151
|
+
// is not the same answer as "there is nothing".
|
|
152
|
+
if (loading || (!error && prs.length === 0)) return null;
|
|
143
153
|
|
|
144
154
|
return (
|
|
145
|
-
|
|
155
|
+
// The prototype's `.crdock` (proto:730-750): pinned under the tree behind
|
|
156
|
+
// one hairline, a disclosure header with an amber count, and rows in the
|
|
157
|
+
// same two type sizes the tree above and the Library nav use, so the whole
|
|
158
|
+
// sidebar is one typographic system rather than three.
|
|
159
|
+
<div className="flex max-h-60 shrink-0 flex-col border-t border-line px-2">
|
|
146
160
|
<button
|
|
161
|
+
type="button"
|
|
147
162
|
onClick={() => setExpanded((v) => !v)}
|
|
148
|
-
|
|
163
|
+
aria-expanded={expanded}
|
|
164
|
+
// The visible label is the prototype's; the accessible name keeps the
|
|
165
|
+
// SCOPE in words, because this queue is deliberately narrower than the
|
|
166
|
+
// dots in the tree — it is the requests that are yours to act on.
|
|
167
|
+
aria-label="Change requests for you"
|
|
168
|
+
className="flex items-center gap-[7px] px-1.5 pt-2.5 pb-2 text-label uppercase text-ink-faint transition-colors hover:text-ink"
|
|
149
169
|
>
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
170
|
+
<span className="flex w-3 flex-none items-center justify-center">
|
|
171
|
+
<ChevronRight
|
|
172
|
+
size={11}
|
|
173
|
+
className={cn('transition-transform duration-150', expanded && 'rotate-90')}
|
|
174
|
+
/>
|
|
175
|
+
</span>
|
|
176
|
+
<span className="flex-1 text-left">Change requests</span>
|
|
177
|
+
{prs.length > 0 && (
|
|
178
|
+
<Badge tone="wait" size="xs">
|
|
155
179
|
{prs.length}
|
|
156
|
-
</
|
|
180
|
+
</Badge>
|
|
157
181
|
)}
|
|
158
182
|
</button>
|
|
159
183
|
|
|
160
184
|
{expanded && (
|
|
161
|
-
<div className="flex-
|
|
162
|
-
{
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
{!loading && error && (
|
|
166
|
-
<div className="px-3 py-2 text-xs text-red-600">{error}</div>
|
|
167
|
-
)}
|
|
168
|
-
{!loading && !error && prs.length === 0 && (
|
|
169
|
-
<div className="px-3 py-2 text-xs text-slate-600">Nothing waiting for your review.</div>
|
|
170
|
-
)}
|
|
171
|
-
{!loading && !error && prs.map((pr) => (
|
|
172
|
-
<PrRow key={pr.number} pr={pr} />
|
|
173
|
-
))}
|
|
185
|
+
<div className="flex flex-col gap-px overflow-y-auto pb-1.5">
|
|
186
|
+
{error && <div className="pl-[25px] pr-1.5 py-2 text-meta text-danger">{error}</div>}
|
|
187
|
+
{!error &&
|
|
188
|
+
prs.map((pr) => <PrRow key={pr.number} pr={pr} onOpen={() => setOpenCr(pr)} />)}
|
|
174
189
|
</div>
|
|
175
190
|
)}
|
|
191
|
+
|
|
192
|
+
{/* The SHARED change-request dialog — the same surface a change box's
|
|
193
|
+
"Read the whole change" opens, unscoped: this queue spans the whole
|
|
194
|
+
repo. Resolving refreshes every listener via the stale event; this
|
|
195
|
+
list is one of them. */}
|
|
196
|
+
{openCr && (
|
|
197
|
+
<ChangeRequestDialog
|
|
198
|
+
cr={openCr}
|
|
199
|
+
onClose={() => setOpenCr(null)}
|
|
200
|
+
onResolved={() => {
|
|
201
|
+
setOpenCr(null);
|
|
202
|
+
window.dispatchEvent(new Event(PR_STALE_EVENT));
|
|
203
|
+
}}
|
|
204
|
+
/>
|
|
205
|
+
)}
|
|
176
206
|
</div>
|
|
177
207
|
);
|
|
178
208
|
}
|
|
179
209
|
|
|
180
|
-
function PrRow({ pr }: { pr: PullRequestSummary }) {
|
|
210
|
+
function PrRow({ pr, onOpen }: { pr: PullRequestSummary; onOpen(): void }) {
|
|
181
211
|
const touched = pr.touchedNodePaths.length;
|
|
182
|
-
|
|
212
|
+
// `appAuthor` is optional — it is absent for a request opened outside this
|
|
213
|
+
// backend, or after the app user was removed. `author.login` is always
|
|
214
|
+
// there; never render "undefined" at somebody.
|
|
215
|
+
const who = pr.appAuthor?.name ?? pr.author.login;
|
|
183
216
|
// The summary endpoint doesn't carry app-level approval state (that only
|
|
184
217
|
// comes from the detail endpoint, which is per-PR). We show the GitHub
|
|
185
|
-
// review badge as-is until the user opens the
|
|
186
|
-
//
|
|
218
|
+
// review badge as-is until the user opens the request and sees the real
|
|
219
|
+
// approval progress — the dialog is authoritative.
|
|
187
220
|
return (
|
|
188
221
|
<div
|
|
189
222
|
role="button"
|
|
190
223
|
tabIndex={0}
|
|
191
|
-
onClick={
|
|
224
|
+
onClick={onOpen}
|
|
192
225
|
onKeyDown={(e) => {
|
|
193
226
|
if (e.key === 'Enter' || e.key === ' ') {
|
|
194
227
|
e.preventDefault();
|
|
195
|
-
|
|
228
|
+
onOpen();
|
|
196
229
|
}
|
|
197
230
|
}}
|
|
198
|
-
className="block
|
|
231
|
+
className="group block cursor-pointer rounded-sm pl-[25px] pr-[7px] py-1.5 transition-colors hover:bg-hover"
|
|
199
232
|
title={pr.title}
|
|
200
233
|
>
|
|
201
|
-
<div className="flex
|
|
202
|
-
<span className="
|
|
203
|
-
|
|
234
|
+
<div className="flex min-w-0 gap-1.5 text-ui text-ink-muted group-hover:text-ink">
|
|
235
|
+
<span className="flex-none tabular-nums text-ink-faint">#{pr.number}</span>
|
|
236
|
+
{/* The ellipsis has to live on the TEXT, not on the flex row — a flex
|
|
237
|
+
container clips its children without ever drawing one. */}
|
|
238
|
+
<span className="min-w-0 truncate">{pr.title}</span>
|
|
204
239
|
</div>
|
|
205
|
-
<div className="flex items-center gap-2
|
|
206
|
-
<span className="truncate">{
|
|
240
|
+
<div className="mt-px flex items-center gap-2 text-meta text-ink-faint">
|
|
241
|
+
<span className="truncate">{who}</span>
|
|
207
242
|
<ReviewBadge review={pr.review} />
|
|
208
243
|
{touched > 0 && (
|
|
209
|
-
<span className="
|
|
244
|
+
<span className="flex-none">
|
|
210
245
|
{touched} file{touched === 1 ? '' : 's'}
|
|
211
246
|
</span>
|
|
212
247
|
)}
|
|
@@ -13,19 +13,19 @@ interface Props {
|
|
|
13
13
|
export function UnifiedDiffView({ diff, emptyMessage = 'No changes.' }: Props) {
|
|
14
14
|
if (!diff.trim()) {
|
|
15
15
|
return (
|
|
16
|
-
<div className="px-3 py-3 text-xs text-
|
|
16
|
+
<div className="px-3 py-3 text-xs text-ink-muted">{emptyMessage}</div>
|
|
17
17
|
);
|
|
18
18
|
}
|
|
19
19
|
const lines = diff.split('\n');
|
|
20
20
|
return (
|
|
21
21
|
<pre className="px-3 py-2 text-xs font-mono leading-5 whitespace-pre">
|
|
22
22
|
{lines.map((line, i) => {
|
|
23
|
-
let cls = 'text-
|
|
24
|
-
if (line.startsWith('+++') || line.startsWith('---')) cls = 'text-
|
|
23
|
+
let cls = 'text-ink';
|
|
24
|
+
if (line.startsWith('+++') || line.startsWith('---')) cls = 'text-ink-muted';
|
|
25
25
|
else if (line.startsWith('@@')) cls = 'text-sky-600';
|
|
26
26
|
else if (line.startsWith('+')) cls = 'text-emerald-700 bg-emerald-50';
|
|
27
27
|
else if (line.startsWith('-')) cls = 'text-red-700 bg-red-50';
|
|
28
|
-
else if (line.startsWith('diff ') || line.startsWith('index ')) cls = 'text-
|
|
28
|
+
else if (line.startsWith('diff ') || line.startsWith('index ')) cls = 'text-ink-muted';
|
|
29
29
|
return (
|
|
30
30
|
<div key={i} className={cls}>
|
|
31
31
|
{line || ' '}
|
|
@@ -23,9 +23,9 @@ vi.mock('../../services/git.api', () => ({
|
|
|
23
23
|
deleteBranch: vi.fn(),
|
|
24
24
|
pull: vi.fn(),
|
|
25
25
|
fetchForkBase: vi.fn(),
|
|
26
|
-
revert: vi.fn(),
|
|
27
26
|
fetchFileHistory: vi.fn(),
|
|
28
27
|
fetchFileDiff: vi.fn(),
|
|
28
|
+
fetchFileAtChange: vi.fn(),
|
|
29
29
|
fetchFileComparison: vi.fn(),
|
|
30
30
|
}));
|
|
31
31
|
|
|
@@ -37,7 +37,7 @@ function mkBranch(name: string): BranchInfo {
|
|
|
37
37
|
return { name, isProtected: false, ahead: 0, behind: 0, hasRemote: true };
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
describe('useGitState
|
|
40
|
+
describe('useGitState: optimistic deleteBranch', () => {
|
|
41
41
|
beforeEach(() => {
|
|
42
42
|
vi.clearAllMocks();
|
|
43
43
|
// Status fetch isn't what these tests care about; resolve it so the
|
|
@@ -9,13 +9,13 @@ import {
|
|
|
9
9
|
createBranch as apiCreateBranch,
|
|
10
10
|
deleteBranch as apiDeleteBranch,
|
|
11
11
|
fetchBranches,
|
|
12
|
+
fetchFileAtChange,
|
|
12
13
|
fetchFileComparison,
|
|
13
14
|
fetchFileDiff,
|
|
14
15
|
fetchFileHistory,
|
|
15
16
|
fetchForkBase,
|
|
16
17
|
fetchStatus,
|
|
17
18
|
pull as apiPull,
|
|
18
|
-
revert as apiRevert,
|
|
19
19
|
} from '../services/git.api';
|
|
20
20
|
|
|
21
21
|
const STATUS_POLL_MS = 30_000;
|
|
@@ -253,17 +253,6 @@ export function useGitState(workspaceId: string | null): GitContextValue {
|
|
|
253
253
|
return fetchForkBase(wid, branch);
|
|
254
254
|
}, []);
|
|
255
255
|
|
|
256
|
-
const revert = useCallback(
|
|
257
|
-
async (sha: string): Promise<CommitAttribution> => {
|
|
258
|
-
const wid = workspaceIdRef.current;
|
|
259
|
-
if (!wid) throw new Error('No workspace loaded');
|
|
260
|
-
const attribution = await apiRevert(wid, sha);
|
|
261
|
-
await refreshStatus();
|
|
262
|
-
return attribution;
|
|
263
|
-
},
|
|
264
|
-
[refreshStatus],
|
|
265
|
-
);
|
|
266
|
-
|
|
267
256
|
const fetchFileHistoryCb = useCallback(
|
|
268
257
|
async (path: string, limit?: number): Promise<CommitAttribution[]> => {
|
|
269
258
|
const wid = workspaceIdRef.current;
|
|
@@ -282,6 +271,18 @@ export function useGitState(workspaceId: string | null): GitContextValue {
|
|
|
282
271
|
[],
|
|
283
272
|
);
|
|
284
273
|
|
|
274
|
+
const fetchFileAtChangeCb = useCallback(
|
|
275
|
+
async (path: string, sha: string): Promise<{ baseline: string | null; current: string | null }> => {
|
|
276
|
+
const wid = workspaceIdRef.current;
|
|
277
|
+
// Null-on-both-sides is a meaningful payload ("absent at this commit"),
|
|
278
|
+
// so don't fake one when there's no workspace — reject so the panel
|
|
279
|
+
// surfaces its error state instead of an empty diff.
|
|
280
|
+
if (!wid) throw new Error('No active workspace.');
|
|
281
|
+
return fetchFileAtChange(wid, path, sha);
|
|
282
|
+
},
|
|
283
|
+
[],
|
|
284
|
+
);
|
|
285
|
+
|
|
285
286
|
const fetchFileComparisonCb = useCallback(
|
|
286
287
|
async (path: string, fromBranch: string, toBranch: string): Promise<string> => {
|
|
287
288
|
const wid = workspaceIdRef.current;
|
|
@@ -310,9 +311,9 @@ export function useGitState(workspaceId: string | null): GitContextValue {
|
|
|
310
311
|
deleteBranch: deleteBranchCb,
|
|
311
312
|
pull,
|
|
312
313
|
fetchForkBase: fetchForkBaseCb,
|
|
313
|
-
revert,
|
|
314
314
|
fetchFileHistory: fetchFileHistoryCb,
|
|
315
315
|
fetchFileDiff: fetchFileDiffCb,
|
|
316
|
+
fetchFileAtChange: fetchFileAtChangeCb,
|
|
316
317
|
fetchFileComparison: fetchFileComparisonCb,
|
|
317
318
|
}),
|
|
318
319
|
[
|
|
@@ -326,9 +327,9 @@ export function useGitState(workspaceId: string | null): GitContextValue {
|
|
|
326
327
|
deleteBranchCb,
|
|
327
328
|
pull,
|
|
328
329
|
fetchForkBaseCb,
|
|
329
|
-
revert,
|
|
330
330
|
fetchFileHistoryCb,
|
|
331
331
|
fetchFileDiffCb,
|
|
332
|
+
fetchFileAtChangeCb,
|
|
332
333
|
fetchFileComparisonCb,
|
|
333
334
|
],
|
|
334
335
|
);
|