@andrioid/paseo-attention-span 0.3.4 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,6 @@
1
1
  import type { usePaseo } from "@getpaseo/plugin/client";
2
2
  import type { AgentSummary, Target } from "../shared/attention";
3
+ import { linkedSessions } from "../shared/linked-sessions";
3
4
  import { chooseAgent, type ReadyProvider } from "../shared/providers";
4
5
  import { type AttentionConfig, codeRepoFor, githubRepoOf, SessionKind } from "../shared/config";
5
6
 
@@ -13,10 +14,15 @@ export const KIND_LABEL = "attention-span-kind";
13
14
  // Sessions started under the plugin's earlier names, "GitHub attention" and "GitHub inbox".
14
15
  const OLD_LABELS = ["github-attention", "github-inbox"];
15
16
 
16
- // Agents started from Attention Span, each with the item it was started on.
17
+ // Agents started from Attention Span, each with the item it was started on, and the agents
18
+ // started outside it in a workspace that belongs to an item [SES-08].
17
19
  export async function itemAgents(paseo: Paseo): Promise<AgentSummary[]> {
18
20
  const labels = [LABEL, ...OLD_LABELS];
19
- const lists = await Promise.all(labels.map((label) => paseo.agents.list({ filter: { labels: { [label]: "1" } } })));
21
+ const [lists, all, workspaces] = await Promise.all([
22
+ Promise.all(labels.map((label) => paseo.agents.list({ filter: { labels: { [label]: "1" } } }))),
23
+ paseo.agents.list(),
24
+ paseo.workspaces.list(),
25
+ ]);
20
26
  const byId = new Map<string, AgentSummary>();
21
27
  for (const { agent } of lists.flatMap((list) => list.entries)) {
22
28
  const itemKey = labels.map((label) => agent.labels?.[`${label}-item`]).find(Boolean);
@@ -32,7 +38,9 @@ export async function itemAgents(paseo: Paseo): Promise<AgentSummary[]> {
32
38
  lastActivityAt: agent.updatedAt ?? null,
33
39
  });
34
40
  }
35
- return [...byId.values()];
41
+ const labelled = [...byId.values()];
42
+ const unlabelled = all.entries.map((entry) => entry.agent).filter((agent) => !labels.some((label) => agent.labels?.[label]));
43
+ return [...labelled, ...linkedSessions(labelled, unlabelled, workspaces.entries)];
36
44
  }
37
45
 
38
46
  export interface ProjectMatch {
@@ -125,7 +125,7 @@ An agent icon (Tabler's `message-ai`, a speech bubble with "AI") marks every act
125
125
 
126
126
  A tap starts with defaults. An existing workspace for the branch or PR is resumed instead of creating a new one.
127
127
 
128
- While an item has an open session, its main action is **Open session** instead, in every tab [SES-03, ATT-07]. A session belongs to an item when it was started on the item or on any PR under it, and isn't archived; none do once the item is merged or closed. With several, it opens one that needs me, else the most recent. In the sheet each session sits in the line of the action that started it, named after it ("Fix CI", "Rebase stack"), one line per session: a session's kind is saved as the `attention-span-kind` label when it starts. Sessions none of the item's actions would start lead the sheet: those started before kinds were saved, as "Continue session", and those whose action is gone, like Fix CI once checks pass. Next up's sheet does the same with Start: "Claim & start…" or "Start…" until there's a session, then the sessions as "Continue session" and a muted "Start another session…". Collapsed, a stack shows only the PRs that need attention [ATT-04].
128
+ While an item has an open session, its main action is **Open session** instead, in every tab [SES-03, ATT-07]. A session belongs to an item when it was started on the item or on any PR under it, and isn't archived; none do once the item is merged or closed. With several, it opens one that needs me, else the most recent. In the sheet each session sits in the line of the action that started it, named after it ("Fix CI", "Rebase stack"), one line per session: a session's kind is saved as the `attention-span-kind` label when it starts. Sessions none of the item's actions would start lead the sheet: those started before kinds were saved, as "Continue session", and those whose action is gone, like Fix CI once checks pass. Sessions started outside Attention Span count too, with no kind, so they lead as "Continue session" [SES-08]: an agent in a workspace Paseo linked to a PR (`githubRuntime.pullRequest`) belongs to that PR, and one in a worktree belongs to the item of the Attention Span session there, unless the worktree has sessions for two items. Main and local checkouts never pass an item on, a labelled session keeps its own item, and agents another agent started belong to that agent. Issues get only the sessions Attention Span started: Paseo doesn't record which issue a workspace was started from. Next up's sheet does the same with Start: "Claim & start…" or "Start…" until there's a session, then the sessions as "Continue session" and a muted "Start another session…". Collapsed, a stack shows only the PRs that need attention [ATT-04].
129
129
 
130
130
  ## Sessions
131
131
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@andrioid/paseo-attention-span",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "description": "For when your attention is spread thin: the GitHub issues and pull requests waiting on you, grouped by why, with one-tap Paseo sessions.",
5
5
  "license": "MIT",
6
6
  "repository": {
package/requirements.yaml CHANGED
@@ -78,6 +78,7 @@ functional:
78
78
  SES-05: start sessions in my local checkout of the item's repository without configuring paths; so that new repositories work without setup.
79
79
  SES-06: start sessions even when no agent profiles are configured; so that Attention Span works before I've set anything up.
80
80
  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.
81
+ 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"; so that I don't start duplicate work.
81
82
  next_up:
82
83
  As a developer, I can:
83
84
  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.
package/server/fixture.ts CHANGED
@@ -238,6 +238,7 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
238
238
  // Sessions the preview shows as started from items: working, needs me, failed, idle.
239
239
  // Each sits in its action's line in the sheet. Issue 90 has two: an old one with no kind, which leads, and Rebase stack on its PR.
240
240
  // #113 waits on CI while its Fix CI session works, though Fix CI isn't one of its actions any more.
241
+ // #120's was started outside Attention Span, in a workspace Paseo linked to the PR, so it has no kind [SES-08].
241
242
  const agent = (id: string, itemKey: string, kind: SessionKind | undefined, status: string, minutesAgo: number, requiresAttention = false): AgentSummary => ({
242
243
  id,
243
244
  itemKey,
@@ -256,6 +257,7 @@ export const FIXTURE_AGENTS: AgentSummary[] = [
256
257
  agent("agent-90", `${REPO}#90`, undefined, "idle", 120, true),
257
258
  agent("agent-103", `${REPO}#103`, "rebase", "running", 6),
258
259
  agent("agent-113", `${REPO}#113`, "fix", "running", 2),
260
+ agent("agent-120", `${REPO}#120`, undefined, "running", 3),
259
261
  ];
260
262
 
261
263
  export const FIXTURE_CONTEXT = "Context from GitHub would go here (fixture mode).";
@@ -0,0 +1,69 @@
1
+ // Sessions started outside Attention Span, on the item their workspace belongs to [SES-08].
2
+ import type { AgentSummary } from "./attention";
3
+
4
+ // The parts of a Paseo agent entry this needs.
5
+ export interface PaseoAgentEntry {
6
+ id: string;
7
+ labels?: Record<string, string>;
8
+ archivedAt?: string | null;
9
+ status: string;
10
+ requiresAttention?: boolean;
11
+ title?: string | null;
12
+ workspaceId?: string | null;
13
+ updatedAt?: string | null;
14
+ }
15
+
16
+ // The parts of a Paseo workspace entry this needs.
17
+ export interface PaseoWorkspaceEntry {
18
+ id: string;
19
+ workspaceKind: string;
20
+ archivingAt?: string | null;
21
+ githubRuntime?: { pullRequest?: { url: string; number?: number } | null } | null;
22
+ }
23
+
24
+ // Agents another agent started belong to that agent's session, not to the item.
25
+ const PARENT_AGENT_LABEL = "paseo.parent-agent-id";
26
+
27
+ // "owner/name#number" for a GitHub pull request URL.
28
+ export function pullRequestKey(url: string): string | null {
29
+ const match = /^https?:\/\/github\.com\/([^/]+\/[^/]+)\/pull\/(\d+)/i.exec(url);
30
+ return match ? `${match[1]}#${match[2]}` : null;
31
+ }
32
+
33
+ // Unlabelled agents, keyed to the PR Paseo linked their workspace to, or else to the item of the
34
+ // Attention Span session whose worktree they share. Main and local checkouts never pass an item on,
35
+ // and a worktree with sessions for two items passes on neither.
36
+ export function linkedSessions(labelled: AgentSummary[], agents: PaseoAgentEntry[], workspaces: PaseoWorkspaceEntry[]): AgentSummary[] {
37
+ const known = new Set(labelled.map((agent) => agent.id));
38
+ const items = new Map<string, Set<string>>();
39
+ for (const agent of labelled) {
40
+ if (!agent.workspaceId) continue;
41
+ const keys = items.get(agent.workspaceId) ?? new Set<string>();
42
+ keys.add(agent.itemKey.toLowerCase());
43
+ items.set(agent.workspaceId, keys);
44
+ }
45
+ const itemOf = new Map<string, string>();
46
+ for (const workspace of workspaces) {
47
+ if (workspace.archivingAt) continue;
48
+ const pr = workspace.githubRuntime?.pullRequest;
49
+ const linked = pr ? pullRequestKey(pr.url) : null;
50
+ const shared = workspace.workspaceKind === "worktree" ? items.get(workspace.id) : undefined;
51
+ const key = linked ?? (shared?.size === 1 ? [...shared][0] : null);
52
+ if (key) itemOf.set(workspace.id, key);
53
+ }
54
+ return agents.flatMap((agent) => {
55
+ const itemKey = agent.workspaceId ? itemOf.get(agent.workspaceId) : undefined;
56
+ if (!itemKey || known.has(agent.id) || agent.archivedAt || agent.labels?.[PARENT_AGENT_LABEL]) return [];
57
+ return [
58
+ {
59
+ id: agent.id,
60
+ itemKey,
61
+ status: agent.status,
62
+ requiresAttention: !!agent.requiresAttention,
63
+ title: agent.title ?? null,
64
+ workspaceId: agent.workspaceId ?? null,
65
+ lastActivityAt: agent.updatedAt ?? null,
66
+ },
67
+ ];
68
+ });
69
+ }