@floless/app 0.168.0 → 0.169.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/cli-actions.mjs +8 -1
  2. package/dist/floless-server.cjs +83100 -68895
  3. package/dist/skills/floless-app-rfi/SKILL.md +4 -2
  4. package/dist/templates/college-phase-exporter.flo +7 -2
  5. package/dist/templates/trimble-list-projects.flo +10 -2
  6. package/dist/web/agent-steps.js +2 -2
  7. package/dist/web/agents.js +49 -13
  8. package/dist/web/app.css +44 -3
  9. package/dist/web/app.js +47 -4
  10. package/dist/web/aware-update-client.js +4 -4
  11. package/dist/web/aware.js +401 -31
  12. package/dist/web/chat.css +10 -0
  13. package/dist/web/chat.js +223 -22
  14. package/dist/web/commands-drawing-check.js +3 -0
  15. package/dist/web/commands-shell.js +111 -4
  16. package/dist/web/commands-steel.js +9 -2
  17. package/dist/web/commands-vector.js +69 -0
  18. package/dist/web/drawing-check-editor.html +10 -0
  19. package/dist/web/drawing-check-editor.js +502 -182
  20. package/dist/web/failure-copy.js +20 -2
  21. package/dist/web/flo-3d.js +310 -0
  22. package/dist/web/flo-card.js +72 -0
  23. package/dist/web/guide.js +3 -1
  24. package/dist/web/index.html +26 -4
  25. package/dist/web/instructor.js +3 -0
  26. package/dist/web/model-editor-steel-adapter.js +41 -1
  27. package/dist/web/model-viewport-toolbar.js +11 -0
  28. package/dist/web/pages.js +17 -14
  29. package/dist/web/panels.js +1 -1
  30. package/dist/web/project-history.js +2 -2
  31. package/dist/web/project-modules.js +3 -3
  32. package/dist/web/project-reconciliation.js +1 -1
  33. package/dist/web/project-rfis.js +2 -2
  34. package/dist/web/project-workflows.js +6 -4
  35. package/dist/web/renderers.js +6 -0
  36. package/dist/web/report-csp.js +68 -0
  37. package/dist/web/revit-editor.js +1 -1
  38. package/dist/web/run-history.js +2 -3
  39. package/dist/web/steel-3d-flo.js +309 -0
  40. package/dist/web/steel-3d-view.js +159 -0
  41. package/dist/web/steel-editor.html +130 -9
  42. package/dist/web/terminal-requests.js +78 -0
  43. package/dist/web/tool-updates.js +3 -2
  44. package/dist/web/vector-3d.html +1 -1
  45. package/dist/web/vector-editor.html +50 -8
  46. package/dist/web/workspace-root-management.js +1 -1
  47. package/dist/web/workspaces.js +626 -140
  48. package/launch.mjs +5 -0
  49. package/package.json +8 -8
@@ -2,7 +2,7 @@
2
2
  name: floless-app-rfi
3
3
  description: File, send, and manage RFIs on a floless.app project from the terminal. Use when the user asks to raise an RFI, send it through the connected Gmail account, record a manual send, chase one, record an answer that came back from the engineer, mark an answer as applied, close or reopen an RFI, or asks what questions are still outstanding on a project. Also use when a size the AI could not work out is one the user cannot answer either, so the question has to become a durable record instead of a message that scrolls away.
4
4
  metadata:
5
- version: 0.9.0
5
+ version: 0.10.0
6
6
  ---
7
7
 
8
8
  # File and manage a project's RFIs
@@ -244,7 +244,9 @@ never work around a version or provenance refusal.
244
244
  Before the irreversible call, show the exact single recipient and ask the user to confirm this send.
245
245
  `rfis.deliver` is `destructive`, so the person confirms it on a card in FloLess and nothing is sent
246
246
  before they do. You supply only the recipient and the current record revision. The server owns the
247
- subject and complete body:
247
+ subject and complete body. That body is the row's `text`; for a height RFI the drawings now contradict,
248
+ it also carries the same "Now:" line(s) the row shows (one per affected occurrence of a grouped RFI),
249
+ composed by the server from the current model when it sends. Never paste them in yourself:
248
250
 
249
251
  ```
250
252
  floless-app do rfis.deliver --input '{"projectId":"<projectId>","rfiId":"<rfiId>","recordRevision":<from the row you just read>,"to":"engineer@example.com"}' --json
@@ -1,8 +1,13 @@
1
1
  app: college-phase-exporter
2
- version: 0.3.0
2
+ version: 0.3.1
3
3
  publisher: floless
4
4
  update-mode: source-only
5
5
  changelog:
6
+ - version: 0.3.1
7
+ summary: Works with the current Trimble Connect tool.
8
+ changes:
9
+ - Asks for Trimble Connect 0.5, the version a current install has. The upload step works as before.
10
+ - It needs AWARE 0.159.0 or newer. If the footer offers an AWARE update, install it before updating this workflow.
6
11
  - version: 0.3.0
7
12
  summary: Works with the current Microsoft 365 tool by leaving out the three Microsoft 365 steps it does not offer yet.
8
13
  changes:
@@ -25,7 +30,7 @@ description: |
25
30
  exposes-as-agent: false
26
31
  requires:
27
32
  - tekla@0.1.x
28
- - trimble-connect@0.2.x
33
+ - trimble-connect@0.5.x
29
34
  - html-report@0.2.x
30
35
  - file@1.0.x
31
36
  requires-permissions:
@@ -1,5 +1,11 @@
1
1
  app: trimble-list-projects
2
- version: 0.1.0
2
+ version: 0.1.1
3
+ changelog:
4
+ - version: 0.1.1
5
+ summary: Works with the current Trimble Connect tool.
6
+ changes:
7
+ - Asks for Trimble Connect 0.5, the version a current install has. The project list works as before.
8
+ - It needs AWARE 0.159.0 or newer. If the footer offers an AWARE update, install it before updating this workflow.
3
9
  display-name: Trimble — list my projects
4
10
  description: |
5
11
  Lists the Trimble Connect projects you can access (read-only) and renders them
@@ -9,7 +15,7 @@ description: |
9
15
  in-app Viewer shows. Foundation demo for Trimble workflow support.
10
16
  exposes-as-agent: false
11
17
  requires:
12
- - trimble-connect@0.2.x
18
+ - trimble-connect@0.5.x
13
19
  - html-report@0.2.x
14
20
  requires-permissions:
15
21
  network:
@@ -25,11 +31,13 @@ nodes:
25
31
  - id: projects
26
32
  agent: trimble-connect
27
33
  command: list-projects
34
+ description: Asks Trimble Connect for the projects you can access, up to 100 of them.
28
35
  config:
29
36
  top: 100
30
37
  - id: report
31
38
  agent: html-report
32
39
  command: render
40
+ description: Turns the project list into a table in an HTML report, most recently changed first.
33
41
  config:
34
42
  data: '{{ projects.body }}'
35
43
  title: My Trimble Connect projects
@@ -403,7 +403,7 @@
403
403
  return;
404
404
  }
405
405
  if (!body || body.code !== 'needs-confirmation') {
406
- model.context.toast(body && body.error ? body.error : 'FloLess couldn’t save the wait. Try again.', 'warn');
406
+ model.context.toast(personText(body) || failureCopy({ status: response.status, body }, { action: 'save the wait' }).text, 'warn');
407
407
  return;
408
408
  }
409
409
  } catch { model.context.toast('FloLess couldn’t save the wait. Check that FloLess is running and try again.', 'warn'); return; }
@@ -481,7 +481,7 @@
481
481
  let body = null;
482
482
  try { body = await response.json(); } catch { body = null; }
483
483
  if (!response.ok || !body || body.ok !== true) {
484
- throw Object.assign(new Error(typeof body?.error === 'string' && body.error ? body.error : 'FloLess could not load the Agent’s step just now. Try again.'), { code: typeof body?.code === 'string' ? body.code : '' });
484
+ throw Object.assign(new Error(personText(body) || 'FloLess could not load the Agent’s step just now. Try again.'), { code: typeof body?.code === 'string' ? body.code : '' });
485
485
  }
486
486
  return body;
487
487
  }
@@ -136,7 +136,7 @@
136
136
  if (!body?.error) console.warn(`[agents] ${path} answered ${response.status} with no explanation`);
137
137
  // #2868: with no sentence from the server, the shared failure copy names the kind of failure (busy, signed out, an
138
138
  // answer that was not FloLess's) instead of "try again, restart FloLess", which fixes none of them.
139
- const failure = new Error(body?.error || failureCopy({ status: response.status, body: body || { code: 'response-unreadable' } }).text);
139
+ const failure = new Error(personText(body) || failureCopy({ status: response.status, body: body || { code: 'response-unreadable' } }).text);
140
140
  failure.code = body?.code || null; failure.body = body; failure.status = response.status;
141
141
  throw failure;
142
142
  }
@@ -359,37 +359,58 @@
359
359
  if (saveBtn) saveBtn.disabled = false;
360
360
  }
361
361
 
362
+ /** True only when the draft was saved and the person is still on its page, so a caller may go on with it. */
362
363
  async function save() {
363
- if (state.saving) return false;
364
+ const saved = await saveDraft();
365
+ return saved.ok && saved.here;
366
+ }
367
+
368
+ /**
369
+ * #3148: the answer belongs to the page that sent it: if the person opened another page meanwhile, it is said in a
370
+ * toast by the agent's name and never painted onto that page. `agent` is what the server saved, either way.
371
+ */
372
+ async function saveDraft() {
373
+ if (state.saving) return { ok: false };
364
374
  const draft = state.draft;
365
375
  if (!draft.name.trim()) {
366
376
  state.banner = { text: 'Give the agent a name before you save it.' };
367
377
  paint(); $surface.querySelector('#ag-name')?.focus();
368
- return false;
378
+ return { ok: false };
369
379
  }
380
+ const generation = state.pageGeneration;
381
+ const here = () => state.view === 'page' && state.pageGeneration === generation;
382
+ const created = !state.agent;
370
383
  state.saving = true; paint();
371
384
  try {
372
385
  const body = state.agent
373
386
  ? await api(`/api/chat/agents/${encodeURIComponent(state.agent.agentId)}`, { method: 'PUT', body: { agent: draft, revision: state.agent.revision } })
374
387
  : await api('/api/chat/agents', { method: 'POST', body: draft });
375
- const created = !state.agent;
388
+ if (!here()) {
389
+ toast(created ? `Agent “${body.agent.name}” created.` : `Agent “${body.agent.name}” saved.`, 'ok');
390
+ return { ok: true, here: false, agent: body.agent };
391
+ }
376
392
  state.agent = body.agent; state.draft = draftOf(body.agent); state.dirty = false; state.banner = null;
377
393
  toast(created ? `Agent “${body.agent.name}” created.` : 'Agent saved.', 'ok');
378
394
  if (created) void loadRuns();
379
- return true;
395
+ return { ok: true, here: true, agent: body.agent };
380
396
  } catch (error) {
381
- if (error.code === 'agent-revision-stale' && error.body?.agent) {
397
+ if (!here()) toast(`Couldn’t save “${draft.name.trim()}”. ${error.message}`, 'err');
398
+ else if (error.code === 'agent-revision-stale' && error.body?.agent) {
382
399
  const current = error.body.agent;
383
400
  state.banner = { text: error.message, action: { label: 'Load the current version', commandId: 'shell.agents-reload', run: () => {
384
401
  state.agent = current; state.draft = draftOf(current); state.dirty = false; state.banner = null; paint();
385
402
  } } };
386
403
  } else state.banner = { text: error.message };
387
- return false;
404
+ return { ok: false };
388
405
  } finally { state.saving = false; paint(); }
389
406
  }
390
407
 
391
408
  async function setArchived(archived) {
392
409
  if (!state.agent) return;
410
+ const { agentId } = state.agent;
411
+ let { name, revision } = state.agent;
412
+ // #3148: the answer belongs to this agent: if the person opened another one meanwhile, it is not painted onto that page.
413
+ const stillHere = () => state.view === 'page' && state.agent?.agentId === agentId;
393
414
  if (archived) {
394
415
  // Unsaved edits are the person's to keep or drop, never lost by an Archive that only asked about archiving.
395
416
  const dirty = state.dirty;
@@ -408,14 +429,29 @@
408
429
  ],
409
430
  });
410
431
  if (choice !== 'archive' && choice !== 'discard' && choice !== 'save') return;
411
- if (choice === 'save' && !(await save())) return; // a save that failed says why and keeps the edits
432
+ if (choice === 'save') {
433
+ if (!stillHere()) {
434
+ // Another agent's page was opened while this one asked: its unsaved edits are no longer on screen to save.
435
+ toast(`“${name}” wasn’t saved or archived, because another agent was opened before you chose. Open it again to archive it.`, 'warn');
436
+ return;
437
+ }
438
+ const saved = await saveDraft();
439
+ if (!saved.ok) return; // a save that failed says why and keeps the edits
440
+ ({ name, revision } = saved.agent);
441
+ }
412
442
  }
413
443
  try {
414
- const body = await api(`/api/chat/agents/${encodeURIComponent(state.agent.agentId)}/archive`, { method: 'POST', body: { archived, revision: state.agent.revision } });
415
- state.agent = body.agent; state.draft = draftOf(body.agent); state.dirty = false; state.banner = null;
416
- toast(archived ? 'Agent archived.' : 'Agent restored.', 'ok');
417
- paint();
418
- } catch (error) { state.banner = { text: error.message }; paint(); }
444
+ const body = await api(`/api/chat/agents/${encodeURIComponent(agentId)}/archive`, { method: 'POST', body: { archived, revision } });
445
+ if (stillHere()) {
446
+ state.agent = body.agent; state.draft = draftOf(body.agent); state.dirty = false; state.banner = null;
447
+ toast(archived ? 'Agent archived.' : 'Agent restored.', 'ok');
448
+ } else toast(archived ? `Agent “${name}” archived.` : `Agent “${name}” restored.`, 'ok');
449
+ } catch (error) {
450
+ if (stillHere()) state.banner = { text: error.message };
451
+ else toast(`Couldn’t ${archived ? 'archive' : 'restore'} “${name}”. ${error.message}`, 'err');
452
+ }
453
+ paint();
454
+ if (!stillHere()) void loadAgents();
419
455
  }
420
456
 
421
457
  /**
package/dist/web/app.css CHANGED
@@ -6248,7 +6248,15 @@ body.mode-workspaces #menu .menu-item[data-action="bake"] { display:none; }
6248
6248
  .wf-draft-failure:focus { outline:none; }
6249
6249
  /* The Draft chip is a state, not a warning: neutral, not the accent. */
6250
6250
  .ws-card .ws-kind.wf-kind.is-draft, .wf-draft-where .ws-kind.is-draft { color:var(--text-muted); border-color:var(--border-strong); }
6251
- .ws-card.wf-card .ws-body { display:block; }
6251
+ /* The text column and, on a card of yours, the ⋯ on the right, as on a project card. */
6252
+ .ws-card.wf-card .ws-body { display:flex; align-items:flex-start; justify-content:space-between; gap:8px; }
6253
+ .ws-card.wf-card .wf-card-text { flex:1 1 auto; min-width:0; }
6254
+ .ws-card .ws-kebab.wf-kebab { cursor:pointer; }
6255
+ .ws-card .ws-kebab.wf-kebab:focus-visible { outline:2px solid var(--accent); outline-offset:1px; }
6256
+ .ws-card .ws-kebab.wf-kebab[aria-expanded="true"] { border-color:var(--border-strong); color:var(--text); }
6257
+ /* The open menu covers the card's name, so the card it belongs to keeps its hover border while the menu is open. */
6258
+ #wf-landing .ws-card.wf-card:has(.wf-kebab[aria-expanded="true"]) { border-color:color-mix(in srgb, var(--part-mark) 60%, transparent); }
6259
+ .wf-card-menu .menu-item:focus-visible { outline:2px solid var(--accent); outline-offset:-2px; }
6252
6260
  .ws-card.wf-card .ws-kind.wf-kind { position:static; display:inline-block; margin-bottom:6px; }
6253
6261
  /* "Scheduled" is a status beside the origin chip, so it recedes: same chip, neutral ink. Not --ok, which the Routines
6254
6262
  window uses for "last run succeeded", something this card cannot know. */
@@ -6353,7 +6361,12 @@ body.mode-workspaces #menu .menu-item[data-action="bake"] { display:none; }
6353
6361
  .graft-check-picker { display:grid; gap:8px; margin-top:8px; max-height:260px; overflow:auto; scrollbar-width:thin; scrollbar-color:var(--border-strong) transparent; }
6354
6362
  .graft-success-actions { display:grid; gap:6px; margin-top:12px; }
6355
6363
  #lib-discover-local { margin-right:0 !important; }
6356
- .ws-spine { display:flex; align-items:center; gap:10px; }
6364
+ .ws-spine { display:flex; align-items:center; gap:10px; min-width:0; }
6365
+ /* When the header is tight the project name gives way (it has its own ellipsis), so the Quick chip and Review & approve
6366
+ stay whole instead of sliding under the account button (#2554). Any flex shrink, even a fraction of a pixel, would
6367
+ ellipsize the chip, so it does not shrink; its cap is what ellipsizes an unusually long one. */
6368
+ #ws-proj-combo { min-width:140px; flex-shrink:40; }
6369
+ #ws-quick.ws-quick-chips { flex-shrink:0; max-width:34ch; }
6357
6370
  #ws-proj-name { max-width:260px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
6358
6371
  #ws-proj-trigger { display:inline-flex; align-items:center; gap:8px; }
6359
6372
 
@@ -6609,11 +6622,30 @@ body.mode-workspaces #menu .menu-item[data-action="bake"] { display:none; }
6609
6622
  [data-theme="light"] .quick-pill { color:#b45309; border-color:color-mix(in srgb, #b45309 40%, transparent); background:color-mix(in srgb, #b45309 7%, transparent); }
6610
6623
  /* On a selected (accent-filled) picker row the amber would sit on blue: take the row's own text colour instead. */
6611
6624
  .export-source-option.selected .quick-pill { color:inherit; border-color:currentColor; background:transparent; }
6625
+ /* #2554 slice 2: which drawing files a model did not read. The Quick pill's shape, but neutral: amber is the Quick label's
6626
+ (AI decided), and this is a different fact. Its outline is its own muted text at 45%, as the Quick pill's is its amber
6627
+ (the border token alone vanishes on a dark card, and with it the dashed state). Dashed when FloLess could not tell. One set of tokens
6628
+ reads in both themes. */
6629
+ .coverage-pill { display:inline-flex; align-items:center; margin-left:6px; padding:0 7px; border:1px solid color-mix(in srgb, var(--text-muted) 45%, transparent);
6630
+ border-radius:999px; background:transparent; color:var(--text-muted); font-size:10.5px; font-weight:500;
6631
+ line-height:16px; white-space:nowrap; vertical-align:middle; cursor:default; }
6632
+ .coverage-pill.is-unknown { border-style:dashed; }
6633
+ .export-source-option.selected .coverage-pill { color:inherit; border-color:currentColor; }
6634
+ .ws-card .ws-meta.ws-quick > .coverage-pill:first-child,
6635
+ .ws-quick-chips .coverage-pill,
6636
+ .hd-quick .coverage-pill { margin-left:0; }
6637
+ .ws-quick-chips .coverage-pill { min-width:0; flex:0 1 auto; display:inline-block; overflow:hidden; text-overflow:ellipsis; }
6638
+ /* Its Exports note: the Quick note's box with the pill's neutral outline. The light pair outranks the Quick note's own
6639
+ light amber rules, which come later in this file. */
6640
+ .export-quick-note.is-coverage { border-color:color-mix(in srgb, var(--text-muted) 35%, transparent); }
6641
+ .export-quick-note.is-coverage b { color:var(--text); }
6642
+ [data-theme="light"] .export-quick-note.is-coverage { border-color:color-mix(in srgb, var(--text-muted) 35%, transparent); }
6643
+ [data-theme="light"] .export-quick-note.is-coverage b { color:var(--text); }
6612
6644
  .ws-card .ws-meta.ws-quick { white-space:normal; overflow:visible; }
6613
6645
  .ws-card .ws-meta.ws-quick .quick-pill,
6614
6646
  .ws-quick-chips .quick-pill,
6615
6647
  .hd-quick .quick-pill { margin-left:0; }
6616
- /* Shrinks (each chip ellipsizes, its full text stays in the tip) before it can push the Approve button off the header. */
6648
+ /* Each chip ellipsizes inside the header's cap (#ws-quick above), its full text staying in the tip. */
6617
6649
  .ws-quick-chips { display:inline-flex; align-items:center; gap:6px; min-width:0; flex:0 1 auto; overflow:hidden; }
6618
6650
  .ws-quick-chips .quick-pill { min-width:0; flex:0 1 auto; display:inline-block; overflow:hidden; text-overflow:ellipsis; }
6619
6651
  .ws-quick-chips[hidden] { display:none; }
@@ -8205,6 +8237,8 @@ button.kb-wikilink:focus-visible, .ai-chat-source-viewer button.kb-wikilink:focu
8205
8237
  .company-knowledge-confirm span { color:var(--text-muted); font-size:11px; line-height:1.5; }
8206
8238
  .company-knowledge-error { margin-top:10px; padding:8px 10px; border:1px solid color-mix(in srgb, var(--err) 35%, transparent);
8207
8239
  border-radius:6px; color:var(--err); background:color-mix(in srgb, var(--err) 7%, var(--surface)); font-size:11px; }
8240
+ .company-knowledge-status { margin-top:10px; color:var(--text-dim); font-size:11px; line-height:1.45; }
8241
+ .company-knowledge-status[hidden] { display:none; }
8208
8242
  .company-knowledge-dialog[aria-busy="true"] .company-knowledge-body { opacity:.7; }
8209
8243
  .company-knowledge-dialog > .modal-actions { flex:none; }
8210
8244
  @media (max-width:720px) {
@@ -8991,6 +9025,13 @@ input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer
8991
9025
  .ac-dialog .modal-actions button.primary[aria-disabled="true"]:hover { background: var(--accent); box-shadow: none; }
8992
9026
  .ac-dialog .modal-actions { flex: none; flex-wrap: wrap; }
8993
9027
  .ac-dialog .modal-actions #ac-cancel { margin-right: auto; }
9028
+ /* #2732: export past the archive bounds. Built on .ac-dialog; tokens only, both themes. Long folder paths wrap, never scroll. */
9029
+ .xo-dialog .xo-path { font-family: var(--mono); font-size: 11.5px; background: var(--surface-2); color: var(--text); padding: 1px 5px; border-radius: 3px; overflow-wrap: anywhere; }
9030
+ .xo-choices { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
9031
+ .xo-choices li { font-size: 12px; line-height: 1.5; color: var(--text-muted); padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2); }
9032
+ .xo-choices li b { color: var(--text); font-weight: 600; }
9033
+ .xo-left-out { font-size: 11.5px; line-height: 1.5; color: var(--text-dim); margin: -4px 0 12px; overflow-wrap: anywhere; }
9034
+ .xo-dialog .modal-actions #xo-cancel { margin-right: auto; }
8994
9035
  .ac-vis { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
8995
9036
 
8996
9037
  /* ── Two steps share one name (#2314, epic #2241 slice 3c): the rename ask. Built on the AI step confirmation's dialog (.ac-dialog)
package/dist/web/app.js CHANGED
@@ -627,9 +627,10 @@ function renderCategorySuggestions() {
627
627
  const cats = [...new Set(state.favorites.map(f => f.category).filter(Boolean))];
628
628
  const defaults = ['Tekla', 'MEP', 'Fab Pipeline', 'Coordination', 'QA'];
629
629
  const all = [...new Set([...cats, ...defaults])];
630
- $favCatSug.innerHTML = all.slice(0, 6).map(c => `<button data-cat="${escapeAttr(c)}">${escapeHtml(c)}</button>`).join('');
630
+ $favCatSug.innerHTML = all.slice(0, 6).map(c => `<button type="button" data-cat="${escapeAttr(c)}" data-command-id="shell.favourite-category-suggestion#${escapeAttr(c)}">${escapeHtml(c)}</button>`).join('');
631
631
  $favCatSug.querySelectorAll('button').forEach(b => {
632
- b.onclick = () => { $favCat.value = b.dataset.cat; };
632
+ // Fill the field and hand focus back to it, so a following Enter saves (#3140).
633
+ b.onclick = () => { $favCat.value = b.dataset.cat; $favCat.focus(); };
633
634
  });
634
635
  }
635
636
 
@@ -1232,12 +1233,38 @@ document.getElementById('lib-close').onclick = () => $libModal.classList.remove(
1232
1233
  onBackdropDismiss($addFavModal, closeAddFavModal);
1233
1234
  onBackdropDismiss($libModal, () => $libModal.classList.remove('show'));
1234
1235
 
1236
+ // Save as Template keys (#3140). Enter saves only from the Name or Category field: a focused button answers Enter
1237
+ // itself, so Save saves once, Cancel cancels and a category suggestion only fills the field. Tab wraps inside the
1238
+ // dialog, so focus never walks onto the page behind it.
1239
+ function onAddFavKey(e) {
1240
+ if (!$addFavModal.classList.contains('show')) return;
1241
+ if (e.key === 'Enter') {
1242
+ // A held Enter repeats; only its first press saves.
1243
+ if (e.isComposing || e.repeat || (e.target !== $favName && e.target !== $favCat)) return;
1244
+ e.preventDefault();
1245
+ commitFav();
1246
+ return;
1247
+ }
1248
+ if (e.key !== 'Tab') return;
1249
+ const active = document.activeElement;
1250
+ // A dialog opened over this one keeps its own Tab.
1251
+ if (active && !$addFavModal.contains(active) && active.closest('[role="dialog"], [role="alertdialog"]')) return;
1252
+ const controls = Array.from($addFavModal.querySelectorAll('input, button'))
1253
+ .filter((el) => !el.disabled && !el.hidden && el.getClientRects().length);
1254
+ if (!controls.length) return;
1255
+ const first = controls[0];
1256
+ const last = controls[controls.length - 1];
1257
+ const inside = $addFavModal.contains(active);
1258
+ if (e.shiftKey && (!inside || active === first)) { e.preventDefault(); last.focus(); }
1259
+ else if (!e.shiftKey && (!inside || active === last)) { e.preventDefault(); first.focus(); }
1260
+ }
1261
+
1235
1262
  document.addEventListener('keydown', (e) => {
1236
1263
  if (e.key === 'Escape') {
1237
1264
  if ($addFavModal.classList.contains('show')) closeAddFavModal();
1238
1265
  if ($libModal.classList.contains('show')) $libModal.classList.remove('show');
1239
1266
  }
1240
- if (e.key === 'Enter' && $addFavModal.classList.contains('show')) commitFav();
1267
+ onAddFavKey(e);
1241
1268
  });
1242
1269
 
1243
1270
  $libSearch.oninput = renderLibrary;
@@ -1323,6 +1350,22 @@ function onBackdropDismiss(modal, dismiss, guard) {
1323
1350
  };
1324
1351
  }
1325
1352
 
1353
+ // #3147: Escape closes `modal` while it shows, as its Cancel does. The key is left alone when something above the
1354
+ // dialog owns it: a press another handler already used, or focus in another dialog. While `guard()` says the dialog
1355
+ // cannot close (work it shows is still running), the press is used up but closes nothing, so it never falls through
1356
+ // to whatever sits underneath either.
1357
+ function onEscapeDismiss(modal, dismiss, guard) {
1358
+ if (!modal) return;
1359
+ document.addEventListener('keydown', (e) => {
1360
+ if (e.key !== 'Escape' || e.defaultPrevented || e.isComposing || !modal.classList.contains('show')) return;
1361
+ const active = document.activeElement;
1362
+ if (active && active !== document.body && !modal.contains(active)
1363
+ && active.closest('[role="dialog"], [role="alertdialog"], .modal-backdrop')) return;
1364
+ e.preventDefault();
1365
+ if (!guard || guard()) dismiss();
1366
+ });
1367
+ }
1368
+
1326
1369
  /* ============= MENU ============= */
1327
1370
 
1328
1371
  const $menuBtn = document.getElementById('menu-btn');
@@ -2064,7 +2107,7 @@ async function workspaceRootApi(path, opts) {
2064
2107
  const body = await response.json().catch(() => ({ ok: false, code: 'response-unreadable' }));
2065
2108
  if (!response.ok || body.ok === false) {
2066
2109
  const method = String(opts?.method || 'GET').toUpperCase();
2067
- const error = new Error(body.error || failureCopy({ status: response.status, body }, { retrySafe: method === 'GET' || method === 'HEAD' }).text);
2110
+ const error = new Error(personText(body) || failureCopy({ status: response.status, body }, { retrySafe: method === 'GET' || method === 'HEAD' }).text);
2068
2111
  error.body = body;
2069
2112
  error.status = response.status;
2070
2113
  throw error;
@@ -222,7 +222,7 @@
222
222
  if (!result.response.ok) {
223
223
  // #3097: the server's reason when it gave one; never a status number. The outcome is unknown here, so the
224
224
  // person is asked to look again before starting another upgrade.
225
- const message = result.body.error || 'FloLess lost track of the AWARE upgrade, so it can’t say whether it finished. Reopen this window to check before starting another upgrade.';
225
+ const message = personText(result.body) || 'FloLess lost track of the AWARE upgrade, so it can’t say whether it finished. Reopen this window to check before starting another upgrade.';
226
226
  console.warn('[aware-update] status read failed', result.response.status, result.body);
227
227
  return emit({ status: 'runtime-failed', transaction, target: state.target, observedVersion: null,
228
228
  // Identity is immutable, and DEFAULTED because start()/resume() emit before any poll
@@ -309,7 +309,7 @@
309
309
  return emit({ ...identity, status: 'runtime-failed', origin: 'user',
310
310
  error: { code: String(result.body.code || 'start-refused'), status: result.response.status,
311
311
  // #3097: never a status number. Refused or not, the server gave no reason, so whether it started is unknown.
312
- message: String(result.body.error || result.body.message || 'FloLess couldn’t confirm that the AWARE upgrade started. Reopen this window to see whether it is running before you try again. If it keeps happening, use Report an issue at the bottom of the window.') } });
312
+ message: String(personText(result.body) || result.body.message || 'FloLess couldn’t confirm that the AWARE upgrade started. Reopen this window to see whether it is running before you try again. If it keeps happening, use Report an issue at the bottom of the window.') } });
313
313
  }
314
314
  const transaction = transactionOf(result.body) || transactionOf(payloadOf(result.body));
315
315
  if (!transaction) {
@@ -439,7 +439,7 @@
439
439
  async function check() {
440
440
  const result = await request('/api/aware/update');
441
441
  if (!result.response.ok) {
442
- throw Object.assign(new Error(result.body.error || 'FloLess couldn’t check for AWARE updates just now. Try again in a moment.'),
442
+ throw Object.assign(new Error(personText(result.body) || 'FloLess couldn’t check for AWARE updates just now. Try again in a moment.'),
443
443
  { status: result.response.status, body: result.body });
444
444
  }
445
445
  return result.body;
@@ -473,7 +473,7 @@
473
473
  }
474
474
  if (!result.response.ok) {
475
475
  return emit({ ...state, status: 'partial',
476
- retryError: String(result.body.error || result.body.message || `The ${row.host} bridge retry was refused.`) });
476
+ retryError: String(personText(result.body) || result.body.message || `The ${row.host} bridge retry was refused.`) });
477
477
  }
478
478
  store(transaction);
479
479
  emit({ ...state, status: 'retrying', host: row.host, retryError: null });