@andrioid/paseo-attention-span 0.4.6 → 0.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/OVERVIEW.md CHANGED
@@ -53,7 +53,7 @@ When someone needs a nudge, **Copy list** next to their name copies their items
53
53
 
54
54
  ## Next up: for when your plate is clear
55
55
 
56
- It does happen. Next up lists issues assigned to you first, because finishing what you've taken seems polite, and then open issues nobody's claimed. If your org uses issue fields for priority and effort, it ranks by those, so the important quick wins float to the top. Each issue shows its repo, priority, effort and scope, and whether someone already has a PR open for it. That last one has saved me from duplicating a colleague's work more than once.
56
+ It does happen. Next up lists issues assigned to you first, because finishing what you've taken seems polite, and then open issues nobody's claimed. If your org uses issue fields for priority and effort, it ranks by those, so the important quick wins float to the top. Fields called Priority, Effort and Scope are picked up on their own; if yours are called something else, pick them in Settings. Each issue shows its repo, priority, effort and scope, and whether someone already has a PR open for it. That last one has saved me from duplicating a colleague's work more than once.
57
57
 
58
58
  ![Next up](docs/screenshots/desktop-dark-next-up.png)
59
59
 
@@ -132,7 +132,7 @@ Everything else lives in `~/.config/paseo-attention-span/config.json` on the dae
132
132
  - `prompts`: your own prompt template per session type, if you don't like mine.
133
133
  - `mergeMethods`: squash, merge or rebase, per repo.
134
134
  - `codeRepos`: where an issue repo's code lives. The screen asks and fills this in, so you probably won't touch it.
135
- - `nextUp`: where Next up picks from (also in Settings), and which org issue fields mean priority, effort and scope.
135
+ - `nextUp`: where Next up picks from and which org issue fields mean priority, effort and scope, both also in Settings. A field's `order` (best first) is the one thing here only the file sets, for when the org's own option order isn't the ranking you want.
136
136
  - `refreshMinutes` (15), `waitingTooLongDays` (3), `staleDraftDays` (30), `mentionDays` (30) and `historyWeeks` (4).
137
137
 
138
138
  ## Your data
@@ -145,4 +145,4 @@ Everything else lives in `~/.config/paseo-attention-span/config.json` on the dae
145
145
  ## What it doesn't do (yet)
146
146
 
147
147
  - github.com only. No other forges and no GitHub Enterprise, for now.
148
- - Apart from orgs and repos, settings are edited by hand. Yes, in JSON. Sorry.
148
+ - Apart from orgs, repos and Next up, settings are edited by hand. Yes, in JSON. Sorry.
@@ -4,12 +4,14 @@ import { useQuery, useQueryClient } from "@tanstack/react-query";
4
4
  import { useState } from "react";
5
5
  import { Text, View } from "react-native";
6
6
  import * as rpc from "../shared/rpc";
7
- import type { ConfigStatus, CoverageKind } from "../shared/setup";
7
+ import { DEFAULT_FIELD, FIELD_ROLES, type FieldRole, sameField } from "../shared/config";
8
+ import type { ConfigStatus, CoverageKind, IssueField } from "../shared/setup";
8
9
  import { VIEW_QUERY_KEY } from "./data";
9
10
  import { Button, StylesProvider, useStyles } from "./ui";
10
11
 
11
12
  const COVERAGE_QUERY_KEY = ["attention-span", "coverage"] as const;
12
13
  const MY_ORGS_QUERY_KEY = ["attention-span", "my-orgs"] as const;
14
+ const FIELDS_QUERY_KEY = ["attention-span", "issue-fields"] as const;
13
15
  // A caption belongs to the card above it, so it sits closer to that card than to the next heading.
14
16
  const CAPTION = { marginTop: -24, marginBottom: 16 };
15
17
 
@@ -30,6 +32,7 @@ function Coverage() {
30
32
  const save = useRpc(rpc.setCoverage);
31
33
  const saveNextUp = useRpc(rpc.setNextUpSources);
32
34
  const saveFollow = useRpc(rpc.setFollowThreads);
35
+ const saveFields = useRpc(rpc.setNextUpFields);
33
36
  const coverage = useQuery({ queryKey: COVERAGE_QUERY_KEY, queryFn: () => fetchCoverage({}) });
34
37
  const [saving, setSaving] = useState(false);
35
38
  const [error, setError] = useState<string | null>(null);
@@ -42,7 +45,7 @@ function Coverage() {
42
45
  </SettingsCard>
43
46
  </SettingsSection>
44
47
  );
45
- const { orgs, repos, nextUp, followThreads } = coverage.data;
48
+ const { orgs, repos, nextUp, fields, followThreads } = coverage.data;
46
49
  // A file that doesn't parse is left for the person who edited it.
47
50
  if (coverage.data.error)
48
51
  return (
@@ -61,6 +64,8 @@ function Coverage() {
61
64
  await send();
62
65
  queryClient.setQueryData(COVERAGE_QUERY_KEY, { ...coverage.data!, ...next });
63
66
  await queryClient.invalidateQueries({ queryKey: VIEW_QUERY_KEY });
67
+ // Other orgs may have other fields.
68
+ if (next.orgs || next.repos || next.nextUp) void queryClient.invalidateQueries({ queryKey: FIELDS_QUERY_KEY });
64
69
  } catch (failure) {
65
70
  setError(`Saving failed: ${(failure as Error).message}`);
66
71
  } finally {
@@ -106,6 +111,7 @@ function Coverage() {
106
111
  : "None chosen: using your Paseo projects."}
107
112
  </Text>
108
113
  </View>
114
+ <NextUpFields value={fields} disabled={saving} onChange={(role, field) => write({ fields: { ...fields, [role]: field } }, () => saveFields({ [role]: field }))} />
109
115
  <View style={{ gap: 8 }}>
110
116
  <SettingsSection title="Replies">
111
117
  <SettingsCard>
@@ -165,6 +171,62 @@ function NextUpSources({ value, disabled, onChange }: { value: ConfigStatus["nex
165
171
  );
166
172
  }
167
173
 
174
+ const ROLE_LABEL: Record<FieldRole, string> = { priority: "Priority", effort: "Effort", scope: "Scope" };
175
+ const ROLE_HINT: Record<FieldRole, string> = {
176
+ priority: "Ranks the list, in the field's order",
177
+ effort: "Breaks ties, in the field's order",
178
+ scope: "Adds a filter to Next up",
179
+ };
180
+
181
+ // Which org issue fields rank and filter Next up [NXT-04], picked from the fields its orgs have. Until I pick, a field
182
+ // named after the role is used, so an org with Priority and Effort needs no setup.
183
+ function NextUpFields({ value, disabled, onChange }: { value: ConfigStatus["fields"]; disabled: boolean; onChange: (role: FieldRole, field: string | null) => Promise<void> }) {
184
+ const styles = useStyles();
185
+ const fetchFields = useRpc(rpc.issueFields);
186
+ const available = useQuery({ queryKey: FIELDS_QUERY_KEY, queryFn: () => fetchFields({}) });
187
+ const fields: IssueField[] = available.data?.fields ?? [];
188
+ const find = (name: string | null | undefined) => fields.find((field) => sameField(field.name, name ?? undefined));
189
+ // What each role uses now: the chosen field, or the one named after it if an org has it. Names match without case,
190
+ // so a field typed "priority" shows as GitHub's "Priority".
191
+ const current = (role: FieldRole): string | null => {
192
+ const chosen = role in value ? (value[role] ?? null) : DEFAULT_FIELD[role];
193
+ return find(chosen)?.name ?? (role in value ? chosen : null);
194
+ };
195
+ const none = available.isLoading ? "Loading…" : "None";
196
+
197
+ return (
198
+ <View style={{ gap: 8 }}>
199
+ <SettingsSection title="Next up fields">
200
+ <SettingsCard>
201
+ {FIELD_ROLES.map((role) => {
202
+ const chosen = current(role);
203
+ // A field no org has any more still shows, so it can be seen and changed.
204
+ const missing = chosen && available.data && !find(chosen) ? [{ label: `${chosen} (not found)`, value: chosen }] : [];
205
+ const hint = !(role in value) && chosen ? `${ROLE_HINT[role]}. Picked by its name` : ROLE_HINT[role];
206
+ return (
207
+ <SettingsSelect
208
+ key={role}
209
+ label={ROLE_LABEL[role]}
210
+ hint={hint}
211
+ error={role === "priority" && available.error ? (available.error as Error).message : null}
212
+ value={chosen ?? ""}
213
+ options={[{ label: none, value: "" }, ...missing, ...fields.map((field) => ({ label: field.name, value: field.name }))]}
214
+ disabled={disabled || !available.data}
215
+ onValueChange={(field) => void onChange(role, field || null)}
216
+ />
217
+ );
218
+ })}
219
+ </SettingsCard>
220
+ </SettingsSection>
221
+ <Text style={[styles.muted, CAPTION]}>
222
+ {available.data && fields.length === 0
223
+ ? "None of the organizations Next up looks in have issue fields, so it lists issues oldest first."
224
+ : "Org issue fields from the organizations Next up looks in. Values rank in the order the organization lists them."}
225
+ </Text>
226
+ </View>
227
+ );
228
+ }
229
+
168
230
  // Each name is checked on GitHub before it's saved; GitHub's exact name is what's kept.
169
231
  function AddRow({ kind, placeholder, existing, disabled, onAdd }: { kind: CoverageKind; placeholder?: string; existing: string[]; disabled: boolean; onAdd: (name: string) => Promise<void> }) {
170
232
  const styles = useStyles();
package/index.server.ts CHANGED
@@ -47,6 +47,8 @@ export default function contribute(server: PluginServerContext) {
47
47
  server.handle(rpc.checkCoverage, ({ kind, name }) => checkCoverage(kind, name));
48
48
  server.handle(rpc.setCoverage, ({ orgs, repos }) => ready(() => attention.setCoverage(orgs, repos)).then(() => ({ ok: true as const })));
49
49
  server.handle(rpc.setNextUpSources, (sources) => ready(() => attention.setNextUpSources(sources)).then(() => ({ ok: true as const })));
50
+ server.handle(rpc.issueFields, () => ready(async () => ({ fields: await attention.issueFields() })));
51
+ server.handle(rpc.setNextUpFields, (fields) => ready(() => attention.setNextUpFields(fields)).then(() => ({ ok: true as const })));
50
52
  server.handle(rpc.setFollowThreads, ({ on }) => ready(() => attention.setFollowThreads(on)).then(() => ({ ok: true as const })));
51
53
  server.handle(rpc.myOrgs, async () => ({ orgs: await myOrgs() }));
52
54
  server.handle(rpc.setScopes, ({ scopes }) => ready(() => attention.setScopes(scopes)).then(() => ({ ok: true as const })));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@andrioid/paseo-attention-span",
3
- "version": "0.4.6",
3
+ "version": "0.4.7",
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
@@ -87,7 +87,7 @@ functional:
87
87
  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.
88
88
  NXT-02: see unclaimed issues ordered by priority, then effort, then age; so that the most important quick wins come first.
89
89
  NXT-03: filter unclaimed issues by scope, and have my choice remembered; so that I only see work I'd pick up.
90
- NXT-04: choose in the app where unclaimed issues come from (my own repositories, organizations I belong to, or single repositories) and choose which issue fields the list uses; so that the plugin can be used elsewhere without editing files.
90
+ NXT-04: choose in the app where unclaimed issues come from (my own repositories, organizations I belong to, or single repositories) and choose which issue fields the list uses, with fields named Priority, Effort and Scope used until I do; so that the plugin can be used elsewhere without editing files.
91
91
  NXT-05: claim an issue and start a session on it in one step; so that teammates see it's taken and I can start right away.
92
92
  NXT-06: see issues assigned to me before unclaimed ones; so that I finish what I've taken before picking more.
93
93
  NXT-07: claim an issue without starting a session, and give back one assigned to me; so that what I've taken matches what I'll do.
@@ -13,7 +13,7 @@ import {
13
13
  type Target,
14
14
  type WaitingOn,
15
15
  } from "../shared/attention";
16
- import type { AttentionConfig, MergeMethod } from "../shared/config";
16
+ import { type AttentionConfig, FIELD_ROLES, type MergeMethod, nextUpField, sameField } from "../shared/config";
17
17
  import { ago, daysSince } from "../shared/format";
18
18
  import { workChip, workKind } from "../shared/work";
19
19
  import type { Actor, Comment, Details, HistoryResult, IssueNode, LinkedIssue, LiveResult, MentionNode, PickableNode, PullRequestNode, RequestedReviewer } from "./github-types";
@@ -565,13 +565,13 @@ export function mergeMethodFor(pr: PullRequestNode, config: AttentionConfig): Me
565
565
  // ---- Next up: issues by priority, effort, then age [NXT-02] ----
566
566
 
567
567
  function rankIssues(nodes: PickableNode[], details: Details, config: AttentionConfig): NextUpIssue[] {
568
- const { priority, effort, scope } = config.nextUp;
569
- const valueOf = (node: PickableNode, field: string | undefined) =>
570
- field ? node.issueFieldValues.nodes.find((value) => value.field?.name === field)?.name : undefined;
568
+ const [priority, effort, scope] = FIELD_ROLES.map((role) => nextUpField(config, role));
569
+ const valueOf = (node: PickableNode, field: string | undefined) => node.issueFieldValues.nodes.find((value) => sameField(value.field?.name, field))?.name;
570
+ const optionsOf = (field: string) => Object.entries(details.fieldOptions).find(([name]) => sameField(name, field))?.[1];
571
571
  // Position in the configured order (matched by name), else in the field's own options; missing goes last.
572
572
  const position = (value: string | undefined, ranked: { field: string; order?: string[] } | undefined) => {
573
573
  if (!value || !ranked) return Infinity;
574
- const order = ranked.order ?? details.fieldOptions[ranked.field] ?? [];
574
+ const order = ranked.order ?? optionsOf(ranked.field) ?? [];
575
575
  const index = order.findIndex((name) => value.toLowerCase().includes(name.toLowerCase()));
576
576
  return index < 0 ? Infinity : index;
577
577
  };
package/server/fixture.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { AgentSummary, ItemDetails, Reviewer, ReviewerChoices, Target } from "../shared/attention";
2
2
  import type { SessionKind } from "../shared/config";
3
+ import type { IssueField } from "../shared/setup";
3
4
  import type { Actor, Comment, Details, IssueNode, MentionNode, PickableNode, PullRequestNode, SearchResult } from "./github-types";
4
5
 
5
6
  // Made-up GitHub data for tests and for previews without GitHub (PASEO_ATTENTION_SPAN_FIXTURE=1).
@@ -12,6 +13,13 @@ export const FIXTURE_ORGS = ["acme"];
12
13
  export const FIXTURE_REPOS = [REPO, ISSUES_REPO, "acme/web", "me/tool"];
13
14
  // The orgs Next up's org picker offers in previews [NXT-04].
14
15
  export const FIXTURE_MY_ORGS = ["acme", "globex"];
16
+ // The org issue fields settings offers for Next up [NXT-04].
17
+ export const FIXTURE_ISSUE_FIELDS: IssueField[] = [
18
+ { name: "Effort", options: ["🐟 Tiny (< 4h)", "🐇 Small (0.5-2d)", "🐂 Medium (2-5d)", "🦑 Large (1-2w)"], orgs: ["acme"] },
19
+ { name: "Priority", options: ["🌋 P0 Urgent", "🏔 P1 High", "🏕P2 Medium", "🏝 P3 Low"], orgs: ["acme"] },
20
+ { name: "Scope", options: ["🔙 Backend", "🖌 Frontend", "🕵 Full-stack", "📱 Mobile app"], orgs: ["acme"] },
21
+ { name: "Team", options: ["Platform", "Payments"], orgs: ["acme"] },
22
+ ];
15
23
  const repository = { nameWithOwner: REPO, squashMergeAllowed: true, defaultBranchRef: { name: "main" } };
16
24
  const avatar = (id: number) => `https://avatars.githubusercontent.com/u/${id}?v=4`;
17
25
 
package/server/queries.ts CHANGED
@@ -208,14 +208,21 @@ export function detailsQuery(prs: PullRequestNode[], orgs: string[], refs: Issue
208
208
  issueOrPullRequest(number: ${ref.number}) { ... on Issue { number title url state repository { nameWithOwner } } }
209
209
  }`),
210
210
  );
211
- orgs.forEach((org, index) =>
212
- fields.push(`o${index}: organization(login: ${JSON.stringify(org)}) {
213
- issueFields(first: 50) { nodes { ... on IssueFieldSingleSelect { name options { name } } } }
214
- }`),
215
- );
211
+ orgs.forEach((org, index) => fields.push(orgFields(`o${index}`, org)));
216
212
  return { query: `query Details {\n${fields.join("\n")}\n}`, compares };
217
213
  }
218
214
 
215
+ // An org's single-select issue fields with their options, in the org's order [NXT-02].
216
+ const orgFields = (alias: string, org: string) => `${alias}: organization(login: ${JSON.stringify(org)}) {
217
+ issueFields(first: 50) { nodes { ... on IssueFieldSingleSelect { name options { name } } } }
218
+ }`;
219
+ export type OrgFields = { issueFields?: { nodes: { name?: string; options?: { name: string }[] }[] } } | null;
220
+
221
+ // The fields settings offers for Next up, from every org it might pick from [NXT-04]. An owner that's a person fails only its own field.
222
+ export function issueFieldsQuery(orgs: string[]): string {
223
+ return `query IssueFields {\n${orgs.map((org, index) => orgFields(`o${index}`, org)).join("\n")}\n}`;
224
+ }
225
+
219
226
  // GitHub works out at most this many PRs' merge state per request; asked about more, it says BLOCKED for all of them, even
220
227
  // in search and in a repo's PR list. Seen on 2026-11-04 [PRS-13].
221
228
  export const MERGE_STATE_BATCH = 5;
package/server/service.ts CHANGED
@@ -1,13 +1,14 @@
1
1
  import type { Attention, AttentionView, FeedId, FeedStatus, Item, Reviewer } from "../shared/attention";
2
2
  import type { PluginHandlerContext } from "@getpaseo/plugin/server";
3
- import { AttentionConfig, githubRepoOf } from "../shared/config";
3
+ import { AttentionConfig, type FieldRole, githubRepoOf, nextUpField } from "../shared/config";
4
+ import type { IssueField } from "../shared/setup";
4
5
  import { classify, classifyHistory } from "./classify";
5
6
  import { FIXTURE, graphql } from "./gh";
6
- import { fixture, FIXTURE_AGENTS } from "./fixture";
7
+ import { fixture, FIXTURE_AGENTS, FIXTURE_ISSUE_FIELDS } from "./fixture";
7
8
  import type { Details, HistoryResult, LinkedIssue, LiveResult, MergeStateStatus, PullRequestNode } from "./github-types";
8
- import { type CheckContext, detailsQuery, HISTORY_SEARCHES, MERGE_STATE_BATCH, mergeStateQuery, mergeUnclaimed, prKey, requiredChecks, type SearchName, searchQuery, searchVariables, type UnclaimedSearch, unclaimedSearches } from "./queries";
9
+ import { type CheckContext, detailsQuery, HISTORY_SEARCHES, issueFieldsQuery, type OrgFields, MERGE_STATE_BATCH, mergeStateQuery, mergeUnclaimed, prKey, requiredChecks, type SearchName, searchQuery, searchVariables, type UnclaimedSearch, unclaimedSearches } from "./queries";
9
10
  import { toLookUp } from "./references";
10
- import { loadConfig, loadState, moveOldFiles, saveCodeRepo, saveCoverage, saveFollowThreads, saveNextUpSources, saveState, State } from "./store";
11
+ import { loadConfig, loadState, moveOldFiles, saveCodeRepo, saveCoverage, saveFollowThreads, saveNextUpFields, saveNextUpSources, saveState, State } from "./store";
11
12
  import { applyPending, buildView, doneItem, type Effect, isPending, SETTLE_MS } from "./view";
12
13
 
13
14
  // History changes only when I finish something, so it's fetched daily, on ⟳ in its tab and after a merge.
@@ -107,6 +108,36 @@ export class AttentionService {
107
108
  await this.refresh("live").catch(() => {});
108
109
  }
109
110
 
111
+ // Which org issue fields Next up uses, chosen in settings [NXT-04]. Only the live feed has Next up.
112
+ async setNextUpFields(fields: Partial<Record<FieldRole, string | null>>): Promise<void> {
113
+ this.config = await saveNextUpFields(fields);
114
+ await this.refresh("live").catch(() => {});
115
+ }
116
+
117
+ // The single-select fields of every org Next up might pick from, merged by name, for settings [NXT-04]:
118
+ // the orgs chosen, the owners of the repos chosen and of my projects, and of the issues it last showed.
119
+ async issueFields(): Promise<IssueField[]> {
120
+ if (FIXTURE) return FIXTURE_ISSUE_FIELDS;
121
+ await this.reloadConfig().catch(() => {});
122
+ const { orgs, repos, nextUp } = this.config;
123
+ const live = this.state.live?.attention;
124
+ const shown = [...(live?.unclaimed ?? []), ...(live?.assigned ?? [])].map((issue) => issue.repo);
125
+ const owners = [...orgs, ...nextUp.orgs, ...[...repos, ...nextUp.repos, ...this.state.projectRepos, ...shown].map((repo) => repo.split("/")[0])];
126
+ const unique = [...new Map(owners.map((owner) => [owner.toLowerCase(), owner])).values()];
127
+ if (unique.length === 0) return [];
128
+ const result = await graphql<Record<string, OrgFields>>(issueFieldsQuery(unique));
129
+ const merged = new Map<string, IssueField>();
130
+ unique.forEach((org, index) => {
131
+ for (const field of result[`o${index}`]?.issueFields?.nodes ?? []) {
132
+ if (!field.name || !field.options) continue;
133
+ const known = merged.get(field.name.toLowerCase());
134
+ if (known) known.orgs.push(org);
135
+ else merged.set(field.name.toLowerCase(), { name: field.name, options: field.options.map((option) => option.name), orgs: [org] });
136
+ }
137
+ });
138
+ return [...merged.values()].sort((a, b) => a.name.localeCompare(b.name));
139
+ }
140
+
110
141
  // Replies on others' threads without a tag [ATT-17]. Only the live feed has them.
111
142
  async setFollowThreads(on: boolean): Promise<void> {
112
143
  this.config = await saveFollowThreads(on);
@@ -265,8 +296,10 @@ export class AttentionService {
265
296
  // Behind counts [UPS-07], required checks [PRS-14] and issue field option order [NXT-02].
266
297
  private async details(data: Pick<LiveResult, "mine" | "assigned" | "unclaimed">): Promise<Details> {
267
298
  const prs = data.mine.nodes.filter((pr) => pr?.headRefName && !pr.isCrossRepository);
268
- const { priority, effort } = this.config.nextUp;
269
- const needsOptions = [priority, effort].some((field) => field && !field.order);
299
+ const needsOptions = (["priority", "effort"] as const).some((role) => {
300
+ const field = nextUpField(this.config, role);
301
+ return field && !field.order;
302
+ });
270
303
  const issues = [...data.unclaimed.nodes, ...data.assigned.nodes];
271
304
  const orgs = needsOptions ? [...new Set(issues.map((issue) => issue?.repository?.nameWithOwner.split("/")[0]).filter(Boolean))] : [];
272
305
  const refs = toLookUp(data.mine.nodes.filter((pr) => pr?.repository));
package/server/setup.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { FIELD_ROLES } from "../shared/config";
1
2
  import type { ConfigStatus, CoverageCheck, CoverageKind, SetupStatus } from "../shared/setup";
2
3
  import { FIXTURE_MY_ORGS, FIXTURE_ORGS, FIXTURE_REPOS } from "./fixture";
3
4
  import { FIXTURE, graphql, runGh } from "./gh";
@@ -22,9 +23,10 @@ async function ghStatus(): Promise<SetupStatus["gh"]> {
22
23
  export async function configStatus(): Promise<ConfigStatus> {
23
24
  try {
24
25
  const { orgs, repos, nextUp, followThreads } = await loadConfig();
25
- return { error: null, orgs, repos, nextUp: { mine: nextUp.mine, orgs: nextUp.orgs, repos: nextUp.repos }, followThreads };
26
+ const fields = Object.fromEntries(FIELD_ROLES.flatMap((role) => (nextUp[role] === undefined ? [] : [[role, nextUp[role]?.field ?? null]])));
27
+ return { error: null, orgs, repos, nextUp: { mine: nextUp.mine, orgs: nextUp.orgs, repos: nextUp.repos }, fields, followThreads };
26
28
  } catch (error) {
27
- return { error: (error as Error).message, orgs: [], repos: [], nextUp: { mine: false, orgs: [], repos: [] }, followThreads: false };
29
+ return { error: (error as Error).message, orgs: [], repos: [], nextUp: { mine: false, orgs: [], repos: [] }, fields: {}, followThreads: false };
28
30
  }
29
31
  }
30
32
 
package/server/store.ts CHANGED
@@ -3,7 +3,7 @@ import { homedir } from "node:os";
3
3
  import { join } from "node:path";
4
4
  import { z } from "zod";
5
5
  import type { Attention, Item, SectionId } from "../shared/attention";
6
- import { AttentionConfig } from "../shared/config";
6
+ import { AttentionConfig, FIELD_ROLES, type FieldRole, sameField } from "../shared/config";
7
7
  import type { Pending } from "./view";
8
8
 
9
9
  // Local files in ~/.config/paseo-attention-span/ [PRIV-01].
@@ -86,6 +86,22 @@ export function saveNextUpSources(sources: Pick<AttentionConfig["nextUp"], "mine
86
86
  });
87
87
  }
88
88
 
89
+ // Which org issue fields Next up uses, from settings [NXT-04]: null turns one off, a role left out is kept as it is.
90
+ // A field kept as it was keeps its order.
91
+ export function saveNextUpFields(fields: Partial<Record<FieldRole, string | null>>): Promise<AttentionConfig> {
92
+ return updateConfig((file) => {
93
+ const nextUp = file.nextUp && typeof file.nextUp === "object" ? (file.nextUp as Record<string, unknown>) : {};
94
+ const chosen = Object.fromEntries(
95
+ FIELD_ROLES.filter((role) => fields[role] !== undefined).map((role) => {
96
+ const before = nextUp[role] as { field?: unknown } | null | undefined;
97
+ const field = fields[role]!;
98
+ return [role, field === null ? null : before && typeof before.field === "string" && sameField(before.field, field) ? { ...before, field } : { field }];
99
+ }),
100
+ );
101
+ return { ...file, nextUp: { ...nextUp, ...chosen } };
102
+ });
103
+ }
104
+
89
105
  // Whether replies on others' threads count without a tag, from settings [ATT-17].
90
106
  export function saveFollowThreads(followThreads: boolean): Promise<AttentionConfig> {
91
107
  return updateConfig((file) => ({ ...file, followThreads }));
package/shared/config.ts CHANGED
@@ -48,9 +48,11 @@ export const AttentionConfig = z.object({
48
48
  mine: z.boolean().default(false),
49
49
  orgs: z.array(z.string()).default([]),
50
50
  repos: z.array(z.string()).default([]),
51
- priority: RankedField.optional(),
52
- effort: RankedField.optional(),
53
- scope: z.object({ field: z.string() }).optional(),
51
+ // Which org issue fields rank and filter the list [NXT-02, NXT-03]. Left out, the field named after the role is used if
52
+ // the org has one; null turns it off.
53
+ priority: RankedField.nullable().optional(),
54
+ effort: RankedField.nullable().optional(),
55
+ scope: z.object({ field: z.string() }).nullable().optional(),
54
56
  })
55
57
  .default({ mine: false, orgs: [], repos: [] }),
56
58
  });
@@ -70,6 +72,23 @@ export function nextUpSources({ nextUp }: Pick<AttentionConfig, "nextUp">): Next
70
72
  ];
71
73
  }
72
74
 
75
+ // What Next up uses org issue fields for, chosen in settings [NXT-04].
76
+ export const FIELD_ROLES = ["priority", "effort", "scope"] as const;
77
+ export type FieldRole = (typeof FIELD_ROLES)[number];
78
+ // The field each role uses until I choose: one with the role's name, like "Priority".
79
+ export const DEFAULT_FIELD: Record<FieldRole, string> = { priority: "Priority", effort: "Effort", scope: "Scope" };
80
+
81
+ // The field a role uses: the chosen one, none if turned off, else the one named after it [NXT-04].
82
+ export function nextUpField({ nextUp }: Pick<AttentionConfig, "nextUp">, role: FieldRole): { field: string; order?: string[] } | undefined {
83
+ const chosen = nextUp[role];
84
+ return chosen === undefined ? { field: DEFAULT_FIELD[role] } : (chosen ?? undefined);
85
+ }
86
+
87
+ // Org issue field names compare without case, as people type them in config.json.
88
+ export function sameField(a: string | undefined, b: string | undefined): boolean {
89
+ return !!a && !!b && a.toLowerCase() === b.toLowerCase();
90
+ }
91
+
73
92
  // "owner/name" of a Paseo project with a GitHub remote, from its project key.
74
93
  export function githubRepoOf(projectKey: string | null | undefined): string | null {
75
94
  return /^remote:github\.com\/(.+)$/i.exec(projectKey ?? "")?.[1] ?? null;
package/shared/rpc.ts CHANGED
@@ -2,7 +2,7 @@ import { defineRpc } from "@getpaseo/plugin";
2
2
  import { z } from "zod";
3
3
  import type { AttentionView, ItemDetails, ReviewerChoices, Target } from "./attention";
4
4
  import { SessionKind } from "./config";
5
- import type { ConfigStatus, CoverageCheck, SetupStatus } from "./setup";
5
+ import type { ConfigStatus, CoverageCheck, IssueField, SetupStatus } from "./setup";
6
6
  import type { FeedbackInfo } from "./feedback";
7
7
  import type { ReadyProvider } from "./providers";
8
8
  import type { UpdateNotice } from "./update";
@@ -28,6 +28,11 @@ export const checkCoverage = defineRpc({ name: "config.check-coverage", input: z
28
28
  export const setCoverage = defineRpc({ name: "config.set-coverage", input: z.object({ orgs: z.array(z.string()), repos: z.array(z.string()) }), output: done });
29
29
  // Where Next up looks, chosen in settings [NXT-04]; orgs are picked from the ones I belong to.
30
30
  export const setNextUpSources = defineRpc({ name: "config.set-next-up", input: z.object({ mine: z.boolean(), orgs: z.array(z.string()), repos: z.array(z.string()) }), output: done });
31
+ // The org issue fields settings offers for Next up, and which one each role uses [NXT-04].
32
+ export const issueFields = defineRpc({ name: "config.issue-fields", input: z.object({}), output: z.custom<{ fields: IssueField[] }>() });
33
+ // Only the roles given change; one left out keeps what config.json says, including finding its field by name.
34
+ const fieldChoice = z.string().nullable().optional();
35
+ export const setNextUpFields = defineRpc({ name: "config.set-next-up-fields", input: z.object({ priority: fieldChoice, effort: fieldChoice, scope: fieldChoice }), output: done });
31
36
  // Replies on others' threads without a tag, from settings [ATT-17].
32
37
  export const setFollowThreads = defineRpc({ name: "config.set-follow-threads", input: z.object({ on: z.boolean() }), output: done });
33
38
  export const myOrgs = defineRpc({ name: "config.my-orgs", input: z.object({}), output: z.object({ orgs: z.array(z.string()) }) });
package/shared/setup.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import type { FieldRole } from "./config";
2
+
1
3
  // What getting started needs, for the setup checklist [SET-01] and the settings screen [SRC-02].
2
4
 
3
5
  export interface ConfigStatus {
@@ -7,6 +9,8 @@ export interface ConfigStatus {
7
9
  repos: string[];
8
10
  // Where Next up looks; none chosen falls back to `orgs` and `repos`, then my Paseo projects [NXT-04, NXT-08].
9
11
  nextUp: { mine: boolean; orgs: string[]; repos: string[] };
12
+ // The issue field chosen for each role, null when turned off; a role left out uses the field named after it [NXT-04].
13
+ fields: Partial<Record<FieldRole, string | null>>;
10
14
  // Replies on others' threads count without a tag [ATT-17].
11
15
  followThreads: boolean;
12
16
  }
@@ -29,3 +33,10 @@ export function blocks(status: SetupStatus): boolean {
29
33
  // An org or repo checked on GitHub before it's saved: its exact name, or why it can't be added.
30
34
  export type CoverageCheck = { name: string; error: null } | { name: null; error: string };
31
35
  export type CoverageKind = "org" | "repo";
36
+
37
+ // A single-select issue field Next up can use, merged by name across the orgs that have it [NXT-04].
38
+ export interface IssueField {
39
+ name: string;
40
+ options: string[];
41
+ orgs: string[];
42
+ }