create-heresay 0.2.30 → 0.2.31

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.31",
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.31
@@ -6,6 +6,7 @@
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';
9
10
  const json = (status, body) => ({ status, body });
10
11
  const str = (v, max) => {
11
12
  if (typeof v !== 'string')
@@ -179,6 +180,30 @@ export async function agent(p, req, deps, body, prompt, createProject, toReporte
179
180
  }
180
181
  if (p[0] === 'findings')
181
182
  return findings(p, req, deps, body, token, repoName, apps, now);
183
+ // A release went out: every fix from this repo's apps without a version ships in it.
184
+ if (p[0] === 'released' && p.length === 1 && req.method === 'POST') {
185
+ const fx = parseFixRef({ version: body.version });
186
+ if (fx.error || !fx.ref.version)
187
+ return json(400, { error: fx.error ?? 'say which version was released, e.g. 1.4' });
188
+ const want = str(body.app, 100);
189
+ const targets = want ? apps.filter((a) => a.id === want || a.name.toLowerCase() === want.toLowerCase()) : apps;
190
+ if (!targets.length)
191
+ return json(400, { error: `this repo is not connected to an app called "${want}"` });
192
+ const stamped = [];
193
+ for (const app of targets) {
194
+ for (const t of await deps.store.listTasks(app.id)) {
195
+ if ((t.repo ?? null) !== null && t.repo !== repoName)
196
+ continue;
197
+ const r = await deps.store.getReport(app.id, t.report_id);
198
+ if (r?.status !== 'fixed' || r.fix_ref?.version)
199
+ continue;
200
+ await stampFix(app, r.id, { version: fx.ref.version, released_at: new Date(now).toISOString() }, deps);
201
+ stamped.push({ app: app.name, id: r.id });
202
+ }
203
+ }
204
+ deps.log('api.release_stamped', { repo: repoName, version: fx.ref.version, n: stamped.length });
205
+ return json(200, { version: fx.ref.version, stamped });
206
+ }
182
207
  if (p[0] !== 'briefs')
183
208
  return json(404, { error: 'not found' });
184
209
  if (p.length === 1 && req.method === 'GET') {
@@ -279,7 +304,10 @@ export async function agent(p, req, deps, body, prompt, createProject, toReporte
279
304
  return json(400, { error: 'write a note for the person who reported it: what changed, in their words' });
280
305
  if (takenByOther(found.task))
281
306
  return json(409, { error: `in progress in ${found.task.claim.repo}` });
282
- const res = await toReporter(app, found.task.id, note, me);
307
+ const fx = parseFixRef(body);
308
+ if (fx.error)
309
+ return json(400, { error: fx.error });
310
+ const res = await toReporter(app, found.task.id, note, me, fx.ref);
283
311
  if (res.status === 200) {
284
312
  await deps.store.updateTask(app.id, found.task.id, (cur) => ({ ...addNote(cur, `Fixed: ${note}`, 'note'), claim: null }));
285
313
  }
@@ -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,7 @@ 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 { alsoReported, duplicatesOf, follow, merge, parseFixRef, stampFix, unmerge } from './duplicates.js';
7
7
  import { notificationSettings, notify } from './notifications.js';
8
8
  import { LIMITS, PLATFORMS, REPORT_ORDER, REPORT_TYPES, isFramework, isPlatform, isReportType, isSignIn, toReporterView, } from './types.js';
9
9
  /**
@@ -201,11 +201,13 @@ async function route(req, deps) {
201
201
  return token(req, deps);
202
202
  // Coding agents, with a per-repo token instead of a person's sign-in.
203
203
  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) => {
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, ref) => {
205
205
  const updated_at = new Date(deps.now()).toISOString();
206
206
  const result = await deps.store.move(project.id, id, 'accepted', 'fixed', { fix_note: note, triaged_by: by, updated_at });
207
207
  if (result.ok) {
208
208
  await follow(project, id, 'accepted', 'fixed', { fix_note: note, triaged_by: by, updated_at }, deps);
209
+ if (ref && (ref.pr || ref.commit || ref.version))
210
+ await stampFix(project, id, ref, deps);
209
211
  await notify('fixed', project, id, deps);
210
212
  }
211
213
  return transitionRes(result);
@@ -273,6 +275,18 @@ async function route(req, deps) {
273
275
  }
274
276
  if (p[2] === 'reports' && p[3] && p[4] === 'merge' && req.method === 'POST')
275
277
  return merge(project, p[3], parseBody(req.body), member, deps);
278
+ if (p[2] === 'reports' && p[3] && p[4] === 'fix-ref' && req.method === 'POST') {
279
+ const r = await deps.store.getReport(project.id, p[3]);
280
+ if (!r)
281
+ return json(404, { error: 'no such report' });
282
+ if (r.status !== 'fixed')
283
+ return json(409, { error: 'only a fixed report has a fix to link' });
284
+ const fx = parseFixRef(parseBody(req.body));
285
+ if (fx.error)
286
+ return json(400, { error: fx.error });
287
+ await stampFix(project, r.id, { ...fx.ref, ...(fx.ref.version ? { released_at: new Date(deps.now()).toISOString() } : {}) }, deps);
288
+ return json(200, { report: await deps.store.getReport(project.id, r.id) });
289
+ }
276
290
  if (p[2] === 'reports' && p[3] && p[4] === 'unmerge' && req.method === 'POST')
277
291
  return unmerge(project, p[3], member, deps);
278
292
  if (p[2] === 'reports' && p[3] && req.method === 'POST') {
@@ -589,6 +603,7 @@ async function triage(project, report_id, action, uid, req, deps) {
589
603
  const body = parseBody(req.body);
590
604
  const at = new Date(deps.now()).toISOString();
591
605
  let t;
606
+ let fixRefLater = null;
592
607
  if (action === 'accept') {
593
608
  const report = await deps.store.getReport(project.id, report_id);
594
609
  if (!report)
@@ -627,7 +642,12 @@ async function triage(project, report_id, action, uid, req, deps) {
627
642
  }
628
643
  else if (action === 'fixed') {
629
644
  // Optional from the dashboard; when given, the reporter reads it next to "Fixed".
645
+ const fx = parseFixRef(body);
646
+ if (fx.error)
647
+ return json(400, { error: fx.error });
630
648
  t = await deps.store.move(project.id, report_id, 'accepted', 'fixed', { fix_note: str(body.note, LIMITS.reasonMax), triaged_by: uid, updated_at: at });
649
+ if (t.ok && (fx.ref.pr || fx.ref.commit || fx.ref.version))
650
+ fixRefLater = fx.ref;
631
651
  }
632
652
  else {
633
653
  return json(404, { error: 'not found' });
@@ -641,6 +661,12 @@ async function triage(project, report_id, action, uid, req, deps) {
641
661
  await follow(project, report_id, 'open', 'declined', { decline_reason: t.report.decline_reason ?? undefined, triaged_by: uid, updated_at: at }, deps);
642
662
  if (action === 'fixed')
643
663
  await follow(project, report_id, 'accepted', 'fixed', { fix_note: t.report.fix_note ?? null, triaged_by: uid, updated_at: at }, deps);
664
+ if (fixRefLater) {
665
+ await stampFix(project, report_id, fixRefLater, deps);
666
+ const r2 = await deps.store.getReport(project.id, report_id);
667
+ if (r2)
668
+ t = { ok: true, report: r2 };
669
+ }
644
670
  }
645
671
  if (t.ok && (action === 'accept' || action === 'fixed')) {
646
672
  await notify(action === 'accept' ? 'accepted' : 'fixed', project, report_id, deps);
@@ -17,7 +17,7 @@ export const isSignIn = (v) => v === 'yes' || v === 'no';
17
17
  export const CLAIM_TTL_MS = 24 * 3600_000;
18
18
  export const toReporterView = (r) => ({
19
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,
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.31';
3
3
  //# sourceMappingURL=version.js.map
@@ -485,3 +485,11 @@ 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; }
@@ -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' }, [
@@ -1687,6 +1722,7 @@
1687
1722
  trailView(r.trail),
1688
1723
  r.decline_reason ? el('div', { class: 'reason', text: 'Declined: ' + r.decline_reason }) : null,
1689
1724
  r.fix_note ? el('div', { class: 'reason', text: 'Told them: ' + r.fix_note }) : null,
1725
+ r.status === 'fixed' ? fixRefLine() : null,
1690
1726
  r.status === 'accepted' && brief ? el('div', { class: 'brief-line' }, [
1691
1727
  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
1728
  ]) : null,
@@ -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.
@@ -117,6 +117,7 @@
117
117
  seeTrail: 'See it', alsoSent: 'Also sent: ',
118
118
  trail: { page: ['page', 'pages'], click: ['click', 'clicks'], request: ['failed request', 'failed requests'], error: ['error', 'errors'], warn: ['warning', 'warnings'], state: ['device event', 'device events'] },
119
119
  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',
120
+ fixedIn: 'Fixed in version {v}.', updateTo: 'Update to {v} to get it.',
120
121
  sentTo: 'Sent to this app’s team', powered: 'Powered by Heresay',
121
122
  },
122
123
  fr: {
@@ -155,6 +156,7 @@
155
156
  seeTrail: 'Voir', alsoSent: 'Aussi envoyé : ',
156
157
  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
158
  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',
159
+ fixedIn: 'Corrigé dans la version {v}.', updateTo: 'Passez à la {v} pour en profiter.',
158
160
  sentTo: 'Envoyé à l’équipe de cette app', powered: 'Propulsé par Heresay',
159
161
  },
160
162
  ta: {
@@ -193,6 +195,7 @@
193
195
  seeTrail: 'பார்', alsoSent: 'இவையும் அனுப்பப்படும்: ',
194
196
  trail: { page: ['பக்கம்', 'பக்கங்கள்'], click: ['கிளிக்', 'கிளிக்குகள்'], request: ['தோல்வியடைந்த கோரிக்கை', 'தோல்வியடைந்த கோரிக்கைகள்'], error: ['பிழை', 'பிழைகள்'], warn: ['எச்சரிக்கை', 'எச்சரிக்கைகள்'], state: ['சாதன நிகழ்வு', 'சாதன நிகழ்வுகள்'] },
195
197
  nudgeStuckTitle: 'எங்காவது சிக்கிக்கொண்டீர்களா?', nudgeStuckBody: 'இங்கே ஏதாவது புரியவில்லை என்றால், குழுவிடம் சொல்லுங்கள். ஒருவர் அதைப் படிப்பார்.', nudgeAria: 'சிக்கலைத் தெரிவிக்க ஒரு அழைப்பு', nudgeTitle: 'ஏதாவது வேலை செய்யவில்லையா?', nudgeBody: 'என்ன நடந்தது என்று குழுவிடம் சொல்லுங்கள். ஒருவர் அதைப் படிப்பார்.', nudgeYes: 'குழுவிடம் சொல்', nudgeNo: 'இப்போது வேண்டாம்',
198
+ fixedIn: 'பதிப்பு {v} இல் சரிசெய்யப்பட்டது.', updateTo: 'இதைப் பெற {v} க்குப் புதுப்பிக்கவும்.',
196
199
  sentTo: 'இந்த ஆப்பின் குழுவுக்கு அனுப்பப்படும்', powered: 'Heresay மூலம் இயங்குகிறது',
197
200
  },
198
201
  hi: {
@@ -231,6 +234,7 @@
231
234
  seeTrail: 'देखें', alsoSent: 'यह भी भेजा जाता है: ',
232
235
  trail: { page: ['पेज', 'पेज'], click: ['क्लिक', 'क्लिक'], request: ['विफल अनुरोध', 'विफल अनुरोध'], error: ['त्रुटि', 'त्रुटियाँ'], warn: ['चेतावनी', 'चेतावनियाँ'], state: ['डिवाइस घटना', 'डिवाइस घटनाएँ'] },
233
236
  nudgeStuckTitle: 'कहीं अटक गए?', nudgeStuckBody: 'अगर यहाँ कुछ साफ़ नहीं है, तो टीम को बताइए। इसे कोई इंसान पढ़ता है।', nudgeAria: 'समस्या बताने का सुझाव', nudgeTitle: 'कुछ काम नहीं कर रहा?', nudgeBody: 'टीम को बताइए क्या हुआ। इसे कोई इंसान पढ़ता है।', nudgeYes: 'टीम को बताएँ', nudgeNo: 'अभी नहीं',
237
+ fixedIn: 'वर्शन {v} में ठीक किया गया।', updateTo: 'इसे पाने के लिए {v} पर अपडेट करें।',
234
238
  sentTo: 'इस ऐप की टीम को भेजा जाता है', powered: 'Heresay द्वारा संचालित',
235
239
  },
236
240
  };
@@ -321,14 +325,26 @@
321
325
 
322
326
  /** Statuses the reporter has already seen, so a new outcome can show a dot. */
323
327
  function seen() { try { return JSON.parse(load('fbsdk.seen.' + KEY) || '{}'); } catch (e) { return {}; } }
328
+ /** What the reporter has seen of a report: its status, and the version a fix ships in once known. */
329
+ function mark(r) { return r.status + (r.fix_version ? '@' + r.fix_version : ''); }
324
330
  function markSeen() {
325
331
  var s = {};
326
- state.reports.forEach(function (r) { s[r.id] = r.status; });
332
+ state.reports.forEach(function (r) { s[r.id] = mark(r); });
327
333
  save('fbsdk.seen.' + KEY, JSON.stringify(s));
328
334
  }
329
335
  function unseen() {
330
336
  var s = seen();
331
- return state.reports.filter(function (r) { return r.status !== 'open' && s[r.id] !== r.status; }).length;
337
+ return state.reports.filter(function (r) { return r.status !== 'open' && s[r.id] !== mark(r); }).length;
338
+ }
339
+ /** a < b for versions like 1.4, 1.10.2, 2.0 (build suffixes ignored). Unknown: false. */
340
+ function older(a, b) {
341
+ var x = String(a || '').split(/[\s(+-]/)[0].split('.'), y = String(b || '').split(/[\s(+-]/)[0].split('.');
342
+ if (!x[0] || !y[0] || x.concat(y).some(function (n) { return !/^\d+$/.test(n); })) return false;
343
+ for (var i = 0; i < Math.max(x.length, y.length); i++) {
344
+ var d = (+x[i] || 0) - (+y[i] || 0);
345
+ if (d) return d < 0;
346
+ }
347
+ return false;
332
348
  }
333
349
 
334
350
  /**
@@ -1487,7 +1503,7 @@
1487
1503
  var s = seen();
1488
1504
  state.reports.forEach(function (r) {
1489
1505
  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;
1506
+ var fresh = r.status !== 'open' && s[r.id] !== mark(r);
1491
1507
  listBox.appendChild(el('div', { class: 'item' }, [
1492
1508
  el('div', { class: 'status ' + r.status, text: (fresh ? '● ' : '') + (S.status[r.status] || r.status) }),
1493
1509
  el('div', { class: 'text', text: r.text }),
@@ -1496,6 +1512,8 @@
1496
1512
  ? el('div', { class: 'reason', text: S.why + r.decline_reason }) : null,
1497
1513
  r.status === 'fixed' && r.fix_note
1498
1514
  ? el('div', { class: 'reason', text: r.fix_note }) : null,
1515
+ r.status === 'fixed' && r.fix_version
1516
+ ? 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,
1499
1517
  ]));
1500
1518
  });
1501
1519
  }