@bevel-software/platform-core-frontend 0.21.0 → 0.22.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 (34) hide show
  1. package/package.json +2 -2
  2. package/src/core/registry.ts +57 -0
  3. package/src/modules/access/__tests__/ManageAccessDialog.request.test.tsx +376 -0
  4. package/src/modules/access/components/AccessRequestControl.tsx +155 -0
  5. package/src/modules/{library → access}/components/AccessRequestsBanner.tsx +62 -24
  6. package/src/modules/access/components/ManageAccessDialog.tsx +81 -4
  7. package/src/modules/access/hooks/useAccessRequests.ts +183 -0
  8. package/src/modules/access/requests.api.ts +121 -0
  9. package/src/modules/auth/components/LoginScreen.tsx +5 -0
  10. package/src/modules/change-requests/__tests__/ChangeRequestDialog.brings-itself-up-to-date.test.tsx +171 -38
  11. package/src/modules/change-requests/__tests__/ChangeRequestDialog.fork-point.test.tsx +34 -19
  12. package/src/modules/change-requests/__tests__/ChangeRequestDialog.test.tsx +173 -6
  13. package/src/modules/change-requests/components/ChangeRequestDialog.tsx +155 -98
  14. package/src/modules/library/__tests__/SkillPage.test.tsx +15 -0
  15. package/src/modules/library/__tests__/ToolPage.test.tsx +15 -1
  16. package/src/modules/library/__tests__/title-row-actions.ts +53 -1
  17. package/src/modules/library/components/PluginJoinRequests.tsx +2 -2
  18. package/src/modules/library/components/skill-page/SkillPage.tsx +2 -2
  19. package/src/modules/library/components/tool-page/ToolPage.tsx +11 -1
  20. package/src/modules/library/hooks/useJoinRequests.ts +26 -101
  21. package/src/modules/pr/services/pr-merge.api.ts +10 -2
  22. package/src/modules/settings/components/DeploymentPage.tsx +22 -0
  23. package/src/modules/settings/components/__tests__/DeploymentPage.test.tsx +72 -4
  24. package/src/modules/setup/__tests__/setup.first-run.test.tsx +276 -0
  25. package/src/modules/setup/__tests__/setup.github.test.tsx +416 -0
  26. package/src/modules/setup/__tests__/setup.kept-draft.test.tsx +275 -0
  27. package/src/modules/setup/__tests__/setup.repository.test.tsx +373 -0
  28. package/src/modules/setup/__tests__/setup.test.tsx +8 -14
  29. package/src/modules/setup/components/GitHubRepositoryPanel.tsx +369 -0
  30. package/src/modules/setup/components/SetupGate.tsx +1 -0
  31. package/src/modules/setup/components/SetupScreen.tsx +464 -38
  32. package/src/modules/setup/services/setup.api.ts +93 -0
  33. package/src/modules/setup/utils/kept-draft.ts +86 -0
  34. package/src/shared/components/SlotBoundary.tsx +51 -0
@@ -142,23 +142,36 @@ export function ChangeRequestDialog({
142
142
  const [baseRevision, setBaseRevision] = useState(0);
143
143
 
144
144
  /**
145
- * The request has fallen behind AND this reader is one of the people who
146
- * may bring it up to date (its author, an admin, or anyone who may apply
147
- * it). The server re-checks the same predicate; this only decides whether
148
- * the dialog reaches for the update at all.
145
+ * This request needs bringing up to date AND this reader is one of the
146
+ * people who may do it (its author, an admin, or anyone who may apply it).
147
+ * The server re-checks the same predicate; this only decides whether the
148
+ * dialog reaches for the update at all.
149
+ *
150
+ * `needsUpdate`, NOT `behind`. `behind` is true whenever the target holds
151
+ * any commit this request does not — which, on a knowledge base where every
152
+ * shared save commits to the default branch, is true again minutes after
153
+ * every update. Reaching for the merge on that answer made opening a
154
+ * request pay for one on almost every open, for a change to a file the
155
+ * request does not contain. `needsUpdate` adds the half that matters: the
156
+ * target moved in a file THIS request also changes.
149
157
  */
150
- const behindAndUpdatable =
151
- detail !== null && detail.state === 'open' && detail.behind && detail.viewerCanUpdate;
158
+ const needsUpdateByThisReader =
159
+ detail !== null && detail.state === 'open' && detail.needsUpdate && detail.viewerCanUpdate;
152
160
  /**
153
- * Mid-update: the dialog shows one status line and NO file content.
161
+ * Mid-update: the files are on screen, with one status line above them, and
162
+ * the two verbs that would act on them are held.
163
+ *
164
+ * The files are NOT hidden. They are the proposal, read at the fork point,
165
+ * and a target that moved in one of them does not make the other nineteen
166
+ * untrue — where hiding them made every reader wait out a merge before
167
+ * seeing anything. What the update can change is the verdict, so Approve
168
+ * and Apply wait for it and the reading does not.
154
169
  *
155
170
  * Derived rather than stored, so it is already true on the very render the
156
- * detail arrives on — a frame of pre-update files, immediately replaced,
157
- * would be the dialog showing a version of the change that is about to stop
158
- * being true. It also holds the file reads back (see the read effect), so
159
- * nothing is fetched against a head the server is in the middle of moving.
171
+ * detail arrives on: the note and the disabled verbs appear WITH the files,
172
+ * never a frame after them.
160
173
  */
161
- const bringingUpToDate = !autoUpdateSettled && behindAndUpdatable && !blocked;
174
+ const bringingUpToDate = !autoUpdateSettled && needsUpdateByThisReader && !blocked;
162
175
 
163
176
  const isTop = useModalLayer(true);
164
177
  useEffect(() => {
@@ -308,25 +321,19 @@ export function ChangeRequestDialog({
308
321
  const asked = useRef<Map<string, object>>(new Map());
309
322
  useEffect(() => {
310
323
  // `selected` is '' until the detail names any file in an unscoped dialog —
311
- // nothing to read yet. Binary files are never read at all (above). A read
312
- // held back while the request is being brought up to date is not skipped:
313
- // `bringingUpToDate` is a dependency, so it fires the moment the update
314
- // settles — against the head the merge left, never the one it replaced.
324
+ // nothing to read yet. Binary files are never read at all (above).
325
+ //
326
+ // A running update does NOT hold this back. The content read here is the
327
+ // proposal as it stands, which is what the reader opened the dialog for;
328
+ // an update in flight can move it, and when it lands it says which files
329
+ // it moved (`updatedPaths`) and exactly those are read again. Waiting
330
+ // instead bought one thing — never showing a line the merge later changes
331
+ // — at the price of showing nothing at all for as long as the merge took.
315
332
  //
316
- // Nothing is read before the DETAIL either, even though a dialog opened
317
- // about a file has a selection from the first render (`initialPath`): until
318
- // the detail says whether this request is behind and whether this reader
319
- // may update it, there is no way to know that the branch is not about to
320
- // move. Reading first would spend a request on content the update then
321
- // throws away, and the pane cannot draw a diff before the detail names its
322
- // fork point regardless.
323
- if (
324
- detail !== null &&
325
- !bringingUpToDate &&
326
- selected &&
327
- !selectedIsBinary &&
328
- !asked.current.has(selected)
329
- ) {
333
+ // Nothing is read before the DETAIL, though: a dialog opened about a file
334
+ // has a selection from the first render (`initialPath`), and the pane
335
+ // cannot draw a diff before the detail names its fork point.
336
+ if (detail !== null && selected && !selectedIsBinary && !asked.current.has(selected)) {
330
337
  const token = {};
331
338
  asked.current.set(selected, token);
332
339
  const current = () => asked.current.get(selected) === token;
@@ -347,7 +354,7 @@ export function ChangeRequestDialog({
347
354
  }),
348
355
  );
349
356
  }
350
- }, [selected, selectedIsBinary, cr.branch, branchRevision, bringingUpToDate, detail]);
357
+ }, [selected, selectedIsBinary, cr.branch, branchRevision, detail]);
351
358
 
352
359
  /**
353
360
  * Read the selected file again, both sides — the Retry link the retryable
@@ -415,11 +422,13 @@ export function ChangeRequestDialog({
415
422
  // Raw-vs-raw: the skills API hands back SKILL.md's PARSED body (frontmatter
416
423
  // stripped), and diffing that against a raw branch read renders the
417
424
  // frontmatter as a deletion and the whole file as changed.
418
- // Nothing is read while the request is being brought up to date, on this
419
- // side either: the fork point is exactly what the merge moves, so a read
420
- // started now would answer about a fork point that no longer exists.
425
+ // A running update moves the fork point, so this read can answer about one
426
+ // that is about to be replaced — and is re-run when it is (`baseRevision`,
427
+ // bumped with `branchRevision` when an update lands). Reading now is what
428
+ // lets the reader see the change at once; the correction, where there is
429
+ // one, costs the files the merge actually touched.
421
430
  const beforePath =
422
- isAdded || renameWithoutOldPath || !selected || selectedIsBinary || bringingUpToDate
431
+ isAdded || renameWithoutOldPath || !selected || selectedIsBinary
423
432
  ? null
424
433
  : (movedFrom ?? selected);
425
434
  /**
@@ -647,8 +656,16 @@ export function ChangeRequestDialog({
647
656
  setVerbError(null);
648
657
  }, [selected]);
649
658
 
659
+ /**
660
+ * Approving and applying are held while the open's update runs — the two
661
+ * verbs that decide the request, and the only two things the merge can
662
+ * change the answer to. An approval recorded now would be pinned to a head
663
+ * the merge is about to replace, and an apply would be a second merge on
664
+ * the same two branches. The buttons are disabled; these guards are what
665
+ * make that true rather than merely drawn.
666
+ */
650
667
  async function toggleApprove(path: string, approved: boolean) {
651
- if (!detail || verbBusy) return;
668
+ if (!detail || verbBusy || bringingUpToDate) return;
652
669
  setVerbBusy(true);
653
670
  setVerbError(null);
654
671
  try {
@@ -670,7 +687,7 @@ export function ChangeRequestDialog({
670
687
  * instead of one per file.
671
688
  */
672
689
  async function approveAllMine(paths: string[]) {
673
- if (!detail || verbBusy) return;
690
+ if (!detail || verbBusy || bringingUpToDate) return;
674
691
  setVerbBusy(true);
675
692
  setVerbError(null);
676
693
  try {
@@ -800,9 +817,22 @@ export function ChangeRequestDialog({
800
817
  detail.approvals.length > 0 &&
801
818
  detail.approvals.filter((a) => a.inMergeGate).every((a) => a.isApproved);
802
819
 
803
- /** Admin-only: delete the request and its branch, with an armed confirm. */
820
+ /**
821
+ * The author's or an admin's: delete the request AND its branch, with an
822
+ * armed confirm. `viewerCanDelete` is the server's verdict on both grants.
823
+ */
804
824
  const [deleteArmed, setDeleteArmed] = useState(false);
805
825
  const [deleting, setDeleting] = useState(false);
826
+ /**
827
+ * The armed button names the branch it is about to remove — except for a
828
+ * `suggestions/...` branch, which the platform named for the author and
829
+ * which they never chose: showing them that internal path asks them to
830
+ * confirm something they have no way to recognise. Authors and admins read
831
+ * the same sentence; what varies is the branch, not who is looking.
832
+ */
833
+ const armedDeleteLabel = cr.branch.startsWith('suggestions/')
834
+ ? 'Really delete request and branch?'
835
+ : `Really delete request and branch ${cr.branch}?`;
806
836
  async function deleteRequest() {
807
837
  if (deleting) return;
808
838
  setDeleting(true);
@@ -856,28 +886,45 @@ export function ChangeRequestDialog({
856
886
  setUpdating(true);
857
887
  setError(null);
858
888
  try {
859
- await refreshChangeRequestFromTarget(cr.number);
889
+ const result = await refreshChangeRequestFromTarget(cr.number);
860
890
  // The branch moved, so every list and every change box behind this
861
891
  // dialog is out of date — including their fork points, which this is
862
892
  // the only thing that moves.
863
893
  window.dispatchEvent(new Event(PR_STALE_EVENT));
864
- // The branch has moved: every copy read so far predates the merge.
865
- // Forget them now, before anything else can fail, so the dialog never
866
- // goes on showing the pre-update text for a branch the server merged.
867
- asked.current.clear();
868
- setBranchContents({});
869
- setBranchFailure(new Map());
870
- try {
871
- // Re-read in the same render the fresh detail (and so the fresh fork
872
- // point) lands in.
873
- const seq = ++detailSeq.current;
874
- const next = await fetchPrDetail(cr.number, { fresh: true });
875
- if (seq === detailSeq.current) setDetail(next);
876
- } catch {
877
- setError("Updated, but couldn't reload this change request. Close it and open it again.");
878
- } finally {
879
- setBranchRevision((r) => r + 1);
894
+ // Forget the copies the merge actually changed — git's own verdict on
895
+ // which, from the server that ran it — before anything else can fail,
896
+ // so the dialog never goes on showing pre-update text for a file the
897
+ // merge rewrote.
898
+ //
899
+ // ONLY those. The reader is looking at these files right now: dropping
900
+ // every copy would blank the pane they are mid-sentence in and re-read
901
+ // the whole request to replace the one file that moved. An unknown
902
+ // answer is not silence — the server sends the request's whole file
903
+ // list when it could not diff, so "drop everything" is still reachable,
904
+ // just no longer the default.
905
+ for (const path of result.updatedPaths) {
906
+ asked.current.delete(path);
880
907
  }
908
+ if (result.updatedPaths.length > 0) {
909
+ const updated = new Set(result.updatedPaths);
910
+ setBranchContents((c) =>
911
+ Object.fromEntries(Object.entries(c).filter(([path]) => !updated.has(path))),
912
+ );
913
+ setBranchFailure((m) => new Map([...m].filter(([path]) => !updated.has(path))));
914
+ }
915
+ // The Update's own answer IS the fresh detail — the server assembled it
916
+ // after the merge, with the carried approvals already in it. Fetching
917
+ // the detail again here would make the server build a second one that
918
+ // can only say the same thing, on the slowest path the dialog has.
919
+ //
920
+ // `detailSeq` still gates it: a detail fetch this dialog started before
921
+ // the update must not land on top of this one.
922
+ const seq = ++detailSeq.current;
923
+ if (seq === detailSeq.current) setDetail(result);
924
+ // The fork point moved with the branch, so the "before" side of the
925
+ // open file is re-read too — one file, not the request.
926
+ setBranchRevision((r) => r + 1);
927
+ setBaseRevision((r) => r + 1);
881
928
  setBroughtUpToDate(true);
882
929
  } catch (err) {
883
930
  const conflicts =
@@ -909,10 +956,11 @@ export function ChangeRequestDialog({
909
956
  const autoUpdateStarted = useRef(false);
910
957
  useEffect(() => {
911
958
  if (autoUpdateStarted.current || autoUpdateSettled) return;
912
- // A viewer who may not update it, a request that is not open or not
913
- // behind, and a conflict already on screen are all ruled out here rather
914
- // than recorded: none of them can turn back into an update this open owes.
915
- if (detail === null || !behindAndUpdatable || blocked) return;
959
+ // A viewer who may not update it, a request that is not open or does not
960
+ // need one, and a conflict already on screen are all ruled out here
961
+ // rather than recorded: none of them can turn back into an update this
962
+ // open owes.
963
+ if (detail === null || !needsUpdateByThisReader || blocked) return;
916
964
  // An apply is a merge on the same two branches; two at once is how a
917
965
  // request ends up half-landed. Not settled — just held, so an apply that
918
966
  // fails without conflicting still lets this through afterwards.
@@ -923,15 +971,15 @@ export function ChangeRequestDialog({
923
971
  autoUpdateStarted.current = true;
924
972
  // The synchronous setState this reaches is the in-flight marker every
925
973
  // effect that starts async work has to raise — the render it costs is the
926
- // one that swaps the files for "Bringing this up to date…", which is the
927
- // whole point. Deferring it would show the pre-update files for a frame.
974
+ // one that disables Approve and Apply. Deferring it would leave them live
975
+ // for a frame, over a verdict the merge is about to move.
928
976
  // eslint-disable-next-line react-hooks/set-state-in-effect
929
977
  void updateFromTarget();
930
978
  // `updateFromTarget` is re-created every render and is deliberately not a
931
979
  // dependency: the guards above are what make this run once, not the dep
932
980
  // list.
933
981
  // eslint-disable-next-line react-hooks/exhaustive-deps
934
- }, [autoUpdateSettled, detail, behindAndUpdatable, blocked, applyBusy]);
982
+ }, [autoUpdateSettled, detail, needsUpdateByThisReader, blocked, applyBusy]);
935
983
 
936
984
  // Name the step: recording approvals and merging are separately slow, and one
937
985
  // label over both makes the longer half look stalled.
@@ -1087,15 +1135,16 @@ export function ChangeRequestDialog({
1087
1135
  </Banner>
1088
1136
  )}
1089
1137
 
1090
- {/* The target moved on after this was proposed, and this reader is not
1091
- one of the people who can do anything about it. Everyone who can
1092
- never sees this: the dialog has already brought the request up to
1093
- date by the time it would render, or is saying so above.
1138
+ {/* The target moved on IN A FILE THIS REQUEST CHANGES, and this reader
1139
+ is not one of the people who can do anything about it. A target
1140
+ that moved elsewhere says nothing here, because nothing about this
1141
+ request has gone stale. Everyone who CAN update it never sees this
1142
+ either: the dialog is already doing it, or has said so above.
1094
1143
  "What everyone sees" is the phrase the Deployment page uses for
1095
1144
  the same thing — a business user does not know what a branch is,
1096
1145
  and this dialog never tells them. */}
1097
1146
  {detail !== null &&
1098
- detail.behind &&
1147
+ detail.needsUpdate &&
1099
1148
  detail.state === 'open' &&
1100
1149
  !detail.viewerCanUpdate &&
1101
1150
  !blocked && (
@@ -1116,31 +1165,33 @@ export function ChangeRequestDialog({
1116
1165
  </p>
1117
1166
  )}
1118
1167
 
1119
- {/* The update the open is running, in place of the files. NOT beside
1120
- them: the file content that exists right now is the proposal
1121
- against text that has already moved, and showing it for the second
1122
- or two the merge takes would be the dialog answering the reader's
1123
- question wrongly and then correcting itself. */}
1124
- {bringingUpToDate ? (
1125
- <div className="mt-4 min-h-0 flex-1 px-8">
1126
- <p
1127
- role="status"
1128
- className="mx-auto max-w-[52ch] py-10 text-center text-detail text-ink-faint"
1129
- >
1130
- Bringing this up to date with what everyone sees…
1131
- </p>
1132
- </div>
1133
- ) : /* A request that no longer changes anything — everything it proposed
1168
+ {/* The update the open is running, ABOVE the files rather than in
1169
+ place of them. The proposal is on screen from the first render and
1170
+ stays there: a merge into a file it changes can move a line or two
1171
+ of it, which is worth saying and is not worth making every reader
1172
+ wait through a merge to see anything at all. What the update can
1173
+ change is the VERDICT, so Approve and Apply are the two things
1174
+ that wait for it (below), and the reading does not. */}
1175
+ {bringingUpToDate && (
1176
+ <p role="status" className="mt-3 px-8 text-detail text-ink-faint">
1177
+ Checking against the latest version…
1178
+ </p>
1179
+ )}
1180
+
1181
+ {/* A request that no longer changes anything — everything it proposed
1134
1182
  has since landed on (or been removed from) the target, or its only
1135
1183
  change was one the merge never takes (roles.yaml). The file grid
1136
1184
  below would render a blank pill over an eternal "Loading…", which
1137
- reads as a hang; the truth is simpler and gets said instead. */
1138
- detail !== null && allFiles.length === 0 ? (
1185
+ reads as a hang; the truth is simpler and gets said instead. */}
1186
+ {detail !== null && allFiles.length === 0 ? (
1139
1187
  <div className="mt-4 min-h-0 flex-1 px-8">
1140
1188
  <p className="mx-auto max-w-[52ch] py-10 text-center text-detail text-ink-faint">
1141
1189
  This request doesn't change anything anymore. What it proposed is already part of
1142
1190
  the current text, or has since been removed on its branch — there is nothing left
1143
- to review or apply. {firstName} can withdraw it.
1191
+ to review or apply.{' '}
1192
+ {/* Withdraw is not in this dialog; Delete is, right below. Point
1193
+ at the verb the reader can actually reach from here. */}
1194
+ {detail.viewerIsAuthor ? 'You can delete it below.' : `${firstName} can delete it.`}
1144
1195
  </p>
1145
1196
  </div>
1146
1197
  ) : (
@@ -1185,7 +1236,7 @@ export function ChangeRequestDialog({
1185
1236
  variant={headerVerb === 'approve' ? 'primary' : 'outline'}
1186
1237
  size="tiny"
1187
1238
  className="ml-auto shrink-0"
1188
- disabled={verbBusy || applyBusy}
1239
+ disabled={verbBusy || applyBusy || bringingUpToDate}
1189
1240
  onClick={() => void toggleApprove(selected, headerVerb === 'undo')}
1190
1241
  >
1191
1242
  {headerVerb === 'approve' ? 'Approve this file' : 'Approved – Undo'}
@@ -1309,11 +1360,11 @@ export function ChangeRequestDialog({
1309
1360
  <div className="mt-4 border-t border-line bg-sunken px-8 py-4">
1310
1361
  {/* What is the viewer's to approve, above the verdict: a count and
1311
1362
  one button for all of them, or who everyone is waiting on. */}
1312
- {/* Nothing to approve or wait on while the files are hidden: the
1313
- verdict belongs to the request as it will stand after the
1314
- update, which is a second away. */}
1363
+ {/* Shown during a running update too, with its button disabled: the
1364
+ files are on screen, so the line that says whose approval they
1365
+ are waiting on belongs on screen with them. Only the ACT of
1366
+ approving waits for the merge. */}
1315
1367
  {!blocked &&
1316
- !bringingUpToDate &&
1317
1368
  detail !== null &&
1318
1369
  allFiles.length > 0 &&
1319
1370
  (mine.length > 0 || !canApply) && (
@@ -1330,7 +1381,7 @@ export function ChangeRequestDialog({
1330
1381
  <Button
1331
1382
  variant="outline"
1332
1383
  size="sm"
1333
- disabled={verbBusy || applyBusy}
1384
+ disabled={verbBusy || applyBusy || bringingUpToDate}
1334
1385
  onClick={() => void approveAllMine(mine)}
1335
1386
  >
1336
1387
  Approve all mine
@@ -1352,10 +1403,13 @@ export function ChangeRequestDialog({
1352
1403
  ? 'Every agent that connects after this picks it up. There is no staged rollout.'
1353
1404
  : ''}
1354
1405
  </p>
1355
- {/* Admins carry the moderation verb: delete the request AND its
1356
- branch, armed on the first click. `viewerCanBypassMerge` is the
1357
- server's admin verdict — the DELETE route re-checks it. */}
1358
- {!blocked && detail?.viewerCanBypassMerge && (
1406
+ {/* The author and admins carry the destructive verb: delete the
1407
+ request AND its branch, armed on the first click.
1408
+ `viewerCanDelete` is the server's verdict on both grants — the
1409
+ DELETE route re-checks it. Shown while `blocked` on purpose: a
1410
+ request stuck on a conflict is exactly the one its author most
1411
+ wants to throw away and propose again. */}
1412
+ {detail?.viewerCanDelete && (
1359
1413
  deleteArmed ? (
1360
1414
  <>
1361
1415
  <Button
@@ -1364,7 +1418,7 @@ export function ChangeRequestDialog({
1364
1418
  disabled={deleting}
1365
1419
  onClick={() => void deleteRequest()}
1366
1420
  >
1367
- {deleting ? 'Deleting…' : 'Really delete request and branch?'}
1421
+ {deleting ? 'Deleting…' : armedDeleteLabel}
1368
1422
  </Button>
1369
1423
  <Button variant="quiet" size="sm" disabled={deleting} onClick={() => setDeleteArmed(false)}>
1370
1424
  Keep
@@ -1386,11 +1440,14 @@ export function ChangeRequestDialog({
1386
1440
  but every one of them approvable BY THIS VIEWER (write access) →
1387
1441
  the same click, named for what it is: their authority covers the
1388
1442
  missing approvals. Anyone else gets the waiting line above. */}
1389
- {!blocked && !bringingUpToDate && canApply && (
1443
+ {/* Rendered throughout a running update, disabled rather than
1444
+ absent: a primary button that appears under the reader's cursor
1445
+ a second after the dialog opens is a click they did not aim. */}
1446
+ {!blocked && canApply && (
1390
1447
  <Button
1391
1448
  variant="primary"
1392
1449
  size="sm"
1393
- disabled={applyBusy || verbBusy}
1450
+ disabled={applyBusy || verbBusy || bringingUpToDate}
1394
1451
  onClick={() => applying.apply(cr)}
1395
1452
  >
1396
1453
  {applyBusy ? applyLabel : allApproved ? 'Apply changes' : 'Bypass approval and apply'}
@@ -129,6 +129,7 @@ vi.mock('../state/library-data', () => ({
129
129
 
130
130
  import { SkillPage } from '../components/skill-page/SkillPage';
131
131
  import { LibraryToastProvider } from '../state/toast';
132
+ import { expectTitleRowSpansTheDocumentColumn } from './title-row-actions';
132
133
 
133
134
  const workspace = {
134
135
  workspaceId: 'target-company-state',
@@ -447,6 +448,20 @@ describe('SkillPage', () => {
447
448
  expect(screen.queryByText('Drafts the Friday newsletter for review.')).toBeNull();
448
449
  });
449
450
 
451
+ /**
452
+ * The third page in the comparison. The criterion names the plugin page and
453
+ * this one as the two controls the tool page's title row is measured
454
+ * against, and they agree only because neither wraps its band in a column
455
+ * narrower than the layout's — which is exactly what the tool page did.
456
+ * Asserted here so the day this page grows its own `max-w`, it is this test
457
+ * that says the row it holds is a control no longer.
458
+ */
459
+ it('runs its title row to the shared document column', async () => {
460
+ renderPage(false);
461
+ await screen.findByRole('heading', { name: 'newsletter' });
462
+ expectTitleRowSpansTheDocumentColumn();
463
+ });
464
+
450
465
  it('marks the open tab selected and loads a bundled file on click', async () => {
451
466
  renderPage(false);
452
467
  const tab = await screen.findByRole('tab', { name: /sources\.yaml/ });
@@ -61,7 +61,7 @@ vi.mock('../utils/navigate-external', () => ({ navigateExternal: vi.fn() }));
61
61
 
62
62
  import { ToolPage } from '../components/tool-page/ToolPage';
63
63
  import { NAME_MIN_WIDTH } from '../components/NameWithBadges';
64
- import { expectMenuAtTheEndOfTheTitleRow } from './title-row-actions';
64
+ import { expectMenuAtTheEndOfTheTitleRow, expectTitleRowSpansTheDocumentColumn } from './title-row-actions';
65
65
  import { TOOL_CREDENTIALS_STALE_EVENT } from '../../../core/events';
66
66
 
67
67
  const GITHUB: ToolSecrets = {
@@ -234,6 +234,20 @@ describe('ToolPage: frame', () => {
234
234
  expectMenuAtTheEndOfTheTitleRow();
235
235
  });
236
236
 
237
+ /**
238
+ * And the right end is the SAME right end. This page used to wrap itself in
239
+ * `max-w-3xl` — a 768px article centred inside the layout's 800px line — so
240
+ * its title row, and the `⋯` at the end of it, stopped 16px short of the
241
+ * plugin page's at every viewport while every structural assertion above
242
+ * passed on both pages.
243
+ */
244
+ it('runs its title row to the document column, not a narrower one of its own', async () => {
245
+ const { container } = renderPage();
246
+ await screen.findByRole('heading', { name: 'heyreach', level: 1 });
247
+ expectTitleRowSpansTheDocumentColumn();
248
+ expect(container.querySelector('article')!.className).not.toContain('max-w-');
249
+ });
250
+
237
251
  it('shows no kicker for a legacy ungrouped path either', async () => {
238
252
  secretsMock.listToolSecrets.mockResolvedValue([
239
253
  { ...GITHUB, slug: 'slack', name: 'slack', path: 'Tools/slack.tool' },
@@ -1,6 +1,13 @@
1
1
  import { expect } from 'vitest';
2
2
  import { screen, within } from '@testing-library/react';
3
3
  import { PAGE_HEADER_TESTID } from '../../../shared/theme/header';
4
+ import { DOCUMENT_COLUMN } from '../../../shared/theme/measure';
5
+
6
+ /**
7
+ * The one width an item page is allowed to be: the shared document measure,
8
+ * which the Library layout's `<main>` already puts around every page.
9
+ */
10
+ const SHARED_MEASURE = DOCUMENT_COLUMN.split(' ').filter((c) => c.startsWith('max-w-'));
4
11
 
5
12
  /**
6
13
  * Where an item page's `⋯` goes: the right end of the title row.
@@ -19,7 +26,9 @@ import { PAGE_HEADER_TESTID } from '../../../shared/theme/header';
19
26
  *
20
27
  * Size needs no assertion of its own: it is the same `PageActions` component,
21
28
  * so the only thing that could differ is where it is put. That is what this
22
- * pins — in the band, last, in a group that neither shrinks nor wraps.
29
+ * pins — in the band, last, in a group that neither shrinks nor wraps: that,
30
+ * plus {@link expectTitleRowSpansTheDocumentColumn} for the row's WIDTH, is
31
+ * the whole of "the same position".
23
32
  */
24
33
  export function expectMenuAtTheEndOfTheTitleRow(): void {
25
34
  const band = screen.getByTestId(PAGE_HEADER_TESTID);
@@ -40,4 +49,47 @@ export function expectMenuAtTheEndOfTheTitleRow(): void {
40
49
  // the back link is the bug this replaced.
41
50
  const header = band.closest('header') ?? band.parentElement!;
42
51
  expect(within(header).getAllByRole('button', { name: 'More actions' })).toHaveLength(1);
52
+
53
+ // Last in a right-aligned row says WHERE ON the row; this says where the row
54
+ // ENDS. Both are needed, and only the pair is the criterion.
55
+ expectTitleRowSpansTheDocumentColumn();
56
+ }
57
+
58
+ /**
59
+ * The title row runs the full width of the shared document column — the page
60
+ * wraps it in no narrower measure of its own.
61
+ *
62
+ * This is the half of "the same position as on the plugin page" that structure
63
+ * alone cannot see, and the half that shipped broken. The tool page put its
64
+ * band, correctly, last-in-row inside a group with the plugin page's exact
65
+ * classes — and rendered it 16px left of the plugin page's, every viewport,
66
+ * because the article around it was `max-w-3xl` (768px) inside the layout's
67
+ * 800px line. Every structural assertion above passed on both pages while the
68
+ * two menus sat at different points on the screen; staging found it with a
69
+ * ruler, which is not a thing this suite can do.
70
+ *
71
+ * So it asserts the CAUSE rather than the pixels: jsdom computes no layout, but
72
+ * the width of a page's title row is decided entirely by which ancestors
73
+ * constrain it, and the layout's `<main>` is the only one entitled to. Anything
74
+ * else between the band and the document is a second column inside the first,
75
+ * and the row cannot reach the same right edge as a page that has none.
76
+ */
77
+ export function expectTitleRowSpansTheDocumentColumn(): void {
78
+ const band = screen.getByTestId(PAGE_HEADER_TESTID);
79
+ const narrowed: string[] = [];
80
+ for (let el = band.parentElement; el && el !== document.body; el = el.parentElement) {
81
+ for (const cls of Array.from(el.classList)) {
82
+ // `DOCUMENT_COLUMN` itself is allowed through: a test that renders the
83
+ // page inside `LibraryLayout` passes the shared measure on the way up,
84
+ // and the shared measure is the one width the row is meant to have.
85
+ if (cls.startsWith('max-w-') && !SHARED_MEASURE.includes(cls)) {
86
+ narrowed.push(`<${el.tagName.toLowerCase()} class="${el.className}">`);
87
+ }
88
+ }
89
+ }
90
+ expect(
91
+ narrowed,
92
+ `The title row is inside a narrower column than the document measure (${SHARED_MEASURE.join(' ')}), ` +
93
+ 'so its right end — and the ⋯ on it — cannot line up with the plugin page\'s.',
94
+ ).toEqual([]);
43
95
  }
@@ -1,6 +1,6 @@
1
1
  import { useEffect, useLayoutEffect } from 'react';
2
2
  import { useJoinRequests } from '../hooks/useJoinRequests';
3
- import { AccessRequestsBanner } from './AccessRequestsBanner';
3
+ import { AccessRequestsBanner } from '../../access/components/AccessRequestsBanner';
4
4
 
5
5
  /**
6
6
  * One plugin's join requests, fetching their own data.
@@ -65,7 +65,7 @@ export function PluginJoinRequests({
65
65
 
66
66
  return (
67
67
  <AccessRequestsBanner
68
- plugin={plugin}
68
+ itemName={plugin}
69
69
  folders={folders}
70
70
  requests={requests.requests}
71
71
  onManage={onManage}
@@ -51,7 +51,7 @@ import { ownersTextOf, pluginLabel } from '../../utils/plugin-summary';
51
51
  import { neededToolsFor, toolStatus } from '../../utils/status';
52
52
  import { StatusDot } from '../StatusDot';
53
53
  import { SharedViaPlugins } from './SharedViaPlugins';
54
- import { AccessRequestsBanner } from '../AccessRequestsBanner';
54
+ import { AccessRequestsBanner } from '../../../access/components/AccessRequestsBanner';
55
55
  import { useJoinRequests, type JoinRequestsApi } from '../../hooks/useJoinRequests';
56
56
  import { listSkillAccessRequests, reconcileSkillAccessRequest } from '../../services/library.api';
57
57
  import { ManageAccessDialog } from '../../../access/components/ManageAccessDialog';
@@ -710,7 +710,7 @@ export function SkillPage({
710
710
  Manage access opens it, and both are no-ops against ''. */}
711
711
  {canWrite && skillFolderEntry && (
712
712
  <AccessRequestsBanner
713
- plugin={name}
713
+ itemName={name}
714
714
  folders={[skillPath]}
715
715
  requests={accessRequests.requests}
716
716
  onManage={() => setManageTarget(skillFolderEntry)}
@@ -316,9 +316,19 @@ export function ToolPage({
316
316
  * The reading column. Horizontal and vertical padding come from the Library
317
317
  * layout's `<main>`, which already wraps every page under `/skills-and-tools` —
318
318
  * repeating them here would double the gutter.
319
+ *
320
+ * And no `max-w` of its own, for the same reason the skill page has none: the
321
+ * layout's `<main>` already holds the shared `DOCUMENT_COLUMN` measure, so a
322
+ * second, narrower width here is a second column inside the first. It was
323
+ * `max-w-3xl` — a 768px article centred in the measure's 800px line — and the
324
+ * 16px that left on each side moved this page's title row in from where the
325
+ * plugin page's and the skill page's are: the same band, the same group, the
326
+ * same `⋯`, ending 16px short of the right edge the other two reach. Where
327
+ * the menu sits on the row is decided by how wide the row is, so the column
328
+ * is where "the same position as on the plugin page" is actually kept.
319
329
  */
320
330
  function Article({ children }: { children: ReactNode }) {
321
- return <article className="mx-auto w-full max-w-3xl">{children}</article>;
331
+ return <article className="w-full">{children}</article>;
322
332
  }
323
333
 
324
334
  function SectionHeading({ children }: { children: ReactNode }) {