@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
@@ -4,24 +4,29 @@ import {
4
4
  type FileDiffPayload,
5
5
  type PullRequestDetail,
6
6
  type PullRequestSummary,
7
+ type UpdateChangeRequestInput,
7
8
  } from '@bevel-software/platform-shared';
8
9
  import '../change-requests.css';
9
- import { Banner, Button, Surface } from '../../../shared/components';
10
+ import { Banner, Button, Surface, TextAreaField, TextField } from '../../../shared/components';
10
11
  import { useModalLayer } from '../../../shared/components/useModalLayer';
11
12
  import { cn } from '../../../lib/utils';
12
13
  import { PR_STALE_EVENT } from '../../../core/events';
13
- import { AuthContext } from '../../auth/state/auth.context';
14
- import { fetchPrDetail } from '../../pr/services/pr-detail.api';
15
- import { useEventBus } from '../../workflow/state/event-bus.context';
16
- import { approvePrFile, revertPrFile, unapprovePrFile } from '../../pr/services/pr-approvals.api';
17
- import { deleteChangeRequest } from '../../pr/services/pr-cancel.api';
18
- import { refreshChangeRequestFromTarget } from '../../pr/services/pr-merge.api';
19
- import { GitApiError } from '../../git/services/git.api';
20
- import { friendlyGitError, friendlyGitMessage } from '../../git/services/error-messages';
14
+ import { AuthContext } from '../../auth';
15
+ import { useEventBus } from '../../workflow';
16
+ import {
17
+ approvePrFile,
18
+ deleteChangeRequest,
19
+ fetchPrDetail,
20
+ refreshChangeRequestFromTarget,
21
+ revertPrFile,
22
+ unapprovePrFile,
23
+ updateChangeRequest,
24
+ } from '../../pr';
25
+ import { GitApiError, friendlyGitError, friendlyGitMessage } from '../../git';
21
26
  import { GitSyncFailedBanner } from '../../git/components/GitSyncFailedBanner';
22
27
  import { useApplyChangeRequest } from '../hooks/useApplyChangeRequest';
23
28
  import { readFileOnBranch } from '../services/change-requests.api';
24
- import { WorkspaceApiError } from '../../workspace/services/workspace.api';
29
+ import { WorkspaceApiError } from '../../workspace';
25
30
  import { describeReadFailure } from '../services/denied-file.api';
26
31
  import { deniedSentence, readErrorLead, type ReadFailure } from '../utils/readFailure';
27
32
  import { changeAuthorName } from '../utils/author';
@@ -233,6 +238,8 @@ export function ChangeRequestDialog({
233
238
  const offs = [
234
239
  bus.subscribe('change-request-apply-failed', reread),
235
240
  bus.subscribe('change-request-merged', reread),
241
+ // Somebody changed the title or description: show the new text.
242
+ bus.subscribe('change-request-edited', reread),
236
243
  ];
237
244
  return () => {
238
245
  cancelled = true;
@@ -873,6 +880,68 @@ export function ChangeRequestDialog({
873
880
  }
874
881
  }
875
882
 
883
+ /**
884
+ * Editing the title and description — the author's, or anyone's who may
885
+ * merge the request (`viewerCanEdit`, the server's verdict; the PATCH route
886
+ * re-checks it). The description field holds the body whole: it is nothing
887
+ * but the description, and a save replaces exactly what the field showed.
888
+ */
889
+ const [editing, setEditing] = useState(false);
890
+ const [draftTitle, setDraftTitle] = useState('');
891
+ const [draftDescription, setDraftDescription] = useState('');
892
+ const [saving, setSaving] = useState(false);
893
+ const [editError, setEditError] = useState<string | null>(null);
894
+ const shownTitle = detail?.title ?? cr.title;
895
+ // The text the form opened with. A save sends only the fields the reader
896
+ // changed FROM it — not from `detail`, which a remote edit may refresh
897
+ // while the form is open — so the untouched field is never written back
898
+ // with a stale draft.
899
+ const editBaseline = useRef({ title: '', description: '' });
900
+ function startEditing() {
901
+ const baseline = { title: shownTitle, description: detail?.body.trim() ?? '' };
902
+ editBaseline.current = baseline;
903
+ setDraftTitle(baseline.title);
904
+ setDraftDescription(baseline.description);
905
+ setEditError(null);
906
+ setEditing(true);
907
+ }
908
+ async function saveEdit() {
909
+ if (saving || !detail) return;
910
+ const title = draftTitle.trim();
911
+ const description = draftDescription.trim();
912
+ const titleChanged = title !== editBaseline.current.title;
913
+ const descriptionChanged = description !== editBaseline.current.description;
914
+ let changes: UpdateChangeRequestInput;
915
+ if (titleChanged) changes = descriptionChanged ? { title, description } : { title };
916
+ else if (descriptionChanged) changes = { description };
917
+ else {
918
+ setEditing(false);
919
+ return;
920
+ }
921
+ setSaving(true);
922
+ setEditError(null);
923
+ try {
924
+ await updateChangeRequest(cr.number, changes);
925
+ } catch (err) {
926
+ setEditError(err instanceof Error ? err.message : "Couldn't save the change request.");
927
+ setSaving(false);
928
+ return;
929
+ }
930
+ // Saved. Every list on the page re-reads — this tab does not wait on its
931
+ // own broadcast — and the dialog shows the new text from a fresh read; a
932
+ // failed read leaves the saved edit saved and shows the last text known.
933
+ window.dispatchEvent(new Event(PR_STALE_EVENT));
934
+ setEditing(false);
935
+ setSaving(false);
936
+ const seq = ++detailSeq.current;
937
+ try {
938
+ const fresh = await fetchPrDetail(cr.number, { fresh: true });
939
+ if (seq === detailSeq.current) setDetail(fresh);
940
+ } catch {
941
+ // The server's `change-request-edited` broadcast re-reads it again.
942
+ }
943
+ }
944
+
876
945
  /**
877
946
  * Apply = record the approvals the gate requires, then merge, then wait for
878
947
  * the merge to land. The POST only acks — see `useApplyChangeRequest` for
@@ -1013,7 +1082,7 @@ export function ChangeRequestDialog({
1013
1082
 
1014
1083
  const author = changeAuthorName(cr);
1015
1084
  const firstName = author.split(' ')[0];
1016
- const why = authorsReason(detail?.body);
1085
+ const why = descriptionOf(detail?.body);
1017
1086
  const [whyExpanded, setWhyExpanded] = useState(false);
1018
1087
  /**
1019
1088
  * Whether the one-line view is actually hiding anything — a short reason
@@ -1029,7 +1098,7 @@ export function ChangeRequestDialog({
1029
1098
  className="fixed inset-0 z-[60] flex flex-col"
1030
1099
  role="dialog"
1031
1100
  aria-modal="true"
1032
- aria-label={`Change request: ${cr.title}`}
1101
+ aria-label={`Change request: ${shownTitle}`}
1033
1102
  >
1034
1103
  <div className="absolute inset-0 bg-scrim" onClick={onClose} />
1035
1104
 
@@ -1042,13 +1111,29 @@ export function ChangeRequestDialog({
1042
1111
  <div className="flex items-start gap-4 px-8 pt-7">
1043
1112
  <div className="min-w-0 flex-1">
1044
1113
  <p className="text-label font-semibold uppercase text-ink-faint">Change request</p>
1045
- <h1 className="mt-1 text-title font-medium text-ink">{cr.title}</h1>
1114
+ {editing ? (
1115
+ <TextField
1116
+ className="mt-1 text-title font-medium"
1117
+ aria-label="Title"
1118
+ value={draftTitle}
1119
+ maxLength={256}
1120
+ disabled={saving}
1121
+ onChange={(e) => setDraftTitle(e.target.value)}
1122
+ />
1123
+ ) : (
1124
+ <h1 className="mt-1 text-title font-medium text-ink">{shownTitle}</h1>
1125
+ )}
1046
1126
  <p className="mt-2 flex flex-wrap items-center gap-2 text-detail text-ink-muted">
1047
1127
  <span>{author}</span>
1048
1128
  <span aria-hidden="true" className="text-ink-faint">·</span>
1049
1129
  <span className="font-mono">{cr.branch}</span>
1050
1130
  </p>
1051
1131
  </div>
1132
+ {detail?.viewerCanEdit && !editing && (
1133
+ <Button variant="quiet" size="sm" onClick={startEditing}>
1134
+ Edit
1135
+ </Button>
1136
+ )}
1052
1137
  <Button variant="quiet" size="sm" onClick={onClose} aria-label="Close change request">
1053
1138
  ✕
1054
1139
  </Button>
@@ -1064,7 +1149,39 @@ export function ChangeRequestDialog({
1064
1149
  more opens the whole thing (self-scrolling past half the surface,
1065
1150
  so even an essay never pushes the files off screen); Hide folds it
1066
1151
  back to the line. */}
1067
- {why && (
1152
+ {editing && (
1153
+ <div className="mx-8 mt-5 shrink-0">
1154
+ <TextAreaField
1155
+ className="max-h-[40vh] min-h-32"
1156
+ aria-label="Description"
1157
+ placeholder="Why this change, in your words"
1158
+ value={draftDescription}
1159
+ maxLength={64_000}
1160
+ disabled={saving}
1161
+ onChange={(e) => setDraftDescription(e.target.value)}
1162
+ />
1163
+ {editError && (
1164
+ <Banner tone="danger" role="alert" className="mt-3">
1165
+ {editError}
1166
+ </Banner>
1167
+ )}
1168
+ <div className="mt-3 flex items-center gap-3">
1169
+ <Button
1170
+ variant="primary"
1171
+ size="sm"
1172
+ disabled={saving || draftTitle.trim().length === 0}
1173
+ onClick={() => void saveEdit()}
1174
+ >
1175
+ {saving ? 'Saving…' : 'Save'}
1176
+ </Button>
1177
+ <Button variant="quiet" size="sm" disabled={saving} onClick={() => setEditing(false)}>
1178
+ Cancel
1179
+ </Button>
1180
+ </div>
1181
+ </div>
1182
+ )}
1183
+
1184
+ {!editing && why && (
1068
1185
  <blockquote
1069
1186
  className={cn(
1070
1187
  'mx-8 mt-5 shrink-0 border-l-2 border-line-strong pl-4 text-body text-ink',
@@ -1491,23 +1608,14 @@ export function ChangeRequestDialog({
1491
1608
  }
1492
1609
 
1493
1610
  /**
1494
- * The author's reason, or nothing.
1495
- *
1496
- * A change request's body is part human and part machine: the backend appends
1497
- * an `## Affected owners` block (and hidden identity markers) to whatever the
1498
- * author wrote, and our propose flow writes no description at all — so the body
1499
- * is USUALLY pure machinery. Rendering it as a pull-quote under the title
1500
- * presents a routing table as the reason someone wants this change. Everything
1501
- * from the first generated heading on is dropped; what survives is quoted only
1502
- * if a human actually wrote it.
1611
+ * The request's description, or nothing. The body IS the description — the
1612
+ * server writes nothing of its own into it — so the quote under the title is
1613
+ * the whole of what the author wrote, and the same text the Edit control
1614
+ * offers. Nothing when nobody wrote one (the propose flow may leave it empty).
1503
1615
  */
1504
- function authorsReason(body: string | undefined): string | null {
1505
- if (!body) return null;
1506
- const human = body
1507
- .split(/^##\s+/m)[0]
1508
- .replace(/<!--[\s\S]*?-->/g, '')
1509
- .trim();
1510
- return human.length > 0 ? human : null;
1616
+ function descriptionOf(body: string | undefined): string | null {
1617
+ const text = body?.trim() ?? '';
1618
+ return text.length > 0 ? text : null;
1511
1619
  }
1512
1620
 
1513
1621
  /**
@@ -1,9 +1,8 @@
1
1
  import { useEffect, useState } from 'react';
2
2
  import { Link, useNavigate, useParams } from 'react-router-dom';
3
3
  import type { PullRequestSummary } from '@bevel-software/platform-shared';
4
- import { getPullRequest } from '../../git/services/pr.api';
5
- import { GitApiError } from '../../git/services/git.api';
6
- import { KB_ROUTE_PREFIX } from '../../workspace/routing/kb-routes';
4
+ import { getPullRequest, GitApiError } from '../../git';
5
+ import { KB_ROUTE_PREFIX } from '../../workspace';
7
6
  import { ChangeRequestDialog } from './ChangeRequestDialog';
8
7
 
9
8
  /**
@@ -13,7 +13,7 @@ import {
13
13
  import type { FileApprovalState, PrFileStatus } from '@bevel-software/platform-shared';
14
14
  import { cn } from '../../../lib/utils';
15
15
  import { hasOwnApproval } from '../utils/approval';
16
- import { displayFileName } from '../../workspace/utils/display-file-name';
16
+ import { displayFileName } from '../../workspace';
17
17
 
18
18
  /**
19
19
  * The change request's files as a TREE — the Knowledge sidebar's visual
@@ -1,8 +1,8 @@
1
1
  import { useCallback, useState } from 'react';
2
2
  import type { PullRequestSummary } from '@bevel-software/platform-shared';
3
3
  import { Banner, Button } from '../../../shared/components';
4
- import { cancelPullRequest } from '../../pr/services/pr-cancel.api';
5
- import { useOpenChangeRequests } from '../../workspace/hooks/useOpenChangeRequests';
4
+ import { cancelPullRequest } from '../../pr';
5
+ import { useOpenChangeRequests, displayFileName, fileNameTooltip } from '../../workspace';
6
6
  import { PR_STALE_EVENT } from '../../../core/events';
7
7
  import { refusalLine, useApplyChangeRequest } from '../hooks/useApplyChangeRequest';
8
8
  import { useCrFileDiffs } from '../hooks/useCrFileDiffs';
@@ -11,7 +11,6 @@ import { conflictResolutionPrompt } from '../utils/conflict';
11
11
  import { isBinaryFile } from '../../workspace/components/renderers';
12
12
  import { ChangeBox } from './ChangeBox';
13
13
  import { ChangeRequestDialog } from './ChangeRequestDialog';
14
- import { displayFileName, fileNameTooltip } from '../../workspace/utils/display-file-name';
15
14
 
16
15
  export interface FileChangeBoxesProps {
17
16
  /** Repo-root-relative path of the open file (kbDirName stripped). */
@@ -1,10 +1,8 @@
1
1
  import { useCallback, useEffect, useRef, useState } from 'react';
2
2
  import type { PullRequestSummary } from '@bevel-software/platform-shared';
3
- import { useEventBus } from '../../workflow/state/event-bus.context';
4
- import { fetchPrDetail } from '../../pr/services/pr-detail.api';
5
- import { approvePrFile } from '../../pr/services/pr-approvals.api';
6
- import { mergePullRequest } from '../../pr/services/pr-merge.api';
7
- import { friendlyGitError, friendlyGitMessage } from '../../git/services/error-messages';
3
+ import { useEventBus } from '../../workflow';
4
+ import { fetchPrDetail, approvePrFile, mergePullRequest } from '../../pr';
5
+ import { friendlyGitError, friendlyGitMessage } from '../../git';
8
6
 
9
7
  /**
10
8
  * Safety net for the async apply: if neither a `change-request-merged` nor a
@@ -3,7 +3,7 @@ import type { PullRequestSummary } from '@bevel-software/platform-shared';
3
3
  import { readFileAtForkPoint, readFileOnBranch, type ForkPointFile } from '../services/change-requests.api';
4
4
  import { subscribePrStale } from '../../../core/events';
5
5
  import { isBinaryFile } from '../../workspace/components/renderers';
6
- import { WorkspaceApiError } from '../../workspace/services/workspace.api';
6
+ import { WorkspaceApiError } from '../../workspace';
7
7
  import { diffLines, hasChanges, type DiffLine } from '../utils/diff';
8
8
 
9
9
  /**
@@ -0,0 +1,14 @@
1
+ /**
2
+ * What the change-requests 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 { refusalLine, useApplyChangeRequest } from './hooks/useApplyChangeRequest';
7
+ export { useCrFileDiffs } from './hooks/useCrFileDiffs';
8
+ export { useDefaultBranchFile, useFileOnBranch } from './hooks/useFileOnBranch';
9
+ export { listChangeRequestsUnderFolder, listMyChangeRequests, listOpenChangeRequests, readFileOnBranch, removeFolderFromChangeRequests } from './services/change-requests.api';
10
+ export { branchSegment, ensureKnowledgeChangeRequest, ensureKnowledgeSuggestionWorkspace, knowledgeSuggestionBranchFor, proposeKnowledgeChange } from './services/propose.api';
11
+ export type { KnowledgeSuggestionTarget } from './services/propose.api';
12
+ export { changeAuthorName, formatWhen, othersPendingBesides } from './utils/author';
13
+ export { conflictResolutionPrompt } from './utils/conflict';
14
+ export type { DiffLine } from './utils/diff';
@@ -4,8 +4,8 @@ import type {
4
4
  PullRequestSummary,
5
5
  } from '@bevel-software/platform-shared';
6
6
  import { authFetch } from '../../../lib/api';
7
- import { handleApiResponse } from '../../git/services/git.api';
8
- import { getOrCreateWorkspace, readFile } from '../../workspace/services/workspace.api';
7
+ import { handleApiResponse } from '../../git';
8
+ import { getOrCreateWorkspace, readFile } from '../../workspace';
9
9
  import { BranchUnavailableError } from '../utils/readFailure';
10
10
 
11
11
  /**
@@ -1,5 +1,5 @@
1
- import { fetchFileAccess } from '../../access/api';
2
- import { getOrCreateWorkspace } from '../../workspace/services/workspace.api';
1
+ import { fetchFileAccess } from '../../access';
2
+ import { getOrCreateWorkspace } from '../../workspace';
3
3
  import { failureReason, isDenial, nearestRuleFolder, type ReadFailure } from '../utils/readFailure';
4
4
 
5
5
  /**
@@ -4,10 +4,9 @@ import {
4
4
  suggestionsBranchPrefixFor,
5
5
  type PullRequestSummary,
6
6
  } from '@bevel-software/platform-shared';
7
- import { createBranch, deleteBranch, GitApiError } from '../../git/services/git.api';
8
- import { getOrCreateWorkspace, writeFile } from '../../workspace/services/workspace.api';
9
- import { openChangeRequest } from '../../pr/services/pr-open.api';
10
- import { fetchPrDetail } from '../../pr/services/pr-detail.api';
7
+ import { createBranch, deleteBranch, GitApiError } from '../../git';
8
+ import { getOrCreateWorkspace, writeFile } from '../../workspace';
9
+ import { openChangeRequest, fetchPrDetail } from '../../pr';
11
10
  import { listMyChangeRequests } from './change-requests.api';
12
11
 
13
12
  /** The default branch's workspace id (id = encodeURIComponent(branch)), read lazily. */
@@ -8,7 +8,7 @@
8
8
  * folding (`collapseUnchanged`) that only change boxes need.
9
9
  */
10
10
 
11
- import { computeDiff } from '../../workspace/utils/diff';
11
+ import { computeDiff } from '../../workspace';
12
12
 
13
13
  export interface DiffLine {
14
14
  kind: 'same' | 'removed' | 'added';
@@ -1,4 +1,4 @@
1
- import type { AccessResponse, GrantSources } from '../../access/api';
1
+ import type { AccessResponse, GrantSources } from '../../access';
2
2
 
3
3
  /**
4
4
  * WHY a copy of a file could not be read.
@@ -4,10 +4,10 @@ import userEvent from '@testing-library/user-event';
4
4
  import { MemoryRouter } from 'react-router-dom';
5
5
  import { AppRegistryContext, type AppRegistry } from '../../../core/registry';
6
6
  import type { EmbedFileView } from '../services/embed.api';
7
- import { useEffect, useState } from 'react';
7
+ import { useContext, useEffect, useState } from 'react';
8
8
  import { EMBED_EXPIRED, EMBED_HEIGHT_MESSAGE } from '../embed-host';
9
9
  import { configureEmbed, resetEmbedConfig } from '../embed-config';
10
- import { useKbGraphLoader, useRendererSurface } from '../../workspace';
10
+ import { PageToolsContext, useKbGraphLoader, useRendererSurface } from '../../workspace';
11
11
 
12
12
  /**
13
13
  * The HTTP surface, stubbed. The error CLASS is hoisted with the rest: the
@@ -550,6 +550,23 @@ describe('the renderer', () => {
550
550
  expect((await screen.findByTestId('sizing-reader')).textContent).toBe('false');
551
551
  });
552
552
 
553
+ /**
554
+ * The embed is outside the platform: a page there gets no tools — the
555
+ * renderer shows it the "only available in the platform" card instead —
556
+ * even for a skill's page, which the skill page answers.
557
+ */
558
+ it('mounts the renderer without the page-tool bridge, a skill page included', async () => {
559
+ api.loadEmbed.mockResolvedValue(
560
+ view({ repoRelative: 'Skills/qa-bridge/view.html', workspacePath: `${KB}/Skills/qa-bridge/view.html`, content: '<p>qa</p>' }),
561
+ );
562
+ const BridgeReader = () => {
563
+ const tools = useContext(PageToolsContext);
564
+ return <div data-testid="bridge-reader">{tools ? tools.pagePath : 'no tools'}</div>;
565
+ };
566
+ mount({ ...EMPTY_REGISTRY, renderers: [{ extensions: ['.html'], Component: BridgeReader }] } as unknown as AppRegistry);
567
+ expect((await screen.findByTestId('bridge-reader')).textContent).toBe('no tools');
568
+ });
569
+
553
570
  it("opens a page on its FILE PAGE in a new tab by an address that asks for it — a skill's page would claim the bare one", async () => {
554
571
  api.loadEmbed.mockResolvedValue(
555
572
  view({ repoRelative: 'Skills/qa-bridge/view.html', workspacePath: `${KB}/Skills/qa-bridge/view.html`, content: '<p>qa</p>' }),
@@ -1,7 +1,6 @@
1
1
  import { useCallback, useState, type ReactNode } from 'react';
2
2
  import { Button } from '../../../shared/components';
3
- import { AuthContext } from '../../auth/state/auth.context';
4
- import { useAuthState } from '../../auth/hooks/useAuthState';
3
+ import { AuthContext, useAuthState } from '../../auth';
5
4
  import { LoginScreen } from '../../auth/components/LoginScreen';
6
5
  import { getToken } from '../../../lib/api';
7
6
  import { linkEmbedAccount } from '../services/embed.api';
@@ -13,11 +13,10 @@ import { useGit } from '../state/git.context';
13
13
  import { isBranchDeleteConfirmSkipped, skipBranchDeleteConfirm } from '../state/branch-delete-confirm';
14
14
  import { useConfirm } from '../../../shared/components';
15
15
  import { parseGitError, type GitErrorInfo } from '../services/error-messages';
16
- import { useAuth } from '../../auth/state/auth.context';
17
- import { useWorkspace } from '../../workspace/state/workspace.context';
18
- import { kbFileUrl, KB_ROUTE_PREFIX } from '../../workspace/routing/kb-routes';
16
+ import { useAuth } from '../../auth';
17
+ import { useWorkspace, kbFileUrl, KB_ROUTE_PREFIX } from '../../workspace';
19
18
  import { useCrCreationPort } from '../../../core/registry';
20
- import { fetchFileAccess } from '../../access/api';
19
+ import { fetchFileAccess } from '../../access';
21
20
 
22
21
  /**
23
22
  * Convert a free-text "what are you changing?" answer into a branch name slug.
@@ -6,8 +6,8 @@ import { formatRelativeTime } from '../../../lib/utils';
6
6
  import { MarkdownDiffViewer } from '../../review/components/MarkdownDiffViewer';
7
7
  import { HistoryVersionPreview } from './HistoryVersionPreview';
8
8
  import { friendlyGitError } from '../services/error-messages';
9
- import { useEventBus, canonicalizeWorkspaceId } from '../../workflow/state/event-bus.context';
10
- import { useWorkspace } from '../../workspace/state/workspace.context';
9
+ import { useEventBus, canonicalizeWorkspaceId } from '../../workflow';
10
+ import { useWorkspace } from '../../workspace';
11
11
 
12
12
  function shortSha(sha: string): string {
13
13
  return sha.slice(0, 7);
@@ -1,9 +1,7 @@
1
1
  import { useCallback, useContext, useState } from 'react';
2
2
  import { AlertTriangle, CloudOff } from 'lucide-react';
3
- import { useEventBusSubscription } from '../../workflow/hooks/useEventBusSubscription';
4
- import { canonicalizeWorkspaceId } from '../../workflow/state/event-bus.context';
5
- import { useWorkspace, WorkspaceContext } from '../../workspace/state/workspace.context';
6
- import { useFileNav } from '../../workspace/routing/kb-routes';
3
+ import { useEventBusSubscription, canonicalizeWorkspaceId } from '../../workflow';
4
+ import { useWorkspace, WorkspaceContext, useFileNav } from '../../workspace';
7
5
 
8
6
  /**
9
7
  * The files a remote sync could not reconcile, each a link that opens it.
@@ -6,24 +6,13 @@ import { formatRelativeTime } from '../../../lib/utils';
6
6
  import { useGit } from '../state/git.context';
7
7
  import { friendlyGitError } from '../services/error-messages';
8
8
  import { UnifiedDiffView } from './UnifiedDiffView';
9
- import { useFileAccess } from '../../access/hooks/useFileAccess';
9
+ import { useFileAccess } from '../../access';
10
10
  import { FilePaneCard } from '../../workspace/components/FilePaneCard';
11
- import {
12
- CanDownloadContext,
13
- DownloadFileButton,
14
- } from '../../workspace/components/renderers/DownloadFileButton';
11
+ import { CanDownloadContext, RendererWorkspaceContext, useWorkspace, displayFileName, fileNameTooltip } from '../../workspace';
12
+ import { DownloadFileButton } from '../../workspace/components/renderers/DownloadFileButton';
15
13
  import { RetryReadButton } from '../../workspace/components/renderers/RetryReadButton';
16
14
  import { READ_PANE } from '../../workspace/components/renderers/readPane';
17
- import {
18
- RendererWorkspaceContext,
19
- getFileRenderer,
20
- getRendererLayout,
21
- hasFileViewer,
22
- isBinaryFile,
23
- type RendererFileRef,
24
- } from '../../workspace/components/renderers';
25
- import { useWorkspace } from '../../workspace/state/workspace.context';
26
- import { displayFileName, fileNameTooltip } from '../../workspace/utils/display-file-name';
15
+ import { getFileRenderer, getRendererLayout, hasFileViewer, isBinaryFile, type RendererFileRef } from '../../workspace/components/renderers';
27
16
 
28
17
  /**
29
18
  * One past save of a file, shown the way the FILE PAGE shows that file.
@@ -5,7 +5,7 @@ import { useGit } from '../state/git.context';
5
5
  import { useAutoUpdate } from '../state/auto-update.context';
6
6
  import { useCrCreationPort } from '../../../core/registry';
7
7
  import { PR_STALE_EVENT } from '../../../core/events';
8
- import { useWorkspace } from '../../workspace/state/workspace.context';
8
+ import { useWorkspace } from '../../workspace';
9
9
  import { sanitizeErrorText } from '../services/error-messages';
10
10
  import { describePullFailure, pullFailurePhrase } from '../services/pull-failure';
11
11
  import { Button } from '../../../shared/components';
@@ -4,7 +4,7 @@ import {
4
4
  IDLE_AUTO_UPDATE,
5
5
  type AutoUpdateState,
6
6
  } from '../state/auto-update.context';
7
- import type { WorkspaceContextValue } from '../../workspace/state/workspace.context';
7
+ import type { WorkspaceContextValue } from '../../workspace';
8
8
  import { sanitizeErrorText } from '../services/error-messages';
9
9
  import { pullFailureDetail } from '../services/pull-failure';
10
10
  import { PR_STALE_EVENT } from '../../../core/events';
@@ -16,3 +16,14 @@ export const GIT_MENU_ITEMS: readonly AdminMenuItem[] = [BRANCH_DELETE_CONFIRM_M
16
16
 
17
17
  /** The branch state a page reads (`useGit`), and the context a test provides it through. */
18
18
  export { GitContext, useGit, type GitContextValue } from './state/git.context';
19
+
20
+ /**
21
+ * The HTTP helpers git's own services are built on, for the modules whose
22
+ * services talk to the same API: the response reader that turns a refusal
23
+ * into a thrown `GitApiError` carrying the server's words and status.
24
+ */
25
+ export { GitApiError, handleApiResponse } from './services/git.api';
26
+ // Reached by other modules; exported here so they stop importing the files.
27
+ export { friendlyGitError, friendlyGitMessage } from './services/error-messages';
28
+ export { createBranch, deleteBranch } from './services/git.api';
29
+ export { getPullRequest } from './services/pr.api';
@@ -2,7 +2,7 @@ import { useCallback, useEffect, useMemo, type ReactNode } from 'react';
2
2
  import { useLocation, useMatch, useNavigate } from 'react-router-dom';
3
3
  import { X } from 'lucide-react';
4
4
  import { LayoutContext, type LayoutController } from '../state/layout.context';
5
- import { KB_ROUTE_PREFIX, kbFileUrl } from '../../workspace/routing/kb-routes';
5
+ import { kbFileUrl, KB_ROUTE_PREFIX } from '../../workspace';
6
6
  import { SlideOverlay } from './SlideOverlay';
7
7
  import { SidebarFrame } from './SidebarFrame';
8
8
  import {
@@ -0,0 +1,9 @@
1
+ /**
2
+ * What the layout 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 { SETUP_COLUMN_HIDDEN_QUERY, TOOLBAR_STACK_QUERY } from './breakpoints';
7
+ export { useMediaQuery } from './hooks/useMediaQuery';
8
+ export { LayoutContext, useLayout } from './state/layout.context';
9
+ export { toggleSidebar, useSidebar } from './state/sidebar';
@@ -1,4 +1,5 @@
1
1
  import { describe, it, expect, vi, beforeEach } from 'vitest';
2
+ import { useContext } from 'react';
2
3
  import { render, screen, fireEvent, waitFor, act, within } from '@testing-library/react';
3
4
  import { MemoryRouter, Route, Routes, useLocation } from 'react-router-dom';
4
5
  import {
@@ -112,6 +113,25 @@ vi.mock('../../workspace/components/renderers/KbMarkdownView', () => ({
112
113
  ),
113
114
  }));
114
115
 
116
+ // The HTML renderer's frame and cards are its own suite's business; this
117
+ // stand-in shows what the page hands it — the page-tool bridge, and the path
118
+ // a page's calls would be recorded under.
119
+ // The context is read through the module's entry point at RENDER time: the
120
+ // entry point itself imports this renderer, so importing it inside the
121
+ // factory would wait on its own result.
122
+ vi.mock('../../workspace/components/renderers/HtmlRenderer', () => {
123
+ return {
124
+ HtmlRenderer: ({ filePath }: { filePath: string }) => {
125
+ const tools = useContext(PageToolsContext);
126
+ return (
127
+ <div data-testid="html-view" data-file={filePath}>
128
+ {tools ? tools.pagePath : 'no tools'}
129
+ </div>
130
+ );
131
+ },
132
+ };
133
+ });
134
+
115
135
  // The file bar's Edit-or-Propose decision asks the per-file access resolver.
116
136
  // Default here is the READER's answer (`canWrite: false`) so the proposing
117
137
  // suites below exercise the propose path; the Edit test flips it.
@@ -144,6 +164,7 @@ vi.mock('../state/library-data', () => ({
144
164
  }));
145
165
 
146
166
  import { SkillPage } from '../components/skill-page/SkillPage';
167
+ import { PageToolsContext } from '../../workspace';
147
168
  import { LibraryToastProvider } from '../state/toast';
148
169
  import { expectTitleRowSpansTheDocumentColumn } from './title-row-actions';
149
170
  import { PAGE_HEADER_TESTID } from '../../../shared/theme/header';
@@ -466,6 +487,24 @@ describe('SkillPage', () => {
466
487
  expect(screen.getByTestId('navigated-raw-file')).toHaveTextContent('true');
467
488
  });
468
489
 
490
+ /**
491
+ * The skill page is the platform: a page of the skill gets its tools here,
492
+ * as on its file page, and under the path the file page would record —
493
+ * the knowledge-base path, never the skill-relative tab name.
494
+ */
495
+ it.each([
496
+ ['the Skills/ root', 'Skills/newsletter'],
497
+ ['a plugin', 'Plugins/Engineering/skills/newsletter'],
498
+ ])('answers an HTML page’s tools under its knowledge-base path, for a skill under %s', async (_, path) => {
499
+ apiMock.getSkill.mockResolvedValue({ ...skillDetail, path, files: [`${path}/view.html`] });
500
+ apiMock.getSkillFile.mockResolvedValue('<script>bevel.tools.requireTools()</script>');
501
+ renderPage(false);
502
+ fireEvent.click(await screen.findByRole('tab', { name: /view\.html/ }));
503
+ const page = await screen.findByTestId('html-view');
504
+ expect(page).toHaveAttribute('data-file', 'view.html');
505
+ expect(page).toHaveTextContent(new RegExp(`^${path}/view\\.html$`));
506
+ });
507
+
469
508
  it('loads the skill and shows its name, needed integrations and files', async () => {
470
509
  renderPage(false);
471
510