@andrioid/paseo-attention-span 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/OVERVIEW.md +3 -1
- package/client/attention-screen.tsx +61 -1174
- package/client/coverage-settings.tsx +5 -4
- package/client/data.ts +4 -2
- package/client/feedback.tsx +21 -25
- package/client/history.tsx +12 -50
- package/client/item-actions.ts +387 -0
- package/client/item-row.tsx +450 -0
- package/client/new-issue.tsx +244 -0
- package/client/next-up.tsx +22 -183
- package/client/pickers.tsx +238 -0
- package/client/session-menu.ts +3 -11
- package/client/sessions.ts +58 -57
- package/client/setup.tsx +2 -1
- package/client/sheet.tsx +92 -15
- package/client/ui.tsx +23 -14
- package/client/wrap-up.tsx +151 -85
- package/docs/architecture.md +24 -13
- 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.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-too-long.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 +19 -0
- package/index.server.ts +43 -26
- package/package.json +2 -1
- package/requirements.yaml +10 -3
- package/server/actions.ts +2 -1
- package/server/archive.ts +146 -67
- package/server/archived.ts +12 -16
- package/server/changes.ts +34 -54
- package/server/classify.ts +157 -139
- package/server/context.ts +95 -3
- package/server/feedback.ts +2 -6
- package/server/fetch.ts +262 -0
- package/server/fixture.ts +88 -14
- package/server/github-types.ts +5 -2
- package/server/markdown.ts +3 -1
- package/server/port.ts +46 -0
- package/server/queries.ts +34 -24
- package/server/service.ts +155 -272
- package/server/setup.ts +15 -14
- package/server/store.ts +94 -80
- package/server/update.ts +34 -13
- package/server/view.ts +16 -15
- package/shared/archive.ts +116 -13
- package/shared/attention.ts +63 -18
- package/shared/changes.ts +2 -1
- package/shared/config.ts +2 -6
- package/shared/drafting.ts +17 -0
- package/shared/feedback.ts +6 -5
- package/shared/format.ts +2 -1
- package/shared/history-report.ts +2 -1
- package/shared/item-sessions.ts +76 -0
- package/shared/item-view.ts +224 -0
- package/shared/linked-sessions.ts +59 -8
- package/shared/names.ts +17 -0
- package/shared/new-issue.ts +129 -0
- package/shared/next-up-filter.ts +137 -0
- package/shared/paging.ts +16 -0
- package/shared/prompts.ts +39 -22
- package/shared/rpc.ts +23 -10
- package/shared/setup.ts +3 -1
- package/shared/wrap-up.ts +20 -23
package/index.client.tsx
CHANGED
|
@@ -6,6 +6,7 @@ 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 { newIssueParams } from "./client/new-issue";
|
|
9
10
|
import { useItemAgents } from "./client/sessions";
|
|
10
11
|
import { doingCount, wrapItems } from "./shared/wrap-up";
|
|
11
12
|
|
|
@@ -38,5 +39,23 @@ export default function contribute(client: PluginClientContext) {
|
|
|
38
39
|
const Screen = (props: PluginScreenProps) => <AttentionScreen {...props} openSettings={() => client.openSettings("coverage")} />;
|
|
39
40
|
client.addScreen({ id: "attention", title: "Attention Span", Component: Screen });
|
|
40
41
|
client.addSidebarHeaderItem({ id: "attention", title: "Attention Span", Component: SidebarItem });
|
|
42
|
+
// A new issue from ⌘K anywhere [ISS-01]. ⌘K can't show a sheet, so it opens the screen with the sheet on it. Paseo lists
|
|
43
|
+
// global items everywhere and agent items beside them, so "from this session" is the one that knows where I am.
|
|
44
|
+
client.addCommandCenterItem({
|
|
45
|
+
id: "new-issue",
|
|
46
|
+
title: "New issue…",
|
|
47
|
+
icon: ICONS.issue,
|
|
48
|
+
context: "global",
|
|
49
|
+
keywords: ["issue", "github", "file", "report", "bug", "idea"],
|
|
50
|
+
onSelect: ({ openScreen }) => openScreen({ screenId: "attention", params: newIssueParams({}) }),
|
|
51
|
+
});
|
|
52
|
+
client.addCommandCenterItem({
|
|
53
|
+
id: "new-issue-from-session",
|
|
54
|
+
title: "New issue from this session…",
|
|
55
|
+
icon: ICONS.issue,
|
|
56
|
+
context: "agent",
|
|
57
|
+
keywords: ["issue", "github", "file", "follow-up", "later"],
|
|
58
|
+
onSelect: ({ openScreen, workspace, agent }) => openScreen({ screenId: "attention", params: newIssueParams({ workspaceId: workspace.id, agentId: agent.id }) }),
|
|
59
|
+
});
|
|
41
60
|
return returnFromFeedback(client);
|
|
42
61
|
}
|
package/index.server.ts
CHANGED
|
@@ -18,38 +18,46 @@ import { ArchivedInPaseo } from "./server/archived";
|
|
|
18
18
|
import { defaultBranch, sessionContext } from "./server/context";
|
|
19
19
|
import { itemDetails } from "./server/details";
|
|
20
20
|
import { feedbackInfo } from "./server/feedback";
|
|
21
|
-
import {
|
|
21
|
+
import { fixtureAnswers, fixtureDismissKept, fixturePort, fixtureView } from "./server/fixture";
|
|
22
22
|
import { FIXTURE } from "./server/gh";
|
|
23
|
-
import {
|
|
23
|
+
import { realPort } from "./server/port";
|
|
24
|
+
import { checkCoverage, configStatus, coverageOnGitHub, ghStatus, myOrgs, setupStatus } from "./server/setup";
|
|
24
25
|
import { AttentionService, type Change } from "./server/service";
|
|
25
|
-
import {
|
|
26
|
-
import
|
|
26
|
+
import { createStore, DIR, OLD_DIR } from "./server/store";
|
|
27
|
+
import { fixtureUpdates, paseoUpdates, UpdateCheck } from "./server/update";
|
|
28
|
+
import type { AttentionView, Chip } from "./shared/attention";
|
|
27
29
|
import { readyProviders } from "./shared/providers";
|
|
28
30
|
import * as rpc from "./shared/rpc";
|
|
29
31
|
|
|
30
32
|
export default function contribute(server: PluginServerContext) {
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
+
// Previews run on made-up data and never reach GitHub; which one is picked here, once.
|
|
34
|
+
const store = createStore(DIR, OLD_DIR);
|
|
35
|
+
const attention = new AttentionService(FIXTURE ? fixturePort(store, DIR) : realPort(store));
|
|
36
|
+
const answers = FIXTURE ? fixtureAnswers : { reviewerChoices, itemDetails, defaultBranch, sessionContext, ghStatus, myOrgs, coverageOnGitHub };
|
|
37
|
+
const updates = new UpdateCheck(FIXTURE ? fixtureUpdates : paseoUpdates);
|
|
38
|
+
// Each view the screen gets; previews add their made-up sessions [ATT-22].
|
|
39
|
+
const shown: (view: AttentionView) => AttentionView = FIXTURE ? fixtureView : (view) => view;
|
|
33
40
|
const archived = new ArchivedInPaseo({ groupKeysOf: (itemKey) => attention.groupKeysOf(itemKey), acknowledge: (keys, upTo) => attention.acknowledge(keys, upTo) });
|
|
34
41
|
const started = attention.start().catch((error) => console.error("Attention Span failed to start:", error));
|
|
35
42
|
const ready = <T>(work: () => Promise<T>) => started.then(work);
|
|
36
43
|
|
|
37
44
|
// A change on GitHub, answered with the list after it; what it does to the card shows right away [FRESH-02].
|
|
38
|
-
const act = (key: string, work: () => Promise<void>, change: Change) => ready(() => attention.act(key, work, change));
|
|
45
|
+
const act = (key: string, work: () => Promise<void>, change: Change) => ready(() => attention.act(key, work, change)).then(shown);
|
|
39
46
|
const chip = (text: string, tone: Chip["tone"] = "neutral", icon?: Chip["icon"]): Change => ({ kind: "chip", chip: { text, tone, ...(icon ? { icon } : {}) } });
|
|
40
47
|
|
|
41
|
-
// The app asks for the list on load and every few minutes; its Paseo connection lets refreshes see my projects [NXT-08]
|
|
42
|
-
|
|
48
|
+
// The app asks for the list on load and every few minutes; its Paseo connection lets refreshes see my projects [NXT-08],
|
|
49
|
+
// and its time zone sets History's weeks [HIS-01].
|
|
50
|
+
server.handle(rpc.getAttention, ({ refresh, cached, timeZone }, { paseo }) =>
|
|
43
51
|
ready(() => {
|
|
44
52
|
attention.connect(paseo);
|
|
45
53
|
if (archived.waiting) void archived.notice(paseo);
|
|
46
|
-
return attention.get(refresh, cached);
|
|
47
|
-
}),
|
|
54
|
+
return attention.get(refresh, cached, timeZone);
|
|
55
|
+
}).then(shown),
|
|
48
56
|
);
|
|
49
|
-
server.handle(rpc.dismissItem, ({ key }) => ready(() => attention.dismiss(key)));
|
|
50
|
-
server.handle(rpc.undismissItem, ({ key }) => ready(() => attention.undismiss(key)));
|
|
51
|
-
server.handle(rpc.gotIt, ({ ids, on }) => ready(() => attention.gotIt(ids, on)));
|
|
52
|
-
server.handle(rpc.setHistoryFilter, ({ filter }) => ready(() => attention.setHistoryFilter(filter)));
|
|
57
|
+
server.handle(rpc.dismissItem, ({ key }) => ready(() => attention.dismiss(key)).then(shown));
|
|
58
|
+
server.handle(rpc.undismissItem, ({ key }) => ready(() => attention.undismiss(key)).then(shown));
|
|
59
|
+
server.handle(rpc.gotIt, ({ ids, on }) => ready(() => attention.gotIt(ids, on)).then(shown));
|
|
60
|
+
server.handle(rpc.setHistoryFilter, ({ filter }) => ready(() => attention.setHistoryFilter(filter)).then(shown));
|
|
53
61
|
// A session Attention Span started, archived in Paseo itself, even with Attention Span closed [HIS-07, ATT-22]. Each
|
|
54
62
|
// event, and each request for the list, also tries again the ones that failed, as both bring a Paseo connection.
|
|
55
63
|
server.on("agent.archived", ({ agent, archivedAt }, { paseo }) => {
|
|
@@ -59,21 +67,30 @@ export default function contribute(server: PluginServerContext) {
|
|
|
59
67
|
server.on("agent.turn_ended", (_event, { paseo }) => {
|
|
60
68
|
if (archived.waiting) void ready(() => archived.notice(paseo));
|
|
61
69
|
});
|
|
62
|
-
server.handle(rpc.archiveSessions, ({ targets, confirm }, { paseo }) => ready(() => attention.archive(paseo, targets, confirm)));
|
|
63
|
-
server.handle(rpc.
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
server.handle(rpc.
|
|
67
|
-
|
|
70
|
+
server.handle(rpc.archiveSessions, ({ targets, confirm, terminals }, { paseo }) => ready(() => attention.archive(paseo, targets, confirm, terminals)).then((outcome) => ({ ...outcome, view: shown(outcome.view) })));
|
|
71
|
+
server.handle(rpc.archiveWorktree, ({ workspaceId, confirm, terminals }, { paseo }) =>
|
|
72
|
+
ready(() => attention.archiveWorktree(paseo, workspaceId, confirm, terminals)).then((outcome) => ({ ...outcome, view: shown(outcome.view) })),
|
|
73
|
+
);
|
|
74
|
+
server.handle(rpc.dismissKept, ({ workspaceId }) => {
|
|
75
|
+
if (FIXTURE) fixtureDismissKept(workspaceId);
|
|
76
|
+
return ready(() => attention.dismissKept(workspaceId)).then(shown);
|
|
77
|
+
});
|
|
78
|
+
server.on("workspace.archived", ({ workspace }) => void ready(() => attention.forgetKept(workspace.id)));
|
|
79
|
+
server.handle(rpc.restoreDismissed, () => ready(() => attention.restoreDismissed()).then(shown));
|
|
80
|
+
server.handle(rpc.setCodeRepo, ({ issueRepo, codeRepo }) => ready(() => attention.setCodeRepo(issueRepo, codeRepo)).then(shown));
|
|
81
|
+
server.handle(rpc.setupStatus, () => setupStatus(store, answers.ghStatus));
|
|
82
|
+
server.handle(rpc.getCoverage, () => configStatus(store));
|
|
83
|
+
server.handle(rpc.checkCoverage, ({ kind, name }) => checkCoverage(kind, name, answers.coverageOnGitHub));
|
|
68
84
|
server.handle(rpc.setCoverage, ({ orgs, repos }) => ready(() => attention.setCoverage(orgs, repos)).then(() => ({ ok: true as const })));
|
|
69
85
|
server.handle(rpc.setNextUpSources, (sources) => ready(() => attention.setNextUpSources(sources)).then(() => ({ ok: true as const })));
|
|
70
86
|
server.handle(rpc.issueFields, () => ready(async () => ({ fields: await attention.issueFields() })));
|
|
71
87
|
server.handle(rpc.setNextUpFields, (fields) => ready(() => attention.setNextUpFields(fields)).then(() => ({ ok: true as const })));
|
|
72
88
|
server.handle(rpc.setFollowThreads, ({ on }) => ready(() => attention.setFollowThreads(on)).then(() => ({ ok: true as const })));
|
|
73
|
-
server.handle(rpc.myOrgs, async () => ({ orgs: await myOrgs() }));
|
|
89
|
+
server.handle(rpc.myOrgs, async () => ({ orgs: await answers.myOrgs() }));
|
|
74
90
|
server.handle(rpc.setScopes, ({ scopes }) => ready(() => attention.setScopes(scopes)).then(() => ({ ok: true as const })));
|
|
75
91
|
server.handle(rpc.setSources, ({ sources }) => ready(() => attention.setSources(sources)).then(() => ({ ok: true as const })));
|
|
76
92
|
server.handle(rpc.setProjectFilter, ({ projects }) => ready(() => attention.setProjectFilter(projects)).then(() => ({ ok: true as const })));
|
|
93
|
+
server.handle(rpc.setNewIssueChoice, ({ repo, profileId }) => ready(() => attention.setNewIssueChoice(repo, profileId)).then(() => ({ ok: true as const })));
|
|
77
94
|
server.handle(rpc.projectsAccess, () => ready(() => attention.projectsAccess(true)));
|
|
78
95
|
server.handle(rpc.updateBranch, ({ key, target }) => act(key, () => updateBranch(target), chip("updating")));
|
|
79
96
|
server.handle(rpc.mergePullRequest, ({ key, target }) => act(key, () => mergePullRequest(target), { kind: "finished" }));
|
|
@@ -90,13 +107,13 @@ export default function contribute(server: PluginServerContext) {
|
|
|
90
107
|
server.handle(rpc.reviewerChoices, ({ target }) =>
|
|
91
108
|
ready(() => {
|
|
92
109
|
const { recent, login } = attention.reviewers(target.repo);
|
|
93
|
-
return
|
|
110
|
+
return answers.reviewerChoices(target, recent, login);
|
|
94
111
|
}),
|
|
95
112
|
);
|
|
96
113
|
server.handle(rpc.react, ({ key, subjectIds, on }) => act(key, () => react(subjectIds, on), on ? chip("acknowledged", "neutral", "thumbUp") : null));
|
|
97
114
|
server.handle(rpc.rerunFailed, ({ key, repo, runIds }) => act(key, () => rerunFailed(repo, runIds), chip("rerunning")));
|
|
98
|
-
server.handle(rpc.itemDetails, ({ subject, target, checks }) =>
|
|
99
|
-
server.handle(rpc.defaultBranch, async ({ repo }) => ({ name:
|
|
115
|
+
server.handle(rpc.itemDetails, ({ subject, target, checks }) => answers.itemDetails(subject, target, checks));
|
|
116
|
+
server.handle(rpc.defaultBranch, async ({ repo }) => ({ name: await answers.defaultBranch(repo) }));
|
|
100
117
|
server.handle(rpc.feedbackInfo, () => feedbackInfo());
|
|
101
118
|
// [UPD-01]
|
|
102
119
|
server.handle(rpc.checkUpdate, () => ready(async () => {
|
|
@@ -107,7 +124,7 @@ export default function contribute(server: PluginServerContext) {
|
|
|
107
124
|
server.handle(rpc.skipUpdate, ({ latest }) => ready(() => attention.skipUpdate(latest)).then(() => ({ ok: true as const })));
|
|
108
125
|
// The server's Paseo connection expands the snapshot; the app's may not (getpaseo compact snapshots) [SES-06].
|
|
109
126
|
server.handle(rpc.readyProviders, async (_input, { paseo }) => ({ providers: readyProviders((await paseo.providers.snapshot()).entries) }));
|
|
110
|
-
server.handle(rpc.sessionContext, async ({ kind, target }) => ({ context:
|
|
127
|
+
server.handle(rpc.sessionContext, async ({ kind, target }) => ({ context: await answers.sessionContext(kind, target) }));
|
|
111
128
|
|
|
112
129
|
return () => attention.stop();
|
|
113
130
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@andrioid/paseo-attention-span",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "For when your attention is spread thin: the GitHub issues and pull requests waiting on you, grouped by why, with one-tap Paseo sessions.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"server/",
|
|
22
22
|
"shared/",
|
|
23
23
|
"!**/*.test.ts",
|
|
24
|
+
"!shared/test-builders.ts",
|
|
24
25
|
"assets/",
|
|
25
26
|
"requirements.yaml",
|
|
26
27
|
"docs/architecture.md",
|
package/requirements.yaml
CHANGED
|
@@ -37,7 +37,7 @@ functional:
|
|
|
37
37
|
ATT-18: see a calm, restful scene in Doing when nothing needs me and no finished work waits to be wrapped up, only once a refresh has confirmed it; so that a clear list feels like rest rather than a blank page, and calm never stands in for a check that failed or hasn't run.
|
|
38
38
|
ATT-19: tell at a glance what each person shown on an item is to it: someone I'm waiting on, who opened it, or whose comments are left to address, with an icon by their picture and the meaning in words when I point at it; so that a face and a time never leave me guessing.
|
|
39
39
|
ATT-20: tell which item a card is on every tab by its number first, then its repository with the repository's name standing out from its owner, which my own repositories leave out; so that cards from several repositories scan without reading each one in full.
|
|
40
|
-
ATT-22: wrap up finished or out-of-my-hands work whose Paseo sessions are still open, archiving them safely:
|
|
40
|
+
ATT-22: wrap up finished or out-of-my-hands work whose Paseo sessions are still open, archiving them, and the sub-agents they started, safely: naming unsaved changes and the open terminals archiving closes first, in a sheet shaped like Paseo's own, keeping worktrees another session lives in, leaving a row that says why a worktree stayed until it goes or is dismissed, and acknowledging what others did once it succeeds; so that leftover sessions get cleaned up without losing work or resurfacing old changes.
|
|
41
41
|
mentions:
|
|
42
42
|
As a developer, I can:
|
|
43
43
|
MEN-01: see open threads where a person mentioned me and is still waiting for my response; so that I only hear about mentions when someone is waiting for me.
|
|
@@ -50,6 +50,7 @@ functional:
|
|
|
50
50
|
reviews:
|
|
51
51
|
As a developer, I can:
|
|
52
52
|
REV-01: see pull requests where my review is requested by name; so that I don't hold up others.
|
|
53
|
+
REV-02: see a pull request whose review was re-requested after I reviewed it marked "Review again", with its Review session given what I said last time and focused on the commits since my last review; so that a second look costs less than the first.
|
|
53
54
|
own_pull_requests:
|
|
54
55
|
As a developer, I can:
|
|
55
56
|
PRS-01: see my pull requests whose checks fail; so that I fix them before they block review or merge.
|
|
@@ -57,7 +58,7 @@ functional:
|
|
|
57
58
|
PRS-03: see my pull requests that are ready to merge; so that finished work ships.
|
|
58
59
|
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.
|
|
59
60
|
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.
|
|
60
|
-
PRS-06: see only
|
|
61
|
+
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.
|
|
61
62
|
PRS-07: refresh or close a draft that has gone stale; so that old drafts don't linger.
|
|
62
63
|
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.
|
|
63
64
|
PRS-09: rerun the failed checks of a pull request without an agent, after seeing which failed and whether they were rerun before; so that flaky checks don't cost a session.
|
|
@@ -85,8 +86,9 @@ functional:
|
|
|
85
86
|
SES-05: start sessions in my local checkout of the item's repository without configuring paths; so that new repositories work without setup.
|
|
86
87
|
SES-06: start sessions even when no agent profiles are configured; so that Attention Span works before I've set anything up.
|
|
87
88
|
SES-07: start a session on an issue in the repository its code lives in, chosen right there the first time; so that issues kept in a separate repository work without editing files.
|
|
88
|
-
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, as "Continue session", including finished work in Wrap up; so that I don't start duplicate work and can clean up what I left open.
|
|
89
|
+
SES-08: see sessions started outside Attention Span on the item of the pull request their workspace is linked to, or of the session whose worktree they share, or of my merged or closed pull request whose branch their worktree is on, as "Continue session", including finished work in Wrap up; so that I don't start duplicate work and can clean up what I left open.
|
|
89
90
|
SES-09: tell sessions reviewing someone else's pull request from work on my own in Paseo's sidebar, by a name like "Review PR 123: title"; so that I know which kind of work a workspace holds.
|
|
91
|
+
SES-10: stay where I am when I start a session on an item, told it started, with the item offering to open it; so that I can start several in a row without finding my place again.
|
|
90
92
|
next_up:
|
|
91
93
|
As a developer, I can:
|
|
92
94
|
NXT-01: see open issues nobody is assigned to, apart from the work that needs me; so that I can get an idea of what to do next.
|
|
@@ -118,6 +120,10 @@ functional:
|
|
|
118
120
|
HIS-06: see each week's work that left my hands under Changed by others when that is shown, out of the week's copy, even once its new owner merges it, and keep it there when the work comes back to me after I've cleared it; so that my report doesn't claim work that wasn't mine.
|
|
119
121
|
HIS-07: see at the top of History, unread, when someone else merged or closed my pull request, closed an issue assigned to me, reopened a pull request I had seen closed, took over or handed on my work, or unassigned me, with a dot on the tab while any is unread and Got it or Mark all as read to clear them; so that I learn when others move my work without it changing what I have to do.
|
|
120
122
|
HIS-08: see a calm scene in History when I've finished nothing in its weeks and nothing is unread, only once a refresh has confirmed it; so that an empty History reads as a start rather than a blank page.
|
|
123
|
+
new_issues:
|
|
124
|
+
As a developer, I can:
|
|
125
|
+
ISS-01: file an issue in a repository I cover from ⌘K anywhere in Paseo or from Next up, starting from a line or two in a sheet that already has the repository, my context and the agent profile filled in, with an agent in my checkout that asks until it's clear, follows the repository's templates, picks labels and type, and posts only once I approve the draft; so that a thought becomes a well-formed issue without leaving what I'm doing.
|
|
126
|
+
ISS-02: see a likely duplicate before filing, and choose to file anyway, comment there or cancel; so that I don't add noise to a repository.
|
|
121
127
|
feedback:
|
|
122
128
|
As a developer, I can:
|
|
123
129
|
FB-01: tell the Attention Span project what to improve from the bottom of any tab, picking a problem, an idea or that I like it, with an agent that asks until it's clear, checks it against what's planned and already reported, and files it as an issue or a discussion, saying which and why, only once I approve the draft; so that feedback costs a minute and lands where it can be acted on or talked through.
|
|
@@ -139,6 +145,7 @@ non_functional:
|
|
|
139
145
|
freshness:
|
|
140
146
|
FRESH-01: stays current without me refreshing it; so that its count can be trusted.
|
|
141
147
|
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.
|
|
148
|
+
FRESH-03: brings a pull request of mine merged outside Attention Span into History and Wrap up within minutes; so that finished work gets cleaned up without me refreshing History.
|
|
142
149
|
|
|
143
150
|
deferred:
|
|
144
151
|
feedback:
|
package/server/actions.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { IssueCloseReason, Reviewer, ReviewerChoices, Target } from "../shared/attention";
|
|
2
2
|
import { graphql, runGh } from "./gh";
|
|
3
|
+
import { sameName } from "../shared/names";
|
|
3
4
|
|
|
4
5
|
// Each action runs only from an explicit tap in Attention Span [SAFE-01].
|
|
5
6
|
|
|
@@ -106,7 +107,7 @@ export async function rerunFailed(repo: string, runIds: number[]): Promise<void>
|
|
|
106
107
|
// Who the reviewer picker suggests: GitHub's picks for the PR and the repo's teams; recent reviewers come from the last fetch [PRS-12].
|
|
107
108
|
// Fetched when the picker opens, not in every refresh [GH-01]. My own repos have no teams, so they aren't asked for.
|
|
108
109
|
export async function reviewerChoices(target: Target, recent: Reviewer[], login: string | null): Promise<ReviewerChoices> {
|
|
109
|
-
const isMe = (name: string) =>
|
|
110
|
+
const isMe = (name: string) => sameName(name, login);
|
|
110
111
|
const [owner] = target.repo.split("/");
|
|
111
112
|
const [suggested, teams] = await Promise.all([
|
|
112
113
|
graphql<{ node: { suggestedReviewers: { reviewer: { login: string; avatarUrl?: string } }[] } | null }>(
|
package/server/archive.ts
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import type { PluginHandlerContext } from "@getpaseo/plugin/server";
|
|
2
2
|
import { execFile } from "node:child_process";
|
|
3
3
|
import { promisify } from "node:util";
|
|
4
|
-
import { isIdle } from "../shared/attention";
|
|
5
|
-
import type
|
|
4
|
+
import { busyWords, isIdle, subAgentBusy } from "../shared/attention";
|
|
5
|
+
import { type ArchiveResult, type KeptWorktree, type UnsavedSession, unsavedOf } from "../shared/archive";
|
|
6
|
+
import { subAgentsOf } from "../shared/linked-sessions";
|
|
7
|
+
import { listAll } from "./archived";
|
|
6
8
|
|
|
7
9
|
// Archiving finished work's sessions, safely [ATT-22]. Paseo's SDK has no restore, so an archive has no Undo here; instead
|
|
8
|
-
// nothing with unsaved work leaves without a confirmation. A
|
|
9
|
-
//
|
|
10
|
+
// nothing with unsaved work or open terminals leaves without a confirmation. A session's sub-agents go with it. A worktree
|
|
11
|
+
// goes only when no other session lives in it, through Paseo's own workspace archive, which archives everything in it; so
|
|
12
|
+
// every check here runs first. Which sessions to archive, and what that acknowledges, is the service's business.
|
|
10
13
|
|
|
11
14
|
const run = promisify(execFile);
|
|
12
15
|
|
|
13
|
-
// A session as Paseo's snapshot describes it; null where Paseo couldn't say.
|
|
16
|
+
// A session as Paseo's snapshot describes it; null where Paseo couldn't say. A worktree tried again on its own stands in as
|
|
17
|
+
// a session of its own, with no agent to archive.
|
|
14
18
|
export interface ArchiveSession {
|
|
15
19
|
agentId: string;
|
|
16
20
|
workspaceId: string | null;
|
|
@@ -18,6 +22,7 @@ export interface ArchiveSession {
|
|
|
18
22
|
branch?: string;
|
|
19
23
|
dirty: boolean | null;
|
|
20
24
|
ahead: number | null;
|
|
25
|
+
worktreeOnly?: true;
|
|
21
26
|
}
|
|
22
27
|
|
|
23
28
|
type Paseo = PluginHandlerContext["paseo"];
|
|
@@ -26,17 +31,12 @@ type ListedWorkspace = Awaited<ReturnType<Paseo["workspaces"]["list"]>>["entries
|
|
|
26
31
|
|
|
27
32
|
const base = (session: ArchiveSession): UnsavedSession => ({ agentId: session.agentId, title: session.title, ...(session.branch ? { branch: session.branch } : {}) });
|
|
28
33
|
|
|
29
|
-
//
|
|
30
|
-
|
|
31
|
-
export function unsaved(session: ArchiveSession): UnsavedSession | null {
|
|
32
|
-
if (session.dirty === false && session.ahead === 0) return null;
|
|
33
|
-
if (session.dirty === null || session.ahead === null) return { ...base(session), unknown: true };
|
|
34
|
-
return { ...base(session), ...(session.ahead ? { commits: session.ahead } : {}) };
|
|
35
|
-
}
|
|
34
|
+
// A workspace as Paseo's sidebar names it [ATT-22].
|
|
35
|
+
const nameOf = (workspace: ListedWorkspace | undefined): string => workspace?.title ?? workspace?.gitRuntime?.currentBranch ?? workspace?.name ?? "its worktree";
|
|
36
36
|
|
|
37
|
-
// How many files are uncommitted and commits unpushed, from git itself, since Paseo's
|
|
38
|
-
// Commits are those ahead of the upstream, or, with no upstream, those no remote has.
|
|
39
|
-
// couldn't give makes the whole answer unknown, never zero [ATT-22].
|
|
37
|
+
// How many files are uncommitted, with the lines added and deleted, and commits unpushed, from git itself, since Paseo's
|
|
38
|
+
// snapshot counts neither and can lag. Commits are those ahead of the upstream, or, with no upstream, those no remote has.
|
|
39
|
+
// Clean needs both answers: one git couldn't give makes the whole answer unknown, never zero [ATT-22].
|
|
40
40
|
export async function gitUnsaved(session: ArchiveSession, directory: string): Promise<UnsavedSession> {
|
|
41
41
|
const git = (args: string[]) => run("git", ["-C", directory, ...args], { timeout: 5000 }).then(({ stdout }) => stdout);
|
|
42
42
|
const count = (args: string[]) =>
|
|
@@ -51,82 +51,161 @@ export async function gitUnsaved(session: ArchiveSession, directory: string): Pr
|
|
|
51
51
|
const commits = await count(["@{upstream}..HEAD"])
|
|
52
52
|
.catch(() => count(["HEAD", "--not", "--remotes"]))
|
|
53
53
|
.catch(() => undefined);
|
|
54
|
-
|
|
54
|
+
// "2 files changed, 12 insertions(+), 3 deletions(-)"; only a nicety, so a failure just leaves the lines out.
|
|
55
|
+
const lines = files
|
|
56
|
+
? await git(["diff", "--shortstat", "HEAD"])
|
|
57
|
+
.then((stdout) => ({ added: Number(/(\d+) insertion/.exec(stdout)?.[1] ?? 0), deleted: Number(/(\d+) deletion/.exec(stdout)?.[1] ?? 0) }))
|
|
58
|
+
.catch(() => null)
|
|
59
|
+
: null;
|
|
60
|
+
const known = {
|
|
61
|
+
...(files ? { files } : {}),
|
|
62
|
+
...(lines && (lines.added || lines.deleted) ? lines : {}),
|
|
63
|
+
...(commits ? { commits } : {}),
|
|
64
|
+
};
|
|
55
65
|
return files === undefined || commits === undefined ? { ...base(session), unknown: true, ...known } : { ...base(session), ...known };
|
|
56
66
|
}
|
|
57
67
|
|
|
58
68
|
// What archiving would lose in a session: git's answer where there's a directory to ask, else Paseo's. Null when clean.
|
|
59
69
|
async function unsavedWork(session: ArchiveSession, workspace: ListedWorkspace | undefined): Promise<UnsavedSession | null> {
|
|
60
70
|
const directory = workspace?.workspaceDirectory ?? workspace?.projectRootPath;
|
|
61
|
-
if (!directory) return
|
|
71
|
+
if (!directory) return unsavedOf(session, session);
|
|
62
72
|
const found = await gitUnsaved(session, directory);
|
|
63
73
|
return found.unknown || found.files || found.commits ? found : null;
|
|
64
74
|
}
|
|
65
75
|
|
|
66
|
-
// Archives the given sessions, and the worktree behind each when
|
|
67
|
-
//
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
76
|
+
// Archives the given sessions with their sub-agents, and the worktree behind each when no other session lives in it
|
|
77
|
+
// [ATT-22]. `worktrees` are kept worktrees tried again on their own. `confirm` is the sheet that named unsaved work and open
|
|
78
|
+
// terminals; `seen` are the terminals it named, the only ones archiving may close.
|
|
79
|
+
export async function archiveSessions(paseo: Paseo, agentIds: string[], confirm: boolean, seen: string[] = [], worktrees: string[] = []): Promise<ArchiveResult> {
|
|
80
|
+
// Every agent, archived ones too, on every page: a sub-agent under an archived one, or a session on a later page, counts.
|
|
81
|
+
const everyAgent = () => listAll(paseo, { filter: { includeArchived: true } });
|
|
82
|
+
const [agentList, workspaceList] = await Promise.all([everyAgent(), paseo.workspaces.list()]);
|
|
83
|
+
const agents = new Map(agentList.map((agent) => [agent.id, agent]));
|
|
71
84
|
const workspaces = new Map<string, ListedWorkspace>(workspaceList.entries.map((workspace) => [workspace.id, workspace]));
|
|
72
85
|
const wanted = [...new Set(agentIds)];
|
|
73
|
-
const
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
{
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
86
|
+
const sessionOf = (workspace: ListedWorkspace, fields: Pick<ArchiveSession, "agentId" | "title"> & { worktreeOnly?: true }): ArchiveSession => {
|
|
87
|
+
const git = workspace.gitRuntime;
|
|
88
|
+
return {
|
|
89
|
+
...fields,
|
|
90
|
+
workspaceId: workspace.id,
|
|
91
|
+
...(git?.currentBranch ? { branch: git.currentBranch } : {}),
|
|
92
|
+
dirty: git?.isDirty ?? null,
|
|
93
|
+
ahead: git?.aheadOfOrigin ?? null,
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
const sessions: ArchiveSession[] = [
|
|
97
|
+
...wanted.flatMap((id) => {
|
|
98
|
+
const agent = agents.get(id);
|
|
99
|
+
if (!agent) return [];
|
|
100
|
+
const workspace = agent.workspaceId ? workspaces.get(agent.workspaceId) : undefined;
|
|
101
|
+
const fields = { agentId: id, title: agent.title ?? null };
|
|
102
|
+
return [workspace ? sessionOf(workspace, fields) : { ...fields, workspaceId: agent.workspaceId ?? null, dirty: null, ahead: null }];
|
|
103
|
+
}),
|
|
104
|
+
...worktrees.flatMap((id) => {
|
|
105
|
+
const workspace = workspaces.get(id);
|
|
106
|
+
// One that's also a session's own is checked as that session's.
|
|
107
|
+
const own = wanted.some((agentId) => agents.get(agentId)?.workspaceId === id);
|
|
108
|
+
return workspace && !own ? [sessionOf(workspace, { agentId: `worktree:${id}`, title: nameOf(workspace), worktreeOnly: true })] : [];
|
|
109
|
+
}),
|
|
110
|
+
];
|
|
111
|
+
// A session, or one of its sub-agents, still busy stops the archive. A session that needs me counts as busy; a sub-agent
|
|
112
|
+
// while it runs or needs me, not once it's finished or failed (subAgentBusy).
|
|
113
|
+
const working = (all: ListedAgent[]) =>
|
|
114
|
+
all.find((agent) => wanted.includes(agent.id) && !agent.archivedAt && !isIdle(agent)) ?? subAgentsOf(all, wanted).find((agent) => !agent.archivedAt && subAgentBusy(agent));
|
|
115
|
+
const busy = working(agentList);
|
|
116
|
+
if (busy) return { ok: false, reason: "working", message: busyWords(busy) };
|
|
117
|
+
const unsaved = async () => {
|
|
118
|
+
const dirty = new Map<string, UnsavedSession>();
|
|
97
119
|
for (const session of sessions) {
|
|
98
120
|
const found = await unsavedWork(session, session.workspaceId ? workspaces.get(session.workspaceId) : undefined);
|
|
99
|
-
if (found) dirty.
|
|
121
|
+
if (found) dirty.set(session.agentId, found);
|
|
100
122
|
}
|
|
101
|
-
|
|
102
|
-
}
|
|
123
|
+
return dirty;
|
|
124
|
+
};
|
|
125
|
+
const dirty = confirm ? new Map<string, UnsavedSession>() : await unsaved();
|
|
103
126
|
|
|
104
127
|
// The checks above can take a while: look again right before archiving, so a session that started working, or a session
|
|
105
128
|
// that moved into one of these worktrees meanwhile, is seen [ATT-22].
|
|
106
|
-
const latest = await
|
|
107
|
-
const resumed = working(latest
|
|
108
|
-
if (resumed) return { ok: false, reason: "working", message:
|
|
129
|
+
const latest = await everyAgent();
|
|
130
|
+
const resumed = working(latest);
|
|
131
|
+
if (resumed) return { ok: false, reason: "working", message: busyWords(resumed, true) };
|
|
132
|
+
const subAgents = subAgentsOf(latest, wanted);
|
|
133
|
+
const ours = new Set([...wanted, ...subAgents.map((agent) => agent.id)]);
|
|
109
134
|
|
|
110
|
-
//
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
135
|
+
// Which worktrees go: Paseo's, with no unarchived session in them but these and their sub-agents. One that holds another
|
|
136
|
+
// session stays, saying which one kept it.
|
|
137
|
+
// Paseo closes a worktree's terminals when it goes, so the sheet names them first. Terminals that can't be listed don't
|
|
138
|
+
// keep it: Paseo would close them all the same.
|
|
139
|
+
const terminalsOf = (workspaceId: string) =>
|
|
140
|
+
paseo.terminals
|
|
141
|
+
.list({ workspaceId })
|
|
142
|
+
.then((result) => result.entries.map(({ id, name }) => ({ id, name })))
|
|
143
|
+
.catch(() => []);
|
|
144
|
+
const leaving: { workspace: ListedWorkspace; session: ArchiveSession; terminals: { id: string; name: string }[] }[] = [];
|
|
145
|
+
const kept: KeptWorktree[] = [];
|
|
146
|
+
const keep = (workspace: ListedWorkspace, fields: Omit<KeptWorktree, "workspaceId" | "name" | "sessionIds">) =>
|
|
147
|
+
kept.push({ workspaceId: workspace.id, name: nameOf(workspace), ...fields, sessionIds: wanted.filter((id) => agents.get(id)?.workspaceId === workspace.id) });
|
|
118
148
|
for (const workspaceId of new Set(sessions.flatMap((session) => (session.workspaceId ? [session.workspaceId] : [])))) {
|
|
119
149
|
const workspace = workspaces.get(workspaceId);
|
|
120
150
|
if (!workspace || workspace.workspaceKind !== "worktree") continue;
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
151
|
+
const other = latest.find((agent) => agent.workspaceId === workspaceId && !agent.archivedAt && !ours.has(agent.id));
|
|
152
|
+
if (other) {
|
|
153
|
+
keep(workspace, { reason: "session", detail: other.title ?? "another session", agentId: other.id });
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
leaving.push({ workspace, session: sessions.find((session) => session.workspaceId === workspaceId)!, terminals: await terminalsOf(workspaceId) });
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Unsaved work, or a terminal the sheet didn't name, asks first; a terminal that opened after the sheet asks again, with
|
|
160
|
+
// whatever else is unsaved by then [ATT-22].
|
|
161
|
+
const unseen = leaving.some(({ terminals }) => terminals.some((terminal) => !seen.includes(terminal.id)));
|
|
162
|
+
if (dirty.size || unseen) {
|
|
163
|
+
const found = confirm ? await unsaved() : dirty;
|
|
164
|
+
for (const { session, terminals } of leaving) {
|
|
165
|
+
if (!terminals.length) continue;
|
|
166
|
+
found.set(session.agentId, { ...(found.get(session.agentId) ?? base(session)), terminals: terminals.map(({ name }) => name) });
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
ok: false,
|
|
170
|
+
reason: "unsaved",
|
|
171
|
+
sessions: sessions.flatMap((session) => found.get(session.agentId) ?? []),
|
|
172
|
+
terminals: leaving.flatMap(({ terminals }) => terminals.map(({ id }) => id)),
|
|
173
|
+
leaving: leaving.map(({ workspace }) => nameOf(workspace)),
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// Archive the sub-agents, deepest first, then the sessions; an already archived one counts as done. A sub-agent that
|
|
178
|
+
// wouldn't go and is still open stops the archive before its session goes, so nothing is acknowledged with it left open.
|
|
179
|
+
const failed: { agent: ListedAgent; message: string }[] = [];
|
|
180
|
+
for (const agent of [...subAgents].reverse()) {
|
|
181
|
+
await paseo.agents
|
|
182
|
+
.ref(agent.id)
|
|
183
|
+
.archive()
|
|
184
|
+
.catch((error: Error) => failed.push({ agent, message: error.message }));
|
|
185
|
+
}
|
|
186
|
+
if (failed.length) {
|
|
187
|
+
const open = new Set((await everyAgent()).filter((agent) => !agent.archivedAt).map((agent) => agent.id));
|
|
188
|
+
const stuck = failed.find(({ agent }) => open.has(agent.id));
|
|
189
|
+
if (stuck) throw new Error(`Couldn't archive ${stuck.agent.title ?? "a sub-agent"}: ${stuck.message}`);
|
|
190
|
+
}
|
|
191
|
+
for (const session of sessions) {
|
|
192
|
+
if (session.worktreeOnly || agents.get(session.agentId)?.archivedAt) continue;
|
|
193
|
+
await paseo.agents.ref(session.agentId).archive();
|
|
194
|
+
}
|
|
195
|
+
// The sessions are put away either way; a worktree that wouldn't go stays, saying why. Its terminals are listed once more
|
|
196
|
+
// right before it goes: one that opened while the sessions were archived wasn't on the sheet, so the worktree stays.
|
|
197
|
+
for (const { workspace } of leaving) {
|
|
198
|
+
const late = (await terminalsOf(workspace.id)).filter((terminal) => !seen.includes(terminal.id));
|
|
199
|
+
if (late.length) {
|
|
200
|
+
keep(workspace, { reason: "terminal", detail: late.map(({ name }) => name).join(", ") });
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
125
203
|
const failed = await paseo.workspaces
|
|
126
|
-
.archive(
|
|
204
|
+
.archive(workspace.id)
|
|
127
205
|
.then((result) => (result.error ? String(result.error) : null))
|
|
128
206
|
.catch((error: Error) => error.message);
|
|
129
|
-
if (failed)
|
|
207
|
+
if (failed) keep(workspace, { reason: "refused", detail: failed });
|
|
130
208
|
}
|
|
131
|
-
return
|
|
209
|
+
return { ok: true, kept };
|
|
132
210
|
}
|
|
211
|
+
|
package/server/archived.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import type { PluginHandlerContext } from "@getpaseo/plugin/server";
|
|
2
|
+
import { keySet } from "../shared/names";
|
|
3
|
+
import { SESSION_LABELS } from "../shared/item-sessions";
|
|
4
|
+
import { everyPage } from "../shared/paging";
|
|
2
5
|
|
|
3
6
|
// A session Attention Span started, archived in Paseo itself: once no session it started is left open on any part of the
|
|
4
7
|
// item's stack or issue group, what others did to that work up to the archive is acknowledged, so it doesn't come back as
|
|
@@ -11,7 +14,7 @@ type ListedAgent = Awaited<ReturnType<Paseo["agents"]["list"]>>["entries"][numbe
|
|
|
11
14
|
type ListOptions = NonNullable<Parameters<Paseo["agents"]["list"]>[0]>;
|
|
12
15
|
|
|
13
16
|
// The markers and item labels of sessions Attention Span started, under its current and earlier names [ATT-07, SES-03].
|
|
14
|
-
const MARKERS =
|
|
17
|
+
const MARKERS = SESSION_LABELS;
|
|
15
18
|
const ITEM_LABELS = MARKERS.map((marker) => `${marker}-item`);
|
|
16
19
|
// Agents another agent started belong to that agent's session.
|
|
17
20
|
const PARENT_AGENT_LABEL = "paseo.parent-agent-id";
|
|
@@ -25,13 +28,13 @@ export interface ArchiveEvent {
|
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
// What Paseo says of the archived session now; null when it couldn't be found.
|
|
28
|
-
|
|
31
|
+
type FoundSession = Pick<ListedAgent, "labels" | "archivedAt"> | null;
|
|
29
32
|
|
|
30
|
-
|
|
33
|
+
const itemKeyOf = (labels: Record<string, string> | undefined | null): string | undefined =>
|
|
31
34
|
ITEM_LABELS.map((label) => labels?.[label]).find(Boolean);
|
|
32
35
|
|
|
33
36
|
// The item whose notes the archive may acknowledge; "drop" when it acknowledges nothing, "wait" when it can't tell yet.
|
|
34
|
-
|
|
37
|
+
function archivedItem(event: ArchiveEvent, found: FoundSession): { itemKey: string } | "drop" | "wait" {
|
|
35
38
|
if (event.parentAgentId) return "drop";
|
|
36
39
|
if (!found) return "wait";
|
|
37
40
|
if (found.labels?.[PARENT_AGENT_LABEL]) return "drop";
|
|
@@ -43,8 +46,8 @@ export function archivedItem(event: ArchiveEvent, found: FoundSession): { itemKe
|
|
|
43
46
|
|
|
44
47
|
// Whether an open session Attention Span started is on any of the keys, which are compared ignoring case. The archived
|
|
45
48
|
// session itself counts too: if it's listed open, it was restored while this was being decided.
|
|
46
|
-
|
|
47
|
-
const wanted =
|
|
49
|
+
function stillOpen(keys: string[], open: Pick<ListedAgent, "labels" | "archivedAt">[]): boolean {
|
|
50
|
+
const wanted = keySet(keys);
|
|
48
51
|
return open.some((agent) => {
|
|
49
52
|
if (agent.archivedAt) return false;
|
|
50
53
|
const itemKey = itemKeyOf(agent.labels);
|
|
@@ -53,15 +56,8 @@ export function stillOpen(keys: string[], open: Pick<ListedAgent, "labels" | "ar
|
|
|
53
56
|
}
|
|
54
57
|
|
|
55
58
|
// Every page of a list; a failed page fails the whole list, so it's never mistaken for an empty one.
|
|
56
|
-
async function listAll(paseo: Paseo, options: ListOptions): Promise<ListedAgent[]> {
|
|
57
|
-
|
|
58
|
-
let cursor: string | undefined;
|
|
59
|
-
for (;;) {
|
|
60
|
-
const result = await paseo.agents.list({ ...options, page: { limit: 200, ...(cursor ? { cursor } : {}) } });
|
|
61
|
-
agents.push(...result.entries.map((entry) => entry.agent));
|
|
62
|
-
if (!result.pageInfo.hasMore || !result.pageInfo.nextCursor) return agents;
|
|
63
|
-
cursor = result.pageInfo.nextCursor;
|
|
64
|
-
}
|
|
59
|
+
export async function listAll(paseo: Paseo, options: ListOptions): Promise<ListedAgent[]> {
|
|
60
|
+
return (await everyPage((page) => paseo.agents.list({ ...options, page }))).map((entry) => entry.agent);
|
|
65
61
|
}
|
|
66
62
|
|
|
67
63
|
// The archived session as Paseo has it now: its own snapshot, or else the list with archived sessions in it.
|
|
@@ -71,7 +67,7 @@ async function findSession(paseo: Paseo, agentId: string): Promise<FoundSession>
|
|
|
71
67
|
return (await listAll(paseo, { filter: { includeArchived: true } })).find((agent) => agent.id === agentId) ?? null;
|
|
72
68
|
}
|
|
73
69
|
|
|
74
|
-
|
|
70
|
+
interface ArchiveDeps {
|
|
75
71
|
groupKeysOf(itemKey: string): string[];
|
|
76
72
|
acknowledge(keys: string[], upTo: string): Promise<unknown>;
|
|
77
73
|
}
|