@andrioid/paseo-attention-span 0.4.14 → 0.6.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 (56) hide show
  1. package/OVERVIEW.md +13 -5
  2. package/README.md +2 -2
  3. package/client/attention-screen.tsx +140 -143
  4. package/client/card.tsx +4 -2
  5. package/client/history.tsx +189 -0
  6. package/client/icons.ts +3 -1
  7. package/client/mark.ts +19 -0
  8. package/client/next-up.tsx +16 -2
  9. package/client/sessions.ts +50 -3
  10. package/client/still.tsx +70 -27
  11. package/client/ui.tsx +3 -3
  12. package/client/wrap-up.tsx +197 -0
  13. package/docs/architecture.md +17 -10
  14. package/docs/screenshots/desktop-dark-doing-acknowledge.png +0 -0
  15. package/docs/screenshots/desktop-dark-doing-clear.png +0 -0
  16. package/docs/screenshots/desktop-dark-doing-issue-sheet.png +0 -0
  17. package/docs/screenshots/desktop-dark-doing-reviewers.png +0 -0
  18. package/docs/screenshots/desktop-dark-doing-sheet.png +0 -0
  19. package/docs/screenshots/desktop-dark-doing-wrap-dirty.png +0 -0
  20. package/docs/screenshots/desktop-dark-doing-wrap-multi.png +0 -0
  21. package/docs/screenshots/desktop-dark-doing-wrap.png +0 -0
  22. package/docs/screenshots/desktop-dark-doing.png +0 -0
  23. package/docs/screenshots/desktop-dark-history-filtered.png +0 -0
  24. package/docs/screenshots/desktop-dark-history-groups.png +0 -0
  25. package/docs/screenshots/desktop-dark-history.png +0 -0
  26. package/docs/screenshots/desktop-dark-next-up-setup.png +0 -0
  27. package/docs/screenshots/desktop-dark-next-up.png +0 -0
  28. package/docs/screenshots/desktop-dark-settings.png +0 -0
  29. package/docs/screenshots/desktop-dark-setup.png +0 -0
  30. package/docs/screenshots/desktop-dark-waiting.png +0 -0
  31. package/docs/screenshots/phone-dark-doing.png +0 -0
  32. package/docs/screenshots/phone-dark-history.png +0 -0
  33. package/docs/screenshots/phone-light-next-up-filtered.png +0 -0
  34. package/index.client.tsx +6 -1
  35. package/index.server.ts +21 -2
  36. package/package.json +9 -3
  37. package/requirements.yaml +13 -9
  38. package/server/archive.ts +132 -0
  39. package/server/archived.ts +120 -0
  40. package/server/changes.ts +184 -26
  41. package/server/classify.ts +9 -2
  42. package/server/fixture.ts +71 -12
  43. package/server/github-types.ts +29 -5
  44. package/server/queries.ts +33 -7
  45. package/server/service.ts +90 -19
  46. package/server/store.ts +10 -3
  47. package/server/view.ts +14 -5
  48. package/shared/archive.ts +37 -0
  49. package/shared/attention.ts +85 -8
  50. package/shared/changes.ts +26 -11
  51. package/shared/got-it.ts +23 -0
  52. package/shared/history-report.ts +61 -0
  53. package/shared/rpc.ts +23 -4
  54. package/shared/still.ts +29 -7
  55. package/shared/wrap-up.ts +126 -0
  56. package/docs/screenshots/desktop-dark-history-reviewed.png +0 -0
package/OVERVIEW.md CHANGED
@@ -6,7 +6,9 @@ There are four tabs. I think of them as a little story: what needs me now, what'
6
6
 
7
7
  ## Doing: what needs you now
8
8
 
9
- This is the one you'll live in. It's split by reason: someone's waiting for your reply, someone answered your question, a review's been requested, CI's failing, changes were requested, it's ready to merge, it needs upstream, nobody's been asked to review it yet, or it's one of your drafts. Only things you can act on, though. Nudging people lives in Waiting.
9
+ This is the one you'll live in. At the top is **Wrap up**: finished or handed-off work whose Paseo sessions are still open, waiting for you to put them away. Below that it's split by reason: someone's waiting for your reply, someone answered your question, a review's been requested, CI's failing, changes were requested, it's ready to merge, it needs upstream, nobody's been asked to review it yet, or it's one of your drafts. Only things you can act on, though. Nudging people lives in Waiting.
10
+
11
+ Wrap up is the cleanup pass. A PR that merged, an issue that closed, work that left your hands, a review you finished on someone else's PR: if one of your sessions is still open on it, it sits here once the agent is idle, newest finish first. **Archive session** puts the session and its worktree away. If anything is uncommitted or unpushed you get a sheet first, naming it, with **Open session** beside **Archive anyway**; several sessions get a list of their own. **Archive all clean** does the tidy ones in one go. A worktree shared with anything else, or a local checkout, is never archived, and there's no Undo, which is exactly why it checks first. Archived work goes to History as already read, not as a new note.
10
12
 
11
13
  ![Doing](docs/screenshots/desktop-dark-doing.png)
12
14
 
@@ -16,9 +18,13 @@ When there's nothing in it, you get a quiet horizon that follows the time of day
16
18
 
17
19
  ![Doing, with nothing in it](docs/screenshots/desktop-dark-doing-clear.png)
18
20
 
21
+ The other tabs get their own version when they're empty: a bench in History, an empty jetty in Waiting, a blank signpost in Next up. An empty Next up also points you to Settings, since it usually means it doesn't know where to look yet.
22
+
23
+ ![Next up, with nowhere to look](docs/screenshots/desktop-dark-next-up-setup.png)
24
+
19
25
  Mentions only count while the person is still waiting for you. Reply or react and it's gone. On your own issues and PRs, a new comment from the last 30 days shows up under **Answered** even if it doesn't tag you. On other people's threads only tags count. The point is to pick out the signal, and most of what happens in threads you once commented on isn't. If you do want those replies, turn on **Follow threads I've commented on** in Settings. Team mentions are left out entirely, because "@everyone-in-backend" is not really a question for *me*. And if something's just an FYI, dismiss it. It stays gone until something new happens on it.
20
26
 
21
- Sometimes other people move your work without asking: they merge your PR, close it, take it over, or unassign you from an issue. None of that is something to do, so it doesn't count, but it shouldn't happen behind your back either. Each one gets a line at the bottom of Doing, like "merged by dave 2h ago" or "phil took over", until you tap **Got it**.
27
+ Sometimes other people move your work without asking: they merge your PR, close it, close an issue assigned to you, reopen a PR you'd seen closed, take work over, or unassign you. None of that is something to do, so it doesn't count, but it shouldn't happen behind your back either. Each one waits at the top of **History**, like "merged by dave 2h ago" or "phil took over", and the tab gets a little green dot until you tap its check, or **Mark all as read** to clear them all. If the work is already in Wrap up, archiving the session acknowledges it instead.
22
28
 
23
29
  Every item has one main button that matches why it's there: Reply, Review, Fix CI, Merge. Open the item and you get 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.
24
30
 
@@ -75,13 +81,15 @@ Some orgs keep issues in a separate repo from the code. When that happens, the f
75
81
 
76
82
  ## History: what you got done
77
83
 
78
- The issues and PRs you finished in recent weeks, grouped by week, plus the PRs you reviewed that got merged. Reviews are work too, even if nobody counts them.
84
+ The issues and PRs you finished in recent weeks, grouped by week, with what others did at the top until you've seen it. Reviews are work too, even if nobody counts them, so **Filter** can show them under each week, along with the changes by others you've cleared. Finished work is always there; the other two are off until you ask, and the button remembers.
79
85
 
80
- There's a copy button per week that gives you a Markdown list of links, each led by what kind of work it was: 🐞 bug, 🚀 feature, 🔧 task, or 🔀 for a PR that's none of those. The kind comes from the issue type, else the labels, else a title like "fix: …", so it works whether or not your repos use issue types. Cards show it too. Issues closed as not planned stay out of the list. A PR someone else merged says who, and work that left your hands (a PR someone closed or took over, an issue you were taken off) sits apart under **Closed or handed off**, out of the list, even if its new owner merges it later. That's my standup prep now, and it takes about four seconds.
86
+ There's a copy button per week that gives you Markdown lists of what's shown, each line led by what kind of work it was: 🐞 bug, 🚀 feature, 🔧 task, or 🔀 for a PR that's none of those. The kind comes from the issue type, else the labels, else a title like "fix: …", so it works whether or not your repos use issue types. Cards show it too. Issues closed as not planned stay out of the list. A PR someone else merged says who, and so does an issue someone else closed. Work that left your hands (a PR someone closed or took over, an issue you were taken off) sits under **Changed by others** when that's shown, out of the list, even if its new owner merges it later. Changes by others are never copied. That's my standup prep now, and it takes about four seconds.
81
87
 
82
88
  ![History](docs/screenshots/desktop-dark-history.png)
83
89
 
84
- ![History with reviews](docs/screenshots/desktop-dark-history-reviewed.png)
90
+ ![History filtered to Reviewed and changes](docs/screenshots/desktop-dark-history-filtered.png)
91
+
92
+ ![Both lists under a week](docs/screenshots/desktop-dark-history-groups.png)
85
93
 
86
94
  ## Agent sessions
87
95
 
package/README.md CHANGED
@@ -8,10 +8,10 @@ It's a [Paseo](https://paseo.sh) plugin that boils GitHub down to a short list o
8
8
 
9
9
  ![Doing](docs/screenshots/desktop-dark-doing.png)
10
10
 
11
- - **Doing:** what needs you right now. Someone's waiting for a reply, a review, CI's red, something's ready to merge.
11
+ - **Doing:** what needs you right now. Someone's waiting for a reply, a review, CI's red, something's ready to merge, and at the top, finished work whose sessions you should put away.
12
12
  - **Waiting:** the ball's in someone else's court. You can stop thinking about it, at least until it's waited too long.
13
13
  - **Next up:** for when your plate is actually clear. It happens. Occasionally.
14
- - **History:** what you got done, for when someone asks and your mind goes blank.
14
+ - **History:** what you got done, for when someone asks and your mind goes blank, with what others did to your work at the top until you've seen it.
15
15
 
16
16
  I've tried not to assume much about how you use GitHub. Solo, a team that reviews everything, stacked PRs, issues first, open source: so far it copes with all of them. Tell me where it doesn't.
17
17
 
@@ -4,19 +4,18 @@ import { Markdown, TextInput, useToast } from "@getpaseo/plugin/client/ui";
4
4
  import { useQuery, useQueryClient } from "@tanstack/react-query";
5
5
  import { type ReactNode, useState } from "react";
6
6
  import { Pressable, ScrollView, Text, View } from "react-native";
7
- import { type ActionId, type AgentSummary, type AttentionView, type Chip, checkoutPr, type FailingChecks, type Item, itemSessions, liftActive, looseSessions, type NextUpIssue, ownStack, type PersonRole, type Reviewer, type Section, type SectionId, SECTIONS, type SubRow, TAB_FEED, type TabId, type Target, type WaitingGroup, type WaitingOn } from "../shared/attention";
7
+ import { type ActionId, type AgentSummary, type AttentionView, type Chip, checkoutPr, type FailingChecks, type Item, itemSessions, liftActive, looseSessions, type NextUpIssue, ownStack, type PersonRole, type Reviewer, type Section, type SectionId, SECTIONS, type SubRow, TAB_FEED, type TabId, type Target, type WaitingGroup, type WaitingOn, type WrapItem } from "../shared/attention";
8
8
  import { type AttentionConfig, nextUpSources, type SessionKind } from "../shared/config";
9
9
  import { failingList, groupLabel, rerunHistory, summarizeRerun } from "../shared/checks";
10
10
  import { changeText } from "../shared/changes";
11
11
  import { ago, linkList } from "../shared/format";
12
- import { isClear } from "../shared/still";
13
- import { workEmoji } from "../shared/work";
12
+ import { historyClear, isClear, nextUpClear, waitingClear } from "../shared/still";
14
13
  import { ACTION_SESSION, renderPrompt } from "../shared/prompts";
15
14
  import * as rpc from "../shared/rpc";
16
15
  import { type FeedbackKind, themeName } from "../shared/feedback";
17
16
  import { blocks } from "../shared/setup";
18
17
  import { useAttention } from "./data";
19
- import { CardList, CardRow, type CardProps } from "./card";
18
+ import { CardList, CardRow } from "./card";
20
19
  import type { IconName } from "./icons";
21
20
  import { NumberText, PlaceText } from "./entity";
22
21
  import { NextUpList } from "./next-up";
@@ -24,10 +23,16 @@ import { Still } from "./still";
24
23
  import { agentSignal, sessionEntry, startAnotherEntry } from "./session-menu";
25
24
  import { ActionSheet, DETAILS_STALE_MS, DetailLines, type DetailsQuery, detailsKey, FadeIn, githubEntry, Modal, type SheetEntry, useArrived, usePrefetchOnRest } from "./sheet";
26
25
  import { FeedbackAsk, FeedbackLine, type FeedbackScreen, FeedbackSheet } from "./feedback";
27
- import { branchWorkspaces, type FetchProviders, findCheckout, githubProjects, itemAgents, listProfiles, noProjectMessage, resolveAgentConfig, startSession } from "./sessions";
26
+ import { AGENTS_QUERY_KEY, branchWorkspaces, type FetchProviders, findCheckout, githubProjects, listProfiles, noProjectMessage, resolveAgentConfig, startSession, useItemAgents } from "./sessions";
27
+ import { ALL_NOTES, ALL_WRAP, noteBusy } from "../shared/got-it";
28
+ import { cleanSingle, doingCount, unreadChanges, wrapItems } from "../shared/wrap-up";
29
+ import { type ArchiveOutcome, archiveTarget } from "../shared/archive";
30
+ import { History } from "./history";
31
+ import { stateMark } from "./mark";
32
+ import { WrapUp } from "./wrap-up";
28
33
  import { SetupChecklist } from "./setup";
29
34
  import { UpdateNotice } from "./update";
30
- import { Avatar, Button, Disclosure, Hint, KeepStyles, LINE_HEIGHT, Loading, Meta, mix, SectionHeader, SpinningIcon, StylesProvider, TablerIcon, Toggle, useCopy, useHover, useStrongText, useStyles } from "./ui";
35
+ import { Avatar, Button, Hint, KeepStyles, LINE_HEIGHT, Loading, Meta, mix, SectionHeader, SpinningIcon, StylesProvider, TablerIcon, Toggle, useCopy, useHover, useStrongText, useStyles } from "./ui";
31
36
 
32
37
  // The agent icon marks every action that starts an agent session; the rest act on GitHub right away [ATT-13].
33
38
  const ACTION_ICONS: Record<ActionId, IconName> = {
@@ -183,10 +188,11 @@ const SECTION_ICONS: Record<SectionId, IconName> = {
183
188
  wait_reviewer: "replyArrow",
184
189
  wait_ci: "clock",
185
190
  wait_answer: "reply",
191
+ wrap: "archive",
186
192
  changed: "team",
187
193
  done: "merge",
188
194
  reviewed: "review",
189
- handed_off: "userShare",
195
+ handed_off: "team",
190
196
  };
191
197
 
192
198
  const TABS: { id: TabId; label: string; icon: IconName }[] = [
@@ -196,7 +202,6 @@ const TABS: { id: TabId; label: string; icon: IconName }[] = [
196
202
  { id: "next", label: "Next up", icon: "nextUp" },
197
203
  ];
198
204
 
199
- const AGENTS_QUERY_KEY = ["attention-span", "agents"] as const;
200
205
  type FetchContext = (input: RpcInput<typeof rpc.sessionContext>) => Promise<RpcOutput<typeof rpc.sessionContext>>;
201
206
  export type FetchDetails = (input: RpcInput<typeof rpc.itemDetails>) => Promise<RpcOutput<typeof rpc.itemDetails>>;
202
207
  type DefaultBranch = (repo: string) => Promise<string | null>;
@@ -248,12 +253,14 @@ function AttentionList({
248
253
  const toast = useToast();
249
254
  const queryClient = useQueryClient();
250
255
  const attention = useAttention();
251
- const agents = useQuery({ queryKey: AGENTS_QUERY_KEY, queryFn: () => itemAgents(paseo), refetchInterval: 15_000 });
256
+ const agents = useItemAgents();
252
257
  const fetchContext = useRpc(rpc.sessionContext);
253
258
  const dismiss = useRpc(rpc.dismissItem);
254
259
  const undismiss = useRpc(rpc.undismissItem);
255
260
  const restore = useRpc(rpc.restoreDismissed);
256
261
  const gotIt = useRpc(rpc.gotIt);
262
+ const saveHistoryFilter = useRpc(rpc.setHistoryFilter);
263
+ const archiveSessions = useRpc(rpc.archiveSessions);
257
264
  const saveScopes = useRpc(rpc.setScopes);
258
265
  const saveSources = useRpc(rpc.setSources);
259
266
  const saveProjects = useRpc(rpc.setProjectFilter);
@@ -279,9 +286,14 @@ function AttentionList({
279
286
  const [tab, setTab] = useState<TabId>("doing");
280
287
  // Every card with a change still running: each runs on its own.
281
288
  const [busy, setBusy] = useState<ReadonlySet<string>>(new Set());
289
+ // Sessions archived here, hidden before Paseo's list catches up; in previews, where nothing really archives, this is what
290
+ // makes a Wrap up row go away after its screenshot [ATT-22].
291
+ const [archivedSessions, setArchivedSessions] = useState<ReadonlySet<string>>(new Set());
282
292
  const [undoable, setUndoable] = useState<Undoable[]>([]);
283
293
  const [placing, setPlacing] = useState<Placing | null>(null);
284
294
  const [options, setOptions] = useState<OptionsSpec | null>(null);
295
+ // History's Filter sheet: Reviewed and Changed by others per week [HIS-07].
296
+ const [filtering, setFiltering] = useState(false);
285
297
  // The feedback sheet, then the first words for the kind picked in it [FB-01].
286
298
  const [feedback, setFeedback] = useState<"sheet" | FeedbackKind | null>(null);
287
299
  const view = attention.data;
@@ -290,7 +302,6 @@ function AttentionList({
290
302
  const failing = !!attention.error || !!view?.feeds.live.error;
291
303
  const setup = useQuery({ queryKey: ["attention-span", "setup"], queryFn: () => fetchSetup({}), enabled: failing });
292
304
  const [checking, setChecking] = useState(false);
293
-
294
305
  async function run(key: string, label: string, work: () => Promise<unknown>) {
295
306
  setBusy((keys) => new Set(keys).add(key));
296
307
  try {
@@ -374,21 +385,35 @@ function AttentionList({
374
385
 
375
386
  // Each tab shows how fresh its own feed is.
376
387
  const feed = view.feeds[TAB_FEED[tab]];
377
- // Calm only once a refresh that worked says Doing is empty [ATT-18].
378
- const clear = isClear(view, !!attention.error);
388
+ // Wrap up is made here from the sessions the screen and sidebar already poll; the server archives and acknowledges [ATT-22].
389
+ const agentsNow = (view.fixtureAgents ?? agents.data ?? []).filter((agent) => !archivedSessions.has(agent.id));
390
+ const wrap = wrapItems(view, agentsNow);
391
+ // Notes about work Already in Wrap up wait there; archiving acknowledges them [HIS-07, ATT-22].
392
+ const notes = unreadChanges(view.history.filter((item) => item.section === "changed"), wrap);
393
+ // Calm only once a refresh that worked says Doing is empty, Wrap up included [ATT-18, ATT-22].
394
+ // Sessions not known yet, or failing to load, leave Wrap up unknown: no calm on that [ATT-18, ATT-22].
395
+ const sessionsKnown = !!view.fixtureAgents || (agents.isSuccess && !agents.isError);
396
+ const clear = sessionsKnown && isClear(view, !!attention.error, wrap.length);
397
+ // The other tabs' scenes, on the same terms [HIS-08, WAI-04, NXT-13].
398
+ const calm = {
399
+ history: historyClear(view, notes.length, !!attention.error),
400
+ waiting: waitingClear(view, !!attention.error),
401
+ next: nextUpClear(view, !!attention.error),
402
+ };
379
403
  // ⟳ 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.
380
404
  const pressed = attention.isRefreshing(TAB_FEED[tab]);
381
405
  const refreshing = feed.refreshing || attention.isFetching || pressed;
382
406
  const counts: Record<TabId, number> = {
383
407
  history: view.history.filter((item) => item.section === "done").length,
384
- doing: view.count,
408
+ doing: doingCount(view, wrap),
385
409
  // Work waiting on several people counts once.
386
410
  waiting: new Set(view.waiting.flatMap((group) => group.items.map((item) => item.key))).size,
387
411
  next: view.assigned.length + view.unclaimed.length,
388
412
  };
389
413
 
390
414
  const actions: Actions = {
391
- agents: view.fixtureAgents ?? agents.data ?? [],
415
+ agents: agentsNow,
416
+ fixture: !!view.fixtureAgents,
392
417
  startWithOptions: setOptions,
393
418
  busy,
394
419
  config: view.config,
@@ -404,10 +429,10 @@ function AttentionList({
404
429
  const session = ACTION_SESSION[action];
405
430
  const { target } = item;
406
431
  if (action === "reply") return void openExternalUrl(item.person?.url ?? item.url);
407
- // [ATT-21]
432
+ // [HIS-07]
408
433
  if (action === "got_it" && item.change) {
409
434
  const { id } = item.change;
410
- return change(item.key, "Got it", () => gotIt({ id, on: true }), `Cleared the note on “${item.title}”`, () => gotIt({ id, on: false }));
435
+ return change(item.key, "Got it", () => gotIt({ ids: [id], on: true }), `Cleared the note on “${item.title}”`, () => gotIt({ ids: [id], on: false }));
411
436
  }
412
437
  if (session) return void startWithDefaults(item.key, session, target);
413
438
  if (action === "update") change(item.key, "Update", () => update({ key: item.key, target }), `Updating PR ${target.number} with ${target.baseRefName}`);
@@ -449,9 +474,41 @@ function AttentionList({
449
474
  action === "merge"
450
475
  ? change(item.key, "Merge", () => merge({ key: item.key, target: item.target }), `PR ${item.target.number} merged`)
451
476
  : change(item.key, "Close", () => close({ key: item.key, target: item.target, comment }), `PR ${item.target.number} closed`),
477
+ // Got it on every Changed by others note at once; one Undo brings them all back [HIS-07].
478
+ gotItAll: (items) => {
479
+ const ids = items.flatMap((item) => (item.change ? [item.change.id] : []));
480
+ const notes = `${ids.length} note${ids.length === 1 ? "" : "s"}`;
481
+ change(ALL_NOTES, "Mark all as read", () => gotIt({ ids, on: true }), `Cleared ${notes} on changes by others`, () => gotIt({ ids, on: false }));
482
+ },
452
483
  dismiss: (item) => change(item.key, "Dismiss", () => dismiss({ key: item.key }), `Dismissed “${item.title}”`, () => undismiss({ key: item.key }), true),
453
484
  };
454
485
 
486
+ // Archive sessions, with the busy key that makes it wait for Archive all clean and the other way round [ATT-22].
487
+ // No Undo: Paseo's SDK can't restore a workspace and its agents, so the sheet is the safeguard instead.
488
+ async function archiveRows(items: WrapItem[], confirm: boolean, key = ALL_WRAP): Promise<ArchiveOutcome | null> {
489
+ if (items.length === 0) return null;
490
+ setBusy((keys) => new Set(keys).add(key));
491
+ try {
492
+ const outcome = await archiveSessions({ targets: items.map(archiveTarget), confirm });
493
+ attention.setView(outcome.view);
494
+ if (outcome.ok) {
495
+ const archived = new Set(items.flatMap((item) => item.wrap.sessions.map((session) => session.id)));
496
+ setArchivedSessions((known) => new Set([...known, ...archived]));
497
+ const sessions = archived.size;
498
+ if (outcome.warning) toast.error(outcome.warning);
499
+ else toast.show(sessions === 1 ? `Archived the session on #${items[0].number}` : `Archived ${sessions} sessions`, { variant: "success" });
500
+ } else if (outcome.reason === "working") {
501
+ toast.error(`Couldn't archive: ${outcome.message}`);
502
+ }
503
+ return outcome;
504
+ } catch (error) {
505
+ toast.error(`Archive failed: ${(error as Error).message}`);
506
+ return null;
507
+ } finally {
508
+ setBusy((keys) => new Set([...keys].filter((other) => other !== key)));
509
+ }
510
+ }
511
+
455
512
  const switchTab = (id: TabId) => {
456
513
  setTab(id);
457
514
  setUndoable([]);
@@ -463,7 +520,7 @@ function AttentionList({
463
520
  <View style={[styles.row, { justifyContent: "space-between", flexWrap: "wrap" }]}>
464
521
  <View style={styles.row}>
465
522
  {TABS.map(({ id, label, icon }) => (
466
- <Tab key={id} icon={icon} label={label} count={counts[id]} active={tab === id} onPress={() => switchTab(id)} />
523
+ <Tab key={id} icon={icon} label={label} count={counts[id]} active={tab === id} dot={id === "history" && notes.length > 0} onPress={() => switchTab(id)} />
467
524
  ))}
468
525
  </View>
469
526
  <View style={[styles.row, { gap: 16 }]}>
@@ -505,10 +562,55 @@ function AttentionList({
505
562
  />
506
563
  </View>
507
564
  ))}
508
- {tab === "history" ? <History items={view.history} actions={actions} /> : null}
565
+ {tab === "history" ? (
566
+ <History
567
+ calm={calm.history}
568
+ notes={notes}
569
+ items={view.history}
570
+ filter={view.historyFilter ?? []}
571
+ filtering={filtering}
572
+ onFiltering={setFiltering}
573
+ onFilter={(next) => {
574
+ // Ticks apply right away, like Next up's; the server remembers them [HIS-07].
575
+ attention.setView({ ...view, historyFilter: next });
576
+ saveHistoryFilter({ filter: next })
577
+ .then((saved) => attention.setView(saved))
578
+ .catch((error: Error) => toast.error(`Saving the filter failed: ${error.message}`));
579
+ }}
580
+ busy={busy}
581
+ onMarkAllRead={actions.gotItAll}
582
+ card={(items) => <Card items={items} actions={actions} />}
583
+ />
584
+ ) : null}
509
585
  {tab === "doing" ? (
510
586
  <>
511
- {clear ? <Still /> : view.doing.length ? <Sections sections={view.doing} actions={actions} /> : !feed.fetchedAt && !feed.error ? <Loading text="Checking GitHub…" /> : null}
587
+ {clear ? <Still /> : wrap.length || view.doing.length ? (
588
+ <>
589
+ {wrap.length > 0 ? (
590
+ <WrapUp
591
+ items={wrap}
592
+ busy={busy}
593
+ login={view.login}
594
+ fixture={!!view.fixtureAgents}
595
+ openAgent={openAgent}
596
+ onArchive={(item, confirm) => archiveRows([item], confirm, item.key)}
597
+ onArchiveAll={async () => {
598
+ const clean = wrap.filter(cleanSingle);
599
+ if (clean.length === 0) return;
600
+ const outcome = await archiveRows(clean, false);
601
+ if (outcome && !outcome.ok && outcome.reason === "unsaved") toast.error("Some sessions have unsaved changes. Archive them one by one.");
602
+ }}
603
+ />
604
+ ) : null}
605
+ {view.doing.length > 0 ? <Sections sections={view.doing} actions={actions} /> : null}
606
+ </>
607
+ ) : !feed.fetchedAt && !feed.error ? (
608
+ <Loading text="Checking GitHub…" />
609
+ ) : agents.isError ? (
610
+ <Text style={styles.muted}>Couldn't check your sessions, so Wrap up isn't known yet.</Text>
611
+ ) : !sessionsKnown ? (
612
+ <Loading text="Checking your sessions…" />
613
+ ) : null}
512
614
  {view.dismissedCount > undoable.filter((row) => row.dismissal).length ? (
513
615
  <Pressable
514
616
  accessibilityRole="button"
@@ -520,9 +622,13 @@ function AttentionList({
520
622
  ) : null}
521
623
  </>
522
624
  ) : null}
523
- {tab === "waiting" ? <Waiting groups={view.waiting} actions={actions} /> : null}
625
+ {tab === "waiting" ? (
626
+ calm.waiting ? <Still shore="jetty" title="Nobody's holding you up." line="Nothing to chase." /> : <Waiting groups={view.waiting} actions={actions} />
627
+ ) : null}
524
628
  {tab === "next" ? (
525
629
  <NextUpList
630
+ calm={calm.next}
631
+ openSettings={openSettings}
526
632
  assigned={view.assigned}
527
633
  unclaimed={view.unclaimed}
528
634
  unclaimedFrom={view.unclaimedFrom}
@@ -584,19 +690,21 @@ function AttentionList({
584
690
  );
585
691
  }
586
692
 
587
- function Tab({ icon, label, count, active, onPress }: { icon: IconName; label: string; count: number; active: boolean; onPress: () => void }) {
693
+ function Tab({ icon, label, count, active, dot, onPress }: { icon: IconName; label: string; count: number; active: boolean; dot?: boolean; onPress: () => void }) {
588
694
  const styles = useStyles();
589
695
  const color = active ? styles.c.foreground : styles.c.foregroundMuted;
590
- // A soft round badge for the count, a shade brighter on the open tab; green marks only where I am.
696
+ // A soft round badge for the count, a shade brighter on the open tab; green marks only where I am. A dot says History
697
+ // has unread changes without adding them to the count [HIS-07].
591
698
  return (
592
699
  <Pressable
593
700
  accessibilityRole="tab"
594
- accessibilityLabel={`${label}, ${count}`}
701
+ accessibilityLabel={`${label}, ${count}${dot ? ", unread changes" : ""}`}
595
702
  accessibilityState={{ selected: active }}
596
703
  onPress={onPress}
597
704
  style={[styles.row, { gap: 6, paddingVertical: 7, paddingHorizontal: styles.compact ? 9 : 12, borderRadius: 9, backgroundColor: active ? styles.c.surface2 : "transparent" }]}
598
705
  >
599
706
  <TablerIcon name={icon} size={16} color={active ? styles.action : color} />
707
+ {dot ? <View style={{ position: "absolute", top: 6, right: 6, width: 7, height: 7, borderRadius: 4, backgroundColor: styles.action }} /> : null}
600
708
  {/* On phones only the active tab is labelled, so four tabs fit. */}
601
709
  {active || !styles.compact ? <Text style={{ color, fontSize: 14, fontWeight: active ? "600" : "400" }}>{label}</Text> : null}
602
710
  <View style={{ minWidth: 20, alignItems: "center", paddingHorizontal: 6, paddingVertical: 1, borderRadius: 9, backgroundColor: tint(styles.c.foreground, active ? 0.14 : 0.08) }}>
@@ -616,6 +724,8 @@ function tint(color: string, alpha: number): string {
616
724
 
617
725
  interface Actions {
618
726
  agents: AgentSummary[];
727
+ // Previews have made-up sessions: show their sheets locally instead of asking a daemon that has none.
728
+ fixture: boolean;
619
729
  startWithOptions: (spec: OptionsSpec) => void;
620
730
  busy: ReadonlySet<string>;
621
731
  config: AttentionConfig;
@@ -632,24 +742,11 @@ interface Actions {
632
742
  acknowledge: (item: Item, commentIds: string[]) => void;
633
743
  confirm: (item: Item, action: "merge" | "close", comment?: string) => void;
634
744
  dismiss: (item: Item) => void;
745
+ gotItAll: (items: Item[]) => void;
635
746
  openAgent: (agentId: string) => void;
636
747
  started: (agentId: string) => Promise<void>;
637
748
  }
638
749
 
639
- // What the card is: open, draft, merged or closed. Urgency stays in the chips and section headers.
640
- // A note on what someone else did shows what happened instead; its words say it too, so color isn't the only sign [ATT-21].
641
- function stateMark(item: Item): CardProps["mark"] {
642
- if (item.change) {
643
- const kind = item.change.kind;
644
- if (kind === "merged") return { icon: "merge", tone: "good" };
645
- if (kind === "closed") return { icon: "prClosed", tone: "bad" };
646
- return { icon: kind === "unassigned" ? "userMinus" : "userShare", tone: "warn" };
647
- }
648
- if (item.closedAt) return item.kind === "pr" ? { icon: "merge", tone: "good" } : { icon: "issueClosed", tone: item.chips.length ? "neutral" : "good" };
649
- if (item.kind === "issue") return { icon: "issue", tone: "good" };
650
- return item.draft ? { icon: "draft", tone: "neutral" } : { icon: "pr", tone: "good" };
651
- }
652
-
653
750
  // A card that works collapsed: its main action and ›. Tapping it opens the sheet with everything else [ATT-05, ATT-06].
654
751
  const isRed = (chips: Chip[]) => chips.some((chip) => chip.tone === "bad");
655
752
 
@@ -733,7 +830,7 @@ function ItemRow({ item, first, actions, group }: { item: Item; first: boolean;
733
830
  when: item.change
734
831
  ? changeText(item.change)
735
832
  : item.closedAt
736
- ? `${item.kind === "pr" ? "merged" : "closed"} ${ago(item.closedAt)} ago${item.mergedBy ? ` by ${item.mergedBy}` : ""}`
833
+ ? `${item.kind === "pr" ? "merged" : "closed"} ${ago(item.closedAt)} ago${(item.kind === "pr" ? item.mergedBy : item.closedBy) ? ` by ${item.kind === "pr" ? item.mergedBy : item.closedBy}` : ""}${item.notPlanned ? " as not planned" : ""}`
737
834
  : undefined,
738
835
  signals: chips,
739
836
  }}
@@ -749,18 +846,18 @@ function ItemRow({ item, first, actions, group }: { item: Item; first: boolean;
749
846
  }
750
847
  onOpen={open}
751
848
  hover={prefetch}
752
- busy={actions.busy.has(item.key)}
849
+ busy={item.change ? noteBusy(actions.busy, item.key) : actions.busy.has(item.key)}
753
850
  primary={
754
851
  sessions[0]
755
852
  ? { label: "Open session", icon: "agent", onPress: () => actions.openAgent(sessions[0].id) }
756
853
  : main
757
- ? { label: actionLabel(main, item), icon: ACTION_ICONS[main], onPress: () => perform(main) }
854
+ ? { label: actionLabel(main, item), icon: ACTION_ICONS[main], iconOnly: main === "got_it", onPress: () => perform(main) }
758
855
  : undefined
759
856
  }
760
857
  secondary={[
761
858
  only ? { label: only.label, accessibilityLabel: only.accessibilityLabel, icon: only.icon, onPress: only.onPress } : { label: `Details for #${item.number}`, icon: "chevronRight", onPress: open },
762
- // History is where I report from, so its cards copy their link in one tap [ATT-15].
763
- ...(history ? [{ label: `Copy link to #${item.number}`, icon: "copy" as const, onPress: () => copy(item.url, `Copied link to #${item.number}`) }] : []),
859
+ // History is where I report from, so its cards copy their link in one tap [ATT-15]. Unread notes are not report rows.
860
+ ...(history && item.section !== "changed" ? [{ label: `Copy link to #${item.number}`, icon: "copy" as const, onPress: () => copy(item.url, `Copied link to #${item.number}`) }] : []),
764
861
  ]}
765
862
  confirm={
766
863
  confirm === "merge"
@@ -899,7 +996,7 @@ function sheetEntries(
899
996
  // History, where an issue is its own target, the first of the PRs that closed it.
900
997
  const pr = targetUrl(item) && item.target.kind === "pr" ? item.target : item.kind === "issue" && item.children[0] ? item.children[0] : undefined;
901
998
  entries.push(githubEntry(item, (url) => close(() => void openExternalUrl(url))(), pr));
902
- // Nothing's left to start on once it's merged or closed, or out of my hands; a note is cleared with Got it, not dismissed [ATT-21].
999
+ // Nothing's left to start on once it's merged or closed, or out of my hands; a note is cleared with Got it, not dismissed [HIS-07].
903
1000
  if (!item.closedAt && !item.change) entries.push(startAnotherEntry(sessions.length > 0, withOptions("Start session", fallbackKind(item))));
904
1001
  if (inDoing && !item.change) entries.push({ key: "dismiss", icon: "dismiss", label: "Dismiss", detail: "Hides it until something new happens on it", housekeeping: true, onPress: close(() => actions.dismiss(item)) });
905
1002
  return entries;
@@ -1208,106 +1305,6 @@ function Waiting({ groups, actions }: { groups: WaitingGroup[]; actions: Actions
1208
1305
  });
1209
1306
  }
1210
1307
 
1211
- // Monday-start weeks in the device's time zone.
1212
- function weekOf(iso: string): Date {
1213
- const day = new Date(iso);
1214
- day.setHours(0, 0, 0, 0);
1215
- day.setDate(day.getDate() - ((day.getDay() + 6) % 7));
1216
- return day;
1217
- }
1218
-
1219
- function weekLabel(monday: Date): string {
1220
- const weeks = Math.round((weekOf(new Date().toISOString()).getTime() - monday.getTime()) / (7 * 86_400_000));
1221
- if (weeks === 0) return "This week";
1222
- if (weeks === 1) return "Last week";
1223
- const sunday = new Date(monday.getTime() + 6 * 86_400_000);
1224
- const format = (date: Date) => date.toLocaleDateString(undefined, { month: "short", day: "numeric" });
1225
- return `${format(monday)} – ${format(sunday)}`;
1226
- }
1227
-
1228
- // What I finished, by week, with reviews tucked away per week [HIS-01, HIS-02].
1229
- // A week copies as a list of links to paste into a report, each led by its kind; its reviews copy as a list of their own [HIS-03, HIS-04].
1230
- function History({ items, actions }: { items: Item[]; actions: Actions }) {
1231
- const styles = useStyles();
1232
- const copy = useCopy();
1233
- // Groups opened, as "<week>:<group>"; each opens on its own.
1234
- const [open, setOpen] = useState<ReadonlySet<string>>(new Set());
1235
- const toggle = (id: string) => setOpen((now) => (now.has(id) ? new Set([...now].filter((other) => other !== id)) : new Set([...now, id])));
1236
- if (items.length === 0) return <Text style={styles.text}>Nothing finished in this period.</Text>;
1237
- const weeks = new Map<number, Item[]>();
1238
- for (const item of items) {
1239
- const week = weekOf(item.closedAt!).getTime();
1240
- weeks.set(week, [...(weeks.get(week) ?? []), item]);
1241
- }
1242
- const blocks: ReactNode[] = [];
1243
- for (const [week, all] of [...weeks].sort((a, b) => b[0] - a[0])) {
1244
- const done = all.filter((item) => item.section === "done").sort((a, b) => b.closedAt!.localeCompare(a.closedAt!));
1245
- const reviewed = all.filter((item) => item.section === "reviewed");
1246
- // Out of the week's copy: it wasn't my finished work [HIS-06].
1247
- const handed = all.filter((item) => item.section === "handed_off").sort((a, b) => b.closedAt!.localeCompare(a.closedAt!));
1248
- // What was done, each led by its kind; not planned issues stay on screen but out of the report [HIS-03, HIS-04].
1249
- const copied = done.filter((item) => !item.notPlanned);
1250
- const label = weekLabel(new Date(week));
1251
- blocks.push(
1252
- <View key={week} style={{ gap: 8 }}>
1253
- <SectionHeader
1254
- icon="clock"
1255
- title={label}
1256
- count={done.length}
1257
- action={
1258
- copied.length > 0 ? (
1259
- <View style={styles.overCard}>
1260
- <Button
1261
- icon="markdown"
1262
- variant="ghost"
1263
- accessibilityLabel={`Copy links from ${label}`}
1264
- onPress={() =>
1265
- copy(
1266
- linkList(copied.map((item) => ({ title: item.title, url: item.url, mark: workEmoji(item) }))),
1267
- `Copied ${copied.length} link${copied.length === 1 ? "" : "s"} from ${label}`,
1268
- )
1269
- }
1270
- />
1271
- </View>
1272
- ) : null
1273
- }
1274
- />
1275
- {done.length > 0 ? <Card items={done} actions={actions} /> : null}
1276
- {reviewed.length > 0 ? (
1277
- <View style={{ gap: 8 }}>
1278
- {/* Its copy lines up under the week's, at the right edge, like every Markdown copy. */}
1279
- <View style={styles.row}>
1280
- <Disclosure label="Reviewed" count={reviewed.length} open={open.has(`${label}:reviewed`)} onPress={() => toggle(`${label}:reviewed`)} />
1281
- <View style={{ flex: 1 }} />
1282
- <View style={styles.overCard}>
1283
- <Button
1284
- icon="markdown"
1285
- variant="ghost"
1286
- accessibilityLabel={`Copy reviewed links from ${label}`}
1287
- onPress={() =>
1288
- copy(
1289
- linkList(reviewed.map((item) => ({ title: item.title, url: item.url, mark: workEmoji(item) }))),
1290
- `Copied ${reviewed.length} reviewed link${reviewed.length === 1 ? "" : "s"} from ${label}`,
1291
- )
1292
- }
1293
- />
1294
- </View>
1295
- </View>
1296
- {open.has(`${label}:reviewed`) ? <Card items={reviewed} actions={actions} /> : null}
1297
- </View>
1298
- ) : null}
1299
- {handed.length > 0 ? (
1300
- <View style={{ gap: 8 }}>
1301
- <Disclosure label="Closed or handed off" count={handed.length} open={open.has(`${label}:handed`)} onPress={() => toggle(`${label}:handed`)} />
1302
- {open.has(`${label}:handed`) ? <Card items={handed} actions={actions} /> : null}
1303
- </View>
1304
- ) : null}
1305
- </View>,
1306
- );
1307
- }
1308
- return blocks;
1309
- }
1310
-
1311
1308
  // Stacked or linked PRs as a connected line; collapsed, only those needing attention [ATT-03, ATT-04].
1312
1309
  // In the sheet each row opens its PR on GitHub [ATT-12], and the PR an issue's actions apply to is tinted and says so [ATT-06].
1313
1310
  function StackLine({ rows, merged, links = false, target }: { rows: SubRow[]; merged: boolean; links?: boolean; target?: string }) {
package/client/card.tsx CHANGED
@@ -24,6 +24,8 @@ export interface CardAction {
24
24
  onPress: () => void;
25
25
  // Defaults to the label.
26
26
  accessibilityLabel?: string;
27
+ // Icon only, still in the main action's style, for an action whose icon says it all, like Got it's check [HIS-07].
28
+ iconOnly?: boolean;
27
29
  }
28
30
 
29
31
  export interface ConfirmSpec {
@@ -68,8 +70,8 @@ export function CardRow({ first, mark, title, meta, accessibilityLabel, onOpen,
68
70
  <View style={styles.wrap}>
69
71
  {primary ? (
70
72
  <Button
71
- label={primary.label}
72
- accessibilityLabel={primary.accessibilityLabel}
73
+ label={primary.iconOnly ? undefined : primary.label}
74
+ accessibilityLabel={primary.accessibilityLabel ?? primary.label}
73
75
  icon={primary.icon}
74
76
  variant="calm"
75
77
  busy={busy}