@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
|
@@ -3,6 +3,7 @@ import { render, screen, waitFor, act, within } from '@testing-library/react';
|
|
|
3
3
|
import userEvent from '@testing-library/user-event';
|
|
4
4
|
import { MemoryRouter, Routes, Route, useLocation } from 'react-router-dom';
|
|
5
5
|
import { useEffect, useState } from 'react';
|
|
6
|
+
import { PAGE_HEADER_TESTID } from '../../../../shared/theme/header';
|
|
6
7
|
import type {
|
|
7
8
|
BranchInfo,
|
|
8
9
|
FileTreeEntry,
|
|
@@ -85,6 +86,9 @@ vi.mock('../../../change-requests/services/change-requests.api', () => ({
|
|
|
85
86
|
listOpenChangeRequests: vi.fn(async () => []),
|
|
86
87
|
listMyChangeRequests: myCrsMock,
|
|
87
88
|
readFileOnBranch: readBranchMock,
|
|
89
|
+
// No fork point: the change boxes fall back to the default branch, which is
|
|
90
|
+
// what these tests diff against.
|
|
91
|
+
readFileAtForkPoint: vi.fn(async () => ({ content: null, forkSha: null })),
|
|
88
92
|
}));
|
|
89
93
|
|
|
90
94
|
// The access sheet is a 1200-line dialog with its own suite and its own
|
|
@@ -131,6 +135,7 @@ import { GitContext, type GitContextValue } from '../../../git/state/git.context
|
|
|
131
135
|
import { ReviewContext, type ReviewContextValue } from '../../../review/state/review.context';
|
|
132
136
|
import { AuthContext, type AuthContextValue } from '../../../auth/state/auth.context';
|
|
133
137
|
import { OpenChangeRequestsContext } from '../../state/open-change-requests.context';
|
|
138
|
+
import { OPEN_COMPARISON_EVENT } from '../../../../core/events';
|
|
134
139
|
|
|
135
140
|
let injectPendingFromTest: ((value?: string) => void) | null = null;
|
|
136
141
|
|
|
@@ -152,12 +157,15 @@ const fetchFileHistoryMock = vi.fn(async () => [
|
|
|
152
157
|
},
|
|
153
158
|
]);
|
|
154
159
|
|
|
155
|
-
function makeGit(
|
|
160
|
+
function makeGit(
|
|
161
|
+
status: WorkingTreeStatus | null,
|
|
162
|
+
availability: GitContextValue['availability'] = 'ready',
|
|
163
|
+
): GitContextValue {
|
|
156
164
|
const branches: BranchInfo[] = [];
|
|
157
165
|
return {
|
|
158
166
|
status,
|
|
159
167
|
branches,
|
|
160
|
-
availability
|
|
168
|
+
availability,
|
|
161
169
|
lastError: null,
|
|
162
170
|
refreshStatus: async () => null,
|
|
163
171
|
refreshBranches: async () => {},
|
|
@@ -194,8 +202,11 @@ function ViewerHarness({
|
|
|
194
202
|
changeRequests = [],
|
|
195
203
|
authUser = null,
|
|
196
204
|
captureTyped = false,
|
|
205
|
+
gitAvailability = 'ready',
|
|
197
206
|
}: {
|
|
198
207
|
initialContent?: string;
|
|
208
|
+
/** What git reports about itself; the history views need `'ready'`. */
|
|
209
|
+
gitAvailability?: GitContextValue['availability'];
|
|
199
210
|
pendingValue?: string;
|
|
200
211
|
/** `null` = git status has not loaded (or failed) — there is no branch yet. */
|
|
201
212
|
branch?: string | null;
|
|
@@ -248,6 +259,9 @@ function ViewerHarness({
|
|
|
248
259
|
workspaceId: 'ws-1',
|
|
249
260
|
kbDirName,
|
|
250
261
|
fileTree,
|
|
262
|
+
bootstrapError: null,
|
|
263
|
+
workspaceBranch: 'main',
|
|
264
|
+
retryBootstrap: () => {},
|
|
251
265
|
openTabs: tab ? [tab] : [],
|
|
252
266
|
activeTab: tab,
|
|
253
267
|
dirtyTabFilenames: [],
|
|
@@ -257,8 +271,8 @@ function ViewerHarness({
|
|
|
257
271
|
hasUnsavedFileChanges: false,
|
|
258
272
|
pendingFileContent,
|
|
259
273
|
setActiveTabContent: captureTyped ? (v: string) => setOpenFileContent(v) : () => {},
|
|
260
|
-
|
|
261
|
-
|
|
274
|
+
uploadErrors: new Map(),
|
|
275
|
+
uploadNotices: new Map(),
|
|
262
276
|
clearUploadNotice: () => {},
|
|
263
277
|
isUploading: false,
|
|
264
278
|
uploadProgress: null,
|
|
@@ -272,7 +286,7 @@ function ViewerHarness({
|
|
|
272
286
|
activateTab: () => {},
|
|
273
287
|
reorderTab: () => {},
|
|
274
288
|
closeAllTabs: () => {},
|
|
275
|
-
hydrateTabs: async () => ({ surviving: [], dropped: [], denied: [] }),
|
|
289
|
+
hydrateTabs: async () => ({ surviving: [], dropped: [], denied: [], superseded: false }),
|
|
276
290
|
createFile: async () => {},
|
|
277
291
|
createDirectory: async () => {},
|
|
278
292
|
unzipHere: async () => ({ extracted: 0, skipped: [], destination: '' }),
|
|
@@ -326,7 +340,7 @@ function ViewerHarness({
|
|
|
326
340
|
const tree = (
|
|
327
341
|
<AuthContext.Provider value={auth}>
|
|
328
342
|
<WorkspaceContext.Provider value={workspace}>
|
|
329
|
-
<GitContext.Provider value={makeGit(branch ? makeStatus(branch) : null)}>
|
|
343
|
+
<GitContext.Provider value={makeGit(branch ? makeStatus(branch) : null, gitAvailability)}>
|
|
330
344
|
<ReviewContext.Provider value={review}>
|
|
331
345
|
<OpenChangeRequestsContext.Provider
|
|
332
346
|
value={{
|
|
@@ -378,6 +392,7 @@ describe('FileViewer', () => {
|
|
|
378
392
|
owners: EMPTY_ELIGIBLE,
|
|
379
393
|
};
|
|
380
394
|
accessMock.fetchFileAccess.mockClear();
|
|
395
|
+
readBranchMock.mockImplementation(async () => '');
|
|
381
396
|
// Restore the default "acquire succeeds" behaviour so a per-test 403
|
|
382
397
|
// override doesn't leak into the next test.
|
|
383
398
|
vi.mocked(acquireLockMock).mockImplementation(async () => ({
|
|
@@ -394,6 +409,41 @@ describe('FileViewer', () => {
|
|
|
394
409
|
}));
|
|
395
410
|
});
|
|
396
411
|
|
|
412
|
+
/**
|
|
413
|
+
* The seam, in the page that broke it.
|
|
414
|
+
*
|
|
415
|
+
* `HeaderAlignment.test.tsx` measures the band's HEIGHT and checks that a
|
|
416
|
+
* document column opens on it. This checks the thing only the real page can
|
|
417
|
+
* say: that the file page actually hands its title bar to that slot. It
|
|
418
|
+
* used to render `<EditorTabs />` above `<KbPageHeader>` inside the column,
|
|
419
|
+
* so the title bar opened 54px below the sidebar header row it is supposed
|
|
420
|
+
* to line up with — at every width, unaffected by collapsing or resizing the
|
|
421
|
+
* sidebar, and invisible to a suite in which no test rendered the header
|
|
422
|
+
* anywhere near a tab strip. Staging found it; this is what would have.
|
|
423
|
+
*
|
|
424
|
+
* Structural, not measured: happy-dom has no layout engine, so "nothing is
|
|
425
|
+
* drawn above the band" is the checkable form of "the band's top edge is
|
|
426
|
+
* the column's top edge".
|
|
427
|
+
*/
|
|
428
|
+
it('opens the document column with the title bar, above the tab strip', async () => {
|
|
429
|
+
render(<ViewerHarness initialContent="Base content" />);
|
|
430
|
+
|
|
431
|
+
const band = await screen.findByTestId(PAGE_HEADER_TESTID);
|
|
432
|
+
// The harness opens one tab, so the strip really is rendered — without it
|
|
433
|
+
// this test would pass on the broken code too.
|
|
434
|
+
const tabs = screen.getByRole('tablist', { name: 'Open files' });
|
|
435
|
+
|
|
436
|
+
// Nothing above the band inside its column — the checkable form of "its
|
|
437
|
+
// top edge is the column's top edge".
|
|
438
|
+
expect(band.previousElementSibling).toBeNull();
|
|
439
|
+
// And the strip did not leave the column to get there; it went below the
|
|
440
|
+
// title. One column still holds the title, the tabs and the text
|
|
441
|
+
// (proto:700-705) — this only changed the order inside it.
|
|
442
|
+
const column = band.parentElement!;
|
|
443
|
+
expect(column.contains(tabs)).toBe(true);
|
|
444
|
+
expect(band.compareDocumentPosition(tabs) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
|
|
445
|
+
});
|
|
446
|
+
|
|
397
447
|
it('immediately enters review mode when pending arrives on a clean file', async () => {
|
|
398
448
|
const user = userEvent.setup();
|
|
399
449
|
render(<ViewerHarness initialContent="base clean" pendingValue="agent clean" />);
|
|
@@ -680,17 +730,151 @@ describe('FileViewer', () => {
|
|
|
680
730
|
expect(screen.queryByRole('button', { name: 'Compare' })).not.toBeInTheDocument();
|
|
681
731
|
});
|
|
682
732
|
|
|
683
|
-
it('opens Version history from
|
|
733
|
+
it('opens Version history from the clock-arrow beside Edit and offers a way back to the document', async () => {
|
|
684
734
|
const user = userEvent.setup();
|
|
685
735
|
render(<ViewerHarness initialContent="historic" />);
|
|
686
736
|
|
|
687
|
-
|
|
688
|
-
|
|
737
|
+
// ONE clock: the prose pane bar carries it beside Edit, and the header
|
|
738
|
+
// stands down (`historyInPane`) rather than offering a second.
|
|
739
|
+
await user.click(screen.getByRole('button', { name: 'Version history' }));
|
|
689
740
|
|
|
690
741
|
const back = await screen.findByRole('button', { name: /Back to the document/ });
|
|
691
742
|
await user.click(back);
|
|
692
743
|
// The document is back, and so is its Edit affordance.
|
|
693
744
|
expect(await screen.findByRole('button', { name: 'Edit' })).toBeInTheDocument();
|
|
745
|
+
// The Back button unmounted with the log. Keyboard focus lands on the
|
|
746
|
+
// bar's clock, the same handoff the header's pressed clock makes, rather
|
|
747
|
+
// than falling to `document`.
|
|
748
|
+
expect(screen.getByRole('button', { name: 'Version history' })).toHaveFocus();
|
|
749
|
+
});
|
|
750
|
+
|
|
751
|
+
/**
|
|
752
|
+
* Opening the log unmounts the editor. Coming back re-mounts it from its
|
|
753
|
+
* seed, while the buffer Send reads still holds the newer keystrokes: the
|
|
754
|
+
* page would show one text and submit another. So the clock goes away for
|
|
755
|
+
* exactly as long as a draft is open, the rule the skill page applies.
|
|
756
|
+
*/
|
|
757
|
+
it('withdraws Version history while the editor is open, and returns it on Done', async () => {
|
|
758
|
+
const user = userEvent.setup();
|
|
759
|
+
render(<ViewerHarness initialContent="draft me" />);
|
|
760
|
+
|
|
761
|
+
expect(screen.getByRole('button', { name: 'Version history' })).toBeInTheDocument();
|
|
762
|
+
await user.click(screen.getByRole('button', { name: 'Edit' }));
|
|
763
|
+
await screen.findByRole('button', { name: 'Done' });
|
|
764
|
+
expect(screen.queryByRole('button', { name: 'Version history' })).not.toBeInTheDocument();
|
|
765
|
+
|
|
766
|
+
await user.click(screen.getByRole('button', { name: 'Done' }));
|
|
767
|
+
expect(await screen.findByRole('button', { name: 'Version history' })).toBeInTheDocument();
|
|
768
|
+
});
|
|
769
|
+
|
|
770
|
+
/**
|
|
771
|
+
* The chat's "View full comparison" link lands whenever the agent answers,
|
|
772
|
+
* and `availability` starts 'loading' until the first status poll returns.
|
|
773
|
+
* The comparison is not gated on the log's availability: the panel asks git
|
|
774
|
+
* itself and reports what it gets. Cancelling the tab here instead dropped
|
|
775
|
+
* the click with nothing on screen to say so.
|
|
776
|
+
*/
|
|
777
|
+
it('opens the comparison a chat link asks for before git has answered, and keeps it through a failed poll', async () => {
|
|
778
|
+
const { rerender } = render(<ViewerHarness initialContent="compared" gitAvailability="loading" />);
|
|
779
|
+
|
|
780
|
+
act(() => {
|
|
781
|
+
window.dispatchEvent(
|
|
782
|
+
new CustomEvent(OPEN_COMPARISON_EVENT, {
|
|
783
|
+
detail: { path: 'knowledge-base/Knowledge/Foo.md', fromBranch: 'main', toBranch: 'alice/draft' },
|
|
784
|
+
}),
|
|
785
|
+
);
|
|
786
|
+
});
|
|
787
|
+
expect(await screen.findByRole('button', { name: /Back to the document/ })).toBeInTheDocument();
|
|
788
|
+
expect(screen.getByText('Compare versions')).toBeInTheDocument();
|
|
789
|
+
|
|
790
|
+
// A poll fails while the comparison is up. It stays up: the reader asked
|
|
791
|
+
// for it, and only the log closes when git stops answering.
|
|
792
|
+
rerender(<ViewerHarness initialContent="compared" gitAvailability="error" />);
|
|
793
|
+
expect(screen.getByRole('button', { name: /Back to the document/ })).toBeInTheDocument();
|
|
794
|
+
expect(screen.getByText('Compare versions')).toBeInTheDocument();
|
|
795
|
+
});
|
|
796
|
+
|
|
797
|
+
/**
|
|
798
|
+
* The comparison outliving `historyAvailable` is the case where the focus
|
|
799
|
+
* handoff has no clock to hand back to: both are withdrawn while git is
|
|
800
|
+
* silent. Leaving the comparison then would drop focus on `document`, the
|
|
801
|
+
* one outcome the handoff exists to prevent, so the document's own title is
|
|
802
|
+
* named last. Found by cubic on #135.
|
|
803
|
+
*/
|
|
804
|
+
it('lands focus on the document title when leaving a comparison git cannot back with a clock', async () => {
|
|
805
|
+
const user = userEvent.setup();
|
|
806
|
+
render(<ViewerHarness initialContent="compared" gitAvailability="error" />);
|
|
807
|
+
|
|
808
|
+
act(() => {
|
|
809
|
+
window.dispatchEvent(
|
|
810
|
+
new CustomEvent(OPEN_COMPARISON_EVENT, {
|
|
811
|
+
detail: { path: 'knowledge-base/Knowledge/Foo.md', fromBranch: 'main', toBranch: 'alice/draft' },
|
|
812
|
+
}),
|
|
813
|
+
);
|
|
814
|
+
});
|
|
815
|
+
const back = await screen.findByRole('button', { name: /Back to the document/ });
|
|
816
|
+
// Neither clock is on screen to catch the focus.
|
|
817
|
+
expect(screen.queryByRole('button', { name: 'Version history' })).not.toBeInTheDocument();
|
|
818
|
+
|
|
819
|
+
await user.click(back);
|
|
820
|
+
expect(screen.queryByRole('button', { name: /Back to the document/ })).not.toBeInTheDocument();
|
|
821
|
+
const title = screen.getByRole('heading', { level: 1, name: 'Foo' });
|
|
822
|
+
expect(document.activeElement).toBe(title);
|
|
823
|
+
expect(document.activeElement).not.toBe(document.body);
|
|
824
|
+
});
|
|
825
|
+
|
|
826
|
+
// With the log open the column goes full-bleed and the header carries the
|
|
827
|
+
// clock, pressed. Clicking it again is the other way back.
|
|
828
|
+
/**
|
|
829
|
+
* `availability` is re-derived from a POLLED status call, so one failed
|
|
830
|
+
* poll flips it off and the next good one flips it back. If `activeTab`
|
|
831
|
+
* survived that on 'history', the column would stay full-bleed with no
|
|
832
|
+
* panel in it (a bare document, no pane card, no way back but the next
|
|
833
|
+
* poll), and then put the log back over the file the moment git recovered.
|
|
834
|
+
* Found by cubic on #134; the skill page already had the rule.
|
|
835
|
+
*/
|
|
836
|
+
it('puts the document back when git stops answering mid-read, and does not reopen the log when it recovers', async () => {
|
|
837
|
+
const user = userEvent.setup();
|
|
838
|
+
const { rerender } = render(<ViewerHarness initialContent="historic" />);
|
|
839
|
+
|
|
840
|
+
await user.click(screen.getByRole('button', { name: 'Version history' }));
|
|
841
|
+
await screen.findByRole('button', { name: /Back to the document/ });
|
|
842
|
+
|
|
843
|
+
// A poll fails: the log goes, and the document is back in its pane card
|
|
844
|
+
// with its Edit, not stranded full-bleed.
|
|
845
|
+
rerender(<ViewerHarness initialContent="historic" gitAvailability="error" />);
|
|
846
|
+
expect(screen.queryByRole('button', { name: /Back to the document/ })).not.toBeInTheDocument();
|
|
847
|
+
expect(await screen.findByRole('button', { name: 'Edit' })).toBeInTheDocument();
|
|
848
|
+
expect(screen.getByTestId('file-pane-card')).toBeInTheDocument();
|
|
849
|
+
expect(screen.queryByRole('button', { name: 'Version history' })).not.toBeInTheDocument();
|
|
850
|
+
|
|
851
|
+
// The next poll succeeds. The file is still what is on screen, and the
|
|
852
|
+
// clock is back, unpressed.
|
|
853
|
+
rerender(<ViewerHarness initialContent="historic" gitAvailability="ready" />);
|
|
854
|
+
expect(screen.queryByRole('button', { name: /Back to the document/ })).not.toBeInTheDocument();
|
|
855
|
+
expect(screen.getByRole('button', { name: 'Edit' })).toBeInTheDocument();
|
|
856
|
+
expect(screen.getByRole('button', { name: 'Version history' })).toBeInTheDocument();
|
|
857
|
+
});
|
|
858
|
+
|
|
859
|
+
it('closes Version history from the pressed clock in the header', async () => {
|
|
860
|
+
const user = userEvent.setup();
|
|
861
|
+
render(<ViewerHarness initialContent="historic" />);
|
|
862
|
+
|
|
863
|
+
await user.click(screen.getByRole('button', { name: 'Version history' }));
|
|
864
|
+
await screen.findByRole('button', { name: /Back to the document/ });
|
|
865
|
+
// The pane bar's clock unmounted with the bar; focus lands on the
|
|
866
|
+
// header's pressed clock rather than falling to `document`.
|
|
867
|
+
const pressed = screen.getByRole('button', { name: 'Version history' });
|
|
868
|
+
expect(pressed).toHaveAttribute('aria-pressed', 'true');
|
|
869
|
+
expect(document.activeElement).toBe(pressed);
|
|
870
|
+
|
|
871
|
+
await user.click(pressed);
|
|
872
|
+
expect(screen.queryByRole('button', { name: /Back to the document/ })).not.toBeInTheDocument();
|
|
873
|
+
expect(await screen.findByRole('button', { name: 'Edit' })).toBeInTheDocument();
|
|
874
|
+
// And back: the header's clock hid again, so focus lands on the bar's.
|
|
875
|
+
const paneClock = screen.getByRole('button', { name: 'Version history' });
|
|
876
|
+
expect(paneClock).not.toHaveAttribute('aria-pressed', 'true');
|
|
877
|
+
expect(document.activeElement).toBe(paneClock);
|
|
694
878
|
});
|
|
695
879
|
|
|
696
880
|
it('shares the file itself from Share, and the parent folder from the chevron', async () => {
|
|
@@ -747,6 +931,63 @@ describe('FileViewer', () => {
|
|
|
747
931
|
).toBeInTheDocument();
|
|
748
932
|
});
|
|
749
933
|
|
|
934
|
+
/**
|
|
935
|
+
* "Waiting on you and N others" counts the people who can APPROVE — the
|
|
936
|
+
* write: grants — not the owner: list. A file written by Bob and Carl (plus
|
|
937
|
+
* the inherited Admin role) with no owners must not tell Bob he is the only
|
|
938
|
+
* one it waits on.
|
|
939
|
+
*/
|
|
940
|
+
it('counts the other approvers from the write grants, not the owners', async () => {
|
|
941
|
+
accessMock.result = {
|
|
942
|
+
canWrite: true,
|
|
943
|
+
canOwner: false,
|
|
944
|
+
eligible: {
|
|
945
|
+
roles: ['Admin'],
|
|
946
|
+
users: [
|
|
947
|
+
{ name: 'Bob', email: 'bob@example.com' },
|
|
948
|
+
{ name: 'Carl', email: 'carl@example.com' },
|
|
949
|
+
],
|
|
950
|
+
},
|
|
951
|
+
owners: EMPTY_ELIGIBLE,
|
|
952
|
+
};
|
|
953
|
+
// The proposal must actually differ from the file, or the box reads
|
|
954
|
+
// "Already up to date" and has no verdict to wait on.
|
|
955
|
+
readBranchMock.mockImplementation((async (branch: string) =>
|
|
956
|
+
branch.startsWith('suggestions/') ? 'proposed' : 'current') as never);
|
|
957
|
+
render(
|
|
958
|
+
<ViewerHarness
|
|
959
|
+
initialContent="contested"
|
|
960
|
+
branch="target-company-state"
|
|
961
|
+
authUser={{ id: 'u-bob', email: 'bob@example.com', name: 'Bob' }}
|
|
962
|
+
changeRequests={[{ number: 33, title: 'Tighten the wording', who: 'Ali Raza' }]}
|
|
963
|
+
/>,
|
|
964
|
+
);
|
|
965
|
+
|
|
966
|
+
expect(await screen.findByText('Waiting on you and 2 others')).toBeInTheDocument();
|
|
967
|
+
expect(screen.getByRole('button', { name: 'Approve' })).toBeInTheDocument();
|
|
968
|
+
});
|
|
969
|
+
|
|
970
|
+
/**
|
|
971
|
+
* A failed access lookup default-allows with an EMPTY grant list. That list
|
|
972
|
+
* is not the approver set, so the box must not claim "Waiting on you".
|
|
973
|
+
*/
|
|
974
|
+
it('makes no waiting-on claim when the approver grants never loaded', async () => {
|
|
975
|
+
accessMock.fetchFileAccess.mockRejectedValueOnce(new Error('network down'));
|
|
976
|
+
readBranchMock.mockImplementation((async (branch: string) =>
|
|
977
|
+
branch.startsWith('suggestions/') ? 'proposed' : 'current') as never);
|
|
978
|
+
render(
|
|
979
|
+
<ViewerHarness
|
|
980
|
+
initialContent="contested"
|
|
981
|
+
branch="target-company-state"
|
|
982
|
+
authUser={{ id: 'u-bob', email: 'bob@example.com', name: 'Bob' }}
|
|
983
|
+
changeRequests={[{ number: 33, title: 'Tighten the wording', who: 'Ali Raza' }]}
|
|
984
|
+
/>,
|
|
985
|
+
);
|
|
986
|
+
|
|
987
|
+
expect(await screen.findByText('You can decide this.')).toBeInTheDocument();
|
|
988
|
+
expect(screen.queryByText(/Waiting on you/)).not.toBeInTheDocument();
|
|
989
|
+
});
|
|
990
|
+
|
|
750
991
|
it('says nothing on a file nobody has proposed a change to', () => {
|
|
751
992
|
render(<ViewerHarness initialContent="quiet" />);
|
|
752
993
|
expect(screen.queryByText(/proposed a change/)).not.toBeInTheDocument();
|
|
@@ -937,6 +1178,37 @@ describe('FileViewer: proposing a change without write access', () => {
|
|
|
937
1178
|
expect(proposeMock).not.toHaveBeenCalled();
|
|
938
1179
|
});
|
|
939
1180
|
|
|
1181
|
+
/**
|
|
1182
|
+
* The seeded case is where the clock did real damage: the editor re-mounts
|
|
1183
|
+
* from `proposeSeed` on the way back from the log, while `proposeBufferRef`
|
|
1184
|
+
* still holds the newer keystrokes — the old text on screen, the new text
|
|
1185
|
+
* sent. No clock while a proposal is open.
|
|
1186
|
+
*/
|
|
1187
|
+
it('withdraws Version history while a proposal is open, and returns it on Discard', async () => {
|
|
1188
|
+
denyWrite();
|
|
1189
|
+
myCrsMock.mockResolvedValue([
|
|
1190
|
+
{ number: 12, state: 'open', branch: 'suggestions/reader-u9/knowledge' },
|
|
1191
|
+
]);
|
|
1192
|
+
readBranchMock.mockResolvedValue('first proposed paragraph');
|
|
1193
|
+
const user = userEvent.setup();
|
|
1194
|
+
render(
|
|
1195
|
+
<ViewerHarness
|
|
1196
|
+
initialContent="official"
|
|
1197
|
+
branch="target-company-state"
|
|
1198
|
+
authUser={reader}
|
|
1199
|
+
captureTyped
|
|
1200
|
+
/>,
|
|
1201
|
+
);
|
|
1202
|
+
|
|
1203
|
+
expect(await screen.findByRole('button', { name: 'Version history' })).toBeInTheDocument();
|
|
1204
|
+
await user.click(screen.getByRole('button', { name: 'Propose changes' }));
|
|
1205
|
+
await screen.findByRole('textbox');
|
|
1206
|
+
expect(screen.queryByRole('button', { name: 'Version history' })).not.toBeInTheDocument();
|
|
1207
|
+
|
|
1208
|
+
await user.click(screen.getByRole('button', { name: 'Discard' }));
|
|
1209
|
+
expect(await screen.findByRole('button', { name: 'Version history' })).toBeInTheDocument();
|
|
1210
|
+
});
|
|
1211
|
+
|
|
940
1212
|
it('discard walks away without sending anything', async () => {
|
|
941
1213
|
denyWrite();
|
|
942
1214
|
const user = userEvent.setup();
|
|
@@ -971,7 +1243,15 @@ describe('FileViewer: proposing a change without write access', () => {
|
|
|
971
1243
|
* away from the pages it holds. It offers those pages now.
|
|
972
1244
|
*/
|
|
973
1245
|
describe('FileViewer: nothing open', () => {
|
|
974
|
-
|
|
1246
|
+
/** The workspace root the API returns, wrapping whatever the checkout holds. */
|
|
1247
|
+
const workspace = (checkout: FileTreeEntry): FileTreeEntry => ({
|
|
1248
|
+
name: '.',
|
|
1249
|
+
relativePath: '.',
|
|
1250
|
+
type: 'directory',
|
|
1251
|
+
children: [checkout],
|
|
1252
|
+
});
|
|
1253
|
+
|
|
1254
|
+
const CHECKOUT: FileTreeEntry = {
|
|
975
1255
|
name: 'knowledge-base',
|
|
976
1256
|
relativePath: 'knowledge-base',
|
|
977
1257
|
type: 'directory',
|
|
@@ -1021,6 +1301,22 @@ describe('FileViewer: nothing open', () => {
|
|
|
1021
1301
|
],
|
|
1022
1302
|
};
|
|
1023
1303
|
|
|
1304
|
+
const TREE = workspace(CHECKOUT);
|
|
1305
|
+
|
|
1306
|
+
/**
|
|
1307
|
+
* The strays that sat beside the checkout on core-staging. Nothing here is
|
|
1308
|
+
* the repository, so nothing here is ever offered as a page.
|
|
1309
|
+
*/
|
|
1310
|
+
const STRAYS: FileTreeEntry[] = [
|
|
1311
|
+
{
|
|
1312
|
+
name: 'KnowledgeBase',
|
|
1313
|
+
relativePath: 'KnowledgeBase',
|
|
1314
|
+
type: 'directory',
|
|
1315
|
+
children: [{ name: 'Planted.md', relativePath: 'KnowledgeBase/Planted.md', type: 'file' }],
|
|
1316
|
+
},
|
|
1317
|
+
{ name: 'Stray.md', relativePath: 'Stray.md', type: 'file' },
|
|
1318
|
+
];
|
|
1319
|
+
|
|
1024
1320
|
it('does not send the reader off to an assistant', async () => {
|
|
1025
1321
|
render(<ViewerHarness filePath={null} fileTree={TREE} />);
|
|
1026
1322
|
await screen.findByRole('heading', { name: /Open a page/ });
|
|
@@ -1105,6 +1401,30 @@ describe('FileViewer: nothing open', () => {
|
|
|
1105
1401
|
expect(await screen.findByRole('button', { name: /Handbook/ })).toBeEnabled();
|
|
1106
1402
|
});
|
|
1107
1403
|
|
|
1404
|
+
/**
|
|
1405
|
+
* The strays on core-staging put a `KnowledgeBase/` beside the checkout.
|
|
1406
|
+
* The offer is the checkout's, so they change nothing — and when the
|
|
1407
|
+
* checkout itself is gone there is nothing to offer, rather than whatever
|
|
1408
|
+
* was written next to it.
|
|
1409
|
+
*/
|
|
1410
|
+
it('offers the same pages with strays beside the checkout, and none without one', async () => {
|
|
1411
|
+
const { unmount } = render(
|
|
1412
|
+
<ViewerHarness
|
|
1413
|
+
filePath={null}
|
|
1414
|
+
fileTree={{ ...TREE, children: [...STRAYS, CHECKOUT] }}
|
|
1415
|
+
/>,
|
|
1416
|
+
);
|
|
1417
|
+
expect(await screen.findByRole('button', { name: /Handbook/ })).toBeInTheDocument();
|
|
1418
|
+
expect(screen.queryByRole('button', { name: /Planted/ })).toBeNull();
|
|
1419
|
+
expect(screen.queryByRole('button', { name: /Stray/ })).toBeNull();
|
|
1420
|
+
unmount();
|
|
1421
|
+
|
|
1422
|
+
render(<ViewerHarness filePath={null} fileTree={{ ...TREE, children: STRAYS }} />);
|
|
1423
|
+
await screen.findByRole('heading', { name: /Open a page/ });
|
|
1424
|
+
expect(screen.queryByRole('button', { name: /Planted/ })).toBeNull();
|
|
1425
|
+
expect(screen.getByText('Pick anything from the file tree.')).toBeInTheDocument();
|
|
1426
|
+
});
|
|
1427
|
+
|
|
1108
1428
|
/** A knowledge base with nothing in it has nothing to suggest, and says so. */
|
|
1109
1429
|
it('promises nothing when there is nothing to open', async () => {
|
|
1110
1430
|
render(<ViewerHarness filePath={null} fileTree={null} />);
|
|
@@ -1121,14 +1441,14 @@ describe('FileViewer: nothing open', () => {
|
|
|
1121
1441
|
render(
|
|
1122
1442
|
<ViewerHarness
|
|
1123
1443
|
filePath={null}
|
|
1124
|
-
fileTree={{
|
|
1444
|
+
fileTree={workspace({
|
|
1125
1445
|
name: 'knowledge-base',
|
|
1126
1446
|
relativePath: 'knowledge-base',
|
|
1127
1447
|
type: 'directory',
|
|
1128
1448
|
children: [
|
|
1129
1449
|
{ name: 'Charter.md', relativePath: 'knowledge-base/Charter.md', type: 'file' },
|
|
1130
1450
|
],
|
|
1131
|
-
}}
|
|
1451
|
+
})}
|
|
1132
1452
|
/>,
|
|
1133
1453
|
);
|
|
1134
1454
|
expect(await screen.findByRole('button', { name: /Charter/ })).toBeInTheDocument();
|
|
@@ -10,6 +10,45 @@ import { KbDocumentShell } from '../KbDocumentShell';
|
|
|
10
10
|
* lands on — rather than computed pixels.
|
|
11
11
|
*/
|
|
12
12
|
describe('KbDocumentShell', () => {
|
|
13
|
+
/**
|
|
14
|
+
* The `header` slot's whole contract, in one assertion per variant: the
|
|
15
|
+
* band opens the column, whatever else the page puts in it.
|
|
16
|
+
*
|
|
17
|
+
* It is a slot rather than the caller's first child because a caller
|
|
18
|
+
* forgot — `FileViewer` rendered the tab strip above its title bar and put
|
|
19
|
+
* the file page's band 54px below the sidebar header row it lines up with.
|
|
20
|
+
* What that costs, and the offset each variant opens on, is asserted at the
|
|
21
|
+
* seam in `layout/__tests__/HeaderAlignment.test.tsx`; that the file page
|
|
22
|
+
* really uses the slot is asserted in `FileViewer.test.tsx`.
|
|
23
|
+
*/
|
|
24
|
+
it.each([
|
|
25
|
+
['prose', {}],
|
|
26
|
+
['full-bleed', { variant: 'full-bleed' as const }],
|
|
27
|
+
['with a rail', { rail: <p>About this file</p> }],
|
|
28
|
+
])('puts the header first in the column (%s)', (_name, props) => {
|
|
29
|
+
render(
|
|
30
|
+
<KbDocumentShell {...props} header={<h1>The title bar</h1>}>
|
|
31
|
+
<div>Everything else the page renders</div>
|
|
32
|
+
</KbDocumentShell>,
|
|
33
|
+
);
|
|
34
|
+
const band = screen.getByText('The title bar');
|
|
35
|
+
const content = screen.getByText('Everything else the page renders');
|
|
36
|
+
|
|
37
|
+
// IN the column, not above it. "First" on its own is satisfied by a band
|
|
38
|
+
// hoisted into a wrapper of its own — which is the regression that
|
|
39
|
+
// reaches the seam, because a wrapper outside the column does not carry
|
|
40
|
+
// the column's `HEADER_COLUMN_TOP` and can put anything underneath it.
|
|
41
|
+
// Tying the band to the content is what makes the next two lines mean
|
|
42
|
+
// "opens the column" rather than "opens something".
|
|
43
|
+
expect(band.parentElement).toBe(content.parentElement);
|
|
44
|
+
expect(band.previousElementSibling).toBeNull();
|
|
45
|
+
expect(band.nextElementSibling).toBe(content);
|
|
46
|
+
|
|
47
|
+
// And the column is inside the shell's own scrolling box in every
|
|
48
|
+
// variant, so nothing can render between the two.
|
|
49
|
+
expect(screen.getByTestId('kb-document-shell')).toContainElement(band);
|
|
50
|
+
});
|
|
51
|
+
|
|
13
52
|
it('renders children inside a centred, measured column', () => {
|
|
14
53
|
render(
|
|
15
54
|
<KbDocumentShell>
|
|
@@ -126,28 +126,29 @@ describe('KbPageHeader', () => {
|
|
|
126
126
|
expect(screen.getByText('Agent update waiting')).toBeInTheDocument();
|
|
127
127
|
});
|
|
128
128
|
|
|
129
|
-
|
|
129
|
+
// Version history is a button of its own — the clock-arrow beside Edit,
|
|
130
|
+
// where Google Docs keeps it. It used to be the lone item behind a ⋯, and
|
|
131
|
+
// a menu with one entry is a hiding place, not an overflow.
|
|
132
|
+
it('opens Version history from the clock-arrow, with no overflow menu in the way', async () => {
|
|
130
133
|
const user = userEvent.setup();
|
|
131
|
-
renderHeader();
|
|
132
|
-
await user.click(screen.getByRole('button', { name: '
|
|
133
|
-
expect(
|
|
134
|
+
const { props } = renderHeader();
|
|
135
|
+
await user.click(screen.getByRole('button', { name: 'Version history' }));
|
|
136
|
+
expect(props.onOpenHistory).toHaveBeenCalled();
|
|
137
|
+
expect(screen.queryByRole('button', { name: 'More actions' })).not.toBeInTheDocument();
|
|
134
138
|
});
|
|
135
139
|
|
|
136
|
-
//
|
|
137
|
-
//
|
|
138
|
-
it('
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
await user.click(screen.getByRole('button', { name: 'More actions' }));
|
|
142
|
-
expect(screen.queryByRole('menuitem', { name: /Copy path/i })).not.toBeInTheDocument();
|
|
140
|
+
// Git not being ready means there is no log to show, so the button goes
|
|
141
|
+
// rather than opening onto nothing.
|
|
142
|
+
it('drops the Version history button entirely when git is not ready', () => {
|
|
143
|
+
renderHeader({ historyAvailable: false });
|
|
144
|
+
expect(screen.queryByRole('button', { name: 'Version history' })).not.toBeInTheDocument();
|
|
143
145
|
});
|
|
144
146
|
|
|
145
|
-
//
|
|
146
|
-
//
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
expect(screen.queryByRole('button', { name: 'More actions' })).not.toBeInTheDocument();
|
|
147
|
+
// A prose document's pane bar owns Edit and carries Version history beside
|
|
148
|
+
// it; a second clock in the header would be two controls for one action.
|
|
149
|
+
it('leaves Version history to the pane bar when the pane carries it', () => {
|
|
150
|
+
renderHeader({ historyInPane: true });
|
|
151
|
+
expect(screen.queryByRole('button', { name: 'Version history' })).not.toBeInTheDocument();
|
|
151
152
|
});
|
|
152
153
|
|
|
153
154
|
// A copy that fails must say so — `navigator.clipboard` rejects outright on
|
|
@@ -178,6 +179,18 @@ describe('KbPageHeader', () => {
|
|
|
178
179
|
expect(await screen.findByRole('menuitem', { name: /Copied/ })).toBeInTheDocument();
|
|
179
180
|
});
|
|
180
181
|
|
|
182
|
+
it('copies the root-anchored path from the page menu', async () => {
|
|
183
|
+
const user = userEvent.setup();
|
|
184
|
+
// After `setup()`, which installs a clipboard stub of its own.
|
|
185
|
+
const writeText = vi.fn(async () => {});
|
|
186
|
+
Object.defineProperty(navigator, 'clipboard', { value: { writeText }, configurable: true });
|
|
187
|
+
renderHeader();
|
|
188
|
+
await user.click(screen.getByRole('button', { name: 'More sharing options' }));
|
|
189
|
+
await user.click(screen.getByRole('menuitem', { name: /Copy path/ }));
|
|
190
|
+
expect(writeText).toHaveBeenCalledWith('/knowledge-base/Knowledge/Invariant.md');
|
|
191
|
+
expect(await screen.findByRole('menuitem', { name: /Copied/ })).toBeInTheDocument();
|
|
192
|
+
});
|
|
193
|
+
|
|
181
194
|
it('says so on the row when copying the link fails', async () => {
|
|
182
195
|
const user = userEvent.setup();
|
|
183
196
|
renderHeader({ onCopyLink: vi.fn(async () => false) });
|
|
@@ -194,14 +207,14 @@ describe('KbPageHeader', () => {
|
|
|
194
207
|
it('closes an open menu on Escape and returns focus to its trigger', async () => {
|
|
195
208
|
const user = userEvent.setup();
|
|
196
209
|
renderHeader();
|
|
197
|
-
const trigger = screen.getByRole('button', { name: 'More
|
|
210
|
+
const trigger = screen.getByRole('button', { name: 'More sharing options' });
|
|
198
211
|
await user.click(trigger);
|
|
199
|
-
expect(screen.getByRole('menu', { name: '
|
|
212
|
+
expect(screen.getByRole('menu', { name: 'Sharing options' })).toBeInTheDocument();
|
|
200
213
|
|
|
201
214
|
await act(async () => {
|
|
202
215
|
fireEvent.keyDown(document, { key: 'Escape' });
|
|
203
216
|
});
|
|
204
|
-
expect(screen.queryByRole('menu', { name: '
|
|
217
|
+
expect(screen.queryByRole('menu', { name: 'Sharing options' })).not.toBeInTheDocument();
|
|
205
218
|
expect(document.activeElement).toBe(trigger);
|
|
206
219
|
});
|
|
207
220
|
});
|
|
@@ -6,8 +6,9 @@ import { useEffect, useState } from 'react';
|
|
|
6
6
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
7
7
|
// @ts-expect-error — mammoth ships no .d.ts
|
|
8
8
|
import mammoth from 'mammoth/mammoth.browser.js';
|
|
9
|
-
import {
|
|
9
|
+
import { useRendererWorkspaceId } from './rendererWorkspace';
|
|
10
10
|
import { authFetch } from '../../../../lib/api';
|
|
11
|
+
import { rawFileUrl } from '../../services/workspace.api';
|
|
11
12
|
import { sanitizeDocxHtml } from './sanitizeDocxHtml';
|
|
12
13
|
import { DownloadFileButton } from './DownloadFileButton';
|
|
13
14
|
import type { FileRendererProps } from './types';
|
|
@@ -30,7 +31,7 @@ import type { FileRendererProps } from './types';
|
|
|
30
31
|
* ignores `onSave` / `onValueChange` / `readOnly`.
|
|
31
32
|
*/
|
|
32
33
|
export function DocxRenderer({ filePath }: FileRendererProps) {
|
|
33
|
-
const
|
|
34
|
+
const workspaceId = useRendererWorkspaceId();
|
|
34
35
|
const [html, setHtml] = useState<string | null>(null);
|
|
35
36
|
const [error, setError] = useState<string | null>(null);
|
|
36
37
|
|
|
@@ -42,9 +43,7 @@ export function DocxRenderer({ filePath }: FileRendererProps) {
|
|
|
42
43
|
let cancelled = false;
|
|
43
44
|
(async () => {
|
|
44
45
|
try {
|
|
45
|
-
const res = await authFetch(
|
|
46
|
-
`/api/workspace/${workspaceId}/file/raw?path=${encodeURIComponent(filePath)}`,
|
|
47
|
-
);
|
|
46
|
+
const res = await authFetch(rawFileUrl(workspaceId, filePath));
|
|
48
47
|
if (cancelled) return;
|
|
49
48
|
if (!res.ok) {
|
|
50
49
|
setError(`Failed to load Word document (HTTP ${res.status})`);
|