ai-agentmanager 1.26.1 → 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 +6 -0
- package/package.json +1 -1
- package/public/actions.js +16 -2
- package/public/app.js +11 -6
- package/public/index.html +23 -0
- package/public/issues.js +22 -2
- package/public/keys.js +1 -0
- package/public/style.css +15 -0
- package/public/support.js +168 -0
- package/public/today.js +73 -4
- package/src/issues.js +3 -0
- package/src/jira.js +34 -10
- package/src/server.js +21 -2
- package/src/support.js +156 -0
- package/src/today.js +19 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
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
|
+
|
|
3
9
|
## 1.26.1 (2026-11-07)
|
|
4
10
|
|
|
5
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.
|
package/package.json
CHANGED
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
|
-
|
|
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
|
-
|
|
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>
|
package/public/issues.js
CHANGED
|
@@ -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)}
|
|
@@ -184,10 +186,18 @@ export function initIssues({ api, $, esc, ago, openAgent, openDoc, toast }) {
|
|
|
184
186
|
keys.redraw();
|
|
185
187
|
}
|
|
186
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
|
+
}
|
|
187
195
|
expandable(dialog, draw);
|
|
188
196
|
|
|
189
197
|
/** Set your action on issues; assign starts the agents of ones not started yet. */
|
|
190
|
-
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]));
|
|
191
201
|
try {
|
|
192
202
|
const r = await api('POST', '/issues/action', { keys, action: action || null });
|
|
193
203
|
for (const k of r.set) ticked.delete(k);
|
|
@@ -198,13 +208,22 @@ export function initIssues({ api, $, esc, ago, openAgent, openDoc, toast }) {
|
|
|
198
208
|
return t ? `${k} (${t.length > 60 ? `${t.slice(0, 59)}…` : t})` : k;
|
|
199
209
|
};
|
|
200
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';
|
|
201
|
-
|
|
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);
|
|
202
214
|
} catch (err) {
|
|
203
215
|
toast?.(err.message, 6000);
|
|
204
216
|
}
|
|
205
217
|
load();
|
|
206
218
|
}
|
|
207
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
|
+
|
|
208
227
|
const keys = rowKeys(dialog, {
|
|
209
228
|
rows: () => [...body.querySelectorAll('tbody tr[data-row-id]')],
|
|
210
229
|
filters: () => [...body.querySelectorAll('[data-issues-filter]')],
|
|
@@ -282,6 +301,7 @@ export function initIssues({ api, $, esc, ago, openAgent, openDoc, toast }) {
|
|
|
282
301
|
if (b === 'start') return startTicked();
|
|
283
302
|
if (b === 'dismiss') return setAction([...ticked], 'remove');
|
|
284
303
|
if (b === 'skip') return setAction([...ticked], 'skip');
|
|
304
|
+
if (b === 'back-all') return setAction(setAsideShown(), null);
|
|
285
305
|
if (b === 'copy') {
|
|
286
306
|
try {
|
|
287
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/style.css
CHANGED
|
@@ -1306,3 +1306,18 @@ table.issues tr.kb-on td:first-child { box-shadow: inset 3px 0 0 var(--accent);
|
|
|
1306
1306
|
.actions-table .action-meta { margin-top: 3px; }
|
|
1307
1307
|
.actions-table .action-due { color: var(--yellow); font-weight: 600; }
|
|
1308
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,6 +17,8 @@ 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
23
|
async function load({ quiet = false, fresh = false } = {}) {
|
|
22
24
|
if (loading) return;
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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}` :
|
|
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);
|
|
@@ -152,10 +205,26 @@ export function initToday({ api, $, esc, ago, openAgent, showInbox, openActions,
|
|
|
152
205
|
s: (r) => act(itemOf(r.dataset.rowId), 'skip'),
|
|
153
206
|
c: (r) => act(itemOf(r.dataset.rowId), 'discuss'),
|
|
154
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('
|
|
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();
|
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,
|
package/src/jira.js
CHANGED
|
@@ -88,13 +88,15 @@ const authOf = (jira) => (jira.email ? `Basic ${Buffer.from(`${jira.email}:${jir
|
|
|
88
88
|
/** The reason in words for an answer that isn't ok, or a fetch that threw. */
|
|
89
89
|
function reasonOf(site, res, e) {
|
|
90
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`;
|
|
91
92
|
const why = {
|
|
92
93
|
401: 'the email or API token is not accepted (Settings → Jira)',
|
|
93
94
|
403: 'no permission; if you mistyped the token a few times, Jira may want you to sign in once in the browser',
|
|
94
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?)',
|
|
95
97
|
429: 'too many requests; trying again later',
|
|
96
|
-
}[res.status];
|
|
97
|
-
return `${site} answered ${res.status}${why ? `: ${why}` : ''}`;
|
|
98
|
+
}[res.forIssue && res.status === 404 ? 'issue404' : res.status];
|
|
99
|
+
return `${site} answered ${res.status}${res.forIssue ? ` for ${res.forIssue}` : ''}${why ? `: ${why}` : ''}`;
|
|
98
100
|
}
|
|
99
101
|
const m = String(e?.cause?.message ?? e?.message ?? e ?? '');
|
|
100
102
|
if (e?.name === 'TimeoutError' || /abort|timeout/i.test(m)) return `${site} did not answer in time (VPN off?)`;
|
|
@@ -107,9 +109,29 @@ function reasonOf(site, res, e) {
|
|
|
107
109
|
* isn't there. Returns the response, or throws.
|
|
108
110
|
*/
|
|
109
111
|
async function jiraGet(fetchImpl, site, v3, v2, init) {
|
|
110
|
-
const res = await fetchImpl
|
|
112
|
+
const res = await follow(fetchImpl, `${site}${v3.path}`, { ...init, ...v3.init });
|
|
111
113
|
if (res.status !== 404 || !v2) return res;
|
|
112
|
-
return fetchImpl
|
|
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' });
|
|
113
135
|
}
|
|
114
136
|
|
|
115
137
|
/**
|
|
@@ -130,7 +152,7 @@ export async function assignedIssues({ jira = loadJira(), fetchImpl = fetch, tim
|
|
|
130
152
|
jira.site,
|
|
131
153
|
{ path: '/rest/api/3/search/jql', init: { method: 'POST', body: JSON.stringify({ jql, fields, maxResults: max }) } },
|
|
132
154
|
{ path: `/rest/api/2/search?${q}`, init: { method: 'GET' } },
|
|
133
|
-
{ headers,
|
|
155
|
+
{ headers, signal: AbortSignal.timeout(timeoutMs) },
|
|
134
156
|
);
|
|
135
157
|
if (!res.ok) {
|
|
136
158
|
problem = { at: new Date().toISOString(), reason: reasonOf(jira.site, res) };
|
|
@@ -215,18 +237,20 @@ export async function issueFields({ key, site }, { jira = loadJira(), fetchImpl
|
|
|
215
237
|
return '';
|
|
216
238
|
}
|
|
217
239
|
})();
|
|
218
|
-
|
|
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);
|
|
219
244
|
const allowed = configured || /\.atlassian\.net$/.test(host) || allow?.(site);
|
|
220
245
|
if (!allowed) return null;
|
|
221
246
|
const headers = { accept: 'application/json' };
|
|
222
|
-
if (configured
|
|
247
|
+
if (configured) headers.authorization = authOf(jira);
|
|
223
248
|
const q = `${encodeURIComponent(key)}?fields=summary,status,description`;
|
|
224
249
|
try {
|
|
225
250
|
// Your site as saved: it may have a path (https://host/jira) that the link's origin leaves out.
|
|
226
|
-
const res = await jiraGet(fetchImpl, configured ? jira.site : site, { path: `/rest/api/3/issue/${q}` }, configured ? { path: `/rest/api/2/issue/${q}` } : null, { headers,
|
|
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) });
|
|
227
252
|
if (!res.ok) {
|
|
228
|
-
|
|
229
|
-
if (configured && res.status !== 404) problem = { at: new Date().toISOString(), reason: reasonOf(jira.site, res) };
|
|
253
|
+
if (configured) problem = { at: new Date().toISOString(), reason: reasonOf(jira.site, Object.assign(res, { forIssue: key })) };
|
|
230
254
|
return null;
|
|
231
255
|
}
|
|
232
256
|
const f = (await res.json())?.fields ?? {};
|
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';
|
|
@@ -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);
|
|
@@ -912,8 +913,26 @@ export async function startServer({ port = PORT, host = HOST } = {}) {
|
|
|
912
913
|
got('reviews', () => reviews.rows()),
|
|
913
914
|
]);
|
|
914
915
|
const items = todayItems({ inbox, issues, actions, reviews: prs });
|
|
915
|
-
return { items, speech: todaySpeech(items), features: f, errors };
|
|
916
|
+
return { items, aside: todayAside({ issues, actions }), speech: todaySpeech(items), features: f, errors };
|
|
916
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
|
+
});
|
|
917
936
|
api.get('/standup', wrap(() => standup.view()));
|
|
918
937
|
api.post('/standup', wrap(async () => ({ ...standup.view(), latest: await standup.make({ reason: 'asked' }) })));
|
|
919
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\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
|
+
}
|