@floless/app 0.146.0 → 0.148.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.
@@ -4338,6 +4338,82 @@
4338
4338
  ));
4339
4339
  }
4340
4340
 
4341
+ /**
4342
+ * Work the Drawing Filter holds that is NOT saved, as the page's own guard reports it (#1781):
4343
+ * 'saving' while its writes are in flight, 'blocked' when the save or its approval was refused and the
4344
+ * Filter explains why, 'confirm' while its "Confirm what this read will dismiss" dialog waits for
4345
+ * Approve or Cancel, 'reload' when a required save failed and Save stays off until a reload,
4346
+ * 'unsaved' for edits nobody pressed Save on, and '' when nothing is pending.
4347
+ *
4348
+ * The Filter lives in a hidden iframe once the user moves to another step, so without this the strip
4349
+ * and the Model tab went on saying "The Drawing Filter is saved" over a save that was waiting on a
4350
+ * confirmation — and AI Chat, which reads the strip, repeated it. Everything that reads it is repainted
4351
+ * from `floless:filter-ai-changed`, which the Filter raises on each of these transitions.
4352
+ */
4353
+ function drawingFilterPendingSave() {
4354
+ const frame = frames.drawings;
4355
+ // A frame that never loaded holds no Filter work to report.
4356
+ if (!frame || !frame.dataset.loaded) return '';
4357
+ let state = '';
4358
+ try {
4359
+ const guard = frame.contentWindow && frame.contentWindow.__floGuard;
4360
+ // A frame still booting (or about:blank) has no guard yet, and so nothing pending.
4361
+ if (!guard || typeof guard.pendingSave !== 'function') return '';
4362
+ state = guard.pendingSave();
4363
+ } catch (err) {
4364
+ // A loaded Filter whose guard cannot be read is a defect, not an empty state. Say it once per
4365
+ // page: this runs on every repaint, and the strip then shows what it would without the Filter.
4366
+ if (!drawingFilterPendingSave.warned) {
4367
+ drawingFilterPendingSave.warned = true;
4368
+ console.error('Could not read whether the Drawing Filter has an unfinished save', err);
4369
+ }
4370
+ return '';
4371
+ }
4372
+ return drawingFilterPendingText(state) ? state : '';
4373
+ }
4374
+
4375
+ /**
4376
+ * The strip's sentence for each pending Filter save (heading · what to do next), or '' for any other
4377
+ * value; the Model tab's tooltip reuses it. Each one names only controls on screen in that state.
4378
+ */
4379
+ function drawingFilterPendingText(state) {
4380
+ switch (state) {
4381
+ case 'saving': return 'Saving the Drawing Filter · FloLess is writing your latest changes. This message clears when the save finishes.';
4382
+ case 'blocked': return 'Drawing Filter couldn’t finish saving · The Drawing Filter explains why and what to do next. Open Drawing Filter to read it.';
4383
+ case 'confirm': return 'Drawing Filter isn’t saved yet · A confirmation is waiting in Drawing Filter: choose Approve these exclusions to save, or Cancel to keep editing.';
4384
+ case 'reload': return 'Drawing Filter couldn’t finish saving · The save was refused, so Save filter is turned off. Open Drawing Filter, press Reload, review your selections, and press Save filter again.';
4385
+ case 'unsaved': return 'Drawing Filter has unsaved changes · Go to Drawing Filter and press Save filter to keep them.';
4386
+ default: return '';
4387
+ }
4388
+ }
4389
+
4390
+ /**
4391
+ * The Drawing Filter step tab carries the pending state too, so it is visible from every step: a static
4392
+ * dot (no pulse), a themed tooltip, and an accessible name that says it. aria-label rather than extra
4393
+ * text in the button, because the tab's text is its label everywhere else that reads it.
4394
+ */
4395
+ function paintDrawingFilterPendingTab(state) {
4396
+ const tab = $stepTabs && $stepTabs.querySelector('button[data-step="drawings"]');
4397
+ if (!tab) return;
4398
+ // [tooltip, what the accessible name adds]
4399
+ const copy = {
4400
+ saving: ['Saving the Drawing Filter', 'saving'],
4401
+ blocked: ['Not saved — open it to see why and what to do next', 'save could not finish'],
4402
+ confirm: ['Not saved yet — a confirmation is waiting here', 'not saved yet, a confirmation is waiting'],
4403
+ reload: ['Save failed — reload the Drawing Filter, then save again', 'save failed, reload needed'],
4404
+ unsaved: ['Unsaved changes — press Save filter to keep them', 'unsaved changes'],
4405
+ }[state];
4406
+ if (copy) {
4407
+ tab.setAttribute('data-filter-pending', state);
4408
+ tab.setAttribute('data-tip', copy[0]);
4409
+ tab.setAttribute('aria-label', `${tab.textContent.trim()}, ${copy[1]}`);
4410
+ } else if (tab.hasAttribute('data-filter-pending')) {
4411
+ tab.removeAttribute('data-filter-pending');
4412
+ tab.removeAttribute('data-tip');
4413
+ tab.removeAttribute('aria-label');
4414
+ }
4415
+ }
4416
+
4341
4417
  function appendStageGuidanceFilterAction() {
4342
4418
  if (!$stageGuidance || $stageGuidance.querySelector('[data-revfilter]')) return;
4343
4419
  const actions = document.createElement('div');
@@ -4354,9 +4430,59 @@
4354
4430
  markScrollable($stageGuidance);
4355
4431
  }
4356
4432
 
4433
+ /**
4434
+ * The control inside the Drawing Filter that answers its unfinished save (#1781), or null when Save
4435
+ * itself is the next action. The sign-off dialog shows Cancel + Approve while it waits, but only
4436
+ * Close (and Reload, where the work is saved) once a refusal replaced them — so take the first one
4437
+ * actually on screen. A refusal the person already closed is reopened by the status chip, and a
4438
+ * reload-only failure by the Reload button on the bar at the bottom of the Filter.
4439
+ */
4440
+ function drawingFilterPendingTarget(doc, state) {
4441
+ if (state === 'confirm' || state === 'blocked') {
4442
+ const overlay = doc.getElementById('signoffOverlay');
4443
+ if (overlay && !overlay.hidden) {
4444
+ return ['signoffCancel', 'signoffClose', 'signoffReload']
4445
+ .map((id) => doc.getElementById(id))
4446
+ .find((button) => button && !button.hidden && !button.disabled) || null;
4447
+ }
4448
+ const chip = doc.getElementById('saved');
4449
+ return state === 'blocked' && chip && chip.getAttribute('role') === 'button' ? chip : null;
4450
+ }
4451
+ if (state === 'reload') return doc.querySelector('#conflictBanner [data-command-id="filter.reload"]');
4452
+ return null;
4453
+ }
4454
+
4455
+ /**
4456
+ * "Open Drawing Filter" everywhere it appears (the strip and the revision card): go to the Filter
4457
+ * and focus its next required action — a waiting confirmation or refusal first, because the page
4458
+ * is inert behind that dialog; otherwise Save (or the sentence saying why Save is off).
4459
+ */
4460
+ function openDrawingFilterNextAction() {
4461
+ // The strip is on every step, and the Filter it points at is a hidden frame on all but one.
4462
+ if (currentStep !== 'drawings') setStep('drawings');
4463
+ const state = drawingFilterPendingSave();
4464
+ if (state && state !== 'unsaved' && state !== 'saving') {
4465
+ try {
4466
+ const child = frames.drawings.contentWindow;
4467
+ const target = drawingFilterPendingTarget(child.document, state);
4468
+ if (target) {
4469
+ child.focus();
4470
+ target.focus();
4471
+ // Focus can silently fail (a control hidden a moment ago, a frame not yet shown); only a
4472
+ // focus that actually landed counts, otherwise fall through to the ordinary route below.
4473
+ if (child.document.activeElement === target) return;
4474
+ }
4475
+ } catch (err) {
4476
+ console.error('Could not move focus to the Drawing Filter’s waiting action', err);
4477
+ }
4478
+ }
4479
+ focusDrawingFilterSave();
4480
+ }
4481
+
4357
4482
  function wireStageGuidanceFilterAction() {
4358
4483
  $stageGuidance?.addEventListener('click', (e) => {
4359
- if (e.target.closest('[data-revfilter]')) focusDrawingFilterSave();
4484
+ if (!e.target.closest('[data-revfilter]')) return;
4485
+ openDrawingFilterNextAction();
4360
4486
  });
4361
4487
  }
4362
4488
 
@@ -4530,7 +4656,12 @@
4530
4656
  if (waitingForInitial && revCardReq?.preparationState === 'blocked') return 'FloLess could not finish drawing preparation. Restart FloLess, then open Requests and follow the detailed instructions if it remains blocked.';
4531
4657
  if (waitingForInitial && revCardReq?.preparationState === 'manifest-published' && !revCardReq?.prepassReady) return `Drawing preparation is complete and saved. Return to the same ${readSessionName(revCardReq)} and tell it to continue creating the Drawing Filter.`;
4532
4658
  if (waitingForInitial && revCardReq?.filterSaveContinuation?.state === 'recovery-needed') return `The Drawing Filter needs attention. ${savedFilterNextStep(revCardReq)}`;
4533
- if (waitingForInitial && revCardReq?.filterCheckpointCurrent) return `The Drawing Filter is saved. ${savedFilterNextStep(revCardReq)}`;
4659
+ if (waitingForInitial && revCardReq?.filterCheckpointCurrent) {
4660
+ // The EARLIER save is on record, but the Filter now holds a newer one nobody has finished (#1781).
4661
+ const pendingSave = drawingFilterPendingSave();
4662
+ if (pendingSave) return drawingFilterPendingText(pendingSave).replace(' · ', '. ');
4663
+ return `The Drawing Filter is saved. ${savedFilterNextStep(revCardReq)}`;
4664
+ }
4534
4665
  if (waitingForInitial && revCardReq?.prepassReady) return `Check steel, member marks, grids, dimensions, and relevant callouts. Ask in AI Chat on the left if you need help. ${readyFilterNextStep(revCardReq)}`;
4535
4666
  if (waitingForInitial && revCardReq?.preparationRetryable) return `Steel Filter preparation was interrupted. Your drawings are still attached. Return to the same ${readSessionName(revCardReq)} and retry preparation for this same request.`;
4536
4667
  if (waitingForInitial) return `The initial drawing read is waiting for ${readRunsInChat(revCardReq) ? 'AI Chat' : 'your terminal AI'}. The model unlocks after you review the Drawing Filter and press Save filter.`;
@@ -4556,6 +4687,7 @@
4556
4687
  b.removeAttribute('data-blocked-reason');
4557
4688
  b.setAttribute('tabindex', '0');
4558
4689
  });
4690
+ paintDrawingFilterPendingTab('');
4559
4691
  clearStageGuidance();
4560
4692
  return;
4561
4693
  }
@@ -4581,19 +4713,32 @@
4581
4713
  b.setAttribute('tabindex', '0');
4582
4714
  }
4583
4715
  });
4716
+ // After the loop, which clears every unlocked tab's tooltip — the Drawing Filter tab is never locked.
4717
+ // Before the redirect below, so the tab the person is sent to already carries the pending save.
4718
+ const pendingSave = drawingFilterPendingSave();
4719
+ paintDrawingFilterPendingTab(pendingSave);
4584
4720
  // A project opened on the old default Model step can become gated when the lifecycle probe
4585
4721
  // returns. Move it to the first actionable stage instead of leaving a locked tab selected.
4586
4722
  if (currentStep !== 'drawings' && stageGateFor(currentStep)) {
4587
4723
  setStep('drawings');
4588
4724
  return;
4589
4725
  }
4726
+ // The strip always speaks for a save waiting on the person (confirm), refused (blocked) or needing a
4727
+ // reload (reload). Plain unsaved edits it reports only where it would otherwise call the Filter saved:
4728
+ // before the first Save its own guidance already says to press Save filter. A save in flight it also
4729
+ // reports while a stage is locked — that same guidance would otherwise say to press a Save filter the
4730
+ // first save has just disabled — but not in a modelled project, where it would flash on every press.
4731
+ const stripPending = pendingSave === 'confirm' || pendingSave === 'blocked' || pendingSave === 'reload'
4732
+ || ((pendingSave === 'unsaved' || pendingSave === 'saving') && !!revCardReq?.filterCheckpointCurrent)
4733
+ || (pendingSave === 'saving' && locked)
4734
+ ? pendingSave : '';
4590
4735
  if (!$stageGuidance) return;
4591
4736
  const initialRead = revCardReq && isInitialRevisionRead(revCardReq);
4592
4737
  const waitingForInitial = initialRead && lastRevState === 'pending';
4593
4738
  const stagedInitial = initialRead && lastRevState === 'staged';
4594
4739
  const failedInitial = initialRead && lastRevState === 'failed';
4595
4740
  const unavailableInitial = initialRead && lastRevState === 'unavailable';
4596
- if (!locked) {
4741
+ if (!locked && !stripPending) {
4597
4742
  clearStageGuidance();
4598
4743
  return;
4599
4744
  }
@@ -4619,6 +4764,17 @@
4619
4764
  paintStageGuidance(liveProgress);
4620
4765
  return;
4621
4766
  }
4767
+ // An unfinished Filter save (being written, waiting on its confirmation, refused, needing a reload,
4768
+ // or never pressed) outranks every sentence below — the one they would otherwise show here is "The
4769
+ // Drawing Filter is saved" (#1781). Live progress above still wins: a read already running works from
4770
+ // the EARLIER save, and hiding it would say less.
4771
+ if (stripPending) {
4772
+ const stripState = stripPending === 'blocked' || stripPending === 'reload' ? 'failed'
4773
+ : stripPending === 'saving' ? 'active' : 'waiting';
4774
+ paintStageGuidance(drawingFilterPendingText(stripPending), stripState);
4775
+ appendStageGuidanceFilterAction();
4776
+ return;
4777
+ }
4622
4778
  const guidance = stagedInitial
4623
4779
  ? 'The drawing read is complete · Open Drawing Filter and choose Review changes before moving to Model, Exports, or History.'
4624
4780
  : failedInitial
@@ -10400,6 +10556,10 @@
10400
10556
  } catch { /* the loaded child is not ready/same-origin — navigate to the authoritative target */ }
10401
10557
  frame.src = frame.dataset.want;
10402
10558
  }
10559
+ // #1781: the Filter raises this on every unsaved / waiting-for-confirmation / saved transition. The strip,
10560
+ // the Drawing Filter tab and the Model tab's tooltip all read that state, so repaint them now rather
10561
+ // than at the next three-second poll — or never, on a step that has no poll running.
10562
+ window.addEventListener('floless:filter-ai-changed', () => { if (current) applyStageGating(); });
10403
10563
  frames.drawings.addEventListener('load', () => {
10404
10564
  requestAnimationFrame(() => {
10405
10565
  reconcileDrawingRevisionRequestAfterLoad();
@@ -10491,7 +10651,8 @@
10491
10651
  const copyButton = e.target.closest('[data-revcopy]');
10492
10652
  await copyRevisionCardRequest(req, copyButton);
10493
10653
  } else if (e.target.closest('[data-revfilter]')) {
10494
- focusDrawingFilterSave();
10654
+ // The same destination as the strip's button, so its narration is true on both (#1781).
10655
+ openDrawingFilterNextAction();
10495
10656
  } else if (e.target.closest('[data-revdismiss]')) {
10496
10657
  await dismissFailedRevision(req);
10497
10658
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floless/app",
3
- "version": "0.146.0",
3
+ "version": "0.148.0",
4
4
  "type": "module",
5
5
  "description": "Thin localhost host for floless.app — serves web/ and shells the aware CLI. No engine, no LLM.",
6
6
  "bin": {