@bevel-software/platform-core-frontend 0.32.0 → 0.34.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.
Files changed (207) hide show
  1. package/package.json +2 -2
  2. package/src/core/CoreAppShell.tsx +1 -1
  3. package/src/lib/__tests__/api.test.ts +28 -1
  4. package/src/lib/api.ts +4 -2
  5. package/src/modules/access/__tests__/ManageAccessDialog.add-row-picking.test.tsx +53 -1
  6. package/src/modules/access/api.ts +4 -5
  7. package/src/modules/access/components/ManageAccessDialog.tsx +11 -12
  8. package/src/modules/access/hooks/useAccessRequests.ts +1 -1
  9. package/src/modules/access/hooks/useFileAccess.ts +1 -1
  10. package/src/modules/access/index.ts +11 -0
  11. package/src/modules/access/requests.api.ts +1 -1
  12. package/src/modules/admin/__tests__/DirectoryGroupsPage.test.tsx +51 -0
  13. package/src/modules/admin/components/AddMemberInput.tsx +1 -1
  14. package/src/modules/admin/components/DirectoryGroupsPage.tsx +42 -5
  15. package/src/modules/admin/components/UserAccountsPage.tsx +3 -3
  16. package/src/modules/admin/index.ts +7 -0
  17. package/src/modules/admin/services/groups.api.ts +11 -1
  18. package/src/modules/admin/state/admin.context.tsx +1 -1
  19. package/src/modules/agents/__tests__/useConnectAsChoice.test.ts +56 -0
  20. package/src/modules/agents/components/ConnectAsChoice.tsx +81 -0
  21. package/src/modules/agents/connect-as.ts +15 -0
  22. package/src/modules/agents/index.ts +5 -0
  23. package/src/modules/agents/services/agent-choices.api.ts +39 -0
  24. package/src/modules/agents/useConnectAsChoice.ts +66 -0
  25. package/src/modules/audit/__tests__/AuditLogPage.test.tsx +13 -0
  26. package/src/modules/audit/components/AuditEventsPanel.tsx +1 -1
  27. package/src/modules/audit/components/AuditLogPage.tsx +11 -2
  28. package/src/modules/audit/services/audit.api.ts +5 -0
  29. package/src/modules/auth/__tests__/AccountPage.test.tsx +21 -0
  30. package/src/modules/auth/__tests__/account.api.test.ts +69 -0
  31. package/src/modules/auth/components/AccountPage.tsx +8 -2
  32. package/src/modules/auth/index.ts +12 -0
  33. package/src/modules/auth/services/account.api.ts +18 -2
  34. package/src/modules/change-requests/__tests__/ChangeRequestDialog.access-rules.test.tsx +0 -1
  35. package/src/modules/change-requests/__tests__/ChangeRequestDialog.binary.test.tsx +0 -1
  36. package/src/modules/change-requests/__tests__/ChangeRequestDialog.brings-itself-up-to-date.test.tsx +0 -1
  37. package/src/modules/change-requests/__tests__/ChangeRequestDialog.edit.test.tsx +166 -0
  38. package/src/modules/change-requests/__tests__/ChangeRequestDialog.fork-point.test.tsx +0 -1
  39. package/src/modules/change-requests/__tests__/ChangeRequestDialog.initial-file.test.tsx +0 -1
  40. package/src/modules/change-requests/__tests__/ChangeRequestDialog.moved.test.tsx +0 -1
  41. package/src/modules/change-requests/__tests__/ChangeRequestDialog.sync-banner.test.tsx +0 -1
  42. package/src/modules/change-requests/__tests__/ChangeRequestDialog.test.tsx +0 -2
  43. package/src/modules/change-requests/__tests__/ChangeRequestDialog.unreadable.test.tsx +0 -1
  44. package/src/modules/change-requests/__tests__/apply-outcome-for-every-viewer.test.tsx +0 -1
  45. package/src/modules/change-requests/components/BranchFilePreview.tsx +4 -12
  46. package/src/modules/change-requests/components/ChangeRequestDialog.tsx +138 -30
  47. package/src/modules/change-requests/components/ChangeRequestLink.tsx +2 -3
  48. package/src/modules/change-requests/components/CrFileTree.tsx +1 -1
  49. package/src/modules/change-requests/components/FileChangeBoxes.tsx +2 -3
  50. package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +3 -5
  51. package/src/modules/change-requests/hooks/useCrFileDiffs.ts +1 -1
  52. package/src/modules/change-requests/index.ts +14 -0
  53. package/src/modules/change-requests/services/change-requests.api.ts +2 -2
  54. package/src/modules/change-requests/services/denied-file.api.ts +2 -2
  55. package/src/modules/change-requests/services/propose.api.ts +3 -4
  56. package/src/modules/change-requests/utils/diff.ts +1 -1
  57. package/src/modules/change-requests/utils/readFailure.ts +1 -1
  58. package/src/modules/embed/__tests__/EmbedView.test.tsx +19 -2
  59. package/src/modules/embed/components/EmbedLinkPage.tsx +1 -2
  60. package/src/modules/git/__tests__/BranchSwitcher.test.tsx +0 -14
  61. package/src/modules/git/__tests__/git.api.test.ts +2 -2
  62. package/src/modules/git/components/BranchSwitcher.tsx +3 -4
  63. package/src/modules/git/components/FileHistoryPanel.tsx +2 -2
  64. package/src/modules/git/components/GitSyncFailedBanner.tsx +2 -4
  65. package/src/modules/git/components/HistoryVersionPreview.tsx +4 -15
  66. package/src/modules/git/components/PullNeededBanner.tsx +1 -1
  67. package/src/modules/git/hooks/__tests__/useGitState.deleteBranch.test.tsx +1 -1
  68. package/src/modules/git/hooks/useAutoPullUpdates.ts +1 -1
  69. package/src/modules/git/index.ts +11 -0
  70. package/src/modules/layout/components/MobileChatLayout.tsx +1 -1
  71. package/src/modules/layout/index.ts +9 -0
  72. package/src/modules/library/__tests__/SkillPage.test.tsx +268 -24
  73. package/src/modules/library/__tests__/propose-change.test.ts +75 -0
  74. package/src/modules/library/components/AddToPluginDialog.tsx +1 -1
  75. package/src/modules/library/components/ChangeRequestDock.tsx +1 -1
  76. package/src/modules/library/components/LibraryLayout.tsx +2 -2
  77. package/src/modules/library/components/LibraryPage.tsx +3 -3
  78. package/src/modules/library/components/ManagedPluginRequests.tsx +1 -1
  79. package/src/modules/library/components/NewSkillPanel.tsx +2 -2
  80. package/src/modules/library/components/PersonalAddDialog.tsx +1 -1
  81. package/src/modules/library/components/PersonalPluginPage.tsx +1 -1
  82. package/src/modules/library/components/PluginExtras.tsx +1 -4
  83. package/src/modules/library/components/PluginPage.tsx +1 -1
  84. package/src/modules/library/components/PluginRows.tsx +1 -1
  85. package/src/modules/library/components/SkillsTree.tsx +1 -4
  86. package/src/modules/library/components/plugin-page-parts.tsx +1 -1
  87. package/src/modules/library/components/skill-page/SkillFilePane.tsx +74 -14
  88. package/src/modules/library/components/skill-page/SkillPage.tsx +80 -47
  89. package/src/modules/library/components/tool-page/ToolConnectionSection.tsx +2 -4
  90. package/src/modules/library/components/tool-page/ToolVarRow.tsx +2 -2
  91. package/src/modules/library/hooks/useJoinRequests.ts +1 -1
  92. package/src/modules/library/hooks/useLibraryData.ts +3 -3
  93. package/src/modules/library/hooks/useToolPage.ts +1 -1
  94. package/src/modules/library/hooks/useToolSource.ts +1 -1
  95. package/src/modules/library/index.ts +12 -0
  96. package/src/modules/library/routes/LibraryRoutes.tsx +1 -1
  97. package/src/modules/library/routes/WorkspaceItemRoute.tsx +1 -3
  98. package/src/modules/library/routes/library-paths.ts +1 -1
  99. package/src/modules/library/services/library.api.ts +10 -8
  100. package/src/modules/library/services/plugins.api.ts +1 -1
  101. package/src/modules/library/services/teams.api.ts +1 -1
  102. package/src/modules/library/utils/status.ts +2 -2
  103. package/src/modules/onboarding/components/ConnectAgentPill.tsx +1 -1
  104. package/src/modules/onboarding/components/CreatorWelcomePage.tsx +2 -3
  105. package/src/modules/onboarding/components/GetStartedColumn.tsx +6 -13
  106. package/src/modules/onboarding/components/InviteButton.tsx +2 -2
  107. package/src/modules/onboarding/components/InviteDialog.tsx +4 -6
  108. package/src/modules/onboarding/components/RootLanding.tsx +2 -2
  109. package/src/modules/onboarding/components/StarterPackCard.tsx +1 -1
  110. package/src/modules/onboarding/components/WelcomePage.tsx +2 -5
  111. package/src/modules/onboarding/index.ts +10 -0
  112. package/src/modules/onboarding/paths.ts +1 -1
  113. package/src/modules/onboarding/state/agent-connection.ts +2 -2
  114. package/src/modules/onboarding/state/onboarding.ts +1 -1
  115. package/src/modules/onboarding/state/starter-packs.ts +1 -1
  116. package/src/modules/pr/components/OpenChangeRequestDialog.tsx +1 -1
  117. package/src/modules/pr/index.ts +14 -0
  118. package/src/modules/pr/services/pr-approvals.api.ts +1 -1
  119. package/src/modules/pr/services/pr-cancel.api.ts +1 -1
  120. package/src/modules/pr/services/pr-detail.api.ts +2 -2
  121. package/src/modules/pr/services/pr-edit.api.ts +22 -0
  122. package/src/modules/pr/services/pr-merge.api.ts +1 -1
  123. package/src/modules/pr/services/pr-open.api.ts +1 -1
  124. package/src/modules/review/components/DiffViewer.tsx +1 -1
  125. package/src/modules/review/components/MarkdownDiffViewer.tsx +24 -3
  126. package/src/modules/review/components/ReviewPanel.tsx +10 -5
  127. package/src/modules/review/components/__tests__/MarkdownDiffViewer.test.tsx +31 -0
  128. package/src/modules/review/state/ReviewProvider.tsx +2 -2
  129. package/src/modules/secrets-vault/components/ConnectToolsPage.tsx +79 -16
  130. package/src/modules/secrets-vault/components/__tests__/ConnectToolsPage.test.tsx +112 -2
  131. package/src/modules/secrets-vault/index.ts +6 -0
  132. package/src/modules/secrets-vault/services/connect.api.ts +20 -5
  133. package/src/modules/settings/components/DeploymentPage.tsx +2 -2
  134. package/src/modules/settings/components/SettingsLayout.tsx +2 -2
  135. package/src/modules/settings/index.ts +8 -0
  136. package/src/modules/setup/components/FirstRunStorage.tsx +1 -1
  137. package/src/modules/setup/index.ts +6 -0
  138. package/src/modules/toolbar/commands/actions.tsx +3 -3
  139. package/src/modules/toolbar/commands/useCommandActions.ts +5 -9
  140. package/src/modules/toolbar/components/AgentInstructionsCard.tsx +2 -2
  141. package/src/modules/toolbar/components/AppSwitcher.tsx +1 -2
  142. package/src/modules/toolbar/components/CoworkSetupSteps.tsx +1 -1
  143. package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +39 -5
  144. package/src/modules/toolbar/components/ProfileMenu.tsx +3 -3
  145. package/src/modules/toolbar/components/SearchPalette.tsx +4 -8
  146. package/src/modules/toolbar/components/Toolbar.tsx +2 -5
  147. package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +91 -2
  148. package/src/modules/toolbar/index.ts +6 -0
  149. package/src/modules/toolbar/search/sources.ts +4 -7
  150. package/src/modules/toolbar/services/agent-instructions.api.ts +1 -1
  151. package/src/modules/toolbar/services/external-api-keys.api.ts +5 -2
  152. package/src/modules/tools/ToolsExplorerPage.tsx +217 -18
  153. package/src/modules/tools/__tests__/ToolsExplorerPage.read-only.test.tsx +220 -0
  154. package/src/modules/tools/tool-hints.api.ts +44 -0
  155. package/src/modules/workflow/index.ts +7 -0
  156. package/src/modules/workflow/state/ChangeRequestStaleBinder.tsx +1 -0
  157. package/src/modules/workflow/state/EventBusFocusBinder.tsx +1 -1
  158. package/src/modules/workspace/components/FileExplorer.tsx +35 -8
  159. package/src/modules/workspace/components/FilePaneCard.tsx +37 -12
  160. package/src/modules/workspace/components/FileRoute.tsx +10 -3
  161. package/src/modules/workspace/components/FileViewer.tsx +169 -25
  162. package/src/modules/workspace/components/FullScreenView.tsx +93 -0
  163. package/src/modules/workspace/components/KbFileRail.tsx +1 -1
  164. package/src/modules/workspace/components/KbPageHeader.tsx +9 -0
  165. package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +163 -0
  166. package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +11 -0
  167. package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +487 -3
  168. package/src/modules/workspace/components/readingCarry.ts +59 -0
  169. package/src/modules/workspace/components/renderers/HtmlRenderer.tsx +74 -180
  170. package/src/modules/workspace/components/renderers/KbAppLink.tsx +56 -0
  171. package/src/modules/workspace/components/renderers/KbMarkdownView.tsx +30 -10
  172. package/src/modules/workspace/components/renderers/MarkdownRenderer.tsx +37 -40
  173. package/src/modules/workspace/components/renderers/ToolRenderer.tsx +1 -1
  174. package/src/modules/workspace/components/renderers/__tests__/HtmlRenderer.links.test.tsx +185 -0
  175. package/src/modules/workspace/components/renderers/__tests__/HtmlRenderer.tools.test.tsx +168 -42
  176. package/src/modules/workspace/components/renderers/__tests__/MarkdownRenderer.sectionReclick.test.tsx +88 -0
  177. package/src/modules/workspace/components/renderers/__tests__/MarkdownRenderer.test.tsx +199 -29
  178. package/src/modules/workspace/components/renderers/__tests__/bridgeHarness.ts +57 -7
  179. package/src/modules/workspace/components/renderers/__tests__/htmlSandbox.test.ts +122 -4
  180. package/src/modules/workspace/components/renderers/__tests__/htmlToolBridge.test.ts +235 -1
  181. package/src/modules/workspace/components/renderers/__tests__/htmlViewsGuide.test.ts +29 -4
  182. package/src/modules/workspace/components/renderers/__tests__/liveDataReferencePage.test.ts +397 -0
  183. package/src/modules/workspace/components/renderers/__tests__/pageToolsHarness.ts +79 -0
  184. package/src/modules/workspace/components/renderers/__tests__/useHtmlToolBridge.test.tsx +316 -0
  185. package/src/modules/workspace/components/renderers/htmlSandbox.ts +123 -28
  186. package/src/modules/workspace/components/renderers/htmlToolBridge.ts +215 -25
  187. package/src/modules/workspace/components/renderers/index.ts +10 -0
  188. package/src/modules/workspace/components/renderers/kbMarkdownPipeline.tsx +35 -28
  189. package/src/modules/workspace/components/renderers/scrollToHeading.ts +35 -0
  190. package/src/modules/workspace/components/renderers/useHtmlToolBridge.tsx +253 -0
  191. package/src/modules/workspace/hooks/__tests__/useLinksOut.test.ts +6 -0
  192. package/src/modules/workspace/hooks/useFullScreenView.ts +52 -0
  193. package/src/modules/workspace/hooks/useImageRevision.ts +1 -1
  194. package/src/modules/workspace/hooks/useKnowledgeWriteTarget.ts +1 -1
  195. package/src/modules/workspace/hooks/useLastCommit.ts +1 -1
  196. package/src/modules/workspace/hooks/useLinksOut.ts +12 -6
  197. package/src/modules/workspace/hooks/useWorkspaceState.ts +4 -4
  198. package/src/modules/workspace/index.ts +50 -2
  199. package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +262 -25
  200. package/src/modules/workspace/routing/kb-routes.ts +222 -54
  201. package/src/modules/workspace/state/__tests__/applied-request-clears-pending.test.tsx +0 -1
  202. package/src/modules/workspace/state/open-change-requests.tsx +1 -1
  203. package/src/modules/workspace/utils/fileTree.ts +1 -1
  204. package/src/modules/workspace/utils/frameEscape.ts +15 -0
  205. package/src/modules/workspace/utils/treeConfirm.ts +1 -1
  206. package/src/shared/theme/measure.ts +7 -0
  207. package/src/modules/pr/services/pr-comments.api.ts +0 -45
@@ -4,12 +4,10 @@ import { MIN_PASSWORD_LENGTH } from '@bevel-software/platform-shared';
4
4
  import { Badge, Banner, Button, Dialog, TextField, type BadgeTone } from '../../../shared/components';
5
5
  import { SlotBoundary } from '../../../shared/components/SlotBoundary';
6
6
  import { useAppRegistry } from '../../../core/registry';
7
- import { useAuth } from '../../auth/state/auth.context';
8
- import { useSignInMethods } from '../../auth/state/use-sign-in-methods';
9
- import type { LoginProviders } from '../../auth/services/sso';
10
- import { createAccount, listAccounts } from '../../auth/services/account.api';
11
- import { addMember, fetchRoles } from '../../admin/services/roles.api';
12
- import { copyToClipboard } from '../../library/utils/clipboard';
7
+ import { useAuth, useSignInMethods, createAccount, listAccounts } from '../../auth';
8
+ import type { LoginProviders } from '../../auth';
9
+ import { addMember, fetchRoles } from '../../admin';
10
+ import { copyToClipboard } from '../../library';
13
11
  import { initials } from '../../../lib/email';
14
12
  import { EmailChipsInput } from './EmailChipsInput';
15
13
  import {
@@ -1,7 +1,7 @@
1
1
  import { useEffect, useState } from 'react';
2
2
  import { Navigate } from 'react-router-dom';
3
- import { KB_ROUTE_PREFIX } from '../../workspace/routing/kb-routes';
4
- import { takePostLoginRedirect } from '../../auth/services/sso';
3
+ import { KB_ROUTE_PREFIX } from '../../workspace';
4
+ import { takePostLoginRedirect } from '../../auth';
5
5
 
6
6
  /**
7
7
  * Where `/` lands: Knowledge, for everyone, brand-new accounts included.
@@ -1,6 +1,6 @@
1
1
  import { useState } from 'react';
2
2
  import { Button } from '../../../shared/components';
3
- import { useWorkspace } from '../../workspace/state/workspace.context';
3
+ import { useWorkspace } from '../../workspace';
4
4
  import { useStarterPacks } from '../state/starter-packs';
5
5
  import { SKIP_STARTER_PACK, type StarterPackApplied, type StarterPackSummary } from '../services/starter-packs.api';
6
6
 
@@ -3,12 +3,9 @@ import { useNavigate } from 'react-router-dom';
3
3
  import { Check, Copy, X } from 'lucide-react';
4
4
  import { cn } from '../../../lib/utils';
5
5
  import { Button, IconButton } from '../../../shared/components';
6
- import { useAuth } from '../../auth/state/auth.context';
7
- import { useLibraryToast } from '../../library/state/toast.context';
8
- import { copyToClipboard, COPY_FAILED_TOAST } from '../../library/utils/clipboard';
9
- import { pathForLibraryFilter } from '../../library/routes/library-paths';
6
+ import { useAuth } from '../../auth';
7
+ import { useLibraryToast, copyToClipboard, COPY_FAILED_TOAST, pathForLibraryFilter, displayFirstName } from '../../library';
10
8
  import { useAppRegistry } from '../../../core/registry';
11
- import { displayFirstName } from '../../library/utils/personal-plugin';
12
9
  import { ChatGptInstallLink, ClaudeInstallLink, mcpEndpointUrl } from '../../../shared/mcp';
13
10
  import { AGENT_CLIENTS, type AgentClient } from '../agent-clients';
14
11
  import { useOnboarding } from '../state/onboarding';
@@ -0,0 +1,10 @@
1
+ /**
2
+ * What the onboarding module offers the other modules. A consumer outside the
3
+ * module imports from here, never from the files: they are the module's own
4
+ * layout and free to move. Export what another module needs; nothing more.
5
+ */
6
+ export { WELCOME_PATH } from './paths';
7
+ export { useInviteDialog } from './state/invite-dialog.context';
8
+ export type { InviteDialogController } from './state/invite-dialog.context';
9
+ export { useOnboarding, useSetupChecklist } from './state/onboarding';
10
+ export { useStarterPacks } from './state/starter-packs';
@@ -1,4 +1,4 @@
1
- import { LIBRARY_ROOT } from '../library/routes/library-paths';
1
+ import { LIBRARY_ROOT } from '../library';
2
2
 
3
3
  /**
4
4
  * The welcome page lives INSIDE the Library surface (it renders in
@@ -1,6 +1,6 @@
1
1
  import { useContext, useEffect, useState, useSyncExternalStore } from 'react';
2
- import { AuthContext } from '../../auth/state/auth.context';
3
- import { useEventBus } from '../../workflow/state/event-bus.context';
2
+ import { AuthContext } from '../../auth';
3
+ import { useEventBus } from '../../workflow';
4
4
  import { fetchAgentConnection, type AgentConnection } from '../services/agent-connection.api';
5
5
 
6
6
  /**
@@ -1,5 +1,5 @@
1
1
  import { useContext, useSyncExternalStore } from 'react';
2
- import { AuthContext } from '../../auth/state/auth.context';
2
+ import { AuthContext } from '../../auth';
3
3
  import { authFetch } from '../../../lib/api';
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import { useCallback, useContext, useEffect, useSyncExternalStore } from 'react';
2
- import { AuthContext } from '../../auth/state/auth.context';
2
+ import { AuthContext } from '../../auth';
3
3
  import {
4
4
  StarterPackApiError,
5
5
  chooseStarterPack,
@@ -5,7 +5,7 @@ import {
5
5
  protectedBranchDisplayName,
6
6
  } from '@bevel-software/platform-shared';
7
7
  import { Dialog } from '../../../shared/components/Dialog';
8
- import { useGit } from '../../git/state/git.context';
8
+ import { useGit } from '../../git';
9
9
  import { openChangeRequest } from '../services/pr-open.api';
10
10
  import { PR_STALE_EVENT } from '../../../core/events';
11
11
 
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The pr module's public surface: the change-request operations other modules
3
+ * call. Composed from the service files here, so a caller depends on the
4
+ * module and not on which file happens to hold a verb.
5
+ */
6
+ export { fetchPrDetail } from './services/pr-detail.api';
7
+ export { openChangeRequest } from './services/pr-open.api';
8
+ export { updateChangeRequest } from './services/pr-edit.api';
9
+ export { approvePrFile, revertPrFile, unapprovePrFile } from './services/pr-approvals.api';
10
+ export { deleteChangeRequest } from './services/pr-cancel.api';
11
+ export { refreshChangeRequestFromTarget } from './services/pr-merge.api';
12
+ // Reached by other modules; exported here so they stop importing the files.
13
+ export { cancelPullRequest } from './services/pr-cancel.api';
14
+ export { mergePullRequest } from './services/pr-merge.api';
@@ -1,6 +1,6 @@
1
1
  import type { FileApprovalState } from '@bevel-software/platform-shared';
2
2
  import { authFetch } from '../../../lib/api';
3
- import { handleApiResponse } from '../../git/services/git.api';
3
+ import { handleApiResponse } from '../../git';
4
4
 
5
5
  export async function approvePrFile(
6
6
  prNumber: number,
@@ -1,6 +1,6 @@
1
1
  import type { CancelPrResult } from '@bevel-software/platform-shared';
2
2
  import { authFetch } from '../../../lib/api';
3
- import { handleApiResponse } from '../../git/services/git.api';
3
+ import { handleApiResponse } from '../../git';
4
4
 
5
5
  /**
6
6
  * Close the change request without merging. The backend re-validates that the
@@ -1,11 +1,11 @@
1
1
  import type { PullRequestDetail } from '@bevel-software/platform-shared';
2
2
  import { authFetch } from '../../../lib/api';
3
- import { handleApiResponse } from '../../git/services/git.api';
3
+ import { handleApiResponse } from '../../git';
4
4
 
5
5
  /**
6
6
  * Fetch the full PR detail (metadata + file diffs). `fresh` bypasses the
7
7
  * backend's 30s detail cache — use from event-driven refreshes (post-merge,
8
- * post-comment, post-open-change-request) but leave off for user-triggered
8
+ * post-edit, post-open-change-request) but leave off for user-triggered
9
9
  * navigation.
10
10
  */
11
11
  export async function fetchPrDetail(
@@ -0,0 +1,22 @@
1
+ import type { PullRequestSummary, UpdateChangeRequestInput } from '@bevel-software/platform-shared';
2
+ import { authFetch } from '../../../lib/api';
3
+ import { handleApiResponse } from '../../git';
4
+
5
+ /**
6
+ * Change an open change request's title and/or description. The server
7
+ * re-checks who may (the author, or anyone who may merge it — the
8
+ * `viewerCanEdit` verdict) and refuses a merged or closed request; its
9
+ * refusal's words arrive as the thrown error's message.
10
+ */
11
+ export async function updateChangeRequest(
12
+ prNumber: number,
13
+ input: UpdateChangeRequestInput,
14
+ ): Promise<PullRequestSummary> {
15
+ return handleApiResponse(
16
+ await authFetch(`/api/workflow/change-requests/${prNumber}`, {
17
+ method: 'PATCH',
18
+ headers: { 'Content-Type': 'application/json' },
19
+ body: JSON.stringify(input),
20
+ }),
21
+ );
22
+ }
@@ -1,6 +1,6 @@
1
1
  import type { ChangeRequestUpdateResult } from '@bevel-software/platform-shared';
2
2
  import { authFetch } from '../../../lib/api';
3
- import { handleApiResponse } from '../../git/services/git.api';
3
+ import { handleApiResponse } from '../../git';
4
4
 
5
5
  /** The 202 ack the merge endpoint returns — the merge then runs in the background. */
6
6
  export interface MergeAccepted {
@@ -1,5 +1,5 @@
1
1
  import { authFetch } from '../../../lib/api';
2
- import { handleApiResponse } from '../../git/services/git.api';
2
+ import { handleApiResponse } from '../../git';
3
3
 
4
4
  /** Request shape of `POST /api/workflow/change-requests` (see backend
5
5
  * `modules/workflow/workflow.routes.ts`). */
@@ -1,6 +1,6 @@
1
1
  import { useMemo } from 'react';
2
2
  import type { FileDiffPayload } from '@bevel-software/platform-shared';
3
- import { computeDiff, type DiffLine } from '../../workspace/utils/diff';
3
+ import { computeDiff, type DiffLine } from '../../workspace';
4
4
 
5
5
  const MAX_RENDERED_LINES = 5000;
6
6
 
@@ -1,8 +1,7 @@
1
1
  import { useMemo } from 'react';
2
2
  import Markdown from 'react-markdown';
3
3
  import { isFrontmatterFence, type FileDiffPayload } from '@bevel-software/platform-shared';
4
- import { computeDiff, type DiffLine } from '../../workspace/utils/diff';
5
- import { parseFrontmatter, labelFor, type FrontmatterData } from '../../workspace/utils/frontmatter';
4
+ import { computeDiff, type DiffLine, parseFrontmatter, labelFor, type FrontmatterData } from '../../workspace';
6
5
  import { escapeSpacesInLinkDestinations } from '../../../shared/markdown/Markdown';
7
6
  import {
8
7
  KB_REMARK_PLUGINS,
@@ -10,6 +9,7 @@ import {
10
9
  useKbMarkdownComponents,
11
10
  type KbImageResolver,
12
11
  } from '../../workspace/components/renderers/kbMarkdownPipeline';
12
+ import type { KbLinkTarget } from '../../workspace';
13
13
 
14
14
  const MAX_RENDERED_LINES = 5000;
15
15
 
@@ -30,6 +30,9 @@ interface MarkdownDiffViewerProps {
30
30
  onOpenFile?: (href: string) => void;
31
31
  /** Same contract as {@link onOpenFile}, for bare node-id links. */
32
32
  onOpenNodeId?: (id: string) => void;
33
+ /** Where each kind of link leads, for its anchor — `KbAppLink` in the pipeline. */
34
+ fileLinkTarget?: (href: string) => KbLinkTarget | null;
35
+ nodeIdLinkTarget?: (id: string) => KbLinkTarget | null;
33
36
  /**
34
37
  * Resolves a workspace image in the diff to the URL that serves it from the
35
38
  * CHECKED-OUT tree. It applies to unchanged and added fragments only; a
@@ -77,7 +80,15 @@ interface MarkdownDiffViewerProps {
77
80
  * routes, which sit outside those providers entirely. A `useNavigate()` in
78
81
  * here would be a runtime crash in all three.
79
82
  */
80
- export function MarkdownDiffViewer({ payload, onOpenFile, onOpenNodeId, resolveImage, scroll = true }: MarkdownDiffViewerProps) {
83
+ export function MarkdownDiffViewer({
84
+ payload,
85
+ onOpenFile,
86
+ onOpenNodeId,
87
+ fileLinkTarget,
88
+ nodeIdLinkTarget,
89
+ resolveImage,
90
+ scroll = true,
91
+ }: MarkdownDiffViewerProps) {
81
92
  const data = useMemo(() => {
82
93
  const baseline = payload.baseline ?? '';
83
94
  const current = payload.current ?? '';
@@ -134,6 +145,8 @@ export function MarkdownDiffViewer({ payload, onOpenFile, onOpenNodeId, resolveI
134
145
  blocks={data.bodyBlocks}
135
146
  onOpenFile={onOpenFile}
136
147
  onOpenNodeId={onOpenNodeId}
148
+ fileLinkTarget={fileLinkTarget}
149
+ nodeIdLinkTarget={nodeIdLinkTarget}
137
150
  resolveImage={resolveImage}
138
151
  />
139
152
  </div>
@@ -295,11 +308,15 @@ function DiffPreview({
295
308
  blocks,
296
309
  onOpenFile,
297
310
  onOpenNodeId,
311
+ fileLinkTarget,
312
+ nodeIdLinkTarget,
298
313
  resolveImage,
299
314
  }: {
300
315
  blocks: DisplayBlock[];
301
316
  onOpenFile?: (href: string) => void;
302
317
  onOpenNodeId?: (id: string) => void;
318
+ fileLinkTarget?: (href: string) => KbLinkTarget | null;
319
+ nodeIdLinkTarget?: (id: string) => KbLinkTarget | null;
303
320
  resolveImage?: KbImageResolver;
304
321
  }) {
305
322
  // Images, per fragment. The caller's resolver serves the CURRENT tree, which
@@ -335,12 +352,16 @@ function DiffPreview({
335
352
  const components = useKbMarkdownComponents({
336
353
  onOpenFile,
337
354
  onOpenNodeId,
355
+ fileLinkTarget,
356
+ nodeIdLinkTarget,
338
357
  onMermaidError: 'source',
339
358
  resolveImage: liveImages,
340
359
  });
341
360
  const baselineComponents = useKbMarkdownComponents({
342
361
  onOpenFile,
343
362
  onOpenNodeId,
363
+ fileLinkTarget,
364
+ nodeIdLinkTarget,
344
365
  onMermaidError: 'source',
345
366
  resolveImage: baselineImages,
346
367
  });
@@ -2,13 +2,12 @@ import { useCallback, useEffect, useRef, useState } from 'react';
2
2
  import { Check, Trash2, Eye, ChevronDown, X } from 'lucide-react';
3
3
  import type { PendingChange } from '@bevel-software/platform-shared';
4
4
  import { useReview } from '../state/review.context';
5
- import { useWorkspace } from '../../workspace/state/workspace.context';
5
+ import { useWorkspace, useWorkspaceImageResolver } from '../../workspace';
6
6
  import {
7
7
  useFileNav,
8
8
  useNodeIdNav,
9
9
  stripJunkBeforeKbDir,
10
- } from '../../workspace/routing/kb-routes';
11
- import { useWorkspaceImageResolver } from '../../workspace/hooks/useWorkspaceImageResolver';
10
+ } from '../../workspace';
12
11
  import { pluginOfPath, currentKbLayout, DEFAULT_BRANCH } from '@bevel-software/platform-shared';
13
12
  import { cn } from '../../../lib/utils';
14
13
  import { DOCUMENT_COLUMN, documentGutters } from '../../../shared/theme/measure';
@@ -110,14 +109,14 @@ function kindLabel(kind: PendingChange['kind']): string {
110
109
  export function ReviewPanel({ onClose }: { onClose?: () => void }) {
111
110
  const review = useReview();
112
111
  const { refreshFileTree, kbDirName, workspaceId } = useWorkspace();
113
- const { openFile, openLink } = useFileNav();
112
+ const { openFile, openLink, linkTarget } = useFileNav();
114
113
  // Links inside a rendered diff. Both resolvers navigate relative to
115
114
  // `git.status.branch`, which is CORRECT here and only here: this panel
116
115
  // reviews the agent's uncommitted changes on the branch you are already
117
116
  // standing on, so "the diff's branch" and "the current branch" are the same
118
117
  // thing. (The change-request dialog is not in that position, which is why it
119
118
  // passes no resolvers — see the comment at its MarkdownDiffViewer call.)
120
- const { openNodeId } = useNodeIdNav();
119
+ const { openNodeId, nodeIdTarget } = useNodeIdNav();
121
120
  const diffPath = review.fileDiff?.path ?? '';
122
121
  // Resolved against the diffed file by `openLink`: decoded, an absolute URL
123
122
  // keeping its own branch. The same grammar MarkdownRenderer uses.
@@ -125,6 +124,10 @@ export function ReviewPanel({ onClose }: { onClose?: () => void }) {
125
124
  (href: string) => openLink(href, diffPath),
126
125
  [openLink, diffPath],
127
126
  );
127
+ const diffLinkTarget = useCallback(
128
+ (href: string) => linkTarget(href, diffPath),
129
+ [linkTarget, diffPath],
130
+ );
128
131
  // Images inside a rendered diff, bound to the CHECKED-OUT workspace for the
129
132
  // reason above: the working tree IS the diff's new state, so an image the
130
133
  // agent added is on disk and can be shown. The viewer applies this to the
@@ -374,6 +377,8 @@ export function ReviewPanel({ onClose }: { onClose?: () => void }) {
374
377
  payload={fileDiff}
375
378
  onOpenFile={openDiffLink}
376
379
  onOpenNodeId={openNodeId}
380
+ fileLinkTarget={diffLinkTarget}
381
+ nodeIdLinkTarget={nodeIdTarget}
377
382
  resolveImage={resolveDiffImage}
378
383
  scroll={false}
379
384
  />
@@ -103,6 +103,37 @@ describe('MarkdownDiffViewer', () => {
103
103
  await userEvent.click(screen.getByText('the process'));
104
104
  expect(onOpenNodeId).toHaveBeenCalledWith('order-intake');
105
105
  });
106
+
107
+ it("carry the target the caller resolves: the new tab's address, target=_blank, rel=noopener", () => {
108
+ const nodeIdLinkTarget = vi.fn(() => ({ href: '/workspace/main/order-intake', newTab: true }));
109
+ render(
110
+ <MarkdownDiffViewer payload={withIdLink} onOpenNodeId={vi.fn()} nodeIdLinkTarget={nodeIdLinkTarget} />,
111
+ );
112
+ const link = screen.getByRole('link', { name: 'the process' });
113
+ expect(nodeIdLinkTarget).toHaveBeenCalledWith('order-intake');
114
+ expect(link).toHaveAttribute('href', '/workspace/main/order-intake');
115
+ expect(link).toHaveAttribute('target', '_blank');
116
+ expect(link).toHaveAttribute('rel', 'noopener');
117
+ });
118
+ });
119
+
120
+ it("gives a file link the target the caller resolves, and follows a click through the caller", async () => {
121
+ const onOpenFile = vi.fn();
122
+ const fileLinkTarget = vi.fn(() => ({ href: '/workspace/main/Knowledge/Plan.md', newTab: true }));
123
+ render(
124
+ <MarkdownDiffViewer
125
+ payload={payload('Nothing\n', 'See [the plan](Plan.md)\n')}
126
+ onOpenFile={onOpenFile}
127
+ fileLinkTarget={fileLinkTarget}
128
+ />,
129
+ );
130
+ const link = screen.getByRole('link', { name: 'the plan' });
131
+ expect(fileLinkTarget).toHaveBeenCalledWith('Plan.md');
132
+ expect(link).toHaveAttribute('href', '/workspace/main/Knowledge/Plan.md');
133
+ expect(link).toHaveAttribute('target', '_blank');
134
+ expect(link).toHaveAttribute('rel', 'noopener');
135
+ await userEvent.click(link);
136
+ expect(onOpenFile).toHaveBeenCalledWith('Plan.md');
106
137
  });
107
138
 
108
139
  it('escapes spaces in link destinations so KB links resolve', () => {
@@ -1,8 +1,8 @@
1
1
  import type { ReactNode } from 'react';
2
2
  import { ReviewContext } from './review.context';
3
3
  import { useReviewState } from '../hooks/useReviewState';
4
- import { useWorkspace } from '../../workspace/state/workspace.context';
5
- import { useGit } from '../../git/state/git.context';
4
+ import { useWorkspace } from '../../workspace';
5
+ import { useGit } from '../../git';
6
6
 
7
7
  /**
8
8
  * Wires the agent-review session state into the tree. Registered by the
@@ -8,6 +8,8 @@ import { setUserVar, setAdminVar, deleteUserVar, setOAuthClientSecret } from '..
8
8
  import { SavedKeyProbeResult } from '../probe/SavedKeyProbeResult';
9
9
  import { useSavedKeyProbe, type SavedKeyProbe } from '../probe/useSavedKeyProbe';
10
10
  import { announceToolCredentialsChanged } from '../../../core/events';
11
+ import { useConnectAsChoice } from '../../agents';
12
+ import { ConnectAsChoice } from '../../agents/components/ConnectAsChoice';
11
13
  import {
12
14
  getConnectPending,
13
15
  startToolOAuth,
@@ -31,6 +33,20 @@ import {
31
33
  * alive across that round-trip. Cleared on Finish or when the state goes stale.
32
34
  */
33
35
  const MCP_OAUTH_STATE_KEY = 'mcp-oauth-state';
36
+ /** The "Connect as" choice made on the way, kept beside the state for the same round-trip. */
37
+ const MCP_OAUTH_AGENT_KEY = 'mcp-oauth-agent';
38
+
39
+ /**
40
+ * The choice to start from: the one made earlier in THIS authorization (the
41
+ * page came back from a tool sign-in, its query stripped), else Everything —
42
+ * an authorization arriving in the address that is not the remembered one is
43
+ * a new connection, and starts at Everything.
44
+ */
45
+ function rememberedConnectAs(): string | null {
46
+ const fromUrl = new URLSearchParams(window.location.search).get('oauth');
47
+ if (fromUrl && fromUrl !== sessionStorage.getItem(MCP_OAUTH_STATE_KEY)) return null;
48
+ return sessionStorage.getItem(MCP_OAUTH_AGENT_KEY);
49
+ }
34
50
 
35
51
  /**
36
52
  * "Connect your tools" — the page a person lands on from the needs-authorization
@@ -99,6 +115,12 @@ export function ConnectToolsPage() {
99
115
  // Agent-connect mode: the signed authorization state + who is asking.
100
116
  const [agentState, setAgentState] = useState<string | null>(null);
101
117
  const [agentName, setAgentName] = useState<string | null>(null);
118
+ // "Connect as": the agents on offer and the choice — Everything unless the
119
+ // person picks one — kept across a tool sign-in's round-trip
120
+ // (`rememberedConnectAs`). Finish waits until the CURRENT request's agents
121
+ // have answered (before that it would approve Everything unseen), and for
122
+ // Everything to be confirmed when they could not be loaded.
123
+ const connectAs = useConnectAsChoice({ initial: rememberedConnectAs, expect: agentState });
102
124
  const [finishing, setFinishing] = useState(false);
103
125
  // Entries the user took OUT. Everything the server sent is in by default —
104
126
  // it used to be the other way round, and an unconfigured tool the reader had
@@ -118,6 +140,14 @@ export function ConnectToolsPage() {
118
140
  */
119
141
  const loadSeq = useRef(0);
120
142
 
143
+ // The agent the list is for: the "Connect as" choice, in agent-connect mode
144
+ // only. A connection made as an agent loads only the connectors its file
145
+ // lists, so the page asks for the sign-ins and keys of those and no other —
146
+ // asking for hubspot's sign-in on the way to an agent that never loads
147
+ // hubspot sends the person off to sign in for nothing. Everything (null)
148
+ // lists what it always listed.
149
+ const chosenAgent = agentState != null ? connectAs.value : null;
150
+
121
151
  /**
122
152
  * @param quiet keep the list on screen while it refetches.
123
153
  *
@@ -132,7 +162,7 @@ export function ConnectToolsPage() {
132
162
  if (!quiet) setLoading(true);
133
163
  setRefreshing(true);
134
164
  try {
135
- const pending = await getConnectPending();
165
+ const pending = await getConnectPending(chosenAgent);
136
166
  if (loadSeq.current !== mine) return;
137
167
  setTools(pending.tools);
138
168
  setOauth(pending.oauth);
@@ -148,17 +178,27 @@ export function ConnectToolsPage() {
148
178
  setRefreshing(false);
149
179
  }
150
180
  }
151
- }, []);
152
-
181
+ }, [chosenAgent]);
182
+
183
+ // The first load, loud; and again, quietly, whenever the choice changes —
184
+ // `refresh` is remade for the chosen agent, and the list on screen is the
185
+ // other agent's until the new one answers, which is the one case a loud
186
+ // reload would have nothing to protect (no row holds a probe's verdict
187
+ // for a list that is about to be replaced) and still nothing to gain.
188
+ const loadedOnce = useRef(false);
153
189
  useEffect(() => {
154
- // eslint-disable-next-line react-hooks/set-state-in-effect -- the first load; refresh sets state once it answers
155
- void refresh();
190
+ const quiet = loadedOnce.current;
191
+ loadedOnce.current = true;
192
+ void refresh(quiet);
156
193
  }, [refresh]);
157
194
 
158
195
  // Pick up (and persist) the external-agent authorization state.
159
196
  useEffect(() => {
160
197
  const fromUrl = new URLSearchParams(window.location.search).get('oauth');
161
198
  if (fromUrl) {
199
+ // A NEW authorization starts at Everything (see `rememberedConnectAs`):
200
+ // a choice remembered from another one is not this connection's.
201
+ if (sessionStorage.getItem(MCP_OAUTH_STATE_KEY) !== fromUrl) sessionStorage.removeItem(MCP_OAUTH_AGENT_KEY);
162
202
  sessionStorage.setItem(MCP_OAUTH_STATE_KEY, fromUrl);
163
203
  // eslint-disable-next-line react-hooks/set-state-in-effect -- the query is read once, on arrival
164
204
  setAgentState(fromUrl);
@@ -169,23 +209,27 @@ export function ConnectToolsPage() {
169
209
 
170
210
  // Resolve who is asking; a stale/expired state silently drops the mode (the
171
211
  // agent restarts the flow if the user takes too long).
212
+ const settleConnectAs = connectAs.settle;
172
213
  useEffect(() => {
173
214
  if (!agentState) return;
174
215
  let cancelled = false;
175
216
  getMcpOAuthRequest(agentState)
176
217
  .then((r) => {
177
- if (!cancelled) setAgentName(r.clientName);
218
+ if (cancelled) return;
219
+ setAgentName(r.clientName);
220
+ settleConnectAs({ agents: r.agents ?? [], failed: r.agentsUnavailable === true }, agentState);
178
221
  })
179
222
  .catch(() => {
180
223
  if (cancelled) return;
181
224
  sessionStorage.removeItem(MCP_OAUTH_STATE_KEY);
225
+ sessionStorage.removeItem(MCP_OAUTH_AGENT_KEY);
182
226
  setAgentState(null);
183
227
  setAgentName(null);
184
228
  });
185
229
  return () => {
186
230
  cancelled = true;
187
231
  };
188
- }, [agentState]);
232
+ }, [agentState, settleConnectAs]);
189
233
 
190
234
  // A sign-in came back to this page (the callback lands on whichever page
191
235
  // started it): the fragment it carried is stripped, now that it has been
@@ -220,11 +264,12 @@ export function ConnectToolsPage() {
220
264
  };
221
265
 
222
266
  const onFinish = async () => {
223
- if (!agentState) return;
267
+ if (!agentState || !connectAs.mayConnect) return;
224
268
  setFinishing(true);
225
269
  try {
226
- const redirectTo = await completeMcpOAuth(agentState);
270
+ const redirectTo = await completeMcpOAuth(agentState, connectAs.value);
227
271
  sessionStorage.removeItem(MCP_OAUTH_STATE_KEY);
272
+ sessionStorage.removeItem(MCP_OAUTH_AGENT_KEY);
228
273
  window.location.href = redirectTo;
229
274
  } catch (err) {
230
275
  setError(err instanceof Error ? err.message : String(err));
@@ -348,12 +393,26 @@ export function ConnectToolsPage() {
348
393
  variant="primary"
349
394
  size="sm"
350
395
  className="shrink-0"
351
- disabled={finishing}
396
+ disabled={finishing || !connectAs.mayConnect}
352
397
  onClick={() => void onFinish()}
353
398
  >
354
399
  {finishing ? 'Finishing…' : 'Finish & return to your agent'}
355
400
  </Button>
356
401
  </div>
402
+ <div className="mt-4">
403
+ <ConnectAsChoice
404
+ agents={connectAs.agents}
405
+ value={connectAs.value}
406
+ disabled={finishing}
407
+ hint="What this connection loads. An agent narrows it to the tools, skills and plugins its configuration lists, and only those you may read."
408
+ onChange={(path) => {
409
+ connectAs.setValue(path);
410
+ if (path) sessionStorage.setItem(MCP_OAUTH_AGENT_KEY, path);
411
+ else sessionStorage.removeItem(MCP_OAUTH_AGENT_KEY);
412
+ }}
413
+ unavailable={connectAs.unavailable}
414
+ />
415
+ </div>
357
416
  </Surface>
358
417
  )}
359
418
 
@@ -378,11 +437,13 @@ export function ConnectToolsPage() {
378
437
  so before they wonder why a row has no field. */}
379
438
  {!nothingToDo && (
380
439
  <p className="mb-5 text-ui text-ink-muted">
381
- These tools need a sign-in or a key before they will work in your agent. Authorize
382
- each connection and enter any keys below, then head back to your agent and run the
383
- tool again. Anything greyed out is not yours to do — it is waiting on the tool&apos;s
384
- owner, or you took it out yourself. Your values are stored securely and never shown
385
- again after saving.
440
+ {chosenAgent
441
+ ? 'These are the tools the chosen agent loads that need a sign-in or a key before they will work in your agent. '
442
+ : 'These tools need a sign-in or a key before they will work in your agent. '}
443
+ Authorize each connection and enter any keys below, then head back to your agent and
444
+ run the tool again. Anything greyed out is not yours to do — it is waiting on the
445
+ tool&apos;s owner, or you took it out yourself. Your values are stored securely and
446
+ never shown again after saving.
386
447
  </p>
387
448
  )}
388
449
 
@@ -394,7 +455,9 @@ export function ConnectToolsPage() {
394
455
  // every shared tool works without a personal credential, so the
395
456
  // user's only job is to finish.
396
457
  <Banner role="status" tone="ok">
397
- You&apos;re all set: none of your tools need a personal sign-in or key. Click
458
+ {chosenAgent
459
+ ? 'You’re all set: none of the tools the chosen agent loads need a personal sign-in or key. Click '
460
+ : 'You’re all set: none of your tools need a personal sign-in or key. Click '}
398
461
  “Finish &amp; return to your agent” above to complete the connection.
399
462
  </Banner>
400
463
  ) : (