@bevel-software/platform-core-frontend 0.20.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.
- package/package.json +2 -2
- package/src/core/registry.ts +57 -0
- package/src/modules/access/__tests__/ManageAccessDialog.request.test.tsx +376 -0
- package/src/modules/access/components/AccessRequestControl.tsx +155 -0
- package/src/modules/{library → access}/components/AccessRequestsBanner.tsx +62 -24
- package/src/modules/access/components/ManageAccessDialog.tsx +81 -4
- package/src/modules/access/hooks/useAccessRequests.ts +183 -0
- package/src/modules/access/hooks/useFileAccess.ts +2 -2
- package/src/modules/access/requests.api.ts +121 -0
- package/src/modules/auth/components/LoginScreen.tsx +6 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.brings-itself-up-to-date.test.tsx +171 -38
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.fork-point.test.tsx +34 -19
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.test.tsx +173 -6
- package/src/modules/change-requests/components/ChangeRequestDialog.tsx +155 -98
- package/src/modules/git/components/BranchSwitcher.tsx +9 -3
- package/src/modules/git/components/FileComparisonPanel.tsx +10 -4
- package/src/modules/git/components/PullNeededBanner.tsx +2 -2
- package/src/modules/git/services/error-messages.ts +2 -2
- package/src/modules/layout/__tests__/HeaderAlignment.test.tsx +110 -9
- package/src/modules/layout/components/SidebarFrame.tsx +26 -9
- package/src/modules/library/__tests__/DeleteToolDialog.test.tsx +11 -0
- package/src/modules/library/__tests__/LibraryRoutes.test.tsx +3 -0
- package/src/modules/library/__tests__/PluginIndexRow.test.tsx +146 -0
- package/src/modules/library/__tests__/PluginPage.test.tsx +110 -3
- package/src/modules/library/__tests__/SkillPage.test.tsx +15 -0
- package/src/modules/library/__tests__/ToolPage.test.tsx +34 -0
- package/src/modules/library/__tests__/name-with-badges.test.tsx +16 -3
- package/src/modules/library/__tests__/title-row-actions.ts +95 -0
- package/src/modules/library/components/PluginIndexRow.tsx +37 -20
- package/src/modules/library/components/PluginJoinRequests.tsx +2 -2
- package/src/modules/library/components/PluginPage.tsx +115 -3
- package/src/modules/library/components/skill-page/SkillPage.tsx +2 -2
- package/src/modules/library/components/tool-page/ToolPage.tsx +36 -18
- package/src/modules/library/hooks/useJoinRequests.ts +26 -101
- package/src/modules/library/routes/library-paths.ts +9 -2
- package/src/modules/library/services/plugins.api.ts +45 -0
- package/src/modules/library/utils/plugin-summary.ts +7 -2
- package/src/modules/onboarding/__tests__/onboarding.test.tsx +43 -0
- package/src/modules/onboarding/components/ConnectAgentPill.tsx +13 -2
- package/src/modules/pr/components/OpenChangeRequestDialog.tsx +3 -2
- package/src/modules/pr/services/pr-merge.api.ts +10 -2
- package/src/modules/review/components/ReviewPanel.tsx +2 -2
- package/src/modules/settings/components/DeploymentPage.tsx +22 -0
- package/src/modules/settings/components/__tests__/DeploymentPage.test.tsx +72 -4
- package/src/modules/setup/__tests__/setup.first-run.test.tsx +276 -0
- package/src/modules/setup/__tests__/setup.github.test.tsx +416 -0
- package/src/modules/setup/__tests__/setup.kept-draft.test.tsx +275 -0
- package/src/modules/setup/__tests__/setup.repository.test.tsx +373 -0
- package/src/modules/setup/__tests__/setup.test.tsx +8 -14
- package/src/modules/setup/components/GitHubRepositoryPanel.tsx +369 -0
- package/src/modules/setup/components/SetupGate.tsx +1 -0
- package/src/modules/setup/components/SetupScreen.tsx +464 -38
- package/src/modules/setup/services/setup.api.ts +93 -0
- package/src/modules/setup/utils/kept-draft.ts +86 -0
- package/src/modules/workspace/components/FileExplorer.tsx +4 -2
- package/src/modules/workspace/components/FileViewer.tsx +8 -3
- package/src/modules/workspace/components/KbDocumentShell.tsx +50 -8
- package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +49 -0
- package/src/modules/workspace/components/__tests__/KbDocumentShell.test.tsx +49 -1
- package/src/modules/workspace/hooks/useWorkspaceState.ts +7 -2
- package/src/modules/workspace/utils/fileTree.ts +2 -1
- package/src/modules/workspace/utils/treeConfirm.ts +7 -3
- package/src/shared/components/SlotBoundary.tsx +51 -0
- package/src/shared/theme/measure.ts +23 -2
|
@@ -142,23 +142,36 @@ export function ChangeRequestDialog({
|
|
|
142
142
|
const [baseRevision, setBaseRevision] = useState(0);
|
|
143
143
|
|
|
144
144
|
/**
|
|
145
|
-
*
|
|
146
|
-
* may
|
|
147
|
-
*
|
|
148
|
-
*
|
|
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
|
|
151
|
-
detail !== null && detail.state === 'open' && detail.
|
|
158
|
+
const needsUpdateByThisReader =
|
|
159
|
+
detail !== null && detail.state === 'open' && detail.needsUpdate && detail.viewerCanUpdate;
|
|
152
160
|
/**
|
|
153
|
-
* Mid-update: the
|
|
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
|
|
157
|
-
*
|
|
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 &&
|
|
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).
|
|
312
|
-
//
|
|
313
|
-
//
|
|
314
|
-
//
|
|
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
|
|
317
|
-
//
|
|
318
|
-
//
|
|
319
|
-
|
|
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,
|
|
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
|
-
//
|
|
419
|
-
//
|
|
420
|
-
//
|
|
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
|
|
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
|
-
/**
|
|
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
|
-
//
|
|
865
|
-
//
|
|
866
|
-
// goes on showing
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
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
|
-
//
|
|
914
|
-
// than recorded: none of them can turn back into an update this
|
|
915
|
-
|
|
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
|
|
927
|
-
//
|
|
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,
|
|
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
|
|
1091
|
-
one of the people who can do anything about it.
|
|
1092
|
-
|
|
1093
|
-
|
|
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.
|
|
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,
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
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.
|
|
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
|
-
{/*
|
|
1313
|
-
|
|
1314
|
-
|
|
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
|
-
{/*
|
|
1356
|
-
branch, armed on the first click.
|
|
1357
|
-
server's
|
|
1358
|
-
|
|
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…' :
|
|
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
|
-
{
|
|
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'}
|
|
@@ -2,7 +2,13 @@ import { useEffect, useMemo, useRef, useState } from 'react';
|
|
|
2
2
|
import { createPortal } from 'react-dom';
|
|
3
3
|
import { useLocation, useNavigate } from 'react-router-dom';
|
|
4
4
|
import { ChevronDown, GitBranch, Plus, Lock, Check, GitPullRequest, Trash2, Loader2 } from 'lucide-react';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
protectedBranchDisplayName,
|
|
7
|
+
currentBranchModel,
|
|
8
|
+
branchAuthorLocalpart,
|
|
9
|
+
isBranchAuthoredBy,
|
|
10
|
+
DEFAULT_BRANCH,
|
|
11
|
+
} from '@bevel-software/platform-shared';
|
|
6
12
|
import { useGit } from '../state/git.context';
|
|
7
13
|
import { parseGitError, type GitErrorInfo } from '../services/error-messages';
|
|
8
14
|
import { useAuth } from '../../auth/state/auth.context';
|
|
@@ -192,7 +198,7 @@ export function BranchSwitcher() {
|
|
|
192
198
|
// shared draft" is wrong, it's the official version everyone sees.
|
|
193
199
|
const branchLabel = (() => {
|
|
194
200
|
if (switchingTo) return `Switching to ${switchingTo}…`;
|
|
195
|
-
const protectedName = protectedBranchDisplayName(git.status?.branch);
|
|
201
|
+
const protectedName = protectedBranchDisplayName(currentBranchModel(), git.status?.branch);
|
|
196
202
|
if (protectedName) return `${protectedName} (official version)`;
|
|
197
203
|
return 'Your active shared draft';
|
|
198
204
|
})();
|
|
@@ -403,7 +409,7 @@ export function BranchSwitcher() {
|
|
|
403
409
|
</div>
|
|
404
410
|
)}
|
|
405
411
|
{targetBranches.map((b) => {
|
|
406
|
-
const displayName = protectedBranchDisplayName(b.name);
|
|
412
|
+
const displayName = protectedBranchDisplayName(currentBranchModel(), b.name);
|
|
407
413
|
// Default destination for shared drafts: visually distinguish
|
|
408
414
|
// the default branch so users see the recommended path without
|
|
409
415
|
// having to read the slug. Others stay available, just quieter.
|
|
@@ -8,7 +8,13 @@ import {
|
|
|
8
8
|
AlertTriangle,
|
|
9
9
|
RefreshCw,
|
|
10
10
|
} from 'lucide-react';
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
protectedBranchDisplayName,
|
|
13
|
+
isProtectedBranch,
|
|
14
|
+
currentBranchModel,
|
|
15
|
+
DEFAULT_BRANCH,
|
|
16
|
+
type BranchInfo,
|
|
17
|
+
} from '@bevel-software/platform-shared';
|
|
12
18
|
import { useGit } from '../state/git.context';
|
|
13
19
|
import { UnifiedDiffView } from './UnifiedDiffView';
|
|
14
20
|
import { friendlyGitError } from '../services/error-messages';
|
|
@@ -84,7 +90,7 @@ function defaultFromForCurrent(
|
|
|
84
90
|
// On a protected branch, prefer the default branch as the comparison base so
|
|
85
91
|
// the picker opens on the canonical "official vs official" diff; if we're
|
|
86
92
|
// already on the default branch, any other protected branch works.
|
|
87
|
-
if (isProtectedBranch(currentBranch)) {
|
|
93
|
+
if (isProtectedBranch(currentBranchModel(), currentBranch)) {
|
|
88
94
|
if (currentBranch !== DEFAULT_BRANCH && others.some((b) => b.name === DEFAULT_BRANCH)) {
|
|
89
95
|
return DEFAULT_BRANCH;
|
|
90
96
|
}
|
|
@@ -313,7 +319,7 @@ function BranchPicker({ label, value, branches, onChange }: BranchPickerProps) {
|
|
|
313
319
|
const valueIsProtected = !!value && (
|
|
314
320
|
branches.find((b) => b.name === value)?.isProtected ?? false
|
|
315
321
|
);
|
|
316
|
-
const valueDisplay = value ? protectedBranchDisplayName(value) ?? value : 'Select…';
|
|
322
|
+
const valueDisplay = value ? protectedBranchDisplayName(currentBranchModel(), value) ?? value : 'Select…';
|
|
317
323
|
|
|
318
324
|
return (
|
|
319
325
|
<div ref={ref} className="relative flex-1 min-w-0">
|
|
@@ -341,7 +347,7 @@ function BranchPicker({ label, value, branches, onChange }: BranchPickerProps) {
|
|
|
341
347
|
<div className="px-3 py-2 text-xs text-ink-muted">No branches.</div>
|
|
342
348
|
)}
|
|
343
349
|
{branches.map((b) => {
|
|
344
|
-
const display = protectedBranchDisplayName(b.name);
|
|
350
|
+
const display = protectedBranchDisplayName(currentBranchModel(), b.name);
|
|
345
351
|
const isSelected = b.name === value;
|
|
346
352
|
return (
|
|
347
353
|
<button
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
2
|
import { GitMerge } from 'lucide-react';
|
|
3
|
-
import { isProtectedBranch } from '@bevel-software/platform-shared';
|
|
3
|
+
import { currentBranchModel, isProtectedBranch } from '@bevel-software/platform-shared';
|
|
4
4
|
import { useGit } from '../state/git.context';
|
|
5
5
|
import { useAutoUpdate } from '../state/auto-update.context';
|
|
6
6
|
import { useCrCreationPort } from '../../../core/registry';
|
|
@@ -63,7 +63,7 @@ export function PullNeededBanner() {
|
|
|
63
63
|
// Captured for the handlers below — TS control-flow narrowing on `status`
|
|
64
64
|
// doesn't survive into nested function declarations.
|
|
65
65
|
const branchName = status.branch;
|
|
66
|
-
const onProtectedBranch = isProtectedBranch(status.branch);
|
|
66
|
+
const onProtectedBranch = isProtectedBranch(currentBranchModel(), status.branch);
|
|
67
67
|
const hasUnsavedEditorChanges = !!workspace.hasUnsavedFileChanges;
|
|
68
68
|
// Under save=share the working tree is never dirty and there are no
|
|
69
69
|
// mid-merge conflicts to gate on — the only thing that can still block
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { protectedBranchDisplayName } from '@bevel-software/platform-shared';
|
|
1
|
+
import { currentBranchModel, protectedBranchDisplayName } from '@bevel-software/platform-shared';
|
|
2
2
|
import { GitApiError } from './git.api';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -74,7 +74,7 @@ export function parseGitError(err: unknown): GitErrorInfo {
|
|
|
74
74
|
* "Target company state" instead of `target-company-state`.
|
|
75
75
|
*/
|
|
76
76
|
function friendlyNoSharedHistoryMessage(base: string): string {
|
|
77
|
-
const baseName = protectedBranchDisplayName(base) ?? base;
|
|
77
|
+
const baseName = protectedBranchDisplayName(currentBranchModel(), base) ?? base;
|
|
78
78
|
return (
|
|
79
79
|
`This draft doesn't share history with the ${baseName}. It was likely started ` +
|
|
80
80
|
`from an unrelated point or outside the app. The assistant can investigate and ` +
|