Public: anyone can read this; the crew can change it.

Every /next decision kind has a test that fails without its 60-second Undo, and the MCP names the same undo #16758

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

scout/forge:scout/11893-every-next-decision-kind-has-a-test-that → main 0 commits fork

  • Merged. scout/11893-every-next-decision-kind-has-a-test-that was merged into main as e78d344.

Review

Sign in to review this change.
2 files changed +51 −2
src/http/mcp/tools/asks_act.ts +6 −2
@@ -20,7 +20,7 @@ export const tool: Tool = {
2020 required: ["action"],
2121 },
2222 doc:
23 "`{ action, items?, repo?, reason?, dryRun? }`: decide asks in bulk (up to 100): `dismiss`, `decline`, `mute`, `ship`, `close` (with `reason`) or `replan`, `listen` with `repo` to unmute one, or `undo` with `operation` to reverse one of your own within a day; planned first, as `POST /api/v1/asks/bulk`",
23 "`{ action, items?, repo?, reason?, dryRun? }`: decide asks in bulk (up to 100): `dismiss`, `decline`, `mute`, `ship`, `close` (with `reason`) or `replan`, `listen` with `repo` to unmute one, or `undo` with `operation` to reverse one of your own within a day; planned first, as `POST /api/v1/asks/bulk`; a reply carries `line` (the page's `Done. Undo`, or why a landed merge has none) and `undo`, the call that takes it back",
2424 writes: true,
2525 dryByDefault: true,
2626 async run(ctx, user, args) {
@@ -55,6 +55,10 @@ export const tool: Tool = {
5555 : bad(plan.error.code, plan.error.message);
5656 }
5757 const done = await applyAsksBulk(ctx.app, user, args["action"], args["items"], args["reason"]);
58 return done.ok ? good({ ...done.value, receipt: receiptOf(done.value) }) : bad(done.error.code, done.error.message);
58 if (!done.ok) return bad(done.error.code, done.error.message);
59 // The page's Undo button, as the call that presses it: none when a landed merge cannot be taken
60 // back.
61 const undo = done.value.reversible ? { undo: { action: "undo", operation: done.value.id } } : {};
62 return good({ ...done.value, ...undo, receipt: receiptOf(done.value) });
5963 },
6064 };
test/asks-bulk.test.ts +45
@@ -964,6 +964,51 @@ describe("acting on many asks at once", () => {
964964 });
965965 });
966966
967 describe("the MCP names the same Done line and undo as /next (#11893)", () => {
968 const call = async (args: Record<string, unknown>) => {
969 const res = await fetch(`${servers.url}/mcp`, {
970 method: "POST",
971 headers: { "content-type": "application/json", accept: "application/json, text/event-stream", authorization: `Bearer ${aliceRw}` },
972 body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "tools/call", params: { name: "asks_act", arguments: args } }),
973 });
974 const body = (await res.json()) as { result: { isError?: boolean; content: { text: string }[] } };
975 const text = body.result.content[0]!.text;
976 return body.result.isError === true ? { isError: true, text, value: undefined as any } : { isError: false, text, value: JSON.parse(text) as any };
977 };
978 const decide = async (action: string, title: string, reason?: string) => {
979 const pull = await greenPull(open, title);
980 const ask = items(alice).filter((i) => i.endsWith(pull.id));
981 const done = await call({ action, items: ask, ...(reason === undefined ? {} : { reason }), dryRun: false });
982 return { pull, done: done.value };
983 };
984 const stateOf = (id: string) => getIssueById(app.db, id)!.state;
985
986 for (const [kind, action, reason] of [["decline", "decline", undefined], ["say", "close", "not now"]] as const) {
987 test(`${kind}: the reply says Done. Undo and names the undo; taking it restores the pull`, async () => {
988 const { pull, done } = await decide(action, `MCP ${kind}`, reason);
989 expect(done.line).toBe(DONE_UNDO);
990 expect(done.undo).toEqual({ action: "undo", operation: done.id });
991 // A decline leaves the pull open and takes the card off the board; a close shuts the pull.
992 if (action === "close") expect(stateOf(pull.id)).not.toBe("open");
993 else expect(items(alice).some((i) => i.endsWith(pull.id))).toBe(false);
994 const undone = await call({ action: "undo", operation: done.undo.operation, dryRun: false });
995 expect(undone.value.undoOf).toBe(done.id);
996 expect(stateOf(pull.id)).toBe("open");
997 expect(items(alice).some((i) => i.endsWith(pull.id))).toBe(true);
998 });
999 }
1000
1001 test("ship: a landed merge says why there is no Undo, names none, and refuses one", async () => {
1002 const { pull, done } = await decide("ship", "MCP ship");
1003 expect(done.line).toBe(DONE_NO_UNDO);
1004 expect(done.undo).toBeUndefined();
1005 expect(stateOf(pull.id)).not.toBe("open");
1006 const refused = await call({ action: "undo", operation: done.id, dryRun: false });
1007 expect(refused.isError).toBe(true);
1008 expect(stateOf(pull.id)).not.toBe("open");
1009 });
1010 });
1011
9671012 test("undoing a bulk mute leaves a mute made elsewhere", () => {
9681013 const item = `repo:${quiet.id}`;
9691014 recordInteraction(app.db, { viewerId: alice.id, itemId: item, kind: "muted", repoId: quiet.id, actorId: null });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs