@floless/app 0.125.0 → 0.125.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
@@ -7054,6 +7054,12 @@
7054
7054
  let previousRequestCount = 0;
7055
7055
  let previousRequestIds = null;
7056
7056
  let reqPulseTimer = null;
7057
+ let revealFlashTimer = null;
7058
+ let revealArriveCleanup = null;
7059
+ // The row still owed a highlight. Survives the list being closed, because a cue the user never saw
7060
+ // has not been delivered — cleared only once it has actually flashed on a visible list, or once the
7061
+ // request it names is gone.
7062
+ let pendingRevealId = null;
7057
7063
  async function loadRequests() {
7058
7064
  try {
7059
7065
  const { requests } = await api('/api/requests');
@@ -7324,7 +7330,7 @@
7324
7330
  ? '<span class="req-lifecycle" data-tip="This clears itself when your terminal AI finishes or fails the organize">finishing in your terminal</span>'
7325
7331
  : `<button class="req-del" data-id="${escapeAttr(r.id)}" data-tip="Clear this request">×</button>`;
7326
7332
  return `
7327
- <div class="req-item">
7333
+ <div class="req-item" data-id="${escapeAttr(r.id)}">
7328
7334
  <div class="req-info">
7329
7335
  <div class="req-head"><span class="${badgeCls}">${label}</span> ${owner ? `<span class="req-owner">${highlightQuery(owner, requestQuery)}</span>` : ''}${time}</div>
7330
7336
  <div class="req-instruction">${highlightQuery(instructionFor(r), requestQuery) || 'This request has no instruction, so it can’t be handed to your terminal AI. Clear it and queue it again.'}</div>
@@ -7392,7 +7398,7 @@
7392
7398
  }
7393
7399
  // Re-fetch before showing: there is no server `request-added` broadcast, so a request queued in
7394
7400
  // another tab (or by the Knowledge step) would otherwise render from a stale cache.
7395
- async function openRequests() {
7401
+ async function openRequests(targetId) {
7396
7402
  // Open on the scope + a clear search every time. A stuck "All" (or a leftover query) from a
7397
7403
  // previous visit would silently answer a different question than the one just asked.
7398
7404
  requestScopeAll = false;
@@ -7401,8 +7407,140 @@
7401
7407
  if ($search) $search.value = '';
7402
7408
  document.getElementById('requests-modal').classList.add('show');
7403
7409
  renderRequests(); // paint the cache immediately — no empty flash
7410
+ // Scroll off the CACHED paint, before the refetch. Gating the reveal on `/api/requests` means an
7411
+ // arbitrarily slow response leaves the list sitting at the top — precisely the state this feature
7412
+ // exists to prevent — and then jumping a beat later. Measured land-times ran 125ms to 1738ms, and
7413
+ // in one batch three of four opens had not revealed at all after 4s because the fetch had not
7414
+ // resolved. A long queue is both when the fetch is slowest (a thumbnail request per snapshot row
7415
+ // competes with it over HTTP/1.1's six connections) and when being at the top hurts most.
7416
+ // Scroll only: the flash belongs to the authoritative paint below, or the cached one would flash a
7417
+ // row the refresh is about to replace.
7418
+ revealRequestRow(targetId, true /* scrollOnly */);
7404
7419
  await loadRequests();
7420
+ // NOTHING here may touch requestScopeAll. Scoping the window to what you have open is a
7421
+ // deliberate decision (#633), and revealing a row is not a licence to override it: a reveal that
7422
+ // widened would answer a different question than the one asked, and the destructive verb is
7423
+ // downstream — `bulkClearPlan` reads the painted set, and when that set is the whole queue
7424
+ // "Clear all" takes the atomic DELETE /api/requests across every project. If the row we were
7425
+ // asked for is out of scope it simply is not revealed; the user's own scope tab stays the truth.
7405
7426
  renderRequests(); // then reconcile with the truth
7427
+ revealRequestRow(targetId); // …then put the row the user came for in view
7428
+ }
7429
+
7430
+ // The list is oldest-first (a contract two shipped skills document, and the order Copy all
7431
+ // concatenates in), so the request a user just queued is at the BOTTOM — measured off-screen past
7432
+ // about six entries. Both entry points therefore have to scroll, but they want different things:
7433
+ // "Open Requests" comes from the just-queued modal and means THAT row, while the requests chip is a
7434
+ // general "show me my queue" and simply wants the freshest activity in view.
7435
+ //
7436
+ // The chip scrolls too, rather than being left alone as "not the reported bug", because
7437
+ // showRequestQueuedModal has exactly one caller — the drawing-attach flow. Every other way to queue
7438
+ // something (the steel editor's Ask AI, ✎ Tweak, use-template) reports inline and never opens that
7439
+ // modal, so for those the chip is the ONLY route to the row you just created.
7440
+ //
7441
+ // targetId is not the same as "the last row": another tab, a poll, or a knowledge-organize can queue
7442
+ // something between the modal opening and the click, and then the last row is somebody else's.
7443
+ function revealRequestRow(targetId, scrollOnly) {
7444
+ const $list = document.getElementById('requests-list');
7445
+ if (!$list) return;
7446
+ const rows = Array.from($list.querySelectorAll('.req-item'));
7447
+ if (!rows.length) return;
7448
+ // An untargeted open (the chip) adopts a target still owed a highlight: closing the list before it
7449
+ // landed leaves pendingRevealId set, and the reopen — whenever it comes — is where the cue is
7450
+ // finally due. Consumed only once it has actually been SHOWN, so it cannot be spent invisibly.
7451
+ const wanted = targetId || pendingRevealId;
7452
+ const target = wanted ? rows.find((el) => el.dataset.id === wanted) : null;
7453
+ // The cached pass positions the list and touches NO state: it must not consume an owed cue, retire
7454
+ // one, or cancel a pending arrival on the strength of a paint that is about to be replaced.
7455
+ if (!scrollOnly) {
7456
+ // Stop owing a highlight for a request that is no longer in the queue at all — applied or cleared
7457
+ // while the list was closed. Without this the variable outlives its meaning, still reading as
7458
+ // "a row is owed" for a row that can never be shown again.
7459
+ if (pendingRevealId && !pendingRequests.some((r) => r && r.id === pendingRevealId)) pendingRevealId = null;
7460
+ // Supersede a reveal still waiting to land ONLY when this one will flash too, so a general
7461
+ // "show me my queue" never cancels a pending "show me THIS row".
7462
+ if (target && revealArriveCleanup) revealArriveCleanup();
7463
+ if (target) pendingRevealId = wanted;
7464
+ }
7465
+ const row = target || rows[rows.length - 1];
7466
+ // Whether a scroll will actually happen has to be decided BEFORE the call: `scroll-behavior:
7467
+ // smooth` makes the offset animate, so reading scrollTop afterwards still reports the old value.
7468
+ const lb = $list.getBoundingClientRect(), rb = row.getBoundingClientRect();
7469
+ // A row TALLER than the scrollport that already spans it counts as visible to Blink's `nearest`,
7470
+ // so scrollIntoView does not move and scrollend never fires — without this the flash would sit out
7471
+ // the full 2s guard on a row that was already showing. Rare: it needs a row of wrapped snapshot
7472
+ // thumbnails deeper than the whole list, and the list now flexes against the modal's 86vh cap.
7473
+ const coversPort = rb.top <= lb.top && rb.bottom >= lb.bottom;
7474
+ const willScroll = !coversPort && (rb.top < lb.top || rb.bottom > lb.bottom);
7475
+ // `block: 'nearest'` is a no-op when the row is already in the scrollport, and there is nothing to
7476
+ // scroll when the list doesn't overflow — so neither case needs a visibility check of its own.
7477
+ row.scrollIntoView({ block: 'nearest' });
7478
+ // Flash ONLY a row we actually found. If the request was applied or cleared between queuing and
7479
+ // clicking, we still scroll to the newest — but flashing it would be pointing at the wrong row.
7480
+ if (scrollOnly || !target) return;
7481
+
7482
+ // Start the flash when the row ARRIVES, not when the scroll starts. Chromium's smooth-scroll
7483
+ // duration grows with distance and is not capped near our 1.2s budget: measured on ~72px rows,
7484
+ // 60 rows takes 1065ms to land (leaving ~135ms of highlight) and 200 rows takes 1514ms, so the
7485
+ // animation is over before the row is on screen. That fails along exactly the axis this feature
7486
+ // exists for — the longer the queue, the more the user needs to be told which row is theirs.
7487
+ const flash = () => {
7488
+ // Re-resolve by id rather than reusing the captured node. Between the scroll starting and
7489
+ // `scrollend` firing, anything that re-renders the list — reopening it from the chip, an SSE
7490
+ // refresh — replaces innerHTML, and the captured row is then detached: the class would land on
7491
+ // an orphan and the user would see nothing at all. (Found by QA: open via Open Requests, Escape
7492
+ // at ~150ms, reopen from the chip — no highlight, 3/3.)
7493
+ // Never spend the cue on a hidden list. Hiding the modal mid-scroll stops `scrollend` from ever
7494
+ // firing, so the 2s guard is what runs — and without this it would flash an invisible row, mark
7495
+ // it delivered, and leave the user who reopens a moment later with nothing. Measured: reopen at
7496
+ // 2.5s saw no highlight. Returning early keeps pendingRevealId set, so the reopen shows it.
7497
+ const $modal = document.getElementById('requests-modal');
7498
+ if (!$modal || !$modal.classList.contains('show')) return;
7499
+ const row = Array.from($list.querySelectorAll('.req-item')).find((el) => el.dataset.id === wanted);
7500
+ if (!row) {
7501
+ // Absent from the PAINTED rows is not the same as gone. A search typed during the glide, or a
7502
+ // scope the row does not belong to, hides it while the request is alive and still owed a cue —
7503
+ // only stop owing it when it has genuinely left the queue.
7504
+ if (!pendingRequests.some((r) => r && r.id === wanted)) pendingRevealId = null;
7505
+ return;
7506
+ }
7507
+ pendingRevealId = null; // delivered — and only now, with the row on a visible list
7508
+ row.classList.remove('req-target-flash');
7509
+ void row.offsetWidth; // restart the animation if the same row is revealed twice
7510
+ row.classList.add('req-target-flash');
7511
+ // One timer, cleared before it is replaced — the same shape as reqPulseTimer above. Two reveals
7512
+ // inside 1.2s would otherwise leave the first timeout to fire against a row that is mid-flash
7513
+ // and cut the second short. Clears whichever row is flashing, not a captured node, because a
7514
+ // live re-render may have replaced it.
7515
+ if (revealFlashTimer) clearTimeout(revealFlashTimer);
7516
+ revealFlashTimer = setTimeout(() => {
7517
+ const still = document.querySelector('.req-item.req-target-flash');
7518
+ if (still) still.classList.remove('req-target-flash');
7519
+ revealFlashTimer = null;
7520
+ }, 1200);
7521
+ };
7522
+ if (!willScroll) { flash(); return; } // already in view — scrollend would never fire
7523
+ // `once` is not enough: scrollend does not fire if the scroll is interrupted (the user grabs the
7524
+ // wheel) or if the engine lacks it, and a highlight that never appears is the bug above again.
7525
+ let armed = true;
7526
+ const arrive = () => {
7527
+ if (!armed) return;
7528
+ armed = false;
7529
+ revealArriveCleanup = null;
7530
+ $list.removeEventListener('scrollend', arrive);
7531
+ clearTimeout(arriveGuard);
7532
+ flash();
7533
+ };
7534
+ $list.addEventListener('scrollend', arrive);
7535
+ const arriveGuard = setTimeout(arrive, 2000);
7536
+ // So a second reveal can drop the first: otherwise the earlier scrollend still fires and flashes
7537
+ // its row after the user has already moved on to another one.
7538
+ revealArriveCleanup = () => {
7539
+ armed = false;
7540
+ revealArriveCleanup = null; // so the variable actually means "a reveal is pending"
7541
+ $list.removeEventListener('scrollend', arrive);
7542
+ clearTimeout(arriveGuard);
7543
+ };
7406
7544
  }
7407
7545
 
7408
7546
  // ── Agents library: real installed agents + their commands ───────────────────
@@ -8878,8 +9016,11 @@
8878
9016
  const $requestHelpKeep = document.getElementById('request-help-keep');
8879
9017
  const $requestHelpCopy = document.getElementById('request-help-copy');
8880
9018
  if ($requestHelpOpen) $requestHelpOpen.onclick = () => {
9019
+ // Read the id BEFORE closing — this button means "take me to the one I just queued", and only
9020
+ // this entry point knows which that is.
9021
+ const id = requestHelpReq && requestHelpReq.id;
8881
9022
  closeRequestHelp({ restoreFocus: false });
8882
- openRequests();
9023
+ openRequests(id);
8883
9024
  };
8884
9025
  if ($requestHelpKeep) $requestHelpKeep.onclick = () => closeRequestHelp();
8885
9026
  if ($requestHelpCopy) $requestHelpCopy.onclick = async () => {
@@ -662,6 +662,21 @@ export const MODEL_V2_TOL = Object.freeze({
662
662
  RESIDUAL_REFUSE_MM: 6.35, // ...and above this is refused: beyond drafting drift = a different grid
663
663
  ROTATION_REFUSE_DEG: 0.05, // secondary ceiling (the binding gate is induced displacement)
664
664
  SCALE_REFUSE_FRAC: 0.002, // secondary ceiling, 0.2%
665
+
666
+ // How far a HAND-READ registration control may land from the grid intersection it names. These two are
667
+ // in DISPLAY POINTS, and that unit is the whole point (#590): a sheet's display px are PDF points —
668
+ // 1/72" of the PRINTED drawing — so a tolerance stated in them means the same thing at every drawing
669
+ // scale and on every size of building, which a tolerance in mm does not. At 1/4"=1'-0" one point is
670
+ // 33.87 mm on the ground, so judging a pixel pick by the 6.35 mm de-dup distance demanded 0.19 pt of
671
+ // reading accuracy and refused every photographed drawing ever read.
672
+ //
673
+ // They bound the pick, NOT the registration: the transform is fitted from the grid, so a pick within
674
+ // tolerance moves nothing. What they bound is the evidence — the picks are the only measurement that
675
+ // sees the drawing at all, and so the only check on `grid.origin` and `pt_per_ft`. Two picks a
676
+ // baseline apart therefore bound a scale error to ±(REFUSE_PT / baselinePt), which is why the reader
677
+ // skill tells the AI to choose the FURTHEST intersection: a longer baseline is a better measurement.
678
+ CONTROL_CHECK_REPORT_PT: 2, // 1/36" on the printed sheet — past ordinary reading error, worth saying
679
+ CONTROL_CHECK_REFUSE_PT: 9, // 1/8" on the printed sheet — nobody misses a grid bubble by this much
665
680
  });
666
681
 
667
682
  /** The §5.2a elevation union: `{known:mm}` | `{unknown:true, rfiRef?}`. */
@@ -793,6 +808,20 @@ export function registerSheet(input) {
793
808
 
794
809
  // Induced displacement is the BINDING gate: §5.2b's own 0.05 deg over the measured 19.4 m baseline
795
810
  // admits ~16.9 mm, against a 6.35 mm refusal in the same table. Angle and ratio are secondary ceilings.
811
+ //
812
+ // IT IS CHARGED OVER THE WHOLE EXTENT. Charging it only over the reach no sample verifies was written
813
+ // during #590 and reverted before it shipped, because it is wrong twice — recorded here so it is not
814
+ // re-invented. The reasoning was that a sample which AGREES has measured the fit out to its own
815
+ // distance, so the proxy should not be charged for that span as well. But (a) the reach is a scalar
816
+ // radius, and on a grid the second-farthest node is nearly as far as the farthest, so the annulus left
817
+ // to charge collapses and the budget grows with lattice density — measured |scale-1| up to 2e-3 at
818
+ // 10x7, past SCALE_REFUSE_FRAC, i.e. this stops being the binding gate the line above claims it is; and
819
+ // (b) the case it was meant to admit is exactly the case where the error is REAL. A PROPORTIONAL
820
+ // difference between two sheets' grid strings leaves `residualMm` at zero by construction — a
821
+ // similarity absorbs a uniform scale exactly — so induced displacement is the only guard there, and
822
+ // relaxing it let one physical column land 8.3 mm apart when read on two sheets, past DEDUP_MM, and be
823
+ // emitted TWICE with a clean `ok` and no reasons. The migration's per-axis extent collapse also cites
824
+ // this bound by name and would have been silently invalidated with it.
796
825
  const induced = (Math.abs(transform.rotationRad) + Math.abs(transform.scale - 1)) * extentMm;
797
826
  let verdict = 'ok';
798
827
  const report = (why) => { reasons.push(why); if (verdict === 'ok') verdict = 'report'; };
@@ -249,8 +249,29 @@ function init(canvas, theApi) {
249
249
  refMeasureLine = new THREE.Line(new THREE.BufferGeometry().setFromPoints([new THREE.Vector3(), new THREE.Vector3()]),
250
250
  new THREE.LineDashedMaterial({ color: 0x22d3ee, dashSize: 60, gapSize: 40 }));
251
251
  refMeasureLine.material.depthTest = false; refMeasureLine.renderOrder = 997; refMeasureLine.visible = false; scene.add(refMeasureLine);
252
+ /*
253
+ * THE FOUR MODEL-GLUED LABEL HOSTS SIT UNDER THE 3D CHROME, and the numbers below are the whole rule.
254
+ *
255
+ * Each is `position:fixed` on `<body>` and projected per frame, so it is painted in the ROOT stacking
256
+ * context (`#stagewrap` and `<main>` are `position:relative; z-index:auto`, which creates none) — it
257
+ * competes directly with the panels. They shipped at 56/57, above every panel, and a chip landing over
258
+ * the expanded Objects panel drew ON TOP of it: unreadable itself, and hiding a control the user was
259
+ * reading. Reported against the 3D property labels, but it was never theirs — the mark/id, dimension
260
+ * and member-length chips all shared it.
261
+ *
262
+ * A label is a READING OF THE MODEL and belongs with the model, under the chrome that frames it. So the
263
+ * band is BELOW the lowest piece of 3D chrome (`#m3dAxes`, z 5) and above the canvas (z auto):
264
+ * 3 member / property / selected-length labels
265
+ * 4 dimension labels — above the other three, which is the order they shipped with
266
+ * 5+ chrome: the triad, the Objects panel and view cube (6), the collapse chevrons (12) …
267
+ * `#m3dBar` was already at 59 — the toolbar had been lifted over the labels one at a time while the
268
+ * panels were not, which is exactly the inconsistency this replaces with one rule.
269
+ *
270
+ * NOT in this band, deliberately: `hoverChip` (a fixed bottom-centre readout, chrome by position) and
271
+ * `rubber` (a live drag overlay, which must cover everything it is drawn across).
272
+ */
252
273
  dimLabelHost = document.createElement('div');
253
- dimLabelHost.style.cssText = 'position:fixed;left:0;top:0;pointer-events:none;z-index:57';
274
+ dimLabelHost.style.cssText = 'position:fixed;left:0;top:0;pointer-events:none;z-index:4';
254
275
  document.body.appendChild(dimLabelHost);
255
276
  // …and its label, in the dim host so it is positioned by the same per-frame projection. The cssText is
256
277
  // the member-label chip's verbatim (cyan border = a dimension read); only `display` is ours to drive.
@@ -258,12 +279,12 @@ function init(canvas, theApi) {
258
279
  refMeasureLabel.style.cssText = 'position:absolute;transform:translate(-50%,-50%);pointer-events:none;background:var(--panel,#0f172a);color:#e2e8f0;border:1px solid #22d3ee;border-radius:4px;padding:1px 6px;font:11px system-ui;white-space:nowrap;box-shadow:0 1px 4px rgba(0,0,0,.4);display:none';
259
280
  dimLabelHost.appendChild(refMeasureLabel);
260
281
  memberLabelHost = document.createElement('div'); // member mark/id labels (Slice 4) — below the dim labels
261
- memberLabelHost.style.cssText = 'position:fixed;left:0;top:0;pointer-events:none;z-index:56;display:none';
282
+ memberLabelHost.style.cssText = 'position:fixed;left:0;top:0;pointer-events:none;z-index:3;display:none';
262
283
  document.body.appendChild(memberLabelHost);
263
284
  propLabelHost = document.createElement('div'); // right-click property labels — own host so they never clobber the mark/id pool
264
- propLabelHost.style.cssText = 'position:fixed;left:0;top:0;pointer-events:none;z-index:56;display:none';
285
+ propLabelHost.style.cssText = 'position:fixed;left:0;top:0;pointer-events:none;z-index:3;display:none';
265
286
  selLenLabelHost = document.createElement('div'); // ⋯ Display → Show member length: on-select length chips (cyan dimension read)
266
- selLenLabelHost.style.cssText = 'position:fixed;left:0;top:0;pointer-events:none;z-index:56;display:none';
287
+ selLenLabelHost.style.cssText = 'position:fixed;left:0;top:0;pointer-events:none;z-index:3;display:none';
267
288
  document.body.appendChild(selLenLabelHost);
268
289
  document.body.appendChild(propLabelHost);
269
290
  // persistent hover/selection status chip, bottom-centre of the canvas (mirrors the viewer's readout)
@@ -1878,8 +1899,13 @@ function syncMemberLabels() {
1878
1899
  }
1879
1900
  for (let i = 0; i < memberLabelPool.length; i++) {
1880
1901
  const el = memberLabelPool[i], m = ms[i];
1881
- if (!m || !Array.isArray(m.wp) || m.wp.length < 2) { el.style.display = 'none'; el._mid = null; continue; }
1882
- const g = geoOf(m);
1902
+ // ASK THE READ HALF FOR A WORK LINE, never for `m.wp` — the same repair the reference lines got in
1903
+ // P7d (see buildRefLines), applied to the two label pools that sweep missed. `wp` is a v1 STORAGE
1904
+ // shape; a v2 canonical member has `from`/`to`, so this guard skipped every member of a canonical
1905
+ // model and the toggle drew nothing at all. MEASURED in a real browser on a v2 document: both pools
1906
+ // allocated their divs and left every one `display:none` with empty text (#614).
1907
+ const g = m && geoOf(m);
1908
+ if (!g || !g.line) { el.style.display = 'none'; el._mid = null; continue; }
1883
1909
  el._mid = [(g.line[0][0] + g.line[1][0]) / 2, (g.line[0][1] + g.line[1][1]) / 2, (g.line[0][2] + g.line[1][2]) / 2];
1884
1910
  el.textContent = m.mark || m.id || '';
1885
1911
  el.style.display = 'block';
@@ -1922,8 +1948,10 @@ function syncPropLabels() {
1922
1948
  const byId = new Map(members().map((m) => [m.id, m]));
1923
1949
  for (let i = 0; i < propLabelPool.length; i++) {
1924
1950
  const el = propLabelPool[i], L = labels[i], m = L ? byId.get(L.id) : null;
1925
- if (!m || !Array.isArray(m.wp) || m.wp.length < 2 || !L.lines || !L.lines.length) { el.style.display = 'none'; el._mid = null; el._memberId = null; continue; }
1926
- const g = geoOf(m), a = g.line[0], b = g.line[1];
1951
+ // The work line, not `m.wp` — see syncMemberLabels above for why, and for what it measured.
1952
+ const g = (m && L.lines && L.lines.length) ? geoOf(m) : null;
1953
+ if (!g || !g.line) { el.style.display = 'none'; el._mid = null; el._memberId = null; continue; }
1954
+ const a = g.line[0], b = g.line[1];
1927
1955
  el._mid = place === 'start' ? a : place === 'end' ? b : [(a[0] + b[0]) / 2, (a[1] + b[1]) / 2, (a[2] + b[2]) / 2];
1928
1956
  el._memberId = m.id;
1929
1957
  el.textContent = L.lines.join('\n');