ai-agentmanager 1.26.0 → 1.27.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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.27.0 (2026-11-07)
4
+
5
+ - **Jira on your company's own address.** With your site saved in Settings → Jira, every issue's summary and status are asked of that site, whatever address its link has (links often use the company's own domain, like `jira.company.com`, while the API answers on `company.atlassian.net`). A site that sends the API on to its Atlassian address is followed there (and only there). When Jira says it can't find an issue, the Jira list says so: usually the email in Settings isn't the one you sign in to Jira with.
6
+ - **Bring back what you set aside, and undo.** Today has a *Set aside* section listing what you skipped, marked done or removed, each with *Bring back*, and *Bring all back*. Skip, Done and Bring back offer *Undo* on their message (or press `u` in Today). The Jira and Actions lists offer *Undo* after each change too, and *Bring all back* on their Skipped, Done and Removed filters. Messages now show over an open window, so their buttons can be clicked.
7
+ - **Report a problem or idea.** In the menu (☰), *Report a problem or idea…* takes a title, the details and a screenshot: paste it (⌘V), drop an image, choose a file, or capture the screen. The report is kept on your computer (`support/` in the home folder), and GitHub opens with a new issue filled in, including the version, OS and which lists are on (no names, folders or tokens). The screenshot is put on your clipboard to paste there. Nothing is posted until you submit it on GitHub.
8
+
9
+ ## 1.26.1 (2026-11-07)
10
+
11
+ - **Jira says why it isn't working.** When your Jira site can't be used (the token isn't accepted, the site sends a sign-in page, it can't be reached), the Jira list and Today say so in words instead of just showing no summaries or statuses. Settings → Jira has a **Check Jira** button that asks the site for your open issues and says how many it found, or why it couldn't.
12
+ - **Jira Server and Data Center.** With no email, the API token is sent as a personal access token, and the older API those sites have is used when Jira Cloud's isn't there. The site address may have a port and a path (`https://jira.company.com:8443/jira`).
13
+ - **Skip, Done and Remove work on every issue in the list.** Before, an issue listed through its agent, whose request named it after other words rather than starting with its link, could fail with "not on the list".
14
+ - **↻ asks Jira again.** Refreshing the Jira list or Today fetches statuses again rather than using those from the last few minutes.
15
+
3
16
  ## 1.26.0 (2026-11-07)
4
17
 
5
18
  - **Today: what needs you, in one list.** The Today button (or `y`) gathers what the other lists know and puts the most pressing first: agents stopped at a prompt or waiting for your answer, overdue and due-today action items, issues and pull requests ready for your review, review requests, then the rest (actions due later, new Jira issues, stuck agents, follow-ups). Each says why it's there ("due today · asked by Pat · in Slack", "Blocked: staging credentials"), and the usual decision is a click or a key away: Done, Skip and Discuss for actions, Assign for new issues, Review it for a requested pull request, Open for the rest. Listen reads the top of it aloud. Lists turned off in Settings are left out. The button's count is the pressing ones.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-agentmanager",
3
- "version": "1.26.0",
3
+ "version": "1.27.0",
4
4
  "description": "Run background coding agents (Claude Code, Codex) per intent, and keep track of them from a web UI, your phone or the CLI",
5
5
  "keywords": [
6
6
  "claude",
package/public/actions.js CHANGED
@@ -95,6 +95,7 @@ export function initActions({ api, $, esc, ago, toast, openAgent, projects = ()
95
95
  <option value="">pick a project</option>
96
96
  ${list.map((p) => `<option value="${esc(p.key)}" ${p.key === project ? 'selected' : ''}>${esc(p.name ?? p.key)}</option>`).join('')}
97
97
  </select></label>
98
+ ${['skipped', 'done', 'removed'].includes(filter) && rows.length ? `<button class="small" data-act="back-all" title="Every one here back to open, undecided">Bring all ${rows.length} back</button>` : ''}
98
99
  <button class="small" data-act="refresh" title="Look again (r)">↻</button>
99
100
  ${expandButton(dialog)}
100
101
  <button class="small" data-act="close" title="Close (Esc)">Close</button>
@@ -117,14 +118,19 @@ export function initActions({ api, $, esc, ago, toast, openAgent, projects = ()
117
118
  const render = holdWhilePicking(body, draw);
118
119
  expandable(dialog, draw);
119
120
 
120
- async function set(ids, state) {
121
+ async function set(ids, state, { undoing = false } = {}) {
121
122
  if (busy) return;
122
123
  busy = true;
124
+ // What each was before, to take the change back.
125
+ const before = new Map(ids.map((id) => [id, data?.rows.find((x) => x.id === id)?.status ?? 'open']));
123
126
  try {
124
127
  const r = await api('POST', '/actions/set', { ids, state, project: project || null });
125
128
  const bad = r.failed.map((x) => x.reason).join('; ');
126
129
  const label = STATES.find(([v]) => v === state)?.[1] ?? state;
127
- toast?.(r.started.length ? `Agent ${r.started.map((x) => x.agent.name).join(', ')} started` : bad ? `Not changed: ${bad}` : state === 'open' ? 'Open again' : label, bad ? 8000 : 2500);
130
+ const msg = r.started.length ? `Agent ${r.started.map((x) => x.agent.name).join(', ')} started` : bad ? `Not changed: ${bad}` : state === 'open' ? (ids.length > 1 ? `${r.set.length} open again` : 'Open again') : label;
131
+ // An agent once started stays; anything else can be taken back.
132
+ const undo = !undoing && r.set.length && !r.started.length ? { label: 'Undo', run: () => undoTo(r.set.map((id) => [id, before.get(id)])) } : null;
133
+ toast?.(msg, bad ? 8000 : undo ? 6000 : 2500, undo);
128
134
  } catch (err) {
129
135
  toast?.(err.message, 6000);
130
136
  } finally {
@@ -133,6 +139,13 @@ export function initActions({ api, $, esc, ago, toast, openAgent, projects = ()
133
139
  load();
134
140
  }
135
141
 
142
+ /** Set each action back to what it was: [[id, status]]. */
143
+ async function undoTo(pairs) {
144
+ for (const state of new Set(pairs.map(([, st]) => st))) {
145
+ await set(pairs.filter(([, st]) => st === state).map(([id]) => id), state, { undoing: true });
146
+ }
147
+ }
148
+
136
149
  async function discuss(id) {
137
150
  try {
138
151
  const r = await api('POST', `/actions/${id}/discuss`, {});
@@ -191,6 +204,7 @@ export function initActions({ api, $, esc, ago, toast, openAgent, projects = ()
191
204
  const b = e.target.closest('[data-act]')?.dataset.act;
192
205
  if (b === 'close') return dialog.close();
193
206
  if (b === 'refresh') return load();
207
+ if (b === 'back-all') return set(data.rows.filter((r) => r.group === filter).map((r) => r.id), 'open');
194
208
  });
195
209
 
196
210
  function open() {
package/public/app.js CHANGED
@@ -21,6 +21,7 @@ import { initPlaybooks } from '/playbooks.js';
21
21
  import { initSetup } from '/setup.js';
22
22
  import { initUpdate } from '/update.js';
23
23
  import { initMenu } from '/menu.js';
24
+ import { initSupport } from '/support.js';
24
25
  import { initCode } from '/code.js';
25
26
  import { initMachine } from '/machine.js';
26
27
  import { initWatch } from '/watch.js';
@@ -136,7 +137,9 @@ function toast(msg, ms = 2600, action) {
136
137
  };
137
138
  el.append(' ', b);
138
139
  }
139
- document.body.append(el);
140
+ // Over an open window (a modal one leaves the page behind it unclickable), else on the page.
141
+ const top = [...document.querySelectorAll('dialog[open]')].filter((d) => d.matches(':modal')).at(-1);
142
+ (top ?? document.body).append(el);
140
143
  setTimeout(() => el.remove(), ms);
141
144
  }
142
145
 
@@ -158,6 +161,8 @@ initWorklog({ api, esc, toast, $ });
158
161
  initSetup({ api, esc, $ });
159
162
  const updateUi = initUpdate({ api, esc, toast, $ });
160
163
  initMenu({ api, esc, toast, $ });
164
+ const supportUi = initSupport({ api, $, esc, toast });
165
+ $('#support-btn').onclick = () => supportUi.open();
161
166
  initMachine({ api, esc, toast, $, Terminal, FitAddon });
162
167
  let sidePane = null; // the split view's right pane (set up once the terminal is)
163
168
  const codeUi = initCode({ api, esc, toast, $, agents, isOpen: () => term.kind === 'code' || Boolean(sidePane?.showing('code')) });
@@ -209,7 +214,7 @@ const standupUi = initStandup({
209
214
  needsFor: (a) => needsFor(a),
210
215
  needCard: (it, o) => needCard(it, o),
211
216
  onNeed: (e) => onNeed(e),
212
- toast: (m, ms) => toast(m, ms),
217
+ toast: (m, ms, a) => toast(m, ms, a),
213
218
  openAgent: (id) => (showTab('agents'), select(id)),
214
219
  });
215
220
  // Jira: every issue an agent works on, the ones waiting for your review first.
@@ -218,7 +223,7 @@ const issuesUi = initIssues({
218
223
  $,
219
224
  esc,
220
225
  ago,
221
- toast: (m, ms) => toast(m, ms),
226
+ toast: (m, ms, a) => toast(m, ms, a),
222
227
  openAgent: (id) => (showTab('agents'), select(id)),
223
228
  openDoc: (id, kind) => (showTab('agents'), select(id), openDoc(id, kind)),
224
229
  });
@@ -229,7 +234,7 @@ const actionsUi = initActions({
229
234
  $,
230
235
  esc,
231
236
  ago,
232
- toast: (m, ms) => toast(m, ms),
237
+ toast: (m, ms, a) => toast(m, ms, a),
233
238
  openAgent: (id) => (showTab('agents'), select(id)),
234
239
  projects: () => projectsState.map((p) => ({ key: p.shortcut, name: p.name })),
235
240
  });
@@ -252,7 +257,7 @@ const todayUi = initToday({
252
257
  $,
253
258
  esc,
254
259
  ago,
255
- toast: (m, ms) => toast(m, ms),
260
+ toast: (m, ms, a) => toast(m, ms, a),
256
261
  openAgent: (id) => (showTab('agents'), select(id)),
257
262
  showInbox: () => showTab('inbox'),
258
263
  openActions: () => actionsUi.open(),
@@ -266,7 +271,7 @@ const designsUi = initDesigns({
266
271
  $,
267
272
  esc,
268
273
  ago,
269
- toast: (m, ms) => toast(m, ms),
274
+ toast: (m, ms, a) => toast(m, ms, a),
270
275
  openAgent: (id) => (showTab('agents'), select(id)),
271
276
  openDoc: (id) => (showTab('agents'), select(id), openDoc(id, 'designdoc')),
272
277
  });
package/public/index.html CHANGED
@@ -61,6 +61,7 @@
61
61
  <div class="menu-sep"></div>
62
62
  <div class="menu-theme"><span>Theme</span><span class="seg" role="radiogroup" aria-label="Theme"><button type="button" data-theme-set="auto" title="Follow this device's setting">Auto</button><button type="button" data-theme-set="light">Light</button><button type="button" data-theme-set="dark">Dark</button></span></div>
63
63
  <div class="menu-sep"></div>
64
+ <button role="menuitem" id="support-btn" title="Tell us about a problem or an idea, with a screenshot">Report a problem or idea…</button>
64
65
  <button role="menuitem" id="keys-btn" title="Quick actions from the keyboard">Keyboard shortcuts… <kbd>?</kbd></button>
65
66
  <button role="menuitem" id="menu-about">About and updates…</button>
66
67
  </div>
@@ -836,6 +837,28 @@
836
837
  </div>
837
838
  </dialog>
838
839
 
840
+ <dialog id="support-dialog" class="support-dialog" aria-label="Report a problem or idea">
841
+ <form id="support-form" class="alerts-body">
842
+ <h2>Report a problem or idea</h2>
843
+ <div class="support-kind" role="radiogroup" aria-label="What it is">
844
+ <label class="check"><input type="radio" name="kind" value="bug" checked /> Something is wrong</label>
845
+ <label class="check"><input type="radio" name="kind" value="idea" /> An improvement</label>
846
+ </div>
847
+ <label>Title <input name="title" maxlength="200" required autocomplete="off" placeholder="In a few words" /></label>
848
+ <label>Details <textarea name="details" rows="7" maxlength="20000" required></textarea></label>
849
+ <div class="support-label">Screenshot <span class="hint">(optional)</span></div>
850
+ <div id="support-shot" class="support-shot"></div>
851
+ <p class="hint">It's kept on this computer, and GitHub opens with a new issue filled in for you to look over and submit. GitHub issues are public, so check the screenshot and the text for anything private first. Your version, OS and which lists are turned on are added; no names, folders or tokens.</p>
852
+ <p id="support-error" class="error" hidden></p>
853
+ <div class="dialog-actions">
854
+ <button type="button" data-support="close" class="ghost">Cancel</button>
855
+ <button type="submit" class="primary">Save and open on GitHub</button>
856
+ </div>
857
+ <div id="support-earlier"></div>
858
+ </form>
859
+ <div id="support-done" class="alerts-body" hidden></div>
860
+ </dialog>
861
+
839
862
  <dialog id="settings-dialog" class="settings-dialog">
840
863
  <form id="settings-form" method="dialog" class="alerts-body">
841
864
  <h2>Settings</h2>
@@ -873,12 +896,13 @@
873
896
  </fieldset>
874
897
  <fieldset class="local-only">
875
898
  <legend>Jira</legend>
876
- <p class="hint">For an agent created from a Jira link, its description shows the issue's summary. Public issues on Atlassian Cloud need nothing here; for your company's site, add it with your email and an <a href="https://id.atlassian.com/manage-profile/security/api-tokens" target="_blank" rel="noopener">API token</a>. The token is kept on this computer and sent only to that site.</p>
899
+ <p class="hint">For an agent created from a Jira link, its description shows the issue's summary. Public issues on Atlassian Cloud need nothing here; for your company's site, add it with your email and an <a href="https://id.atlassian.com/manage-profile/security/api-tokens" target="_blank" rel="noopener">API token</a> (Jira Server or Data Center: leave the email empty and use a personal access token). The token is kept on this computer and sent only to that site.</p>
877
900
  <div class="row three">
878
901
  <label>Site <input name="jiraSite" placeholder="https://yourcompany.atlassian.net" autocomplete="off" /></label>
879
902
  <label>Email <input name="jiraEmail" type="email" autocomplete="off" /></label>
880
903
  <label>API token <input name="jiraToken" type="password" autocomplete="new-password" /></label>
881
904
  </div>
905
+ <p><button type="button" class="small" data-jira-check title="Ask your Jira site for the open issues assigned to you, with the saved settings">Check Jira</button> <span class="hint" data-jira-result></span></p>
882
906
  </fieldset>
883
907
  <fieldset>
884
908
  <legend>Updates</legend>
package/public/issues.js CHANGED
@@ -77,7 +77,7 @@ export function initIssues({ api, $, esc, ago, openAgent, openDoc, toast }) {
77
77
  }
78
78
 
79
79
  function aboutIssue(r) {
80
- const missing = data?.jira?.signedIn ? 'Summary not fetched from Jira yet' : 'Summary shows once your Jira site, email and API token are in Settings → Jira';
80
+ const missing = data?.jira?.problem ? 'No summary: Jira can’t be used (see above)' : data?.jira?.signedIn ? 'Summary not fetched from Jira yet' : 'Summary shows once your Jira site, email and API token are in Settings → Jira';
81
81
  return `${r.title ? `<div class="issue-title">${esc(r.title)}</div>` : `<div class="hint issue-title">${esc(missing)}</div>`}${r.synopsis ? `<div class="issue-synopsis" title="${esc(r.synopsis)}">${esc(r.synopsis)}</div>` : ''}`;
82
82
  }
83
83
 
@@ -154,11 +154,13 @@ export function initIssues({ api, $, esc, ago, openAgent, openDoc, toast }) {
154
154
  : filter === 'removed'
155
155
  ? 'Nothing removed. Set an issue back to another action here to bring it back.'
156
156
  : 'None here.';
157
+ const backAll = ['skipped', 'done', 'removed'].includes(filter) ? setAsideShown().length : 0;
157
158
  body.innerHTML = `
158
159
  <div class="issues-head">
159
160
  <h2>Jira</h2>
160
161
  <div class="chips" role="tablist">${FILTERS.map(([k, label]) => `<button class="chip ${k === filter ? 'active' : ''}" role="tab" aria-selected="${k === filter}" data-issues-filter="${k}">${label} <span class="count">${count(k)}</span></button>`).join('')}</div>
161
162
  <span class="spacer"></span>
163
+ ${backAll ? `<button class="small" data-issues="back-all" title="Clear your action on every one here: back to undecided">Bring all ${backAll} back</button>` : ''}
162
164
  <button class="small" data-issues="copy" title="Copy this list as a Markdown table, to paste into Slack, Jira or a doc" ${rows.length ? '' : 'disabled'}>Copy</button>
163
165
  <button class="small" data-issues="refresh" title="Look again now">↻</button>
164
166
  ${expandButton(dialog)}
@@ -172,6 +174,7 @@ export function initIssues({ api, $, esc, ago, openAgent, openDoc, toast }) {
172
174
  <span class="hint">Tick the issues to start agents for; the rest stay here.</span>
173
175
  </div>`
174
176
  : ''}
177
+ ${data.jira?.problem ? `<p class="issues-problem" role="alert">Jira: ${esc(data.jira.problem)}. Summaries, statuses and the issues assigned to you need it; try <b>Check Jira</b> in Settings → Jira.</p>` : ''}
175
178
  ${rows.length
176
179
  ? `<div class="issues-scroll"><table class="issues">
177
180
  <thead><tr>${boxes ? `<th class="pick"><input type="checkbox" data-issue-pick-all ${allTicked ? 'checked' : ''} aria-label="Tick all" title="Tick all" /></th>` : ''}<th class="issue-action" title="Your action, kept across restarts and updates">Action</th><th>Issue</th><th>Jira status</th><th>Where it stands</th><th>Plan</th><th>Design</th><th>Pull request</th><th>Agent</th><th class="col-active">Active</th></tr></thead>
@@ -183,10 +186,18 @@ export function initIssues({ api, $, esc, ago, openAgent, openDoc, toast }) {
183
186
  keys.redraw();
184
187
  }
185
188
  const render = holdWhilePicking(body, draw);
189
+
190
+ /** The issues shown that you skipped, marked done or removed (not those done in Jira). */
191
+ function setAsideShown() {
192
+ const g = { skipped: 'skip', done: 'done', removed: 'remove' }[filter];
193
+ return (data?.rows ?? []).filter((r) => r.group === filter && r.action === g).map((r) => r.key);
194
+ }
186
195
  expandable(dialog, draw);
187
196
 
188
197
  /** Set your action on issues; assign starts the agents of ones not started yet. */
189
- async function setAction(keys, action) {
198
+ async function setAction(keys, action, { undoing = false } = {}) {
199
+ // What each was before, to take the change back.
200
+ const before = new Map(keys.map((k) => [k, data?.rows.find((x) => x.key === k)?.action ?? null]));
190
201
  try {
191
202
  const r = await api('POST', '/issues/action', { keys, action: action || null });
192
203
  for (const k of r.set) ticked.delete(k);
@@ -197,13 +208,22 @@ export function initIssues({ api, $, esc, ago, openAgent, openDoc, toast }) {
197
208
  return t ? `${k} (${t.length > 60 ? `${t.slice(0, 59)}…` : t})` : k;
198
209
  };
199
210
  const what = r.started.length ? `Started ${r.started.map((x) => named(x.key)).join(', ')}` : r.set.length ? `${r.set.map(named).join(', ')}: ${label}` : 'Nothing changed';
200
- toast?.(`${what}${bad ? `. Not changed: ${bad}` : ''}`, bad ? 8000 : 3000);
211
+ // An agent once started stays; anything else can be taken back.
212
+ const undo = !undoing && r.set.length && !r.started.length ? { label: 'Undo', run: () => undoTo(r.set.map((k) => [k, before.get(k)])) } : null;
213
+ toast?.(`${what}${bad ? `. Not changed: ${bad}` : ''}`, bad ? 8000 : undo ? 6000 : 3000, undo);
201
214
  } catch (err) {
202
215
  toast?.(err.message, 6000);
203
216
  }
204
217
  load();
205
218
  }
206
219
 
220
+ /** Set each issue back to what it was: [[key, action]]. */
221
+ async function undoTo(pairs) {
222
+ for (const action of new Set(pairs.map(([, a]) => a))) {
223
+ await setAction(pairs.filter(([, a]) => a === action).map(([k]) => k), action === 'assign' ? null : action, { undoing: true });
224
+ }
225
+ }
226
+
207
227
  const keys = rowKeys(dialog, {
208
228
  rows: () => [...body.querySelectorAll('tbody tr[data-row-id]')],
209
229
  filters: () => [...body.querySelectorAll('[data-issues-filter]')],
@@ -281,6 +301,7 @@ export function initIssues({ api, $, esc, ago, openAgent, openDoc, toast }) {
281
301
  if (b === 'start') return startTicked();
282
302
  if (b === 'dismiss') return setAction([...ticked], 'remove');
283
303
  if (b === 'skip') return setAction([...ticked], 'skip');
304
+ if (b === 'back-all') return setAction(setAsideShown(), null);
284
305
  if (b === 'copy') {
285
306
  try {
286
307
  const { markdown } = await api('GET', `/issues?group=${encodeURIComponent(filter)}&format=markdown`);
package/public/keys.js CHANGED
@@ -43,6 +43,7 @@ export const SHORTCUTS = [
43
43
  [['o'], 'Undecided again (Actions) or clear (Jira)', null],
44
44
  [['c'], 'Discuss it with Claude (Actions)', null],
45
45
  [['Enter'], 'Open the issue or where it was asked', null],
46
+ [['u'], 'Undo the last change (Today); or Undo on the message', null],
46
47
  [['r'], 'Look again', null],
47
48
  ]],
48
49
  ['In the standup', [
package/public/menu.js CHANGED
@@ -107,6 +107,7 @@ export function initMenu({ api, esc, toast, $ }) {
107
107
  form.jiraEmail.value = jira?.email ?? '';
108
108
  form.jiraToken.value = '';
109
109
  form.jiraToken.placeholder = jira?.hasToken ? 'saved (type to replace)' : '';
110
+ dialog.querySelector('[data-jira-result]').textContent = '';
110
111
  containers = await api('GET', '/isolation').catch(() => null);
111
112
  showContainers();
112
113
  form.claudeToken.value = '';
@@ -146,6 +147,29 @@ export function initMenu({ api, esc, toast, $ }) {
146
147
  dialog.close();
147
148
  $(`#${go.dataset.open}`).click();
148
149
  });
150
+ // Check Jira: saves what was typed, then asks the site for your open issues.
151
+ dialog.addEventListener('click', async (e) => {
152
+ const b = e.target.closest('[data-jira-check]');
153
+ if (!b) return;
154
+ const out = dialog.querySelector('[data-jira-result]');
155
+ b.disabled = true;
156
+ out.textContent = 'Asking Jira…';
157
+ try {
158
+ const typed = { site: form.jiraSite.value.trim(), email: form.jiraEmail.value.trim(), token: form.jiraToken.value.trim() || undefined };
159
+ const changed = jira && (typed.site !== (jira.site ?? '') || typed.email !== (jira.email ?? '') || typed.token);
160
+ const r = changed ? await api('PUT', '/jira', typed) : await api('GET', '/jira/check');
161
+ if (changed) {
162
+ jira = { site: r.site, email: r.email, hasToken: r.hasToken };
163
+ form.jiraToken.value = '';
164
+ form.jiraToken.placeholder = r.hasToken ? 'saved (type to replace)' : '';
165
+ }
166
+ out.textContent = r.problem ? `Not working: ${r.problem}` : `Works: ${r.assigned} open issue${r.assigned === 1 ? '' : 's'} assigned to you`;
167
+ } catch (err) {
168
+ out.textContent = err.message;
169
+ } finally {
170
+ b.disabled = false;
171
+ }
172
+ });
149
173
  form.addEventListener('submit', async (e) => {
150
174
  e.preventDefault();
151
175
  try {
@@ -159,8 +183,8 @@ export function initMenu({ api, esc, toast, $ }) {
159
183
  }
160
184
  }
161
185
  if (!remote() && jira && (form.jiraSite.value.trim() !== (jira.site ?? '') || form.jiraEmail.value.trim() !== (jira.email ?? '') || form.jiraToken.value.trim())) {
162
- await api('PUT', '/jira', { site: form.jiraSite.value.trim(), email: form.jiraEmail.value.trim(), token: form.jiraToken.value.trim() || undefined });
163
- toast('Jira saved; summaries for agents from Jira links are being fetched', 4000);
186
+ const j = await api('PUT', '/jira', { site: form.jiraSite.value.trim(), email: form.jiraEmail.value.trim(), token: form.jiraToken.value.trim() || undefined });
187
+ toast(j.problem ? `Jira saved, but it doesn't work yet: ${j.problem}` : j.assigned !== null && j.assigned !== undefined ? `Jira works: ${j.assigned} open issue${j.assigned === 1 ? '' : 's'} assigned to you` : 'Jira saved', j.problem ? 10_000 : 4000);
164
188
  }
165
189
  if (!remote() && containers?.available) {
166
190
  if (form.claudeToken.value.trim()) await api('PUT', '/isolation/token', { token: form.claudeToken.value.trim() });
package/public/style.css CHANGED
@@ -1175,6 +1175,7 @@ table.issues .dot { display: inline-block; width: 7px; height: 7px; border-radiu
1175
1175
  table.issues .dot.busy { background: var(--green); }
1176
1176
  table.issues .dot.idle { background: var(--muted); }
1177
1177
  .issues-empty { padding: 24px 4px; }
1178
+ .issues-problem { margin: 0 0 8px; padding: 6px 10px; border-left: 3px solid var(--red); color: var(--red); font-size: 13px; }
1178
1179
  @media (max-width: 640px) {
1179
1180
  .issues-dialog { width: calc(100% - 32px); padding: 12px; }
1180
1181
  table.issues .col-active { display: none; }
@@ -1305,3 +1306,18 @@ table.issues tr.kb-on td:first-child { box-shadow: inset 3px 0 0 var(--accent);
1305
1306
  .actions-table .action-meta { margin-top: 3px; }
1306
1307
  .actions-table .action-due { color: var(--yellow); font-weight: 600; }
1307
1308
  .actions-table tr.action-skip td:not(.issue-action), .actions-table tr.action-remove td:not(.issue-action), .actions-table tr.action-done td:not(.issue-action) { opacity: 0.65; }
1309
+
1310
+ /* Report a problem or idea */
1311
+ .support-dialog { width: min(640px, calc(100vw - 32px)); }
1312
+ .support-dialog .hint { margin: 0; }
1313
+ .support-kind { display: flex; gap: 20px; flex-wrap: wrap; font-size: 13px; }
1314
+ .support-kind label.check { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; width: auto; font-weight: 400; }
1315
+ .support-kind input { width: auto; margin: 0; }
1316
+ .support-dialog textarea { width: 100%; resize: vertical; font: inherit; }
1317
+ .support-label { font-size: 13px; font-weight: 500; }
1318
+ .support-shot { border: 1px dashed var(--border); border-radius: 8px; padding: 10px; font-size: 13px; }
1319
+ .support-shot.over { border-color: var(--accent, currentColor); background: color-mix(in srgb, currentColor 6%, transparent); }
1320
+ .support-img { display: block; max-width: 100%; max-height: 260px; margin: 0 auto; border-radius: 4px; }
1321
+ .support-shot-acts { display: flex; justify-content: flex-end; margin-top: 6px; }
1322
+ #support-earlier ul { margin: 6px 0; padding-left: 18px; font-size: 13px; }
1323
+ #support-earlier summary { cursor: pointer; font-size: 13px; }
@@ -0,0 +1,168 @@
1
+ // Report a problem or an idea: a title, what happened (or what would help) and a screenshot when
2
+ // one helps, by pasting, dropping, choosing a file or capturing the screen. It's kept on this
3
+ // computer, and GitHub opens with a new issue filled in; the screenshot is put on the clipboard
4
+ // to paste there. Nothing is posted until you submit it on GitHub.
5
+
6
+ const MAX_SIDE = 2400;
7
+ const HINT = {
8
+ bug: 'What happened, and what you expected. Steps help: what you clicked or typed, in order.',
9
+ idea: 'What would help, and what you would use it for.',
10
+ };
11
+
12
+ export function initSupport({ api, $, esc, toast }) {
13
+ const dialog = $('#support-dialog');
14
+ const form = $('#support-form');
15
+ const shot = $('#support-shot');
16
+ let image = null; // { blob, url }
17
+
18
+ /** Any image as a PNG no larger than MAX_SIDE on a side: what the clipboard and GitHub take. */
19
+ async function asPng(source) {
20
+ const bmp = await createImageBitmap(source);
21
+ const k = Math.min(1, MAX_SIDE / Math.max(bmp.width, bmp.height));
22
+ const c = document.createElement('canvas');
23
+ c.width = Math.round(bmp.width * k);
24
+ c.height = Math.round(bmp.height * k);
25
+ c.getContext('2d').drawImage(bmp, 0, 0, c.width, c.height);
26
+ bmp.close?.();
27
+ return new Promise((ok, no) => c.toBlob((b) => (b ? ok(b) : no(new Error("Couldn't read the image"))), 'image/png'));
28
+ }
29
+
30
+ async function setImage(source) {
31
+ try {
32
+ const blob = source ? await asPng(source) : null;
33
+ if (image) URL.revokeObjectURL(image.url);
34
+ image = blob ? { blob, url: URL.createObjectURL(blob) } : null;
35
+ } catch (e) {
36
+ toast(e.message || "Couldn't read the image", 5000);
37
+ }
38
+ drawShot();
39
+ }
40
+
41
+ function drawShot() {
42
+ const capture = navigator.mediaDevices?.getDisplayMedia ? '<button type="button" class="small" data-support="capture" title="Pick a screen, window or tab to take a picture of">Capture the screen</button>' : '';
43
+ shot.innerHTML = image
44
+ ? `<img src="${image.url}" alt="Screenshot" class="support-img" /><div class="support-shot-acts"><button type="button" class="small" data-support="remove-shot">Remove</button></div>`
45
+ : `<div class="support-drop">Paste a screenshot (⌘V), drop an image here, <label class="small-link">choose a file<input type="file" accept="image/*" data-support="file" hidden /></label>${capture ? `, or ${capture}` : ''}.</div>`;
46
+ }
47
+
48
+ /** One frame of a screen, window or tab you pick; this window steps aside while it's taken. */
49
+ async function capture() {
50
+ let stream = null;
51
+ dialog.close();
52
+ try {
53
+ stream = await navigator.mediaDevices.getDisplayMedia({ video: { displaySurface: 'browser' }, audio: false, preferCurrentTab: true, selfBrowserSurface: 'include' });
54
+ const video = document.createElement('video');
55
+ video.muted = true;
56
+ video.srcObject = stream;
57
+ await video.play();
58
+ // Let the picker's own overlay go first.
59
+ await new Promise((r) => setTimeout(r, 400));
60
+ await setImage(await createImageBitmap(video));
61
+ } catch (e) {
62
+ if (e?.name !== 'NotAllowedError') toast(`Couldn't capture: ${e.message}`, 5000);
63
+ } finally {
64
+ stream?.getTracks().forEach((t) => t.stop());
65
+ dialog.showModal();
66
+ }
67
+ }
68
+
69
+ function kind() {
70
+ return form.kind.value || 'bug';
71
+ }
72
+
73
+ async function drawEarlier() {
74
+ const box = $('#support-earlier');
75
+ try {
76
+ const { tickets } = await api('GET', '/support');
77
+ box.innerHTML = tickets.length
78
+ ? `<details><summary>Your earlier reports (${tickets.length})</summary><ul>${tickets
79
+ .map((t) => `<li><a href="${esc(t.issueUrl)}" target="_blank" rel="noopener">${esc(t.title)}</a> <span class="hint">${esc(new Date(t.at).toLocaleDateString())}${t.screenshot ? ` · <a href="/api/support/${esc(t.id)}/screenshot" target="_blank" rel="noopener">screenshot</a>` : ''}</span></li>`)
80
+ .join('')}</ul><p class="hint">Kept on this computer in ${esc(tickets[0].folder.replace(/\/[^/]+$/, ''))}.</p></details>`
81
+ : '';
82
+ } catch {
83
+ box.innerHTML = '';
84
+ }
85
+ }
86
+
87
+ function open() {
88
+ form.reset();
89
+ $('#support-error').hidden = true;
90
+ $('#support-done').hidden = true;
91
+ form.hidden = false;
92
+ setImage(null);
93
+ form.details.placeholder = HINT.bug;
94
+ dialog.showModal();
95
+ form.title.focus();
96
+ drawEarlier();
97
+ }
98
+
99
+ form.addEventListener('change', (e) => {
100
+ if (e.target.name === 'kind') form.details.placeholder = HINT[kind()];
101
+ });
102
+ dialog.addEventListener('paste', (e) => {
103
+ const f = [...(e.clipboardData?.files ?? [])].find((x) => x.type.startsWith('image/'));
104
+ if (!f) return;
105
+ e.preventDefault();
106
+ setImage(f);
107
+ });
108
+ shot.addEventListener('dragover', (e) => {
109
+ e.preventDefault();
110
+ shot.classList.add('over');
111
+ });
112
+ shot.addEventListener('dragleave', () => shot.classList.remove('over'));
113
+ shot.addEventListener('drop', (e) => {
114
+ e.preventDefault();
115
+ shot.classList.remove('over');
116
+ const f = [...(e.dataTransfer?.files ?? [])].find((x) => x.type.startsWith('image/'));
117
+ if (f) setImage(f);
118
+ });
119
+ dialog.addEventListener('change', (e) => {
120
+ if (e.target.dataset.support === 'file' && e.target.files?.[0]) setImage(e.target.files[0]);
121
+ });
122
+ dialog.addEventListener('click', (e) => {
123
+ const b = e.target.closest('[data-support]')?.dataset.support;
124
+ if (b === 'capture') capture();
125
+ else if (b === 'remove-shot') setImage(null);
126
+ else if (b === 'close') dialog.close();
127
+ });
128
+
129
+ form.addEventListener('submit', async (e) => {
130
+ e.preventDefault();
131
+ const err = $('#support-error');
132
+ err.hidden = true;
133
+ // While this click still counts as yours: the browser allows the new tab and the clipboard only then.
134
+ const tab = window.open('about:blank', '_blank');
135
+ let copied = false;
136
+ if (image && navigator.clipboard?.write && window.ClipboardItem) {
137
+ copied = await navigator.clipboard.write([new ClipboardItem({ 'image/png': image.blob })]).then(
138
+ () => true,
139
+ () => false,
140
+ );
141
+ }
142
+ try {
143
+ let t = await api('POST', '/support', { kind: kind(), title: form.title.value, details: form.details.value });
144
+ if (image) {
145
+ const res = await fetch(`/api/support/${encodeURIComponent(t.id)}/screenshot`, { method: 'PUT', headers: { 'content-type': 'image/png', 'x-agentmgr': '1' }, body: image.blob });
146
+ if (!res.ok) throw new Error((await res.json().catch(() => null))?.error ?? `The screenshot wasn't saved (${res.status})`);
147
+ t = await res.json();
148
+ }
149
+ if (tab) {
150
+ tab.opener = null;
151
+ tab.location.href = t.issueUrl;
152
+ }
153
+ form.hidden = true;
154
+ const done = $('#support-done');
155
+ done.hidden = false;
156
+ done.innerHTML = `<p><b>Saved.</b> ${tab ? 'GitHub opened in a new tab with your report filled in' : 'Open the filled-in report on GitHub'}: look it over, ${t.screenshot ? (copied ? 'paste the screenshot (⌘V) where it says, ' : 'drag the screenshot in where it says, ') : ''}then submit it there.</p>
157
+ <p><a href="${esc(t.issueUrl)}" target="_blank" rel="noopener" class="small-link">Open the report on GitHub ↗</a>${t.screenshot ? ` · <a href="/api/support/${esc(t.id)}/screenshot" target="_blank" rel="noopener" class="small-link">The screenshot</a>` : ''}</p>
158
+ <p class="hint">GitHub issues are public. You need a GitHub account to submit. A copy is kept on this computer in ${esc(t.folder)}.</p>
159
+ <div class="dialog-actions"><button type="button" data-support="close" class="primary">Done</button></div>`;
160
+ } catch (ex) {
161
+ tab?.close();
162
+ err.textContent = ex.message;
163
+ err.hidden = false;
164
+ }
165
+ });
166
+
167
+ return { open };
168
+ }
package/public/today.js CHANGED
@@ -17,12 +17,14 @@ export function initToday({ api, $, esc, ago, openAgent, showInbox, openActions,
17
17
  let loading = false;
18
18
  let again = null;
19
19
  let loadedAt = 0;
20
+ let undo = null; // { label, run }: the last change made here, to take back (u)
21
+ let asideOpen = false;
20
22
 
21
- async function load({ quiet = false } = {}) {
23
+ async function load({ quiet = false, fresh = false } = {}) {
22
24
  if (loading) return;
23
25
  loading = true;
24
26
  try {
25
- data = await api('GET', '/today');
27
+ data = await api('GET', `/today${fresh ? '?fresh=1' : ''}`);
26
28
  loadedAt = Date.now();
27
29
  } catch (e) {
28
30
  if (!quiet) toast?.(e.message, 5000);
@@ -85,10 +87,59 @@ export function initToday({ api, $, esc, ago, openAgent, showInbox, openActions,
85
87
  ${items.length
86
88
  ? `<div class="issues-scroll"><table class="issues today-table"><tbody>${items.map(row).join('')}</tbody></table></div>`
87
89
  : '<p class="hint issues-empty">Nothing needs you right now: no agent is waiting on you, nothing is due, and no review is waiting.</p>'}
88
- <p class="hint">Keys: j/k move (or click a row), Enter opens, a assign or review, d done, s skip, c discuss, r look again, f bigger.${off.length ? ` Not included (off in Settings → What you use): ${esc(off.join(', '))}.` : ''}${data.errors?.length ? ` Couldn't get: ${esc(data.errors.map((e) => e.source).join(', '))}.` : ''}</p>`;
90
+ ${asideHtml()}
91
+ <p class="hint">Keys: j/k move (or click a row), Enter opens, a assign or review, d done, s skip, c discuss, u undo, r look again, f bigger.${off.length ? ` Not included (off in Settings → What you use): ${esc(off.join(', '))}.` : ''}${data.errors?.length ? ` Couldn't get: ${esc(data.errors.map((e) => `${e.source === 'jira' ? 'Jira' : e.source} (${e.error})`).join('; '))}.` : ''}</p>`;
89
92
  keys.redraw();
90
93
  }
91
94
  const render = holdWhilePicking(body, draw);
95
+
96
+ /** What you skipped, marked done or removed: each can be brought back, or all of them. */
97
+ function asideHtml() {
98
+ const aside = data?.aside ?? [];
99
+ if (!aside.length) return '';
100
+ const rows = aside
101
+ .map((a) => `<tr data-aside-id="${esc(a.id)}"><td class="nowrap"><span class="today-label">${esc(a.label)}</span></td><td><div class="today-title">${esc(a.title)}</div>${a.at ? `<div class="hint">${esc(ago(a.at))}</div>` : ''}</td><td class="nowrap today-acts"><button class="small" data-today-back="${esc(a.id)}" title="Back on the list, undecided">Bring back</button></td></tr>`)
102
+ .join('');
103
+ return `<details class="today-aside" ${asideOpen ? 'open' : ''}><summary>Set aside: skipped, done or removed (${aside.length})</summary>
104
+ <div class="today-aside-head"><span class="hint">Brought back, an item is undecided again and shows in Today and its own list.</span><button class="small" data-today-back="all" title="Bring every one back">Bring all ${aside.length} back</button></div>
105
+ <table class="issues today-table"><tbody>${rows}</tbody></table></details>`;
106
+ }
107
+
108
+ /** Back to undecided: issues to no action, actions to open. Returns how to set them aside again. */
109
+ async function bringBack(list) {
110
+ const issues = list.filter((a) => a.kind === 'issue');
111
+ const acts = list.filter((a) => a.kind === 'action');
112
+ if (issues.length) await api('POST', '/issues/action', { keys: issues.map((a) => a.issueKey), action: null });
113
+ if (acts.length) await api('POST', '/actions/set', { ids: acts.map((a) => a.actionId), state: 'open' });
114
+ return async () => {
115
+ for (const state of new Set(list.map((a) => a.state))) {
116
+ const same = list.filter((a) => a.state === state);
117
+ const keys = same.filter((a) => a.kind === 'issue').map((a) => a.issueKey);
118
+ const ids = same.filter((a) => a.kind === 'action').map((a) => a.actionId);
119
+ if (keys.length) await api('POST', '/issues/action', { keys, action: state });
120
+ if (ids.length) await api('POST', '/actions/set', { ids, state });
121
+ }
122
+ };
123
+ }
124
+
125
+ /** Remember how to take back a change, and offer it on the toast. */
126
+ function changedWith(msg, label, run) {
127
+ undo = { label, run };
128
+ toast?.(msg, 6000, { label: 'Undo', run: takeBack });
129
+ }
130
+
131
+ async function takeBack() {
132
+ if (!undo) return toast?.('Nothing to undo', 2000);
133
+ const u = undo;
134
+ undo = null;
135
+ try {
136
+ await u.run();
137
+ toast?.(`Undone: ${u.label}`, 2500);
138
+ } catch (e) {
139
+ toast?.(e.message, 6000);
140
+ }
141
+ load();
142
+ }
92
143
  expandable(dialog, draw);
93
144
 
94
145
  const itemOf = (id) => data?.items.find((i) => i.id === id) ?? null;
@@ -124,7 +175,8 @@ export function initToday({ api, $, esc, ago, openAgent, showInbox, openActions,
124
175
  }
125
176
  if (it.kind === 'action' && ['done', 'skip'].includes(what)) {
126
177
  const r = await api('POST', '/actions/set', { ids: [it.actionId], state: what });
127
- toast?.(r.failed.length ? `Not changed: ${r.failed.map((x) => x.reason).join('; ')}` : what === 'done' ? 'Done' : 'Skipped', 2500);
178
+ if (r.failed.length) toast?.(`Not changed: ${r.failed.map((x) => x.reason).join('; ')}`, 6000);
179
+ else changedWith(what === 'done' ? 'Done' : 'Skipped', `${what === 'done' ? 'done' : 'skipped'} "${it.title}"`, () => api('POST', '/actions/set', { ids: [it.actionId], state: 'open' }));
128
180
  } else if (it.kind === 'action' && what === 'discuss') {
129
181
  const r = await api('POST', `/actions/${it.actionId}/discuss`, {});
130
182
  dialog.close();
@@ -132,7 +184,8 @@ export function initToday({ api, $, esc, ago, openAgent, showInbox, openActions,
132
184
  } else if (it.kind === 'issue-new' && ['assign', 'skip'].includes(what)) {
133
185
  const r = await api('POST', '/issues/action', { keys: [it.issueKey], action: what });
134
186
  const bad = r.failed.map((x) => x.reason).join('; ');
135
- toast?.(bad ? `Not changed: ${bad}` : r.started.length ? `Started an agent on ${it.title}` : `${it.title}: skipped`, bad ? 6000 : 3000);
187
+ if (bad || r.started.length) toast?.(bad ? `Not changed: ${bad}` : `Started an agent on ${it.title}`, bad ? 6000 : 3000);
188
+ else changedWith(`${it.title}: skipped`, `skipped ${it.issueKey}`, () => api('POST', '/issues/action', { keys: [it.issueKey], action: null }));
136
189
  } else if (it.kind === 'pr-requested' && (what === 'review' || what === 'assign')) {
137
190
  const a = await api('POST', '/reviews', { url: it.reviewUrl });
138
191
  toast?.(`Reviewer ${a.name ?? 'agent'} started`, 3000);
@@ -151,15 +204,31 @@ export function initToday({ api, $, esc, ago, openAgent, showInbox, openActions,
151
204
  d: (r) => act(itemOf(r.dataset.rowId), 'done'),
152
205
  s: (r) => act(itemOf(r.dataset.rowId), 'skip'),
153
206
  c: (r) => act(itemOf(r.dataset.rowId), 'discuss'),
154
- r: Object.assign(() => load(), { needsRow: false }),
207
+ r: Object.assign(() => load({ fresh: true }), { needsRow: false }),
208
+ u: Object.assign(() => takeBack(), { needsRow: false }),
155
209
  },
156
210
  });
157
211
 
158
- body.addEventListener('click', (e) => {
212
+ body.addEventListener('toggle', (e) => {
213
+ if (e.target.matches?.('.today-aside')) asideOpen = e.target.open;
214
+ }, true);
215
+ body.addEventListener('click', async (e) => {
216
+ const back = e.target.closest('[data-today-back]')?.dataset.todayBack;
217
+ if (back) {
218
+ const list = back === 'all' ? data?.aside ?? [] : (data?.aside ?? []).filter((a) => a.id === back);
219
+ if (!list.length) return;
220
+ try {
221
+ const again = await bringBack(list);
222
+ changedWith(list.length === 1 ? `Back on the list: ${list[0].title}` : `${list.length} back on the list`, list.length === 1 ? 'brought back' : `brought ${list.length} back`, again);
223
+ } catch (err) {
224
+ toast?.(err.message, 6000);
225
+ }
226
+ return load();
227
+ }
159
228
  const b = e.target.closest('[data-today]')?.dataset.today;
160
229
  if (!b) return;
161
230
  if (b === 'close') return dialog.close();
162
- if (b === 'refresh') return load();
231
+ if (b === 'refresh') return load({ fresh: true });
163
232
  act(itemOf(e.target.closest('tr[data-row-id]')?.dataset.rowId), b);
164
233
  });
165
234
 
package/src/issues.js CHANGED
@@ -112,6 +112,7 @@ export function issueRows(views, jira = new Map(), read = () => null, proposed =
112
112
  const j = jira.get(p.key) ?? null;
113
113
  const action = actions[p.key]?.action ?? (p.status === 'dismissed' ? 'remove' : null);
114
114
  rows.push({
115
+ actionAt: actions[p.key]?.at ?? null,
115
116
  key: p.key,
116
117
  url: p.url,
117
118
  title: j?.summary ?? mine.get(p.key)?.summary ?? p.title,
@@ -140,6 +141,7 @@ export function issueRows(views, jira = new Map(), read = () => null, proposed =
140
141
  const note = ACTION_NOTE[action] ? `${ACTION_NOTE[action]} (${where.charAt(0).toLowerCase()}${where.slice(1)})` : where;
141
142
  const design = designOf(v, read);
142
143
  rows.push({
144
+ actionAt: actions[issue.key]?.at ?? null,
143
145
  key: issue.key,
144
146
  url: issue.url,
145
147
  title: j?.summary ?? mine.get(issue.key)?.summary ?? issue.title,
@@ -164,6 +166,7 @@ export function issueRows(views, jira = new Map(), read = () => null, proposed =
164
166
  listed.add(i.key);
165
167
  const action = actions[i.key]?.action ?? null;
166
168
  rows.push({
169
+ actionAt: actions[i.key]?.at ?? null,
167
170
  key: i.key,
168
171
  url: i.url,
169
172
  title: i.summary,
@@ -282,8 +285,9 @@ export class ProposedIssues {
282
285
  let p = this.all.find((x) => x.key === key);
283
286
  let agent = this.agentFor(key);
284
287
  const mine = !p && !agent ? (this.manager.assignedNow ?? []).find((i) => i.key === key) : null;
285
- if (!p && !agent && !mine) {
286
- failed.push({ key, reason: 'not on the list' });
288
+ // Skip, done, remove and clear are kept by key, whatever listed the issue; assign needs where to start from.
289
+ if (!p && !agent && !mine && (action === 'assign' || !ISSUE_KEY.test(key))) {
290
+ failed.push({ key, reason: action === 'assign' ? "can't start an agent: no link for it (Jira didn't list it; is Settings → Jira working?)" : 'not an issue key' });
287
291
  continue;
288
292
  }
289
293
  // An issue assigned to you in Jira: assigning it makes the request from its link and summary.
@@ -319,7 +323,13 @@ export class ProposedIssues {
319
323
 
320
324
  agentFor(key) {
321
325
  const k = key.toLowerCase();
322
- return this.store.list().find((a) => a.kind === 'task' && (a.name.toLowerCase() === k || leadingJiraKey(a.intent)?.toLowerCase() === k)) ?? null;
326
+ const list = this.store.list();
327
+ return (
328
+ list.find((a) => a.kind === 'task' && (a.name.toLowerCase() === k || leadingJiraKey(a.intent)?.toLowerCase() === k)) ??
329
+ // The agent the Jira list shows on the issue: its request may name the issue later on, not lead with the link.
330
+ list.find((a) => a.kind !== 'assistant' && issueOf({ ...a, bugs: Object.values(a.bugs ?? {}) })?.key.toLowerCase() === k) ??
331
+ null
332
+ );
323
333
  }
324
334
 
325
335
  /** Propose an issue: the request starts with its link. */
package/src/jira.js CHANGED
@@ -42,7 +42,7 @@ export function saveJira({ site, email, token, clearToken = false } = {}) {
42
42
  email: email === undefined ? cur.email ?? '' : String(email).trim(),
43
43
  token: clearToken ? '' : token ? String(token).trim() : cur.token ?? '',
44
44
  };
45
- if (next.site && !/^https:\/\/[\w.-]+$/.test(next.site)) throw Object.assign(new Error('The Jira site is an https address, like https://yourcompany.atlassian.net'), { status: 400 });
45
+ if (next.site && !/^https:\/\/[\w.-]+(:\d+)?(\/[\w.~-]+)*$/.test(next.site)) throw Object.assign(new Error('The Jira site is an https address, like https://yourcompany.atlassian.net (or https://jira.yourcompany.com:8443/jira)'), { status: 400 });
46
46
  fs.mkdirSync(paths.home, { recursive: true });
47
47
  fs.writeFileSync(file(), JSON.stringify(next, null, 2) + '\n', { mode: 0o600 });
48
48
  return jiraView(loadJira());
@@ -75,18 +75,89 @@ export function wordsAfterLink(text) {
75
75
  // Statuses that mean the work is over, whatever category a workflow puts them in.
76
76
  const FINISHED = /^(closed|done|resolved|integrated|cancell?ed|won'?t (do|fix)|duplicate|rejected)$/i;
77
77
 
78
+ // Why the last call to your Jira site failed ({ at, reason }), or null when it worked: shown in
79
+ // the Jira list and Today, since an empty list alone doesn't say whether Jira was reached.
80
+ let problem = null;
81
+
82
+ /** Why your Jira site couldn't be used last time, or null. */
83
+ export const jiraProblem = () => problem;
84
+
85
+ /** Basic with the email and API token (Jira Cloud); a bearer token without an email (Server, Data Center). */
86
+ const authOf = (jira) => (jira.email ? `Basic ${Buffer.from(`${jira.email}:${jira.token}`).toString('base64')}` : `Bearer ${jira.token}`);
87
+
88
+ /** The reason in words for an answer that isn't ok, or a fetch that threw. */
89
+ function reasonOf(site, res, e) {
90
+ if (res) {
91
+ if (res.status >= 300 && res.status < 400) return `${site} sent the request on to ${res.movedTo ?? 'another address'} (a sign-in page?): put your Atlassian address (https://yourcompany.atlassian.net) in Settings → Jira`;
92
+ const why = {
93
+ 401: 'the email or API token is not accepted (Settings → Jira)',
94
+ 403: 'no permission; if you mistyped the token a few times, Jira may want you to sign in once in the browser',
95
+ 404: 'no Jira API at that address (is the site right?)',
96
+ issue404: 'no such issue, or the account in Settings can\'t see it (is the email the one you sign in to Jira with?)',
97
+ 429: 'too many requests; trying again later',
98
+ }[res.forIssue && res.status === 404 ? 'issue404' : res.status];
99
+ return `${site} answered ${res.status}${res.forIssue ? ` for ${res.forIssue}` : ''}${why ? `: ${why}` : ''}`;
100
+ }
101
+ const m = String(e?.cause?.message ?? e?.message ?? e ?? '');
102
+ if (e?.name === 'TimeoutError' || /abort|timeout/i.test(m)) return `${site} did not answer in time (VPN off?)`;
103
+ if (/redirect/i.test(m)) return `${site} sent a sign-in page instead of an answer (the site address may be wrong, or it needs single sign-on)`;
104
+ return `couldn't reach ${site}: ${m || 'network error'}`;
105
+ }
106
+
107
+ /**
108
+ * Jira Cloud's API (v3), then the older one (v2) that Jira Server and Data Center have when v3
109
+ * isn't there. Returns the response, or throws.
110
+ */
111
+ async function jiraGet(fetchImpl, site, v3, v2, init) {
112
+ const res = await follow(fetchImpl, `${site}${v3.path}`, { ...init, ...v3.init });
113
+ if (res.status !== 404 || !v2) return res;
114
+ return follow(fetchImpl, `${site}${v2.path}`, { ...init, ...v2.init });
115
+ }
116
+
117
+ /**
118
+ * A site on its own domain (jira.company.com) may send API calls on to its Atlassian Cloud
119
+ * address: followed once, to the same host or an *.atlassian.net one only, so the token never goes
120
+ * anywhere else. Any other redirect (a sign-in page) comes back as it is.
121
+ */
122
+ async function follow(fetchImpl, url, init) {
123
+ const res = await fetchImpl(url, { ...init, redirect: 'manual' });
124
+ if (!(res.status >= 300 && res.status < 400)) return res;
125
+ const where = res.headers?.get?.('location');
126
+ const to = (() => {
127
+ try {
128
+ return where ? new URL(where, url) : null;
129
+ } catch {
130
+ return null;
131
+ }
132
+ })();
133
+ if (!to || to.protocol !== 'https:' || !(to.host === new URL(url).host || /\.atlassian\.net$/.test(to.host))) return Object.assign(res, { movedTo: to?.host ?? null });
134
+ return fetchImpl(to.href, { ...init, redirect: 'manual' });
135
+ }
136
+
78
137
  /**
79
138
  * Open issues assigned to you on your Jira site (epics too): [{ key, url, summary, status,
80
- * category, type, synopsis, updated }]. Needs the site, email and API token from Settings → Jira;
81
- * null without them or when Jira can't be reached. Closed and integrated ones are left out.
139
+ * category, type, synopsis, updated }]. Needs the site and API token from Settings → Jira (and the
140
+ * email, for Jira Cloud); null without them or when Jira can't be reached (jiraProblem() says why).
141
+ * Closed and integrated ones are left out.
82
142
  */
83
143
  export async function assignedIssues({ jira = loadJira(), fetchImpl = fetch, timeoutMs = 10_000, max = 100 } = {}) {
84
- if (!jira.site || !jira.email || !jira.token) return null;
85
- const headers = { accept: 'application/json', 'content-type': 'application/json', authorization: `Basic ${Buffer.from(`${jira.email}:${jira.token}`).toString('base64')}` };
86
- const body = JSON.stringify({ jql: 'assignee = currentUser() AND statusCategory != Done ORDER BY updated DESC', fields: ['summary', 'status', 'issuetype', 'description', 'updated'], maxResults: max });
144
+ if (!jira.site || !jira.token) return null;
145
+ const headers = { accept: 'application/json', 'content-type': 'application/json', authorization: authOf(jira) };
146
+ const jql = 'assignee = currentUser() AND statusCategory != Done ORDER BY updated DESC';
147
+ const fields = ['summary', 'status', 'issuetype', 'description', 'updated'];
148
+ const q = new URLSearchParams({ jql, fields: fields.join(','), maxResults: String(max) });
87
149
  try {
88
- const res = await fetchImpl(`${jira.site}/rest/api/3/search/jql`, { method: 'POST', headers, body, redirect: 'error', signal: AbortSignal.timeout(timeoutMs) });
89
- if (!res.ok) return null;
150
+ const res = await jiraGet(
151
+ fetchImpl,
152
+ jira.site,
153
+ { path: '/rest/api/3/search/jql', init: { method: 'POST', body: JSON.stringify({ jql, fields, maxResults: max }) } },
154
+ { path: `/rest/api/2/search?${q}`, init: { method: 'GET' } },
155
+ { headers, signal: AbortSignal.timeout(timeoutMs) },
156
+ );
157
+ if (!res.ok) {
158
+ problem = { at: new Date().toISOString(), reason: reasonOf(jira.site, res) };
159
+ return null;
160
+ }
90
161
  const out = [];
91
162
  for (const i of (await res.json())?.issues ?? []) {
92
163
  const f = i?.fields ?? {};
@@ -104,8 +175,10 @@ export async function assignedIssues({ jira = loadJira(), fetchImpl = fetch, tim
104
175
  updated: typeof f.updated === 'string' ? f.updated : null,
105
176
  });
106
177
  }
178
+ problem = null;
107
179
  return out;
108
- } catch {
180
+ } catch (e) {
181
+ problem = { at: new Date().toISOString(), reason: reasonOf(jira.site, null, e) };
109
182
  return null;
110
183
  }
111
184
  }
@@ -164,21 +237,30 @@ export async function issueFields({ key, site }, { jira = loadJira(), fetchImpl
164
237
  return '';
165
238
  }
166
239
  })();
167
- const configured = jira.site && new URL(jira.site).host === host;
240
+ // With your site saved, the issue is asked of it, whatever address the link has: links often use
241
+ // the site's own domain (jira.company.com) while the API is on its Atlassian address, or the
242
+ // other way round. Without one, only public Atlassian Cloud issues are asked for, signed out.
243
+ const configured = Boolean(jira.site && jira.token);
168
244
  const allowed = configured || /\.atlassian\.net$/.test(host) || allow?.(site);
169
245
  if (!allowed) return null;
170
246
  const headers = { accept: 'application/json' };
171
- if (configured && jira.email && jira.token) headers.authorization = `Basic ${Buffer.from(`${jira.email}:${jira.token}`).toString('base64')}`;
247
+ if (configured) headers.authorization = authOf(jira);
248
+ const q = `${encodeURIComponent(key)}?fields=summary,status,description`;
172
249
  try {
173
- const res = await fetchImpl(`${site}/rest/api/3/issue/${encodeURIComponent(key)}?fields=summary,status,description`, { headers, redirect: 'error', signal: AbortSignal.timeout(timeoutMs) });
174
- if (!res.ok) return null;
250
+ // Your site as saved: it may have a path (https://host/jira) that the link's origin leaves out.
251
+ const res = await jiraGet(fetchImpl, configured ? jira.site : site, { path: `/rest/api/3/issue/${q}` }, configured ? { path: `/rest/api/2/issue/${q}` } : null, { headers, signal: AbortSignal.timeout(timeoutMs) });
252
+ if (!res.ok) {
253
+ if (configured) problem = { at: new Date().toISOString(), reason: reasonOf(jira.site, Object.assign(res, { forIssue: key })) };
254
+ return null;
255
+ }
175
256
  const f = (await res.json())?.fields ?? {};
176
257
  const summary = typeof f.summary === 'string' && f.summary.trim() ? f.summary.trim().slice(0, 300) : null;
177
258
  const status = typeof f.status?.name === 'string' ? f.status.name.slice(0, 60) : null;
178
259
  if (!summary && !status) return null;
179
260
  const synopsis = synopsisOf(f.description);
180
261
  return { summary, status, category: typeof f.status?.statusCategory?.key === 'string' ? f.status.statusCategory.key : null, ...(synopsis ? { synopsis } : {}) };
181
- } catch {
262
+ } catch (e) {
263
+ if (configured) problem = { at: new Date().toISOString(), reason: reasonOf(jira.site, null, e) };
182
264
  return null;
183
265
  }
184
266
  }
package/src/manager.js CHANGED
@@ -107,7 +107,7 @@ import { spawn } from 'node:child_process';
107
107
  import * as git from './git.js';
108
108
  import { buildMap, touchedFiles } from './codemap.js';
109
109
  import { parseDiff } from '../public/review.js';
110
- import { assignedIssues, issueFields, issueSummary, leadingIssue, loadJira, wordsAfterLink } from './jira.js';
110
+ import { assignedIssues, issueFields, issueSummary, jiraProblem, leadingIssue, loadJira, wordsAfterLink } from './jira.js';
111
111
  import { issueRows } from './issues.js';
112
112
  import { designRows } from './designs.js';
113
113
  import { reviewPath, reviewerPrompt } from './reviews.js';
@@ -869,7 +869,7 @@ export class AgentManager extends EventEmitter {
869
869
  }
870
870
  for (const [k, v] of jira) if (!v) jira.delete(k);
871
871
  const j = loadJira();
872
- return { rows: issueRows(views, jira, (id, name) => readSpecDoc(id, name)?.markdown ?? null, proposed, actions, assigned), jira: { site: j.site, signedIn: Boolean(j.site && j.email && j.token) } };
872
+ return { rows: issueRows(views, jira, (id, name) => readSpecDoc(id, name)?.markdown ?? null, proposed, actions, assigned), jira: { site: j.site, signedIn: Boolean(j.site && j.token), problem: j.site && j.token ? jiraProblem()?.reason ?? null : null } };
873
873
  }
874
874
 
875
875
  /** Every agent's design doc, for the Designs list. */
@@ -893,6 +893,7 @@ export class AgentManager extends EventEmitter {
893
893
  /** Fill in summaries still missing (after Jira settings change); returns how many it found. */
894
894
  async refreshSynopses() {
895
895
  this.jiraCache?.clear();
896
+ this.assignedAt = 0;
896
897
  let found = 0;
897
898
  for (const a of this.store.list()) {
898
899
  if (a.synopsis?.source === 'jira' || !leadingIssue(a.intent)) continue;
package/src/server.js CHANGED
@@ -26,7 +26,7 @@ import { Repeats } from './repeats.js';
26
26
  import { Updates } from './update.js';
27
27
  import { identity } from './identity.js';
28
28
  import { WorkLog, summaryMarkdown } from './worklog.js';
29
- import { todayItems, todaySpeech } from './today.js';
29
+ import { todayAside, todayItems, todaySpeech } from './today.js';
30
30
  import { Studio } from './studio.js';
31
31
  import { Memory } from './memory.js';
32
32
  import { doctor } from './doctor.js';
@@ -39,7 +39,7 @@ import { Previews, parseUrl } from './preview.js';
39
39
  import { LiveBrowser } from './livebrowser.js';
40
40
  import * as remote from './remote.js';
41
41
  import * as service from './service.js';
42
- import { jiraView, saveJira } from './jira.js';
42
+ import { assignedIssues, jiraProblem, jiraView, saveJira } from './jira.js';
43
43
  import { ProposedIssues, issuesMarkdown } from './issues.js';
44
44
  import { MyActions } from './actions.js';
45
45
  import { designsMarkdown } from './designs.js';
@@ -51,6 +51,7 @@ import { Standup } from './standup.js';
51
51
  import { Value, valueSlack } from './value.js';
52
52
  import { Store } from './store.js';
53
53
  import { about, latestRelease } from './about.js';
54
+ import { Support } from './support.js';
54
55
 
55
56
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
56
57
  const require = createRequire(import.meta.url);
@@ -78,7 +79,7 @@ function isAllowedOrigin(origin, port) {
78
79
  const PUBLIC_REMOTE_API = new Set(['POST /api/login', 'GET /api/session']);
79
80
  // Updates are not here: a signed-in device (a phone) can install the newest release too. It only
80
81
  // ever installs an official release from where this copy came from (git tag or npm) and restarts.
81
- const LOCAL_ONLY_API = /^\/api\/(remote(\/|$)|notify(\/|$)|hub(\/|$)|triggers(\/|$)|service$|jira$|isolation\/|editors$|agentkit\/connect$|agents\/[\w-]+\/open-in$|shutdown$)/;
82
+ const LOCAL_ONLY_API = /^\/api\/(remote(\/|$)|notify(\/|$)|hub(\/|$)|triggers(\/|$)|service$|jira(\/check)?$|isolation\/|editors$|agentkit\/connect$|agents\/[\w-]+\/open-in$|shutdown$)/;
82
83
  const HOOK_PATH = '/api/hooks/agents';
83
84
  const REPORT_PATH = '/api/agentkit/report';
84
85
  const NO_REPO_KINDS = new Set(['general', 'assistant']);
@@ -717,13 +718,25 @@ export async function startServer({ port = PORT, host = HOST } = {}) {
717
718
  );
718
719
  // Jira: the site and API token used to show an issue's summary for agents created from its link.
719
720
  api.get('/jira', wrap(() => jiraView()));
721
+ // Whether the saved settings work: how many open issues are yours, or why Jira can't be used.
722
+ api.get(
723
+ '/jira/check',
724
+ wrap(async () => {
725
+ const view = jiraView();
726
+ if (!view.site || !view.hasToken) return { assigned: null, problem: 'Add the site and API token first' };
727
+ const mine = await assignedIssues({ timeoutMs: 8000 });
728
+ return { assigned: mine ? mine.length : null, problem: mine ? null : jiraProblem()?.reason ?? 'Jira could not be reached' };
729
+ }),
730
+ );
720
731
  api.put(
721
732
  '/jira',
722
733
  wrap(async (req) => {
723
734
  const view = saveJira(req.body ?? {});
724
735
  // Agents already created from links get their summaries now (in the background).
725
736
  manager.refreshSynopses().catch(() => {});
726
- return view;
737
+ // Tried at once, so Settings can say whether it works: how many issues are yours, or why not.
738
+ const mine = view.site && view.hasToken ? await assignedIssues({ timeoutMs: 8000 }) : null;
739
+ return { ...view, assigned: mine ? mine.length : null, problem: view.site && view.hasToken && !mine ? jiraProblem()?.reason ?? 'Jira could not be reached' : null };
727
740
  }),
728
741
  );
729
742
  // Start at login: the login service (launchd or systemd) that brings the daemon back after a reboot.
@@ -790,8 +803,11 @@ export async function startServer({ port = PORT, host = HOST } = {}) {
790
803
  api.get('/codemap', wrap((req) => manager.codeMap(req.query.project ? String(req.query.project) : null)));
791
804
  // Issues agents work on, for the summary; ?group=you|agent|done and ?format=markdown to paste.
792
805
  api.get('/issues', wrap(async (req) => {
793
- // ?fresh=1 (the ↻ button) asks Jira again for the issues assigned to you.
794
- if (req.query.fresh === '1') manager.assignedAt = 0;
806
+ // ?fresh=1 (the ↻ button) asks Jira again: the issues assigned to you and each issue's status.
807
+ if (req.query.fresh === '1') {
808
+ manager.assignedAt = 0;
809
+ manager.jiraCache?.clear();
810
+ }
795
811
  manager.jiraOff = !featuresOf(config).jira;
796
812
  const v = await manager.issues(proposed.listed(), proposed.actions);
797
813
  const group = req.query.group ? String(req.query.group) : null;
@@ -867,8 +883,13 @@ export async function startServer({ port = PORT, host = HOST } = {}) {
867
883
  });
868
884
  // Today: what needs you, from every list, most pressing first (today.js). A list that's off or
869
885
  // can't be had right now is left out, and said so.
870
- api.get('/today', wrap(async () => {
886
+ api.get('/today', wrap(async (req) => {
871
887
  const f = featuresOf(config);
888
+ // ?fresh=1 (↻ or r) asks Jira again rather than using what was fetched in the last few minutes.
889
+ if (req.query.fresh === '1') {
890
+ manager.assignedAt = 0;
891
+ manager.jiraCache?.clear();
892
+ }
872
893
  manager.jiraOff = !f.jira;
873
894
  const errors = [];
874
895
  const got = async (name, fn) => {
@@ -881,13 +902,37 @@ export async function startServer({ port = PORT, host = HOST } = {}) {
881
902
  };
882
903
  const [inbox, issues, actions, prs] = await Promise.all([
883
904
  got('inbox', () => manager.inbox()),
884
- f.jira ? got('jira', async () => (await manager.issues(proposed.listed(), proposed.actions)).rows) : [],
905
+ f.jira
906
+ ? got('jira', async () => {
907
+ const v = await manager.issues(proposed.listed(), proposed.actions);
908
+ if (v.jira.problem) errors.push({ source: 'jira', error: v.jira.problem });
909
+ return v.rows;
910
+ })
911
+ : [],
885
912
  f.slack || f.gemini ? got('actions', () => myActions.rows()) : [],
886
913
  got('reviews', () => reviews.rows()),
887
914
  ]);
888
915
  const items = todayItems({ inbox, issues, actions, reviews: prs });
889
- return { items, speech: todaySpeech(items), features: f, errors };
916
+ return { items, aside: todayAside({ issues, actions }), speech: todaySpeech(items), features: f, errors };
890
917
  }));
918
+ // Support tickets: kept on this computer, each with a filled-in link to a new GitHub issue.
919
+ const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8'));
920
+ const support = new Support({
921
+ issuesUrl: pkg.bugs?.url ?? 'https://github.com/jdmunta/ai-agentmanager-core/issues',
922
+ about: () => ({ version: pkgVersion, features: featuresOf(config), agents: store.list().length }),
923
+ });
924
+ api.get('/support', wrap(() => ({ tickets: support.list() })));
925
+ api.post('/support', wrap((req) => support.create({ ...req.body, browser: req.headers['user-agent'] ?? null })));
926
+ // The screenshot comes as the image itself (not JSON): up to 10 MB.
927
+ api.put('/support/:id/screenshot', express.raw({ type: 'image/*', limit: '10mb' }), wrap((req) => support.addScreenshot(req.params.id, req.body, req.headers['content-type'])));
928
+ api.get('/support/:id/screenshot', (req, res) => {
929
+ try {
930
+ const { file, type } = support.screenshot(req.params.id);
931
+ res.type(type).sendFile(file);
932
+ } catch (e) {
933
+ res.status(e.status ?? 500).json({ error: e.message });
934
+ }
935
+ });
891
936
  api.get('/standup', wrap(() => standup.view()));
892
937
  api.post('/standup', wrap(async () => ({ ...standup.view(), latest: await standup.make({ reason: 'asked' }) })));
893
938
  api.put('/standup', wrap((req) => {
package/src/support.js ADDED
@@ -0,0 +1,156 @@
1
+ // Support tickets: a problem or an idea, in your words, with a screenshot when one helps. Each is
2
+ // kept on this computer (support/<id>/ in the home folder: ticket.md, ticket.json, screenshot) and
3
+ // comes with a link to a new GitHub issue filled in with it. Nothing is sent from here: you look
4
+ // it over on GitHub, paste the screenshot (it's put on your clipboard) and submit it yourself.
5
+ import fs from 'node:fs';
6
+ import os from 'node:os';
7
+ import path from 'node:path';
8
+ import { paths } from './config.js';
9
+
10
+ export const KINDS = { bug: 'Something is wrong', idea: 'An improvement' };
11
+ const LABELS = { bug: 'bug', idea: 'enhancement' };
12
+ const IMAGE = { 'image/png': 'png', 'image/jpeg': 'jpg', 'image/webp': 'webp' };
13
+ const MAX_KEPT = 100;
14
+ // GitHub refuses very long new-issue links; the body is cut to fit.
15
+ const MAX_URL = 7500;
16
+ const err = (status, message) => Object.assign(new Error(message), { status });
17
+
18
+ const dir = () => path.join(paths.home, 'support');
19
+ const ticketDir = (id) => {
20
+ if (!/^[\w-]{1,80}$/.test(String(id))) throw err(400, 'No such ticket');
21
+ return path.join(dir(), id);
22
+ };
23
+
24
+ /** What's useful to know about this setup, without names, folders, hosts or tokens. */
25
+ export function aboutThis({ version, browser = null, features = {}, agents = null } = {}) {
26
+ return {
27
+ version: version ?? null,
28
+ os: `${os.type()} ${os.release()} (${process.arch})`,
29
+ node: process.version,
30
+ ...(browser ? { browser: String(browser).slice(0, 200) } : {}),
31
+ on: Object.entries(features)
32
+ .filter(([, v]) => v)
33
+ .map(([k]) => k),
34
+ ...(agents === null ? {} : { agents }),
35
+ };
36
+ }
37
+
38
+ /** The issue's text, in Markdown. */
39
+ export function ticketMarkdown(t) {
40
+ const info = t.info ?? {};
41
+ const lines = [
42
+ t.details.trim(),
43
+ '',
44
+ ...(t.screenshot ? ['**Screenshot:** _(pasted below)_', '', ''] : []),
45
+ '<details><summary>About this setup</summary>',
46
+ '',
47
+ `- AI Agent Manager ${info.version ?? '?'}`,
48
+ `- ${info.os ?? '?'}, Node ${info.node ?? '?'}`,
49
+ ...(info.browser ? [`- Browser: ${info.browser}`] : []),
50
+ ...(info.on?.length ? [`- Turned on: ${info.on.join(', ')}`] : []),
51
+ ...(info.agents !== undefined ? [`- Agents: ${info.agents}`] : []),
52
+ '',
53
+ '</details>',
54
+ ];
55
+ return lines.join('\n');
56
+ }
57
+
58
+ /** A link to a new issue on `issuesUrl` (…/issues) with the title, text and label filled in. */
59
+ export function issueLink(issuesUrl, t) {
60
+ const base = `${String(issuesUrl).replace(/\/+$/, '')}/new`;
61
+ const q = (body) => `${base}?${new URLSearchParams({ title: t.title, labels: LABELS[t.kind] ?? '', body })}`;
62
+ let link = q(ticketMarkdown(t));
63
+ // Cut the details, not the setup: the whole text stays in the ticket on this computer.
64
+ for (let room = t.details.length; link.length > MAX_URL && room > 0; ) {
65
+ room = Math.floor(room * Math.min(0.9, MAX_URL / link.length));
66
+ link = q(ticketMarkdown({ ...t, details: `${t.details.slice(0, room).trim()}\n\n_(cut short to fit the link; paste the rest)_` }));
67
+ }
68
+ return link;
69
+ }
70
+
71
+ export class Support {
72
+ constructor({ issuesUrl, about = () => ({}) }) {
73
+ this.issuesUrl = issuesUrl;
74
+ this.about = about;
75
+ }
76
+
77
+ /** Keep a ticket: { kind, title, details, browser } → the ticket with its id and issue link. */
78
+ create({ kind = 'bug', title, details, browser = null } = {}) {
79
+ if (!KINDS[kind]) throw err(400, `The kind is ${Object.keys(KINDS).join(' or ')}`);
80
+ title = String(title ?? '').trim().replace(/\s+/g, ' ').slice(0, 200);
81
+ details = String(details ?? '').trim().slice(0, 20_000);
82
+ if (!title) throw err(400, 'Give it a short title');
83
+ if (!details) throw err(400, 'Say what happened, or what would help');
84
+ const at = new Date();
85
+ const id = `${at.toISOString().slice(0, 19).replace(/[-:T]/g, '')}-${Math.random().toString(36).slice(2, 6)}`;
86
+ const t = { id, kind, title, details, at: at.toISOString(), screenshot: null, info: aboutThis({ ...this.about(), browser }) };
87
+ fs.mkdirSync(ticketDir(id), { recursive: true });
88
+ this.write(t);
89
+ this.prune();
90
+ return this.view(t);
91
+ }
92
+
93
+ /** The screenshot for a ticket (PNG, JPEG or WebP, as sent). */
94
+ addScreenshot(id, buf, type) {
95
+ const t = this.read(id);
96
+ const ext = IMAGE[String(type ?? '').split(';')[0]];
97
+ if (!ext) throw err(415, 'The screenshot is a PNG, JPEG or WebP image');
98
+ if (!buf?.length) throw err(400, 'The screenshot is empty');
99
+ const name = `screenshot.${ext}`;
100
+ fs.writeFileSync(path.join(ticketDir(id), name), buf);
101
+ t.screenshot = name;
102
+ this.write(t);
103
+ return this.view(t);
104
+ }
105
+
106
+ /** The screenshot's file: { file, type }. */
107
+ screenshot(id) {
108
+ const t = this.read(id);
109
+ if (!t.screenshot) throw err(404, 'No screenshot');
110
+ const ext = t.screenshot.split('.').pop();
111
+ return { file: path.join(ticketDir(id), t.screenshot), type: Object.keys(IMAGE).find((k) => IMAGE[k] === ext) };
112
+ }
113
+
114
+ /** Your tickets, newest first. */
115
+ list(max = 20) {
116
+ let ids = [];
117
+ try {
118
+ ids = fs.readdirSync(dir()).sort().reverse();
119
+ } catch {}
120
+ const out = [];
121
+ for (const id of ids) {
122
+ if (out.length >= max) break;
123
+ try {
124
+ out.push(this.view(this.read(id)));
125
+ } catch {}
126
+ }
127
+ return out;
128
+ }
129
+
130
+ view(t) {
131
+ return { ...t, folder: ticketDir(t.id), issueUrl: issueLink(this.issuesUrl, t) };
132
+ }
133
+
134
+ read(id) {
135
+ const file = path.join(ticketDir(id), 'ticket.json');
136
+ try {
137
+ return JSON.parse(fs.readFileSync(file, 'utf8'));
138
+ } catch {
139
+ throw err(404, 'No such ticket');
140
+ }
141
+ }
142
+
143
+ write(t) {
144
+ fs.writeFileSync(path.join(ticketDir(t.id), 'ticket.json'), JSON.stringify(t, null, 2) + '\n');
145
+ fs.writeFileSync(path.join(ticketDir(t.id), 'ticket.md'), `# ${t.title}\n\n_${KINDS[t.kind]} · ${t.at}_\n\n${ticketMarkdown(t)}\n${t.screenshot ? `\n![Screenshot](${t.screenshot})\n` : ''}`);
146
+ }
147
+
148
+ /** The oldest go when there are many. */
149
+ prune() {
150
+ let ids = [];
151
+ try {
152
+ ids = fs.readdirSync(dir()).sort();
153
+ } catch {}
154
+ for (const id of ids.slice(0, Math.max(0, ids.length - MAX_KEPT))) fs.rmSync(ticketDir(id), { recursive: true, force: true });
155
+ }
156
+ }
package/src/today.js CHANGED
@@ -112,3 +112,22 @@ export function todaySpeech(items, max = 8) {
112
112
  items.slice(0, max).forEach((it, i) => parts.push(`${i + 1}. ${it.label}. ${say(it.title)} ${say(it.why)}`));
113
113
  return parts;
114
114
  }
115
+
116
+ const ASIDE = { skip: 'Skipped', done: 'Done', remove: 'Removed' };
117
+
118
+ /**
119
+ * What you set aside from Today's lists (skipped, done, removed), newest first, so any of it can be
120
+ * brought back: [{ id, kind: 'issue' | 'action', state, label, title, at, issueKey?, actionId? }].
121
+ */
122
+ export function todayAside({ issues = [], actions = [], max = 50 } = {}) {
123
+ const out = [];
124
+ for (const r of issues) {
125
+ if (!ASIDE[r.action]) continue;
126
+ out.push({ id: `issue:${r.key}`, kind: 'issue', state: r.action, label: ASIDE[r.action], title: r.title ? `${r.key}: ${r.title}` : r.key, at: r.actionAt ?? r.updatedAt ?? null, issueKey: r.key });
127
+ }
128
+ for (const a of actions) {
129
+ if (!ASIDE[a.status]) continue;
130
+ out.push({ id: `action:${a.id}`, kind: 'action', state: a.status, label: ASIDE[a.status], title: a.text, at: a.updatedAt ?? null, actionId: a.id });
131
+ }
132
+ return out.sort((x, y) => String(y.at ?? '').localeCompare(String(x.at ?? ''))).slice(0, max);
133
+ }