MCPcopy Create free account
hub / github.com/backnotprop/plannotator / markGhFilesViewed

Function markGhFilesViewed

packages/shared/pr-github.ts:604–641  ·  view source on GitHub ↗
(
  runtime: PRRuntime,
  ref: GhPRRef,
  prNodeId: string,
  filePaths: string[],
  viewed: boolean,
)

Source from the content-addressed store, hash-verified

602 * Throws only if ALL mutations fail.
603 */
604export async function markGhFilesViewed(
605 runtime: PRRuntime,
606 ref: GhPRRef,
607 prNodeId: string,
608 filePaths: string[],
609 viewed: boolean,
610): Promise<void> {
611 if (filePaths.length === 0) return;
612
613 const mutationName = viewed ? "markFileAsViewed" : "unmarkFileAsViewed";
614 const mutation = `
615 mutation($id: ID!, $path: String!) {
616 ${mutationName}(input: { pullRequestId: $id, path: $path }) {
617 clientMutationId
618 }
619 }
620 `;
621
622 const results = await Promise.allSettled(
623 filePaths.map((path) =>
624 runtime.runCommandWithInput
625 ? runtime.runCommand("gh", hostnameArgs(ref.host, [
626 "api", "graphql",
627 "-f", `query=${mutation}`,
628 "-F", `id=${prNodeId}`,
629 "-F", `path=${path}`,
630 ]))
631 : Promise.reject(new Error("Runtime does not support commands")),
632 ),
633 );
634
635 const failures = results.filter((r): r is PromiseRejectedResult => r.status === "rejected");
636 if (failures.length === filePaths.length) {
637 throw new Error(
638 `Failed to ${mutationName} all files: ${failures[0].reason}`,
639 );
640 }
641}
642
643// --- Submit PR Review ---
644

Callers 1

markPRFilesViewedFunction · 0.90

Calls 1

hostnameArgsFunction · 0.85

Tested by

no test coverage detected