create-heresay 0.2.30 → 0.2.32

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-heresay",
3
- "version": "0.2.30",
3
+ "version": "0.2.32",
4
4
  "description": "Set up your own Heresay: in-app feedback that every report gets a hearing. Creates a Firebase project in your Google account and deploys the dashboard, API and SDK to it.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/release/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.30
1
+ 0.2.32
@@ -6,6 +6,8 @@
6
6
  import { createHash, randomBytes, timingSafeEqual } from 'node:crypto';
7
7
  import { CLAIM_TTL_MS, LIMITS, PLATFORMS, REPORT_TYPES, isPlatform, isReportType, toReporterView, } from './types.js';
8
8
  import { notify } from './notifications.js';
9
+ import { parseFixRef, stampFix } from './duplicates.js';
10
+ import { withdraw } from './withdraw.js';
9
11
  const json = (status, body) => ({ status, body });
10
12
  const str = (v, max) => {
11
13
  if (typeof v !== 'string')
@@ -179,6 +181,30 @@ export async function agent(p, req, deps, body, prompt, createProject, toReporte
179
181
  }
180
182
  if (p[0] === 'findings')
181
183
  return findings(p, req, deps, body, token, repoName, apps, now);
184
+ // A release went out: every fix from this repo's apps without a version ships in it.
185
+ if (p[0] === 'released' && p.length === 1 && req.method === 'POST') {
186
+ const fx = parseFixRef({ version: body.version });
187
+ if (fx.error || !fx.ref.version)
188
+ return json(400, { error: fx.error ?? 'say which version was released, e.g. 1.4' });
189
+ const want = str(body.app, 100);
190
+ const targets = want ? apps.filter((a) => a.id === want || a.name.toLowerCase() === want.toLowerCase()) : apps;
191
+ if (!targets.length)
192
+ return json(400, { error: `this repo is not connected to an app called "${want}"` });
193
+ const stamped = [];
194
+ for (const app of targets) {
195
+ for (const t of await deps.store.listTasks(app.id)) {
196
+ if ((t.repo ?? null) !== null && t.repo !== repoName)
197
+ continue;
198
+ const r = await deps.store.getReport(app.id, t.report_id);
199
+ if (r?.status !== 'fixed' || r.fix_ref?.version)
200
+ continue;
201
+ await stampFix(app, r.id, { version: fx.ref.version, released_at: new Date(now).toISOString() }, deps);
202
+ stamped.push({ app: app.name, id: r.id });
203
+ }
204
+ }
205
+ deps.log('api.release_stamped', { repo: repoName, version: fx.ref.version, n: stamped.length });
206
+ return json(200, { version: fx.ref.version, stamped });
207
+ }
182
208
  if (p[0] !== 'briefs')
183
209
  return json(404, { error: 'not found' });
184
210
  if (p.length === 1 && req.method === 'GET') {
@@ -279,7 +305,10 @@ export async function agent(p, req, deps, body, prompt, createProject, toReporte
279
305
  return json(400, { error: 'write a note for the person who reported it: what changed, in their words' });
280
306
  if (takenByOther(found.task))
281
307
  return json(409, { error: `in progress in ${found.task.claim.repo}` });
282
- const res = await toReporter(app, found.task.id, note, me);
308
+ const fx = parseFixRef(body);
309
+ if (fx.error)
310
+ return json(400, { error: fx.error });
311
+ const res = await toReporter(app, found.task.id, note, me, fx.ref);
283
312
  if (res.status === 200) {
284
313
  await deps.store.updateTask(app.id, found.task.id, (cur) => ({ ...addNote(cur, `Fixed: ${note}`, 'note'), claim: null }));
285
314
  }
@@ -342,6 +371,14 @@ async function findings(p, req, deps, body, token, repoName, apps, now) {
342
371
  out.sort((a, b) => b.created_at.localeCompare(a.created_at));
343
372
  return json(200, { repo: repoName, findings: out.slice(0, 100) });
344
373
  }
374
+ if (p.length === 3 && p[2] === 'withdraw' && req.method === 'POST') {
375
+ for (const app of apps) {
376
+ if (!(await deps.store.getReport(app.id, p[1])))
377
+ continue;
378
+ return withdraw(app, p[1], { kind: 'agent', by: repoName }, body.reason, (d) => d === device, deps);
379
+ }
380
+ return json(404, { error: 'no such finding from this repo' });
381
+ }
345
382
  if (p.length !== 1 || req.method !== 'POST')
346
383
  return json(404, { error: 'not found' });
347
384
  const want = str(body.app, 100);
@@ -13,6 +13,7 @@
13
13
  import { createHash } from 'node:crypto';
14
14
  import { OPEN_CORS, baseUrl, chatCaller, signInFirst } from './oauth.js';
15
15
  import { notify } from './notifications.js';
16
+ import { withdraw } from './withdraw.js';
16
17
  import { LIMITS, REPORT_TYPES, isReportType } from './types.js';
17
18
  const PROTOCOLS = ['2025-06-18', '2025-03-26', '2024-11-05'];
18
19
  const json = (status, body, headers) => ({ status, body, headers: { ...OPEN_CORS, ...headers } });
@@ -80,6 +81,21 @@ const TOOLS = [
80
81
  },
81
82
  annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
82
83
  },
84
+ {
85
+ name: 'withdraw_request',
86
+ title: 'Take back a Heresay request',
87
+ description: 'Withdraws a request this team member sent, while it is still open. It isn\'t deleted: the team sees it under Withdrawn, with the reason. Accepted requests can\'t be withdrawn.',
88
+ inputSchema: {
89
+ type: 'object',
90
+ properties: {
91
+ id: { type: 'string', description: 'The request id, from my_requests' },
92
+ reason: { type: 'string', maxLength: LIMITS.reasonMax, description: 'Why, in a sentence. Optional.' },
93
+ },
94
+ required: ['id'],
95
+ additionalProperties: false,
96
+ },
97
+ annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false },
98
+ },
83
99
  {
84
100
  name: 'my_requests',
85
101
  title: 'My Heresay requests',
@@ -160,6 +176,8 @@ async function one(m, member, via, req, deps) {
160
176
  return rpcResult(msg.id, await draftRequest(args, member, via, deps));
161
177
  if (name === 'send_draft')
162
178
  return rpcResult(msg.id, await sendDraft(args, member, req, deps));
179
+ if (name === 'withdraw_request')
180
+ return rpcResult(msg.id, await withdrawRequest(args, member, deps));
163
181
  if (name === 'my_requests')
164
182
  return rpcResult(msg.id, await myRequests(args, member, req, deps));
165
183
  return rpcError(msg.id, -32602, `Unknown tool: ${String(name)}`);
@@ -285,8 +303,25 @@ async function myRequests(a, member, req, deps) {
285
303
  }
286
304
  }
287
305
  rows.sort((x, y) => String(y.sent_at).localeCompare(String(x.sent_at)));
288
- const line = (r) => `- ${r.app} · ${r.type} · ${r.status}${r.status === 'declined' && r.decline_reason ? ` (why: ${r.decline_reason})` : ''}`
306
+ const line = (r) => `- ${r.id} · ${r.app} · ${r.type} · ${r.status}${r.status === 'declined' && r.decline_reason ? ` (why: ${r.decline_reason})` : ''}`
289
307
  + `${r.status === 'fixed' && r.fix_note ? ` (${r.fix_note})` : ''}: ${String(r.text).slice(0, 140)}`;
290
308
  return result(rows.length ? rows.slice(0, 50).map(line).join('\n') : 'Nothing sent from a chat app yet.', { requests: rows.slice(0, 50) });
291
309
  }
310
+ /** Find one of this member's requests across the apps and take it back. */
311
+ async function withdrawRequest(a, member, deps) {
312
+ const id = str(a.id, 64);
313
+ if (!id)
314
+ throw new ToolError('Say which request: its id, from my_requests.');
315
+ const device = chatDevice(member.email);
316
+ for (const p of await deps.store.listProjects()) {
317
+ const r = await deps.store.getReport(p.id, id);
318
+ if (!r)
319
+ continue;
320
+ const res = await withdraw(p, id, { kind: 'member', by: member.email }, a.reason, (d) => d === device, deps);
321
+ if (res.status !== 200)
322
+ throw new ToolError(String(res.body.error ?? 'Couldn\'t withdraw it.'));
323
+ return result(`Withdrawn from ${p.name}. It stays on the team's dashboard under Withdrawn${a.reason ? ', with your reason' : ''}.`, { id, app: p.name, status: 'withdrawn' });
324
+ }
325
+ throw new ToolError('No request with that id was sent by you.');
326
+ }
292
327
  //# sourceMappingURL=chat.js.map
@@ -103,4 +103,40 @@ export async function follow(project, primary_id, from, to, patch, deps) {
103
103
  }
104
104
  return n;
105
105
  }
106
+ /** Set (or add to) the proof of a fix on a report and everything merged into it. */
107
+ export async function stampFix(project, report_id, ref, deps) {
108
+ const all = [await deps.store.getReport(project.id, report_id), ...await duplicatesOf(project, report_id, deps)].filter((r) => !!r);
109
+ for (const r of all) {
110
+ const cur = r.fix_ref ?? { pr: null, commit: null, version: null, released_at: null };
111
+ const next = { pr: ref.pr ?? cur.pr, commit: ref.commit ?? cur.commit, version: ref.version ?? cur.version, released_at: ref.released_at ?? cur.released_at };
112
+ await deps.store.updateReport(r.project_id, r.id, { fix_ref: next, updated_at: new Date(deps.now()).toISOString() });
113
+ }
114
+ }
115
+ const VERSION = /^[\w.+-]{1,40}$/;
116
+ /** A PR as an http(s) URL, a commit as 7 to 40 hex, a version as up to 40 plain characters. */
117
+ export function parseFixRef(b) {
118
+ const ref = {};
119
+ if (b.pr != null && b.pr !== '') {
120
+ try {
121
+ const u = new URL(String(b.pr));
122
+ if (u.protocol !== 'https:' && u.protocol !== 'http:')
123
+ throw 0;
124
+ ref.pr = u.href.slice(0, 300);
125
+ }
126
+ catch {
127
+ return { ref, error: 'pr must be a link to the pull request' };
128
+ }
129
+ }
130
+ if (b.commit != null && b.commit !== '') {
131
+ if (!/^[0-9a-f]{7,40}$/i.test(String(b.commit)))
132
+ return { ref, error: 'commit must be a git hash' };
133
+ ref.commit = String(b.commit).toLowerCase();
134
+ }
135
+ if (b.version != null && b.version !== '') {
136
+ if (!VERSION.test(String(b.version).trim()))
137
+ return { ref, error: 'version must be like 1.4 or 2.0.1-beta' };
138
+ ref.version = String(b.version).trim();
139
+ }
140
+ return { ref };
141
+ }
106
142
  //# sourceMappingURL=duplicates.js.map
@@ -3,7 +3,8 @@ import { agent, normaliseRepo, reposFor, tokens } from './agent.js';
3
3
  import { parseTrail, trailLines } from './trail.js';
4
4
  import { OPEN_CORS, approve, authorizationServer, authorize, connections, describeAsk, protectedResource, register, token } from './oauth.js';
5
5
  import { mcp } from './chat.js';
6
- import { alsoReported, duplicatesOf, follow, merge, unmerge } from './duplicates.js';
6
+ import { withdraw } from './withdraw.js';
7
+ import { alsoReported, duplicatesOf, follow, merge, parseFixRef, stampFix, unmerge } from './duplicates.js';
7
8
  import { notificationSettings, notify } from './notifications.js';
8
9
  import { LIMITS, PLATFORMS, REPORT_ORDER, REPORT_TYPES, isFramework, isPlatform, isReportType, isSignIn, toReporterView, } from './types.js';
9
10
  /**
@@ -186,6 +187,8 @@ async function route(req, deps) {
186
187
  return submit(req, deps);
187
188
  if (p[0] === 'reports' && p[1] === 'mine' && req.method === 'POST')
188
189
  return mine(req, deps);
190
+ if (p[0] === 'reports' && p[1] === 'withdraw' && req.method === 'POST')
191
+ return withdrawMine(req, deps);
189
192
  if (p[0] === 'reports' && req.method === 'OPTIONS')
190
193
  return preflight(req);
191
194
  // Chat apps (ChatGPT and other MCP clients): OAuth with the member's own sign-in, then MCP.
@@ -201,11 +204,13 @@ async function route(req, deps) {
201
204
  return token(req, deps);
202
205
  // Coding agents, with a per-repo token instead of a person's sign-in.
203
206
  if (p[0] === 'agent') {
204
- return agent(p.slice(1), req, deps, parseBody(req.body), agentPrompt, (by, body) => createProject({ email: by, role: 'member', added_at: '', added_by: null }, { ...req, body }, deps), async (project, id, note, by) => {
207
+ return agent(p.slice(1), req, deps, parseBody(req.body), agentPrompt, (by, body) => createProject({ email: by, role: 'member', added_at: '', added_by: null }, { ...req, body }, deps), async (project, id, note, by, ref) => {
205
208
  const updated_at = new Date(deps.now()).toISOString();
206
209
  const result = await deps.store.move(project.id, id, 'accepted', 'fixed', { fix_note: note, triaged_by: by, updated_at });
207
210
  if (result.ok) {
208
211
  await follow(project, id, 'accepted', 'fixed', { fix_note: note, triaged_by: by, updated_at }, deps);
212
+ if (ref && (ref.pr || ref.commit || ref.version))
213
+ await stampFix(project, id, ref, deps);
209
214
  await notify('fixed', project, id, deps);
210
215
  }
211
216
  return transitionRes(result);
@@ -273,6 +278,18 @@ async function route(req, deps) {
273
278
  }
274
279
  if (p[2] === 'reports' && p[3] && p[4] === 'merge' && req.method === 'POST')
275
280
  return merge(project, p[3], parseBody(req.body), member, deps);
281
+ if (p[2] === 'reports' && p[3] && p[4] === 'fix-ref' && req.method === 'POST') {
282
+ const r = await deps.store.getReport(project.id, p[3]);
283
+ if (!r)
284
+ return json(404, { error: 'no such report' });
285
+ if (r.status !== 'fixed')
286
+ return json(409, { error: 'only a fixed report has a fix to link' });
287
+ const fx = parseFixRef(parseBody(req.body));
288
+ if (fx.error)
289
+ return json(400, { error: fx.error });
290
+ await stampFix(project, r.id, { ...fx.ref, ...(fx.ref.version ? { released_at: new Date(deps.now()).toISOString() } : {}) }, deps);
291
+ return json(200, { report: await deps.store.getReport(project.id, r.id) });
292
+ }
276
293
  if (p[2] === 'reports' && p[3] && p[4] === 'unmerge' && req.method === 'POST')
277
294
  return unmerge(project, p[3], member, deps);
278
295
  if (p[2] === 'reports' && p[3] && req.method === 'POST') {
@@ -442,6 +459,29 @@ async function mine(req, deps) {
442
459
  rs.sort((a, b) => b.created_at.localeCompare(a.created_at));
443
460
  return json(200, { reports: rs.map(toReporterView) }, headers);
444
461
  }
462
+ /**
463
+ * POST /v1/reports/withdraw { key, device_id, report_id, reason? }: the reporter takes back one of
464
+ * their own open reports. Origin-checked like every SDK call, limited like reading them, and the
465
+ * device id must be the one that sent it.
466
+ */
467
+ async function withdrawMine(req, deps) {
468
+ const body = parseBody(req.body);
469
+ const got = await publicProject(req, body.key, deps);
470
+ if ('status' in got)
471
+ return got;
472
+ const { project, headers } = got;
473
+ if (!validDeviceId(body.device_id))
474
+ return json(400, { error: 'bad device_id' }, headers);
475
+ const now = deps.now();
476
+ const start = Math.floor(now / MINE_LIMIT.windowMs) * MINE_LIMIT.windowMs;
477
+ if (!(await deps.store.hit(`mine:${sha(req.ip)}:${start}`, MINE_LIMIT.limit, start + MINE_LIMIT.windowMs))) {
478
+ return json(429, { error: 'too many requests, try again later' }, headers);
479
+ }
480
+ const device = body.device_id;
481
+ const res = await withdraw(project, String(body.report_id ?? ''), { kind: 'reporter', by: 'the reporter' }, body.reason, (d) => d === device, deps);
482
+ const r = res.body.report;
483
+ return { ...res, body: r ? { report: toReporterView(r) } : res.body, headers };
484
+ }
445
485
  /** The SDK posts text/plain to avoid a preflight, so the body may arrive as a string. */
446
486
  function parseBody(b) {
447
487
  if (typeof b === 'string') {
@@ -589,6 +629,7 @@ async function triage(project, report_id, action, uid, req, deps) {
589
629
  const body = parseBody(req.body);
590
630
  const at = new Date(deps.now()).toISOString();
591
631
  let t;
632
+ let fixRefLater = null;
592
633
  if (action === 'accept') {
593
634
  const report = await deps.store.getReport(project.id, report_id);
594
635
  if (!report)
@@ -627,7 +668,12 @@ async function triage(project, report_id, action, uid, req, deps) {
627
668
  }
628
669
  else if (action === 'fixed') {
629
670
  // Optional from the dashboard; when given, the reporter reads it next to "Fixed".
671
+ const fx = parseFixRef(body);
672
+ if (fx.error)
673
+ return json(400, { error: fx.error });
630
674
  t = await deps.store.move(project.id, report_id, 'accepted', 'fixed', { fix_note: str(body.note, LIMITS.reasonMax), triaged_by: uid, updated_at: at });
675
+ if (t.ok && (fx.ref.pr || fx.ref.commit || fx.ref.version))
676
+ fixRefLater = fx.ref;
631
677
  }
632
678
  else {
633
679
  return json(404, { error: 'not found' });
@@ -641,6 +687,12 @@ async function triage(project, report_id, action, uid, req, deps) {
641
687
  await follow(project, report_id, 'open', 'declined', { decline_reason: t.report.decline_reason ?? undefined, triaged_by: uid, updated_at: at }, deps);
642
688
  if (action === 'fixed')
643
689
  await follow(project, report_id, 'accepted', 'fixed', { fix_note: t.report.fix_note ?? null, triaged_by: uid, updated_at: at }, deps);
690
+ if (fixRefLater) {
691
+ await stampFix(project, report_id, fixRefLater, deps);
692
+ const r2 = await deps.store.getReport(project.id, report_id);
693
+ if (r2)
694
+ t = { ok: true, report: r2 };
695
+ }
644
696
  }
645
697
  if (t.ok && (action === 'accept' || action === 'fixed')) {
646
698
  await notify(action === 'accept' ? 'accepted' : 'fixed', project, report_id, deps);
@@ -16,8 +16,8 @@ export const isSignIn = (v) => v === 'yes' || v === 'no';
16
16
  /** A claim nobody has touched for this long is dropped, so a crashed agent can't block a brief. */
17
17
  export const CLAIM_TTL_MS = 24 * 3600_000;
18
18
  export const toReporterView = (r) => ({
19
- id: r.id, type: r.type, text: r.text, status: r.status,
20
- decline_reason: r.decline_reason, fix_note: r.fix_note ?? null,
19
+ id: r.id, type: r.type, text: r.text, status: r.status, withdrawn_reason: r.withdrawal?.reason ?? null,
20
+ decline_reason: r.decline_reason, fix_note: r.fix_note ?? null, fix_version: r.fix_ref?.version ?? null,
21
21
  created_at: r.created_at, updated_at: r.updated_at,
22
22
  });
23
23
  export const LIMITS = {
@@ -1,3 +1,3 @@
1
1
  /** The Heresay release. Bumped by the release script; the CLI and /v1/health report it. */
2
- export const VERSION = '0.2.30';
2
+ export const VERSION = '0.2.32';
3
3
  //# sourceMappingURL=version.js.map
@@ -0,0 +1,29 @@
1
+ import { duplicatesOf } from './duplicates.js';
2
+ import { LIMITS } from './types.js';
3
+ const json = (status, body) => ({ status, body });
4
+ export async function withdraw(project, id, by, reason, owns, deps) {
5
+ const r = await deps.store.getReport(project.id, id);
6
+ // Not yours and not there look the same, so a device can't probe other reports.
7
+ if (!r || !owns(r.device_id))
8
+ return json(404, { error: 'no such report' });
9
+ if (r.status === 'withdrawn')
10
+ return json(200, { report: r, already: true });
11
+ if (r.status !== 'open') {
12
+ return json(409, { error: r.status === 'accepted'
13
+ ? 'This has been accepted and work may have started, so it can\'t be taken back now. Tell the team instead.'
14
+ : `This is already ${r.status}.`, status: r.status });
15
+ }
16
+ const at = new Date(deps.now()).toISOString();
17
+ const why = typeof reason === 'string' && reason.trim() ? reason.trim().slice(0, LIMITS.reasonMax) : null;
18
+ const t = await deps.store.move(project.id, id, 'open', 'withdrawn', { triaged_by: by.by, updated_at: at });
19
+ if (!t.ok)
20
+ return json(409, { error: 'it changed just now; look again' });
21
+ const withdrawal = { ...by, at, reason: why };
22
+ await deps.store.updateReport(project.id, id, { withdrawal });
23
+ // Reports merged into it stand on their own again: their reporters still want an answer.
24
+ for (const d of await duplicatesOf(project, id, deps))
25
+ await deps.store.updateReport(d.project_id, d.id, { duplicate_of: null });
26
+ deps.log('api.report_withdrawn', { project_id: project.id, report_id: id, kind: by.kind });
27
+ return json(200, { report: { ...t.report, withdrawal } });
28
+ }
29
+ //# sourceMappingURL=withdraw.js.map
@@ -485,3 +485,14 @@ a.platform:hover { border-color:var(--acc); box-shadow:0 0 0 3px var(--mist); }
485
485
  .report .dups li .link { margin-left:6px; }
486
486
  .report .suggest { margin-top:8px; padding:8px 10px; border-radius:8px; background:#fff7ed; color:#7c2d12; font-size:13px; }
487
487
  .report .dups .link, .report .suggest .link { border:0; background:none; padding:0; font:inherit; color:var(--deep, #0b5e57); text-decoration:underline; cursor:pointer; }
488
+
489
+ /* fixes: PR, commit, version */
490
+ .report .fix-line { display:flex; flex-wrap:wrap; align-items:center; gap:8px; margin-top:8px; font-size:13px; }
491
+ .report .fix-line code { font:12px var(--mono, ui-monospace, monospace); padding:1px 6px; border-radius:5px; background:rgba(127,127,127,.12); }
492
+ .report .fix-line input { max-width:140px; }
493
+ .report .fix-line .link { border:0; background:none; padding:0; font:inherit; color:var(--deep, #0b5e57); text-decoration:underline; cursor:pointer; }
494
+ .pill.version-pill { background:#dcfce7; color:#166534; }
495
+ .fix-ref input { flex:1; min-width:160px; }
496
+
497
+ .status.s-withdrawn { background:rgba(127,127,127,.14); color:var(--mute); }
498
+ .report .reason.withdrawn { color:var(--mute); }
@@ -7,7 +7,7 @@
7
7
 
8
8
  var $ = function (id) { return document.getElementById(id); };
9
9
  var TYPE_LABEL = { broken: 'Broken', confusing: 'Confusing', improvement: 'Could be better', idea: 'Idea' };
10
- var STATUS_LABEL = { open: 'Open', accepted: 'Accepted', fixed: 'Fixed', declined: 'Declined' };
10
+ var STATUS_LABEL = { open: 'Open', accepted: 'Accepted', fixed: 'Fixed', declined: 'Declined', withdrawn: 'Withdrawn' };
11
11
  var SDK_URL = location.origin + '/sdk/v1.js';
12
12
  var me = null, projects = [], timer = null;
13
13
 
@@ -1374,7 +1374,7 @@
1374
1374
  function drawFilters(here) {
1375
1375
  here = here || reports.filter(function (r) { return where === 'all' || r.project_id === where; });
1376
1376
  filters.textContent = '';
1377
- ['open', 'accepted', 'fixed', 'declined', 'all'].forEach(function (f) {
1377
+ ['open', 'accepted', 'fixed', 'declined', 'withdrawn', 'all'].forEach(function (f) {
1378
1378
  var n = f === 'all' ? here.length : here.filter(function (r) { return r.status === f; }).length;
1379
1379
  filters.appendChild(el('button', {
1380
1380
  'aria-pressed': String(filter === f),
@@ -1571,11 +1571,18 @@
1571
1571
  function fixedForm() {
1572
1572
  actions.textContent = '';
1573
1573
  var note = el('textarea', { placeholder: 'What changed, in their words. The person who sent this will read it. Optional.', 'aria-label': 'Note for the reporter' });
1574
+ var pr = el('input', { type: 'url', placeholder: 'Pull request link (optional)', 'aria-label': 'Pull request link' });
1575
+ var version = el('input', { type: 'text', placeholder: 'Ships in version (optional)', 'aria-label': 'Ships in version', maxlength: '40' });
1574
1576
  var go = el('button', { class: 'btn primary', type: 'button', text: 'Mark fixed', onclick: function (e) {
1575
- act('fixed', note.value.trim() ? { note: note.value } : undefined, e.currentTarget);
1577
+ var body = {};
1578
+ if (note.value.trim()) body.note = note.value;
1579
+ if (pr.value.trim()) body.pr = pr.value.trim();
1580
+ if (version.value.trim()) body.version = version.value.trim();
1581
+ act('fixed', Object.keys(body).length ? body : undefined, e.currentTarget);
1576
1582
  } });
1577
1583
  submitOnCmdEnter(note, go);
1578
1584
  actions.appendChild(note);
1585
+ actions.appendChild(el('div', { class: 'row tight fix-ref' }, [pr, version]));
1579
1586
  actions.appendChild(go);
1580
1587
  actions.appendChild(el('button', { class: 'btn ghost', type: 'button', text: 'Cancel', onclick: buttons }));
1581
1588
  actions.appendChild(err);
@@ -1653,6 +1660,34 @@
1653
1660
  actions.appendChild(err);
1654
1661
  }
1655
1662
 
1663
+ /** Where the fix is: its PR and commit for the team, the version reporters see. A version can be set later. */
1664
+ function fixRefLine() {
1665
+ var f = r.fix_ref || {};
1666
+ var line = el('div', { class: 'fix-line' });
1667
+ function draw() {
1668
+ line.textContent = '';
1669
+ if (f.version) line.appendChild(el('span', { class: 'pill version-pill', text: 'Fixed in ' + f.version }));
1670
+ if (f.pr) line.appendChild(el('a', { href: f.pr, target: '_blank', rel: 'noopener noreferrer', text: (/\/pull\/(\d+)/.exec(f.pr) || [])[1] ? 'PR #' + /\/pull\/(\d+)/.exec(f.pr)[1] : 'Pull request' }));
1671
+ if (f.commit) line.appendChild(el('code', { text: f.commit.slice(0, 7) }));
1672
+ if (!f.version) line.appendChild(el('button', { class: 'link', type: 'button', text: 'Set the version it ships in', onclick: ask }));
1673
+ }
1674
+ function ask() {
1675
+ line.textContent = '';
1676
+ var v = el('input', { type: 'text', placeholder: 'e.g. 1.4', 'aria-label': 'Version', maxlength: '40' });
1677
+ var save = el('button', { class: 'btn primary', type: 'button', text: 'Save', onclick: function () {
1678
+ api('POST', '/projects/' + r.project_id + '/reports/' + r.id + '/fix-ref', { version: v.value.trim() })
1679
+ .then(function (b) { f = b.report.fix_ref || f; draw(); toast('They’ll see “Fixed in ' + f.version + '”.'); })
1680
+ .catch(function (x) { toast(x.message); });
1681
+ } });
1682
+ submitOnCmdEnter(v, save);
1683
+ line.appendChild(v); line.appendChild(save);
1684
+ line.appendChild(el('button', { class: 'btn ghost', type: 'button', text: 'Cancel', onclick: draw }));
1685
+ v.focus();
1686
+ }
1687
+ draw();
1688
+ return line;
1689
+ }
1690
+
1656
1691
  var status = el('span', { class: 'status s-' + r.status, text: STATUS_LABEL[r.status] });
1657
1692
  card = el('article', { class: 'report t-' + r.type }, [
1658
1693
  el('div', { class: 'meta' }, [
@@ -1686,13 +1721,16 @@
1686
1721
  suggest,
1687
1722
  trailView(r.trail),
1688
1723
  r.decline_reason ? el('div', { class: 'reason', text: 'Declined: ' + r.decline_reason }) : null,
1724
+ r.withdrawal ? el('div', { class: 'reason withdrawn', text: 'Withdrawn by ' + ({ reporter: 'the person who sent it', member: r.withdrawal.by, agent: 'the agent in ' + r.withdrawal.by }[r.withdrawal.kind] || r.withdrawal.by)
1725
+ + ' on ' + new Date(r.withdrawal.at).toLocaleString() + (r.withdrawal.reason ? ': ' + r.withdrawal.reason : '') }) : null,
1689
1726
  r.fix_note ? el('div', { class: 'reason', text: 'Told them: ' + r.fix_note }) : null,
1727
+ r.status === 'fixed' ? fixRefLine() : null,
1690
1728
  r.status === 'accepted' && brief ? el('div', { class: 'brief-line' }, [
1691
1729
  brief.claimed_by ? el('b', { text: 'In progress in ' + brief.claimed_by }) : document.createTextNode(brief.repo ? 'Waiting for an agent in ' + brief.repo : 'Waiting for an agent in any connected repo'),
1692
1730
  ]) : null,
1693
1731
  brief && brief.notes.length ? el('details', { class: 'notes' }, [el('summary', { text: brief.notes.length + (brief.notes.length === 1 ? ' note' : ' notes') + ' from agents' })]
1694
1732
  .concat(brief.notes.map(function (n) { return el('p', {}, [el('span', { class: 'mute', text: n.by.replace(/^agent:/, '') + ' · ' + new Date(n.at).toLocaleString() + ': ' }), n.text]); }))) : null,
1695
- r.status === 'fixed' || r.status === 'declined' ? null : actions,
1733
+ r.status === 'fixed' || r.status === 'declined' || r.status === 'withdrawn' ? null : actions,
1696
1734
  ]);
1697
1735
  return card;
1698
1736
  }
@@ -41,5 +41,9 @@ accepts it. `my_findings` shows what happened to them.
41
41
 
42
42
  ## 6. Done
43
43
 
44
- When the fix is merged or ready to merge, `mark_fixed(id, note)`. The reporter reads the note
45
- in the app next to "Fixed", so write it for them: see `write-note`.
44
+ When the fix is merged or ready to merge, `mark_fixed(id, note, pr, commit, version)`. The
45
+ reporter reads the note in the app next to "Fixed", so write it for them: see `write-note`. Link
46
+ the PR and commit; the team sees them on the report. If you know the app version it ships in,
47
+ pass it: reporters see "Fixed in 1.4" and, on an older version, a nudge to update. If not,
48
+ `mark_released(version)` (or `npx heresay released 1.4`) stamps it on every unversioned fix when
49
+ the release goes out.
@@ -97,7 +97,8 @@
97
97
  improvement: ['Could be better', 'It works, but it could be better'],
98
98
  idea: ['Idea', 'Something that does not exist yet'],
99
99
  },
100
- status: { open: 'Waiting for the developer', accepted: 'Accepted, being worked on', fixed: 'Fixed', declined: 'Declined' },
100
+ status: { open: 'Waiting for the developer', accepted: 'Accepted, being worked on', fixed: 'Fixed', declined: 'Declined', withdrawn: 'You took this back' },
101
+ takeBack: 'Take back', takeBackAsk: 'Take this back? It isn’t deleted: the team sees you withdrew it.', takeBackWhy: 'Why? (optional)', takeBackYes: 'Take it back', keep: 'Keep it', yourWhy: 'Your reason: ',
101
102
  optional: '(optional)', yourName: 'Your name', email: 'Email',
102
103
  emailHint: 'Only if you are happy for the team to reply to you.',
103
104
  setup: 'About your setup', setupHint: 'Sent with every report, so you only say it once.',
@@ -117,6 +118,7 @@
117
118
  seeTrail: 'See it', alsoSent: 'Also sent: ',
118
119
  trail: { page: ['page', 'pages'], click: ['click', 'clicks'], request: ['failed request', 'failed requests'], error: ['error', 'errors'], warn: ['warning', 'warnings'], state: ['device event', 'device events'] },
119
120
  nudgeStuckTitle: 'Stuck on something?', nudgeStuckBody: 'If something here isn’t clear, tell the team. A real person reads it.', nudgeAria: 'Offer to report a problem', nudgeTitle: 'Something not working?', nudgeBody: 'Tell the team what happened. A real person reads it.', nudgeYes: 'Tell the team', nudgeNo: 'Not now',
121
+ fixedIn: 'Fixed in version {v}.', updateTo: 'Update to {v} to get it.',
120
122
  sentTo: 'Sent to this app’s team', powered: 'Powered by Heresay',
121
123
  },
122
124
  fr: {
@@ -135,7 +137,8 @@
135
137
  improvement: ['Pourrait être mieux', 'Ça marche, mais ça pourrait être mieux'],
136
138
  idea: ['Idée', 'Quelque chose qui n’existe pas encore'],
137
139
  },
138
- status: { open: 'En attente de l’équipe', accepted: 'Accepté, en cours', fixed: 'Corrigé', declined: 'Refusé' },
140
+ status: { open: 'En attente de l’équipe', accepted: 'Accepté, en cours', fixed: 'Corrigé', declined: 'Refusé', withdrawn: 'Vous l’avez retiré' },
141
+ takeBack: 'Retirer', takeBackAsk: 'Retirer ce signalement ? Il n’est pas supprimé : l’équipe voit que vous l’avez retiré.', takeBackWhy: 'Pourquoi ? (facultatif)', takeBackYes: 'Le retirer', keep: 'Le garder', yourWhy: 'Votre raison : ',
139
142
  optional: '(facultatif)', yourName: 'Votre nom', email: 'E-mail',
140
143
  emailHint: 'Seulement si vous acceptez que l’équipe vous réponde.',
141
144
  setup: 'Votre configuration', setupHint: 'Envoyé avec chaque signalement, pour ne le dire qu’une fois.',
@@ -155,6 +158,7 @@
155
158
  seeTrail: 'Voir', alsoSent: 'Aussi envoyé : ',
156
159
  trail: { page: ['page', 'pages'], click: ['clic', 'clics'], request: ['requête échouée', 'requêtes échouées'], error: ['erreur', 'erreurs'], warn: ['avertissement', 'avertissements'], state: ['événement de l’appareil', 'événements de l’appareil'] },
157
160
  nudgeStuckTitle: 'Bloqué quelque part ?', nudgeStuckBody: 'Si quelque chose n’est pas clair ici, dites-le à l’équipe. Une vraie personne le lit.', nudgeAria: 'Proposition de signaler un problème', nudgeTitle: 'Quelque chose ne marche pas ?', nudgeBody: 'Dites à l’équipe ce qui s’est passé. Une vraie personne le lit.', nudgeYes: 'Signaler', nudgeNo: 'Pas maintenant',
161
+ fixedIn: 'Corrigé dans la version {v}.', updateTo: 'Passez à la {v} pour en profiter.',
158
162
  sentTo: 'Envoyé à l’équipe de cette app', powered: 'Propulsé par Heresay',
159
163
  },
160
164
  ta: {
@@ -173,7 +177,8 @@
173
177
  improvement: ['இன்னும் சிறப்பாக்கலாம்', 'வேலை செய்கிறது, ஆனால் மேம்படுத்தலாம்'],
174
178
  idea: ['யோசனை', 'இன்னும் இல்லாத ஒன்று'],
175
179
  },
176
- status: { open: 'டெவலப்பருக்காகக் காத்திருக்கிறது', accepted: 'ஏற்கப்பட்டது, வேலை நடக்கிறது', fixed: 'சரிசெய்யப்பட்டது', declined: 'நிராகரிக்கப்பட்டது' },
180
+ status: { open: 'டெவலப்பருக்காகக் காத்திருக்கிறது', accepted: 'ஏற்கப்பட்டது, வேலை நடக்கிறது', fixed: 'சரிசெய்யப்பட்டது', declined: 'நிராகரிக்கப்பட்டது', withdrawn: 'நீங்கள் திரும்பப் பெற்றீர்கள்' },
181
+ takeBack: 'திரும்பப் பெறு', takeBackAsk: 'இதைத் திரும்பப் பெறவா? இது நீக்கப்படாது: நீங்கள் திரும்பப் பெற்றதைக் குழு பார்க்கும்.', takeBackWhy: 'ஏன்? (விருப்பத்தேர்வு)', takeBackYes: 'திரும்பப் பெறு', keep: 'வைத்திரு', yourWhy: 'உங்கள் காரணம்: ',
177
182
  optional: '(விருப்பத்தேர்வு)', yourName: 'உங்கள் பெயர்', email: 'மின்னஞ்சல்',
178
183
  emailHint: 'குழு உங்களுக்குப் பதில் அனுப்பலாம் என்றால் மட்டும்.',
179
184
  setup: 'உங்கள் அமைப்பு பற்றி', setupHint: 'ஒவ்வொரு புகாருடனும் அனுப்பப்படும், எனவே ஒருமுறை சொன்னால் போதும்.',
@@ -193,6 +198,7 @@
193
198
  seeTrail: 'பார்', alsoSent: 'இவையும் அனுப்பப்படும்: ',
194
199
  trail: { page: ['பக்கம்', 'பக்கங்கள்'], click: ['கிளிக்', 'கிளிக்குகள்'], request: ['தோல்வியடைந்த கோரிக்கை', 'தோல்வியடைந்த கோரிக்கைகள்'], error: ['பிழை', 'பிழைகள்'], warn: ['எச்சரிக்கை', 'எச்சரிக்கைகள்'], state: ['சாதன நிகழ்வு', 'சாதன நிகழ்வுகள்'] },
195
200
  nudgeStuckTitle: 'எங்காவது சிக்கிக்கொண்டீர்களா?', nudgeStuckBody: 'இங்கே ஏதாவது புரியவில்லை என்றால், குழுவிடம் சொல்லுங்கள். ஒருவர் அதைப் படிப்பார்.', nudgeAria: 'சிக்கலைத் தெரிவிக்க ஒரு அழைப்பு', nudgeTitle: 'ஏதாவது வேலை செய்யவில்லையா?', nudgeBody: 'என்ன நடந்தது என்று குழுவிடம் சொல்லுங்கள். ஒருவர் அதைப் படிப்பார்.', nudgeYes: 'குழுவிடம் சொல்', nudgeNo: 'இப்போது வேண்டாம்',
201
+ fixedIn: 'பதிப்பு {v} இல் சரிசெய்யப்பட்டது.', updateTo: 'இதைப் பெற {v} க்குப் புதுப்பிக்கவும்.',
196
202
  sentTo: 'இந்த ஆப்பின் குழுவுக்கு அனுப்பப்படும்', powered: 'Heresay மூலம் இயங்குகிறது',
197
203
  },
198
204
  hi: {
@@ -211,7 +217,8 @@
211
217
  improvement: ['बेहतर हो सकता है', 'काम करता है, पर बेहतर हो सकता है'],
212
218
  idea: ['सुझाव', 'कुछ ऐसा जो अभी नहीं है'],
213
219
  },
214
- status: { open: 'डेवलपर का इंतज़ार', accepted: 'स्वीकार, इस पर काम चल रहा है', fixed: 'ठीक हो गया', declined: 'अस्वीकार' },
220
+ status: { open: 'डेवलपर का इंतज़ार', accepted: 'स्वीकार, इस पर काम चल रहा है', fixed: 'ठीक हो गया', declined: 'अस्वीकार', withdrawn: 'आपने इसे वापस ले लिया' },
221
+ takeBack: 'वापस लें', takeBackAsk: 'इसे वापस लें? यह हटाया नहीं जाएगा: टीम देखेगी कि आपने इसे वापस लिया।', takeBackWhy: 'क्यों? (वैकल्पिक)', takeBackYes: 'वापस लें', keep: 'रहने दें', yourWhy: 'आपकी वजह: ',
215
222
  optional: '(वैकल्पिक)', yourName: 'आपका नाम', email: 'ईमेल',
216
223
  emailHint: 'सिर्फ़ तब, जब आप चाहते हैं कि टीम आपको जवाब दे।',
217
224
  setup: 'आपके सेटअप के बारे में', setupHint: 'हर रिपोर्ट के साथ भेजा जाता है, ताकि आपको एक ही बार बताना पड़े।',
@@ -231,6 +238,7 @@
231
238
  seeTrail: 'देखें', alsoSent: 'यह भी भेजा जाता है: ',
232
239
  trail: { page: ['पेज', 'पेज'], click: ['क्लिक', 'क्लिक'], request: ['विफल अनुरोध', 'विफल अनुरोध'], error: ['त्रुटि', 'त्रुटियाँ'], warn: ['चेतावनी', 'चेतावनियाँ'], state: ['डिवाइस घटना', 'डिवाइस घटनाएँ'] },
233
240
  nudgeStuckTitle: 'कहीं अटक गए?', nudgeStuckBody: 'अगर यहाँ कुछ साफ़ नहीं है, तो टीम को बताइए। इसे कोई इंसान पढ़ता है।', nudgeAria: 'समस्या बताने का सुझाव', nudgeTitle: 'कुछ काम नहीं कर रहा?', nudgeBody: 'टीम को बताइए क्या हुआ। इसे कोई इंसान पढ़ता है।', nudgeYes: 'टीम को बताएँ', nudgeNo: 'अभी नहीं',
241
+ fixedIn: 'वर्शन {v} में ठीक किया गया।', updateTo: 'इसे पाने के लिए {v} पर अपडेट करें।',
234
242
  sentTo: 'इस ऐप की टीम को भेजा जाता है', powered: 'Heresay द्वारा संचालित',
235
243
  },
236
244
  };
@@ -321,14 +329,26 @@
321
329
 
322
330
  /** Statuses the reporter has already seen, so a new outcome can show a dot. */
323
331
  function seen() { try { return JSON.parse(load('fbsdk.seen.' + KEY) || '{}'); } catch (e) { return {}; } }
332
+ /** What the reporter has seen of a report: its status, and the version a fix ships in once known. */
333
+ function mark(r) { return r.status + (r.fix_version ? '@' + r.fix_version : ''); }
324
334
  function markSeen() {
325
335
  var s = {};
326
- state.reports.forEach(function (r) { s[r.id] = r.status; });
336
+ state.reports.forEach(function (r) { s[r.id] = mark(r); });
327
337
  save('fbsdk.seen.' + KEY, JSON.stringify(s));
328
338
  }
329
339
  function unseen() {
330
340
  var s = seen();
331
- return state.reports.filter(function (r) { return r.status !== 'open' && s[r.id] !== r.status; }).length;
341
+ return state.reports.filter(function (r) { return r.status !== 'open' && r.status !== 'withdrawn' && s[r.id] !== mark(r); }).length;
342
+ }
343
+ /** a < b for versions like 1.4, 1.10.2, 2.0 (build suffixes ignored). Unknown: false. */
344
+ function older(a, b) {
345
+ var x = String(a || '').split(/[\s(+-]/)[0].split('.'), y = String(b || '').split(/[\s(+-]/)[0].split('.');
346
+ if (!x[0] || !y[0] || x.concat(y).some(function (n) { return !/^\d+$/.test(n); })) return false;
347
+ for (var i = 0; i < Math.max(x.length, y.length); i++) {
348
+ var d = (+x[i] || 0) - (+y[i] || 0);
349
+ if (d) return d < 0;
350
+ }
351
+ return false;
332
352
  }
333
353
 
334
354
  /**
@@ -1006,6 +1026,15 @@
1006
1026
  }).then(body);
1007
1027
  }
1008
1028
 
1029
+ function withdrawReport(id, reason) {
1030
+ if (PREVIEW) return Promise.resolve({ report: Object.assign({}, state.reports.filter(function (x) { return x.id === id; })[0], { status: 'withdrawn', withdrawn_reason: reason || null }) });
1031
+ return fetch(API + '/reports/withdraw', {
1032
+ method: 'POST',
1033
+ headers: { 'content-type': 'text/plain;charset=UTF-8' },
1034
+ body: JSON.stringify({ key: KEY, device_id: deviceId(), report_id: id, reason: reason || null }),
1035
+ }).then(body);
1036
+ }
1037
+
1009
1038
  function refresh() {
1010
1039
  if (PREVIEW) return Promise.resolve();
1011
1040
  return fetch(API + '/reports/mine', {
@@ -1139,6 +1168,8 @@
1139
1168
  '.thanks{padding:10px 12px;margin:0 0 8px;border-radius:10px;background:var(--fb-line)}',
1140
1169
  '.item{border-top:1px solid var(--fb-line);padding:10px 0}',
1141
1170
  '.item:first-child{border-top:0}',
1171
+ '.take-back{margin-top:6px}.take-back input{width:100%;padding:7px 9px;border:1px solid var(--fb-line);border-radius:8px;background:none;margin:4px 0}',
1172
+ '.take-back .row{margin-top:4px;justify-content:flex-end}',
1142
1173
  '.status{font-size:12px;font-weight:600}',
1143
1174
  '.status.fixed,.status.accepted{color:var(--fb-fg)}',
1144
1175
  '.reason{margin-top:4px;padding:8px;border-radius:8px;background:var(--fb-line);font-size:13px}',
@@ -1487,7 +1518,7 @@
1487
1518
  var s = seen();
1488
1519
  state.reports.forEach(function (r) {
1489
1520
  var label = (TYPES.filter(function (t) { return t.id === r.type; })[0] || {}).label || r.type;
1490
- var fresh = r.status !== 'open' && s[r.id] !== r.status;
1521
+ var fresh = r.status !== 'open' && r.status !== 'withdrawn' && s[r.id] !== mark(r);
1491
1522
  listBox.appendChild(el('div', { class: 'item' }, [
1492
1523
  el('div', { class: 'status ' + r.status, text: (fresh ? '● ' : '') + (S.status[r.status] || r.status) }),
1493
1524
  el('div', { class: 'text', text: r.text }),
@@ -1496,10 +1527,44 @@
1496
1527
  ? el('div', { class: 'reason', text: S.why + r.decline_reason }) : null,
1497
1528
  r.status === 'fixed' && r.fix_note
1498
1529
  ? el('div', { class: 'reason', text: r.fix_note }) : null,
1530
+ r.status === 'fixed' && r.fix_version
1531
+ ? el('div', { class: 'small', text: fmt(S.fixedIn, { v: r.fix_version }) + (older(state.version, r.fix_version) ? ' ' + fmt(S.updateTo, { v: r.fix_version }) : '') }) : null,
1532
+ r.status === 'withdrawn' && r.withdrawn_reason ? el('div', { class: 'small', text: S.yourWhy + r.withdrawn_reason }) : null,
1533
+ r.status === 'open' ? takeBack(r) : null,
1499
1534
  ]));
1500
1535
  });
1501
1536
  }
1502
1537
 
1538
+ /** "Take back": a report they sent and the team hasn't accepted. Kept as withdrawn, not deleted. */
1539
+ function takeBack(r) {
1540
+ var box = el('div', { class: 'take-back' });
1541
+ function ask() {
1542
+ box.textContent = '';
1543
+ var why = el('input', { type: 'text', maxlength: '500', placeholder: S.takeBackWhy, 'aria-label': S.takeBackWhy });
1544
+ var err = el('div', { class: 'err', role: 'alert' });
1545
+ box.appendChild(el('p', { class: 'small', text: S.takeBackAsk }));
1546
+ box.appendChild(why);
1547
+ box.appendChild(el('div', { class: 'row' }, [
1548
+ el('button', { class: 'link', type: 'button', text: S.keep, onclick: idle }),
1549
+ el('button', { class: 'send', type: 'button', text: S.takeBackYes, onclick: function () {
1550
+ withdrawReport(r.id, why.value.trim()).then(function (b) {
1551
+ state.reports = state.reports.map(function (x) { return x.id === r.id ? b.report : x; });
1552
+ markSeen();
1553
+ renderList();
1554
+ }).catch(function (x) { err.textContent = x.message || S.cantSend; });
1555
+ } }),
1556
+ ]));
1557
+ box.appendChild(err);
1558
+ why.focus();
1559
+ }
1560
+ function idle() {
1561
+ box.textContent = '';
1562
+ box.appendChild(el('button', { class: 'link', type: 'button', text: S.takeBack, onclick: ask }));
1563
+ }
1564
+ idle();
1565
+ return box;
1566
+ }
1567
+
1503
1568
  // ---- introduction ----------------------------------------------------------------------
1504
1569
 
1505
1570
  // People can't use a button they never noticed. Once per device and app, a bubble says what it