@floless/app 0.125.0 → 0.126.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.
@@ -1607,7 +1607,7 @@
1607
1607
  hostReadinessStates = {};
1608
1608
  renderReadinessState = null;
1609
1609
  track('workspace_project_opened', { app: p.app }); // a real open (card click or post-create landing)
1610
- lastRevState = 'none'; stopRevisionPoll(); closeRevReview(); // fresh project — drop any prior revision-poll state and any open review
1610
+ resetRevisionState(); closeRevReview(); // fresh project — drop any prior revision state and any open review
1611
1611
  // …and any open CONVERSION, for the same reason. The header project combo reaches `openProject`
1612
1612
  // without going through `closeProject`, so switching projects under an open migrate modal would
1613
1613
  // otherwise leave it on screen bound to `migState.projectId` — the project just navigated away
@@ -1679,7 +1679,7 @@
1679
1679
  exportState = null;
1680
1680
  hostReadinessStates = {};
1681
1681
  renderReadinessState = null;
1682
- stopRevisionPoll();
1682
+ resetRevisionState();
1683
1683
  stopKnowledgePoll(); kbCloseConfirm(); kbResetViewer(); knowledgeState = null; // the KB pane is per-project — never carry it across
1684
1684
  // A STAGED REVIEW IS PER-PROJECT TOO, and the line above is the precedent. Without this the modal
1685
1685
  // survived leaving the project: it kept rendering the old project's proposals over the landing, and
@@ -1698,7 +1698,7 @@
1698
1698
  // Reset with the rest of the per-project state — this file resets `histDiffSupported` for exactly
1699
1699
  // this reason. Bumping the generation also voids any probe still in flight for the closing project.
1700
1700
  exportsHasModel = true; modelPresenceGen++;
1701
- lastRevState = 'none'; $revisionCard.hidden = true; closeProjMenu(); applyMode(); syncWorkspaceGuide();
1701
+ closeProjMenu(); applyMode(); syncWorkspaceGuide(); // revision state cleared by resetRevisionState() above
1702
1702
  }
1703
1703
  document.getElementById('ws-back').addEventListener('click', closeProject);
1704
1704
 
@@ -5250,9 +5250,41 @@
5250
5250
  // no SSE hook — and refreshes History on completion. Cards are DOM-built (textContent, never
5251
5251
  // innerHTML) so an AI-supplied error string can never reach the DOM as markup.
5252
5252
  let lastRevState = 'none';
5253
- let revBaseVersion = 0; // the ledger head captured at attach — success = the head advances past it
5253
+ let revBaseVersion = 0; // the ledger head captured at attach — success = the head advances past it
5254
+ let revBaseProject = null; // …and WHICH project it was captured in; a baseline means nothing anywhere else
5254
5255
  let revCardReq = null;
5255
5256
  let revisionPoll = null;
5257
+ let revisionGen = 0; // bumped per render AND by openProject/closeProject — see renderRevisionCard
5258
+ let revRequestsFailed = false; // one log per outage, not one per 3-second poll tick
5259
+ /**
5260
+ * Every piece of revision state above is PER-PROJECT, so opening or closing one must clear all of
5261
+ * it — and until this existed only `lastRevState` was. What the other three left behind:
5262
+ *
5263
+ * - `$revisionCard` / `revCardReq`: `openProject` never touched the card, and the only thing that
5264
+ * used to wipe it on a switch was the stale render carrying on with the new project as `current`
5265
+ * — the very bug the guards in `renderRevisionCard` now stop. So the clearing has to be explicit
5266
+ * here, or one failed `/api/requests` for the newly opened project leaves the OLD project's card
5267
+ * standing over it with live buttons: "Review changes" resolving a foreign request id, "Dismiss"
5268
+ * DELETING the previous project's pending read.
5269
+ *
5270
+ * `revBaseVersion` is deliberately NOT reset here, and the reason is worth stating because zeroing
5271
+ * it looks like the same tidy-up. The completion check is `tip.n > revBaseVersion`, and its job (see
5272
+ * the comment at the check) is to keep a bare request DELETE — Dismiss, or the footer's Clear all —
5273
+ * from claiming a read completed. Zeroing on every open turns that into `tip.n > 0`, which ANY
5274
+ * previously committed revision-read satisfies: switch away and back, clear the request from a
5275
+ * second tab, and the card announces a completion that never happened and re-locks exports.
5276
+ * Scoping the baseline to the project it was captured in (`revBaseProject`) fixes the cross-project
5277
+ * miss without widening that window — an unknown project falls back to 0, exactly as a cold page
5278
+ * load always has.
5279
+ */
5280
+ function resetRevisionState() {
5281
+ lastRevState = 'none';
5282
+ revCardReq = null;
5283
+ revisionGen++; // voids any render still in flight for the project being left
5284
+ stopRevisionPoll();
5285
+ $revisionCard.hidden = true;
5286
+ $revisionCard.replaceChildren();
5287
+ }
5256
5288
  const isInitialRevisionRead = (req) => !req || !req.baseVersion || req.baseVersion <= 0;
5257
5289
  function stopRevisionPoll() { if (revisionPoll) { clearInterval(revisionPoll); revisionPoll = null; } }
5258
5290
  function startRevisionPoll() {
@@ -5298,6 +5330,7 @@
5298
5330
  if (bridge.loadRequests) bridge.loadRequests().catch(() => {}); // refresh the footer Requests popover
5299
5331
  if (current !== proj) return; // switched away while posting — don't drive the wrong project's card/poll
5300
5332
  revBaseVersion = (req && typeof req.baseVersion === 'number') ? req.baseVersion : 0;
5333
+ revBaseProject = proj.id; // the baseline belongs to THIS project — see resetRevisionState
5301
5334
  showToast(`${revBaseVersion <= 0 ? 'Initial' : 'Revised'} set queued — ${files.length} file${files.length > 1 ? 's' : ''} for your terminal AI`, 'ok');
5302
5335
  lastRevState = 'pending';
5303
5336
  startRevisionPoll();
@@ -5349,10 +5382,34 @@
5349
5382
  }
5350
5383
 
5351
5384
  async function renderRevisionCard() {
5352
- if (!current) { $revisionCard.hidden = true; return; }
5385
+ // GENERATION, not just the captured object — the idiom `refreshModelPresence`/`refreshApprovalState`
5386
+ // already use here, and for the reason `closeProject` bumps THEIR counters: a *close* has to void an
5387
+ // in-flight render, and comparing the project alone cannot see one. `openProject` re-uses the cached
5388
+ // `projects` entry, so closing a project and re-opening it hands back the SAME object — an identity
5389
+ // check passes and the stale render carries on. Bumping per render also settles two renders racing
5390
+ // for one project (the 3s poll can start a second while the first is still out): newest wins.
5391
+ const gen = ++revisionGen;
5392
+ const proj = current;
5393
+ if (!proj) { $revisionCard.hidden = true; return; }
5353
5394
  let reqs = [];
5354
- try { const b = await api('/api/requests'); reqs = Array.isArray(b) ? b : (b.requests || []); } catch { return; }
5355
- const mine = reqs.filter((r) => r && r.type === 'revision-read' && r.project === current.id);
5395
+ // ONCE PER OUTAGE, not once per tick. This runs on a 3-second poll, so an unguarded log turns a
5396
+ // server restart into a wall of red — the same "every open logs an error" noise #600 was written
5397
+ // to remove, and enough to fail the console-clean bar every E2E is held to. Silence was still
5398
+ // wrong (a stuck card had no trace at all), so the first failure speaks and the recovery resets it.
5399
+ try {
5400
+ const b = await api('/api/requests');
5401
+ reqs = Array.isArray(b) ? b : (b.requests || []);
5402
+ revRequestsFailed = false;
5403
+ } catch (e) {
5404
+ if (!revRequestsFailed) console.error('[workspaces] could not load requests for the revision card', e);
5405
+ revRequestsFailed = true;
5406
+ return;
5407
+ }
5408
+ // Superseded while the requests were in flight. Everything past here reads the project and paints
5409
+ // the ONE shared card, so resuming would either throw on a null `current` (the Workspaces
5410
+ // breadcrumb, mid-poll) or paint the old project's revision state over the newly opened one.
5411
+ if (gen !== revisionGen || !current || current.id !== proj.id) return;
5412
+ const mine = reqs.filter((r) => r && r.type === 'revision-read' && r.project === proj.id);
5356
5413
  const failed = mine.find((r) => r.status === 'failed');
5357
5414
  const staged = mine.find((r) => r.status === 'staged');
5358
5415
  const pending = mine.find((r) => r.status === 'pending');
@@ -5364,23 +5421,35 @@
5364
5421
  // must NOT show a false "complete" toast or re-lock exports.
5365
5422
  if (lastRevState === 'pending' && state === 'none') {
5366
5423
  let vr;
5367
- try { vr = await api(`/api/projects/${encodeURIComponent(current.id)}/versions`); }
5368
- catch { return; } // transient — leave lastRevState 'pending'; the poll retries next tick
5424
+ try { vr = await api(`/api/projects/${encodeURIComponent(proj.id)}/versions`); }
5425
+ catch (e) { console.error('[workspaces] could not read versions to confirm the revision read', e); return; }
5426
+ // ^ transient — leave lastRevState 'pending'; the poll retries next tick.
5427
+ // THIS one is not transient and does not retry: `openProject`/`closeProject` have already reset
5428
+ // `lastRevState` and stopped the poll, so the pending→none EDGE below is gone for good and the
5429
+ // completion toast for `proj` is DROPPED, not deferred. That is the deliberate trade — the
5430
+ // alternative, which is what shipped before, was to fire "Revision read complete" while another
5431
+ // project is on screen and clear ITS `approvedAt`, attributing one project's read to another.
5432
+ if (gen !== revisionGen || !current || current.id !== proj.id) return;
5369
5433
  const tip = (vr.versions || [])[0];
5370
- if (tip && tip.kind === 'revision-read' && tip.n > revBaseVersion) {
5371
- current.approvedAt = vr.approvedAt || undefined; // the AI read cleared the sign-off (exports re-lock)
5434
+ // A baseline captured in ANOTHER project says nothing about this one's ledger, and reading it as
5435
+ // though it did suppressed real completions (attach at head 12 there, a read commits at 4 here —
5436
+ // `4 > 12` is false, so no toast, no re-lock, no repaint, and nothing said). Unknown falls back
5437
+ // to 0, which is what a cold page load has always used.
5438
+ const base = revBaseProject === proj.id ? revBaseVersion : 0;
5439
+ if (tip && tip.kind === 'revision-read' && tip.n > base) {
5440
+ proj.approvedAt = vr.approvedAt || undefined; // the AI read cleared the sign-off (exports re-lock)
5372
5441
  // A model may have just come into existence, and the repaints below fire only for the VISIBLE
5373
5442
  // pane — which on the drop-a-drawing flow is Drawings, neither of them. Without this the header
5374
5443
  // stays gated, telling the user to read a drawing they just finished reading. (approveProject
5375
5444
  // re-probes so the ACTION is never blocked; this stops the chrome lying in the meantime.)
5376
- refreshModelPresence(current.id, current.app).catch(() => { /* header stays as-is */ });
5445
+ refreshModelPresence(proj.id, proj.app).catch(() => { /* header stays as-is */ });
5377
5446
  // AND the approval state, which model presence alone no longer covers. Before "not reviewable"
5378
5447
  // was told apart from "the probe failed", an empty project sat in the ERROR state here and the
5379
5448
  // header's click-to-retry quietly repaired it on the next click. That retry is gone by design —
5380
5449
  // it cannot help a project that is simply too old — so the read completing, which is the event
5381
5450
  // that just made `no-contract` false, has to say so itself. Without this the header keeps
5382
5451
  // telling someone to read a drawing they have this second finished reading.
5383
- refreshApprovalState(current.id).catch((e) => console.error('[workspaces] approval header did not refresh after the read', e));
5452
+ refreshApprovalState(proj.id).catch((e) => console.error('[workspaces] approval header did not refresh after the read', e));
5384
5453
  if (!$wsHistory.hidden) renderHistory();
5385
5454
  // …and the Exports pane, if it is the one showing. "Exports re-lock" was the intent, but
5386
5455
  // nothing repainted them: the pane kept its live buttons and its per-destination Details
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floless/app",
3
- "version": "0.125.0",
3
+ "version": "0.126.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": {
@@ -28,6 +28,7 @@
28
28
  "verify:skill-versions": "node build/verify-skill-versions.mjs",
29
29
  "verify:skill-parity": "node build/verify-skill-parity.mjs",
30
30
  "verify:flo": "node build/verify-flo-descriptions.mjs",
31
+ "verify:aisc": "node build/verify-aisc-table.mjs",
31
32
  "verify:flo-naming": "node build/verify-flo-naming.mjs",
32
33
  "verify:no-title": "node build/verify-no-title.mjs",
33
34
  "verify:no-native-select": "node build/verify-no-native-select.mjs",