@andrioid/paseo-attention-span 0.7.4 → 0.7.5

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/OVERVIEW.md CHANGED
@@ -10,11 +10,11 @@ This is the tab you'll live in. Items are grouped by reason: someone's waiting f
10
10
 
11
11
  At the top is **Wrap up**. It lists merged, closed or handed-off work that still has a Paseo session open. Archive puts the session and its worktree away. It leaves alone worktrees another session still uses, and your own checkout. It also checks for uncommitted or unpushed work first, because there's no Undo.
12
12
 
13
- ![Doing](https://cdn.jsdelivr.net/npm/@andrioid/paseo-attention-span@0.7.4/docs/screenshots/desktop-dark-doing.png)
13
+ ![Doing](https://cdn.jsdelivr.net/npm/@andrioid/paseo-attention-span@0.7.5/docs/screenshots/desktop-dark-doing.png)
14
14
 
15
15
  Every item has one main button that matches why it's there: Reply, Review, Fix CI, Merge. Open the item to see every action, each with a line saying what it'll do. I wanted buttons you can press without wondering what's about to happen to your repo.
16
16
 
17
- ![An item's actions](https://cdn.jsdelivr.net/npm/@andrioid/paseo-attention-span@0.7.4/docs/screenshots/desktop-dark-doing-sheet.png)
17
+ ![An item's actions](https://cdn.jsdelivr.net/npm/@andrioid/paseo-attention-span@0.7.5/docs/screenshots/desktop-dark-doing-sheet.png)
18
18
 
19
19
  Mentions clear when you reply or react. Team mentions don't count, because "@everyone-in-backend" isn't really a question for *me*. If something's just an FYI, dismiss it.
20
20
 
@@ -24,7 +24,7 @@ This is your work where someone else has the next move: a review you asked for,
24
24
 
25
25
  Otherwise there's nothing to do here, and that's kind of the point. It's tracked, so you can stop holding it in your head.
26
26
 
27
- ![Waiting](https://cdn.jsdelivr.net/npm/@andrioid/paseo-attention-span@0.7.4/docs/screenshots/desktop-dark-waiting.png)
27
+ ![Waiting](https://cdn.jsdelivr.net/npm/@andrioid/paseo-attention-span@0.7.5/docs/screenshots/desktop-dark-waiting.png)
28
28
 
29
29
  ## Next up
30
30
 
@@ -32,7 +32,7 @@ For when your plate is clear. It does happen. Issues assigned to you come first,
32
32
 
33
33
  **Start** launches an agent that reads the issue and proposes a plan. **New issue** (also in ⌘K) takes a line or two, and an agent turns that into a proper issue. It checks for duplicates and shows you the result before anything goes to GitHub.
34
34
 
35
- ![Next up](https://cdn.jsdelivr.net/npm/@andrioid/paseo-attention-span@0.7.4/docs/screenshots/desktop-dark-next-up.png)
35
+ ![Next up](https://cdn.jsdelivr.net/npm/@andrioid/paseo-attention-span@0.7.5/docs/screenshots/desktop-dark-next-up.png)
36
36
 
37
37
  ## History
38
38
 
@@ -40,7 +40,7 @@ What you finished in recent weeks, grouped by week. There's a copy button per we
40
40
 
41
41
  Things other people did to your work, like merging your PR or taking an issue over, wait at the top until you've seen them. None of it is a to-do, but it shouldn't happen behind your back either.
42
42
 
43
- ![History](https://cdn.jsdelivr.net/npm/@andrioid/paseo-attention-span@0.7.4/docs/screenshots/desktop-dark-history.png)
43
+ ![History](https://cdn.jsdelivr.net/npm/@andrioid/paseo-attention-span@0.7.5/docs/screenshots/desktop-dark-history.png)
44
44
 
45
45
  ## Agent sessions
46
46
 
@@ -3,7 +3,8 @@ import { useToast } from "@getpaseo/plugin/client/ui";
3
3
  import { useQuery } from "@tanstack/react-query";
4
4
  import { useEffect, useState } from "react";
5
5
  import { Pressable, ScrollView, Text, View } from "react-native";
6
- import { liftActive, type Section, type SectionId, TAB_FEED, type TabId, type WaitingGroup } from "../shared/attention";
6
+ import { liftActive, type Section, type SectionId, SECTIONS, TAB_FEED, type TabId, type WaitingGroup } from "../shared/attention";
7
+ import { inProgressEntries, type StartedIssue, withInProgress } from "../shared/in-progress";
7
8
  import { nextUpSources } from "../shared/config";
8
9
  import { ago, linkList } from "../shared/format";
9
10
  import { historyClear, isClear, nextUpClear, waitingClear } from "../shared/still";
@@ -16,7 +17,8 @@ import { useAttention } from "./data";
16
17
  import type { IconName } from "./icons";
17
18
  import { type Actions, useItemActions } from "./item-actions";
18
19
  import { Card } from "./item-row";
19
- import { NextUpList } from "./next-up";
20
+ import { InProgress } from "./in-progress";
21
+ import { type IssueRowProps, NextUpList } from "./next-up";
20
22
  import { CodeRepoPicker, SessionOptions } from "./pickers";
21
23
  import { Still } from "./still";
22
24
  import { FeedbackAsk, FeedbackLine, type FeedbackScreen, FeedbackSheet } from "./feedback";
@@ -122,6 +124,8 @@ function AttentionList({
122
124
  // Wrap up is made here from the sessions the screen and sidebar already poll; the server archives and acknowledges [ATT-22].
123
125
  const agentsNow = (view.fixtureAgents ?? agents.data ?? []).filter((agent) => !act.archivedSessions.has(agent.id));
124
126
  const wrap = wrapItems(view, agentsNow);
127
+ // Issues I started a session on leave Next up for In progress until a card of their own shows them [PRS-05, SES-11].
128
+ const shown = withInProgress(view, agentsNow, wrap);
125
129
  // Notes about work Already in Wrap up wait there; archiving acknowledges them [HIS-07, ATT-22].
126
130
  const notes = unreadChanges(view.history.filter((item) => item.section === "changed"), wrap);
127
131
  // Calm only once a refresh that worked says Doing is empty, Wrap up included [ATT-18, ATT-22].
@@ -129,19 +133,21 @@ function AttentionList({
129
133
  const sessionsKnown = !!view.fixtureAgents || (agents.isSuccess && !agents.isError);
130
134
  // A worktree that stayed after its sessions were archived lingers in Wrap up, uncounted, but keeps the calm away [ATT-22].
131
135
  const kept = view.kept ?? [];
132
- const clear = sessionsKnown && isClear(view, !!attention.error, wrap.length + kept.length);
136
+ const clear = sessionsKnown && isClear(view, !!attention.error, wrap.length + kept.length + shown.started.length);
133
137
  // The other tabs' scenes, on the same terms [HIS-08, WAI-04, NXT-13].
134
138
  const calm = {
135
139
  history: historyClear(view, notes.length, !!attention.error),
136
140
  waiting: waitingClear(view, !!attention.error),
137
- next: nextUpClear(view, !!attention.error),
141
+ next: nextUpClear(shown, !!attention.error),
138
142
  };
139
143
  // ⟳ turns for any refresh of this tab's feed, but only my own press locks it: the cached view can still say a background one runs after it's done.
140
144
  const pressed = attention.isRefreshing(TAB_FEED[tab]);
141
145
  const refreshing = feed.refreshing || attention.isFetching || pressed;
142
- const counts = tabCounts(view, wrap);
146
+ const counts = tabCounts(shown, wrap);
143
147
 
144
148
  const actions = act.itemActions(view, agentsNow);
149
+ // A started issue's card is Next up's, with its sheet's Unclaim and Close issue [SES-11].
150
+ const issueRow: IssueRowProps = { agents: actions.agents, login: view.login, busy: act.busy, fetchDetails: act.fetchDetails, onOpenAgent: act.openAgent, ...act.issueActions };
145
151
 
146
152
  const switchTab = (id: TabId) => {
147
153
  setTab(id);
@@ -203,7 +209,7 @@ function AttentionList({
203
209
  ) : null}
204
210
  {tab === "doing" ? (
205
211
  <>
206
- {clear ? <Still /> : wrap.length || kept.length || view.doing.length ? (
212
+ {clear ? <Still /> : wrap.length || kept.length || view.doing.length || shown.started.length ? (
207
213
  <>
208
214
  {wrap.length + kept.length > 0 ? (
209
215
  <WrapUp
@@ -227,7 +233,7 @@ function AttentionList({
227
233
  }}
228
234
  />
229
235
  ) : null}
230
- {view.doing.length > 0 ? <Sections sections={view.doing} actions={actions} /> : null}
236
+ {view.doing.length || shown.started.length ? <Sections sections={view.doing} started={shown.started} actions={actions} issueRow={issueRow} /> : null}
231
237
  </>
232
238
  ) : !feed.fetchedAt && !feed.error ? (
233
239
  <Loading text="Checking GitHub…" />
@@ -254,8 +260,8 @@ function AttentionList({
254
260
  <NextUpList
255
261
  calm={calm.next}
256
262
  openSettings={openSettings}
257
- assigned={view.assigned}
258
- unclaimed={view.unclaimed}
263
+ assigned={shown.assigned}
264
+ unclaimed={shown.unclaimed}
259
265
  unclaimedFrom={view.unclaimedFrom}
260
266
  selected={view.scopes}
261
267
  sources={nextUpSources(view.config)}
@@ -318,13 +324,22 @@ function Tab({ icon, label, count, active, dot, onPress }: { icon: IconName; lab
318
324
  );
319
325
  }
320
326
 
321
- function Sections({ sections, actions }: { sections: Section[]; actions: Actions }) {
322
- return sections.map((section) => (
323
- <View key={section.id}>
324
- <SectionHeader icon={SECTION_ICONS[section.id]} title={section.title} count={section.items.length} />
325
- <Card items={section.items} actions={actions} />
326
- </View>
327
- ));
327
+ // In progress comes last and holds the started issues too, even with no drafts [PRS-05, SES-11].
328
+ function Sections({ sections, started, actions, issueRow }: { sections: Section[]; started: StartedIssue[]; actions: Actions; issueRow: IssueRowProps }) {
329
+ const all = started.length && !sections.some((section) => section.id === "drafts") ? [...sections, { id: "drafts" as const, title: SECTIONS.drafts.title, items: [] }] : sections;
330
+ return all.map((section) =>
331
+ section.id === "drafts" ? (
332
+ <View key={section.id}>
333
+ <SectionHeader icon={SECTION_ICONS[section.id]} title={section.title} count={section.items.length + started.length} />
334
+ <InProgress entries={inProgressEntries(section.items, started, actions.agents)} actions={actions} issueRow={issueRow} />
335
+ </View>
336
+ ) : (
337
+ <View key={section.id}>
338
+ <SectionHeader icon={SECTION_ICONS[section.id]} title={section.title} count={section.items.length} />
339
+ <Card items={section.items} actions={actions} />
340
+ </View>
341
+ ),
342
+ );
328
343
  }
329
344
 
330
345
  // Waiting by who it waits on, each with a list to copy for a nudge, oldest first; a bot gets none, as there's nobody to send
@@ -0,0 +1,74 @@
1
+ import { openExternalUrl } from "@getpaseo/plugin/client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useState } from "react";
4
+ import { type InProgressEntry, type StartedIssue } from "../shared/in-progress";
5
+ import { sessionSignal } from "../shared/item-view";
6
+ import { CardList, CardRow } from "./card";
7
+ import type { Actions } from "./item-actions";
8
+ import { ItemRow } from "./item-row";
9
+ import { IssueRow, type IssueRowProps, issueDetailsQuery } from "./next-up";
10
+ import { PlaceText } from "./entity";
11
+ import { sessionEntry } from "./session-menu";
12
+ import { ActionSheet, DETAILS_STALE_MS, DetailLines, githubEntry, type SheetEntry, usePrefetchOnRest } from "./sheet";
13
+ import { Meta } from "./ui";
14
+
15
+ // In progress: my drafts and the issues I started, in one list, whatever waits on me first [PRS-05, SES-11].
16
+ export function InProgress({ entries, actions, issueRow }: { entries: InProgressEntry[]; actions: Actions; issueRow: IssueRowProps }) {
17
+ return (
18
+ <CardList>
19
+ {entries.map((entry, index) =>
20
+ entry.kind === "draft" ? (
21
+ <ItemRow key={entry.item.key} item={entry.item} first={index === 0} actions={actions} />
22
+ ) : entry.started.issue ? (
23
+ // Next up's card, so its sheet keeps Unclaim and Close issue; it's mine to unclaim once assigned [NXT-07].
24
+ <IssueRow key={entry.started.key} issue={entry.started.issue} claim={!entry.started.assigned} first={index === 0} {...issueRow} />
25
+ ) : (
26
+ <PlainIssueRow key={entry.started.key} started={entry.started} first={index === 0} login={issueRow.login} fetchDetails={issueRow.fetchDetails} onOpenAgent={issueRow.onOpenAgent} />
27
+ ),
28
+ )}
29
+ </CardList>
30
+ );
31
+ }
32
+
33
+ // An issue Next up doesn't know, assigned to someone else or outside where it looks: what its session says, until a PR
34
+ // that closes it gives it a full card. Like every card, › and a tap open its sheet [ATT-06, SES-11].
35
+ function PlainIssueRow({ started, first, login, fetchDetails, onOpenAgent }: { started: StartedIssue; first: boolean } & Pick<IssueRowProps, "login" | "fetchDetails" | "onOpenAgent">) {
36
+ const [sheet, setSheet] = useState(false);
37
+ const session = started.sessions[0];
38
+ const title = session.title ?? `Issue #${started.number}`;
39
+ const open = () => setSheet(true);
40
+ const prefetch = usePrefetchOnRest(issueDetailsQuery(started, fetchDetails));
41
+ return (
42
+ <CardRow
43
+ first={first}
44
+ mark={{ icon: "issue", tone: "neutral" }}
45
+ title={title}
46
+ meta={{ place: { repo: started.repo, number: started.number, login }, signals: [sessionSignal(session)] }}
47
+ onOpen={open}
48
+ hover={prefetch}
49
+ primary={{ label: "Open session", icon: "agent", onPress: () => onOpenAgent(session.id) }}
50
+ secondary={[{ label: `Details for #${started.number}`, icon: "chevronRight", onPress: open }]}
51
+ overlay={sheet ? <PlainIssueSheet started={started} title={title} fetchDetails={fetchDetails} onOpenAgent={onOpenAgent} onClose={() => setSheet(false)} /> : null}
52
+ />
53
+ );
54
+ }
55
+
56
+ // Its sessions, then the issue on GitHub, then what the sheet fetches [ATT-06, SES-03].
57
+ function PlainIssueSheet({ started, title, fetchDetails, onOpenAgent, onClose }: { started: StartedIssue; title: string; onClose: () => void } & Pick<IssueRowProps, "fetchDetails" | "onOpenAgent">) {
58
+ const details = useQuery({ ...issueDetailsQuery(started, fetchDetails), staleTime: DETAILS_STALE_MS });
59
+ const close = (then: () => void) => () => (onClose(), then());
60
+ const url = `https://github.com/${started.repo}/issues/${started.number}`;
61
+ const entries: SheetEntry[] = [
62
+ ...started.sessions.map((agent) => sessionEntry(agent, "Continue session", (agentId) => close(() => onOpenAgent(agentId))())),
63
+ githubEntry({ kind: "issue", repo: started.repo, number: started.number, url }, (link) => close(() => void openExternalUrl(link))()),
64
+ ];
65
+ return (
66
+ <ActionSheet
67
+ title={title}
68
+ onClose={onClose}
69
+ top={<Meta lead={<PlaceText place={{ repo: started.repo, number: started.number, login: null }} />} facts={[]} chips={[]} />}
70
+ entries={entries}
71
+ bottom={<DetailLines details={details.data} loading={details.isLoading} error={details.error} linkedLabel="PR" expected={0} />}
72
+ />
73
+ );
74
+ }
@@ -118,7 +118,7 @@ type Sheet = "item" | "acknowledge" | "reviewers" | "reviewers-after-ready" | nu
118
118
 
119
119
  // A card that works collapsed: its main action and ›. Tapping it opens the sheet with everything else [ATT-05, ATT-06].
120
120
  // In Waiting, a card sits under one of whom it waits on: its group.
121
- function ItemRow({ item, first, actions, group }: { item: Item; first: boolean; actions: Actions; group?: WaitingGroup }) {
121
+ export function ItemRow({ item, first, actions, group }: { item: Item; first: boolean; actions: Actions; group?: WaitingGroup }) {
122
122
  const styles = useStyles();
123
123
  // An open session leads; without one, the item's own action does [SES-03].
124
124
  const sessions = itemSessions(actions.agents, item);
@@ -13,6 +13,7 @@ import {
13
13
  type UnclaimedSource,
14
14
  } from "../shared/attention";
15
15
  import type { NextUpSource } from "../shared/config";
16
+ import { sessionSignal } from "../shared/item-view";
16
17
  import { CLEAR_FILTER, type FilterChange, nextUpFilter, repoGroups } from "../shared/next-up-filter";
17
18
  import type { IconName } from "./icons";
18
19
  import type { FetchDetails } from "./item-actions";
@@ -62,6 +63,8 @@ interface Props {
62
63
  onNewIssue: () => void;
63
64
  }
64
65
 
66
+ export type IssueRowProps = RowProps;
67
+
65
68
  type RowProps = Omit<Props, "calm" | "openSettings" | "assigned" | "unclaimed" | "unclaimedFrom" | "selected" | "sources" | "selectedSources" | "projects" | "selectedProjects" | "onFilter" | "byRepo" | "onByRepo" | "onNewIssue">;
66
69
 
67
70
  // Assigned issues first [NXT-06], then unclaimed ones [NXT-01]; both already ranked by the server [NXT-02].
@@ -182,7 +185,7 @@ function prSignal(issue: NextUpIssue): Chip[] {
182
185
  }
183
186
 
184
187
  // What an issue's sheet fetches when it opens; resting the pointer on its card fetches the same ahead [ATT-06].
185
- function issueDetailsQuery(issue: NextUpIssue, fetchDetails: FetchDetails): DetailsQuery {
188
+ export function issueDetailsQuery(issue: Pick<NextUpIssue, "repo" | "number">, fetchDetails: FetchDetails): DetailsQuery {
186
189
  const subject = { kind: "issue" as const, repo: issue.repo, number: issue.number };
187
190
  return { queryKey: detailsKey(subject, undefined, false), queryFn: () => fetchDetails({ subject, checks: false }) };
188
191
  }
@@ -191,7 +194,7 @@ function issueDetailsQuery(issue: NextUpIssue, fetchDetails: FetchDetails): Deta
191
194
  const TYPE_TONES: Record<string, Tone> = { bug: "bad", feature: "good", epic: "good", debt: "warn" };
192
195
 
193
196
  // Its main action and ›; tapping it opens the sheet with the description, Claim or Unclaim [ATT-06, NXT-07].
194
- function IssueRow({ issue, claim, first, agents, login, busy, fetchDetails, onStart, onOptions, onClaim, onCloseIssue, onOpenAgent }: RowProps & { issue: NextUpIssue; claim: boolean; first: boolean }) {
197
+ export function IssueRow({ issue, claim, first, agents, login, busy, fetchDetails, onStart, onOptions, onClaim, onCloseIssue, onOpenAgent }: RowProps & { issue: NextUpIssue; claim: boolean; first: boolean }) {
195
198
  const [sheet, setSheet] = useState(false);
196
199
  // The sheet opens at once; what it fetches fills in [ATT-06].
197
200
  const open = () => setSheet(true);
@@ -209,7 +212,7 @@ function IssueRow({ issue, claim, first, agents, login, busy, fetchDetails, onSt
209
212
  mark={{ icon: TYPE_ICONS[type] ?? "issue", tone: TYPE_TONES[type] ?? "neutral" }}
210
213
  title={issue.title}
211
214
  accessibilityLabel={`${issue.type ? `${issue.type}: ` : ""}${issue.title}, more`}
212
- meta={{ place: { repo: issue.repo, number: issue.number, login }, when: `${ago(issue.createdAt)} old`, signals: prSignal(issue) }}
215
+ meta={{ place: { repo: issue.repo, number: issue.number, login }, when: `${ago(issue.createdAt)} old`, signals: sessions[0] ? [...prSignal(issue), sessionSignal(sessions[0])] : prSignal(issue) }}
213
216
  extra={<IssuePills issue={issue} />}
214
217
  onOpen={open}
215
218
  hover={prefetch}
@@ -83,21 +83,21 @@ Top to bottom. Each item appears once, under its most urgent reason [ATT-02]. `s
83
83
  | Ready to merge | My approved PRs without conflicts or failing checks, that GitHub's rules let me merge [PRS-03, PRS-13] |
84
84
  | Needs upstream | My PRs with conflicts or an out-of-sync stack [UPS-01, UPS-02] |
85
85
  | Needs a reviewer | My PRs nobody has been asked to review, even while CI runs [PRS-12]. Only what GitHub records counts as asked: a pending request, an approval or requested changes. GitHub drops a reviewer's request once they review, so a review that only commented, by a person or a bot, leaves it here to re-request; the repo, not us, decides whose approval counts |
86
- | My drafts | My drafts, with their own state tags [PRS-05, PRS-06] |
86
+ | In progress | My drafts, with their own state tags, and issues I started a session on that no other card shows yet [PRS-05, PRS-06, SES-11] |
87
87
  | Wrap up | First, the cleanup: finished or out-of-my-hands work whose unarchived Paseo sessions are all idle, including a review session on someone else's merged PR [ATT-22]. It takes merged, closed and handed-off items, mine or anyone's, including my own PRs I closed without merging ("closed 3h ago, not merged", from the live closed search, never listed in History) and my merged PRs from the same search, which stand in until History has them (`ownClosed` in `server/changes.ts`; History's entry wins) [FRESH-03], as far back as History and its ledger keep, with no age cutoff of its own; a stack or issue group enters only when everything its sessions serve is done, and counts once; one session never makes two rows. A busy session keeps its row out until idle. Newest finish first, each row saying what happened and what is still open: "merged by dave 2h ago · your session's still open", "merged by alice 1d ago · your review session's still open", "2 sessions still open", with an amber "unsaved changes" where a worktree has them. **Archive session** (plural for several) archives the item's agents and the sub-agents they started; a worktree goes too only when it's Paseo's and no other session lives in it, never a local checkout. A sub-agent still running or starting, or flagged for anything but finished or failed (a permission, say), keeps its session's row out, like a busy session; a finished or failed one Paseo still flags for attention doesn't (`subAgentBusy`), as nobody opens a sub-agent and reporting back is its parent's job. One idle session with nothing uncommitted or unpushed archives at once; unsaved or unknown work, or a terminal open in a worktree that goes, asks first in a sheet shaped like Paseo's own "Archive workspace" one: 'Archive "Split invoice PDF"?' when the worktree goes with it (else "Archive the session on #186?"), then each session's lines in Paseo's words ("Uncommitted changes: 2 files (+12 −3)", "1 unpushed commit", "Couldn't check for unsaved changes") and a muted "Closes terminals: dev, shell", with Open session and Archive; a terminal that opened after the sheet brings it back; the multi sheet notes "+1 sub-agent" under a session that has them; several sessions open a shared action sheet listing each one's state with Continue session; archiving from there checks first too, and any unsaved work it finds gets the naming confirm. **Archive all clean · n** sits in the header with 2+ rows and archives every clean single-session row; it and single archives wait for each other like Got it and Mark all. Success acknowledges exactly the changes present at that moment, so they go to their week as cleared rather than History's unread notes; so does archiving a session Attention Span started in Paseo itself, for what others did up to then, once no session it started is left on that work; a failure keeps the row and says why, and a worktree that stayed after its sessions went keeps a row in Wrap up, uncounted, saying why, briefly, beside the archive mark ("Fix flaky test still in it", "dev server opened meanwhile", "Paseo: worktree is locked") with a button for the reason (Open session, Archive worktree, Try again) and Dismiss in its detail sheet; it goes once the worktree is archived anywhere, and keeps the horizon away until then. Until the session list has loaded, or when it fails, Wrap up isn't known: Doing says so instead of showing the horizon. There is no Undo: Paseo's SDK can't restore a workspace and its agents, so the dirty check and confirmation are the safeguard instead. Its rows count in Doing's and the sidebar's count, and keep the horizon away. An open issue whose PRs of mine have all merged, with no PR open for it, gets a row too, with or without a session: "Close #12? #34 and #35 merged 2h ago", **Close #12** (as completed, no comment, Undo reopens) and Keep open in its detail sheet, which lasts until another PR of mine merges under it (Undo too); its merged PRs' idle sessions join that row instead of making their own, and once it's closed they're the usual row. Archive all clean leaves it [ATT-24]. |
88
88
 
89
89
  **Nothing in Doing** shows a horizon instead of a list (`client/still.tsx`) [ATT-18], with "Nothing's on you. Enjoy the quiet." It follows the device's clock at fixed hours: a low sun in the morning (5–11), a high sun at midday (11–16), a setting sun in the evening (16–21), and a moon with a few stars at night, each in its own soft tint. It settles in on every arrival on the tab (the sky drifts up as it fades in, then its reflections, 700 ms; not with reduced motion), then holds still; when the hour changes while it's open, it crossfades. It shows only after a refresh that worked: before the first one there's a spinner, and after a failed one just the error. Items that are all dismissed count as clear; the "show them again" line sits faintly at the bottom. Wrap up's rows don't: the horizon waits until they're archived too [ATT-22]. Changed by others never touches Doing; it lives in History [HIS-07].
90
90
 
91
91
  ## Rules
92
92
 
93
- - **One item per issue** [ATT-03]: PRs are grouped under the issue they work on, across repos. GitHub links (`closingIssuesReferences`) only PRs into the default branch, so a stack's upper PRs are read too. For a stack, strongest evidence first: what GitHub links on any of its PRs, bottom first; then a closing keyword ("Closes #N") in any PR's description; then the one issue the bottom PR's description mentions ("First of three for #N"), and none when it mentions several. Code, quotes and template comments don't count. References from descriptions are looked up in the details request, and only open issues count, so a reference to a PR doesn't group. A PR without an issue is its own item. History does the same per merged PR, against the closed issues it lists.
93
+ - **One item per issue** [ATT-03]: PRs are grouped under the issue they work on, across repos. GitHub links (`closingIssuesReferences`) only PRs into the default branch, so a stack's upper PRs are read too. For a stack, strongest evidence first: what GitHub links on any of its PRs, bottom first; then a closing keyword ("Closes #N") in any PR's description. A plain mention ("for #N", "follow-up to #N") doesn't group, so a PR isn't put under an issue it only refers to, and Wrap up doesn't offer to close one. Code, quotes and template comments don't count. Issues a description closes are looked up in the details request, from my PRs and those asking for my review, as another's PR atop my stack may be the one that closes it, and only open issues count, so a reference to a PR doesn't group. A PR without an issue is its own item. History does the same per merged PR, against the closed issues it lists.
94
94
  - **One item per stack** [ATT-04]: a stack is followed through base/head branch names, among my PRs and others' PRs requesting my review, whoever opened them; a PR from a fork never parents another. Only PRs those two searches return can be joined, so a PR in the stack that's neither mine nor asking for my review is left out. The item is led by the stack's bottom PR, with the rest listed beneath. My PRs in it are decided by their bottom PR, as before; others' PRs asking for my review add one Review for all of them, or a reply when one mentions me. Where a stack has both, its section is the more urgent of the two and it offers both, that one's actions first. GitHub actions act on my PRs, from my bottom one; a stack only asking for my review is never grouped under an issue. Sessions on any PR in the stack show on its item [SES-03, SES-08].
95
95
  - **Answers** [ATT-16]: on an issue a PR of mine closes, an answer leads the item like a mention does. From the issue itself only what's on me counts; its PRs say how the work is going.
96
96
  - **Mentions** [MEN-01..06]: a thread counts when a person @-mentioned me after my last comment, review or reaction there. Team mentions are ignored. A bot counts only when it opened a thread I need to resolve, and is marked with 🤖. The quote on a card is cut around the mention, so it's shown as plain text: links keep their text, Markdown marks and quoted replies go.
97
97
  - **Handed over** [PRS-08]: my PRs assigned to someone else, and not to me, are left out. Mentions of me on them still count. A PR of mine with nobody assigned is mine.
98
98
  - **Changed by others** [HIS-07] (`server/changes.ts`) keeps a ledger of what others did, in `state.json`, by GitHub's node ids, which a transfer keeps. Only someone else's doing counts; my own actions and others' pushes don't. Merges, unmerged closes and issue closes come from live searches: `mergedBy`, the last close event's actor, and an issue's `stateReason`. A PR that left my hands before it ended counts as the handover, not the merge; one assigned to someone after it ended is still my merge, and a PR someone else has waits a refresh for its lookup rather than be called a merge. Handovers come from GitHub's assign and unassign events, which are separate, never one "handover": a PR is looked up when it's assigned to someone else and not me, once per change of its assignees; it left my hands with whichever came last of my removal and the new owner's assignment, so a PR I took myself off is mine until someone takes it, and an earlier round's removal doesn't name who took it this time; an issue when it leaves my assigned search since the last refresh that worked. Leaving the search proves nothing (search lag, a coverage change, its 50 results), so only an unassign event of me by someone else counts; one closed by then is left to its close note. So unassignments are noticed only for issues Attention Span has seen assigned to me; on the first run none count as gone. A PR seen closed unmerged is tracked; once it drops out of the closed search, as a reopen takes it out, a batch asks for its state and last reopen event. A reopen removes the old close from its week whoever did it, and only someone else's is a note; a merged one stops being tracked, and nothing older than the ledger's window is tracked. A first run tracks from then on, so old closes don't replay as new. A failed lookup, or one node in it GitHub failed on (anything but not found), is asked again on the next refresh. A PR handed over isn't listed under the finished issue it closed either; when a cleared handover's work comes back to me it stays in its week, marked returned, so my later work on it is mine again. Events are kept `historyWeeks` + 1 weeks, or `mentionDays` if longer; unread notes expire after `mentionDays` for History's top section.
99
99
  - **Wrap up** [ATT-22] (`shared/wrap-up.ts`, drawn by `client/wrap-up.tsx`) uses the shared `ActionSheet` on every card-body or Details tap, including close-issue prompts and kept worktrees [ATT-06]. PR cards and linked stack rows share state marks: open green, draft muted, closed unmerged red and merged purple; each stack row uses its own state, with merge timestamps supporting older saved rows. Cards show their main action and one Details chevron; Keep open and Dismiss live in the sheet. Close-issue prompts also offer the shared Start a session / Start another session entry, opening the usual session options on the issue. Their navigation lists all matching sessions, including working sessions; archive eligibility stays separate. Item sheets reuse the detail query, hover prefetch, session entries, linked-PR rows (`client/stack.tsx`) and GitHub links from the other tabs; cleanup is an explicit action, with unsaved-work and terminal confirmations kept separate. Wrap up is assembled on the client from the sessions the screen and the sidebar already poll; the server archives and acknowledges. An item's identity is `memberKeys` in `shared/attention.ts`: its key, the PRs under it and the work a change note is about, spelled as GitHub spells them since Paseo's labels match exactly, and compared ignoring case (`shared/names.ts`, as all GitHub names are); Wrap up, archiving and acknowledging all use it. A finished item, reviewed PR, my own unmerged close, cleared change or unread change is a candidate; its sessions are the ones on any of its member keys. It enters when it has at least one unarchived session, every one is idle (not working and not needing me), none serves an item still in Doing or Waiting, and no session already belongs to another row. History lists a merged PR alone, as its branches are gone, so each live refresh remembers every open stack's and issue group's keys under each member (`groups` in `state.json`, kept as long as the ledger): a merged member whose remembered sibling is still open stays out, and so does its session. The screen freezes rows whose archive runs and Archive all clean while any row's archive runs (`shared/got-it.ts`). Archiving goes through `paseo.agents.ref(id).archive()`, sub-agents first (found by Paseo's `paseo.parent-agent-id` label, `subAgentsOf` in `shared/linked-sessions.ts`; one in another workspace is archived, its workspace left alone; archive lists every page of agents, archived ones too, so one under an archived sub-agent still counts, and a sub-agent that won't archive and stays open stops the archive before its session goes); a Paseo worktree is archived too, through `paseo.workspaces.archive`, which archives everything in it, only when every unarchived agent in it is being archived, and a local checkout never is. Workspaces are named as Paseo's sidebar names them: the title, else the branch. A worktree that stays is a `KeptRow` in `state.json` (`kept`) with its row's item; the `workspace.archived` hook forgets it, and remembers the workspace so an archive still running doesn't add it back, Dismiss forgets it, and Archive worktree or Try again runs the same checks on the worktree alone (`rpc.archiveWorktree`). Paseo closes a worktree's terminals when it archives it, so they're listed (`paseo.terminals.list`) right before archiving and named on the sheet; the confirm sends back the ids it named, and any other asks again. They're listed once more right before each worktree goes: one that opened while the sessions were being archived keeps its worktree, said in its kept row, as Paseo's SDK has no archive that checks and removes at once. Terminals that can't be listed don't keep the worktree, as Paseo would close them anyway. The plugin SDK says nothing of what a terminal runs, so an idle shell and a dev server are named alike. The dirty check reads Paseo's workspace snapshot and, for counts, `git status --porcelain`, `git diff --shortstat HEAD` for lines, and `git rev-list --count @{upstream}..HEAD` (with no upstream, `HEAD --not --remotes`) on the daemon host. Clean needs both answers: when either can't say, it's treated as dirty and the sheet says so (`unsavedOf` in `shared/archive.ts`, for the server and the screen alike). Agents and their status are listed again right before archiving, so a session that started working during the checks, or one that moved into the worktree, stops it. A session Attention Span started, archived in Paseo itself, is caught by the `agent.archived` hook in `index.server.ts` (`server/archived.ts`), even with the screen closed: once no other open session labelled with any key of its item's group is left, the group's changes up to the archive's `archivedAt` are acknowledged, so what others do later still shows. A sub-agent's archive, a restored session and a session without an item label acknowledge nothing; sessions linked only by their workspace neither acknowledge nor hold an acknowledgement back. Lists read every page, and a lookup that fails is tried again on the next hook event or list request, never taken as "none left"; tries are kept in memory, so an archive while the server isn't running, or one pending at a restart, isn't noticed, and Got it or Mark all clears its notes. A new list that brings other merged branches polls again at once, so a session linked by branch doesn't wait for the next round. When a session leaves the screen's 15-second poll (`useItemAgents` in `client/sessions.ts`, shared with the sidebar), the screen reads the server's view from memory first, so the notes acknowledged for it are cleared before its Wrap up row goes. Paseo's SDK has no `restoreWorkspace`, so there is no Undo; `server/archive.ts` confirms instead.
100
- - **Close #12?** [ATT-24] (`classifyCloseAsks` in `server/classify.ts`): after History's searches, the issues my merged PRs refer to that History doesn't know closed (`mergedToLookUp` in `server/references.ts`, at most 100) are looked up, a batch per request, for their state and the open PRs GitHub links to them, anyone's. A merged PR is put under an issue as `issueFor` picks one, counting History's closed issues as issues so a PR that closed one isn't put under another it mentions. An issue that's open, with no linked PR open, is asked about (`asks` in `state.json`'s History); as History is fetched daily, each live refresh looks the asked issues up again (`askOff`, one batched request while any is asked; one that can't be looked up keeps asking); the view leaves out one with a PR of mine open under it in the live feed (a mention or answer on the issue alone doesn't count), one Next up knows has anyone's PR open, one the live lookup found closed or with a PR open, one whose latest merge is older than History's weeks, one kept open (`keptOpen`: the latest merge then, so a later one asks again; kept for History's weeks, so an ask missing from one fetch doesn't lose it) and one I just closed. Closing goes through `rpc.closeIssue`, its done item carrying the merged PRs with their branches, so a session linked by branch keeps its row, whether the issue is assigned to me or not; as History's search only finds closed issues assigned to me, it's kept in `closedAsks` for History's weeks, listed in History with its PRs under it rather than alone, and Undo forgets it; Next up's card gets a "PRs merged" pill (`prsMerged`).
100
+ - **Close #12?** [ATT-24] (`classifyCloseAsks` in `server/classify.ts`): after History's searches, the issues my merged PRs close, by GitHub's link or a closing keyword, that History doesn't know closed (`mergedToLookUp` in `server/references.ts`, at most 100) are looked up, a batch per request, for their state and the open PRs GitHub links to them, anyone's. A merged PR is put under an issue as `issueFor` picks one, counting History's closed issues as issues so a PR that closed one isn't put under another it also closes. An issue that's open, with no linked PR open, is asked about (`asks` in `state.json`'s History); as History is fetched daily, each live refresh looks the asked issues up again (`askOff`, one batched request while any is asked; one that can't be looked up keeps asking); the view leaves out one with a PR of mine open under it in the live feed (a mention or answer on the issue alone doesn't count), one Next up knows has anyone's PR open, one the live lookup found closed or with a PR open, one whose latest merge is older than History's weeks, one kept open (`keptOpen`: the latest merge then, so a later one asks again; kept for History's weeks, so an ask missing from one fetch doesn't lose it) and one I just closed. Closing goes through `rpc.closeIssue`, its done item carrying the merged PRs with their branches, so a session linked by branch keeps its row, whether the issue is assigned to me or not; as History's search only finds closed issues assigned to me, it's kept in `closedAsks` for History's weeks, listed in History with its PRs under it rather than alone, and Undo forgets it; Next up's card gets a "PRs merged" pill (`prsMerged`).
101
101
 
102
102
  - **Dismiss** [ATT-08] hides an item until someone other than me comments, reviews or pushes, or its reason changes. My own actions and CI reruns don't bring it back.
103
103
  - **Behind base** [UPS-07] only matters when:
@@ -210,7 +210,7 @@ One GraphQL request per search, sent in parallel (`server/fetch.ts`; the service
210
210
  - `is:issue is:closed assignee:@me closed:>=<30 days ago> sort:updated-desc`, 50 at most, with `stateReason` and the last close event's actor (an issue someone else closed) [HIS-07]
211
211
  - `is:issue is:open no:assignee` (Next up, with issue type and field values, and projects when the login may read them [NXT-12]; one request per source [NXT-09], skipped when there's nowhere to look [NXT-08]). "My repos" needs my login, taken from the last fetch or asked once with `viewer { login }`
212
212
 
213
- Once my PRs and both issue searches are back, one batched **details** request asks for `Ref.compare` behind counts for my PRs, the open issues their descriptions refer to (at most 100), and the option order and colors of org issue fields when Next up needs them [NXT-02, NXT-10]. The other searches carry on meanwhile.
213
+ Once my PRs, the PRs asking for my review and both issue searches are back, one batched **details** request asks for `Ref.compare` behind counts for my PRs, the open issues their descriptions close (at most 100), and the option order and colors of org issue fields when Next up needs them [NXT-02, NXT-10]. The other searches carry on meanwhile.
214
214
 
215
215
  Then, only for PRs whose assignees changed to someone else and issues that left my assigned search, one request per 20 asks for their last 30 assign and unassign events (`assignmentsQuery`) [HIS-07]; and, at the same time, one per 20 for tracked closed PRs that left the closed search asks their state and last reopen event (`reopenQuery`) [HIS-07]; usually none.
216
216
 
package/index.client.tsx CHANGED
@@ -1,22 +1,31 @@
1
- import type { PluginClientContext, PluginScreenProps, PluginSidebarItemProps } from "@getpaseo/plugin/client";
1
+ import { type PluginClientContext, type PluginScreenProps, type PluginSidebarItemProps, useHosts } from "@getpaseo/plugin/client";
2
2
  import { SidebarRow } from "@getpaseo/plugin/client/ui";
3
- import { Text } from "react-native";
3
+ import { Text, View } from "react-native";
4
4
  import { AttentionScreen } from "./client/attention-screen";
5
5
  import { CoverageSettings } from "./client/coverage-settings";
6
6
  import { useAttention } from "./client/data";
7
7
  import { returnFromFeedback } from "./client/feedback";
8
8
  import { ICONS } from "./client/icons";
9
+ import { tint } from "./client/ui";
9
10
  import { newIssueParams } from "./client/new-issue";
10
11
  import { useItemAgents } from "./client/sessions";
12
+ import { withInProgress } from "./shared/in-progress";
11
13
  import { doingCount, wrapItems } from "./shared/wrap-up";
12
14
 
13
15
  // The count, visible from anywhere in Paseo [ATT-09].
14
- function SidebarItem({ theme, currentScreen, openScreen }: PluginSidebarItemProps) {
16
+ function SidebarItem({ theme, host, currentScreen, openScreen }: PluginSidebarItemProps) {
15
17
  const { data } = useAttention();
16
18
  // Wrap up's rows need the sessions, which live in Paseo [ATT-09, ATT-22].
17
19
  const agents = useItemAgents();
18
- const wrap = data ? wrapItems(data, data.fixtureAgents ?? agents.data ?? []) : [];
19
- const count = data ? doingCount(data, wrap) : 0;
20
+ const sessions = data?.fixtureAgents ?? agents.data ?? [];
21
+ const wrap = data ? wrapItems(data, sessions) : [];
22
+ // A started issue counts while its session waits on me, as on the screen [SES-11].
23
+ const count = data ? doingCount(withInProgress(data, sessions, wrap), wrap) : 0;
24
+ // Paseo merges every host's row into one, showing the host picked last, so with more than one host a pill says whose
25
+ // count this is [REACH-02]. Paseo only lists the hosts I've configured, not which of them have Attention Span, so a host
26
+ // without it still counts. The pill gives way first, so "Attention" keeps its line in a narrow sidebar.
27
+ const hosts = useHosts();
28
+ const muted = theme.colors.foregroundMuted;
20
29
  return (
21
30
  <SidebarRow
22
31
  icon={ICONS.logo}
@@ -24,8 +33,17 @@ function SidebarItem({ theme, currentScreen, openScreen }: PluginSidebarItemProp
24
33
  active={currentScreen?.screenId === "attention"}
25
34
  onPress={() => openScreen({ screenId: "attention" })}
26
35
  trailing={
27
- count > 0 ? (
28
- <Text style={{ color: data?.feeds.live.error ? theme.colors.statusDanger : theme.colors.foregroundMuted, fontSize: 12 }}>{count}</Text>
36
+ hosts.length > 1 || count > 0 ? (
37
+ <View style={{ flexDirection: "row", alignItems: "center", gap: 8, flexShrink: 1 }}>
38
+ {hosts.length > 1 ? (
39
+ <View style={{ flexShrink: 1, maxWidth: 72, paddingHorizontal: 6, paddingVertical: 1, borderRadius: 9, backgroundColor: tint(theme.colors.foreground, 0.08) }}>
40
+ <Text numberOfLines={1} accessibilityLabel={`On ${host.label}`} style={{ color: muted, fontSize: 11, fontWeight: "500" }}>
41
+ {host.label}
42
+ </Text>
43
+ </View>
44
+ ) : null}
45
+ {count > 0 ? <Text style={{ color: data?.feeds.live.error ? theme.colors.statusDanger : muted, fontSize: 12 }}>{count}</Text> : null}
46
+ </View>
29
47
  ) : undefined
30
48
  }
31
49
  />
package/index.server.ts CHANGED
@@ -36,7 +36,7 @@ export default function contribute(server: PluginServerContext) {
36
36
  const answers = FIXTURE ? fixtureAnswers : { reviewerChoices, itemDetails, defaultBranch, sessionContext, ghStatus, myOrgs, coverageOnGitHub };
37
37
  const updates = new UpdateCheck(FIXTURE ? fixtureUpdates : paseoUpdates);
38
38
  // Each view the screen gets; previews add their made-up sessions [ATT-22].
39
- const shown: (view: AttentionView) => AttentionView = FIXTURE ? fixtureView : (view) => view;
39
+ const shown: (view: AttentionView) => AttentionView = FIXTURE ? fixtureView(DIR) : (view) => view;
40
40
  const archived = new ArchivedInPaseo({ groupKeysOf: (itemKey) => attention.groupKeysOf(itemKey), acknowledge: (keys, upTo) => attention.acknowledge(keys, upTo) });
41
41
  const started = attention.start().catch((error) => console.error("Attention Span failed to start:", error));
42
42
  const ready = <T>(work: () => Promise<T>) => started.then(work);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@andrioid/paseo-attention-span",
3
- "version": "0.7.4",
3
+ "version": "0.7.5",
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
@@ -58,7 +58,7 @@ functional:
58
58
  PRS-02: see my pull requests with requested changes or unresolved review comments; so that I finish ongoing work, since I can only handle so many tasks at once.
59
59
  PRS-03: see my pull requests that are ready to merge; so that finished work ships.
60
60
  PRS-04: merge a ready pull request once its checks pass against its current base; so that what merges was tested against what it merges into.
61
- PRS-05: see my drafts after everything that isn't a draft; so that I finish or close my drafts before picking up new work.
61
+ PRS-05: see my work in progress last in Doing, my drafts and the issues I started without a pull request together, whatever waits on me first; so that I finish what I started before picking up new work.
62
62
  PRS-06: see other people's drafts only where they ask something of me, like a review or a mention; so that their unfinished work stays out of my list otherwise.
63
63
  PRS-07: refresh or close a draft that has gone stale; so that old drafts don't linger.
64
64
  PRS-08: have my pull requests that are assigned to someone else left out; so that pull requests I've handed over don't count as mine.
@@ -90,6 +90,7 @@ functional:
90
90
  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.
91
91
  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.
92
92
  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.
93
+ SES-11: see an issue I started a session on in Doing's In progress instead of Next up, until a card of its own shows it, like a pull request that closes it, or I archive its last session, counted only while its session waits on me; so that started work doesn't hide in Next up.
93
94
  next_up:
94
95
  As a developer, I can:
95
96
  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.
@@ -144,6 +145,7 @@ non_functional:
144
145
  PRIV-01: may keep a local copy of the GitHub data it shows; so that Attention Span shows instantly after a restart.
145
146
  reach:
146
147
  REACH-01: works in Paseo on both phone and desktop; so that I can triage from anywhere.
148
+ REACH-02: names the host its sidebar count is for when I have more than one host; so that I know whose work the count is.
147
149
  freshness:
148
150
  FRESH-01: stays current without me refreshing it; so that its count can be trusted.
149
151
  FRESH-02: shows what I just did on GitHub right away, and keeps showing it until GitHub's search catches up; so that I never refresh to see it.
@@ -502,7 +502,7 @@ export function classifyHistory(data: HistoryResult): Item[] {
502
502
  // feed, so the view leaves those out.
503
503
  export function classifyCloseAsks(data: HistoryResult): CloseAsk[] {
504
504
  const referenced = new Map(Object.entries(data.referenced ?? {}));
505
- // Closed issues count as issues too, so a PR that worked on one isn't put under another it mentions.
505
+ // Closed issues count as issues too, so a PR that closed one isn't put under another it also closes.
506
506
  const closed = new Set(compact(data.closed.nodes).map(prKey));
507
507
  const me = data.viewer?.login.toLowerCase();
508
508
  const asks = new Map<string, CloseAsk>();
package/server/fetch.ts CHANGED
@@ -109,8 +109,8 @@ export async function searchLive(gh: Gh, config: AttentionConfig, now: Date, unc
109
109
  return { unclaimed: { nodes: mergeUnclaimed(results) } };
110
110
  };
111
111
  const merge = (parts: Partial<LiveResult>[]) => Object.assign({}, ...parts) as LiveResult;
112
- const forDetails = Promise.all([search("mine"), search("assigned"), searchUnclaimed()]);
113
- const others = Promise.all([search("reviews"), search("mentions"), search("involved"), search("asked"), search("ended"), search("closedIssues")]);
112
+ const forDetails = Promise.all([search("mine"), search("reviews"), search("assigned"), searchUnclaimed()]);
113
+ const others = Promise.all([search("mentions"), search("involved"), search("asked"), search("ended"), search("closedIssues")]);
114
114
  const afterThem = forDetails.then((parts) => details(gh, config, merge(parts), projects.on, projects.problems));
115
115
  const [first, rest, found] = await Promise.all([forDetails, others, afterThem]);
116
116
  return { data: merge([...first, ...rest]), details: found };
@@ -123,14 +123,15 @@ function variables(config: AttentionConfig, names: readonly Exclude<SearchName,
123
123
 
124
124
  // Behind counts [UPS-07], required checks [PRS-14], issue field option order [NXT-02] and colors [NXT-10], and the Status
125
125
  // options of the boards Next up's issues are on [NXT-03].
126
- async function details(gh: Gh, config: AttentionConfig, data: Pick<LiveResult, "mine" | "assigned" | "unclaimed">, projects: boolean, problems: string[]): Promise<Details> {
126
+ async function details(gh: Gh, config: AttentionConfig, data: Pick<LiveResult, "mine" | "reviews" | "assigned" | "unclaimed">, projects: boolean, problems: string[]): Promise<Details> {
127
127
  const prs = data.mine.nodes.filter((pr) => pr?.headRefName && !pr.isCrossRepository);
128
128
  // Priority's colors tint its pill, so its options are asked for even when the config orders it.
129
129
  const effort = nextUpField(config, "effort");
130
130
  const needsOptions = !!nextUpField(config, "priority") || (!!effort && !effort.order);
131
131
  const issues = [...data.unclaimed.nodes, ...data.assigned.nodes];
132
132
  const orgs = needsOptions ? [...new Set(issues.map((issue) => issue?.repository?.nameWithOwner.split("/")[0]).filter(Boolean))] : [];
133
- const refs = toLookUp(data.mine.nodes.filter((pr) => pr?.repository));
133
+ // Others' PRs too: one asking for my review can sit atop my stack and say which issue it closes [ATT-03].
134
+ const refs = toLookUp([...data.mine.nodes, ...data.reviews.nodes].filter((pr) => pr?.repository));
134
135
  const mergeState = mergeStates(gh, data.mine.nodes.filter((pr) => pr?.repository));
135
136
  const statuses = projects ? projectStatuses(gh, issueBoardIds(issues), problems) : Promise.resolve({});
136
137
  if (prs.length === 0 && orgs.length === 0 && refs.length === 0) return { ...readDetails({}, [], {}), mergeState: await mergeState, projectStatuses: await statuses };
@@ -182,7 +183,7 @@ export async function projectStatuses(gh: Gh, ids: string[], problems: string[])
182
183
  return Object.fromEntries([...found].flatMap(([id, board]) => (board?.field?.options ? [[id, board.field.options]] : [])));
183
184
  }
184
185
 
185
- // History's searches, then whether the issues my merged PRs refer to are still open, so Wrap up can offer to close one
186
+ // History's searches, then whether the issues my merged PRs close are still open, so Wrap up can offer to close one
186
187
  // whose work is done [HIS-01, ATT-24]. A lookup that fails only leaves those out until the next fetch.
187
188
  async function searchHistory(gh: Gh, config: AttentionConfig, now: Date, timeZone: string): Promise<HistoryResult> {
188
189
  const data = await gh.graphql<HistoryResult>(searchQuery(HISTORY_SEARCHES, true), variables(config, HISTORY_SEARCHES, now, timeZone));
@@ -198,7 +199,7 @@ async function lookUpIssues(gh: Gh, refs: IssueRef[]): Promise<Record<string, Re
198
199
  if (refs.length === 0) return {};
199
200
  const found = await lookupBatches<IssueRef, { issueOrPullRequest: Partial<ReferencedIssue> | null }>(gh, refs, "i", referencedIssuesQuery, {
200
201
  size: REFERENCED_BATCH,
201
- problem: (message) => console.error("Couldn't check the issues my merged PRs refer to:", message),
202
+ problem: (message) => console.error("Couldn't check the issues my merged PRs close:", message),
202
203
  });
203
204
  return Object.fromEntries([...found].flatMap(([, node]) => (node?.issueOrPullRequest?.repository ? [[prKey(node.issueOrPullRequest as ReferencedIssue), node.issueOrPullRequest as ReferencedIssue]] : [])));
204
205
  }
package/server/fixture.ts CHANGED
@@ -187,7 +187,7 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
187
187
  pr(102, { title: "Retry webhook deliveries with backoff", reviewThreads: { nodes: [thread(alice, 1), thread(bot, 2)] } }),
188
188
  pr(103, { title: "Fetch supplier price files nightly", reviewDecision: "APPROVED", closingIssuesReferences: closes(90, "Supplier prices are a week out of date") }),
189
189
  pr(104, { title: "Move price-file login into a service", isDraft: true, baseRefName: "branch-103", headRefName: "branch-104" }),
190
- // A stack GitHub links to no issue: its descriptions say which [ATT-03].
190
+ // A stack GitHub links to no issue: its top PR's description closes it [ATT-03].
191
191
  pr(105, { title: "Dialog focus returns to the trigger", body: "First of three stacked PRs for #132.", reviewDecision: "APPROVED", headRefName: "a11y-1" }),
192
192
  pr(106, { title: "Keyboard navigation for calendar cards", isDraft: true, baseRefName: "a11y-1", headRefName: "a11y-2", reviewDecision: "APPROVED" }),
193
193
  pr(107, { title: "Calendar: jump between weeks with keys", body: "Closes #132", isDraft: true, baseRefName: "a11y-2", headRefName: "a11y-3" }, "FAILURE"),
@@ -306,8 +306,8 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
306
306
  merged(179, "Move invoices to the new queue", 1),
307
307
  merged(173, "Speed up the order list", 9, 174),
308
308
  merged(175, "Remove the old importer", 16),
309
- { ...merged(194, "Statement layout", 1), body: "First of two for #152" },
310
- { ...merged(195, "Statement PDF download", 3 / 24), body: "Second of two for #152" },
309
+ { ...merged(194, "Statement layout", 1), body: "Fixes #152, first of two" },
310
+ { ...merged(195, "Statement PDF download", 3 / 24), body: "Closes #152" },
311
311
  ],
312
312
  reviewed: [
313
313
  { number: 190, title: "Add the VAT export", url: `https://github.com/${REPO}/pull/190`, mergedAt: daysAgo(1), mergedBy: { login: "alice" }, repository, author: alice, labels: labels("feature") },
@@ -426,7 +426,9 @@ export const FIXTURE_AGENTS: AgentSummary[] = [
426
426
  agent("agent-101", `${REPO}#101`, "fix", "running", 4),
427
427
  agent("agent-102", `${REPO}#102`, "address", "idle", 30, true),
428
428
  agent("agent-108", `${REPO}#108`, "rebase", "error", 90),
429
- agent("agent-150", `${REPO}#150`, "start", "idle", 300),
429
+ // Started on assigned #150, and on someone else's issue Next up doesn't know, which needs me: In progress [SES-11].
430
+ agent("agent-150", `${REPO}#150`, "start", "idle", 300, false, undefined, "Orders export times out for big shops"),
431
+ agent("agent-205", "acme/platform#205", "start", "idle", 8, true, undefined, "Plan single sign-on for partners"),
430
432
  agent("agent-90", `${REPO}#90`, undefined, "idle", 120, true),
431
433
  agent("agent-103", `${REPO}#103`, "rebase", "running", 6),
432
434
  agent("agent-113", `${REPO}#113`, "fix", "running", 2),
@@ -531,12 +533,15 @@ export const FIXTURE_KEPT: KeptRow[] = [
531
533
  const dismissedKept = new Set<string>();
532
534
  export const fixtureDismissKept = (workspaceId: string) => void dismissedKept.add(workspaceId);
533
535
 
534
- // A view with the made-up sessions, as the preview daemon has no agents, and kept worktrees for it to show [ATT-22].
535
- export const fixtureView = (view: AttentionView): AttentionView => ({
536
- ...view,
537
- fixtureAgents: FIXTURE_AGENTS,
538
- kept: [...(view.kept ?? []), ...FIXTURE_KEPT.filter((row) => !dismissedKept.has(row.workspaceId))],
539
- });
536
+ // A view with the made-up sessions, as the preview daemon has no agents, and kept worktrees for it to show [ATT-22]. While
537
+ // `fixture-no-started` exists in `dir`, the sessions started on issues are as good as archived, so Doing can clear [SES-11].
538
+ export const fixtureView =
539
+ (dir: string) =>
540
+ (view: AttentionView): AttentionView => ({
541
+ ...view,
542
+ fixtureAgents: existsSync(join(dir, "fixture-no-started")) ? FIXTURE_AGENTS.filter((agent) => agent.kind !== "start") : FIXTURE_AGENTS,
543
+ kept: [...(view.kept ?? []), ...FIXTURE_KEPT.filter((row) => !dismissedKept.has(row.workspaceId))],
544
+ });
540
545
 
541
546
  // The sheet's, picker's, session's and setup's asks, answered from made-up data; gh counts as signed in.
542
547
  export const fixtureAnswers = {
package/server/queries.ts CHANGED
@@ -257,7 +257,7 @@ export function reopenQuery(ids: string[]): string {
257
257
  return `query Reopened {\n${fields.join("\n")}\n}`;
258
258
  }
259
259
 
260
- // The issues my merged PRs refer to, a batch per request: whether each is still open, and the open PRs GitHub links to
260
+ // The issues my merged PRs close, a batch per request: whether each is still open, and the open PRs GitHub links to
261
261
  // it, anyone's, as a PR still open means the work isn't done [ATT-24, GH-01]. PRs answer nothing.
262
262
  export const REFERENCED_BATCH = 50;
263
263
  export function referencedIssuesQuery(refs: IssueRef[]): string {
@@ -9,7 +9,6 @@ export interface IssueRef {
9
9
  const REF = String.raw`(?:https://github\.com/([\w.-]+/[\w.-]+)/issues/(\d+)|(?<![\w/#&])(?:([\w.-]+/[\w.-]+))?#(\d+))(?![\w-])`;
10
10
  // GitHub's closing keywords [docs: linking a pull request to an issue].
11
11
  const CLOSING = new RegExp(String.raw`\b(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\b:?\s+${REF}`, "gi");
12
- const ANY = new RegExp(REF, "gi");
13
12
 
14
13
  // What counts as said: not code, quoted replies or template comments.
15
14
  function prose(body: string): string {
@@ -21,9 +20,10 @@ function prose(body: string): string {
21
20
  .replace(/^\s*>.*$/gm, "");
22
21
  }
23
22
 
24
- function refs(body: string | undefined, repo: string, pattern: RegExp): IssueRef[] {
23
+ // The issues a description closes with a keyword ("Closes #12"); plain mentions don't count.
24
+ export function closingRefs(body: string | undefined, repo: string): IssueRef[] {
25
25
  const found = new Map<string, IssueRef>();
26
- for (const match of prose(body ?? "").matchAll(pattern)) {
26
+ for (const match of prose(body ?? "").matchAll(CLOSING)) {
27
27
  const ref = { repo: match[1] ?? match[3] ?? repo, number: Number(match[2] ?? match[4]) };
28
28
  found.set(refKey(ref), ref);
29
29
  }
@@ -31,8 +31,6 @@ function refs(body: string | undefined, repo: string, pattern: RegExp): IssueRef
31
31
  }
32
32
 
33
33
  export const refKey = (ref: IssueRef) => `${ref.repo}#${ref.number}`;
34
- export const closingRefs = (body: string | undefined, repo: string) => refs(body, repo, CLOSING);
35
- export const mentionedRefs = (body: string | undefined, repo: string) => refs(body, repo, ANY);
36
34
 
37
35
  export interface LinkedPr {
38
36
  repo: string;
@@ -42,9 +40,9 @@ export interface LinkedPr {
42
40
  }
43
41
 
44
42
  // The issue for PRs listed bottom first, strongest evidence first: what GitHub links, then a closing keyword in a
45
- // description, then the one issue the bottom PR's description mentions. GitHub links only PRs into the default branch,
46
- // so a stack's upper PRs need their descriptions read. `isIssue` says whether a reference is an issue that counts, which
47
- // rules out PRs and closed issues; several mentioned issues are too ambiguous to pick from.
43
+ // description. GitHub links only PRs into the default branch, so a stack's upper PRs need their descriptions read. A plain
44
+ // mention ("follow-up to #12", "see #12") says nothing about resolving it, so it doesn't count. `isIssue` says whether a
45
+ // reference is an issue that counts, which rules out PRs and closed issues.
48
46
  export function issueFor(prs: LinkedPr[], isIssue: (key: string) => boolean): string | undefined {
49
47
  for (const pr of prs) {
50
48
  const linked = pr.linked.find(isIssue);
@@ -54,29 +52,28 @@ export function issueFor(prs: LinkedPr[], isIssue: (key: string) => boolean): st
54
52
  const closing = closingRefs(pr.body, pr.repo).map(refKey).find(isIssue);
55
53
  if (closing) return closing;
56
54
  }
57
- const mentioned = prs[0] ? mentionedRefs(prs[0].body, prs[0].repo).map(refKey).filter(isIssue) : [];
58
- return mentioned.length === 1 ? mentioned[0] : undefined;
55
+ return undefined;
59
56
  }
60
57
 
61
- // The references in my PRs' descriptions to look up, at most `max`: my PRs themselves and what GitHub links are known.
58
+ // The issues my PRs' descriptions close to look up, at most `max`: my PRs themselves and what GitHub links are known.
62
59
  type Node = { number: number; repository: { nameWithOwner: string } };
63
60
  const nodeKey = (node: Node) => `${node.repository.nameWithOwner}#${node.number}`;
64
61
 
65
62
  export function toLookUp(prs: (Node & { body?: string; closingIssuesReferences: { nodes: Node[] } })[], max = 100): IssueRef[] {
66
63
  const known = new Set(prs.flatMap((pr) => [pr, ...pr.closingIssuesReferences.nodes].map(nodeKey)));
67
64
  const wanted = new Map<string, IssueRef>();
68
- for (const pr of prs) for (const ref of mentionedRefs(pr.body, pr.repository.nameWithOwner)) if (!known.has(refKey(ref))) wanted.set(refKey(ref), ref);
65
+ for (const pr of prs) for (const ref of closingRefs(pr.body, pr.repository.nameWithOwner)) if (!known.has(refKey(ref))) wanted.set(refKey(ref), ref);
69
66
  return [...wanted.values()].slice(0, max);
70
67
  }
71
68
 
72
- // The issues my merged PRs refer to that History doesn't know closed, at most `max`, to ask whether they're still open
69
+ // The issues my merged PRs close that History doesn't know closed, at most `max`, to ask whether they're still open
73
70
  // [ATT-24]. My merged PRs themselves are known to be PRs.
74
71
  export function mergedToLookUp(merged: { number: number; body?: string; repository: { nameWithOwner: string }; closingIssuesReferences: { nodes: Node[] } }[], closed: Node[], max = 100): IssueRef[] {
75
72
  const known = new Set([...merged, ...closed].map(nodeKey));
76
73
  const wanted = new Map<string, IssueRef>();
77
74
  for (const pr of merged) {
78
75
  const linked = pr.closingIssuesReferences.nodes.map((node) => ({ repo: node.repository.nameWithOwner, number: node.number }));
79
- for (const ref of [...linked, ...mentionedRefs(pr.body, pr.repository.nameWithOwner)]) if (!known.has(refKey(ref))) wanted.set(refKey(ref), ref);
76
+ for (const ref of [...linked, ...closingRefs(pr.body, pr.repository.nameWithOwner)]) if (!known.has(refKey(ref))) wanted.set(refKey(ref), ref);
80
77
  }
81
78
  return [...wanted.values()].slice(0, max);
82
79
  }
@@ -29,7 +29,8 @@ export const SECTIONS = {
29
29
  upstream: { tab: "doing", title: "Needs upstream" },
30
30
  // Nobody has the next move until I ask someone [PRS-12].
31
31
  needs_reviewer: { tab: "doing", title: "Needs a reviewer" },
32
- drafts: { tab: "doing", title: "My drafts" },
32
+ // My drafts, and issues I started a session on that no other card shows yet [PRS-05, SES-11].
33
+ drafts: { tab: "doing", title: "In progress" },
33
34
  // Waiting groups these by who they wait on, not by section [WAI-01].
34
35
  wait_review: { tab: "waiting", title: "Waiting for review" },
35
36
  wait_reviewer: { tab: "waiting", title: "Waiting for the reviewer" },
@@ -0,0 +1,117 @@
1
+ import { type AgentSummary, type AttentionView, type Item, itemSessions, matchSessions, memberKeys, type NextUpIssue, type WrapItem } from "./attention";
2
+ import type { WrapView } from "./wrap-up";
3
+ import { keySet } from "./names";
4
+
5
+ // In progress: my drafts, and the issues I started a session on that no card shows yet [PRS-05, SES-11]. Pure, so the rules
6
+ // test in node. It's assembled on the client, which polls Paseo's sessions, and every place that shows or counts Doing or
7
+ // Next up reads the same projection.
8
+
9
+ // An issue I started from Next up or Wrap up, with no pull request, reply or wrap-up row of its own yet.
10
+ export interface StartedIssue {
11
+ key: string;
12
+ repo: string;
13
+ number: number;
14
+ // Next up's issue, when Next up knows it: assigned to me, or unclaimed where it looks. Without it, the card is plain.
15
+ issue?: NextUpIssue;
16
+ assigned: boolean;
17
+ // Its open sessions, the one that needs me first, then the latest.
18
+ sessions: AgentSummary[];
19
+ // One of its sessions waits on me: only then does it count [ATT-09].
20
+ needsMe: boolean;
21
+ // Its sessions' latest activity.
22
+ at: string;
23
+ }
24
+
25
+ type ProjectionView = WrapView & Pick<AttentionView, "count" | "assigned" | "unclaimed">;
26
+
27
+ // "owner/name#12" -> its parts.
28
+ function parseKey(key: string): { repo: string; number: number } | null {
29
+ const match = /^([^/\s]+\/[^#\s]+)#(\d+)$/.exec(key);
30
+ return match ? { repo: match[1], number: Number(match[2]) } : null;
31
+ }
32
+
33
+ // Every key a card already shows, open or finished: a started issue that has one belongs there, not here. That covers an
34
+ // issue whose PRs are listed under it, a reply on it, a close it waits for, and it closing [ATT-03, ATT-22, ATT-24]. A card
35
+ // I dismissed counts too, so dismissing it doesn't bring the issue back here [ATT-08].
36
+ function shownKeys(view: ProjectionView, wrap: WrapItem[]): Set<string> {
37
+ const items: Item[] = [
38
+ ...view.doing.flatMap((section) => section.items),
39
+ ...view.waiting.flatMap((group) => group.items),
40
+ ...view.history,
41
+ ...(view.ownClosed ?? []),
42
+ ];
43
+ return keySet([
44
+ ...(view.activeKeys ?? []),
45
+ ...items.flatMap(memberKeys),
46
+ ...(view.closeAsks ?? []).flatMap((ask) => [ask.key, ...ask.prs.map((pr) => pr.key)]),
47
+ ...wrap.flatMap((item) => item.wrap.keys),
48
+ ]);
49
+ }
50
+
51
+ // The issues with an open session started on them as an issue ("start") that no card shows, latest activity first. Sessions
52
+ // Paseo links by workspace, or started on a pull request, never make one, but once there is one they're its sessions too.
53
+ export function startedIssues(view: ProjectionView, agents: AgentSummary[], wrap: WrapItem[]): StartedIssue[] {
54
+ const shown = shownKeys(view, wrap);
55
+ const known = new Map<string, { issue: NextUpIssue; assigned: boolean }>();
56
+ for (const issue of view.unclaimed) known.set(issue.key.toLowerCase(), { issue, assigned: false });
57
+ for (const issue of view.assigned) known.set(issue.key.toLowerCase(), { issue, assigned: true });
58
+ const byKey = new Map<string, string>();
59
+ for (const agent of agents) {
60
+ const key = agent.itemKey.toLowerCase();
61
+ if (agent.kind === "start" && !shown.has(key) && !byKey.has(key)) byKey.set(key, agent.itemKey);
62
+ }
63
+ const started: StartedIssue[] = [];
64
+ for (const [key, itemKey] of byKey) {
65
+ const match = known.get(key);
66
+ const parts = match ? { repo: match.issue.repo, number: match.issue.number } : parseKey(itemKey);
67
+ if (!parts) continue;
68
+ const sessions = matchSessions(agents, [itemKey]);
69
+ started.push({
70
+ key: match?.issue.key ?? itemKey,
71
+ ...parts,
72
+ ...(match ? { issue: match.issue } : {}),
73
+ assigned: match?.assigned ?? false,
74
+ sessions,
75
+ needsMe: sessions.some((agent) => agent.requiresAttention),
76
+ at: sessions.map((agent) => agent.lastActivityAt ?? "").reduce((a, b) => (a > b ? a : b), ""),
77
+ });
78
+ }
79
+ return started.sort((a, b) => Number(b.needsMe) - Number(a.needsMe) || b.at.localeCompare(a.at));
80
+ }
81
+
82
+ // The view as Doing, Next up and their counts show it: started issues leave Next up for In progress, and the ones whose
83
+ // session waits on me add to Doing's count [ATT-09, NXT-06].
84
+ export function withInProgress<V extends ProjectionView>(view: V, agents: AgentSummary[], wrap: WrapItem[]): V & { started: StartedIssue[] } {
85
+ const started = startedIssues(view, agents, wrap);
86
+ if (started.length === 0) return { ...view, started };
87
+ const moved = keySet(started.map((issue) => issue.key));
88
+ const stays = (issue: NextUpIssue) => !moved.has(issue.key.toLowerCase());
89
+ return {
90
+ ...view,
91
+ assigned: view.assigned.filter(stays),
92
+ unclaimed: view.unclaimed.filter(stays),
93
+ count: view.count + started.filter((issue) => issue.needsMe).length,
94
+ started,
95
+ };
96
+ }
97
+
98
+ // One line of In progress: a draft from the server, or a started issue.
99
+ export type InProgressEntry = { kind: "draft"; item: Item } | { kind: "issue"; started: StartedIssue };
100
+
101
+ // Drafts and started issues together: whatever waits on me first, then the latest session activity; drafts without a
102
+ // session keep the server's order after them [PRS-05].
103
+ export function inProgressEntries(drafts: Item[], started: StartedIssue[], agents: AgentSummary[]): InProgressEntry[] {
104
+ const ranked = [
105
+ ...drafts.map((item, order) => {
106
+ const sessions = itemSessions(agents, item);
107
+ return {
108
+ entry: { kind: "draft", item } as InProgressEntry,
109
+ needsMe: sessions.some((agent) => agent.requiresAttention),
110
+ at: sessions.map((agent) => agent.lastActivityAt ?? "").reduce((a, b) => (a > b ? a : b), ""),
111
+ order,
112
+ };
113
+ }),
114
+ ...started.map((issue, order) => ({ entry: { kind: "issue", started: issue } as InProgressEntry, needsMe: issue.needsMe, at: issue.at, order: drafts.length + order })),
115
+ ];
116
+ return ranked.sort((a, b) => Number(b.needsMe) - Number(a.needsMe) || b.at.localeCompare(a.at) || a.order - b.order).map(({ entry }) => entry);
117
+ }