@andrioid/paseo-attention-span 0.4.13 → 0.5.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.
- package/OVERVIEW.md +10 -4
- package/README.md +2 -2
- package/client/attention-screen.tsx +142 -123
- package/client/card.tsx +4 -2
- package/client/history.tsx +184 -0
- package/client/icons.ts +7 -0
- package/client/mark.ts +19 -0
- package/client/sessions.ts +50 -3
- package/client/ui.tsx +18 -3
- package/client/wrap-up.tsx +197 -0
- package/docs/architecture.md +19 -7
- package/docs/screenshots/desktop-dark-doing-acknowledge.png +0 -0
- package/docs/screenshots/desktop-dark-doing-clear.png +0 -0
- package/docs/screenshots/desktop-dark-doing-issue-sheet.png +0 -0
- package/docs/screenshots/desktop-dark-doing-reviewers.png +0 -0
- package/docs/screenshots/desktop-dark-doing-sheet.png +0 -0
- package/docs/screenshots/desktop-dark-doing-wrap-dirty.png +0 -0
- package/docs/screenshots/desktop-dark-doing-wrap-multi.png +0 -0
- package/docs/screenshots/desktop-dark-doing-wrap.png +0 -0
- package/docs/screenshots/desktop-dark-doing.png +0 -0
- package/docs/screenshots/desktop-dark-history-filtered.png +0 -0
- package/docs/screenshots/desktop-dark-history-groups.png +0 -0
- package/docs/screenshots/desktop-dark-history.png +0 -0
- package/docs/screenshots/desktop-dark-next-up.png +0 -0
- package/docs/screenshots/desktop-dark-settings.png +0 -0
- package/docs/screenshots/desktop-dark-setup.png +0 -0
- package/docs/screenshots/desktop-dark-waiting.png +0 -0
- package/docs/screenshots/phone-dark-doing.png +0 -0
- package/docs/screenshots/phone-dark-history.png +0 -0
- package/docs/screenshots/phone-light-next-up-filtered.png +0 -0
- package/index.client.tsx +6 -1
- package/index.server.ts +21 -1
- package/package.json +8 -3
- package/requirements.yaml +11 -7
- package/server/archive.ts +132 -0
- package/server/archived.ts +120 -0
- package/server/changes.ts +355 -0
- package/server/classify.ts +15 -4
- package/server/fixture.ts +85 -8
- package/server/gh.ts +16 -4
- package/server/github-types.ts +67 -3
- package/server/queries.ts +62 -8
- package/server/service.ts +131 -11
- package/server/store.ts +20 -1
- package/server/view.ts +25 -6
- package/shared/archive.ts +37 -0
- package/shared/attention.ts +93 -3
- package/shared/changes.ts +66 -0
- package/shared/got-it.ts +23 -0
- package/shared/history-report.ts +61 -0
- package/shared/rpc.ts +23 -2
- package/shared/still.ts +4 -3
- package/shared/wrap-up.ts +126 -0
- package/docs/screenshots/desktop-dark-history-reviewed.png +0 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import { Pressable, Text, View } from "react-native";
|
|
3
|
+
import type { HistoryFilter, Item } from "../shared/attention";
|
|
4
|
+
import { allNotesBusy } from "../shared/got-it";
|
|
5
|
+
import { historyWeeks, weekOf } from "../shared/history-report";
|
|
6
|
+
import type { IconName } from "./icons";
|
|
7
|
+
import { Modal } from "./sheet";
|
|
8
|
+
import { Button, KeepStyles, SectionHeader, TablerIcon, useCopy, useStyles } from "./ui";
|
|
9
|
+
|
|
10
|
+
// History: what others did to my work, unread, on top until Got it or an archive; then what I finished, by week, with
|
|
11
|
+
// Reviewed and cleared changes when the filter shows them [HIS-01, HIS-02, HIS-06, HIS-07]. A week copies what's shown as
|
|
12
|
+
// Markdown lists, per kind; changes by others are never copied [HIS-03]. Which items go where is shared/history-report.ts.
|
|
13
|
+
|
|
14
|
+
function weekLabel(monday: Date): string {
|
|
15
|
+
const weeks = Math.round((weekOf(new Date().toISOString()).getTime() - monday.getTime()) / (7 * 86_400_000));
|
|
16
|
+
if (weeks === 0) return "This week";
|
|
17
|
+
if (weeks === 1) return "Last week";
|
|
18
|
+
const sunday = new Date(monday.getTime() + 6 * 86_400_000);
|
|
19
|
+
const format = (date: Date) => date.toLocaleDateString(undefined, { month: "short", day: "numeric" });
|
|
20
|
+
return `${format(monday)} – ${format(sunday)}`;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function History({
|
|
24
|
+
notes,
|
|
25
|
+
items,
|
|
26
|
+
filter,
|
|
27
|
+
filtering,
|
|
28
|
+
onFiltering,
|
|
29
|
+
onFilter,
|
|
30
|
+
busy,
|
|
31
|
+
onMarkAllRead,
|
|
32
|
+
card,
|
|
33
|
+
}: {
|
|
34
|
+
notes: Item[];
|
|
35
|
+
items: Item[];
|
|
36
|
+
filter: HistoryFilter[];
|
|
37
|
+
filtering: boolean;
|
|
38
|
+
onFiltering: (open: boolean) => void;
|
|
39
|
+
onFilter: (filter: HistoryFilter[]) => void;
|
|
40
|
+
busy: ReadonlySet<string>;
|
|
41
|
+
onMarkAllRead: (notes: Item[]) => void;
|
|
42
|
+
// The screen's cards, with their actions and sheets.
|
|
43
|
+
card: (items: Item[]) => ReactNode;
|
|
44
|
+
}) {
|
|
45
|
+
const styles = useStyles();
|
|
46
|
+
const copy = useCopy();
|
|
47
|
+
const { weeks, anything } = historyWeeks(items, filter);
|
|
48
|
+
if (notes.length === 0 && !anything) return <Text style={styles.text}>Nothing finished in this period.</Text>;
|
|
49
|
+
return (
|
|
50
|
+
<>
|
|
51
|
+
{notes.length > 0 ? (
|
|
52
|
+
<View>
|
|
53
|
+
<SectionHeader
|
|
54
|
+
icon="team"
|
|
55
|
+
title="Changed by others"
|
|
56
|
+
count={notes.length}
|
|
57
|
+
action={
|
|
58
|
+
notes.length > 1 ? (
|
|
59
|
+
<View style={styles.overCard}>
|
|
60
|
+
<Button
|
|
61
|
+
label="Mark all as read"
|
|
62
|
+
icon="check"
|
|
63
|
+
variant="ghost"
|
|
64
|
+
disabled={allNotesBusy(busy, notes.map((item) => item.key))}
|
|
65
|
+
onPress={() => onMarkAllRead(notes)}
|
|
66
|
+
/>
|
|
67
|
+
</View>
|
|
68
|
+
) : null
|
|
69
|
+
}
|
|
70
|
+
/>
|
|
71
|
+
{card(notes)}
|
|
72
|
+
</View>
|
|
73
|
+
) : null}
|
|
74
|
+
{/* Filter shows whenever a week holds anything, even only what the filter hides, so it can be turned on [HIS-07]. */}
|
|
75
|
+
{anything ? (
|
|
76
|
+
<View style={[styles.row, { justifyContent: "flex-end" }]}>
|
|
77
|
+
<Button
|
|
78
|
+
label={filter.length ? `Filter · ${filter.length}` : "Filter"}
|
|
79
|
+
accessibilityLabel={filter.length ? `Filter, ${filter.length} on` : "Filter"}
|
|
80
|
+
icon="filter"
|
|
81
|
+
variant={filter.length ? "calm" : "ghost"}
|
|
82
|
+
onPress={() => onFiltering(true)}
|
|
83
|
+
/>
|
|
84
|
+
</View>
|
|
85
|
+
) : null}
|
|
86
|
+
{anything && weeks.length === 0 ? <Text style={styles.text}>Nothing finished in this period.</Text> : null}
|
|
87
|
+
{weeks.map((week) => {
|
|
88
|
+
const label = weekLabel(week.monday);
|
|
89
|
+
const { links } = week.copy;
|
|
90
|
+
return (
|
|
91
|
+
<View key={week.monday.getTime()} style={{ gap: 8 }}>
|
|
92
|
+
<SectionHeader
|
|
93
|
+
icon="clock"
|
|
94
|
+
title={label}
|
|
95
|
+
count={week.done.length}
|
|
96
|
+
action={
|
|
97
|
+
links > 0 ? (
|
|
98
|
+
<View style={styles.overCard}>
|
|
99
|
+
<Button
|
|
100
|
+
icon="markdown"
|
|
101
|
+
variant="ghost"
|
|
102
|
+
accessibilityLabel={`Copy links from ${label}`}
|
|
103
|
+
onPress={() => copy(week.copy.text, `Copied ${links} link${links === 1 ? "" : "s"} from ${label}`)}
|
|
104
|
+
/>
|
|
105
|
+
</View>
|
|
106
|
+
) : null
|
|
107
|
+
}
|
|
108
|
+
/>
|
|
109
|
+
{week.done.length > 0 ? card(week.done) : null}
|
|
110
|
+
{week.reviewed.length > 0 ? (
|
|
111
|
+
<View style={{ gap: 8 }}>
|
|
112
|
+
<Subgroup icon="review" label="Reviewed" count={week.reviewed.length} />
|
|
113
|
+
{card(week.reviewed)}
|
|
114
|
+
</View>
|
|
115
|
+
) : null}
|
|
116
|
+
{week.changed.length > 0 ? (
|
|
117
|
+
<View style={{ gap: 8 }}>
|
|
118
|
+
<Subgroup icon="team" label="Changed by others" count={week.changed.length} />
|
|
119
|
+
{card(week.changed)}
|
|
120
|
+
</View>
|
|
121
|
+
) : null}
|
|
122
|
+
</View>
|
|
123
|
+
);
|
|
124
|
+
})}
|
|
125
|
+
{filtering ? <HistoryFilterSheet filter={filter} onChange={onFilter} onClose={() => onFiltering(false)} /> : null}
|
|
126
|
+
</>
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// A quiet name for a week's second list, like Reviewed or its cleared changes [HIS-02, HIS-07].
|
|
131
|
+
function Subgroup({ icon, label, count }: { icon: IconName; label: string; count: number }) {
|
|
132
|
+
const styles = useStyles();
|
|
133
|
+
return (
|
|
134
|
+
<View style={[styles.row, { gap: 6, paddingVertical: 2 }]}>
|
|
135
|
+
<TablerIcon name={icon} size={13} />
|
|
136
|
+
<Text style={styles.muted}>
|
|
137
|
+
{label} · {count}
|
|
138
|
+
</Text>
|
|
139
|
+
</View>
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// History's filter: Finished always, plus Reviewed and cleared Changed by others per week [HIS-07]. Ticks apply right away.
|
|
144
|
+
function HistoryFilterSheet({ filter, onChange, onClose }: { filter: HistoryFilter[]; onChange: (filter: HistoryFilter[]) => void; onClose: () => void }) {
|
|
145
|
+
const styles = useStyles();
|
|
146
|
+
const flip = (id: HistoryFilter) => onChange(filter.includes(id) ? filter.filter((other) => other !== id) : [...filter, id]);
|
|
147
|
+
const row = (id: HistoryFilter | null, label: string, note?: string) => {
|
|
148
|
+
const on = id === null || filter.includes(id);
|
|
149
|
+
return (
|
|
150
|
+
<Pressable
|
|
151
|
+
accessibilityRole="checkbox"
|
|
152
|
+
accessibilityState={{ checked: on, disabled: id === null }}
|
|
153
|
+
disabled={id === null}
|
|
154
|
+
accessibilityLabel={label}
|
|
155
|
+
onPress={() => id && flip(id)}
|
|
156
|
+
style={[styles.row, { paddingVertical: 11, paddingHorizontal: 14, opacity: id === null ? 0.65 : 1 }]}
|
|
157
|
+
>
|
|
158
|
+
<TablerIcon name={on ? "squareCheck" : "square"} size={18} color={on ? styles.action : styles.c.foregroundMuted} />
|
|
159
|
+
<Text style={[styles.text, { flex: 1 }]}>{label}</Text>
|
|
160
|
+
{note ? <Text style={styles.muted}>{note}</Text> : null}
|
|
161
|
+
</Pressable>
|
|
162
|
+
);
|
|
163
|
+
};
|
|
164
|
+
return (
|
|
165
|
+
<Modal title="Filter" open onOpenChange={(open) => (open ? null : onClose())}>
|
|
166
|
+
<Modal.Content>
|
|
167
|
+
<KeepStyles styles={styles}>
|
|
168
|
+
<Text style={styles.muted}>Show in each week</Text>
|
|
169
|
+
<View style={[styles.card, { backgroundColor: styles.c.surface2 }]}>
|
|
170
|
+
{row(null, "Finished", "always")}
|
|
171
|
+
<View style={{ height: 1, backgroundColor: styles.c.surface1 }} />
|
|
172
|
+
{row("reviewed", "Reviewed")}
|
|
173
|
+
<View style={{ height: 1, backgroundColor: styles.c.surface1 }} />
|
|
174
|
+
{row("changed", "Changed by others")}
|
|
175
|
+
</View>
|
|
176
|
+
<View style={[styles.row, { justifyContent: "flex-end" }]}>
|
|
177
|
+
<Button label="Clear" variant="ghost" disabled={filter.length === 0} onPress={() => onChange([])} />
|
|
178
|
+
<Button label="Done" variant="solid" onPress={onClose} />
|
|
179
|
+
</View>
|
|
180
|
+
</KeepStyles>
|
|
181
|
+
</Modal.Content>
|
|
182
|
+
</Modal>
|
|
183
|
+
);
|
|
184
|
+
}
|
package/client/icons.ts
CHANGED
|
@@ -51,6 +51,13 @@ export const ICONS = {
|
|
|
51
51
|
chevronRight: { svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"m9 6l6 6l-6 6\"/></svg>" },
|
|
52
52
|
plus: { svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M12 5v14m-7-7h14\"/></svg>" },
|
|
53
53
|
check: { svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"m5 12l5 5L20 7\"/></svg>" },
|
|
54
|
+
// Tabler git-pull-request-closed, user-share, user-minus and chevron-down: what others did to my work [HIS-07, HIS-06].
|
|
55
|
+
prClosed: { svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M4 18a2 2 0 1 0 4 0a2 2 0 1 0-4 0M4 6a2 2 0 1 0 4 0a2 2 0 1 0-4 0m12 12a2 2 0 1 0 4 0a2 2 0 1 0-4 0M6 8v8m12-5v5M16 4l4 4m0-4l-4 4\"/></svg>" },
|
|
56
|
+
userShare: { svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 7a4 4 0 1 0 8 0a4 4 0 0 0-8 0M6 21v-2a4 4 0 0 1 4-4h3m3 7l5-5m0 4.5V17h-4.5\"/></svg>" },
|
|
57
|
+
userMinus: { svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 7a4 4 0 1 0 8 0a4 4 0 0 0-8 0M6 21v-2a4 4 0 0 1 4-4h4c.348 0 .686.045 1.009.128M16 19h6\"/></svg>" },
|
|
58
|
+
// Tabler archive: puts a finished item's Paseo sessions away [ATT-22].
|
|
59
|
+
archive: { svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><g fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\"><path d=\"M3 4a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z\"/><path d=\"M5 8v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8M10 12h4\"/></g></svg>" },
|
|
60
|
+
chevronDown: { svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"m6 9l6 6l6-6\"/></svg>" },
|
|
54
61
|
// Tabler message-ai: marks actions that start or continue an agent session.
|
|
55
62
|
agent: { svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><g fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\"><path d=\"M8 9h8m-8 4h3.5m-1.506 6.804L8 21v-3H6a3 3 0 0 1-3-3V7a3 3 0 0 1 3-3h12a3 3 0 0 1 3 3v4\"/><path d=\"M14 21v-4a2 2 0 1 1 4 0v4m-4-2h4m3-4v6\"/></g></svg>" },
|
|
56
63
|
} as const;
|
package/client/mark.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Item } from "../shared/attention";
|
|
2
|
+
import type { CardProps } from "./card";
|
|
3
|
+
|
|
4
|
+
// What the card is: open, draft, merged or closed. Urgency stays in the chips and section headers.
|
|
5
|
+
// A note on what someone else did shows what happened instead; its words say it too, so color isn't the only sign [HIS-07].
|
|
6
|
+
export function stateMark(item: Item): CardProps["mark"] {
|
|
7
|
+
if (item.section === "reviewed" || item.wrap?.review) return { icon: "review", tone: "neutral" };
|
|
8
|
+
if (item.change) {
|
|
9
|
+
const kind = item.change.kind;
|
|
10
|
+
if (kind === "merged") return { icon: "merge", tone: "good" };
|
|
11
|
+
if (kind === "closed") return { icon: "prClosed", tone: "bad" };
|
|
12
|
+
if (kind === "issue_closed") return item.change.reason === "not_planned" ? { icon: "close", tone: "bad" } : { icon: "issueClosed", tone: "good" };
|
|
13
|
+
if (kind === "reopened") return { icon: "pr", tone: "warn" };
|
|
14
|
+
return { icon: kind === "unassigned" ? "userMinus" : "userShare", tone: "warn" };
|
|
15
|
+
}
|
|
16
|
+
if (item.closedAt) return item.kind === "pr" ? { icon: "merge", tone: "good" } : { icon: "issueClosed", tone: item.chips.length ? "neutral" : "good" };
|
|
17
|
+
if (item.kind === "issue") return { icon: "issue", tone: "good" };
|
|
18
|
+
return item.draft ? { icon: "draft", tone: "neutral" } : { icon: "pr", tone: "good" };
|
|
19
|
+
}
|
package/client/sessions.ts
CHANGED
|
@@ -1,11 +1,41 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { usePaseo, useRpc } from "@getpaseo/plugin/client";
|
|
2
|
+
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { type AgentSummary, checkoutPr, type SessionWorkspace, sessionTitle, type Target } from "../shared/attention";
|
|
3
4
|
import { linkedSessions } from "../shared/linked-sessions";
|
|
4
5
|
import { chooseAgent, type ReadyProvider } from "../shared/providers";
|
|
5
6
|
import { type AttentionConfig, codeRepoFor, githubRepoOf, SessionKind } from "../shared/config";
|
|
7
|
+
import { getAttention } from "../shared/rpc";
|
|
8
|
+
import { VIEW_QUERY_KEY } from "./data";
|
|
6
9
|
|
|
7
10
|
type Paseo = ReturnType<typeof usePaseo>;
|
|
8
11
|
|
|
12
|
+
// The app's session list, shared by the screen and the sidebar's count [ATT-09, ATT-22].
|
|
13
|
+
export const AGENTS_QUERY_KEY = ["attention-span", "agents"] as const;
|
|
14
|
+
|
|
15
|
+
// The sessions on items, polled for the screen and the sidebar alike [ATT-09, ATT-22]. When one has gone since the last
|
|
16
|
+
// poll, perhaps archived in Paseo, the server's view is read first (from memory, not GitHub), so the notes the server
|
|
17
|
+
// acknowledged for it are cleared before its Wrap up row goes, rather than showing as unread in between [HIS-07].
|
|
18
|
+
export function useItemAgents() {
|
|
19
|
+
const paseo = usePaseo();
|
|
20
|
+
const queryClient = useQueryClient();
|
|
21
|
+
const fetchAttention = useRpc(getAttention);
|
|
22
|
+
return useQuery({
|
|
23
|
+
queryKey: AGENTS_QUERY_KEY,
|
|
24
|
+
refetchInterval: 15_000,
|
|
25
|
+
queryFn: async () => {
|
|
26
|
+
const before = queryClient.getQueryData<AgentSummary[]>(AGENTS_QUERY_KEY);
|
|
27
|
+
const agents = await itemAgents(paseo);
|
|
28
|
+
const now = new Set(agents.map((agent) => agent.id));
|
|
29
|
+
if (before?.some((agent) => !now.has(agent.id))) {
|
|
30
|
+
await fetchAttention({ cached: true })
|
|
31
|
+
.then((view) => queryClient.setQueryData(VIEW_QUERY_KEY, view))
|
|
32
|
+
.catch(() => {}); // the view's own poll catches up
|
|
33
|
+
}
|
|
34
|
+
return agents;
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
9
39
|
// Labels tie an agent to the item it works on [ATT-07, SES-03].
|
|
10
40
|
export const LABEL = "attention-span";
|
|
11
41
|
export const ITEM_LABEL = "attention-span-item";
|
|
@@ -14,6 +44,19 @@ export const KIND_LABEL = "attention-span-kind";
|
|
|
14
44
|
// Sessions started under the plugin's earlier names, "GitHub attention" and "GitHub inbox".
|
|
15
45
|
const OLD_LABELS = ["github-attention", "github-inbox"];
|
|
16
46
|
|
|
47
|
+
// What Paseo knows about the workspace a session runs in, for Wrap up's unsaved-work check [ATT-22].
|
|
48
|
+
function sessionWorkspace(workspace: (Awaited<ReturnType<Paseo["workspaces"]["list"]>>["entries"][number])): SessionWorkspace {
|
|
49
|
+
const git = workspace.gitRuntime;
|
|
50
|
+
return {
|
|
51
|
+
kind: workspace.workspaceKind,
|
|
52
|
+
name: workspace.title ?? workspace.name,
|
|
53
|
+
directory: workspace.workspaceDirectory ?? workspace.projectRootPath,
|
|
54
|
+
...(git?.currentBranch ? { branch: git.currentBranch } : {}),
|
|
55
|
+
...(typeof git?.isDirty === "boolean" ? { dirty: git.isDirty } : {}),
|
|
56
|
+
...(typeof git?.aheadOfOrigin === "number" ? { ahead: git.aheadOfOrigin } : {}),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
17
60
|
// Agents started from Attention Span, each with the item it was started on, and the agents
|
|
18
61
|
// started outside it in a workspace that belongs to an item [SES-08].
|
|
19
62
|
export async function itemAgents(paseo: Paseo): Promise<AgentSummary[]> {
|
|
@@ -40,7 +83,11 @@ export async function itemAgents(paseo: Paseo): Promise<AgentSummary[]> {
|
|
|
40
83
|
}
|
|
41
84
|
const labelled = [...byId.values()];
|
|
42
85
|
const unlabelled = all.entries.map((entry) => entry.agent).filter((agent) => !labels.some((label) => agent.labels?.[label]));
|
|
43
|
-
|
|
86
|
+
const byWorkspace = new Map(workspaces.entries.map((workspace) => [workspace.id, sessionWorkspace(workspace)]));
|
|
87
|
+
return [...labelled, ...linkedSessions(labelled, unlabelled, workspaces.entries)].map((agent) => {
|
|
88
|
+
const workspace = agent.workspaceId ? byWorkspace.get(agent.workspaceId) : undefined;
|
|
89
|
+
return workspace ? { ...agent, workspace } : agent;
|
|
90
|
+
});
|
|
44
91
|
}
|
|
45
92
|
|
|
46
93
|
export interface ProjectMatch {
|
package/client/ui.tsx
CHANGED
|
@@ -286,7 +286,7 @@ export function Avatar({ url, bot, team, size = 18 }: { url?: string; bot?: bool
|
|
|
286
286
|
}
|
|
287
287
|
|
|
288
288
|
// ghost: no background until hovered or pressed, for secondary icons on every row.
|
|
289
|
-
type Variant = "calm" | "solid" | "plain" | "ghost";
|
|
289
|
+
type Variant = "calm" | "solid" | "plain" | "ghost" | "danger";
|
|
290
290
|
|
|
291
291
|
export function useHover() {
|
|
292
292
|
const [hovered, setHovered] = useState(false);
|
|
@@ -315,7 +315,7 @@ export function Button({
|
|
|
315
315
|
const styles = useStyles();
|
|
316
316
|
const { hovered, hover } = useHover();
|
|
317
317
|
const { c } = styles;
|
|
318
|
-
const color = variant === "solid" ? c.accentForeground : variant === "calm" ? styles.action : variant === "ghost" ? c.foregroundMuted : c.foreground;
|
|
318
|
+
const color = variant === "solid" ? c.accentForeground : variant === "calm" ? styles.action : variant === "ghost" ? c.foregroundMuted : variant === "danger" ? c.statusDanger : c.foreground;
|
|
319
319
|
return (
|
|
320
320
|
<Pressable
|
|
321
321
|
accessibilityRole="button"
|
|
@@ -331,7 +331,7 @@ export function Button({
|
|
|
331
331
|
height: 30,
|
|
332
332
|
paddingHorizontal: label ? 11 : 8,
|
|
333
333
|
borderRadius: 8,
|
|
334
|
-
backgroundColor: variant === "solid" ? c.accent : hovered || (pressed && variant === "ghost") ? c.border : variant === "ghost" ? "transparent" : c.surface2,
|
|
334
|
+
backgroundColor: variant === "solid" ? c.accent : variant === "danger" ? mix(c.statusDanger, c.surface1, 0.18) : hovered || (pressed && variant === "ghost") ? c.border : variant === "ghost" ? "transparent" : c.surface2,
|
|
335
335
|
opacity: disabled ? 0.5 : pressed ? 0.8 : 1,
|
|
336
336
|
})}
|
|
337
337
|
>
|
|
@@ -357,6 +357,21 @@ export function SectionHeader({ icon, title, count, action }: { icon: IconName |
|
|
|
357
357
|
);
|
|
358
358
|
}
|
|
359
359
|
|
|
360
|
+
// A group that opens in place, like a week's reviews in History: a chevron, its name and count. Each opens on its own, so
|
|
361
|
+
// they don't read as a choice between them [HIS-02, HIS-06].
|
|
362
|
+
export function Disclosure({ label, count, open, onPress }: { label: string; count: number; open: boolean; onPress: () => void }) {
|
|
363
|
+
const styles = useStyles();
|
|
364
|
+
return (
|
|
365
|
+
<Pressable accessibilityRole="button" accessibilityLabel={`${label}, ${count}`} accessibilityState={{ expanded: open }} onPress={onPress} hitSlop={6} style={[styles.row, { gap: 6, paddingVertical: 4 }]}>
|
|
366
|
+
<TablerIcon name={open ? "chevronDown" : "chevronRight"} size={14} />
|
|
367
|
+
<Text style={{ color: styles.c.foreground, fontSize: 13, fontWeight: "600" }}>
|
|
368
|
+
{label}
|
|
369
|
+
<Text style={{ color: styles.c.foregroundMuted, fontWeight: "400" }}> · {count}</Text>
|
|
370
|
+
</Text>
|
|
371
|
+
</Pressable>
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
|
|
360
375
|
// Copy text and say so, since an icon-only button gives no other sign it worked.
|
|
361
376
|
export function useCopy() {
|
|
362
377
|
const toast = useToast();
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import { Text, View } from "react-native";
|
|
3
|
+
import type { AgentSummary, WrapItem } from "../shared/attention";
|
|
4
|
+
import type { ArchiveOutcome, UnsavedSession } from "../shared/archive";
|
|
5
|
+
import { allWrapBusy, wrapBusy } from "../shared/got-it";
|
|
6
|
+
import { cleanSingle, sessionCleanliness, unsavedText } from "../shared/wrap-up";
|
|
7
|
+
import { CardList, CardRow } from "./card";
|
|
8
|
+
import { stateMark } from "./mark";
|
|
9
|
+
import { Modal } from "./sheet";
|
|
10
|
+
import { Button, KeepStyles, SectionHeader, TablerIcon, useStyles } from "./ui";
|
|
11
|
+
|
|
12
|
+
// Doing's Wrap up: finished or out-of-my-hands work whose sessions are still open, and archiving them [ATT-22]. The screen
|
|
13
|
+
// assembles the rows and runs the archive; these draw them and ask before archiving anything unsaved.
|
|
14
|
+
|
|
15
|
+
interface RowProps {
|
|
16
|
+
busy: ReadonlySet<string>;
|
|
17
|
+
login: string | null;
|
|
18
|
+
// Previews have made-up sessions: their snapshot is the answer, as there's no daemon to ask.
|
|
19
|
+
fixture: boolean;
|
|
20
|
+
openAgent: (agentId: string) => void;
|
|
21
|
+
onArchive: (item: WrapItem, confirm: boolean) => Promise<ArchiveOutcome | null>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Finished or out-of-my-hands work whose Paseo sessions are all idle: the cleanup Doing owns [ATT-22].
|
|
25
|
+
export function WrapUp({ items, onArchiveAll, ...row }: { items: WrapItem[]; onArchiveAll: () => Promise<void> } & RowProps) {
|
|
26
|
+
const styles = useStyles();
|
|
27
|
+
const clean = items.filter(cleanSingle);
|
|
28
|
+
return (
|
|
29
|
+
<View>
|
|
30
|
+
<SectionHeader
|
|
31
|
+
icon="archive"
|
|
32
|
+
title="Wrap up"
|
|
33
|
+
count={items.length}
|
|
34
|
+
action={
|
|
35
|
+
items.length > 1 && clean.length > 0 ? (
|
|
36
|
+
<View style={styles.overCard}>
|
|
37
|
+
<Button
|
|
38
|
+
label={`Archive all clean · ${clean.length}`}
|
|
39
|
+
icon="archive"
|
|
40
|
+
variant="ghost"
|
|
41
|
+
disabled={allWrapBusy(row.busy, items.map((item) => item.key))}
|
|
42
|
+
onPress={() => void onArchiveAll()}
|
|
43
|
+
/>
|
|
44
|
+
</View>
|
|
45
|
+
) : null
|
|
46
|
+
}
|
|
47
|
+
/>
|
|
48
|
+
<CardList>
|
|
49
|
+
{items.map((item, index) => (
|
|
50
|
+
<WrapRow key={item.key} item={item} first={index === 0} {...row} />
|
|
51
|
+
))}
|
|
52
|
+
</CardList>
|
|
53
|
+
</View>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// "merged by dave 2h ago · your session's still open": what finishing looked like, then the session it left behind [ATT-22].
|
|
58
|
+
function wrapMeta({ wrap }: WrapItem): string {
|
|
59
|
+
const still = wrap.review ? "your review session's still open" : wrap.sessions.length > 1 ? `${wrap.sessions.length} sessions still open` : "your session's still open";
|
|
60
|
+
return `${wrap.finish} · ${still}`;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function WrapRow({ item, first, busy, login, fixture, openAgent: openSession, onArchive }: { item: WrapItem; first: boolean } & RowProps) {
|
|
64
|
+
const styles = useStyles();
|
|
65
|
+
const { sessions } = item.wrap;
|
|
66
|
+
const [sheet, setSheet] = useState<"multi" | "dirty" | null>(null);
|
|
67
|
+
const [unsaved, setUnsaved] = useState<UnsavedSession[]>([]);
|
|
68
|
+
const dirty = sessions.some((session) => sessionCleanliness(session) === "dirty");
|
|
69
|
+
const press = async () => {
|
|
70
|
+
if (sessions.length > 1) return setSheet("multi");
|
|
71
|
+
// A preview has no daemon to ask; its made-up snapshot is the answer. Elsewhere the server checks git too, so the sheet
|
|
72
|
+
// can name the files and commits it found.
|
|
73
|
+
if (sessionCleanliness(sessions[0]) !== "clean" && fixture) {
|
|
74
|
+
setUnsaved([dirtyFallback(sessions[0])]);
|
|
75
|
+
return setSheet("dirty");
|
|
76
|
+
}
|
|
77
|
+
const outcome = await onArchive(item, false);
|
|
78
|
+
if (outcome && !outcome.ok && outcome.reason === "unsaved") {
|
|
79
|
+
setUnsaved(outcome.sessions);
|
|
80
|
+
setSheet("dirty");
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
// The multi sheet asks the server first, like a single row; unsaved work it finds gets the confirm that names it [ATT-22].
|
|
84
|
+
const confirm = async (confirm: boolean) => {
|
|
85
|
+
const outcome = await onArchive(item, confirm);
|
|
86
|
+
if (outcome?.ok) return setSheet(null);
|
|
87
|
+
if (outcome && outcome.reason === "unsaved") {
|
|
88
|
+
setUnsaved(outcome.sessions);
|
|
89
|
+
setSheet("dirty");
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
return (
|
|
93
|
+
<CardRow
|
|
94
|
+
first={first}
|
|
95
|
+
mark={stateMark(item)}
|
|
96
|
+
title={item.title}
|
|
97
|
+
meta={{
|
|
98
|
+
place: { repo: item.repo, number: item.number, login },
|
|
99
|
+
when: wrapMeta(item),
|
|
100
|
+
signals: dirty ? [{ text: "unsaved changes", tone: "warn" }] : [],
|
|
101
|
+
}}
|
|
102
|
+
onOpen={() => (sessions.length > 1 ? setSheet("multi") : sessions[0] ? openSession(sessions[0].id) : undefined)}
|
|
103
|
+
busy={wrapBusy(busy, item.key)}
|
|
104
|
+
primary={{
|
|
105
|
+
label: sessions.length > 1 ? "Archive sessions" : "Archive session",
|
|
106
|
+
accessibilityLabel: `Archive the ${sessions.length > 1 ? "sessions" : "session"} on #${item.number}`,
|
|
107
|
+
icon: "archive",
|
|
108
|
+
onPress: () => void press(),
|
|
109
|
+
}}
|
|
110
|
+
secondary={[{ label: `Details for #${item.number}`, icon: "chevronRight", onPress: () => (sessions.length > 1 ? setSheet("multi") : sessions[0] ? openSession(sessions[0].id) : undefined) }]}
|
|
111
|
+
overlay={
|
|
112
|
+
sheet === "multi" ? (
|
|
113
|
+
<Modal title={`Sessions on #${item.number}`} open onOpenChange={(open) => (open ? null : setSheet(null))}>
|
|
114
|
+
<Modal.Content>
|
|
115
|
+
<KeepStyles styles={styles}>
|
|
116
|
+
<Text style={styles.muted}>
|
|
117
|
+
{item.title} · {item.wrap.finish}
|
|
118
|
+
</Text>
|
|
119
|
+
<View style={[styles.card, { backgroundColor: styles.c.surface2 }]}>
|
|
120
|
+
{sessions.map((session, index) => (
|
|
121
|
+
<View key={session.id} style={[styles.row, { paddingVertical: 10, paddingHorizontal: 12 }, index > 0 ? styles.divider : null]}>
|
|
122
|
+
<TablerIcon name="agent" size={16} />
|
|
123
|
+
<View style={{ flex: 1, gap: 2 }}>
|
|
124
|
+
<Text style={styles.text}>{session.title ?? "Session"}</Text>
|
|
125
|
+
<Text style={styles.muted}>{sessionStateText(session)}</Text>
|
|
126
|
+
</View>
|
|
127
|
+
<Button label="Open" variant="ghost" onPress={() => openSession(session.id)} />
|
|
128
|
+
</View>
|
|
129
|
+
))}
|
|
130
|
+
</View>
|
|
131
|
+
<Text style={styles.muted}>
|
|
132
|
+
Archives {sessions.length} sessions. Their worktrees go too when nothing else lives in them
|
|
133
|
+
{sessions.some((session) => sessionCleanliness(session) === "unknown") ? "; the one that couldn't be checked may hold unsaved work" : ""}.
|
|
134
|
+
</Text>
|
|
135
|
+
<View style={[styles.row, { justifyContent: "flex-end" }]}>
|
|
136
|
+
<Button label="Cancel" onPress={() => setSheet(null)} />
|
|
137
|
+
<Button label={sessions.length === 2 ? "Archive both" : `Archive ${sessions.length}`} variant="danger" onPress={() => void confirm(false)} />
|
|
138
|
+
</View>
|
|
139
|
+
</KeepStyles>
|
|
140
|
+
</Modal.Content>
|
|
141
|
+
</Modal>
|
|
142
|
+
) : sheet === "dirty" ? (
|
|
143
|
+
<Modal title={sessions.length > 1 ? `Archive the sessions on #${item.number}?` : `Archive the session on #${item.number}?`} open onOpenChange={(open) => (open ? null : setSheet(null))}>
|
|
144
|
+
<Modal.Content>
|
|
145
|
+
<KeepStyles styles={styles}>
|
|
146
|
+
{(unsaved.length ? unsaved : [dirtyFallback(sessions[0])]).map((info) => (
|
|
147
|
+
<View key={info.agentId} style={{ gap: 2 }}>
|
|
148
|
+
<Text style={styles.text}>{info.title ?? "Session"}</Text>
|
|
149
|
+
<Text style={{ color: styles.c.statusWarning, fontSize: 13 }}>
|
|
150
|
+
{info.unknown ? "Couldn't check for unsaved changes. Archiving may remove the worktree." : `Its worktree has ${unsavedTextFrom(info)}. Archiving may remove them.`}
|
|
151
|
+
</Text>
|
|
152
|
+
</View>
|
|
153
|
+
))}
|
|
154
|
+
<View style={[styles.row, { justifyContent: "flex-end" }]}>
|
|
155
|
+
<Button label="Open session" icon="agent" variant="calm" onPress={() => openSession(unsaved[0]?.agentId ?? sessions[0].id)} />
|
|
156
|
+
<Button label="Archive anyway" variant="danger" onPress={() => void confirm(true)} />
|
|
157
|
+
</View>
|
|
158
|
+
</KeepStyles>
|
|
159
|
+
</Modal.Content>
|
|
160
|
+
</Modal>
|
|
161
|
+
) : null
|
|
162
|
+
}
|
|
163
|
+
/>
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// What a session in Wrap up's multi sheet says about its worktree [ATT-22].
|
|
168
|
+
function sessionStateText(session: AgentSummary): string {
|
|
169
|
+
const state = sessionCleanliness(session);
|
|
170
|
+
if (state === "clean") return "idle · nothing unsaved";
|
|
171
|
+
if (state === "dirty") return `idle · ${unsavedText(session)}`;
|
|
172
|
+
return "idle · couldn't check for unsaved changes";
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function dirtyFallback(session: AgentSummary | undefined): UnsavedSession {
|
|
176
|
+
const workspace = session?.workspace;
|
|
177
|
+
return session
|
|
178
|
+
? {
|
|
179
|
+
agentId: session.id,
|
|
180
|
+
title: session.title,
|
|
181
|
+
...(workspace?.branch ? { branch: workspace.branch } : {}),
|
|
182
|
+
...(workspace?.dirtyFiles ? { files: workspace.dirtyFiles } : {}),
|
|
183
|
+
...(workspace?.ahead ? { commits: workspace.ahead } : {}),
|
|
184
|
+
...(sessionCleanliness(session) === "unknown" ? { unknown: true as const } : {}),
|
|
185
|
+
}
|
|
186
|
+
: { agentId: "", title: null, unknown: true };
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// "2 uncommitted files and 1 unpushed commit on branch", from the archive check's git counts [ATT-22].
|
|
190
|
+
function unsavedTextFrom(info: UnsavedSession): string {
|
|
191
|
+
if (info.unknown) return "changes Paseo couldn't check";
|
|
192
|
+
const parts: string[] = [];
|
|
193
|
+
if (info.files) parts.push(`${info.files} uncommitted file${info.files === 1 ? "" : "s"}`);
|
|
194
|
+
if (info.commits) parts.push(`${info.commits} unpushed commit${info.commits === 1 ? "" : "s"}`);
|
|
195
|
+
const what = parts.join(" and ") || "unsaved changes";
|
|
196
|
+
return info.branch ? `${what} on ${info.branch}` : what;
|
|
197
|
+
}
|