@app-vitals/agent-admin 1.89.0 → 1.90.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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@app-vitals/agent-admin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.90.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/app-vitals/agent.git",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@anthropic-ai/sdk": "0.137.0",
|
|
47
|
-
"@app-vitals/agent-lib": "1.
|
|
47
|
+
"@app-vitals/agent-lib": "1.90.0",
|
|
48
48
|
"@hono/zod-openapi": "^1.0.0",
|
|
49
49
|
"@prisma/adapter-pg": "^7.10.0",
|
|
50
50
|
"@prisma/client": "^7.10.0",
|
|
@@ -208,6 +208,7 @@ export interface GithubSyncPreviewView {
|
|
|
208
208
|
appAdds?: string[];
|
|
209
209
|
appRemoves?: string[];
|
|
210
210
|
agentRemoves?: string[];
|
|
211
|
+
selectionSwitches?: { org: string; repos: string[] }[];
|
|
211
212
|
skippedOrgs?: { org: string; reason: string; detail?: SkipDetail }[];
|
|
212
213
|
openWork?: OpenWorkView[];
|
|
213
214
|
warnings?: string[];
|
|
@@ -465,6 +466,19 @@ const repoList = (kind: string, title: string, repos: readonly string[]) =>
|
|
|
465
466
|
const plural = (n: number, one: string, many: string) =>
|
|
466
467
|
`${n} ${n === 1 ? one : many}`;
|
|
467
468
|
|
|
469
|
+
/** Orgs the confirmed sync switches from "all repositories" to "selected repositories". */
|
|
470
|
+
const selectionSwitchesHtml = (
|
|
471
|
+
switches: readonly { org: string; repos: readonly string[] }[],
|
|
472
|
+
) =>
|
|
473
|
+
switches.length === 0
|
|
474
|
+
? ""
|
|
475
|
+
: `<div data-list="selection-switches" style="margin-top:8px"><div style="font-weight:600">Switch from all repositories to selected repositories (${switches.length})</div><ul style="margin:4px 0 0 18px">${switches
|
|
476
|
+
.map(
|
|
477
|
+
(s) =>
|
|
478
|
+
`<li data-switch-org="${escapeHtml(s.org)}"><span class="mono">${escapeHtml(s.org)}</span>: keeps ${plural(s.repos.length, "repo", "repos")}</li>`,
|
|
479
|
+
)
|
|
480
|
+
.join("")}</ul></div>`;
|
|
481
|
+
|
|
468
482
|
/** One readable sentence-list describing why an org's cached access was skipped. */
|
|
469
483
|
function skipDetailText(d: SkipDetail, timezone?: string): string {
|
|
470
484
|
const out: string[] = [];
|
|
@@ -528,8 +542,8 @@ const skippedOrgsHtml = (
|
|
|
528
542
|
.join("")}</div>`;
|
|
529
543
|
|
|
530
544
|
/**
|
|
531
|
-
* The single confirm step of Sync: the installation adds,
|
|
532
|
-
* removes, agent-repo removes and the open work the removals would block. One
|
|
545
|
+
* The single confirm step of Sync: the selection switches, installation adds,
|
|
546
|
+
* installation removes, agent-repo removes and the open work the removals would block. One
|
|
533
547
|
* confirmation applies them all; more than the removal cap needs the extra
|
|
534
548
|
* checkbox (confirmRemovals).
|
|
535
549
|
*/
|
|
@@ -544,12 +558,19 @@ export function renderSyncConfirm(
|
|
|
544
558
|
const appAdds = preview.appAdds ?? [];
|
|
545
559
|
const appRemoves = preview.appRemoves ?? [];
|
|
546
560
|
const agentRemoves = preview.agentRemoves ?? [];
|
|
561
|
+
const switches = preview.selectionSwitches ?? [];
|
|
547
562
|
const skippedList = preview.skippedOrgs ?? [];
|
|
548
563
|
const skipped = skippedOrgsHtml(skippedList, timezone);
|
|
549
564
|
const warnings = warningsHtml(
|
|
550
565
|
withoutSkipWarnings(preview.warnings, skippedList),
|
|
551
566
|
);
|
|
552
|
-
if (
|
|
567
|
+
if (
|
|
568
|
+
appAdds.length +
|
|
569
|
+
appRemoves.length +
|
|
570
|
+
agentRemoves.length +
|
|
571
|
+
switches.length ===
|
|
572
|
+
0
|
|
573
|
+
) {
|
|
553
574
|
if (skippedList.length > 0) {
|
|
554
575
|
return `<div class="alert alert-warning" data-sync="nothing-synced">Nothing was synced: ${skippedList.length} org(s) skipped, see below.</div>${skipped}${warnings}`;
|
|
555
576
|
}
|
|
@@ -564,7 +585,7 @@ export function renderSyncConfirm(
|
|
|
564
585
|
const capBox = overCap
|
|
565
586
|
? `<label style="display:block;margin:12px 0"><input type="checkbox" id="github-sync-confirm-removals" /> I confirm removing ${removals} repos (more than ${MAX_UNCONFIRMED_REMOVALS}).</label>`
|
|
566
587
|
: "";
|
|
567
|
-
return `<div class="alert alert-warning" data-sync="confirm">Apply these changes?</div>${repoList("app-adds", "Add to the agent App installation", appAdds)}${repoList("app-removes", "Remove from the agent App installation", appRemoves)}${repoList("agent-removes", "Remove from the agent's repos", agentRemoves)}${renderOpenWorkByRepo(
|
|
588
|
+
return `<div class="alert alert-warning" data-sync="confirm">Apply these changes?</div>${selectionSwitchesHtml(switches)}${repoList("app-adds", "Add to the agent App installation", appAdds)}${repoList("app-removes", "Remove from the agent App installation", appRemoves)}${repoList("agent-removes", "Remove from the agent's repos", agentRemoves)}${renderOpenWorkByRepo(
|
|
568
589
|
preview.openWork ?? [],
|
|
569
590
|
"Open tasks and PRs that will be blocked",
|
|
570
591
|
"No open tasks or PRs would be blocked.",
|
|
@@ -187,6 +187,47 @@ describe("renderSyncConfirm", () => {
|
|
|
187
187
|
});
|
|
188
188
|
});
|
|
189
189
|
|
|
190
|
+
it("lists each selection switch with org and kept repo count in the one confirm", () => {
|
|
191
|
+
const html = renderSyncConfirm("a1", {
|
|
192
|
+
...preview,
|
|
193
|
+
selectionSwitches: [
|
|
194
|
+
{ org: "acme", repos: ["acme/a", "acme/b"] },
|
|
195
|
+
{ org: "solo<x>", repos: ["solo/a"] },
|
|
196
|
+
],
|
|
197
|
+
});
|
|
198
|
+
expect(html).toContain('data-list="selection-switches"');
|
|
199
|
+
expect(html).toContain("all repositories to selected repositories (2)");
|
|
200
|
+
expect(html).toContain('data-switch-org="acme"');
|
|
201
|
+
expect(html).toContain("keeps 2 repos");
|
|
202
|
+
expect(html).toContain("solo<x>");
|
|
203
|
+
expect(html).toContain("keeps 1 repo<");
|
|
204
|
+
expect(html.match(/id="github-sync-confirm-btn"/g)?.length).toBe(1);
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it("confirms a switch-only plan instead of saying in sync", () => {
|
|
208
|
+
const html = renderSyncConfirm("a1", {
|
|
209
|
+
status: "previewed",
|
|
210
|
+
selectionSwitches: [{ org: "acme", repos: ["acme/a"] }],
|
|
211
|
+
});
|
|
212
|
+
expect(html).toContain('data-sync="confirm"');
|
|
213
|
+
expect(html).not.toContain("in-sync");
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
it("shows the empty-target skip warning with the Uninstall hint", () => {
|
|
217
|
+
const html = renderSyncConfirm("a1", {
|
|
218
|
+
...preview,
|
|
219
|
+
skippedOrgs: [
|
|
220
|
+
{
|
|
221
|
+
org: "empty-org",
|
|
222
|
+
reason:
|
|
223
|
+
"the bound user can push to none of this org's repos, so it stays on All repositories; use Uninstall to remove the agent App from this org",
|
|
224
|
+
},
|
|
225
|
+
],
|
|
226
|
+
});
|
|
227
|
+
expect(html).toContain("empty-org");
|
|
228
|
+
expect(html).toContain("use Uninstall to remove the agent App");
|
|
229
|
+
});
|
|
230
|
+
|
|
190
231
|
it("requires the over-cap checkbox for more than 10 removals", () => {
|
|
191
232
|
const many = Array.from({ length: 11 }, (_, i) => `acme/r${i}`);
|
|
192
233
|
const html = renderSyncConfirm("a1", {
|
|
@@ -397,6 +397,20 @@ describe("admin UI — GitHub sync card (IRM-3.2)", () => {
|
|
|
397
397
|
expect(html).toContain("30 repos have no access answer yet.");
|
|
398
398
|
});
|
|
399
399
|
|
|
400
|
+
it("renders a selection switch row in the Sync confirm fragment", async () => {
|
|
401
|
+
const { app } = setup({
|
|
402
|
+
agentsApi: () =>
|
|
403
|
+
json({
|
|
404
|
+
status: "previewed",
|
|
405
|
+
selectionSwitches: [{ org: "acme", repos: ["acme/a", "acme/b"] }],
|
|
406
|
+
}),
|
|
407
|
+
});
|
|
408
|
+
const html = await (await get(app, "/github-sync/confirm")).text();
|
|
409
|
+
expect(html).toContain('data-list="selection-switches"');
|
|
410
|
+
expect(html).toContain('data-switch-org="acme"');
|
|
411
|
+
expect(html).toContain("keeps 2 repos");
|
|
412
|
+
});
|
|
413
|
+
|
|
400
414
|
it("shows the reason for a skipped preview", async () => {
|
|
401
415
|
const { app } = setup({
|
|
402
416
|
agentsApi: () => json({ status: "skipped", reason: "user not found" }),
|