@bevel-software/platform-core-frontend 0.14.0 → 0.19.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/THIRD-PARTY-NOTICES.md +2 -2
- package/package.json +3 -3
- package/src/core/CoreAppShell.tsx +34 -26
- package/src/core/__tests__/AppChrome.test.tsx +0 -3
- package/src/core/__tests__/bootstrap.test.ts +33 -1
- package/src/core/__tests__/events.test.ts +43 -0
- package/src/core/bootstrap.ts +38 -1
- package/src/core/events.ts +85 -3
- package/src/core/registry.ts +1 -1
- package/src/lib/__tests__/api.test.ts +38 -0
- package/src/lib/__tests__/email.test.ts +44 -0
- package/src/lib/api.ts +19 -2
- package/src/lib/email.ts +37 -1
- package/src/lib/utils.ts +2 -0
- package/src/modules/access/__tests__/ManageAccessDialog.add-row-picking.test.tsx +141 -0
- package/src/modules/access/__tests__/ManageAccessDialog.chip-truncation.test.tsx +204 -0
- package/src/modules/access/__tests__/ManageAccessDialog.download-read.test.tsx +234 -0
- package/src/modules/access/__tests__/ManageAccessDialog.edited-row-visible.test.tsx +160 -0
- package/src/modules/access/__tests__/ManageAccessDialog.placement.test.tsx +2 -2
- package/src/modules/access/__tests__/ManageAccessDialog.proposal.test.tsx +166 -0
- package/src/modules/access/__tests__/ManageAccessDialog.restrict.test.tsx +510 -0
- package/src/modules/access/__tests__/ManageAccessDialog.row-menu-axes.test.tsx +299 -0
- package/src/modules/access/__tests__/ManageAccessDialog.row-menu-width.test.tsx +226 -0
- package/src/modules/access/__tests__/ManageAccessDialog.test.tsx +781 -76
- package/src/modules/access/__tests__/ManageAccessDialog.unknown-email.test.tsx +314 -0
- package/src/modules/access/__tests__/manage-access-affordance.test.ts +14 -0
- package/src/modules/access/__tests__/plugin-token.test.ts +21 -0
- package/src/modules/access/__tests__/tailwindDeclarations.ts +210 -0
- package/src/modules/access/api.ts +192 -10
- package/src/modules/access/components/ManageAccessDialog.tsx +1337 -570
- package/src/modules/access/manage-access-affordance.ts +17 -0
- package/src/modules/admin/__tests__/AddMemberInput.test.tsx +297 -0
- package/src/modules/admin/__tests__/AdminRolesPage.capabilities.test.tsx +2 -2
- package/src/modules/admin/__tests__/AdminRolesPage.fixed-admin.test.tsx +189 -0
- package/src/modules/admin/__tests__/AdminRolesPage.suggest.test.tsx +1 -1
- package/src/modules/admin/__tests__/ConnectionKeysPage.test.tsx +266 -0
- package/src/modules/admin/__tests__/DirectoryGroupsPage.suggest.test.tsx +182 -0
- package/src/modules/admin/__tests__/DirectoryGroupsPage.test.tsx +165 -14
- package/src/modules/admin/__tests__/UserAccountsPage.test.tsx +401 -4
- package/src/modules/admin/__tests__/group-members-path.test.ts +27 -0
- package/src/modules/admin/components/AddMemberInput.tsx +268 -0
- package/src/modules/admin/components/AdminRolesPage.tsx +97 -132
- package/src/modules/admin/components/ConnectionKeysPage.tsx +269 -0
- package/src/modules/admin/components/DirectoryGroupsPage.tsx +91 -39
- package/src/modules/admin/components/UserAccountsPage.tsx +271 -37
- package/src/modules/admin/components/connection-keys-grouping.ts +43 -0
- package/src/modules/admin/components/group-members-path.ts +32 -0
- package/src/modules/admin/services/connection-keys.api.ts +47 -0
- package/src/modules/admin/services/roles.api.ts +12 -1
- package/src/modules/auth/__tests__/AccountPage.test.tsx +50 -2
- package/src/modules/auth/components/AccountPage.tsx +73 -54
- package/src/modules/auth/components/LoginScreen.tsx +1 -0
- package/src/modules/auth/services/account.api.ts +78 -4
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.access-rules.test.tsx +144 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.binary.test.tsx +422 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.brings-itself-up-to-date.test.tsx +431 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.fork-point.test.tsx +193 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.initial-file.test.tsx +142 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.moved.test.tsx +202 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.test.tsx +205 -13
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.unreadable.test.tsx +271 -0
- package/src/modules/change-requests/__tests__/FileChangeBoxes.test.tsx +208 -0
- package/src/modules/change-requests/__tests__/apply-outcome-for-every-viewer.test.tsx +286 -0
- package/src/modules/change-requests/__tests__/propose.concurrent.test.ts +273 -0
- package/src/modules/change-requests/__tests__/readFailure.test.ts +122 -0
- package/src/modules/change-requests/__tests__/useCrFileDiffs.test.tsx +238 -0
- package/src/modules/change-requests/__tests__/useFileOnBranch.test.tsx +56 -1
- package/src/modules/change-requests/__tests__/useForkPointFile.test.tsx +79 -0
- package/src/modules/change-requests/components/BranchFilePreview.tsx +357 -0
- package/src/modules/change-requests/components/ChangeBox.tsx +31 -2
- package/src/modules/change-requests/components/ChangeRequestDialog.tsx +862 -72
- package/src/modules/change-requests/components/CrFileTree.tsx +74 -58
- package/src/modules/change-requests/components/FileChangeBoxes.tsx +19 -15
- package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +41 -7
- package/src/modules/change-requests/hooks/useCrFileDiffs.ts +181 -23
- package/src/modules/change-requests/hooks/useFileOnBranch.ts +70 -7
- package/src/modules/change-requests/hooks/useForkPointFile.ts +77 -0
- package/src/modules/change-requests/services/change-requests.api.ts +57 -1
- package/src/modules/change-requests/services/denied-file.api.ts +53 -0
- package/src/modules/change-requests/services/propose.api.ts +97 -8
- package/src/modules/change-requests/utils/approval.ts +15 -0
- package/src/modules/change-requests/utils/author.ts +32 -0
- package/src/modules/change-requests/utils/readFailure.ts +110 -0
- package/src/modules/git/__tests__/FileHistoryPanel.test.tsx +20 -0
- package/src/modules/git/__tests__/GitSyncFailedBanner.test.tsx +65 -1
- package/src/modules/git/components/FileHistoryPanel.tsx +5 -0
- package/src/modules/git/components/GitSyncFailedBanner.tsx +68 -5
- package/src/modules/git/components/PullRequestsForMe.tsx +51 -24
- package/src/modules/git/services/__tests__/error-messages.test.ts +29 -0
- package/src/modules/git/services/error-messages.ts +12 -0
- package/src/modules/git/services/pr-prompts.ts +5 -5
- package/src/modules/layout/__tests__/HeaderAlignment.test.tsx +401 -0
- package/src/modules/layout/__tests__/SidebarFooterGrid.test.tsx +286 -0
- package/src/modules/layout/__tests__/SidebarFrameResponsive.test.tsx +61 -0
- package/src/modules/layout/components/AppLayout.tsx +2 -0
- package/src/modules/layout/components/MobileChatLayout.tsx +4 -1
- package/src/modules/layout/components/ResizableThreePaneLayout.tsx +4 -1
- package/src/modules/layout/components/SidebarFrame.tsx +109 -4
- package/src/modules/library/__tests__/AddToPluginDialog.test.tsx +171 -5
- package/src/modules/library/__tests__/DeleteToolDialog.test.tsx +356 -0
- package/src/modules/library/__tests__/IntegrationsSetupReminder.test.tsx +60 -0
- package/src/modules/library/__tests__/LibraryCard.test.tsx +91 -10
- package/src/modules/library/__tests__/LibraryRoutes.test.tsx +242 -107
- package/src/modules/library/__tests__/LibrarySidebarMenu.test.tsx +104 -99
- package/src/modules/library/__tests__/LinkSkillPanel.test.tsx +136 -0
- package/src/modules/library/__tests__/LockedPluginView.test.tsx +103 -7
- package/src/modules/library/__tests__/NewPluginDialog.test.tsx +18 -8
- package/src/modules/library/__tests__/PersonalAddDialog.test.tsx +79 -3
- package/src/modules/library/__tests__/PersonalPluginPage.test.tsx +201 -0
- package/src/modules/library/__tests__/PluginExtras.test.tsx +115 -9
- package/src/modules/library/__tests__/PluginJoinRequests.test.tsx +60 -1
- package/src/modules/library/__tests__/PluginPage.test.tsx +453 -7
- package/src/modules/library/__tests__/PluginsSidebar.contextmenu.test.tsx +17 -57
- package/src/modules/library/__tests__/PluginsSidebar.test.tsx +161 -97
- package/src/modules/library/__tests__/PluginsSidebarMenu.test.tsx +16 -0
- package/src/modules/library/__tests__/SharedViaPlugins.test.tsx +106 -0
- package/src/modules/library/__tests__/SkillPage.test.tsx +391 -78
- package/src/modules/library/__tests__/SkillsTree.test.tsx +461 -0
- package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +582 -71
- package/src/modules/library/__tests__/ToolPage.test.tsx +94 -4
- package/src/modules/library/__tests__/WorkspaceItemRoute.test.tsx +279 -21
- package/src/modules/library/__tests__/auth-harness.tsx +9 -9
- package/src/modules/library/__tests__/card-row-menu.test.tsx +320 -0
- package/src/modules/library/__tests__/library-data.mapping.test.tsx +98 -0
- package/src/modules/library/__tests__/library-data.stale.test.tsx +183 -0
- package/src/modules/library/__tests__/library-data.test.ts +7 -0
- package/src/modules/library/__tests__/library-paths.test.ts +75 -0
- package/src/modules/library/__tests__/link-membership.test.ts +129 -0
- package/src/modules/library/__tests__/name-with-badges.test.tsx +273 -0
- package/src/modules/library/__tests__/newSkillMarkdown.test.ts +30 -0
- package/src/modules/library/__tests__/owner-pill.test.tsx +357 -0
- package/src/modules/library/__tests__/pending-tools.test.tsx +400 -0
- package/src/modules/library/__tests__/plugin-entries.test.ts +122 -0
- package/src/modules/library/__tests__/plugin-summary.test.ts +67 -0
- package/src/modules/library/__tests__/status.test.ts +82 -2
- package/src/modules/library/__tests__/tools.api.test.ts +44 -1
- package/src/modules/library/__tests__/useJoinRequests.test.tsx +46 -0
- package/src/modules/library/components/AccessRequestsBanner.tsx +85 -47
- package/src/modules/library/components/AddDialogTabs.tsx +103 -0
- package/src/modules/library/components/AddToPluginDialog.tsx +107 -18
- package/src/modules/library/components/IntegrationsSetupReminder.tsx +59 -0
- package/src/modules/library/components/ItemActionsMenu.tsx +288 -0
- package/src/modules/library/components/LibraryCard.tsx +149 -34
- package/src/modules/library/components/LibraryLayout.tsx +120 -247
- package/src/modules/library/components/LibraryPage.tsx +172 -39
- package/src/modules/library/components/LinkSkillPanel.tsx +169 -0
- package/src/modules/library/components/LockedPluginView.tsx +63 -35
- package/src/modules/library/components/NameWithBadges.tsx +164 -0
- package/src/modules/library/components/NewPluginDialog.tsx +19 -5
- package/src/modules/library/components/PageActions.tsx +31 -9
- package/src/modules/library/components/{PendingSkillReview.tsx → PendingItemReview.tsx} +14 -7
- package/src/modules/library/components/PersonalAddDialog.tsx +68 -18
- package/src/modules/library/components/PersonalPluginPage.tsx +123 -23
- package/src/modules/library/components/PluginExtras.tsx +143 -18
- package/src/modules/library/components/PluginIndexRow.tsx +47 -12
- package/src/modules/library/components/PluginPage.tsx +234 -38
- package/src/modules/library/components/PluginRows.tsx +286 -0
- package/src/modules/library/components/PluginsSidebar.tsx +271 -238
- package/src/modules/library/components/PluginsSidebarMenu.tsx +26 -1
- package/src/modules/library/components/RenamePluginDialog.tsx +136 -0
- package/src/modules/library/components/ShareButton.tsx +17 -0
- package/src/modules/library/components/SkillsTree.tsx +204 -0
- package/src/modules/library/components/StatusDot.tsx +1 -0
- package/src/modules/library/components/TeamRoute.tsx +15 -0
- package/src/modules/library/components/__tests__/upload-notices-once-per-page.test.tsx +144 -0
- package/src/modules/library/components/plugin-page-parts.tsx +132 -23
- package/src/modules/library/components/skill-page/SharedViaPlugins.tsx +212 -0
- package/src/modules/library/components/skill-page/SkillFilePane.tsx +5 -0
- package/src/modules/library/components/skill-page/SkillPage.tsx +337 -121
- package/src/modules/library/components/tool-page/DeleteToolDialog.tsx +218 -0
- package/src/modules/library/components/tool-page/ToolConnectionSection.tsx +79 -178
- package/src/modules/library/components/tool-page/ToolPage.tsx +116 -17
- package/src/modules/library/components/tool-page/ToolVarRow.tsx +42 -41
- package/src/modules/library/hooks/__tests__/useLibraryData.test.ts +98 -0
- package/src/modules/library/hooks/useJoinRequests.ts +48 -18
- package/src/modules/library/hooks/useLibraryData.ts +92 -19
- package/src/modules/library/routes/LibraryRoutes.tsx +14 -11
- package/src/modules/library/routes/WorkspaceItemRoute.tsx +229 -82
- package/src/modules/library/routes/library-paths.ts +46 -35
- package/src/modules/library/services/library.api.ts +89 -17
- package/src/modules/library/services/plugins.api.ts +161 -9
- package/src/modules/library/services/teams.api.ts +15 -0
- package/src/modules/library/services/tools.api.ts +78 -0
- package/src/modules/library/state/library-data.tsx +268 -37
- package/src/modules/library/utils/personal-plugin.ts +13 -15
- package/src/modules/library/utils/plugin-entries.ts +134 -0
- package/src/modules/library/utils/plugin-summary.ts +102 -0
- package/src/modules/library/utils/status.ts +204 -35
- package/src/modules/onboarding/__tests__/creator-welcome.test.tsx +11 -3
- package/src/modules/onboarding/__tests__/onboarding.test.tsx +853 -760
- package/src/modules/onboarding/agent-clients.ts +55 -23
- package/src/modules/onboarding/components/ConnectAgentPill.tsx +5 -1
- package/src/modules/onboarding/components/WelcomePage.tsx +98 -62
- package/src/modules/pr/services/pr-merge.api.ts +2 -1
- package/src/modules/review/components/MarkdownDiffViewer.tsx +53 -8
- package/src/modules/review/components/ReviewPanel.tsx +15 -17
- package/src/modules/review/components/__tests__/MarkdownDiffViewer.test.tsx +64 -0
- package/src/modules/review/components/__tests__/ReviewPanel.test.tsx +25 -1
- package/src/modules/secrets-vault/components/ConnectToolsPage.tsx +454 -117
- package/src/modules/secrets-vault/components/SecretsPage.tsx +48 -7
- package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +84 -5
- package/src/modules/secrets-vault/components/__tests__/ConnectToolsPage.test.tsx +425 -0
- package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +417 -82
- package/src/modules/secrets-vault/components/__tests__/ToolSecretsPanel.test.tsx +105 -0
- package/src/modules/secrets-vault/components/__tests__/connect-lists-what-the-banner-counted.test.tsx +407 -0
- package/src/modules/secrets-vault/probe/SavedKeyProbeResult.tsx +98 -0
- package/src/modules/secrets-vault/probe/__tests__/probe-verdict.test.ts +160 -0
- package/src/modules/secrets-vault/probe/probe-verdict.ts +108 -0
- package/src/modules/secrets-vault/probe/useSavedKeyProbe.ts +228 -0
- package/src/modules/secrets-vault/services/connect.api.ts +36 -5
- package/src/modules/secrets-vault/utils/connect-status.ts +98 -0
- package/src/modules/settings/components/ClaudeConnectionCard.tsx +154 -0
- package/src/modules/settings/components/ClaudeConnectionFields.tsx +23 -0
- package/src/modules/settings/components/DeploymentPage.tsx +16 -22
- package/src/modules/settings/components/MarketplaceSection.tsx +152 -0
- package/src/modules/settings/components/__tests__/ClaudeConnectionCard.test.tsx +63 -0
- package/src/modules/settings/components/__tests__/DeploymentPage.test.tsx +74 -1
- package/src/modules/settings/components/__tests__/MarketplaceSection.test.tsx +325 -0
- package/src/modules/settings/components/__tests__/SettingsLayout.test.tsx +5 -5
- package/src/modules/settings/services/github-facade.api.ts +66 -0
- package/src/modules/settings/settings-nav-items.tsx +10 -2
- package/src/modules/setup/__tests__/setup.oidc.test.tsx +172 -0
- package/src/modules/setup/__tests__/setup.probe-refusal.test.tsx +123 -0
- package/src/modules/setup/__tests__/setup.test.tsx +615 -4
- package/src/modules/setup/__tests__/useSetupStatus.test.tsx +130 -0
- package/src/modules/setup/components/SetupGate.tsx +16 -16
- package/src/modules/setup/components/SetupScreen.tsx +711 -40
- package/src/modules/setup/hooks/useSetupStatus.ts +93 -0
- package/src/modules/setup/services/setup.api.ts +218 -3
- package/src/modules/setup/utils/__tests__/root-folders.test.ts +72 -0
- package/src/modules/setup/utils/root-folders.ts +46 -0
- package/src/modules/toolbar/assets/claude-setup/01-add-manually.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/02-add-configuration.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/03-connect-account.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/04-pick-instance.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/05-plugins-add.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/06-add-marketplace.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/07-paste-url-sync.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/08-install-plugins.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/09-select-repository.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/10-connector-not-added.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/11-add-custom-connector.webp +0 -0
- package/src/modules/toolbar/assets/claude-setup/README.md +68 -0
- package/src/modules/toolbar/components/AgentInstructionsCard.tsx +296 -0
- package/src/modules/toolbar/components/ClaudeMarketplaceCarousel.tsx +107 -0
- package/src/modules/toolbar/components/ClaudeRegistrationSteps.tsx +127 -0
- package/src/modules/toolbar/components/CoworkSetupSteps.tsx +100 -0
- package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +395 -124
- package/src/modules/toolbar/components/ScreenshotStep.tsx +77 -0
- package/src/modules/toolbar/components/SetupCarousel.tsx +177 -0
- package/src/modules/toolbar/components/__tests__/AgentInstructionsCard.test.tsx +370 -0
- package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +659 -36
- package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +2 -2
- package/src/modules/toolbar/components/__tests__/claude-setup-shots.test.ts +104 -0
- package/src/modules/toolbar/components/claude-connector-slide.tsx +38 -0
- package/src/modules/toolbar/components/claude-setup-shots.ts +167 -0
- package/src/modules/toolbar/components/deployment-address.ts +29 -0
- package/src/modules/toolbar/components/setup-step-parts.tsx +35 -0
- package/src/modules/toolbar/services/__tests__/agent-instructions.api.test.ts +89 -0
- package/src/modules/toolbar/services/agent-instructions.api.ts +167 -0
- package/src/modules/toolbar/services/external-api-keys.api.ts +8 -0
- package/src/modules/workflow/state/ChangeRequestStaleBinder.tsx +43 -0
- package/src/modules/workflow/state/EventBusProvider.tsx +122 -11
- package/src/modules/workflow/state/__tests__/EventBusProvider.storage.test.tsx +87 -0
- package/src/modules/workflow/state/__tests__/EventBusProvider.watch.test.tsx +223 -0
- package/src/modules/workflow/state/event-bus.context.ts +10 -0
- package/src/modules/workspace/__tests__/testFixtures.ts +6 -3
- package/src/modules/workspace/components/FileExplorer.tsx +1527 -367
- package/src/modules/workspace/components/FileRoute.tsx +376 -22
- package/src/modules/workspace/components/FileViewer.tsx +166 -45
- package/src/modules/workspace/components/KbDocumentShell.tsx +50 -6
- package/src/modules/workspace/components/KbPageHeader.tsx +120 -55
- package/src/modules/workspace/components/TreeActionConfirm.tsx +350 -0
- package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +2473 -129
- package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +768 -16
- package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +332 -12
- package/src/modules/workspace/components/__tests__/KbDocumentShell.test.tsx +39 -0
- package/src/modules/workspace/components/__tests__/KbPageHeader.test.tsx +33 -20
- package/src/modules/workspace/components/renderers/DocxRenderer.tsx +4 -5
- package/src/modules/workspace/components/renderers/DownloadFileButton.tsx +13 -4
- package/src/modules/workspace/components/renderers/EmailRenderer.tsx +4 -3
- package/src/modules/workspace/components/renderers/HtmlRenderer.tsx +8 -14
- package/src/modules/workspace/components/renderers/ImageRenderer.tsx +75 -16
- package/src/modules/workspace/components/renderers/KbImage.tsx +180 -0
- package/src/modules/workspace/components/renderers/KbMarkdownView.tsx +22 -6
- package/src/modules/workspace/components/renderers/MarkdownRenderer.tsx +48 -22
- package/src/modules/workspace/components/renderers/PdfRenderer.tsx +4 -5
- package/src/modules/workspace/components/renderers/PptxRenderer.tsx +4 -3
- package/src/modules/workspace/components/renderers/XlsxRenderer.tsx +4 -3
- package/src/modules/workspace/components/renderers/__tests__/DocxRenderer.test.tsx +12 -0
- package/src/modules/workspace/components/renderers/__tests__/DownloadFileButton.test.tsx +57 -9
- package/src/modules/workspace/components/renderers/__tests__/EmailRenderer.test.tsx +13 -1
- package/src/modules/workspace/components/renderers/__tests__/ImageRenderer.test.tsx +163 -0
- package/src/modules/workspace/components/renderers/__tests__/KbMarkdownView.test.tsx +237 -0
- package/src/modules/workspace/components/renderers/__tests__/MarkdownRenderer.test.tsx +108 -14
- package/src/modules/workspace/components/renderers/__tests__/PptxRenderer.test.tsx +14 -1
- package/src/modules/workspace/components/renderers/__tests__/XlsxRenderer.test.tsx +16 -1
- package/src/modules/workspace/components/renderers/__tests__/rendererSelection.test.tsx +66 -1
- package/src/modules/workspace/components/renderers/index.ts +53 -2
- package/src/modules/workspace/components/renderers/kbMarkdownPipeline.tsx +25 -4
- package/src/modules/workspace/components/renderers/rendererWorkspace.ts +40 -0
- package/src/modules/workspace/hooks/__tests__/useImageRevision.test.tsx +174 -0
- package/src/modules/workspace/hooks/__tests__/useOpenChangeRequests.test.tsx +179 -1
- package/src/modules/workspace/hooks/__tests__/useWorkspaceImageResolver.test.tsx +122 -0
- package/src/modules/workspace/hooks/__tests__/useWorkspaceState.test.tsx +892 -7
- package/src/modules/workspace/hooks/useImageRevision.ts +101 -0
- package/src/modules/workspace/hooks/useMergedWorkspaceTree.ts +89 -0
- package/src/modules/workspace/hooks/useWorkspaceImageResolver.ts +55 -0
- package/src/modules/workspace/hooks/useWorkspaceState.ts +438 -66
- package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +279 -3
- package/src/modules/workspace/routing/kb-routes.ts +207 -30
- package/src/modules/workspace/services/__tests__/workspace.api.test.ts +57 -1
- package/src/modules/workspace/services/workspace.api.ts +57 -4
- package/src/modules/workspace/state/__tests__/applied-request-clears-pending.test.tsx +343 -0
- package/src/modules/workspace/state/__tests__/upload-lands-where-it-was-dropped.test.tsx +158 -0
- package/src/modules/workspace/state/open-change-requests.tsx +100 -12
- package/src/modules/workspace/state/workspace.context.ts +130 -16
- package/src/modules/workspace/utils/__tests__/file-trace.test.ts +73 -0
- package/src/modules/workspace/utils/__tests__/fileTree.test.ts +234 -5
- package/src/modules/workspace/utils/__tests__/pasteLink.test.ts +76 -0
- package/src/modules/workspace/utils/__tests__/treeConfirm.test.ts +364 -0
- package/src/modules/workspace/utils/__tests__/uploadError.test.ts +35 -0
- package/src/modules/workspace/utils/file-trace.ts +50 -0
- package/src/modules/workspace/utils/fileTree.ts +126 -52
- package/src/modules/workspace/utils/frontmatter.ts +8 -4
- package/src/modules/workspace/utils/pasteLink.ts +90 -0
- package/src/modules/workspace/utils/treeConfirm.ts +338 -0
- package/src/modules/workspace/utils/uploadError.ts +29 -0
- package/src/shared/__tests__/marketplace-url.test.ts +59 -0
- package/src/shared/components/Badge.tsx +3 -1
- package/src/shared/components/Banner.tsx +5 -1
- package/src/shared/components/Button.tsx +16 -2
- package/src/shared/components/Dialog.tsx +27 -11
- package/src/shared/components/Menu.tsx +13 -1
- package/src/shared/components/PageShell.tsx +13 -8
- package/src/shared/components/__tests__/primitives.test.tsx +116 -2
- package/src/shared/components/__tests__/useFocusHandoff.test.tsx +192 -0
- package/src/shared/components/index.ts +2 -0
- package/src/shared/components/useDismissableMenu.ts +32 -10
- package/src/shared/components/useFocusHandoff.ts +51 -0
- package/src/shared/components/useLatestRef.ts +28 -0
- package/src/shared/markdown/Markdown.tsx +12 -3
- package/src/shared/markdown/__tests__/escapeSpacesInLinkDestinations.test.ts +39 -0
- package/src/shared/markdown/hrefs.ts +50 -0
- package/src/shared/marketplace-url.ts +118 -0
- package/src/shared/mcp/ChatGptInstallLink.tsx +3 -3
- package/src/shared/mcp/ConnectionInstructions.tsx +38 -27
- package/src/shared/mcp/__tests__/connect-snippets.test.ts +3 -3
- package/src/shared/mcp/connect-snippets.ts +14 -9
- package/src/shared/mcp/index.ts +1 -1
- package/src/shared/theme/__tests__/header-band.test.ts +197 -0
- package/src/shared/theme/header.ts +75 -0
- package/src/shared/theme/measure.ts +7 -4
- package/src/shared/theme/tokens.css +34 -0
- package/src/modules/library/__tests__/PluginsIndexPage.test.tsx +0 -363
- package/src/modules/library/__tests__/PluginsSidebar.locked.test.tsx +0 -97
- package/src/modules/library/components/PluginsIndexPage.tsx +0 -265
- package/src/modules/update-check/__tests__/UpdateBanner.test.tsx +0 -126
- package/src/modules/update-check/components/UpdateBanner.tsx +0 -92
- package/src/modules/update-check/services/update-check.api.ts +0 -24
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The seam: the sidebar's header row and a page's title bar, measured.
|
|
3
|
+
*
|
|
4
|
+
* `shared/theme/__tests__/header-band.test.ts` checks that both sides go
|
|
5
|
+
* through `HEADER_BAND`. That is the contract; this is the consequence — the
|
|
6
|
+
* two rows RENDER to the same height, with the real token, in the same
|
|
7
|
+
* document, at the widths the ticket names.
|
|
8
|
+
*
|
|
9
|
+
* The stylesheet under these assertions is the PRODUCTION one. `src/index.css`
|
|
10
|
+
* — the app's real entry, Tailwind and the design tokens and the typography
|
|
11
|
+
* plugin — is handed to Tailwind's own compiler here and the CSS it emits is
|
|
12
|
+
* what the document is measured against. Nothing about the height is restated
|
|
13
|
+
* in this file: not the token's value, not the `.h-header` rule. A token
|
|
14
|
+
* renamed, a token moved out of `@theme`, a `@import` dropped from the entry,
|
|
15
|
+
* an upgrade that changes how a `--spacing-*` token compiles — each of those
|
|
16
|
+
* is a real regression of this seam, and each of them fails here, because the
|
|
17
|
+
* rule the browser would get is the rule this test gets.
|
|
18
|
+
*/
|
|
19
|
+
import { describe, it, expect, beforeAll, beforeEach, afterAll } from 'vitest';
|
|
20
|
+
import { render, screen } from '@testing-library/react';
|
|
21
|
+
import { readFileSync } from 'node:fs';
|
|
22
|
+
import { createRequire } from 'node:module';
|
|
23
|
+
import { dirname, join, resolve } from 'node:path';
|
|
24
|
+
import { fileURLToPath } from 'node:url';
|
|
25
|
+
import { compile } from 'tailwindcss';
|
|
26
|
+
import { SidebarFrame } from '../components/SidebarFrame';
|
|
27
|
+
import {
|
|
28
|
+
SIDEBAR_DEFAULT_WIDTH,
|
|
29
|
+
SIDEBAR_MAX_WIDTH,
|
|
30
|
+
SIDEBAR_MIN_WIDTH,
|
|
31
|
+
setSidebarCollapsed,
|
|
32
|
+
setSidebarNarrow,
|
|
33
|
+
setSidebarWidth,
|
|
34
|
+
toggleSidebar,
|
|
35
|
+
} from '../state/sidebar';
|
|
36
|
+
import { KbPageHeader } from '../../workspace/components/KbPageHeader';
|
|
37
|
+
import { KbDocumentShell } from '../../workspace/components/KbDocumentShell';
|
|
38
|
+
import {
|
|
39
|
+
HEADER_BAND,
|
|
40
|
+
HEADER_COLUMN_TOP,
|
|
41
|
+
PAGE_HEADER_TESTID,
|
|
42
|
+
SIDEBAR_HEADER_TESTID,
|
|
43
|
+
} from '../../../shared/theme/header';
|
|
44
|
+
|
|
45
|
+
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
46
|
+
/** `src/`, three levels up from `modules/layout/__tests__`. */
|
|
47
|
+
const SRC = join(HERE, '..', '..', '..');
|
|
48
|
+
/** The application's real stylesheet entry — what `apps/web` imports. */
|
|
49
|
+
const APP_STYLESHEET = join(SRC, 'index.css');
|
|
50
|
+
/** Resolved from the package root, so pnpm's symlinked tree answers. */
|
|
51
|
+
const requirePackage = createRequire(join(SRC, '..', 'package.json'));
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The app's CSS, compiled by Tailwind exactly as the build does it.
|
|
55
|
+
*
|
|
56
|
+
* `build()` takes the class names the app uses; a utility nobody names is a
|
|
57
|
+
* utility Tailwind does not emit, which is the whole point of the engine and
|
|
58
|
+
* the reason this has to be told what the band wears. It is told by READING
|
|
59
|
+
* `HEADER_BAND` — so the classes compiled here can never drift from the
|
|
60
|
+
* classes rendered below.
|
|
61
|
+
*/
|
|
62
|
+
async function compileAppStylesheet(candidates: string[]): Promise<string> {
|
|
63
|
+
const compiler = await compile(readFileSync(APP_STYLESHEET, 'utf8'), {
|
|
64
|
+
base: dirname(APP_STYLESHEET),
|
|
65
|
+
loadStylesheet: async (id, base) => {
|
|
66
|
+
// `@import 'tailwindcss'` is a package, not a path; everything else in
|
|
67
|
+
// this tree is relative to the file that imported it.
|
|
68
|
+
const path =
|
|
69
|
+
id === 'tailwindcss' ? requirePackage.resolve('tailwindcss/index.css') : resolve(base, id);
|
|
70
|
+
return { path, base: dirname(path), content: readFileSync(path, 'utf8') };
|
|
71
|
+
},
|
|
72
|
+
loadModule: async (id, base) => {
|
|
73
|
+
const path = requirePackage.resolve(id, { paths: [base] });
|
|
74
|
+
const loaded: { default?: unknown } = await import(path);
|
|
75
|
+
return { path, base: dirname(path), module: loaded.default ?? loaded };
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
return compiler.build(candidates);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Unwrap `@layer` — the one edit this file makes to the compiler's output.
|
|
83
|
+
*
|
|
84
|
+
* happy-dom does not implement cascade layers: it parses `@layer utilities {
|
|
85
|
+
* … }` and then matches nothing inside it, so every rule Tailwind emits would
|
|
86
|
+
* be invisible and every height would read `''`. Unwrapping is safe to do
|
|
87
|
+
* here and nowhere else, because the compiled sheet is the ONLY stylesheet in
|
|
88
|
+
* the document — layers order rules against each other, and with one sheet
|
|
89
|
+
* and one rule per property there is nothing to order. The declarations
|
|
90
|
+
* themselves are untouched; this moves braces, never values.
|
|
91
|
+
*/
|
|
92
|
+
function flattenCascadeLayers(css: string): string {
|
|
93
|
+
// `@layer theme, base, components, utilities;` — the ordering statement,
|
|
94
|
+
// which has no block and nothing to unwrap.
|
|
95
|
+
let out = css.replace(/@layer[^;{]*;/g, '');
|
|
96
|
+
for (;;) {
|
|
97
|
+
const opener = /@layer[^;{]*\{/.exec(out);
|
|
98
|
+
if (!opener) return out;
|
|
99
|
+
// Walk to the matching close brace: the block holds nested rules, so the
|
|
100
|
+
// first `}` after it is almost never the right one.
|
|
101
|
+
let depth = 0;
|
|
102
|
+
let end = -1;
|
|
103
|
+
for (let i = opener.index + opener[0].length - 1; i < out.length; i++) {
|
|
104
|
+
if (out[i] === '{') depth++;
|
|
105
|
+
else if (out[i] === '}' && --depth === 0) {
|
|
106
|
+
end = i;
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (end === -1) throw new Error('unbalanced @layer block in the compiled stylesheet');
|
|
111
|
+
out =
|
|
112
|
+
out.slice(0, opener.index) +
|
|
113
|
+
out.slice(opener.index + opener[0].length, end) +
|
|
114
|
+
out.slice(end + 1);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* `--spacing-header` as the BUILD resolves it, read back out of the compiled
|
|
120
|
+
* CSS. Not out of `tokens.css`: a value a test parses from source is a value
|
|
121
|
+
* the test has decided for itself, and what the seam depends on is the one
|
|
122
|
+
* the browser is served. Every assertion below compares against this, so
|
|
123
|
+
* there is no second copy of the number anywhere in the file.
|
|
124
|
+
*/
|
|
125
|
+
function tokenHeightIn(css: string): string {
|
|
126
|
+
const match = css.match(/--spacing-header:\s*([^;]+);/);
|
|
127
|
+
if (!match) throw new Error('the compiled stylesheet declares no --spacing-header');
|
|
128
|
+
return match[1]!.trim();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
let headerHeight: string;
|
|
132
|
+
|
|
133
|
+
/** The ticket's three desktop widths. */
|
|
134
|
+
const WIDTHS = [1280, 1440, 1920];
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Move the viewport. happy-dom answers `matchMedia` out of `innerWidth`, so
|
|
138
|
+
* this is how a test reaches a given desktop width — there is no window to
|
|
139
|
+
* resize. Same helper `SidebarFrameResponsive` uses to cross the narrow
|
|
140
|
+
* breakpoint.
|
|
141
|
+
*/
|
|
142
|
+
function setViewportWidth(width: number): void {
|
|
143
|
+
const testWindow = window as typeof window & {
|
|
144
|
+
happyDOM: { setInnerWidth(value: number): void };
|
|
145
|
+
};
|
|
146
|
+
testWindow.happyDOM.setInnerWidth(width);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
let stylesheet: HTMLStyleElement;
|
|
150
|
+
|
|
151
|
+
beforeAll(async () => {
|
|
152
|
+
// The candidates are the band's own classes, read off the constant the app
|
|
153
|
+
// renders — `flex h-header flex-none items-center` today, whatever it says
|
|
154
|
+
// tomorrow. `HEADER_COLUMN_TOP` rides along because the column's offset is
|
|
155
|
+
// the other half of the seam.
|
|
156
|
+
const css = await compileAppStylesheet(`${HEADER_BAND} ${HEADER_COLUMN_TOP}`.split(/\s+/));
|
|
157
|
+
|
|
158
|
+
// The compiled output has to CONTAIN the height utility, or the rest of
|
|
159
|
+
// this file is measuring an element with no rule behind it and every
|
|
160
|
+
// `auto === auto` comparison passes. This is the assertion that catches a
|
|
161
|
+
// Tailwind or configuration regression rather than a markup one.
|
|
162
|
+
expect(css).toMatch(/\.h-header\s*\{[^}]*height:\s*var\(--spacing-header\)/);
|
|
163
|
+
headerHeight = tokenHeightIn(css);
|
|
164
|
+
|
|
165
|
+
stylesheet = document.createElement('style');
|
|
166
|
+
stylesheet.textContent = flattenCascadeLayers(css);
|
|
167
|
+
document.head.appendChild(stylesheet);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
afterAll(() => stylesheet.remove());
|
|
171
|
+
|
|
172
|
+
beforeEach(() => {
|
|
173
|
+
// A desktop width, an open sidebar, the default column — the state the seam
|
|
174
|
+
// is about. The store is module-global, so a case that collapses or drags
|
|
175
|
+
// the sidebar would otherwise hand the next one a narrow drawer.
|
|
176
|
+
setViewportWidth(WIDTHS[1]!);
|
|
177
|
+
setSidebarNarrow(false);
|
|
178
|
+
setSidebarCollapsed(false);
|
|
179
|
+
setSidebarWidth(SIDEBAR_DEFAULT_WIDTH);
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Both sides of the seam, each in the frame that owns it.
|
|
184
|
+
*
|
|
185
|
+
* The page header goes through `KbDocumentShell`, not straight into the
|
|
186
|
+
* document. That is not ceremony: the header rendered bare is exactly what
|
|
187
|
+
* this file used to assert, and it is why a 54px misalignment on the file
|
|
188
|
+
* page reached staging. A bare header has no column above it, so it cannot
|
|
189
|
+
* be anything but the first row — the test could not see the tab strip that
|
|
190
|
+
* was pushing it down, because in the test the tab strip did not exist.
|
|
191
|
+
*
|
|
192
|
+
* `children` is a stand-in for that tab strip: something the page renders
|
|
193
|
+
* inside the column BESIDE the title bar. If the band ever stops opening the
|
|
194
|
+
* column, this is where it shows.
|
|
195
|
+
*/
|
|
196
|
+
function renderSeam() {
|
|
197
|
+
return render(
|
|
198
|
+
<>
|
|
199
|
+
<SidebarFrame label="File explorer" header={<div>Connect your agent</div>}>
|
|
200
|
+
<nav>tree</nav>
|
|
201
|
+
</SidebarFrame>
|
|
202
|
+
<KbDocumentShell header={<PageHeader />}>
|
|
203
|
+
<div role="tablist" aria-label="Open files">
|
|
204
|
+
<span>Onboarding.md</span>
|
|
205
|
+
</div>
|
|
206
|
+
<p>The document</p>
|
|
207
|
+
</KbDocumentShell>
|
|
208
|
+
</>,
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function PageHeader() {
|
|
213
|
+
return (
|
|
214
|
+
<KbPageHeader
|
|
215
|
+
path="Knowledge/Onboarding.md"
|
|
216
|
+
canWrite
|
|
217
|
+
editMode={false}
|
|
218
|
+
entering={false}
|
|
219
|
+
proposeMode={false}
|
|
220
|
+
proposalBusy={false}
|
|
221
|
+
onPropose={() => {}}
|
|
222
|
+
onSendProposal={() => {}}
|
|
223
|
+
onDiscardProposal={() => {}}
|
|
224
|
+
lockedBy={null}
|
|
225
|
+
historyAvailable
|
|
226
|
+
isDirty={false}
|
|
227
|
+
waitingOnAgentUpdate={false}
|
|
228
|
+
isReviewingPending={false}
|
|
229
|
+
activeTab="content"
|
|
230
|
+
onEdit={() => {}}
|
|
231
|
+
onDone={() => {}}
|
|
232
|
+
onOpenHistory={() => {}}
|
|
233
|
+
onShare={() => {}}
|
|
234
|
+
onCopyLink={async () => true}
|
|
235
|
+
/>
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
const heightOf = (testId: string) =>
|
|
240
|
+
window.getComputedStyle(screen.getByTestId(testId)).height;
|
|
241
|
+
|
|
242
|
+
/** The column a band opens — the element the band is the first row of. */
|
|
243
|
+
const columnOf = (testId: string) => screen.getByTestId(testId).parentElement!;
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Everything drawn above a band inside its own column.
|
|
247
|
+
*
|
|
248
|
+
* Zero is the contract. Anything here is vertical space between the column's
|
|
249
|
+
* top edge and the band's, which moves the band down by exactly that much and
|
|
250
|
+
* breaks the seam however precisely the two heights agree.
|
|
251
|
+
*/
|
|
252
|
+
function drawnAbove(testId: string): Element[] {
|
|
253
|
+
const band = screen.getByTestId(testId);
|
|
254
|
+
const siblings: Element[] = [];
|
|
255
|
+
for (let node = band.previousElementSibling; node; node = node.previousElementSibling) {
|
|
256
|
+
siblings.push(node);
|
|
257
|
+
}
|
|
258
|
+
return siblings;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
describe('the sidebar header row and the page title bar', () => {
|
|
262
|
+
it.each(WIDTHS)('are the same height at %ipx wide', (width) => {
|
|
263
|
+
setViewportWidth(width);
|
|
264
|
+
renderSeam();
|
|
265
|
+
|
|
266
|
+
expect(heightOf(SIDEBAR_HEADER_TESTID)).toBe(heightOf(PAGE_HEADER_TESTID));
|
|
267
|
+
// And it is the TOKEN's height, not two elements agreeing on `auto`:
|
|
268
|
+
// `auto === auto` would pass the line above while the page rendered as
|
|
269
|
+
// broken as it did before the fix.
|
|
270
|
+
expect(heightOf(SIDEBAR_HEADER_TESTID)).toBe(headerHeight);
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
it('keeps the page title bar the same height while the sidebar collapses and reopens', () => {
|
|
274
|
+
renderSeam();
|
|
275
|
+
const open = heightOf(PAGE_HEADER_TESTID);
|
|
276
|
+
|
|
277
|
+
// Collapsing is a WIDTH change on the frame; nothing about it may reach
|
|
278
|
+
// the height of either header. The sidebar's own row goes with it, so the
|
|
279
|
+
// assertion that matters on the way through is the page's.
|
|
280
|
+
toggleSidebar();
|
|
281
|
+
expect(heightOf(PAGE_HEADER_TESTID)).toBe(open);
|
|
282
|
+
expect(heightOf(SIDEBAR_HEADER_TESTID)).toBe(open);
|
|
283
|
+
|
|
284
|
+
toggleSidebar();
|
|
285
|
+
expect(heightOf(PAGE_HEADER_TESTID)).toBe(open);
|
|
286
|
+
expect(heightOf(SIDEBAR_HEADER_TESTID)).toBe(open);
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
it('keeps both heights while the sidebar is being resized', () => {
|
|
290
|
+
renderSeam();
|
|
291
|
+
|
|
292
|
+
// The narrowest the frame allows, a width in the middle, and the widest —
|
|
293
|
+
// the span a drag covers. The header row is `w-full` inside the column,
|
|
294
|
+
// so a width that changed its height would mean the row had started
|
|
295
|
+
// wrapping: the failure the band and the title's `truncate` prevent.
|
|
296
|
+
// `false` is the mid-drag write, the one that does not persist.
|
|
297
|
+
for (const width of [SIDEBAR_MIN_WIDTH, SIDEBAR_DEFAULT_WIDTH, SIDEBAR_MAX_WIDTH]) {
|
|
298
|
+
setSidebarWidth(width, false);
|
|
299
|
+
expect(heightOf(SIDEBAR_HEADER_TESTID)).toBe(heightOf(PAGE_HEADER_TESTID));
|
|
300
|
+
expect(heightOf(SIDEBAR_HEADER_TESTID)).toBe(headerHeight);
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
it('reserves the row for a header that draws nothing', () => {
|
|
305
|
+
// Knowledge and the Library both pass the connect-your-agent pill, which
|
|
306
|
+
// renders NOTHING once onboarding is done. If the row collapsed with it,
|
|
307
|
+
// the page's title bar would be left lined up against a nav that had
|
|
308
|
+
// moved a band's height up — the seam would break for exactly the people
|
|
309
|
+
// who have finished setting the product up.
|
|
310
|
+
const DismissedPill = () => null;
|
|
311
|
+
render(
|
|
312
|
+
<SidebarFrame label="File explorer" header={<DismissedPill />}>
|
|
313
|
+
<nav>tree</nav>
|
|
314
|
+
</SidebarFrame>,
|
|
315
|
+
);
|
|
316
|
+
expect(heightOf(SIDEBAR_HEADER_TESTID)).toBe(headerHeight);
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
it('renders no band for a surface that declares no header', () => {
|
|
320
|
+
// Settings fills the same frame with no header slot and has no title bar
|
|
321
|
+
// on the other side of the seam. A band there would be a band's worth of
|
|
322
|
+
// empty space above its nav, holding a line with nothing.
|
|
323
|
+
render(
|
|
324
|
+
<SidebarFrame label="Settings">
|
|
325
|
+
<nav>settings</nav>
|
|
326
|
+
</SidebarFrame>,
|
|
327
|
+
);
|
|
328
|
+
expect(screen.queryByTestId(SIDEBAR_HEADER_TESTID)).toBeNull();
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* The other half of AC1, and the half that reached staging: the two bands
|
|
334
|
+
* have to START at the same place, not merely be the same height.
|
|
335
|
+
*
|
|
336
|
+
* These assertions are STRUCTURAL, and deliberately so. happy-dom has no
|
|
337
|
+
* layout engine — `getBoundingClientRect` answers an all-zero rect for every
|
|
338
|
+
* element — so a top edge is not a thing this suite can measure, and a test
|
|
339
|
+
* that pretended to would compare 0 with 0 and pass through anything. What
|
|
340
|
+
* IS checkable is the two facts that together fix the top edge: each column
|
|
341
|
+
* opens on the same offset, and the band is the first thing in it. Break
|
|
342
|
+
* either and the seam moves; hold both and it cannot.
|
|
343
|
+
*
|
|
344
|
+
* A real browser measured the consequence: Staging Testing put the sidebar
|
|
345
|
+
* band and the library band at y=61 and the file page's at y=115.13, because
|
|
346
|
+
* the file page held the second fact and nothing checked it.
|
|
347
|
+
*/
|
|
348
|
+
describe('the two bands open at the same offset', () => {
|
|
349
|
+
it('each opens the column it is in — nothing is drawn above either', () => {
|
|
350
|
+
renderSeam();
|
|
351
|
+
expect(drawnAbove(SIDEBAR_HEADER_TESTID)).toEqual([]);
|
|
352
|
+
expect(drawnAbove(PAGE_HEADER_TESTID)).toEqual([]);
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
it('the page column holds what used to sit above the band, below it', () => {
|
|
356
|
+
renderSeam();
|
|
357
|
+
const band = screen.getByTestId(PAGE_HEADER_TESTID);
|
|
358
|
+
const tabs = screen.getByRole('tablist', { name: 'Open files' });
|
|
359
|
+
// Same column — the tab strip did not move out of the measure, it moved
|
|
360
|
+
// under the title (proto:700-705 keeps one column; this changes the order
|
|
361
|
+
// inside it).
|
|
362
|
+
expect(tabs.parentElement).toBe(band.parentElement);
|
|
363
|
+
expect(band.compareDocumentPosition(tabs) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
it('both columns open on the one shared offset', () => {
|
|
367
|
+
renderSeam();
|
|
368
|
+
// Not "both contain pt-3": both contain the SAME constant, read from the
|
|
369
|
+
// module the app renders, so a change to it moves this test with it.
|
|
370
|
+
for (const testId of [SIDEBAR_HEADER_TESTID, PAGE_HEADER_TESTID]) {
|
|
371
|
+
expect(columnOf(testId).className.split(/\s+/)).toContain(HEADER_COLUMN_TOP);
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
it('a full-bleed page opens on that offset too', () => {
|
|
376
|
+
// The variant a PDF, an image or a spreadsheet gets. It gives up the
|
|
377
|
+
// measure and the gutters — it used to give up the offset with them, and
|
|
378
|
+
// its title bar sat a column-offset higher than the sidebar's row.
|
|
379
|
+
render(
|
|
380
|
+
<KbDocumentShell variant="full-bleed" header={<PageHeader />}>
|
|
381
|
+
<iframe title="A PDF" />
|
|
382
|
+
</KbDocumentShell>,
|
|
383
|
+
);
|
|
384
|
+
expect(drawnAbove(PAGE_HEADER_TESTID)).toEqual([]);
|
|
385
|
+
expect(columnOf(PAGE_HEADER_TESTID).className.split(/\s+/)).toContain(HEADER_COLUMN_TOP);
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
it('a page with a rail opens on it as well', () => {
|
|
389
|
+
render(
|
|
390
|
+
<KbDocumentShell header={<PageHeader />} rail={<p>About this file</p>}>
|
|
391
|
+
<p>The document</p>
|
|
392
|
+
</KbDocumentShell>,
|
|
393
|
+
);
|
|
394
|
+
expect(drawnAbove(PAGE_HEADER_TESTID)).toEqual([]);
|
|
395
|
+
// Here the offset is on the grid the article sits in, so the band's own
|
|
396
|
+
// parent is the article and the offset is one level up.
|
|
397
|
+
const article = columnOf(PAGE_HEADER_TESTID);
|
|
398
|
+
expect(article.tagName).toBe('ARTICLE');
|
|
399
|
+
expect(article.parentElement!.className.split(/\s+/)).toContain(HEADER_COLUMN_TOP);
|
|
400
|
+
});
|
|
401
|
+
});
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import { render, screen, waitFor, within } from '@testing-library/react';
|
|
3
|
+
import { MemoryRouter } from 'react-router-dom';
|
|
4
|
+
import type { PullRequestSummary } from '@bevel-software/platform-shared';
|
|
5
|
+
|
|
6
|
+
const api = vi.hoisted(() => ({ listPullRequestsForMe: vi.fn() }));
|
|
7
|
+
vi.mock('../../git/services/pr.api', () => ({
|
|
8
|
+
listPullRequestsForMe: api.listPullRequestsForMe,
|
|
9
|
+
}));
|
|
10
|
+
|
|
11
|
+
import { SidebarFrame } from '../components/SidebarFrame';
|
|
12
|
+
import {
|
|
13
|
+
SIDEBAR_DEFAULT_WIDTH,
|
|
14
|
+
SIDEBAR_MIN_WIDTH,
|
|
15
|
+
setSidebarCollapsed,
|
|
16
|
+
setSidebarNarrow,
|
|
17
|
+
setSidebarWidth,
|
|
18
|
+
} from '../state/sidebar';
|
|
19
|
+
import { PluginsSidebar } from '../../library/components/PluginsSidebar';
|
|
20
|
+
import { IntegrationsSetupReminder } from '../../library/components/IntegrationsSetupReminder';
|
|
21
|
+
import { PullRequestsForMe } from '../../git/components/PullRequestsForMe';
|
|
22
|
+
import { GitContext, type GitContextValue } from '../../git/state/git.context';
|
|
23
|
+
import {
|
|
24
|
+
WorkspaceContext,
|
|
25
|
+
type WorkspaceContextValue,
|
|
26
|
+
} from '../../workspace/state/workspace.context';
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The sidebar's bottom-left rows, measured against the tree rows above them,
|
|
30
|
+
* at the two widths the ticket names: the default (212px) and the narrowest
|
|
31
|
+
* the drag handle allows (180px).
|
|
32
|
+
*
|
|
33
|
+
* This is the visual regression test, and it is arithmetic rather than a
|
|
34
|
+
* screenshot because there is no CSS engine here: happy-dom parses the
|
|
35
|
+
* markup and resolves no styles at all, so a pixel read off `getBoundingClientRect`
|
|
36
|
+
* would be zero for every element on the page and would agree with any
|
|
37
|
+
* regression whatsoever. What IS in the DOM is the utility classes, and they
|
|
38
|
+
* carry the measure: `px-2.5` is ten pixels wherever it appears. So the test
|
|
39
|
+
* resolves the spacing utilities on the chain from a row up to the sidebar
|
|
40
|
+
* column and compares the sums — the same number a ruler on the screenshot
|
|
41
|
+
* would give, arrived at from the source of the number.
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
/** Tailwind's spacing scale: one step is 4px, and `[29px]` says what it is. */
|
|
45
|
+
function spacingPx(value: string): number {
|
|
46
|
+
const arbitrary = /^\[(\d+(?:\.\d+)?)px\]$/.exec(value);
|
|
47
|
+
if (arbitrary) return Number(arbitrary[1]);
|
|
48
|
+
return Number(value) * 4;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* How far this element's content sits from the sidebar's left edge: its own
|
|
53
|
+
* left padding plus every ancestor's, up to and including the column that
|
|
54
|
+
* `SidebarFrame` draws (the one carrying the frame's `px-3.5`).
|
|
55
|
+
*/
|
|
56
|
+
function leftInset(el: Element): number {
|
|
57
|
+
let total = 0;
|
|
58
|
+
for (let node: Element | null = el; node; node = node.parentElement) {
|
|
59
|
+
for (const cls of node.classList) {
|
|
60
|
+
const px = /^p([xl])-(.+)$/.exec(cls);
|
|
61
|
+
if (px) total += spacingPx(px[2]!);
|
|
62
|
+
}
|
|
63
|
+
if (node.hasAttribute('data-sidebar-column')) break;
|
|
64
|
+
}
|
|
65
|
+
return total;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Every element from `el` up to the sidebar column that would clip a focus
|
|
70
|
+
* ring drawn on `el` — named rather than counted, so a failure says which one
|
|
71
|
+
* appeared. The column itself is the ceiling: what the frame does above it is
|
|
72
|
+
* the collapse animation's business and predates the footer rows.
|
|
73
|
+
*/
|
|
74
|
+
function clipsBetweenRowAndColumn(el: Element): string[] {
|
|
75
|
+
const found: string[] = [];
|
|
76
|
+
for (let node: Element | null = el; node; node = node.parentElement) {
|
|
77
|
+
if (node.hasAttribute('data-sidebar-column')) break;
|
|
78
|
+
for (const cls of node.classList) {
|
|
79
|
+
if (/^overflow(-[xy])?-(hidden|clip|auto|scroll)$/.test(cls)) found.push(cls);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return found;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** The single spacing utility of a kind on an element, in pixels. */
|
|
86
|
+
function spacingOf(el: Element, prefix: string): number | null {
|
|
87
|
+
for (const cls of el.classList) {
|
|
88
|
+
if (cls.startsWith(`${prefix}-`)) return spacingPx(cls.slice(prefix.length + 1));
|
|
89
|
+
}
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function pr(over: Partial<PullRequestSummary> = {}): PullRequestSummary {
|
|
94
|
+
return {
|
|
95
|
+
number: 32,
|
|
96
|
+
title: 'Restate the enforcement wording so it reads as a rule',
|
|
97
|
+
author: { login: 'bevel-bot' },
|
|
98
|
+
appAuthor: { name: 'Ali Raza' },
|
|
99
|
+
branch: 'ali/wording',
|
|
100
|
+
base: 'main',
|
|
101
|
+
state: 'open',
|
|
102
|
+
createdAt: '2026-07-27T00:00:00.000Z',
|
|
103
|
+
touchedNodePaths: ['Knowledge/Foo.md'],
|
|
104
|
+
review: { approvals: 0, changesRequested: 0, pendingLogins: [] },
|
|
105
|
+
url: 'https://example.com/pr/32',
|
|
106
|
+
...over,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const git = {
|
|
111
|
+
status: { branch: 'main', hasUpstream: true, unmergedFromUpstream: false },
|
|
112
|
+
branches: [],
|
|
113
|
+
availability: 'ready',
|
|
114
|
+
lastError: null,
|
|
115
|
+
refreshStatus: async () => null,
|
|
116
|
+
refreshBranches: async () => {},
|
|
117
|
+
createBranch: async () => {},
|
|
118
|
+
deleteBranch: async () => {},
|
|
119
|
+
pull: async () => {},
|
|
120
|
+
fetchForkBase: async () => null,
|
|
121
|
+
fetchFileHistory: async () => [],
|
|
122
|
+
fetchFileDiff: async () => '',
|
|
123
|
+
fetchFileAtChange: async () => ({ baseline: null, current: null }),
|
|
124
|
+
fetchFileComparison: async () => '',
|
|
125
|
+
} as unknown as GitContextValue;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* The Library sidebar as it is actually composed: the nav in the frame, the
|
|
129
|
+
* setup reminder and the change-request dock in the frame's footer slot —
|
|
130
|
+
* the arrangement `LibraryLayout` builds.
|
|
131
|
+
*/
|
|
132
|
+
async function renderSidebarAt(width: number) {
|
|
133
|
+
setSidebarWidth(width);
|
|
134
|
+
const view = render(
|
|
135
|
+
<MemoryRouter>
|
|
136
|
+
<WorkspaceContext.Provider
|
|
137
|
+
value={{ kbDirName: 'knowledge-base' } as unknown as WorkspaceContextValue}
|
|
138
|
+
>
|
|
139
|
+
<GitContext.Provider value={git}>
|
|
140
|
+
<SidebarFrame
|
|
141
|
+
label="Library navigation"
|
|
142
|
+
footer={
|
|
143
|
+
<>
|
|
144
|
+
<IntegrationsSetupReminder count={2} onFinishSetup={() => {}} />
|
|
145
|
+
<PullRequestsForMe />
|
|
146
|
+
</>
|
|
147
|
+
}
|
|
148
|
+
>
|
|
149
|
+
<PluginsSidebar
|
|
150
|
+
filter={{ kind: 'all' }}
|
|
151
|
+
onSelect={() => {}}
|
|
152
|
+
ownedCount={2}
|
|
153
|
+
ownedAttention={0}
|
|
154
|
+
teams={[{ name: 'Engineering', count: 4, urgent: 0 }]}
|
|
155
|
+
onCreatePlugin={() => {}}
|
|
156
|
+
/>
|
|
157
|
+
</SidebarFrame>
|
|
158
|
+
</GitContext.Provider>
|
|
159
|
+
</WorkspaceContext.Provider>
|
|
160
|
+
</MemoryRouter>,
|
|
161
|
+
);
|
|
162
|
+
// The dock only exists once the queue has arrived.
|
|
163
|
+
await screen.findByRole('button', { name: 'Change requests for you' });
|
|
164
|
+
return view;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const treeRow = () => screen.getByRole('button', { name: /^Everything/ });
|
|
168
|
+
const reminder = () => screen.getByRole('button', { name: /setup/ });
|
|
169
|
+
const dockHeader = () => screen.getByRole('button', { name: 'Change requests for you' });
|
|
170
|
+
const request = () => screen.getByRole('button', { name: /Restate the enforcement/ });
|
|
171
|
+
/** Where a request's title actually lands — the row's inset plus its indent. */
|
|
172
|
+
const requestText = () => screen.getByText('Restate the enforcement wording so it reads as a rule');
|
|
173
|
+
|
|
174
|
+
beforeEach(() => {
|
|
175
|
+
api.listPullRequestsForMe.mockReset();
|
|
176
|
+
api.listPullRequestsForMe.mockResolvedValue([
|
|
177
|
+
pr({ number: 32 }),
|
|
178
|
+
pr({ number: 41, title: 'Name the folder after what is in it' }),
|
|
179
|
+
]);
|
|
180
|
+
window.localStorage.removeItem('bevel-library-sidebar-view');
|
|
181
|
+
setSidebarNarrow(false);
|
|
182
|
+
setSidebarCollapsed(false);
|
|
183
|
+
setSidebarWidth(SIDEBAR_DEFAULT_WIDTH);
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
describe.each([
|
|
187
|
+
['the default width', SIDEBAR_DEFAULT_WIDTH],
|
|
188
|
+
['the narrowest width', SIDEBAR_MIN_WIDTH],
|
|
189
|
+
])('the sidebar footer at %s', (_name, width) => {
|
|
190
|
+
it('puts both footer rows on the tree rows own left inset', async () => {
|
|
191
|
+
await renderSidebarAt(width);
|
|
192
|
+
|
|
193
|
+
const tree = leftInset(treeRow());
|
|
194
|
+
// 14px of column padding + the 10px row inset. Stated as a number as
|
|
195
|
+
// well as a comparison: if the grid itself moves, the comparison alone
|
|
196
|
+
// would still pass with all three rows wrong together.
|
|
197
|
+
expect(tree).toBe(24);
|
|
198
|
+
expect(leftInset(reminder())).toBe(tree);
|
|
199
|
+
expect(leftInset(dockHeader())).toBe(tree);
|
|
200
|
+
// A request is a CHILD of that row, indented by the caret slot (12px)
|
|
201
|
+
// and its gap (7px) so it starts under the word "Change". Measured from
|
|
202
|
+
// its TEXT rather than its row: the row sits on the shared inset like
|
|
203
|
+
// every other row, and the indent is inside it.
|
|
204
|
+
expect(leftInset(requestText())).toBe(tree + 19);
|
|
205
|
+
expect(leftInset(request())).toBe(tree);
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
it('separates the two rows by one gap, owned by the frame', async () => {
|
|
209
|
+
const { container } = await renderSidebarAt(width);
|
|
210
|
+
const group = container.querySelector('[data-sidebar-footer]') as HTMLElement;
|
|
211
|
+
|
|
212
|
+
expect(group).toContainElement(reminder());
|
|
213
|
+
expect(group).toContainElement(dockHeader());
|
|
214
|
+
// One gap for the group, and one rule above it, at a fixed distance from
|
|
215
|
+
// the tree. Each row bringing its own was the reported bug: two hairlines
|
|
216
|
+
// with nothing between them.
|
|
217
|
+
expect(spacingOf(group, 'gap')).toBe(6);
|
|
218
|
+
expect(spacingOf(group, 'mt')).toBe(8);
|
|
219
|
+
expect(spacingOf(group, 'pt')).toBe(8);
|
|
220
|
+
expect(group).toHaveClass('border-t');
|
|
221
|
+
for (const row of [reminder(), dockHeader().parentElement!]) {
|
|
222
|
+
expect(row.className).not.toMatch(/\bborder-t\b|\bmt-\d/);
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
it('keeps the count on the CHANGE REQUESTS row hard against the right edge', async () => {
|
|
227
|
+
await renderSidebarAt(width);
|
|
228
|
+
const header = dockHeader();
|
|
229
|
+
const count = within(header).getByText('2');
|
|
230
|
+
|
|
231
|
+
expect(header).toHaveClass('flex', 'items-center');
|
|
232
|
+
// Last in the row, and unable to be pushed out of it: the label gives way
|
|
233
|
+
// (`min-w-0 truncate`) and the count does not (`flex-none`).
|
|
234
|
+
expect(header.lastElementChild).toBe(count);
|
|
235
|
+
expect(count).toHaveClass('flex-none');
|
|
236
|
+
expect(screen.getByText('Change requests')).toHaveClass('min-w-0', 'flex-1', 'truncate');
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
it('truncates the reminder to an ellipsis and a tooltip, never the link', async () => {
|
|
240
|
+
await renderSidebarAt(width);
|
|
241
|
+
|
|
242
|
+
expect(screen.getByText('2 integrations need setup.')).toHaveClass('truncate', 'min-w-0');
|
|
243
|
+
expect(screen.getByText('Finish now')).toHaveClass('flex-none');
|
|
244
|
+
expect(screen.getByText('Finish now')).not.toHaveClass('truncate');
|
|
245
|
+
expect(reminder()).toHaveAttribute('title', '2 integrations need setup. Finish now');
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* The hit areas the ticket asks to leave alone. Both footer rows are still
|
|
250
|
+
* whole rows — the button IS the row, the way a tree row's is — and neither
|
|
251
|
+
* has grown a nested control or a new clip between itself and the sidebar's
|
|
252
|
+
* column.
|
|
253
|
+
*
|
|
254
|
+
* "Between itself and the column" is the whole claim, and it stops there on
|
|
255
|
+
* purpose. The frame's `<aside>` is `overflow-hidden` and always was: that
|
|
256
|
+
* is what lets the column keep its width and slide out intact while the
|
|
257
|
+
* frame animates to zero, and it clips the tree rows exactly as much as
|
|
258
|
+
* these two. What this PR must not do is add a clip BELOW it, inside the
|
|
259
|
+
* column, where only the footer rows would lose their ring.
|
|
260
|
+
*/
|
|
261
|
+
it('leaves both rows as one focusable control each', async () => {
|
|
262
|
+
await renderSidebarAt(width);
|
|
263
|
+
|
|
264
|
+
for (const row of [reminder(), dockHeader()]) {
|
|
265
|
+
expect(row.tagName).toBe('BUTTON');
|
|
266
|
+
expect(row.querySelector('button, a, [tabindex]')).toBeNull();
|
|
267
|
+
expect(clipsBetweenRowAndColumn(row)).toEqual([]);
|
|
268
|
+
}
|
|
269
|
+
expect(request()).toHaveAttribute('tabindex', '0');
|
|
270
|
+
});
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* The sidebar's own width is the one thing that moves between the two runs
|
|
275
|
+
* above, so it is worth stating that it really did move — otherwise the whole
|
|
276
|
+
* suite could be passing twice at the same width.
|
|
277
|
+
*/
|
|
278
|
+
it('is measured at two genuinely different widths', async () => {
|
|
279
|
+
const { container, unmount } = await renderSidebarAt(SIDEBAR_DEFAULT_WIDTH);
|
|
280
|
+
expect(container.querySelector('aside')).toHaveStyle({ width: '212px' });
|
|
281
|
+
unmount();
|
|
282
|
+
|
|
283
|
+
await waitFor(() => expect(screen.queryByText('Change requests')).toBeNull());
|
|
284
|
+
const narrow = await renderSidebarAt(SIDEBAR_MIN_WIDTH);
|
|
285
|
+
expect(narrow.container.querySelector('aside')).toHaveStyle({ width: '180px' });
|
|
286
|
+
});
|