create-heresay 0.2.14 → 0.2.16

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.14",
3
+ "version": "0.2.16",
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.14
1
+ 0.2.16
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import { createHash, randomBytes, timingSafeEqual } from 'node:crypto';
7
7
  import { CLAIM_TTL_MS, LIMITS, PLATFORMS, isPlatform, } from './types.js';
8
+ import { notify } from './notifications.js';
8
9
  const json = (status, body) => ({ status, body });
9
10
  const str = (v, max) => {
10
11
  if (typeof v !== 'string')
@@ -264,6 +265,7 @@ export async function agent(p, req, deps, body, prompt, createProject, toReporte
264
265
  if (refused)
265
266
  return json(409, { error: `in progress in ${refused}`, claimed_by: refused });
266
267
  deps.log('api.brief_handed_off', { from: repoName, to, report_id: t.id });
268
+ await notify('handoff', app, t.id, deps);
267
269
  return json(200, { brief: summary(t, app, now) });
268
270
  }
269
271
  if (p[2] === 'fixed') {
@@ -1,5 +1,6 @@
1
1
  import { createHash, randomBytes } from 'node:crypto';
2
2
  import { agent, normaliseRepo, reposFor, tokens } from './agent.js';
3
+ import { notificationSettings, notify } from './notifications.js';
3
4
  import { LIMITS, PLATFORMS, REPORT_ORDER, REPORT_TYPES, isFramework, isPlatform, isReportType, isSignIn, toReporterView, } from './types.js';
4
5
  /**
5
6
  * Fixed windows. The public endpoint has no login, so each of these is a separate line of
@@ -137,7 +138,12 @@ async function route(req, deps) {
137
138
  return preflight(req);
138
139
  // Coding agents, with a per-repo token instead of a person's sign-in.
139
140
  if (p[0] === 'agent') {
140
- 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) => transitionRes(await deps.store.move(project.id, id, 'accepted', 'fixed', { fix_note: note, triaged_by: by, updated_at: new Date(deps.now()).toISOString() })));
141
+ 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) => {
142
+ const result = await deps.store.move(project.id, id, 'accepted', 'fixed', { fix_note: note, triaged_by: by, updated_at: new Date(deps.now()).toISOString() });
143
+ if (result.ok)
144
+ await notify('fixed', project, id, deps);
145
+ return transitionRes(result);
146
+ });
141
147
  }
142
148
  // The team, signed in to the dashboard.
143
149
  const who = await caller(req, deps);
@@ -156,6 +162,11 @@ async function route(req, deps) {
156
162
  }
157
163
  if (p[0] === 'team')
158
164
  return team(p, member, req, deps);
165
+ if (p[0] === 'notifications') {
166
+ if (member.role !== 'owner')
167
+ return json(403, { error: 'Only an owner can manage notifications.' });
168
+ return notificationSettings(p, req, deps, parseBody(req.body));
169
+ }
159
170
  if (p[0] === 'agent-tokens')
160
171
  return tokens(p, member, req, deps, parseBody(req.body));
161
172
  if (p[0] === 'projects' && p.length === 1) {
@@ -328,6 +339,7 @@ async function submit(req, deps) {
328
339
  await deps.store.updateProject(project.id, { framework: report.context.framework, framework_detected: true });
329
340
  }
330
341
  deps.log('api.report_created', { project_id: project.id, report_id: report.id, type: report.type });
342
+ await notify('new_report', project, report.id, deps);
331
343
  return json(201, { report: toReporterView(report) }, headers);
332
344
  }
333
345
  /**
@@ -532,6 +544,9 @@ async function triage(project, report_id, action, uid, req, deps) {
532
544
  return json(404, { error: 'not found' });
533
545
  }
534
546
  deps.log('api.report_triaged', { project_id: project.id, report_id, action, ok: t.ok });
547
+ if (t.ok && (action === 'accept' || action === 'fixed')) {
548
+ await notify(action === 'accept' ? 'accepted' : 'fixed', project, report_id, deps);
549
+ }
535
550
  return transitionRes(t);
536
551
  }
537
552
  //# sourceMappingURL=handler.js.map
@@ -0,0 +1,205 @@
1
+ export const NOTIFICATION_EVENTS = ['new_report', 'accepted', 'fixed', 'handoff'];
2
+ export const defaultNotifications = () => ({
3
+ events: { new_report: true, accepted: false, fixed: true, handoff: true },
4
+ telegram: { enabled: false, token: null, chat_id: '' },
5
+ cliq: { enabled: false, token: null, endpoint: '' },
6
+ });
7
+ /** Credentials never leave the server, including in save responses. */
8
+ export function notificationView(settings) {
9
+ return {
10
+ events: settings.events,
11
+ telegram: { enabled: settings.telegram.enabled, configured: !!settings.telegram.token, chat_id: settings.telegram.chat_id },
12
+ cliq: { enabled: settings.cliq.enabled, configured: !!settings.cliq.token, endpoint: settings.cliq.endpoint },
13
+ };
14
+ }
15
+ class SettingsError extends Error {
16
+ }
17
+ const object = (v) => {
18
+ if (!v || typeof v !== 'object' || Array.isArray(v))
19
+ throw new SettingsError('Invalid notification settings.');
20
+ return v;
21
+ };
22
+ const field = (v, max) => {
23
+ if (typeof v !== 'string' || v.length > max)
24
+ throw new SettingsError('Invalid notification field.');
25
+ return v.trim();
26
+ };
27
+ const boolean = (v) => {
28
+ if (typeof v !== 'boolean')
29
+ throw new SettingsError('Notification switches must be true or false.');
30
+ return v;
31
+ };
32
+ /** Only Zoho's message endpoints; redirects and arbitrary webhook hosts are not allowed. */
33
+ const CLIQ_HOSTS = new Set([
34
+ 'cliq.zoho.com', 'cliq.zoho.in', 'cliq.zoho.eu', 'cliq.zoho.com.au',
35
+ 'cliq.zoho.jp', 'cliq.zohocloud.ca', 'cliq.zoho.com.cn', 'cliq.zoho.sa',
36
+ 'cliq.zoho.uk', 'cliq.zoho.ae', 'cliq.zoho.sg',
37
+ ]);
38
+ export function validCliqEndpoint(endpoint) {
39
+ try {
40
+ const u = new URL(endpoint);
41
+ return u.protocol === 'https:' && !u.username && !u.password && !u.port && !u.search && !u.hash
42
+ && CLIQ_HOSTS.has(u.hostname)
43
+ && /^\/api\/v2\/(bots|channelsbyname)\/[A-Za-z0-9_-]+\/message$/.test(u.pathname);
44
+ }
45
+ catch {
46
+ return false;
47
+ }
48
+ }
49
+ /** Patch inside updateInstance: blank/omitted tokens retain the saved secret; null removes it. */
50
+ export function patchNotifications(current, body) {
51
+ const next = structuredClone(current);
52
+ if (body.events !== undefined) {
53
+ const events = object(body.events);
54
+ for (const event of NOTIFICATION_EVENTS)
55
+ if (events[event] !== undefined)
56
+ next.events[event] = boolean(events[event]);
57
+ }
58
+ for (const provider of ['telegram', 'cliq']) {
59
+ if (body[provider] === undefined)
60
+ continue;
61
+ const patch = object(body[provider]);
62
+ const target = next[provider];
63
+ if (patch.enabled !== undefined)
64
+ target.enabled = boolean(patch.enabled);
65
+ if (patch.token === null)
66
+ target.token = null;
67
+ else if (patch.token !== undefined) {
68
+ const token = field(patch.token, 512);
69
+ if (token) {
70
+ if (provider === 'telegram' ? !/^\d+:[A-Za-z0-9_-]{20,}$/.test(token) : !/^[A-Za-z0-9._-]+$/.test(token)) {
71
+ throw new SettingsError(`Invalid ${provider === 'telegram' ? 'Telegram bot' : 'Cliq webhook'} token.`);
72
+ }
73
+ target.token = token;
74
+ }
75
+ }
76
+ if (provider === 'telegram' && patch.chat_id !== undefined)
77
+ next.telegram.chat_id = field(patch.chat_id, 100);
78
+ if (provider === 'cliq' && patch.endpoint !== undefined)
79
+ next.cliq.endpoint = field(patch.endpoint, 300);
80
+ }
81
+ if (next.telegram.chat_id && !/^(?:-?\d+|@[A-Za-z][A-Za-z0-9_]{4,})$/.test(next.telegram.chat_id)) {
82
+ throw new SettingsError('Enter a Telegram chat ID or @channel username.');
83
+ }
84
+ if (next.cliq.endpoint && !validCliqEndpoint(next.cliq.endpoint)) {
85
+ throw new SettingsError('Use a Zoho Cliq bot or channel message endpoint, without a query string.');
86
+ }
87
+ if (next.telegram.enabled && (!next.telegram.token || !next.telegram.chat_id)) {
88
+ throw new SettingsError('Telegram needs a bot token and a chat ID.');
89
+ }
90
+ if (next.cliq.enabled && (!next.cliq.token || !next.cliq.endpoint)) {
91
+ throw new SettingsError('Cliq needs a webhook token and a message endpoint.');
92
+ }
93
+ return next;
94
+ }
95
+ export async function notificationSettings(p, req, deps, body) {
96
+ const json = (status, body) => ({ status, body, headers: { 'cache-control': 'no-store' } });
97
+ if (p.length === 1 && req.method === 'GET') {
98
+ const settings = (await deps.store.getInstance()).notifications ?? defaultNotifications();
99
+ return json(200, { notifications: notificationView(settings) });
100
+ }
101
+ if (p.length === 1 && req.method === 'PATCH') {
102
+ try {
103
+ const instance = await deps.store.updateInstance((cur) => ({
104
+ ...cur, notifications: patchNotifications(cur.notifications ?? defaultNotifications(), body),
105
+ }));
106
+ return json(200, { notifications: notificationView(instance.notifications) });
107
+ }
108
+ catch (error) {
109
+ // Validation messages are ours; never expose backend exceptions or credentials.
110
+ if (error instanceof SettingsError) {
111
+ return json(400, { error: error.message });
112
+ }
113
+ throw error;
114
+ }
115
+ }
116
+ if (p.length === 2 && p[1] === 'test' && req.method === 'POST') {
117
+ const provider = body.provider;
118
+ if (provider !== 'telegram' && provider !== 'cliq')
119
+ return json(400, { error: 'Choose Telegram or Cliq.' });
120
+ const settings = (await deps.store.getInstance()).notifications ?? defaultNotifications();
121
+ const target = settings[provider];
122
+ if (!target.enabled)
123
+ return json(400, { error: 'Save and enable this destination first.' });
124
+ const now = deps.now(), start = Math.floor(now / 60_000) * 60_000;
125
+ if (!await deps.store.hit(`notification-test:${provider}:${start}`, 3, start + 60_000)) {
126
+ return json(429, { error: 'Wait a minute before sending another test.' });
127
+ }
128
+ if (!deps.sendNotification)
129
+ return json(503, { error: 'Notification delivery is unavailable.' });
130
+ try {
131
+ await deps.sendNotification(provider, target, 'Heresay notifications are connected. You will receive the events selected in Notifications.');
132
+ return json(200, { ok: true });
133
+ }
134
+ catch {
135
+ return json(502, { error: 'Test could not be delivered. Check the token, destination, and bot permissions, then try again.' });
136
+ }
137
+ }
138
+ return json(404, { error: 'not found' });
139
+ }
140
+ /** Metadata only: open reports and reporter details must never flow into an integration. */
141
+ export async function notify(event, project, reportId, deps) {
142
+ try {
143
+ const settings = (await deps.store.getInstance())?.notifications;
144
+ if (!settings?.events[event] || !deps.sendNotification)
145
+ return;
146
+ const labels = {
147
+ new_report: 'A new report needs your review', accepted: 'A report was accepted for a coding agent',
148
+ fixed: 'A report was marked fixed', handoff: 'A coding agent handed off a report',
149
+ };
150
+ const origin = deps.selfOrigins?.[0];
151
+ const text = `Heresay: ${labels[event]}.\nApp: ${project.name}\nReport: ${reportId}`
152
+ + (origin ? `\n${origin}/app/#/apps/${encodeURIComponent(project.id)}` : '');
153
+ await Promise.all(['telegram', 'cliq'].map(async (provider) => {
154
+ if (!settings[provider].enabled)
155
+ return;
156
+ try {
157
+ await deps.sendNotification(provider, settings[provider], text);
158
+ deps.log('api.notification_sent', { provider, notification_event: event, project_id: project.id, report_id: reportId });
159
+ }
160
+ catch {
161
+ // Transport errors may contain credential-bearing URLs. Never log those errors.
162
+ deps.log('api.notification_failed', { provider, notification_event: event, project_id: project.id, report_id: reportId });
163
+ }
164
+ }));
165
+ }
166
+ catch {
167
+ // A notification outage must not turn a saved report/status change into a failed request.
168
+ deps.log('api.notification_failed', { notification_event: event, project_id: project.id, report_id: reportId });
169
+ }
170
+ }
171
+ /** Shared HTTP transport; a backend adapter supplies this to the portable core. */
172
+ export function notificationSender(http = fetch) {
173
+ return async (provider, destination, text) => {
174
+ let url, body;
175
+ if (!destination.token)
176
+ throw new Error('Notification token missing.');
177
+ if (provider === 'telegram' && 'chat_id' in destination) {
178
+ url = `https://api.telegram.org/bot${destination.token}/sendMessage`;
179
+ body = { chat_id: destination.chat_id, text, link_preview_options: { is_disabled: true } };
180
+ }
181
+ else if (provider === 'cliq' && 'endpoint' in destination && validCliqEndpoint(destination.endpoint)) {
182
+ const u = new URL(destination.endpoint);
183
+ u.searchParams.set('zapikey', destination.token);
184
+ url = u.href;
185
+ body = { text };
186
+ }
187
+ else {
188
+ throw new Error('Invalid notification destination.');
189
+ }
190
+ // Await within the request so serverless runtimes cannot stop before delivery. Bounded,
191
+ // with no retries: report creation and triage are never rolled back by a provider outage.
192
+ const response = await http(url, {
193
+ method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body),
194
+ signal: AbortSignal.timeout(5000), redirect: 'error',
195
+ });
196
+ if (!response.ok)
197
+ throw new Error('Notification provider rejected the message.');
198
+ if (provider === 'telegram') {
199
+ const result = await response.json();
200
+ if (result.ok !== true)
201
+ throw new Error('Telegram rejected the message.');
202
+ }
203
+ };
204
+ }
205
+ //# sourceMappingURL=notifications.js.map
@@ -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.14';
2
+ export const VERSION = '0.2.16';
3
3
  //# sourceMappingURL=version.js.map
@@ -8,6 +8,7 @@ import { auth, db } from './admin.js';
8
8
  import { FirestoreStore } from './firestore-store.js';
9
9
  import { handle } from '../../core/handler.js';
10
10
  import { VERSION } from '../../core/version.js';
11
+ import { notificationSender } from '../../core/notifications.js';
11
12
  const deps = {
12
13
  store: new FirestoreStore(db),
13
14
  async verifyIdToken(token) {
@@ -23,6 +24,7 @@ const deps = {
23
24
  log: (event, fields) => logger.info(event, { event, ...fields }),
24
25
  version: VERSION,
25
26
  selfOrigins: selfOrigins(),
27
+ sendNotification: notificationSender(),
26
28
  };
27
29
  function selfOrigins() {
28
30
  const id = process.env.GCLOUD_PROJECT;
@@ -9,7 +9,7 @@
9
9
  "scripts": {
10
10
  "build": "tsc -p tsconfig.json",
11
11
  "typecheck": "tsc -p tsconfig.json --noEmit",
12
- "test": "tsc -p tsconfig.test.json && node --test 'lib-test/test/handler.test.js' 'lib-test/test/agent.test.js' 'lib-test/test/store-memory.test.js'",
12
+ "test": "tsc -p tsconfig.test.json && node --test 'lib-test/test/handler.test.js' 'lib-test/test/agent.test.js' 'lib-test/test/notifications.test.js' 'lib-test/test/store-memory.test.js'",
13
13
  "build:test": "tsc -p tsconfig.test.json"
14
14
  },
15
15
  "dependencies": {
@@ -44,6 +44,7 @@
44
44
  <nav class="tabs" aria-label="Main">
45
45
  <a href="#/" data-nav="apps">Apps</a>
46
46
  <a href="#/team" data-nav="team">Team</a>
47
+ <a href="#/notifications" data-nav="notifications">Notifications</a>
47
48
  </nav>
48
49
  <span class="spacer"></span>
49
50
  <span id="who" class="who"></span>
@@ -144,17 +144,57 @@ a.platform:hover { border-color:var(--acc); box-shadow:0 0 0 3px var(--mist); }
144
144
  .filters button { font:inherit; font-weight:600; border:1px solid var(--line); background:none; color:var(--mute); border-radius:999px; padding:4px 12px; cursor:pointer; }
145
145
  .filters button .n { font-weight:500; }
146
146
  .filters button[aria-pressed=true] { color:var(--deep); border-color:var(--acc); background:var(--mist); }
147
- .report { border:1px solid var(--line); border-radius:14px; padding:16px 18px; margin-bottom:10px; }
147
+ .report { position:relative; border:1px solid var(--line); border-radius:14px; padding:16px 18px 16px 20px; margin-bottom:10px; overflow:hidden;
148
+ transition:border-color .2s, box-shadow .2s, background-color .3s, opacity .3s, height .3s ease, margin .3s ease, padding .3s ease; }
149
+ .report { --strip:var(--line); box-shadow:inset 3px 0 0 var(--strip); }
150
+ .report.t-broken { --strip:var(--broken); } .report.t-confusing { --strip:var(--confusing); }
151
+ .report.t-improvement { --strip:var(--improvement); } .report.t-idea { --strip:var(--idea); }
152
+ .report:hover { border-color:#cfd4da; box-shadow:inset 3px 0 0 var(--strip), 0 1px 3px rgb(21 23 28 / .06); }
153
+ .report.working { background:var(--soft); }
154
+ .report.settled { border-color:var(--acc); background:var(--mist); box-shadow:inset 3px 0 0 var(--strip), 0 0 0 3px var(--mist); }
155
+ .report.leaving { opacity:0; margin-bottom:0; padding-top:0; padding-bottom:0; border-width:0; }
148
156
  .report .meta { display:flex; gap:10px; align-items:center; font-size:13px; color:var(--mute); flex-wrap:wrap; }
149
157
  .pill { font-weight:700; font-size:12px; letter-spacing:.02em; }
158
+ .report .pill:first-child { padding:1px 9px; border-radius:999px; background:var(--soft); }
150
159
  .pill.broken { color:var(--broken); } .pill.confusing { color:var(--confusing); }
151
160
  .pill.improvement { color:var(--improvement); } .pill.idea { color:var(--idea); }
152
- .status { margin-left:auto; font-weight:600; }
161
+ .report .pill.broken { background:#fbeceb; } .report .pill.confusing { background:#fbf1e3; }
162
+ .report .pill.improvement { background:#eaf0fa; } .report .pill.idea { background:#f1edf9; }
163
+ .status { margin-left:auto; font-weight:600; font-size:12px; padding:1px 9px; border-radius:999px; background:var(--soft); transition:background-color .3s, color .3s; }
164
+ .s-open { color:var(--fg); }
153
165
  .s-accepted { color:var(--deep); }
166
+ .status.s-accepted { background:var(--mist); }
167
+ .status.s-fixed { color:#fff; background:var(--acc); }
168
+ .status.s-declined { color:var(--mute); }
154
169
  .report .text { margin:8px 0 6px; white-space:pre-wrap; word-break:break-word; font-size:16px; }
155
170
  .ctx { font-size:13px; color:var(--mute); }
156
171
  .actions { display:flex; gap:8px; margin-top:12px; flex-wrap:wrap; align-items:flex-start; }
157
172
  .actions textarea { flex:1 1 100%; min-height:70px; }
173
+ .done-line { display:flex; align-items:center; gap:8px; font-weight:600; font-size:14px; color:var(--deep); animation:pop-in .25s ease-out; }
174
+ .done-line.s-declined { color:var(--fg); }
175
+ .done-tick, .toast-tick { width:20px; height:20px; flex:none; border-radius:50%; background:var(--acc) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5L19 7'/%3E%3C/svg%3E") center/12px no-repeat; }
176
+ .done-line.s-declined .done-tick { background-color:var(--fg); }
177
+ @keyframes pop-in { from { opacity:0; transform:translateY(4px); } }
178
+
179
+ /* a button at work */
180
+ .btn { transition:background-color .15s, border-color .15s, color .15s, transform .1s; }
181
+ .btn:active:not(:disabled) { transform:scale(.97); }
182
+ .btn.busy, .btn.busy:disabled { opacity:1; cursor:progress; }
183
+ .btn.busy::before { content:""; width:14px; height:14px; border-radius:50%; border:2px solid currentColor; border-right-color:transparent; animation:spin .7s linear infinite; }
184
+
185
+ /* toast */
186
+ .toast { position:fixed; left:50%; bottom:24px; z-index:10; display:flex; align-items:center; gap:12px; max-width:calc(100vw - 32px);
187
+ padding:10px 12px 10px 14px; border-radius:12px; background:var(--fg); color:#fff; font-size:14px; font-weight:500;
188
+ box-shadow:0 10px 30px rgb(21 23 28 / .25); transform:translate(-50%, 16px); opacity:0; pointer-events:none; transition:opacity .2s, transform .2s; }
189
+ .toast.on { opacity:1; transform:translate(-50%, 0); pointer-events:auto; }
190
+ .toast button { font:inherit; font-weight:700; color:#7dd3c8; background:none; border:0; padding:4px 6px; border-radius:6px; cursor:pointer; }
191
+ .toast button:hover { background:rgb(255 255 255 / .1); }
192
+ .toast button:focus-visible { outline:2px solid #7dd3c8; }
193
+ @media (prefers-reduced-motion: reduce) {
194
+ .report, .toast, .btn { transition:none; }
195
+ .done-line { animation:none; }
196
+ .btn.busy::before { animation-duration:2s; }
197
+ }
158
198
  .reason { margin-top:8px; font-size:14px; padding:10px 12px; border-radius:10px; background:var(--soft); }
159
199
  .empty { text-align:center; color:var(--mute); padding:40px 0; }
160
200
 
@@ -328,3 +368,17 @@ a.platform:hover { border-color:var(--acc); box-shadow:0 0 0 3px var(--mist); }
328
368
  .am-titlebar i { width:11px; height:11px; border-radius:50%; background:#ff5f57; } .am-titlebar i:nth-child(2) { background:#febc2e; } .am-titlebar i:nth-child(3) { background:#28c840; }
329
369
  .am-titlebar span { flex:1; text-align:center; margin-right:40px; }
330
370
  .am-mac .am-content h3 { font-size:22px; }
371
+
372
+ /* notification settings */
373
+ .notification-form { max-width:none; }
374
+ .notification-form .notification-choice { display:flex; align-items:flex-start; gap:12px; margin:14px 0; }
375
+ .notification-choice input[type=checkbox] { width:18px; height:18px; flex:none; margin:3px 0 0; accent-color:var(--acc); }
376
+ .notification-choice .hint { display:block; margin:2px 0 0; }
377
+ .notification-form input[type=text], .notification-form input[type=password] { width:100%; min-width:0; }
378
+ .notification-form .row { margin-top:22px; }
379
+ @media (max-width:600px) {
380
+ .top { flex-wrap:wrap; gap:8px 12px; padding:12px 16px; }
381
+ .top .tabs { order:5; width:100%; }
382
+ .top .tabs a { padding:6px 10px; }
383
+ .top .who { max-width:130px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
384
+ }
@@ -65,6 +65,33 @@
65
65
  return el('div', { class: 'code' }, [el('pre', { text: text }), copyButton(function () { return text; })]);
66
66
  }
67
67
 
68
+ /** One message at a time, bottom of the screen, with an optional action. Read out by screen readers. */
69
+ var toastBox = null, toastTimer = null;
70
+ function toast(text, action) {
71
+ if (!toastBox) {
72
+ toastBox = el('div', { class: 'toast', role: 'status', 'aria-live': 'polite' });
73
+ document.body.appendChild(toastBox);
74
+ }
75
+ clearTimeout(toastTimer);
76
+ toastBox.textContent = '';
77
+ toastBox.appendChild(el('span', { class: 'toast-tick', 'aria-hidden': 'true' }));
78
+ toastBox.appendChild(el('span', { text: text }));
79
+ if (action) toastBox.appendChild(el('button', { type: 'button', text: action.label, onclick: function () { hideToast(); action.run(); } }));
80
+ toastBox.classList.add('on');
81
+ toastTimer = setTimeout(hideToast, 6000);
82
+ }
83
+ function hideToast() { if (toastBox) toastBox.classList.remove('on'); }
84
+
85
+ /** A button that is working: spinner, a new label, and no second click. */
86
+ function busyButton(b, label) {
87
+ var was = b.textContent;
88
+ b.disabled = true;
89
+ b.classList.add('busy');
90
+ b.setAttribute('aria-busy', 'true');
91
+ b.textContent = label;
92
+ return function () { b.disabled = false; b.classList.remove('busy'); b.removeAttribute('aria-busy'); b.textContent = was; };
93
+ }
94
+
68
95
  function stopTimer() { if (timer) { clearInterval(timer); timer = null; } }
69
96
  function every(ms, fn) {
70
97
  stopTimer();
@@ -200,13 +227,15 @@
200
227
  var query = new URLSearchParams(hash.split('?')[1] || '');
201
228
  var parts = hash.split('?')[0].split('/').filter(Boolean);
202
229
  document.querySelectorAll('[data-nav]').forEach(function (a) {
203
- a.setAttribute('aria-current', String((parts[0] === 'team') === (a.dataset.nav === 'team')));
230
+ var active = parts[0] === 'team' || parts[0] === 'notifications' ? parts[0] : 'apps';
231
+ a.setAttribute('aria-current', String(active === a.dataset.nav));
204
232
  });
205
233
  var view = $('view');
206
234
  view.textContent = '';
207
235
  view.appendChild(loading());
208
236
  view.classList.remove('wide');
209
237
  if (parts[0] === 'team') return teamView(view);
238
+ if (parts[0] === 'notifications') return notificationsView(view);
210
239
  if (parts[0] === 'connect') return connectView(view, query);
211
240
  if (parts[0] === 'new') return newAppView(view, parts[1], query);
212
241
  if (parts[0] === 'apps' && parts[1]) {
@@ -1258,14 +1287,7 @@
1258
1287
  });
1259
1288
  }
1260
1289
  var here = reports.filter(function (r) { return where === 'all' || r.project_id === where; });
1261
- filters.textContent = '';
1262
- ['open', 'accepted', 'fixed', 'declined', 'all'].forEach(function (f) {
1263
- var n = f === 'all' ? here.length : here.filter(function (r) { return r.status === f; }).length;
1264
- filters.appendChild(el('button', {
1265
- 'aria-pressed': String(filter === f),
1266
- onclick: function () { filter = f; render(); },
1267
- }, [(f === 'all' ? 'All' : STATUS_LABEL[f]) + ' ', el('span', { class: 'n', text: String(n) })]));
1268
- });
1290
+ drawFilters(here);
1269
1291
  list.textContent = '';
1270
1292
  var shown = here.filter(function (r) { return filter === 'all' || r.status === filter; });
1271
1293
  empty.hidden = shown.length > 0;
@@ -1276,13 +1298,48 @@
1276
1298
  } else empty.textContent = filter === 'open' ? 'Nothing waiting. Every report has had its hearing.' : 'Nothing here.';
1277
1299
  shown.forEach(function (r) {
1278
1300
  var c = ctxs[r.project_id];
1279
- list.appendChild(row(c.project, r, load, c, many));
1301
+ list.appendChild(row(c.project, r, settled, c, many));
1280
1302
  });
1281
1303
  }
1282
1304
 
1305
+ function drawFilters(here) {
1306
+ here = here || reports.filter(function (r) { return where === 'all' || r.project_id === where; });
1307
+ filters.textContent = '';
1308
+ ['open', 'accepted', 'fixed', 'declined', 'all'].forEach(function (f) {
1309
+ var n = f === 'all' ? here.length : here.filter(function (r) { return r.status === f; }).length;
1310
+ filters.appendChild(el('button', {
1311
+ 'aria-pressed': String(filter === f),
1312
+ onclick: function () { filter = f; render(); },
1313
+ }, [(f === 'all' ? 'All' : STATUS_LABEL[f]) + ' ', el('span', { class: 'n', text: String(n) })]));
1314
+ });
1315
+ }
1316
+
1317
+ /**
1318
+ * A report moved. The card says so where the click was, the counts move at once, and only
1319
+ * then does it leave this filter, so nothing vanishes without a word.
1320
+ */
1321
+ function settled(r, card, done) {
1322
+ if (!done) return load(); // someone else got there first: show what they did
1323
+ drawFilters();
1324
+ var to = r.status;
1325
+ toast(DONE_TOAST[to], filter === to || filter === 'all' ? null : {
1326
+ label: 'View ' + STATUS_LABEL[to].toLowerCase(), run: function () { filter = to; render(); window.scrollTo(0, 0); },
1327
+ });
1328
+ card.classList.add('settled');
1329
+ setTimeout(function () {
1330
+ if (!card.isConnected) return;
1331
+ if (filter === 'all' || filter === to) return load(); // it stays in this list
1332
+ card.style.height = card.offsetHeight + 'px';
1333
+ card.getBoundingClientRect();
1334
+ card.classList.add('leaving');
1335
+ card.style.height = '0px';
1336
+ setTimeout(load, 320);
1337
+ }, 2200);
1338
+ }
1339
+
1283
1340
  load();
1284
- // Reports arrive while you read. Don't refresh under someone typing a decline reason.
1285
- every(30000, function () { if (!list.querySelector('textarea')) load(); });
1341
+ // Reports arrive while you read. Don't refresh under someone typing, or a card on its way out.
1342
+ every(30000, function () { if (!list.querySelector('textarea, .report.settled, .report .busy')) load(); });
1286
1343
  }
1287
1344
 
1288
1345
  function ctxLine(c) {
@@ -1311,41 +1368,88 @@
1311
1368
  ]);
1312
1369
  }
1313
1370
 
1314
- function row(p, r, reload, ctx, showPlatform) {
1371
+ var DONE_TOAST = {
1372
+ accepted: 'Accepted. It is waiting for a coding agent.',
1373
+ declined: 'Declined. They will see your reason.',
1374
+ fixed: 'Marked fixed. They will see it in “Your reports”.',
1375
+ };
1376
+ var BUSY_LABEL = { accept: 'Accepting…', decline: 'Declining…', fixed: 'Saving…' };
1377
+
1378
+ function row(p, r, settled, ctx, showPlatform) {
1315
1379
  var brief = ctx.briefs[r.id];
1316
- var err = el('span', { class: 'err' });
1380
+ var err = el('span', { class: 'err', role: 'alert' });
1317
1381
  var actions = el('div', { class: 'actions' });
1318
- var act = function (action, body) {
1382
+ var card, sentTo = null;
1383
+ var act = function (action, body, b) {
1384
+ if (action === 'accept') sentTo = (body && body.repo) || ctx.repos[0] || null;
1319
1385
  err.textContent = '';
1386
+ var undo = busyButton(b, BUSY_LABEL[action]);
1387
+ actions.querySelectorAll('button, select, textarea').forEach(function (c) { if (c !== b) c.disabled = true; });
1388
+ card.classList.add('working');
1320
1389
  return api('POST', '/projects/' + p.id + '/reports/' + r.id + '/' + action, body)
1321
- .then(reload)
1322
- .catch(function (x) { err.textContent = x.message; if (x.status === 409) reload(); });
1390
+ .then(function (x) {
1391
+ Object.assign(r, x.report || {});
1392
+ card.classList.remove('working');
1393
+ showDone();
1394
+ settled(r, card, true);
1395
+ })
1396
+ .catch(function (x) {
1397
+ undo();
1398
+ card.classList.remove('working');
1399
+ actions.querySelectorAll('button, select, textarea').forEach(function (c) { c.disabled = false; });
1400
+ err.textContent = x.message;
1401
+ if (x.status === 409) settled(r, card, false);
1402
+ });
1323
1403
  };
1324
1404
 
1405
+ /** In place of the buttons: what just happened, in the colour of the new status. */
1406
+ function showDone() {
1407
+ status.className = 'status s-' + r.status;
1408
+ status.textContent = STATUS_LABEL[r.status];
1409
+ var line = r.status === 'accepted'
1410
+ ? 'Accepted. Waiting for an agent' + (sentTo ? ' in ' + sentTo : '') + '.'
1411
+ : r.status === 'declined' ? 'Declined. They will read your reason.' : 'Marked fixed. They will see it.';
1412
+ actions.textContent = '';
1413
+ actions.appendChild(el('div', { class: 'done-line s-' + r.status }, [
1414
+ el('span', { class: 'done-tick', 'aria-hidden': 'true' }), document.createTextNode(line),
1415
+ ]));
1416
+ }
1417
+
1418
+ function submitOnCmdEnter(area, go) {
1419
+ area.addEventListener('keydown', function (e) { if (e.key === 'Enter' && (e.metaKey || e.ctrlKey)) { e.preventDefault(); go.click(); } });
1420
+ }
1421
+
1325
1422
  function buttons() {
1326
1423
  actions.textContent = '';
1327
1424
  if (r.status === 'open') {
1328
1425
  // Several repos hold this app's code: say where the fix goes, defaulting to the first.
1329
1426
  var pick = ctx.repos.length > 1 ? el('select', { 'aria-label': 'Where the fix goes' },
1330
1427
  ctx.repos.map(function (x) { return el('option', { value: x, text: 'Fix in ' + x }); })) : null;
1331
- actions.appendChild(el('button', { class: 'btn primary', text: 'Accept', onclick: function () {
1332
- act('accept', pick ? { repo: pick.value } : undefined);
1428
+ actions.appendChild(el('button', { class: 'btn primary', type: 'button', text: 'Accept', onclick: function (e) {
1429
+ act('accept', pick ? { repo: pick.value } : undefined, e.currentTarget);
1333
1430
  } }));
1334
1431
  if (pick) actions.appendChild(pick);
1335
- actions.appendChild(el('button', { class: 'btn', text: 'Decline…', onclick: declineForm }));
1432
+ actions.appendChild(el('button', { class: 'btn', type: 'button', text: 'Decline…', onclick: declineForm }));
1336
1433
  }
1337
1434
  if (r.status === 'accepted') {
1338
1435
  actions.appendChild(el('button', {
1339
1436
  class: 'btn primary', text: 'Copy prompt for agent',
1437
+ type: 'button',
1340
1438
  onclick: function (e) {
1341
- var b = e.target;
1439
+ var b = e.currentTarget;
1440
+ var undo = busyButton(b, 'Copying…');
1342
1441
  api('GET', '/projects/' + p.id + '/reports/' + r.id + '/prompt')
1343
1442
  .then(function (x) { return navigator.clipboard.writeText(x.prompt); })
1344
- .then(function () { b.textContent = 'Copied'; })
1345
- .catch(function (x) { err.textContent = x.message; });
1443
+ .then(function () {
1444
+ undo();
1445
+ b.textContent = 'Copied ✓';
1446
+ toast('Prompt copied. Paste it into your coding agent.');
1447
+ setTimeout(function () { b.textContent = 'Copy prompt for agent'; }, 2000);
1448
+ })
1449
+ .catch(function (x) { undo(); err.textContent = x.message; });
1346
1450
  },
1347
1451
  }));
1348
- actions.appendChild(el('button', { class: 'btn', text: 'Mark fixed…', onclick: fixedForm }));
1452
+ actions.appendChild(el('button', { class: 'btn', type: 'button', text: 'Mark fixed…', onclick: fixedForm }));
1349
1453
  }
1350
1454
  actions.appendChild(err);
1351
1455
  }
@@ -1353,11 +1457,13 @@
1353
1457
  function fixedForm() {
1354
1458
  actions.textContent = '';
1355
1459
  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' });
1460
+ var go = el('button', { class: 'btn primary', type: 'button', text: 'Mark fixed', onclick: function (e) {
1461
+ act('fixed', note.value.trim() ? { note: note.value } : undefined, e.currentTarget);
1462
+ } });
1463
+ submitOnCmdEnter(note, go);
1356
1464
  actions.appendChild(note);
1357
- actions.appendChild(el('button', { class: 'btn primary', text: 'Mark fixed', onclick: function () {
1358
- act('fixed', note.value.trim() ? { note: note.value } : undefined);
1359
- } }));
1360
- actions.appendChild(el('button', { class: 'btn ghost', text: 'Cancel', onclick: buttons }));
1465
+ actions.appendChild(go);
1466
+ actions.appendChild(el('button', { class: 'btn ghost', type: 'button', text: 'Cancel', onclick: buttons }));
1361
1467
  actions.appendChild(err);
1362
1468
  note.focus();
1363
1469
  }
@@ -1365,23 +1471,26 @@
1365
1471
  function declineForm() {
1366
1472
  actions.textContent = '';
1367
1473
  var reason = el('textarea', { placeholder: 'Why? The person who sent this will read it.', 'aria-label': 'Reason for declining' });
1368
- actions.appendChild(reason);
1369
- actions.appendChild(el('button', { class: 'btn', text: 'Decline', onclick: function () {
1474
+ var go = el('button', { class: 'btn primary', type: 'button', text: 'Decline', onclick: function (e) {
1370
1475
  if (!reason.value.trim()) { err.textContent = 'Give a reason. They will see it.'; reason.focus(); return; }
1371
- act('decline', { reason: reason.value });
1372
- } }));
1373
- actions.appendChild(el('button', { class: 'btn ghost', text: 'Cancel', onclick: buttons }));
1476
+ act('decline', { reason: reason.value }, e.currentTarget);
1477
+ } });
1478
+ submitOnCmdEnter(reason, go);
1479
+ actions.appendChild(reason);
1480
+ actions.appendChild(go);
1481
+ actions.appendChild(el('button', { class: 'btn ghost', type: 'button', text: 'Cancel', onclick: buttons }));
1374
1482
  actions.appendChild(err);
1375
1483
  reason.focus();
1376
1484
  }
1377
1485
  buttons();
1378
1486
 
1379
- return el('article', { class: 'report' }, [
1487
+ var status = el('span', { class: 'status s-' + r.status, text: STATUS_LABEL[r.status] });
1488
+ card = el('article', { class: 'report t-' + r.type }, [
1380
1489
  el('div', { class: 'meta' }, [
1381
1490
  el('span', { class: 'pill ' + r.type, text: TYPE_LABEL[r.type] }),
1382
1491
  showPlatform ? el('span', { class: 'pill platform-pill', text: platformOf(p.platform).label }) : null,
1383
1492
  el('time', { datetime: r.created_at, text: new Date(r.created_at).toLocaleString() }),
1384
- el('span', { class: 'status s-' + r.status, text: STATUS_LABEL[r.status] }),
1493
+ status,
1385
1494
  ]),
1386
1495
  el('p', { class: 'text', text: r.text }),
1387
1496
  el('div', { class: 'ctx', text: ctxLine(r.context) }),
@@ -1396,6 +1505,7 @@
1396
1505
  .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,
1397
1506
  r.status === 'fixed' || r.status === 'declined' ? null : actions,
1398
1507
  ]);
1508
+ return card;
1399
1509
  }
1400
1510
 
1401
1511
  // ---- delete an app ---------------------------------------------------------------------
@@ -1536,6 +1646,117 @@
1536
1646
  repo.focus();
1537
1647
  }
1538
1648
 
1649
+ // ---- notifications ---------------------------------------------------------------------
1650
+
1651
+ function notificationsView(view) {
1652
+ view.appendChild(el('div', { class: 'head' }, [el('h1', { text: 'Notifications' })]));
1653
+ view.appendChild(el('p', { class: 'mute', text: 'Know when a report needs a hearing, or when work moves forward. These settings apply to every app in this Heresay.' }));
1654
+ if (me.role !== 'owner') {
1655
+ view.appendChild(el('section', { class: 'card' }, [el('p', { text: 'An owner can connect Telegram or Zoho Cliq and choose which events your team receives.' }), el('a', { href: '#/team', text: 'See team owners' })]));
1656
+ return;
1657
+ }
1658
+ var content = el('div');
1659
+ view.appendChild(content);
1660
+ api('GET', '/notifications').then(function (b) {
1661
+ var settings = b.notifications;
1662
+ var choices = [
1663
+ ['new_report', 'New reports', 'A new report is waiting for a person to review it.'],
1664
+ ['accepted', 'Accepted reports', 'A person approved a report for a coding agent.'],
1665
+ ['fixed', 'Reports marked fixed', 'A teammate or coding agent marked a report fixed.'],
1666
+ ['handoff', 'Agent handoffs', 'An agent handed accepted work to another repo.'],
1667
+ ];
1668
+ var eventInputs = {};
1669
+ var eventsMsg = el('p', { role: 'status' });
1670
+ var eventSave = el('button', { class: 'btn primary', type: 'submit', text: 'Save events' });
1671
+ var eventsForm = el('form', { class: 'form notification-form' }, choices.map(function (choice) {
1672
+ var input = eventInputs[choice[0]] = el('input', { type: 'checkbox', name: choice[0], checked: settings.events[choice[0]] });
1673
+ return el('label', { class: 'notification-choice' }, [input, el('span', {}, [el('b', { text: choice[1] }), el('span', { class: 'hint', text: choice[2] })])]);
1674
+ }).concat([el('div', { class: 'row' }, [eventSave]), eventsMsg]));
1675
+ eventsForm.onsubmit = function (e) {
1676
+ e.preventDefault();
1677
+ var events = {};
1678
+ Object.keys(eventInputs).forEach(function (key) { events[key] = eventInputs[key].checked; eventInputs[key].disabled = true; });
1679
+ eventSave.disabled = true;
1680
+ eventsMsg.className = 'hint'; eventsMsg.textContent = 'Saving…';
1681
+ api('PATCH', '/notifications', { events: events }).then(function () {
1682
+ eventsMsg.className = 'ok-msg'; eventsMsg.textContent = 'Notification events saved.';
1683
+ }).catch(function (x) { eventsMsg.className = 'err'; eventsMsg.textContent = x.message; }).finally(function () {
1684
+ eventSave.disabled = false;
1685
+ Object.keys(eventInputs).forEach(function (key) { eventInputs[key].disabled = false; });
1686
+ });
1687
+ };
1688
+ content.appendChild(el('section', { class: 'card' }, [el('h2', { text: 'When to notify' }), eventsForm]));
1689
+ content.appendChild(el('p', { class: 'hint', text: 'Alerts include the app name, event, report ID, and a link to the dashboard. Reporter text and contact details stay in Heresay.' }));
1690
+ destination('telegram', 'Telegram', settings.telegram);
1691
+ destination('cliq', 'Zoho Cliq', settings.cliq);
1692
+
1693
+ function destination(provider, title, saved) {
1694
+ var telegram = provider === 'telegram', dirty = false;
1695
+ var enabled = el('input', { type: 'checkbox', name: provider + '_enabled', checked: saved.enabled });
1696
+ var token = el('input', { type: 'password', name: provider + '_token', maxlength: 512, autocomplete: 'new-password', spellcheck: 'false' });
1697
+ var address = el('input', { type: 'text', name: telegram ? 'chat_id' : 'endpoint', value: telegram ? saved.chat_id : saved.endpoint, maxlength: telegram ? 100 : 300, autocomplete: 'off', spellcheck: 'false', placeholder: telegram ? '-1001234567890 or @yourchannel' : 'https://cliq.zoho.com/api/v2/channelsbyname/team/message' });
1698
+ var tokenHint = el('p', { class: 'hint' });
1699
+ var message = el('p', { role: 'status' });
1700
+ var save = el('button', { class: 'btn primary', type: 'submit', text: 'Save ' + title });
1701
+ var test = el('button', { class: 'btn', type: 'button', text: 'Send test notification' });
1702
+ var remove = el('button', { class: 'btn ghost', type: 'button', text: 'Disconnect' });
1703
+ var form = el('form', { class: 'form notification-form' }, [
1704
+ el('label', { class: 'notification-choice' }, [enabled, el('b', { text: 'Enable ' + title + ' notifications' })]),
1705
+ el('label', {}, [telegram ? 'Bot token' : 'Webhook token', token]), tokenHint,
1706
+ el('label', {}, [telegram ? 'Chat ID or channel username' : 'Message endpoint', address]),
1707
+ el('p', { class: 'hint' }, telegram
1708
+ ? ['Create a bot with BotFather, start a conversation with it (or add it to your group), and enter the target chat ID. For a channel, add the bot as an administrator. ', el('a', { href: 'https://core.telegram.org/bots/tutorial', target: '_blank', rel: 'noopener noreferrer', text: 'Telegram setup guide' })]
1709
+ : ['In Cliq, open Bots & Tools → Webhook Tokens and generate a token. Use the bot or channel message endpoint from Get Webhook URL, without the ?zapikey part. Use your region’s Cliq domain. ', el('a', { href: 'https://www.zoho.com/cliq/help/platform/webhook-tokens.html', target: '_blank', rel: 'noopener noreferrer', text: 'Cliq setup guide' })]),
1710
+ el('div', { class: 'row' }, [save, test, remove]), message,
1711
+ ]);
1712
+ function refresh() {
1713
+ token.placeholder = saved.configured ? 'Leave blank to keep the saved token' : 'Paste your token';
1714
+ tokenHint.textContent = saved.configured ? 'A token is saved. Paste a new one to replace it.' : 'Your token is saved on the server and is never displayed here.';
1715
+ test.disabled = dirty || !saved.enabled;
1716
+ remove.disabled = !saved.configured;
1717
+ }
1718
+ function busy(on) {
1719
+ form.querySelectorAll('input, button').forEach(function (control) { control.disabled = on; });
1720
+ if (!on) refresh();
1721
+ }
1722
+ function feedback(text, bad) { message.className = bad ? 'err' : 'ok-msg'; message.textContent = text; }
1723
+ form.oninput = function () { dirty = true; test.disabled = true; feedback('Save your changes before sending a test.'); };
1724
+ form.onsubmit = function (e) {
1725
+ e.preventDefault();
1726
+ var patch = { enabled: enabled.checked, token: token.value.trim() };
1727
+ patch[telegram ? 'chat_id' : 'endpoint'] = address.value.trim();
1728
+ var body = {}; body[provider] = patch;
1729
+ busy(true); feedback('Saving…');
1730
+ api('PATCH', '/notifications', body).then(function (result) {
1731
+ saved = result.notifications[provider]; dirty = false; token.value = '';
1732
+ feedback(title + ' settings saved. Send a test to check delivery.');
1733
+ }).catch(function (x) { feedback(x.message, true); }).finally(function () { busy(false); });
1734
+ };
1735
+ test.onclick = function () {
1736
+ busy(true); feedback('Sending a test…');
1737
+ api('POST', '/notifications/test', { provider: provider }).then(function () {
1738
+ feedback('Test notification sent. Check ' + title + '.');
1739
+ }).catch(function (x) { feedback(x.message, true); }).finally(function () { busy(false); });
1740
+ };
1741
+ remove.onclick = function () {
1742
+ var body = {}, patch = { enabled: false, token: null };
1743
+ patch[telegram ? 'chat_id' : 'endpoint'] = '';
1744
+ body[provider] = patch;
1745
+ busy(true); feedback('Disconnecting…');
1746
+ api('PATCH', '/notifications', body).then(function (result) {
1747
+ saved = result.notifications[provider]; dirty = false; enabled.checked = false; token.value = ''; address.value = '';
1748
+ feedback(title + ' disconnected. The saved token was removed.');
1749
+ }).catch(function (x) { feedback(x.message, true); }).finally(function () { busy(false); });
1750
+ };
1751
+ refresh();
1752
+ content.appendChild(el('section', { class: 'card' }, [el('h2', { text: title }), form]));
1753
+ }
1754
+ }).catch(function (x) {
1755
+ content.appendChild(el('p', { class: 'err', role: 'alert', text: x.message }));
1756
+ content.appendChild(el('button', { class: 'btn', text: 'Retry', onclick: function () { route(); } }));
1757
+ });
1758
+ }
1759
+
1539
1760
  // ---- team ------------------------------------------------------------------------------
1540
1761
 
1541
1762
  function teamView(view) {