@andrioid/paseo-attention-span 0.6.1 → 0.7.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 (33) hide show
  1. package/client/attention-screen.tsx +1 -1
  2. package/client/item-actions.ts +25 -1
  3. package/client/pickers.tsx +4 -3
  4. package/docs/architecture.md +2 -2
  5. package/docs/screenshots/desktop-dark-doing-acknowledge.png +0 -0
  6. package/docs/screenshots/desktop-dark-doing-clear.png +0 -0
  7. package/docs/screenshots/desktop-dark-doing-issue-sheet.png +0 -0
  8. package/docs/screenshots/desktop-dark-doing-reviewers.png +0 -0
  9. package/docs/screenshots/desktop-dark-doing-sheet.png +0 -0
  10. package/docs/screenshots/desktop-dark-doing-wrap-dirty.png +0 -0
  11. package/docs/screenshots/desktop-dark-doing-wrap-multi.png +0 -0
  12. package/docs/screenshots/desktop-dark-doing.png +0 -0
  13. package/docs/screenshots/desktop-dark-history-filtered.png +0 -0
  14. package/docs/screenshots/desktop-dark-history.png +0 -0
  15. package/docs/screenshots/desktop-dark-next-up-setup.png +0 -0
  16. package/docs/screenshots/desktop-dark-next-up.png +0 -0
  17. package/docs/screenshots/desktop-dark-settings.png +0 -0
  18. package/docs/screenshots/desktop-dark-setup.png +0 -0
  19. package/docs/screenshots/desktop-dark-waiting-too-long.png +0 -0
  20. package/docs/screenshots/desktop-dark-waiting.png +0 -0
  21. package/docs/screenshots/phone-dark-doing.png +0 -0
  22. package/docs/screenshots/phone-dark-history.png +0 -0
  23. package/docs/screenshots/phone-light-next-up-filtered.png +0 -0
  24. package/package.json +1 -1
  25. package/requirements.yaml +2 -0
  26. package/server/classify.ts +15 -3
  27. package/server/context.ts +95 -3
  28. package/server/fixture.ts +5 -0
  29. package/server/github-types.ts +2 -1
  30. package/server/queries.ts +1 -1
  31. package/shared/attention.ts +13 -0
  32. package/shared/item-view.ts +5 -4
  33. package/shared/prompts.ts +39 -22
@@ -283,7 +283,7 @@ function AttentionList({
283
283
  />
284
284
  ) : null}
285
285
  {newIssue ? <NewIssueSheet request={newIssue} view={view} onView={attention.setView} onStarted={act.started} onClose={() => setNewIssue(null)} /> : null}
286
- {act.options ? <SessionOptions spec={act.options} config={view.config} started={act.started} onClose={act.closeOptions} /> : null}
286
+ {act.options ? <SessionOptions spec={act.options} config={view.config} started={act.startedOn} onClose={act.closeOptions} /> : null}
287
287
  {act.placing ? <CodeRepoPicker issueRepo={act.placing.target.repo} missing={act.placing.missing} onPick={act.place} onClose={act.cancelPlacing} /> : null}
288
288
  </ScrollView>
289
289
  );
@@ -72,6 +72,14 @@ export interface Actions {
72
72
  started: (agentId: string) => Promise<void>;
73
73
  }
74
74
 
75
+ // A session just started on an item.
76
+ export interface Started {
77
+ agentId: string;
78
+ itemKey: string;
79
+ kind: SessionKind;
80
+ target: Target;
81
+ }
82
+
75
83
  function issueTarget(issue: NextUpIssue): Target {
76
84
  return { kind: "issue", repo: issue.repo, number: issue.number, title: issue.title, url: issue.url, defaultBranch: issue.defaultBranch };
77
85
  }
@@ -145,11 +153,25 @@ export function useItemActions(attention: ReturnType<typeof useAttention>, navig
145
153
  else toast.show("Session started. Open it from the sidebar.", { variant: "success" });
146
154
  }
147
155
 
156
+ // A session started from somewhere with no card for it (a new issue, feedback): open it, or it'd be hard to find.
148
157
  async function started(agentId: string) {
149
158
  await queryClient.invalidateQueries({ queryKey: AGENTS_QUERY_KEY });
150
159
  openAgent(agentId);
151
160
  }
152
161
 
162
+ // A session started on an item leaves me here, so I can start several in a row; the item's card offers Open session
163
+ // [SES-10]. The session goes on the list at once, so the card offers it even if the poll after fails, rather than Start
164
+ // again; the next poll that succeeds replaces it with Paseo's own.
165
+ async function startedOn({ agentId, itemKey, kind, target }: Started) {
166
+ queryClient.setQueryData<AgentSummary[]>(AGENTS_QUERY_KEY, (agents = []) =>
167
+ agents.some((agent) => agent.id === agentId)
168
+ ? agents
169
+ : [...agents, { id: agentId, itemKey, kind, status: "running", requiresAttention: false, title: null, workspaceId: null, lastActivityAt: new Date().toISOString() }],
170
+ );
171
+ await queryClient.invalidateQueries({ queryKey: AGENTS_QUERY_KEY });
172
+ toast.show(`Session started on #${target.number}`, { variant: "success" });
173
+ }
174
+
153
175
  // One tap: start a session with defaults [SES-01]. An open one is offered first, by the card [SES-03].
154
176
  async function startWithDefaults(itemKey: string, kind: SessionKind, target: Target, before?: () => Promise<unknown>) {
155
177
  if (!view) return;
@@ -163,7 +185,8 @@ export function useItemActions(attention: ReturnType<typeof useAttention>, navig
163
185
  await before?.();
164
186
  const { context } = await fetchContext({ kind, target });
165
187
  const prompt = renderPrompt(kind, target, context, config);
166
- await started(await startSession(paseo, { itemKey, kind, target, prompt, config, fetchProviders, checkout }));
188
+ const agentId = await startSession(paseo, { itemKey, kind, target, prompt, config, fetchProviders, checkout });
189
+ await startedOn({ agentId, itemKey, kind, target });
167
190
  }
168
191
 
169
192
  function place(codeRepo: string) {
@@ -352,6 +375,7 @@ export function useItemActions(attention: ReturnType<typeof useAttention>, navig
352
375
  fetchDetails,
353
376
  openAgent,
354
377
  started,
378
+ startedOn,
355
379
  archiveRows,
356
380
  archiveWorktree,
357
381
  dismissKept: (row: KeptRow) => void run(`kept:${row.workspaceId}`, "Dismiss", async () => attention.setView(await dismissKept({ workspaceId: row.workspaceId }))),
@@ -8,7 +8,7 @@ import type { AttentionConfig } from "../shared/config";
8
8
  import { ago } from "../shared/format";
9
9
  import { renderPrompt } from "../shared/prompts";
10
10
  import * as rpc from "../shared/rpc";
11
- import type { OptionsSpec } from "./item-actions";
11
+ import type { OptionsSpec, Started } from "./item-actions";
12
12
  import { branchWorkspaces, findCheckout, githubProjects, listProfiles, noProjectMessage, resolveAgentConfig, startSession, useStartRpcs } from "./sessions";
13
13
  import { Dialog } from "./sheet";
14
14
  import { Avatar, Button, CheckRow, Loading, TablerIcon, Toggle, useStyles } from "./ui";
@@ -137,7 +137,7 @@ export function ReviewerSheet({
137
137
  }
138
138
 
139
139
  // Session options in a modal: a bottom sheet on phones [SES-02].
140
- export function SessionOptions({ spec, config, started, onClose }: { spec: OptionsSpec; config: AttentionConfig; started: (agentId: string) => Promise<void>; onClose: () => void }) {
140
+ export function SessionOptions({ spec, config, started, onClose }: { spec: OptionsSpec; config: AttentionConfig; started: (started: Started) => Promise<void>; onClose: () => void }) {
141
141
  const styles = useStyles();
142
142
  const paseo = usePaseo();
143
143
  const toast = useToast();
@@ -169,7 +169,8 @@ export function SessionOptions({ spec, config, started, onClose }: { spec: Optio
169
169
  setStarting(true);
170
170
  try {
171
171
  await spec.before?.();
172
- await started(await startSession(paseo, { itemKey, kind, target, prompt: prompt ?? data.prompt, config: config, fetchProviders: fetchProviders, checkout: data.checkout, profileId, workspaceId }));
172
+ const agentId = await startSession(paseo, { itemKey, kind, target, prompt: prompt ?? data.prompt, config: config, fetchProviders: fetchProviders, checkout: data.checkout, profileId, workspaceId });
173
+ await started({ agentId, itemKey, kind, target });
173
174
  onClose();
174
175
  } catch (error) {
175
176
  toast.error(`Starting the session failed: ${(error as Error).message}`);
@@ -77,7 +77,7 @@ Top to bottom. Each item appears once, under its most urgent reason [ATT-02]. `s
77
77
  |---|---|
78
78
  | Waiting for your reply | Open threads with a mention waiting on me [MEN-01] |
79
79
  | Answered | Issues and PRs I opened where a person commented in the conversation after me, within `mentionDays` (default 30), without mentioning me, and I haven't 👍'd it; opening a thread counts as my last word until I comment. Replies after mine on other people's threads count only with `followThreads` on (Settings → Replies → Follow threads I've commented on, off by default); then my comment must be among the thread's last 10. Reply and Acknowledge clear it, and so does Dismiss until someone comments again [ATT-16, ATT-17, MEN-02] |
80
- | Review requested | PRs requesting my review by name, not via a team [REV-01] |
80
+ | Review requested | PRs requesting my review by name, not via a team [REV-01]. One asked again after I reviewed it has a *review again* chip: GitHub drops my request once I review, so a request alongside a review of mine in `latestReviews` is a re-request, and a push without one doesn't list it [REV-02] |
81
81
  | CI failing | My PRs with failing checks [PRS-01] |
82
82
  | Changes requested | My PRs with requested changes or unresolved threads [PRS-02] |
83
83
  | Ready to merge | My approved PRs without conflicts or failing checks, that GitHub's rules let me merge [PRS-03, PRS-13] |
@@ -130,7 +130,7 @@ An agent icon (Tabler's `message-ai`, a speech bubble with "AI") marks every act
130
130
  |---|---|---|
131
131
  | Reply ↗ | Mention waiting | Opens the comment on GitHub [ATT-12] |
132
132
  | Acknowledge | Mention waiting | Lists every waiting comment in full, rendered as Markdown with Paseo's renderer (cut after whole blocks, up to about 4,000 characters), all ticked; 👍 on the ones I keep ticked (`addReaction`), which clears them [MEN-07]. Undo removes them. |
133
- | Review *(agent)* | Review requested | Session in a PR checkout using the review profile [SES-01]. For a stack, "Review stack": one session in a checkout of the stack's top, whose prompt lists every branch and asks for a review of only the PRs requesting mine, each against its own base, with their descriptions and recent comments as context [ATT-04] |
133
+ | Review *(agent)* | Review requested | Session in a PR checkout using the review profile [SES-01]. For a stack, "Review stack": one session in a checkout of the stack's top, whose prompt lists every branch and asks for a review of only the PRs requesting mine, each against its own base, with their descriptions and recent comments as context [ATT-04]. Asked again, it's "Review again": its stack entry carries when and on which commit I reviewed it (`latestReviews { commit { oid } }`, in the same search). A new session's context adds, per PR asked again, what I wrote in my reviews (asked for by my login, so others' can't crowd them out), the threads I'm in with their replies and whether they're resolved, and how to find the commits since: `git diff <reviewed>..<head>`, or the author's own commits and the merge's conflict resolutions when the base was merged in since, `git range-diff <reviewed>...<head>` after a rebase or force-push, ignoring commits that came with the base or a rebased parent, or the whole diff when the commit is gone; the built-in Review prompt asks about what changed and how each earlier comment was taken up. With a Review session still open, the button opens it, as for any session on an item [SES-03]; a new one gets the context above [REV-02] |
134
134
  | Fix CI / Address comments *(agent)* | CI failing / changes requested | Session with the failing log or unresolved threads in the prompt [SES-04] |
135
135
  | Rerun failed jobs | CI failing, in the sheet | `gh run rerun --failed` for each failing GitHub Actions run of the PR, or of every PR of mine in its stack. Its line, fetched when the sheet opens, says in one line how many failed, which (a matrix's jobs as one, "e2e ×3"; a job alone by its full name), and whether they were rerun before (`gh api …/runs/<id>`), in amber once they were, a hint they may not be flaky: "7 failed · lint, e2e ×3, unit ×2 · ↻ rerun once". Hovering it lists every check by full name; on phones it wraps to two lines instead. Other status checks can't be rerun from here, so they're dimmer. It can be pressed before the checks are in: the sheet closes, and it reruns once they are (`shared/checks.ts`) [PRS-09]. |
136
136
  | Update branch | Behind with no conflicts, not stacked | `updatePullRequestBranch` (rebase) [UPS-03] |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@andrioid/paseo-attention-span",
3
- "version": "0.6.1",
3
+ "version": "0.7.0",
4
4
  "description": "For when your attention is spread thin: the GitHub issues and pull requests waiting on you, grouped by why, with one-tap Paseo sessions.",
5
5
  "license": "MIT",
6
6
  "repository": {
package/requirements.yaml CHANGED
@@ -50,6 +50,7 @@ functional:
50
50
  reviews:
51
51
  As a developer, I can:
52
52
  REV-01: see pull requests where my review is requested by name; so that I don't hold up others.
53
+ REV-02: see a pull request whose review was re-requested after I reviewed it marked "Review again", with its Review session given what I said last time and focused on the commits since my last review; so that a second look costs less than the first.
53
54
  own_pull_requests:
54
55
  As a developer, I can:
55
56
  PRS-01: see my pull requests whose checks fail; so that I fix them before they block review or merge.
@@ -87,6 +88,7 @@ functional:
87
88
  SES-07: start a session on an issue in the repository its code lives in, chosen right there the first time; so that issues kept in a separate repository work without editing files.
88
89
  SES-08: see sessions started outside Attention Span on the item of the pull request their workspace is linked to, or of the session whose worktree they share, or of my merged or closed pull request whose branch their worktree is on, as "Continue session", including finished work in Wrap up; so that I don't start duplicate work and can clean up what I left open.
89
90
  SES-09: tell sessions reviewing someone else's pull request from work on my own in Paseo's sidebar, by a name like "Review PR 123: title"; so that I know which kind of work a workspace holds.
91
+ SES-10: stay where I am when I start a session on an item, told it started, with the item offering to open it; so that I can start several in a row without finding my place again.
90
92
  next_up:
91
93
  As a developer, I can:
92
94
  NXT-01: see open issues nobody is assigned to, apart from the work that needs me; so that I can get an idea of what to do next.
@@ -4,6 +4,7 @@ import {
4
4
  type Attention,
5
5
  type Chip,
6
6
  type Item,
7
+ type LastReview,
7
8
  type NextUpIssue,
8
9
  type IssueProject,
9
10
  type Person,
@@ -297,14 +298,22 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
297
298
  };
298
299
  };
299
300
 
300
- // Others' PRs in a stack that ask for my review: one Review for them all [REV-01, ATT-04].
301
+ // My last review of a PR asking for it again. GitHub drops my request once I review, so a request alongside a review of
302
+ // mine is a re-request; a push since then without one doesn't list it at all [REV-02].
303
+ const lastReview = (pr: PullRequestNode): LastReview | undefined => {
304
+ const review = pr.latestReviews.nodes.find((r) => isMe(r.author));
305
+ if (!review) return undefined;
306
+ return { at: review.submittedAt ?? EPOCH, ...(review.commit?.oid ? { oid: review.commit.oid } : {}) };
307
+ };
308
+
309
+ // Others' PRs in a stack that ask for my review: one Review for them all [REV-01, ATT-04], marked when it's asked again [REV-02].
301
310
  const reviewPart = (stack: PullRequestNode[]): Part => {
302
311
  const waiting = stack.map((pr) => mentions.get(prKey(pr))).find(Boolean);
303
312
  const lastCommitAt = latest(...stack.map((pr) => state(pr).lastCommitAt));
304
313
  return {
305
314
  section: waiting ? "reply" : "review",
306
315
  actions: waiting ? [...replyActions(waiting), "review"] : ["review"],
307
- chips: stack.some((pr) => state(pr).ciFailing) ? [chip("CI failing", "bad")] : [],
316
+ chips: [...(stack.some(lastReview) ? [chip("review again")] : []), ...(stack.some((pr) => state(pr).ciFailing) ? [chip("CI failing", "bad")] : [])],
308
317
  person: waiting ?? author(stack[0].author, lastCommitAt),
309
318
  othersActivityAt: latest(...stack.map((pr) => state(pr).othersActivityAt), lastCommitAt, waiting?.since),
310
319
  };
@@ -351,7 +360,10 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
351
360
  headRefOid: pr.headRefOid,
352
361
  defaultBranch: pr.repository.defaultBranchRef?.name,
353
362
  mergeMethod: mergeMethodFor(pr, config),
354
- stack: stack.map((p) => ({ number: p.number, head: p.headRefName, base: p.baseRefName, ...(isOwn(p) ? {} : { review: true as const }) })),
363
+ stack: stack.map((p) => {
364
+ const reviewed = isOwn(p) ? undefined : lastReview(p);
365
+ return { number: p.number, head: p.headRefName, base: p.baseRefName, ...(isOwn(p) ? {} : { review: true as const }), ...(reviewed ? { reviewed } : {}) };
366
+ }),
355
367
  });
356
368
 
357
369
  // One item per issue: my PRs grouped under the issue they work on [ATT-03]. Otherwise one per unit, led by its bottom PR.
package/server/context.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ownStack, type StackPr, type Target } from "../shared/attention";
1
+ import { ownStack, reviewAgain, type StackPr, type Target } from "../shared/attention";
2
2
  import type { SessionKind } from "../shared/config";
3
3
  import { graphql, runGh } from "./gh";
4
4
 
@@ -49,14 +49,106 @@ export async function sessionContext(kind: SessionKind, target: Target): Promise
49
49
  if (kind === "address") return reviewFeedback(target);
50
50
 
51
51
  // Review of a stack: every branch, with a link to each PR asking for my review; the agent reads what it needs [ATT-04].
52
+ // Asked again, what I said last time and what changed since, on each PR I reviewed [REV-02].
52
53
  const stack = target.stack ?? [];
54
+ const again = kind === "review" ? reviewAgainContext(target) : Promise.resolve("");
53
55
  if (kind === "review" && stack.length > 1) {
54
56
  const lines = stack.map((pr) => `${branchLine(pr)}${pr.review ? `, review requested: https://github.com/${target.repo}/pull/${pr.number}` : ", mine"}`);
55
- return `Stack, bottom first:\n${lines.join("\n")}`;
57
+ return join(`Stack, bottom first:\n${lines.join("\n")}`, await again);
56
58
  }
57
59
 
58
60
  // review, start: the whole description and the latest comments.
59
- return conversation(ref, target);
61
+ const [talk, since] = await Promise.all([conversation(ref, target), again]);
62
+ return join(talk, since);
63
+ }
64
+
65
+ const join = (...parts: string[]) => parts.filter(Boolean).join("\n\n");
66
+
67
+ const MY_REVIEWS = 5;
68
+ const MY_THREADS = 100;
69
+
70
+ // For each PR asking for my review again: my last reviews and the threads I'm in, with what came after, and how to find
71
+ // the commits since the one I reviewed, whether the branch moved on, was rebased, or lost it [REV-02]. Empty when none
72
+ // asks again.
73
+ export async function reviewAgainContext(target: Target): Promise<string> {
74
+ const prs = reviewAgain(target);
75
+ const named = (target.stack?.length ?? 0) > 1;
76
+ const blocks = await Promise.all(prs.map((pr) => lastReview(target.repo, pr, named)));
77
+ return join(...blocks);
78
+ }
79
+
80
+ async function lastReview(repo: string, stacked: StackPr, named: boolean): Promise<string> {
81
+ type Author = { login: string } | null;
82
+ type Review = { author: Author; state: string; body: string; submittedAt: string | null; commit: { oid: string } | null };
83
+ type Thread = { isResolved: boolean; path: string; line: number | null; comments: { totalCount: number; nodes: { author: Author; body: string }[] } };
84
+ const [owner, name] = repo.split("/");
85
+ const { number } = stacked;
86
+ // My reviews only, by login, so others' reviews since can't crowd mine out; submitted ones only, as a review I've
87
+ // started and not sent isn't where I left off.
88
+ const { login } = (await graphql<{ viewer: { login: string } }>("query { viewer { login } }")).viewer;
89
+ const data = await graphql<{
90
+ repository: { pullRequest: { url: string; baseRefName: string; headRefOid: string; reviews: { nodes: Review[] }; reviewThreads: { totalCount: number; nodes: Thread[] } } };
91
+ }>(
92
+ `query($owner: String!, $name: String!, $number: Int!, $login: String!) {
93
+ repository(owner: $owner, name: $name) {
94
+ pullRequest(number: $number) {
95
+ url baseRefName headRefOid
96
+ reviews(last: ${MY_REVIEWS * 4}, author: $login, states: [APPROVED, CHANGES_REQUESTED, COMMENTED, DISMISSED]) { nodes { author { login } state body submittedAt commit { oid } } }
97
+ reviewThreads(first: ${MY_THREADS}) { totalCount nodes { isResolved path line comments(first: ${THREAD_COMMENTS}) { totalCount nodes { author { login } body } } } }
98
+ }
99
+ }
100
+ }`,
101
+ { owner, name, number, login },
102
+ );
103
+ const me = login.toLowerCase();
104
+ const mine = (author: Author) => author?.login.toLowerCase() === me;
105
+ const pr = data.repository.pullRequest;
106
+ const reviews = pr.reviews.nodes.filter((r) => mine(r.author));
107
+ const latest = reviews.at(-1);
108
+ const title = `Your last review${named ? ` of #${number}` : ""}`;
109
+ // Where GitHub's answer has none, the list's own reading of it still says when, and on which commit.
110
+ const reviewed = latest ? latest.commit?.oid : stacked.reviewed?.oid;
111
+ const when = latest ? `${latest.state.toLowerCase()}${latest.submittedAt ? ` on ${latest.submittedAt}` : ""}` : `on ${stacked.reviewed?.at ?? "an earlier date"}`;
112
+
113
+ const who = (author: Author) => (mine(author) ? "you" : `@${author?.login ?? "ghost"}`);
114
+ const said = reviews
115
+ .filter((r) => r.body.trim())
116
+ .slice(-MY_REVIEWS)
117
+ .map((r) => `- ${r.state.toLowerCase()}${r.submittedAt ? `, ${r.submittedAt}` : ""}: ${clip(r.body, 1500)}`);
118
+ const threads = pr.reviewThreads.nodes
119
+ .filter((t) => t.comments.nodes.some((c) => mine(c.author)))
120
+ .map((t) => {
121
+ const comments = t.comments.nodes.map((c) => ` ${who(c.author)}: ${clip(c.body, 800).replace(/\n/g, "\n ")}`);
122
+ const more = notShown(t.comments.totalCount - t.comments.nodes.length, "more comments", pr.url);
123
+ return [`- ${t.path}${t.line ? `:${t.line}` : ""} (${t.isResolved ? "resolved" : "unresolved"})`, ...comments, more && ` ${more}`].filter(Boolean).join("\n");
124
+ });
125
+ // A long thread I'm not in among its first comments may still have mine further down; say how many weren't read through.
126
+ const longThreads = pr.reviewThreads.nodes.filter((t) => t.comments.totalCount > t.comments.nodes.length && !t.comments.nodes.some((c) => mine(c.author))).length;
127
+ const unread = longThreads ? `${longThreads === 1 ? "1 long review thread was" : `${longThreads} long review threads were`} read only to comment ${THREAD_COMMENTS} and may have yours further down; see ${pr.url}` : "";
128
+ const laterThreads = notShown(pr.reviewThreads.totalCount - pr.reviewThreads.nodes.length, "more review threads, some maybe yours", pr.url);
129
+
130
+ return join(
131
+ `${title}: ${when}.\n${sinceSteps(reviewed, pr.headRefOid, pr.baseRefName)}`,
132
+ said.length ? `What you wrote in your reviews:\n${said.join("\n")}` : "",
133
+ threads.length ? `Review threads you're in, with the replies:\n${threads.join("\n")}` : "",
134
+ unread,
135
+ laterThreads,
136
+ );
137
+ }
138
+
139
+ // How to find the commits since the one I reviewed: they follow it, perhaps with the base merged in, or the branch was
140
+ // rebased or force-pushed past it. The
141
+ // rebase case compares the two versions from where they meet, as the base may have moved too, a stack's parent with it.
142
+ function sinceSteps(reviewed: string | undefined, head: string, base: string): string {
143
+ if (!reviewed) return `GitHub no longer has the commit you reviewed, so review the whole diff against ${base} and say you couldn't narrow it down.`;
144
+ if (reviewed === head) return `No commits since: the head is still ${head}. What's new is in the replies below.`;
145
+ return [
146
+ `You reviewed commit ${reviewed}; the head is now ${head}.`,
147
+ `- \`git fetch origin ${reviewed} ${head}\``,
148
+ `- If \`git merge-base --is-ancestor ${reviewed} ${head}\`: the new commits are \`git log ${reviewed}..${head}\`, their changes \`git diff ${reviewed}..${head}\`. If one of them merges ${base} in, what came with it isn't the PR's: review the author's own commits (\`git log --first-parent --no-merges ${reviewed}..${head}\`, each with \`git show\`) and the merge's conflict resolutions (\`git show --remerge-diff <merge>\`) instead of the whole diff.`,
149
+ `- Otherwise the branch was rebased or force-pushed: compare the two versions with \`git range-diff ${reviewed}...${head}\`. Commits that came with ${base} or a rebased parent show up too, as added, dropped or matched; leave those out.`,
150
+ `- If ${reviewed} can't be fetched, review the whole diff against ${base} and say you couldn't narrow it down.`,
151
+ ].join("\n");
60
152
  }
61
153
 
62
154
  const branchLine = (pr: StackPr) => `- #${pr.number}: ${pr.head} (on ${pr.base})`;
package/server/fixture.ts CHANGED
@@ -223,6 +223,9 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
223
223
  // Bob's stack asking for my review: one item with one Review [ATT-04].
224
224
  pr(196, { title: "Price rules: data model", author: bob, headRefName: "rules-1", commits: commit("SUCCESS", 0.4) }),
225
225
  pr(197, { title: "Price rules: admin screen", author: bob, baseRefName: "rules-1", headRefName: "rules-2", commits: commit("SUCCESS", 0.3) }),
226
+ // Asked again after I reviewed: one with the Review session still open, one without [REV-02].
227
+ pr(198, { title: "Show shipping estimates at checkout", author: alice, latestReviews: { nodes: [{ author: me, state: "CHANGES_REQUESTED", submittedAt: daysAgo(2), commit: { oid: "oid198old" } }] }, commits: commit("SUCCESS", 0.2) }),
228
+ pr(199, { title: "Group order emails by customer", author: bob, latestReviews: { nodes: [{ author: me, state: "COMMENTED", submittedAt: daysAgo(3), commit: { oid: "oid199old" } }] }, commits: commit("SUCCESS", 0.5) }),
226
229
  ],
227
230
  mentions: [
228
231
  mention(95, [comment(bob, "@me should reminders go out on weekends too, or only on workdays?", 0.5)], { title: "Customers forget unpaid invoices", author: bob }),
@@ -381,6 +384,7 @@ export function fixtureGotIt(now: Date): string[] {
381
384
  // #113 waits on CI while its Fix CI session works, though Fix CI isn't one of its actions any more.
382
385
  // #120's was started outside Attention Span, in a workspace Paseo linked to the PR, so it has no kind [SES-08].
383
386
  // #197's too, so it shows on its stack, led by #196 [ATT-04].
387
+ // #198 is asked to be reviewed again while its Review session is still open: the card opens it [REV-02].
384
388
  const agent = (
385
389
  id: string,
386
390
  itemKey: string,
@@ -421,6 +425,7 @@ export const FIXTURE_AGENTS: AgentSummary[] = [
421
425
  agent("agent-113", `${REPO}#113`, "fix", "running", 2),
422
426
  agent("agent-120", `${REPO}#120`, undefined, "running", 3),
423
427
  agent("agent-197", `${REPO}#197`, undefined, "idle", 15),
428
+ agent("agent-198", `${REPO}#198`, "review", "idle", 2880, false, undefined, "Review PR 198: Show shipping estimates at checkout"),
424
429
  // Wrap up: finished work whose sessions are all idle [ATT-22].
425
430
  agent("agent-183", `${REPO}#183`, "fix", "idle", 20, false, sessionWorkspace("retry-webhooks", false, 0), "Retry webhooks"),
426
431
  // Its sheet counts lines and names the terminals archiving closes, as Paseo's own sheet would.
@@ -61,7 +61,8 @@ export interface PullRequestNode {
61
61
  commits: Nodes<{ commit: { committedDate: string; statusCheckRollup: { state: string } | null } }>;
62
62
  // A person, or a team by its "org/slug"; null when it can't be seen.
63
63
  reviewRequests: Nodes<{ requestedReviewer: RequestedReviewer | null }>;
64
- latestReviews: Nodes<{ author: Actor | null; state: string; submittedAt: string | null }>;
64
+ // The commit each review was made on, so a review asked for again can start from it [REV-02].
65
+ latestReviews: Nodes<{ author: Actor | null; state: string; submittedAt: string | null; commit?: { oid: string } | null }>;
65
66
  reviewThreads: Nodes<ReviewThread>;
66
67
  comments: Nodes<Comment>;
67
68
  }
package/server/queries.ts CHANGED
@@ -101,7 +101,7 @@ const FRAGMENTS: Record<string, string> = {
101
101
  closingIssuesReferences(first: 5) { nodes { number title url repository { nameWithOwner } } }
102
102
  commits(last: 1) { nodes { commit { committedDate statusCheckRollup { state } } } }
103
103
  reviewRequests(first: 5) { nodes { requestedReviewer { ... on User { ...author } ... on Bot { ...author } ... on Team { __typename combinedSlug avatarUrl } } } }
104
- latestReviews(first: 10) { nodes { author { ...author } state submittedAt } }
104
+ latestReviews(first: 10) { nodes { author { ...author } state submittedAt commit { oid } } }
105
105
  reviewThreads(last: 30) {
106
106
  nodes {
107
107
  isResolved
@@ -181,6 +181,19 @@ export interface StackPr {
181
181
  base: string;
182
182
  // Someone else's, asking for my review; the rest are mine.
183
183
  review?: true;
184
+ // Asking for my review again after I reviewed it: when, and on which commit [REV-02].
185
+ reviewed?: LastReview;
186
+ }
187
+
188
+ export interface LastReview {
189
+ at: string;
190
+ // The commit my review was made on; missing when GitHub no longer has it.
191
+ oid?: string;
192
+ }
193
+
194
+ // The PRs in a target's stack asking for my review again [REV-02].
195
+ export function reviewAgain(target: Pick<Target, "stack">): StackPr[] {
196
+ return (target.stack ?? []).filter((pr) => pr.review && pr.reviewed);
184
197
  }
185
198
 
186
199
  // The PRs of mine in a target's stack: what Rebase, Refresh and Rerun act on. Others' branches are never pushed [ATT-04].
@@ -1,6 +1,6 @@
1
1
  // What an item's card and sheet say and offer, as plain data: client/attention-screen.tsx draws it and wires the presses
2
2
  // [ATT-05, ATT-06].
3
- import { type ActionId, type AgentSummary, type AttentionView, type Chip, type FailingChecks, isWorking, type Item, looseSessions, ownStack, SECTIONS, type SubRow, type TabId, type WaitingOn, type WrapItem } from "./attention";
3
+ import { type ActionId, type AgentSummary, type AttentionView, type Chip, type FailingChecks, isWorking, type Item, looseSessions, ownStack, reviewAgain, SECTIONS, type SubRow, type TabId, type WaitingOn, type WrapItem } from "./attention";
4
4
  import { summarizeRerun } from "./checks";
5
5
  import type { SessionKind } from "./config";
6
6
  import { ago } from "./format";
@@ -28,7 +28,7 @@ export function actionLabel(action: ActionId, item: Item): string {
28
28
  return {
29
29
  reply: "Reply ↗",
30
30
  acknowledge: "Acknowledge",
31
- review: (item.target.stack?.length ?? 0) > 1 ? "Review stack" : "Review",
31
+ review: `${(item.target.stack?.length ?? 0) > 1 ? "Review stack" : "Review"}${reviewAgain(item.target).length ? " again" : ""}`,
32
32
  fix: "Fix CI",
33
33
  rerun: "Rerun failed jobs",
34
34
  address: "Address comments",
@@ -57,8 +57,9 @@ export function actionDetail(action: Exclude<ActionId, "rerun">, item: Item): st
57
57
  reply: item.person ? `Opens ${item.person.login}'s comment on GitHub` : "Opens it on GitHub",
58
58
  acknowledge:
59
59
  comments.length === 1 ? `Reacts to ${comments[0].author}'s comment, which clears it` : `Pick which of the ${comments.length} waiting comments to react to`,
60
- review:
61
- (target.stack?.length ?? 0) > 1
60
+ review: reviewAgain(target).length
61
+ ? "An agent reviews what changed since your last review and checks your earlier comments. Nothing is posted"
62
+ : (target.stack?.length ?? 0) > 1
62
63
  ? `An agent reviews ${asking.map((p) => `#${p.number}`).join(", ") || "the stack"} in a checkout of the stack's top and reports back. Nothing is posted`
63
64
  : "An agent reviews the PR in a checkout and reports back. Nothing is posted",
64
65
  fix: "An agent reads the failing logs and commits a fix, without pushing",
package/shared/prompts.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type ActionId, ownStack, type Target } from "./attention";
1
+ import { type ActionId, ownStack, reviewAgain, type Target } from "./attention";
2
2
  import type { AttentionConfig, SessionKind } from "./config";
3
3
 
4
4
  // Built-in prompt templates [SES-04]. A template in config.json replaces one.
@@ -6,20 +6,30 @@ import type { AttentionConfig, SessionKind } from "./config";
6
6
  // For Review of a stack, {{head}} is its top branch and {{review}} the PRs asking for my review.
7
7
  const SWEEP = `Browser sweep, only if you're equipped to (you can run this repo's app and have browser tools): work out which pages and screens the change affects and check each one. If you can't, skip this and say so. Don't spend the session getting the app to run.`;
8
8
 
9
- export const PROMPT_TEMPLATES: Record<SessionKind, string> = {
10
- review: `Review pull request {{repo}}#{{number}}: "{{title}}" ({{url}}). You are in a checkout of the PR branch.
9
+ const STACK_INTRO = "Review the pull requests {{review}} in {{repo}}, part of the stack {{stack}} (bottom first). You are in a checkout of the top branch, {{head}}, which has every PR's changes.";
10
+ const STACK_DIFF = "for each of {{review}}, read its description (linked below) and its diff against its own base (`git diff origin/<base>...origin/<head>`, branches below).";
11
+ const AGAIN_STEP = "what changed since your last review, that is the commits after the one you reviewed, found as the context below says. Check whether each of your earlier comments was addressed.";
12
+ const AGAIN_REPORT = "Your earlier comments, each: addressed, partly, or not, with where.";
13
+
14
+ // The built-in Review prompt: what to review, the sweep, and what to report.
15
+ function reviewTemplate(intro: string, read: string, touched: string, each: string, again?: string): string {
16
+ return `${intro}
11
17
 
12
- 1. Review: read the description and the diff against {{base}}.
13
- 2. Investigate: dig into anything risky or unclear in the code it touches.
18
+ 1. Review: ${read}
19
+ 2. Investigate: dig into anything risky or unclear in ${touched}.
14
20
  3. ${SWEEP}
15
- 4. Report back:
16
- - Findings, most important first.
21
+ 4. Report back${each}:
22
+ ${again ? ` - ${again}\n` : ""} - Findings, most important first.
17
23
  - Verdict: approve, request changes or comment, with a one-line reason.
18
24
  - Draft review comments, ready to paste, each with file:line.
19
25
 
20
26
  Do not post anything to GitHub.
21
27
 
22
- {{context}}`,
28
+ {{context}}`;
29
+ }
30
+
31
+ export const PROMPT_TEMPLATES: Record<SessionKind, string> = {
32
+ review: reviewTemplate("Review pull request {{repo}}#{{number}}: \"{{title}}\" ({{url}}). You are in a checkout of the PR branch.", "read the description and the diff against {{base}}.", "the code it touches", ""),
23
33
 
24
34
  fix: `The checks on pull request {{repo}}#{{number}} "{{title}}" ({{url}}) are failing.
25
35
 
@@ -63,19 +73,24 @@ Read the issue and the code it touches, then propose a plan before changing anyt
63
73
  };
64
74
 
65
75
  // Review of a stack, while config.json doesn't replace the review template: one session for every PR asking for my review [ATT-04].
66
- export const REVIEW_STACK_TEMPLATE = `Review the pull requests {{review}} in {{repo}}, part of the stack {{stack}} (bottom first). You are in a checkout of the top branch, {{head}}, which has every PR's changes.
67
-
68
- 1. Review: for each of {{review}}, read its description (linked below) and its diff against its own base (\`git diff origin/<base>...origin/<head>\`, branches below). Review only those; the rest of the stack is context.
69
- 2. Investigate: dig into anything risky or unclear in the code they touch.
70
- 3. ${SWEEP}
71
- 4. Report back, for each PR:
72
- - Findings, most important first.
73
- - Verdict: approve, request changes or comment, with a one-line reason.
74
- - Draft review comments, ready to paste, each with file:line.
75
-
76
- Do not post anything to GitHub.
77
-
78
- {{context}}`;
76
+ export const REVIEW_STACK_TEMPLATE = reviewTemplate(STACK_INTRO, `${STACK_DIFF} Review only those; the rest of the stack is context.`, "the code they touch", ", for each PR");
77
+
78
+ // Review asked for again after I reviewed, while config.json doesn't replace the review template: what changed since, and
79
+ // whether my earlier comments were taken up; the context says how to find it [REV-02].
80
+ export const REVIEW_AGAIN_TEMPLATE = reviewTemplate(
81
+ "Review pull request {{repo}}#{{number}}: \"{{title}}\" ({{url}}) again. You reviewed it before, and review was asked for again. You are in a checkout of the PR branch.",
82
+ `${AGAIN_STEP} For context, the PR's whole diff is against {{base}}.`,
83
+ "the code the new commits touch",
84
+ "",
85
+ AGAIN_REPORT,
86
+ );
87
+ export const REVIEW_STACK_AGAIN_TEMPLATE = reviewTemplate(
88
+ `${STACK_INTRO} You reviewed some of them before, and review was asked for again.`,
89
+ `${AGAIN_STEP} For a PR asking for your review that you haven't reviewed before, ${STACK_DIFF.replace(/^for each of \{\{review\}\}, r/, "r")} Review only {{review}}; the rest of the stack is context.`,
90
+ "the code the new commits touch",
91
+ ", for each PR",
92
+ AGAIN_REPORT,
93
+ );
79
94
 
80
95
  export const ACTION_SESSION: Partial<Record<ActionId, SessionKind>> = {
81
96
  review: "review",
@@ -94,7 +109,9 @@ export function renderPrompt(
94
109
  ): string {
95
110
  const stack = target.stack ?? [];
96
111
  const reviewStack = kind === "review" && stack.length > 1;
97
- const template = config.prompts[kind] ?? (reviewStack ? REVIEW_STACK_TEMPLATE : PROMPT_TEMPLATES[kind]);
112
+ const again = kind === "review" && reviewAgain(target).length > 0;
113
+ const builtIn = reviewStack ? (again ? REVIEW_STACK_AGAIN_TEMPLATE : REVIEW_STACK_TEMPLATE) : again ? REVIEW_AGAIN_TEMPLATE : PROMPT_TEMPLATES[kind];
114
+ const template = config.prompts[kind] ?? builtIn;
98
115
  // Review reads the whole stack; the rest act on my PRs in it [ATT-04].
99
116
  const shown = kind === "review" ? stack : ownStack(target);
100
117
  const asking = stack.filter((pr) => pr.review);