@bevel-software/platform-core-frontend 0.32.0 → 0.33.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 (167) hide show
  1. package/package.json +2 -2
  2. package/src/core/CoreAppShell.tsx +1 -1
  3. package/src/modules/access/api.ts +1 -1
  4. package/src/modules/access/components/ManageAccessDialog.tsx +4 -5
  5. package/src/modules/access/hooks/useAccessRequests.ts +1 -1
  6. package/src/modules/access/hooks/useFileAccess.ts +1 -1
  7. package/src/modules/access/index.ts +11 -0
  8. package/src/modules/access/requests.api.ts +1 -1
  9. package/src/modules/admin/components/AddMemberInput.tsx +1 -1
  10. package/src/modules/admin/components/UserAccountsPage.tsx +3 -3
  11. package/src/modules/admin/index.ts +7 -0
  12. package/src/modules/admin/state/admin.context.tsx +1 -1
  13. package/src/modules/audit/components/AuditEventsPanel.tsx +1 -1
  14. package/src/modules/audit/components/AuditLogPage.tsx +2 -2
  15. package/src/modules/auth/index.ts +12 -0
  16. package/src/modules/change-requests/__tests__/ChangeRequestDialog.access-rules.test.tsx +0 -1
  17. package/src/modules/change-requests/__tests__/ChangeRequestDialog.binary.test.tsx +0 -1
  18. package/src/modules/change-requests/__tests__/ChangeRequestDialog.brings-itself-up-to-date.test.tsx +0 -1
  19. package/src/modules/change-requests/__tests__/ChangeRequestDialog.edit.test.tsx +166 -0
  20. package/src/modules/change-requests/__tests__/ChangeRequestDialog.fork-point.test.tsx +0 -1
  21. package/src/modules/change-requests/__tests__/ChangeRequestDialog.initial-file.test.tsx +0 -1
  22. package/src/modules/change-requests/__tests__/ChangeRequestDialog.moved.test.tsx +0 -1
  23. package/src/modules/change-requests/__tests__/ChangeRequestDialog.sync-banner.test.tsx +0 -1
  24. package/src/modules/change-requests/__tests__/ChangeRequestDialog.test.tsx +0 -2
  25. package/src/modules/change-requests/__tests__/ChangeRequestDialog.unreadable.test.tsx +0 -1
  26. package/src/modules/change-requests/__tests__/apply-outcome-for-every-viewer.test.tsx +0 -1
  27. package/src/modules/change-requests/components/BranchFilePreview.tsx +4 -12
  28. package/src/modules/change-requests/components/ChangeRequestDialog.tsx +138 -30
  29. package/src/modules/change-requests/components/ChangeRequestLink.tsx +2 -3
  30. package/src/modules/change-requests/components/CrFileTree.tsx +1 -1
  31. package/src/modules/change-requests/components/FileChangeBoxes.tsx +2 -3
  32. package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +3 -5
  33. package/src/modules/change-requests/hooks/useCrFileDiffs.ts +1 -1
  34. package/src/modules/change-requests/index.ts +14 -0
  35. package/src/modules/change-requests/services/change-requests.api.ts +2 -2
  36. package/src/modules/change-requests/services/denied-file.api.ts +2 -2
  37. package/src/modules/change-requests/services/propose.api.ts +3 -4
  38. package/src/modules/change-requests/utils/diff.ts +1 -1
  39. package/src/modules/change-requests/utils/readFailure.ts +1 -1
  40. package/src/modules/embed/__tests__/EmbedView.test.tsx +19 -2
  41. package/src/modules/embed/components/EmbedLinkPage.tsx +1 -2
  42. package/src/modules/git/components/BranchSwitcher.tsx +3 -4
  43. package/src/modules/git/components/FileHistoryPanel.tsx +2 -2
  44. package/src/modules/git/components/GitSyncFailedBanner.tsx +2 -4
  45. package/src/modules/git/components/HistoryVersionPreview.tsx +4 -15
  46. package/src/modules/git/components/PullNeededBanner.tsx +1 -1
  47. package/src/modules/git/hooks/useAutoPullUpdates.ts +1 -1
  48. package/src/modules/git/index.ts +11 -0
  49. package/src/modules/layout/components/MobileChatLayout.tsx +1 -1
  50. package/src/modules/layout/index.ts +9 -0
  51. package/src/modules/library/__tests__/SkillPage.test.tsx +39 -0
  52. package/src/modules/library/__tests__/propose-change.test.ts +75 -0
  53. package/src/modules/library/components/AddToPluginDialog.tsx +1 -1
  54. package/src/modules/library/components/ChangeRequestDock.tsx +1 -1
  55. package/src/modules/library/components/LibraryLayout.tsx +2 -2
  56. package/src/modules/library/components/LibraryPage.tsx +3 -3
  57. package/src/modules/library/components/ManagedPluginRequests.tsx +1 -1
  58. package/src/modules/library/components/NewSkillPanel.tsx +2 -2
  59. package/src/modules/library/components/PersonalAddDialog.tsx +1 -1
  60. package/src/modules/library/components/PersonalPluginPage.tsx +1 -1
  61. package/src/modules/library/components/PluginExtras.tsx +1 -4
  62. package/src/modules/library/components/PluginPage.tsx +1 -1
  63. package/src/modules/library/components/PluginRows.tsx +1 -1
  64. package/src/modules/library/components/SkillsTree.tsx +1 -4
  65. package/src/modules/library/components/plugin-page-parts.tsx +1 -1
  66. package/src/modules/library/components/skill-page/SkillFilePane.tsx +19 -7
  67. package/src/modules/library/components/skill-page/SkillPage.tsx +19 -26
  68. package/src/modules/library/components/tool-page/ToolConnectionSection.tsx +2 -4
  69. package/src/modules/library/components/tool-page/ToolVarRow.tsx +2 -2
  70. package/src/modules/library/hooks/useJoinRequests.ts +1 -1
  71. package/src/modules/library/hooks/useLibraryData.ts +3 -3
  72. package/src/modules/library/hooks/useToolPage.ts +1 -1
  73. package/src/modules/library/hooks/useToolSource.ts +1 -1
  74. package/src/modules/library/index.ts +12 -0
  75. package/src/modules/library/routes/LibraryRoutes.tsx +1 -1
  76. package/src/modules/library/routes/WorkspaceItemRoute.tsx +1 -3
  77. package/src/modules/library/routes/library-paths.ts +1 -1
  78. package/src/modules/library/services/library.api.ts +10 -8
  79. package/src/modules/library/services/plugins.api.ts +1 -1
  80. package/src/modules/library/services/teams.api.ts +1 -1
  81. package/src/modules/library/utils/status.ts +2 -2
  82. package/src/modules/onboarding/components/ConnectAgentPill.tsx +1 -1
  83. package/src/modules/onboarding/components/CreatorWelcomePage.tsx +2 -3
  84. package/src/modules/onboarding/components/GetStartedColumn.tsx +6 -13
  85. package/src/modules/onboarding/components/InviteButton.tsx +2 -2
  86. package/src/modules/onboarding/components/InviteDialog.tsx +4 -6
  87. package/src/modules/onboarding/components/RootLanding.tsx +2 -2
  88. package/src/modules/onboarding/components/StarterPackCard.tsx +1 -1
  89. package/src/modules/onboarding/components/WelcomePage.tsx +2 -5
  90. package/src/modules/onboarding/index.ts +10 -0
  91. package/src/modules/onboarding/paths.ts +1 -1
  92. package/src/modules/onboarding/state/agent-connection.ts +2 -2
  93. package/src/modules/onboarding/state/onboarding.ts +1 -1
  94. package/src/modules/onboarding/state/starter-packs.ts +1 -1
  95. package/src/modules/pr/components/OpenChangeRequestDialog.tsx +1 -1
  96. package/src/modules/pr/index.ts +14 -0
  97. package/src/modules/pr/services/pr-approvals.api.ts +1 -1
  98. package/src/modules/pr/services/pr-cancel.api.ts +1 -1
  99. package/src/modules/pr/services/pr-detail.api.ts +2 -2
  100. package/src/modules/pr/services/pr-edit.api.ts +22 -0
  101. package/src/modules/pr/services/pr-merge.api.ts +1 -1
  102. package/src/modules/pr/services/pr-open.api.ts +1 -1
  103. package/src/modules/review/components/DiffViewer.tsx +1 -1
  104. package/src/modules/review/components/MarkdownDiffViewer.tsx +1 -2
  105. package/src/modules/review/components/ReviewPanel.tsx +2 -3
  106. package/src/modules/review/state/ReviewProvider.tsx +2 -2
  107. package/src/modules/secrets-vault/index.ts +6 -0
  108. package/src/modules/settings/components/DeploymentPage.tsx +2 -2
  109. package/src/modules/settings/components/SettingsLayout.tsx +2 -2
  110. package/src/modules/settings/index.ts +8 -0
  111. package/src/modules/setup/components/FirstRunStorage.tsx +1 -1
  112. package/src/modules/setup/index.ts +6 -0
  113. package/src/modules/toolbar/commands/actions.tsx +3 -3
  114. package/src/modules/toolbar/commands/useCommandActions.ts +5 -9
  115. package/src/modules/toolbar/components/AgentInstructionsCard.tsx +2 -2
  116. package/src/modules/toolbar/components/AppSwitcher.tsx +1 -2
  117. package/src/modules/toolbar/components/CoworkSetupSteps.tsx +1 -1
  118. package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +1 -1
  119. package/src/modules/toolbar/components/ProfileMenu.tsx +3 -3
  120. package/src/modules/toolbar/components/SearchPalette.tsx +4 -8
  121. package/src/modules/toolbar/components/Toolbar.tsx +2 -5
  122. package/src/modules/toolbar/index.ts +6 -0
  123. package/src/modules/toolbar/search/sources.ts +4 -7
  124. package/src/modules/toolbar/services/agent-instructions.api.ts +1 -1
  125. package/src/modules/tools/ToolsExplorerPage.tsx +217 -18
  126. package/src/modules/tools/__tests__/ToolsExplorerPage.read-only.test.tsx +220 -0
  127. package/src/modules/tools/tool-hints.api.ts +44 -0
  128. package/src/modules/workflow/index.ts +7 -0
  129. package/src/modules/workflow/state/ChangeRequestStaleBinder.tsx +1 -0
  130. package/src/modules/workflow/state/EventBusFocusBinder.tsx +1 -1
  131. package/src/modules/workspace/components/FileExplorer.tsx +35 -8
  132. package/src/modules/workspace/components/FilePaneCard.tsx +37 -12
  133. package/src/modules/workspace/components/FileRoute.tsx +10 -3
  134. package/src/modules/workspace/components/FileViewer.tsx +169 -25
  135. package/src/modules/workspace/components/FullScreenView.tsx +93 -0
  136. package/src/modules/workspace/components/KbFileRail.tsx +1 -1
  137. package/src/modules/workspace/components/KbPageHeader.tsx +9 -0
  138. package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +137 -0
  139. package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +11 -0
  140. package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +487 -3
  141. package/src/modules/workspace/components/readingCarry.ts +59 -0
  142. package/src/modules/workspace/components/renderers/HtmlRenderer.tsx +36 -175
  143. package/src/modules/workspace/components/renderers/ToolRenderer.tsx +1 -1
  144. package/src/modules/workspace/components/renderers/__tests__/HtmlRenderer.tools.test.tsx +168 -42
  145. package/src/modules/workspace/components/renderers/__tests__/bridgeHarness.ts +20 -3
  146. package/src/modules/workspace/components/renderers/__tests__/htmlSandbox.test.ts +63 -4
  147. package/src/modules/workspace/components/renderers/__tests__/htmlToolBridge.test.ts +235 -1
  148. package/src/modules/workspace/components/renderers/__tests__/htmlViewsGuide.test.ts +14 -3
  149. package/src/modules/workspace/components/renderers/__tests__/pageToolsHarness.ts +79 -0
  150. package/src/modules/workspace/components/renderers/__tests__/useHtmlToolBridge.test.tsx +316 -0
  151. package/src/modules/workspace/components/renderers/htmlSandbox.ts +75 -13
  152. package/src/modules/workspace/components/renderers/htmlToolBridge.ts +196 -25
  153. package/src/modules/workspace/components/renderers/index.ts +10 -0
  154. package/src/modules/workspace/components/renderers/useHtmlToolBridge.tsx +253 -0
  155. package/src/modules/workspace/hooks/useFullScreenView.ts +52 -0
  156. package/src/modules/workspace/hooks/useImageRevision.ts +1 -1
  157. package/src/modules/workspace/hooks/useKnowledgeWriteTarget.ts +1 -1
  158. package/src/modules/workspace/hooks/useLastCommit.ts +1 -1
  159. package/src/modules/workspace/hooks/useWorkspaceState.ts +4 -4
  160. package/src/modules/workspace/index.ts +30 -1
  161. package/src/modules/workspace/routing/kb-routes.ts +1 -1
  162. package/src/modules/workspace/state/__tests__/applied-request-clears-pending.test.tsx +0 -1
  163. package/src/modules/workspace/state/open-change-requests.tsx +1 -1
  164. package/src/modules/workspace/utils/frameEscape.ts +15 -0
  165. package/src/modules/workspace/utils/treeConfirm.ts +1 -1
  166. package/src/shared/theme/measure.ts +7 -0
  167. package/src/modules/pr/services/pr-comments.api.ts +0 -45
@@ -1,5 +1,5 @@
1
1
  import { useEffect, useState } from 'react';
2
- import { useEventBus, canonicalizeWorkspaceId } from '../../workflow/state/event-bus.context';
2
+ import { useEventBus, canonicalizeWorkspaceId } from '../../workflow';
3
3
 
4
4
  /**
5
5
  * The extensions the raw file route serves as pictures, which is what a
@@ -1,6 +1,6 @@
1
1
  import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
2
2
  import { currentBranchModel, isProtectedBranch, type FileTreeEntry } from '@bevel-software/platform-shared';
3
- import { fetchFileAccessBatch } from '../../access/api';
3
+ import { fetchFileAccessBatch } from '../../access';
4
4
  import { useWorkspace } from '../state/workspace.context';
5
5
  import { useMergedWorkspaceTree } from './useMergedWorkspaceTree';
6
6
  import { findEntryByPath } from '../utils/fileTree';
@@ -1,5 +1,5 @@
1
1
  import { useEffect, useState } from 'react';
2
- import { useGit } from '../../git/state/git.context';
2
+ import { useGit } from '../../git';
3
3
  import { formatRelativeTime } from '../../../lib/utils';
4
4
 
5
5
  export interface LastCommit {
@@ -5,14 +5,14 @@ import {
5
5
  isProtectedBranch,
6
6
  type FileTreeEntry,
7
7
  } from '@bevel-software/platform-shared';
8
- import { useEventBus, canonicalizeWorkspaceId } from '../../workflow/state/event-bus.context';
9
- import { AuthContext } from '../../auth/state/auth.context';
10
- import { fetchFileAccess } from '../../access/api';
8
+ import { useEventBus, canonicalizeWorkspaceId } from '../../workflow';
9
+ import { AuthContext } from '../../auth';
10
+ import { fetchFileAccess } from '../../access';
11
11
  import {
12
12
  ensureKnowledgeSuggestionWorkspace,
13
13
  ensureKnowledgeChangeRequest,
14
14
  type KnowledgeSuggestionTarget,
15
- } from '../../change-requests/services/propose.api';
15
+ } from '../../change-requests';
16
16
  import { PR_STALE_EVENT, SUGGESTIONS_OPTIMISTIC_EVENT } from '../../../core/events';
17
17
  import type {
18
18
  HydrateResult,
@@ -21,20 +21,49 @@
21
21
  * of such a mount has to name; `kbFilePageUrl`, the file page's address
22
22
  * even for a file a skill's page would otherwise claim, and
23
23
  * `asksForFilePage`, whether a location's query makes that ask.
24
+ * - `PageToolsContext`: the page-tool bridge, for a mount that is the
25
+ * platform itself (the skill page) — see `htmlToolBridge.ts` for the
26
+ * hosts that provide it and the ones that must not.
24
27
  * - `OpenPageInPlatformContext`: how an HTML page mounted there is taken
25
28
  * to the file page when it needs tools and the viewer picks Open in the
26
29
  * platform (a skill page provides it; without it the renderer opens the
27
30
  * file's own address).
31
+ * - `useHtmlToolBridge`, `PageToolsContext` and their types: the page
32
+ * tool bridge a distribution's own HTML renderer calls to answer a page's
33
+ * `window.bevel.tools` exactly as the app's renderer does, and the
34
+ * file page's provider its tests mount it under.
28
35
  */
29
36
  export {
30
37
  CanDownloadContext,
31
38
  isViewOnlyFile,
39
+ OpenPageInPlatformContext,
40
+ PageToolsContext,
32
41
  pickFileRenderer,
33
42
  RendererSurfaceContext,
43
+ useHtmlToolBridge,
34
44
  useKbGraphLoader,
35
45
  useRendererSurface,
46
+ type HtmlToolBridgeOptions,
47
+ type HtmlToolBridgeResult,
48
+ type PageTools,
36
49
  type RendererSurface,
37
50
  } from './components/renderers';
38
51
  export { RendererWorkspaceContext } from './components/renderers/rendererWorkspace';
39
52
  export { asksForFilePage, kbFilePageUrl, kbFileUrl, resolveKbHref } from './routing/kb-routes';
40
- export { OpenPageInPlatformContext } from './components/renderers/htmlToolBridge';
53
+ // Reached by other modules; exported here so they stop importing the files.
54
+ export { useCreatePage } from './hooks/useCreatePage';
55
+ export { useMergedWorkspaceTree } from './hooks/useMergedWorkspaceTree';
56
+ export { useOpenChangeRequests } from './hooks/useOpenChangeRequests';
57
+ export { useWorkspaceImageResolver } from './hooks/useWorkspaceImageResolver';
58
+ export { KB_ROUTE_PREFIX, openExternalHref, safeDecode, stripJunkBeforeKbDir, useFileNav, useNodeIdNav } from './routing/kb-routes';
59
+ export { WorkspaceApiError, deleteFile, getOrCreateWorkspace, listFiles, readFile, writeFile } from './services/workspace.api';
60
+ export type { SkillToolWarning } from './services/workspace.api';
61
+ export { useEditablePage } from './state/editable-page';
62
+ export { WorkspaceContext, libraryUploadTarget, useWorkspace } from './state/workspace.context';
63
+ export type { WorkspaceContextValue } from './state/workspace.context';
64
+ export { computeDiff } from './utils/diff';
65
+ export type { DiffLine } from './utils/diff';
66
+ export { displayFileName, fileNameTooltip } from './utils/display-file-name';
67
+ export { checkoutRoot, findEntryByPath, knowledgeFiles, pathExistsInTree } from './utils/fileTree';
68
+ export { labelFor, parseFrontmatter } from './utils/frontmatter';
69
+ export type { FrontmatterData } from './utils/frontmatter';
@@ -1,6 +1,6 @@
1
1
  import { useCallback, useContext, useEffect, useState } from 'react';
2
2
  import { useLocation, useNavigate } from 'react-router-dom';
3
- import { GitContext } from '../../git/state/git.context';
3
+ import { GitContext } from '../../git';
4
4
  import { WorkspaceContext } from '../state/workspace.context';
5
5
  import { useRendererSurface } from '../components/renderers/rendererSurface';
6
6
  import { authFetch } from '../../../lib/api';
@@ -208,7 +208,6 @@ describe('an applied change request stops showing as pending — for every viewe
208
208
  source: 'suggestions/bo/knowledge',
209
209
  target: 'main',
210
210
  authorIdHash: null,
211
- title: 'Upload into Plugins/x',
212
211
  }),
213
212
  );
214
213
  await waitFor(() => expect(pending(result)).toBe(true));
@@ -3,7 +3,7 @@ import type { PullRequestSummary } from '@bevel-software/platform-shared';
3
3
  import {
4
4
  listMyChangeRequests,
5
5
  listOpenChangeRequests,
6
- } from '../../change-requests/services/change-requests.api';
6
+ } from '../../change-requests';
7
7
  import { useWorkspace } from './workspace.context';
8
8
  import {
9
9
  PR_STALE_FALLBACK_MS,
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Whether a window message is an Escape handed up by a page's frame inside
3
+ * `surface` (`bevel.key`, posted by the sandbox's key bridge in
4
+ * `htmlSandbox.ts`) — the one kind the full-screen view acts on. A message
5
+ * from any other window, or of any other shape, is not.
6
+ *
7
+ * Closes over nothing, so the real-browser suite can load it into a page from
8
+ * its source and hold it to a real sandboxed frame's `postMessage`.
9
+ */
10
+ export function isFrameEscape(e: MessageEvent, surface: Element | null): boolean {
11
+ const msg = e.data as { type?: unknown; key?: unknown } | null;
12
+ if (!msg || typeof msg !== 'object' || msg.type !== 'bevel.key' || msg.key !== 'Escape') return false;
13
+ if (!e.source || !surface) return false;
14
+ return Array.from(surface.querySelectorAll('iframe')).some((f) => f.contentWindow === e.source);
15
+ }
@@ -14,7 +14,7 @@ import {
14
14
  type AccessPrincipalRef,
15
15
  type PathPrincipals,
16
16
  type ProspectiveAccess,
17
- } from '../../access/api';
17
+ } from '../../access';
18
18
  import { KB_ROOT_DIRS } from './fileTree';
19
19
 
20
20
  // What the tree's delete and move confirmations say — see
@@ -29,6 +29,13 @@
29
29
  /** The default column: an 880px measure, centred. */
30
30
  export const DOCUMENT_COLUMN = 'mx-auto w-full max-w-[880px]';
31
31
 
32
+ /**
33
+ * What the default column leaves for its content: the 880px measure less the
34
+ * 40px side gutters `documentSideGutters(false)` puts inside it, centred. For
35
+ * a surface that holds the column's content without the column around it.
36
+ */
37
+ export const DOCUMENT_COLUMN_CONTENT = 'mx-auto w-full max-w-[800px]';
38
+
32
39
  /** The opt-out, for a page that puts a second column (a rail) beside the article. */
33
40
  export const DOCUMENT_COLUMN_WIDE = 'mx-auto w-full max-w-[980px]';
34
41
 
@@ -1,45 +0,0 @@
1
- import type { PostPrCommentInput, PrReviewComment } from '@bevel-software/platform-shared';
2
- import { authFetch } from '../../../lib/api';
3
- import { handleApiResponse } from '../../git/services/git.api';
4
-
5
- export async function listPrComments(prNumber: number): Promise<PrReviewComment[]> {
6
- return handleApiResponse(await authFetch(`/api/workflow/change-requests/${prNumber}/comments`));
7
- }
8
-
9
- export async function postPrComment(
10
- prNumber: number,
11
- input: PostPrCommentInput,
12
- ): Promise<PrReviewComment> {
13
- return handleApiResponse(
14
- await authFetch(`/api/workflow/change-requests/${prNumber}/comments`, {
15
- method: 'POST',
16
- headers: { 'Content-Type': 'application/json' },
17
- body: JSON.stringify(input),
18
- }),
19
- );
20
- }
21
-
22
- export async function editPrComment(
23
- prNumber: number,
24
- commentId: string,
25
- body: string,
26
- ): Promise<PrReviewComment> {
27
- return handleApiResponse(
28
- await authFetch(`/api/workflow/change-requests/${prNumber}/comments/${commentId}`, {
29
- method: 'PATCH',
30
- headers: { 'Content-Type': 'application/json' },
31
- body: JSON.stringify({ body }),
32
- }),
33
- );
34
- }
35
-
36
- export async function deletePrComment(
37
- prNumber: number,
38
- commentId: string,
39
- ): Promise<void> {
40
- await handleApiResponse(
41
- await authFetch(`/api/workflow/change-requests/${prNumber}/comments/${commentId}`, {
42
- method: 'DELETE',
43
- }),
44
- );
45
- }