@floless/app 0.134.4 → 0.135.1

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/dist/web/aware.js CHANGED
@@ -633,6 +633,13 @@
633
633
  // Declared here, above its first use in api(), rather than beside the recovery helper that reads
634
634
  // it — a `let` referenced before its declaration executes is a TDZ crash, not a false.
635
635
  let awareMaintenanceRefused = false;
636
+ // Reloading or leaving the workspace aborts fetches owned by the retired document. Chromium reports
637
+ // those aborts as the same `TypeError: Failed to fetch` used for a live outage, so remember the page
638
+ // lifecycle and let reportErr() distinguish teardown noise from an error the user can still act on.
639
+ // `pageshow` matters for a document restored from the back-forward cache.
640
+ let awarePageUnloading = false;
641
+ window.addEventListener('pagehide', () => { awarePageUnloading = true; });
642
+ window.addEventListener('pageshow', () => { awarePageUnloading = false; });
636
643
 
637
644
  async function api(path, opts) {
638
645
  const res = await fetch(path, {
@@ -3897,7 +3904,7 @@
3897
3904
  const $dont = document.getElementById('confirm-dont-save');
3898
3905
  const $cancel = document.getElementById('confirm-cancel');
3899
3906
  $save.textContent = (actionLabels && actionLabels.confirm) || 'Save';
3900
- $dont.textContent = (actionLabels && actionLabels.discard) || 'Don’t save';
3907
+ $dont.textContent = (actionLabels && actionLabels.discard) || 'Don’t save';
3901
3908
  $cancel.textContent = (actionLabels && actionLabels.cancel) || 'Cancel';
3902
3909
  $dont.hidden = !!(actionLabels && actionLabels.hideDiscard);
3903
3910
  $title.textContent = titleMsg || 'Unsaved input changes'; // reset each call (default = the inputs-switch copy)
@@ -6119,12 +6126,35 @@
6119
6126
  * static markup default says an AWARE *upgrade* is available, so a pill that reaches this state
6120
6127
  * without passing through an offer branch would otherwise hover-explain the wrong thing entirely.
6121
6128
  */
6129
+ /**
6130
+ * ONE definition of the unfinished-update pill, because two surfaces reach it: the check-driven
6131
+ * paint (a marker is outstanding) and the attention paint (a recovery failed). Two literals would
6132
+ * drift, and the single-painter guard exists precisely to stop that.
6133
+ */
6134
+ const AWARE_RECOVERY_PILL = 'AWARE update needs finishing';
6135
+ const AWARE_RECOVERY_PILL_TIP = "An earlier AWARE update didn't finish — open this to pick it up";
6136
+
6122
6137
  function paintAwareAttentionPill() {
6123
6138
  if (!$awareUpdate) return;
6139
+ // The KIND is derived here rather than passed in, so this stays the single painter and every
6140
+ // existing caller keeps its signature. Widening awareNeedsAttention to cover a failed recovery
6141
+ // would otherwise have announced "Installed bridges need attention" for an unfinished UPDATE —
6142
+ // the exact class of lie the comments around this pill were written to kill.
6143
+ const live = window.awareUpdateController && window.awareUpdateController.getState();
6144
+ // `|| awareUpgradeOperation` to MATCH awareNeedsAttention exactly. Without it the predicate
6145
+ // said "this needs attention" for a recovery while the painter said "bridges", and a refused
6146
+ // start — which carried no operation — landed on the bridge label every time.
6147
+ const recovery = !!live && live.status === 'runtime-failed'
6148
+ && (live.operation || awareUpgradeOperation) === 'maintenance-recovery';
6124
6149
  $awareUpdate.hidden = false;
6125
6150
  $awareUpdate.disabled = false;
6126
- $awareUpdate.textContent = 'Installed bridges need attention';
6127
- $awareUpdate.dataset.tip = 'A bridge repair did not finish — open it to see which bridge and try again';
6151
+ // No ↑ on either: that glyph means "a runtime upgrade is on offer", and neither of these is one.
6152
+ // The command id moves with the label, or Instructor narrates the wrong job from the registry.
6153
+ $awareUpdate.dataset.commandId = recovery ? 'shell.aware-update-finish' : 'shell.aware-update';
6154
+ $awareUpdate.textContent = recovery ? AWARE_RECOVERY_PILL : 'Installed bridges need attention';
6155
+ $awareUpdate.dataset.tip = recovery
6156
+ ? AWARE_RECOVERY_PILL_TIP
6157
+ : 'A bridge repair did not finish — open it to see which bridge and try again';
6128
6158
  $awareUpdate.setAttribute('aria-haspopup', 'dialog');
6129
6159
  }
6130
6160
 
@@ -6135,9 +6165,14 @@
6135
6165
  * `runtime-failed` on a runtime UPGRADE is the upgrade failing — labelling that "Installed
6136
6166
  * bridges need attention" would be the same class of lie this change set out to remove, and the
6137
6167
  * ordinary re-check below correctly re-offers the upgrade instead.
6168
+ *
6169
+ * A failed `maintenance-recovery` belongs here too, and for a sharper reason: an unfinished
6170
+ * update blocks every later one, so a pill that quietly fell through to the release-notes
6171
+ * popover would leave the user with no route back to the only action that unblocks them.
6138
6172
  */
6139
6173
  const awareNeedsAttention = (s) => !!s && (s.status === 'partial'
6140
- || (s.status === 'runtime-failed' && (s.operation || awareUpgradeOperation) === 'bridge-repair'));
6174
+ || (s.status === 'runtime-failed'
6175
+ && ['bridge-repair', 'maintenance-recovery'].includes(s.operation || awareUpgradeOperation)));
6141
6176
 
6142
6177
  /**
6143
6178
  * True when the live job state owns the pill and this generic re-check must keep its hands off.
@@ -6168,8 +6203,20 @@
6168
6203
  // opened. paintAwareUpgrade is also driven by the client subscription (a server-started job
6169
6204
  // never opens the modal), so without this a stale set from an earlier open could be named.
6170
6205
  awareUpgradeInventory = awareInventoryOf(awareUpdateCheck);
6171
- if (r.ok && d.updateAvailable && d.targetVersion && d.operation === 'bridge-repair') {
6206
+ if (r.ok && d.recoveryPending) {
6207
+ // OUTRANKS both offers, because an unfinished update blocks them: starting one is what the
6208
+ // server does with this click either way. A machine already on the newest release still
6209
+ // lands here, which is exactly the case a version-only check renders as "nothing to do".
6210
+ $awareUpdate.dataset.commandId = 'shell.aware-update-finish';
6211
+ $awareUpdate.textContent = AWARE_RECOVERY_PILL;
6212
+ $awareUpdate.dataset.target = d.targetVersion || '';
6213
+ $awareUpdate.dataset.operation = 'maintenance-recovery';
6214
+ $awareUpdate.dataset.tip = AWARE_RECOVERY_PILL_TIP;
6215
+ $awareUpdate.setAttribute('aria-haspopup', 'dialog');
6216
+ $awareUpdate.hidden = false;
6217
+ } else if (r.ok && d.updateAvailable && d.targetVersion && d.operation === 'bridge-repair') {
6172
6218
  const count = Array.isArray(d.bridges) ? d.bridges.filter((row) => row.status !== 'current').length : 0;
6219
+ $awareUpdate.dataset.commandId = 'shell.aware-update';
6173
6220
  $awareUpdate.textContent = `Repair ${count || ''} installed bridge${count === 1 ? '' : 's'}`.replace(' ', ' ');
6174
6221
  $awareUpdate.dataset.target = d.targetVersion;
6175
6222
  $awareUpdate.dataset.operation = 'bridge-repair';
@@ -6177,6 +6224,7 @@
6177
6224
  $awareUpdate.setAttribute('aria-haspopup', 'dialog');
6178
6225
  $awareUpdate.hidden = false;
6179
6226
  } else if (r.ok && d.updateAvailable && d.targetVersion) {
6227
+ $awareUpdate.dataset.commandId = 'shell.aware-update';
6180
6228
  $awareUpdate.textContent = '↑ Upgrade AWARE to v' + d.targetVersion;
6181
6229
  $awareUpdate.dataset.target = d.targetVersion;
6182
6230
  $awareUpdate.dataset.operation = 'runtime-update';
@@ -6188,6 +6236,11 @@
6188
6236
  if (!applyDevForcedUpdate('aware', $awareUpdate)) $awareUpdate.hidden = true; // up-to-date / absent / registry error → no pill
6189
6237
  }
6190
6238
  } catch {
6239
+ // The check FAILED, so nothing it last said is current. Leaving the previous answer in place
6240
+ // let the post-recovery handoff read it and re-offer the very version the recovery had just
6241
+ // finished installing — an offer whose only possible end is "already the current release".
6242
+ awareUpdateCheck = null;
6243
+ awareUpgradeInventory = awareInventoryOf(null);
6191
6244
  if (!applyDevForcedUpdate('aware', $awareUpdate)) $awareUpdate.hidden = true;
6192
6245
  }
6193
6246
  }
@@ -6283,7 +6336,60 @@
6283
6336
  };
6284
6337
  // A registry hiccup leaves `target` empty; "v" + nothing used to render "vthe current release".
6285
6338
  const awareVersionLabel = (target) => (target ? `v${target}` : 'the current release');
6339
+ /**
6340
+ * What the recovery modal says, keyed on the terminal code the JOB reports.
6341
+ *
6342
+ * Kept as data rather than nested ternaries because there are seven states and the failure
6343
+ * heading is not the same sentence for all of them: two of these outcomes are not failures of
6344
+ * the recovery at all, and one is explicitly "still going, nothing lost". Rendering them all
6345
+ * under the old fixed "AWARE could not be upgraded." was the defect that sank the first attempt.
6346
+ */
6347
+ const AWARE_RECOVERY_COPY = {
6348
+ 'maintenance-pending': {
6349
+ live: 'The interrupted AWARE update could not be sorted out.',
6350
+ note: 'Close any AWARE or npm installer that is still running, then try again.',
6351
+ action: 'Try again',
6352
+ },
6353
+ 'marker-superseded': {
6354
+ live: 'The interrupted AWARE update changed while FloLess was working on it.',
6355
+ note: 'Nothing was lost. Try again to pick up where it now stands.',
6356
+ action: 'Try again',
6357
+ },
6358
+ 'recovery-unverified': {
6359
+ live: 'The interrupted AWARE update was cleared, but AWARE did not start correctly.',
6360
+ note: 'Try again. If it keeps happening, reinstall AWARE and relaunch FloLess.',
6361
+ action: 'Try again',
6362
+ },
6363
+ 'recovery-target-unknown': {
6364
+ // A torn marker plus an unreadable runtime. Trying again re-derives the same nothing, so the
6365
+ // action must not be "Try again" — that is the dead-end control this whole change exists to
6366
+ // remove, rebuilt one state further along. The live region carries the instruction because
6367
+ // #aware-update-results is outside the dialog's aria-describedby and is never spoken.
6368
+ live: 'FloLess cannot tell which AWARE version the interrupted update was returning to. Reinstall AWARE, then relaunch FloLess.',
6369
+ note: 'Trying again cannot help: the record of what was being installed is damaged.',
6370
+ action: null,
6371
+ },
6372
+ 'recovery-incomplete': {
6373
+ // Deliberately NOT phrased as a failure. The durable record is left in place on purpose, so
6374
+ // the next attempt continues rather than restarts — saying otherwise would send the user
6375
+ // hunting for damage that is not there.
6376
+ live: 'FloLess is still working through the interrupted AWARE update.',
6377
+ note: 'It stopped for now so the rest of FloLess stays usable. Continue when you are ready — it picks up where it left off.',
6378
+ action: 'Continue',
6379
+ },
6380
+ };
6381
+ const awareRecoveryCopy = (code) => AWARE_RECOVERY_COPY[code] || {
6382
+ live: 'The interrupted AWARE update could not be sorted out.',
6383
+ note: 'Try again.',
6384
+ action: 'Try again',
6385
+ };
6386
+
6286
6387
  const awareUpgradeCopyText = (target, operation, inventory) => {
6388
+ if (operation === 'maintenance-recovery') {
6389
+ // No version offer: a recovery finishes what was already started, it does not choose a
6390
+ // target. And no duration — this runs in npm on an unbounded machine.
6391
+ return 'An earlier AWARE update did not finish. FloLess will sort it out. Other AWARE actions pause until it is done.';
6392
+ }
6287
6393
  if (operation === 'bridge-repair') {
6288
6394
  const stale = (inventory || []).filter((row) => row.status === 'stale' || row.status === 'unverifiable');
6289
6395
  const versions = stale.map((row) => `${awareHostLabel(row.host)}${row.version ? ` v${row.version}` : ''}`).join(', ');
@@ -6341,32 +6447,69 @@
6341
6447
  const busy = awareBusy(status);
6342
6448
  $awareUpgradeModal.dataset.state = status;
6343
6449
  $awareUpgradeModal.setAttribute('aria-busy', busy ? 'true' : 'false');
6344
- if ($awareUpgradeTitle) $awareUpgradeTitle.textContent = operation === 'bridge-repair'
6345
- ? 'Repair installed bridges'
6346
- : operation === 'combined' ? 'Update AWARE and installed bridges' : 'Upgrade AWARE';
6450
+ if ($awareUpgradeTitle) $awareUpgradeTitle.textContent = operation === 'maintenance-recovery'
6451
+ ? 'Finish the interrupted AWARE update'
6452
+ : operation === 'bridge-repair'
6453
+ ? 'Repair installed bridges'
6454
+ : operation === 'combined' ? 'Update AWARE and installed bridges' : 'Upgrade AWARE';
6347
6455
  $awareUpgradeCopy.textContent = awareUpgradeCopyText(target, operation, awareUpgradeInventory);
6348
6456
  $awareUpgradeResults.innerHTML = '';
6349
- $awareUpgradeOk.hidden = status !== 'idle' && status !== 'runtime-failed';
6350
- $awareUpgradeOk.textContent = status === 'runtime-failed'
6351
- ? (operation === 'bridge-repair' ? 'Try repair again' : 'Try upgrade again')
6352
- : (operation === 'bridge-repair' ? 'Repair bridges' : operation === 'combined' ? 'Update all' : 'Upgrade now');
6457
+ // 'runtime-current' is the one runtime-failed that must NOT offer a retry: nothing is wrong, so
6458
+ // trying again can only reproduce the same sentence — the dead-end shape, one layer up.
6459
+ // `unknown-operation` belongs here beside `runtime-current`: its own message says the accepted
6460
+ // job is STILL RUNNING, so a retry could only be refused — and offering one contradicts the
6461
+ // sentence directly above it.
6462
+ const nothingToDo = status === 'runtime-failed' && s.error
6463
+ && (s.error.code === 'runtime-current' || s.error.code === 'unknown-operation'
6464
+ // A recovery whose copy declares no action has nothing that pressing could achieve.
6465
+ || (operation === 'maintenance-recovery' && !awareRecoveryCopy(s.error.code).action));
6466
+ $awareUpgradeOk.hidden = (status !== 'idle' && status !== 'runtime-failed') || nothingToDo;
6467
+ // The recovery arms take their label from the code, because "Continue" and "Try again" mean
6468
+ // different things to the user and only one of them is true per outcome.
6469
+ $awareUpgradeOk.textContent = operation === 'maintenance-recovery'
6470
+ ? (status === 'runtime-failed'
6471
+ ? awareRecoveryCopy(s.error && s.error.code).action
6472
+ : 'Finish the update')
6473
+ : status === 'runtime-failed'
6474
+ ? (operation === 'bridge-repair' ? 'Try repair again' : 'Try upgrade again')
6475
+ : (operation === 'bridge-repair' ? 'Repair bridges' : operation === 'combined' ? 'Update all' : 'Upgrade now');
6353
6476
  $awareUpgradeRetry.hidden = status !== 'partial' || !s.failed || !s.failed.length;
6354
- $awareUpgradeCancel.textContent = status === 'idle' ? 'Not now' : 'Close';
6477
+ $awareUpgradeCancel.textContent = status === 'idle' ? 'Not now' : nothingToDo ? 'Done' : 'Close';
6355
6478
 
6356
6479
  if (status === 'idle') $awareUpgradeLive.textContent = '';
6357
- else if (status === 'starting') $awareUpgradeLive.textContent = operation === 'bridge-repair'
6358
- ? 'Starting the bridge repair…' : 'Starting the AWARE upgrade…';
6480
+ // Operation-NEUTRAL on purpose. This fires before the POST returns, i.e. before anyone can know
6481
+ // whether the server will start an upgrade or a recovery — and it is spoken. Announcing
6482
+ // "Starting the AWARE upgrade…" and then flipping to a recovery reads as a contradiction to a
6483
+ // screen-reader user; this way the flip reads as an answer.
6484
+ else if (status === 'starting') $awareUpgradeLive.textContent = 'Starting — checking what AWARE needs first…';
6359
6485
  else if (status === 'running') {
6360
6486
  const count = s.total > 0 ? ` ${s.completed || 0} of ${s.total} bridges checked.` : '';
6361
6487
  $awareUpgradeLive.textContent = s.connectionMessage
6362
- || `${operation === 'bridge-repair' ? 'Repair' : 'Upgrade'} in progress — ${String(s.stage || 'preparing').replaceAll('-', ' ')}.${count}`;
6488
+ || (operation === 'maintenance-recovery'
6489
+ // No stage name: 'recovering' is the only stage a recovery has, and echoing it as
6490
+ // "Recovery in progress — recovering." says nothing twice.
6491
+ ? 'Sorting out the interrupted AWARE update. Other AWARE actions pause until it is done.'
6492
+ : `${operation === 'bridge-repair' ? 'Repair' : 'Upgrade'} in progress — ${String(s.stage || 'preparing').replaceAll('-', ' ')}.${count}`);
6363
6493
  } else if (status === 'retrying') {
6364
6494
  $awareUpgradeLive.textContent = s.connectionMessage || `Trying the ${awareHostLabel(s.host || '')} bridge again…`;
6365
6495
  } else if (status === 'success') {
6366
6496
  const version = s.observedVersion || target;
6367
6497
  const count = (s.updated || []).length;
6368
- $awareUpgradeLive.textContent = `AWARE v${version || ''}${count ? ` and ${count} installed bridge${count === 1 ? '' : 's'}` : ''} are up to date.`;
6369
- $awareUpgradeResults.innerHTML = awareHostRows('Updated bridges', s.updated || [], false);
6498
+ if (operation === 'maintenance-recovery') {
6499
+ // THE state this whole change exists for. A recovery that worked used to render under
6500
+ // "AWARE could not be upgraded." with a retry button that could never succeed.
6501
+ //
6502
+ // It names only what it just finished. Reading `awareUpdateCheck` here to advertise a
6503
+ // NEWER release named the check taken BEFORE the recovery ran — which is the one thing
6504
+ // that recovery may have changed — so a stale answer could offer a version that is no
6505
+ // longer on offer, or the very one that was just installed. The handoff below re-checks
6506
+ // first and then names it; that is the only place with an answer worth naming.
6507
+ $awareUpgradeLive.textContent = `The interrupted AWARE update is sorted out. AWARE v${version || ''} is ready.`;
6508
+ $awareUpgradeResults.innerHTML = '';
6509
+ } else {
6510
+ $awareUpgradeLive.textContent = `AWARE v${version || ''}${count ? ` and ${count} installed bridge${count === 1 ? '' : 's'}` : ''} are up to date.`;
6511
+ $awareUpgradeResults.innerHTML = awareHostRows('Updated bridges', s.updated || [], false);
6512
+ }
6370
6513
  } else if (status === 'partial') {
6371
6514
  $awareUpgradeLive.textContent = 'AWARE is up to date, but some installed bridges still need attention.';
6372
6515
  $awareUpgradeResults.innerHTML = '<div class="aware-update-summary">FloLess will keep incompatible bridges blocked until they are refreshed. You can retry only the failed bridges below.</div>'
@@ -6379,11 +6522,31 @@
6379
6522
  // A bridge repair can terminalize here too (a failed preflight, smoke, or a runtime that
6380
6523
  // moved underneath it) — and it never set out to upgrade anything, so the generic wording
6381
6524
  // would be simply untrue.
6382
- $awareUpgradeLive.textContent = operation === 'bridge-repair'
6383
- ? "AWARE's installed bridges could not be refreshed."
6384
- : 'AWARE could not be upgraded.';
6385
- const reason = s.error && s.error.message ? s.error.message : 'Check your connection and try again.';
6386
- $awareUpgradeResults.innerHTML = `<div class="aware-update-summary">${escapeHtml(reason)}</div>`;
6525
+ if (s.error && s.error.code === 'runtime-current') {
6526
+ // FIRST, ahead of the operation arms. A recovery can terminalise with this code when the
6527
+ // marker was discharged elsewhere between the pill's check and the click — and the recovery
6528
+ // arm below would then fall to its default copy, announcing "could not be sorted out" and
6529
+ // telling the user to "Try again" beside a Try-again button that `nothingToDo` has hidden.
6530
+ // Nothing is wrong here, so nothing is announced as wrong.
6531
+ $awareUpgradeLive.textContent = s.error.message;
6532
+ $awareUpgradeResults.innerHTML = '';
6533
+ } else if (operation === 'maintenance-recovery') {
6534
+ // Keyed on the CODE, not on the state. `recovery-incomplete` in particular is not a
6535
+ // failure — the work is paused with its place kept — and announcing it as one in the live
6536
+ // region is what a screen-reader user would be left with, since the results div below is
6537
+ // not part of the dialog's accessible description.
6538
+ const copy = awareRecoveryCopy(s.error && s.error.code);
6539
+ $awareUpgradeLive.textContent = copy.live;
6540
+ const detail = s.error && s.error.message ? s.error.message : '';
6541
+ $awareUpgradeResults.innerHTML = `<div class="aware-update-summary">${escapeHtml(copy.note)}</div>`
6542
+ + (detail && detail !== copy.live ? `<div class="aware-update-summary">${escapeHtml(detail)}</div>` : '');
6543
+ } else {
6544
+ $awareUpgradeLive.textContent = operation === 'bridge-repair'
6545
+ ? "AWARE's installed bridges could not be refreshed."
6546
+ : 'AWARE could not be upgraded.';
6547
+ const reason = s.error && s.error.message ? s.error.message : 'Check your connection and try again.';
6548
+ $awareUpgradeResults.innerHTML = `<div class="aware-update-summary">${escapeHtml(reason)}</div>`;
6549
+ }
6387
6550
  } else if (status === 'expired') {
6388
6551
  $awareUpgradeLive.textContent = s.message || 'The previous upgrade result expired.';
6389
6552
  $awareUpgradeResults.innerHTML = '<div class="aware-update-summary">The installed runtime was checked again. Use the current upgrade action if an update is still available.</div>';
@@ -6430,7 +6593,18 @@
6430
6593
  }
6431
6594
  }
6432
6595
  const check = awareUpdateCheck || {};
6433
- awareUpgradeOperation = check.operation || ($awareUpdate && $awareUpdate.dataset.operation) || 'runtime-update';
6596
+ // A pending recovery wins over the version check, which cannot see one: `check.operation` is
6597
+ // 'none' on a machine already at the newest release — and 'none' is TRUTHY, so it beat the
6598
+ // pill's own dataset and opened this dialog titled "Upgrade AWARE" over an interrupted update.
6599
+ // A live job that this dialog is about to show OWNS the answer. Taking it from the check
6600
+ // instead let a failed recovery open under its own copy — the painter reads `s.operation` —
6601
+ // and then start a runtime UPGRADE when the button was pressed, because the button passes this
6602
+ // variable. The dialog and its button have to be acting on the same job.
6603
+ const showing = awareBusy(current.status) || awareNeedsAttention(current) ? current.operation : null;
6604
+ awareUpgradeOperation = showing
6605
+ || (check.recoveryPending
6606
+ ? 'maintenance-recovery'
6607
+ : (check.operation || ($awareUpdate && $awareUpdate.dataset.operation) || 'runtime-update'));
6434
6608
  awareUpgradeInventory = awareInventoryOf(check);
6435
6609
  awareUpgradeTarget = target;
6436
6610
  awareUpgradeReturnFocus = returnFocusTo || document.activeElement;
@@ -6467,7 +6641,29 @@
6467
6641
  // every bridge-repair label deliberately goes without it, and a retry is bridge work.
6468
6642
  $awareUpdate.textContent = s.status === 'retrying'
6469
6643
  ? 'Retrying bridge…'
6470
- : operation === 'bridge-repair' ? 'Repairing installed bridges…' : '↑ Upgrading AWARE…';
6644
+ : operation === 'bridge-repair' ? 'Repairing installed bridges…'
6645
+ // A recovery is not an upgrade, and the ↑ glyph means "a runtime upgrade is on
6646
+ // offer" everywhere else in this footer — so it announced the wrong work with the
6647
+ // wrong glyph for the whole time the job ran.
6648
+ : operation === 'maintenance-recovery' ? 'Finishing AWARE update…'
6649
+ : '↑ Upgrading AWARE…';
6650
+ // The id follows the label HERE too, not only on the attention pill. The footer can be
6651
+ // painted as an upgrade and become a recovery when the 202 says so — and Instructor
6652
+ // narrates from the registry, so the id left behind described an upgrade over
6653
+ // "Finishing AWARE update…" for the whole time the job ran.
6654
+ // BOTH branches stamp BOTH fields. A one-sided write is how the id came to disagree
6655
+ // with the label in the first place, and `dataset.operation` is what openAwareUpgrade
6656
+ // falls back to — so a stale one reopens the dialog on the wrong job.
6657
+ $awareUpdate.dataset.operation = operation;
6658
+ if (operation === 'maintenance-recovery') {
6659
+ $awareUpdate.dataset.commandId = 'shell.aware-update-finish';
6660
+ $awareUpdate.dataset.tip = AWARE_RECOVERY_PILL_TIP;
6661
+ } else {
6662
+ $awareUpdate.dataset.commandId = 'shell.aware-update';
6663
+ $awareUpdate.dataset.tip = operation === 'bridge-repair'
6664
+ ? 'Repair installed bridges that do not match AWARE'
6665
+ : "What's new in v" + (s.target || '');
6666
+ }
6471
6667
  } else if (awareNeedsAttention(s)) {
6472
6668
  // Every suppressed automatic failure must land on an ENABLED attention pill. Without the
6473
6669
  // runtime-failed arm the pill stays frozen on "Repairing installed bridges…" forever,
@@ -6506,14 +6702,57 @@
6506
6702
  awareUpgradeFloorUntil = Date.now() + 10000;
6507
6703
  refreshVersionNotesTip('aware', version, wv, true);
6508
6704
  }
6705
+ // A recovery that succeeded hands straight over to the upgrade it was blocking, in ONE
6706
+ // click. Without this the modal auto-closes, and the pill then opens the release-notes
6707
+ // popover rather than starting anything — three actions to finish what the user asked for
6708
+ // once. Awaited, because the offer depends on the re-check that refreshAwareUpdate runs.
6709
+ if (operation === 'maintenance-recovery' && $awareUpgradeModal.classList.contains('show')) {
6710
+ refreshAwareUpdate().then(() => {
6711
+ if (awareUpdateClient.getState().transaction !== s.transaction) return; // superseded
6712
+ const check = awareUpdateCheck;
6713
+ if (!check || !check.updateAvailable || !check.targetVersion) return;
6714
+ awareUpgradeOperation = check.operation === 'bridge-repair' ? 'bridge-repair' : 'runtime-update';
6715
+ awareUpgradeTarget = check.targetVersion;
6716
+ awareUpgradeInventory = awareInventoryOf(check);
6717
+ // Repainted as a fresh OFFER so the primary button is visible, enabled and armed with
6718
+ // the new target — paintAwareUpgrade hides it on every non-idle, non-failed status, and
6719
+ // painting `idle` also makes the pending auto-close timer self-cancel through its own
6720
+ // dataset guard.
6721
+ paintAwareUpgrade({ status: 'idle', transaction: null, target: check.targetVersion,
6722
+ operation: awareUpgradeOperation, origin: 'user' });
6723
+ // AFTER the paint, never before: the idle arm sets the live region to '' , so a
6724
+ // sentence written first is wiped and the one thing a screen-reader user is told about
6725
+ // the recovery having WORKED disappears silently.
6726
+ $awareUpgradeLive.textContent = awareUpgradeOperation === 'bridge-repair'
6727
+ // "interrupted", the ONE word this feature uses for this thing — the same one the
6728
+ // dialog title and the `?` entry use. Two words for it, one after the other on the
6729
+ // same screen, read as two different things.
6730
+ ? `The interrupted AWARE update is finished. Some installed bridges still need to match it — choose Repair bridges.`
6731
+ : `The interrupted AWARE update is finished. AWARE v${check.targetVersion} is now available — choose Upgrade now to install it.`;
6732
+ // Only steal focus if the user is already in this dialog; otherwise they are elsewhere
6733
+ // and a recovery they may not have been watching must not yank them back.
6734
+ if ($awareUpgradeModal.contains(document.activeElement)) {
6735
+ try { $awareUpgradeOk.focus(); } catch { /* best effort */ }
6736
+ }
6737
+ }).catch(() => { /* the pill keeps its own state */ });
6738
+ return;
6739
+ }
6509
6740
  refreshAwareUpdate();
6510
6741
  if (!$awareUpgradeModal.classList.contains('show')) {
6511
6742
  showToast($awareUpgradeLive.textContent, 'ok');
6512
6743
  } else {
6513
6744
  // Success is a brief confirmation; partial results remain available
6514
6745
  // until dismissed because they still carry recovery actions.
6746
+ //
6747
+ // SCOPED TO THIS TRANSACTION. The old check looked only at the current status and a
6748
+ // dataset attribute, both of which a LATER job satisfies just as well — so a timer armed
6749
+ // by one success could close the modal of the next job that happened to be showing. Now
6750
+ // a timer that outlives its own transaction does nothing.
6751
+ const closing = s.transaction;
6515
6752
  setTimeout(() => {
6516
- if (awareUpdateClient.getState().status === 'success'
6753
+ const now = awareUpdateClient.getState();
6754
+ if (now.status === 'success'
6755
+ && now.transaction === closing
6517
6756
  && $awareUpgradeModal.dataset.state === 'success'
6518
6757
  && $awareUpgradeModal.classList.contains('show')) {
6519
6758
  closeAwareUpgradeModal();
@@ -6523,7 +6762,12 @@
6523
6762
  }
6524
6763
  });
6525
6764
  $awareUpgradeOk.onclick = () => {
6526
- awareUpdateClient.start(awareUpgradeTarget);
6765
+ // Caught: start() can reject on a response this build cannot describe, and an unhandled
6766
+ // rejection here leaves the modal busy with no buttons and nothing said.
6767
+ // The operation goes WITH the target. Sending only the target left `starting` with no
6768
+ // identity, so a refusal was narrated as a failed upgrade whatever the dialog had offered.
6769
+ awareUpdateClient.start(awareUpgradeTarget, awareUpgradeOperation)
6770
+ .catch(() => { /* the emitted state explains it */ });
6527
6771
  };
6528
6772
  $awareUpgradeRetry.onclick = () => awareUpdateClient.retryFailed();
6529
6773
  $awareUpgradeCancel.onclick = closeAwareUpgradeModal;
@@ -6566,7 +6810,11 @@
6566
6810
  return;
6567
6811
  }
6568
6812
  const version = $awareUpdate.dataset.target || '';
6569
- if ($awareUpdate.dataset.operation === 'bridge-repair') {
6813
+ // A pending recovery opens the dialog, never the changelog. Falling through would show
6814
+ // release notes to a user whose pill says an update needs finishing — and leave the only
6815
+ // action that unblocks them unreachable.
6816
+ if ($awareUpdate.dataset.operation === 'bridge-repair'
6817
+ || $awareUpdate.dataset.operation === 'maintenance-recovery') {
6570
6818
  openAwareUpgrade(version, $awareUpdate);
6571
6819
  return;
6572
6820
  }
@@ -7590,6 +7838,7 @@
7590
7838
  }
7591
7839
 
7592
7840
  function reportErr(e) {
7841
+ if (awarePageUnloading && e instanceof TypeError && e.message === 'Failed to fetch') return;
7593
7842
  console.error(e);
7594
7843
  showToast(e.message || String(e), 'err');
7595
7844
  }
@@ -8210,7 +8459,7 @@
8210
8459
  /** Fields whose change makes the upload handoff modal's guidance or Start policy stale. */
8211
8460
  function requestHelpStateKey(r) {
8212
8461
  if (!r) return '';
8213
- return [r.status, !!r.prepassReady, !!r.filterSaved, !!r.canRun, r.runWhy || '',
8462
+ return [r.status, !!r.prepassReady, !!r.filterCheckpointCurrent, !!r.canRun, r.runWhy || '',
8214
8463
  r.run && r.run.state || '', r.resumeCommand || '', !!r.desktopHandoffs].join('|');
8215
8464
  }
8216
8465
 
@@ -8588,7 +8837,7 @@
8588
8837
  }
8589
8838
  return 'This drawing read uses a status this version of FloLess does not recognize. Update FloLess, then open Requests again. If it still appears, clear it and attach the drawing set again.';
8590
8839
  }
8591
- if (r.filterSaved) {
8840
+ if (r.filterCheckpointCurrent) {
8592
8841
  return 'Drawing Filter saved. Return to the same terminal AI session that prepared it and tell it to continue the drawing read.';
8593
8842
  }
8594
8843
  if (r.prepassReady) {
@@ -8605,7 +8854,7 @@
8605
8854
  if (r.status && r.status !== 'pending') return '';
8606
8855
  if (r.refusalCode === 'steel-manifest-extraction-timeout'
8607
8856
  || r.run?.refusalCode === 'steel-manifest-extraction-timeout') return '';
8608
- if (r.filterSaved) {
8857
+ if (r.filterCheckpointCurrent) {
8609
8858
  return 'Next step: return to the same terminal AI session that prepared this Drawing Filter and tell it to continue the drawing read. Do not start the request again.';
8610
8859
  }
8611
8860
  if (r.prepassReady) {
@@ -835,6 +835,26 @@
835
835
  guidance: 'on-demand',
836
836
  });
837
837
 
838
+ /**
839
+ * The SAME footer pill, when an earlier update did not finish.
840
+ *
841
+ * A distinct definition rather than broadened prose on `shell.aware-update`: that entry says
842
+ * "Upgrades the AWARE runtime in place", and while the pill reads "AWARE update needs finishing"
843
+ * every word of it is false. Instructor takes the registry label over the DOM accessible name
844
+ * (see instructor.js), so a stable id cannot describe a carrier whose job changes — the id is
845
+ * swapped at paint time instead, which adds no carrier.
846
+ */
847
+ def('shell.aware-update-finish', {
848
+ label: 'Finish the interrupted AWARE update',
849
+ actsOn: 'Opens the dialog that completes an AWARE update that stopped part-way',
850
+ group: 'In the footer',
851
+ persistence: 'external',
852
+ interaction: 'dialog',
853
+ risk: ['costs-time'],
854
+ guidance: 'on-demand',
855
+ why: 'Until it finishes, AWARE cannot be updated or repaired — this is the only action that unblocks it.',
856
+ });
857
+
838
858
  def('shell.aware-update', {
839
859
  label: 'Update AWARE',
840
860
  actsOn: 'Upgrades the AWARE runtime in place',
@@ -951,8 +971,16 @@
951
971
  /* ── updates ────────────────────────────────────────────────────────────── */
952
972
 
953
973
  def('shell.aware-update-apply', {
954
- label: 'Install the AWARE update',
955
- actsOn: 'Upgrades the AWARE runtime now',
974
+ // NOT "Install the AWARE update". Instructor prefers the registry label over the button's own
975
+ // accessible name, and this one button reads "Upgrade now", "Repair bridges", "Update all" or
976
+ // "Finish the update" depending on what is being offered — so a label naming one of them is
977
+ // wrong three times out of four.
978
+ label: 'Start what the AWARE dialog is offering',
979
+ // Covers all THREE things this one carrier runs. Its data-command-id is deliberately stable
980
+ // (the rubric requires that of the exact carrier), so the narration has to be true whichever
981
+ // job the dialog is currently offering — including finishing an update that was interrupted,
982
+ // which is neither an upgrade nor a bridge repair.
983
+ actsOn: 'Runs what this dialog is offering — an AWARE upgrade, a bridge repair, or finishing an update that did not complete',
956
984
  group: 'In the FloLess dialogs',
957
985
  persistence: 'external',
958
986
  interaction: 'instant',
@@ -961,8 +989,11 @@
961
989
  });
962
990
 
963
991
  def('shell.aware-update-retry', {
964
- label: 'Retry the AWARE update',
965
- actsOn: 'Tries the upgrade again after a failure',
992
+ // This button appears only on a PARTIAL result and calls retryFailed(), which re-runs the
993
+ // bridges that failed and leaves the ones that worked alone. "Retry the update" described a
994
+ // different action entirely.
995
+ label: 'Retry the bridges that failed',
996
+ actsOn: 'Tries the installed bridges that did not refresh, without repeating the ones that worked',
966
997
  group: 'In the FloLess dialogs',
967
998
  persistence: 'external',
968
999
  interaction: 'instant',
@@ -907,7 +907,7 @@
907
907
  <span class="rtn-spinner" aria-hidden="true"></span>
908
908
  <div>
909
909
  <p class="rhrs-title" id="request-help-run-title"></p>
910
- <p class="rhrs-sub">This can take a few minutes, and you don’t need to wait. Keep working — the row in Requests updates as it goes.</p>
910
+ <p class="rhrs-sub">Larger drawing sets take longer. You don’t need to wait here — leave FloLess open, and the row in Requests updates as it goes.</p>
911
911
  </div>
912
912
  </div>
913
913
  <div class="request-help-note" id="request-help-note">FloLess cannot start the first read automatically yet: your terminal AI must create the starting project checkpoint, then wait for you to review and save the Drawing Filter. After you save, tell the terminal AI to continue.</div>