@floless/app 0.164.0 → 0.166.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.
@@ -843,6 +843,7 @@
843
843
  { key: 'knowledge', label: 'Knowledge' }, // KB is project-level — every workspace app gets it
844
844
  { key: 'drawings', label: 'Source' }, // reuse the 'drawings' frame slot; label "Source"
845
845
  { key: 'model', label: 'Traced' }, // reuse the 'model' frame slot; label "Traced"
846
+ { key: 'rfis', label: 'RFIs' }, // #2470 R6.6d: owner ruling 2026-10-29, right after the model step
846
847
  { key: 'pages', label: 'Pages' }, // #2262: stored, versioned HTML Pages; #2568: just before Exports (both are output)
847
848
  { key: 'exports', label: 'Exports' },
848
849
  { key: 'workflows', label: 'Workflows' }, // #2470 R6.2b: the workflows this project owns; owner ruling 2026-10-29, right after Exports
@@ -876,6 +877,7 @@
876
877
  { key: 'knowledge', label: 'Knowledge' },
877
878
  { key: 'drawings', label: 'Source' },
878
879
  { key: 'model', label: 'Model' },
880
+ { key: 'rfis', label: 'RFIs' }, // #2470 R6.6d: owner ruling 2026-10-29, right after the model step
879
881
  { key: 'pages', label: 'Pages' }, // #2262: stored, versioned HTML Pages (every app)
880
882
  // #2470 R6.2b: the workflows this project owns. Owner ruling 2026-10-29, "After Pages, before History": History closes the row.
881
883
  { key: 'workflows', label: 'Workflows' },
@@ -906,6 +908,7 @@
906
908
  { key: 'knowledge', label: 'Knowledge' },
907
909
  { key: 'drawings', label: 'Source' },
908
910
  { key: 'model', label: 'Model' },
911
+ { key: 'rfis', label: 'RFIs' }, // #2470 R6.6d: owner ruling 2026-10-29, right after the model step
909
912
  { key: 'pages', label: 'Pages' }, // #2262: stored, versioned HTML Pages (every app)
910
913
  // #2470 R6.2b: the workflows this project owns. Owner ruling 2026-10-29, "After Pages, before History": History closes the row.
911
914
  { key: 'workflows', label: 'Workflows' },
@@ -972,6 +975,7 @@
972
975
  steps: [
973
976
  { key: 'knowledge', label: 'Knowledge' }, // the client's standards are knowledge, as for every app
974
977
  { key: 'model', label: 'Checker' },
978
+ { key: 'rfis', label: 'RFIs' }, // #2470 R6.6d: owner ruling 2026-10-29, right after the model step
975
979
  { key: 'pages', label: 'Pages' }, // #2262: stored, versioned HTML Pages (every app)
976
980
  // #2470 R6.2b: the workflows this project owns. Owner ruling 2026-10-29, "After Pages, before History": History closes the row.
977
981
  { key: 'workflows', label: 'Workflows' },
@@ -1335,6 +1339,15 @@
1335
1339
  reads as a different pane rather than the same one in a different state. */
1336
1340
  const HIST_HEAD = '<div class="step-head"><span>History</span></div>';
1337
1341
 
1342
+ // #2470 R6.5b: a module project's History step has two views, its approval ledger ('approvals', the default) and its
1343
+ // activity journal ('activity'), chosen with the switch at the end of the step row. The choice holds while the same
1344
+ // project stays open; another project opens on Approvals, the view of record. Plan 2026-10-30-2470-r6-5b-module-journal-PLAN.md.
1345
+ let historyView = { project: null, view: 'approvals' };
1346
+ const historyViewKey = (project) => `${project.id}|${String(project.uuid || '').toLowerCase()}`;
1347
+ /** Whether kind `d`'s History step has the two views: it is the approval ledger's `history` step (a module kind). */
1348
+ function hasHistoryViews(d) { return !!d?.steps?.some((x) => x.key === 'history'); }
1349
+ const APPROVALS_TIP = 'Approved versions, saved work and rollback.';
1350
+
1338
1351
  /**
1339
1352
  * The server's own plain-English refusal for a project that cannot be signed off at all, or `''`
1340
1353
  * when approval is merely unavailable for the moment (loading, a failed probe, nothing read yet).
@@ -2088,11 +2101,11 @@
2088
2101
  || !['available', 'unavailable'].includes(registration.status)) {
2089
2102
  throw new Error('The project view no longer matches this registration.');
2090
2103
  }
2091
- const wasUnits = cached.displayUnits === 'mm' ? 'mm' : 'ft-in';
2104
+ const wasUnits = (cached?.displayUnits === 'mm' || cached?.displayUnits === 'ft-in' ? cached.displayUnits : cached?.environment === 'UK' ? 'mm' : 'ft-in');
2092
2105
  const wasApproved = cached.approvedAt;
2093
2106
  const wasSortKeys = { name: cached.name, createdAt: cached.createdAt, updatedAt: cached.updatedAt };
2094
2107
  Object.assign(cached, fresh, {
2095
- displayUnits: fresh.displayUnits === 'mm' ? 'mm' : 'ft-in',
2108
+ displayUnits: (fresh?.displayUnits === 'mm' || fresh?.displayUnits === 'ft-in' ? fresh.displayUnits : fresh?.environment === 'UK' ? 'mm' : 'ft-in'),
2096
2109
  registrationState: registration.status,
2097
2110
  registrationRevision: registration.entryRevision,
2098
2111
  registrationReason: registration.reason,
@@ -2284,7 +2297,7 @@
2284
2297
  // that never had a unit choice arrives as `undefined` — and assigning that raw made the
2285
2298
  // `!==` test true on every `projects-changed`, discarding the server's `exportUnits` and
2286
2299
  // repainting for nothing. (Review round 5.)
2287
- const freshUnits = mine.displayUnits === 'mm' ? 'mm' : 'ft-in';
2300
+ const freshUnits = (mine?.displayUnits === 'mm' || mine?.displayUnits === 'ft-in' ? mine.displayUnits : mine?.environment === 'UK' ? 'mm' : 'ft-in');
2288
2301
  const freshName = typeof mine.name === 'string' ? mine.name : current.name;
2289
2302
  if (current && current.id === id && current.name !== freshName) {
2290
2303
  current.name = freshName;
@@ -3512,6 +3525,15 @@
3512
3525
  // read-only source chrome, the secure editor session and the /api/{revit,tekla}-projects endpoints.
3513
3526
  // `serverAuthorizedOnly` is NOT this: Drawing Checker is server-authorized and has no model source.
3514
3527
  const isModelSourceProject = (project = current) => isTeklaParserProject(project) || isRevitProject(project);
3528
+ /**
3529
+ * Whether a project opened on `step` waits for its model before the step is shown. #2470 R6.6d: RFIs waits only where
3530
+ * the editor hosts them (Steel); on every other kind the RFIs step is the shell's own and opens before there is a
3531
+ * source or model (owner ruling 2026-10-29, "Always open").
3532
+ */
3533
+ function waitsForModelOnOpen(d, project, step) {
3534
+ return !!(d.filter || isModelSourceProject(project)) && ['model', 'rfis', 'exports', 'history'].includes(step)
3535
+ && (step !== 'rfis' || !!d.rfisInEditor);
3536
+ }
3515
3537
  $revitReplace?.addEventListener('click', async () => {
3516
3538
  const project = current;
3517
3539
  if (!project) return;
@@ -3875,9 +3897,20 @@
3875
3897
  else localStorage.removeItem(PROJECT_CHAT_INTAKE_KEY);
3876
3898
  }
3877
3899
 
3878
- function setProjectSetupError(message, { workspaceAction = false } = {}) {
3900
+ function setProjectSetupError(message, { workspaceAction = false, withoutLinkAction = null } = {}) {
3879
3901
  $projectSetupError.hidden = !message;
3880
3902
  $projectSetupError.textContent = message || '';
3903
+ // #2470 R6.7b: a link to the General project that can't be made is a choice, never a refusal.
3904
+ if (message && withoutLinkAction) {
3905
+ const action = document.createElement('button');
3906
+ action.type = 'button';
3907
+ action.className = 'project-setup-error-action';
3908
+ action.textContent = 'Create without linking';
3909
+ action.setAttribute('data-command-id', 'shell.project-setup-without-link');
3910
+ action.setAttribute('data-tip', 'Creates the project and starts its chat without linking it. You can link it later from the General project’s Modules step.');
3911
+ action.addEventListener('click', withoutLinkAction);
3912
+ $projectSetupError.append(' ', action);
3913
+ }
3881
3914
  if (message && workspaceAction) {
3882
3915
  const action = document.createElement('button');
3883
3916
  action.type = 'button';
@@ -3891,6 +3924,24 @@
3891
3924
  }
3892
3925
  }
3893
3926
 
3927
+ /**
3928
+ * #2470 R6.7b: why the General project can't take the link now, named the way the person knows it, and the choice. The
3929
+ * server's sentence is kept only where it already says what to do (a busy project says to wait).
3930
+ */
3931
+ function projectSetupLinkChoiceMessage(state, code, serverText) {
3932
+ const general = state.linkFrom?.name ? `“${state.linkFrom.name}”` : 'The General project';
3933
+ const why = {
3934
+ 'project-archived': `${general} was archived, so it can’t take the link.`,
3935
+ 'project-not-found': `${general} is no longer in this Workspace, so it can’t take the link.`,
3936
+ 'not-general': `${general} is no longer in this Workspace, so it can’t take the link.`,
3937
+ 'project-unavailable': `${general}’s folder can’t be read right now, so it can’t take the link.`,
3938
+ 'project-links-stale': `${general} or the Workspace changed since this dialog opened, so it can’t take the link.`,
3939
+ 'project-links-changed': `${general}’s modules changed since this dialog opened, so it can’t take the link.`,
3940
+ }[code] || String(serverText || `${general} can’t take the link right now.`).trim();
3941
+ const name = String(state.name || '').trim();
3942
+ return `${why} You can still create ${name ? `“${name}”` : 'the project'} without linking it.`;
3943
+ }
3944
+
3894
3945
  function projectSetupErrorMessage(error) {
3895
3946
  // A sentence the server wrote for the person (#1965 review) — what to fix, or what restarting costs —
3896
3947
  // names their own folders, so it is shown as written rather than run through the filter below.
@@ -3949,7 +4000,7 @@
3949
4000
  $projectSetupCreate.textContent = label || 'Create project & start chat';
3950
4001
  $projectSetupCreateOnly.textContent = busy && !projectSetupState.settingUp
3951
4002
  ? 'Creating…'
3952
- : projectSetupState.linkFrom ? 'Create project' : createOnlyLabel(projectSetupState.kind);
4003
+ : createOnlyLabel(projectSetupState.kind);
3953
4004
  if (!busy) {
3954
4005
  $projectSetupCreate.disabled = !projectSetupReady();
3955
4006
  $projectSetupCreateOnly.disabled = !projectSetupReady();
@@ -3982,7 +4033,7 @@
3982
4033
  // Setup kinds that start from no file at all: a Drawing Checker profile and a General project.
3983
4034
  const NO_FILE_SETUP_KINDS = ['drawing-check-profile', 'general-project'];
3984
4035
  function projectSetupProvider(state) {
3985
- if (!state || NO_CHAT_SETUP_KINDS.includes(state.kind) || state.linkFrom) return null;
4036
+ if (!state || NO_CHAT_SETUP_KINDS.includes(state.kind)) return null;
3986
4037
  const runtimes = bridge.chatProviderRuntimes?.() || [];
3987
4038
  const readiness = (id) => (id ? projectSetupProviderReadiness(runtimes.find((runtime) => runtime.id === id)) : 'unavailable');
3988
4039
  const canStart = (id) => readiness(id) !== 'unavailable';
@@ -4204,7 +4255,7 @@
4204
4255
  const $sourceKicker = $projectSetupSourceName.previousElementSibling;
4205
4256
  if ($sourceKicker) $sourceKicker.textContent = state.kind === 'general-project' ? 'Starting point' : 'Source';
4206
4257
  $projectSetupSourceName.parentElement?.setAttribute('aria-label', state.kind === 'general-project' ? 'Starting point' : 'Selected source drawings');
4207
- $projectSetupCreateOnly.textContent = state.busy ? 'Creating…' : state.linkFrom ? 'Create project' : createOnlyLabel(state.kind);
4258
+ $projectSetupCreateOnly.textContent = state.busy ? 'Creating…' : createOnlyLabel(state.kind);
4208
4259
  $projectSetupSourceCount.textContent = state.files.length > 1 ? `+ ${state.files.length - 1} more` : '';
4209
4260
  $projectSetupFolder.textContent = state.directory
4210
4261
  ? state.directory.path
@@ -4391,10 +4442,14 @@
4391
4442
  ...(state.sentBuildMode === 'quick' ? { buildMode: 'quick' } : {}),
4392
4443
  ...(state.sentBuildMode === 'quick' && state.sentFilterChoice === 'ai' ? { quickFilterByAi: true } : {}),
4393
4444
  ...(state.sentBuildMode === 'quick' && state.sentFilterChoice === 'ai' && state.sentExclusionsChoice === 'ai' ? { quickFilterExclusionsByAi: true } : {}),
4445
+ // #2470 R6.7b: added from a General project's Modules step, the project is made already linked there.
4446
+ ...(state.linkFrom ? { linkFrom: { projectId: state.linkFrom.projectId, sourceUuid: state.linkFrom.sourceUuid, rootId: state.linkFrom.rootId } } : {}),
4447
+ ...(state.linkFrom && state.withoutLink ? { withoutLink: true } : {}),
4394
4448
  });
4395
4449
  const project = result.project;
4396
4450
  state.project = project;
4397
4451
  state.request = result.request;
4452
+ state.moduleLink = result.moduleLink || null;
4398
4453
  state.buildModeNotice = result.buildModeNotice || null;
4399
4454
  if (!projects.some((item) => item.id === project.id)) {
4400
4455
  projects.unshift(project);
@@ -4415,13 +4470,25 @@
4415
4470
  $projectSetupFolderChoose.textContent = 'Choose…';
4416
4471
  }
4417
4472
  const outsideWorkspace = code === 'project-directory-outside-root';
4418
- setProjectSetupError(projectSetupErrorMessage(error), { workspaceAction: outsideWorkspace });
4473
+ // #2470 R6.7b: the server's own sentence on why the link can't be made, and the choice to go on without it.
4474
+ const linkChoice = startChat && state.linkFrom && error?.linkChoice === true;
4475
+ setProjectSetupError(linkChoice ? projectSetupLinkChoiceMessage(state, code, error.message) : projectSetupErrorMessage(error), {
4476
+ workspaceAction: outsideWorkspace,
4477
+ withoutLinkAction: linkChoice ? () => { state.withoutLink = true; void createProjectFromSetup(true); } : null,
4478
+ });
4419
4479
  setProjectSetupBusy(false);
4420
4480
  renderProjectSetup();
4421
4481
  return;
4422
4482
  }
4423
4483
  setProjectSetupBusy(false);
4424
4484
  closeProjectSetup({ restoreFocus: false });
4485
+ if (state.linkFrom) {
4486
+ // #2470 R6.7b: one message from the real outcome — the link to the General project, then what the chat is doing.
4487
+ globalThis.flolessProjectModules?.afterCreate?.({ project: state.project, linkFrom: state.linkFrom, moduleLink: state.moduleLink,
4488
+ outcome: 'ok', next: state.request?.buildMode === 'quick' ? 'The Quick model read is running in AI Chat.' : 'The drawing task is running in AI Chat.' });
4489
+ if (state.buildModeNotice?.why) showToast(state.buildModeNotice.why, 'warn');
4490
+ return;
4491
+ }
4425
4492
  // A General project's chat is Flo's kickoff; its first reply may still be on its way (#2470 R6.4).
4426
4493
  // #2521 row 7a: said from what was queued, never from the button still pressed.
4427
4494
  if (state.buildModeNotice?.why) showToast(`Project created. ${state.buildModeNotice.why}`, 'warn');
@@ -4431,6 +4498,24 @@
4431
4498
  : 'Project created — the drawing task is running in AI Chat.', 'ok');
4432
4499
  }
4433
4500
 
4501
+ // #2470 R6.7b: a recovery that asked the person to choose about the link is asked once per page.
4502
+ const projectChatIntakeLinkChoiceShown = new Set();
4503
+ async function recoverProjectChatIntake(submissionId, options) {
4504
+ const result = await bridge.resumeProjectChatIntake(submissionId, options);
4505
+ if (!result) return;
4506
+ if (!projects.some((item) => item.id === result.project.id)) projects.unshift(result.project);
4507
+ await openProject(result.project.id, result.project.app === 'floless-general' ? 'knowledge' : 'drawings');
4508
+ await bridge.openChatConversation(result.chat.chatId);
4509
+ forgetProjectChatIntake(submissionId);
4510
+ // #2470 R6.7b: started from a General project's Modules step: say what became of the link, never a silent "linked".
4511
+ const unlinked = result.moduleLink && result.moduleLink.ok === false
4512
+ ? (result.moduleLink.code === 'link-skipped' ? ' It isn’t linked to the General project, as you chose.'
4513
+ : ' It couldn’t be linked to the General project; link it from that project’s Modules step.')
4514
+ : '';
4515
+ // #2521 row 7a: a Quick choice queued Precise is said on recovery too, from the saved receipt.
4516
+ if (result.buildModeNotice?.why) showToast(`Recovered the project and its AI Chat.${unlinked} ${result.buildModeNotice.why}`, 'warn');
4517
+ else showToast(`Recovered the project and its AI Chat.${unlinked}`, unlinked && result.moduleLink.code !== 'link-skipped' ? 'warn' : 'ok');
4518
+ }
4434
4519
  async function resumeInterruptedProjectChatIntake() {
4435
4520
  if (projectChatIntakeRecoveryStarted) return;
4436
4521
  const submissionIds = pendingProjectChatIntakes();
@@ -4438,18 +4523,26 @@
4438
4523
  projectChatIntakeRecoveryStarted = true;
4439
4524
  for (const submissionId of submissionIds) {
4440
4525
  try {
4441
- const result = await bridge.resumeProjectChatIntake(submissionId);
4442
- if (!result) continue;
4443
- if (!projects.some((item) => item.id === result.project.id)) projects.unshift(result.project);
4444
- await openProject(result.project.id, result.project.app === 'floless-general' ? 'knowledge' : 'drawings');
4445
- await bridge.openChatConversation(result.chat.chatId);
4446
- forgetProjectChatIntake(submissionId);
4447
- // #2521 row 7a: a Quick choice queued Precise is said on recovery too, from the saved receipt.
4448
- if (result.buildModeNotice?.why) showToast(`Recovered the project and its AI Chat. ${result.buildModeNotice.why}`, 'warn');
4449
- else showToast('Recovered the project and its AI Chat.', 'ok');
4526
+ await recoverProjectChatIntake(submissionId);
4450
4527
  } catch (error) {
4451
4528
  const code = error && (error.code || error.body && error.body.code);
4452
- if (code === 'project-intake-not-found' || code === 'project-intake-damaged') {
4529
+ if (error?.linkChoice === true) {
4530
+ // The General project it was started from can't take the link now: ask once per page, never decide for them.
4531
+ // It stays until the person acts on it; a choice that fails is offered again.
4532
+ if (!projectChatIntakeLinkChoiceShown.has(submissionId)) {
4533
+ projectChatIntakeLinkChoiceShown.add(submissionId);
4534
+ showToast(`A project you started from a General project wasn’t created yet. ${projectSetupLinkChoiceMessage({}, code, error.message)}`, 'warn', {
4535
+ persistent: true,
4536
+ action: { label: 'Create without linking', commandId: 'shell.project-setup-recover-without-link',
4537
+ onClick: () => recoverProjectChatIntake(submissionId, { withoutLink: true }).catch((retryError) => {
4538
+ projectChatIntakeLinkChoiceShown.delete(submissionId);
4539
+ showToast(projectSetupErrorMessage(retryError), 'error');
4540
+ projectChatIntakeRecoveryStarted = false;
4541
+ void resumeInterruptedProjectChatIntake();
4542
+ }) },
4543
+ });
4544
+ }
4545
+ } else if (code === 'project-intake-not-found' || code === 'project-intake-damaged') {
4453
4546
  forgetProjectChatIntake(submissionId);
4454
4547
  } else if (code === 'project-intake-project-missing') {
4455
4548
  // The project this setup made was removed or replaced: nothing is left to resume, so say so once (#2470 R6.4).
@@ -4510,7 +4603,7 @@
4510
4603
  renderProjectSetup();
4511
4604
  $projectSetup.classList.add('show');
4512
4605
  $projectSetupFolderChoose.focus();
4513
- if (!NO_CHAT_SETUP_KINDS.includes(kind) && !linkFrom) void refreshProjectSetupProviders(state);
4606
+ if (!NO_CHAT_SETUP_KINDS.includes(kind)) void refreshProjectSetupProviders(state);
4514
4607
  try {
4515
4608
  if (kind !== 'tekla-source') {
4516
4609
  await Promise.all(files.map(assertProjectSourceReadable));
@@ -5370,6 +5463,8 @@
5370
5463
  if (!nav.skipLeaveGuard && current && current.id !== p.id && !(await leaveOpenProject(nav.returnFocus))) return STAYED_IN_PROJECT;
5371
5464
  if (unwanted()) return STAYED_IN_PROJECT;
5372
5465
  if (current?.uuid !== p.uuid) revisionNoteEditorGeneration++;
5466
+ // #2470 R6.5b: the History view chosen on the project being left is not carried back to it after another one.
5467
+ if (current?.uuid !== p.uuid || current?.id !== p.id) historyView = { project: null, view: 'approvals' };
5373
5468
  current = p;
5374
5469
  // #2470 R6.6c: whatever editor is still loaded belongs to the project as it was before this open, and the frame is
5375
5470
  // reset below; until the new document says it is ready, no step message goes to the old one.
@@ -5437,7 +5532,7 @@
5437
5532
  // A sourceless project (General, #2470) has no Model, Drawings, Exports or History step; a step carried
5438
5533
  // over from another project lands on its first step instead of a pane it does not have.
5439
5534
  if (d.sourceless && !d.steps.some((step) => step.key === initialStep)) initialStep = d.steps[0].key;
5440
- if ((d.filter || isModelSourceProject(p)) && ['model', 'rfis', 'exports', 'history'].includes(initialStep)) {
5535
+ if (waitsForModelOnOpen(d, p, initialStep)) {
5441
5536
  pendingPresenceStep = { projectId: p.id, step: initialStep };
5442
5537
  }
5443
5538
  // The LIVE app id, deliberately: the frames address the server with it (contract reads, saves),
@@ -5517,7 +5612,9 @@
5517
5612
  applyModelPresence(present);
5518
5613
  // Restore only when this same project's authoritative answer says a model exists. A confirmed
5519
5614
  // preliminary lifecycle remains on Drawing Filter and gets the real prerequisite gate below.
5520
- if (present === 'model' && restore && currentStep === 'drawings') setStep(restore);
5615
+ // #2470 R6.5b: History on a kind with two views is never gated (its Activity view needs no model), so it is
5616
+ // restored on any known answer too, and opens on Activity when Approvals still has to wait.
5617
+ if (restore && currentStep === 'drawings' && (present === 'model' || (present !== 'unknown' && restore === 'history' && !stageGateFor(restore)))) setStep(restore);
5521
5618
  return true;
5522
5619
  })();
5523
5620
  modelPresenceProbe = { projectId, promise };
@@ -6358,8 +6455,11 @@
6358
6455
  : 'Then press Save filter in the top-right corner. After Save, return to the terminal AI that prepared it and tell it to continue.';
6359
6456
  }
6360
6457
 
6361
- function stageGateFor(step) {
6458
+ function stageGateFor(step, opts) {
6362
6459
  const d = wsApp();
6460
+ // #2470 R6.5b: the History step's Activity view needs no model, so where the step has two views it is never locked;
6461
+ // only its Approvals view is (`{ ledger: true }` asks for that), and syncHistoryViews opens the step on Activity then.
6462
+ if (step === 'history' && !opts?.ledger && typeof hasHistoryViews === 'function' && hasHistoryViews(d)) return '';
6363
6463
  if (!d || !d.filter || !['model', 'rfis', 'exports', 'history'].includes(step)) return '';
6364
6464
  const initialRead = revCardReq && isInitialRevisionRead(revCardReq);
6365
6465
  const waitingForInitial = initialRead && lastRevState === 'pending';
@@ -6393,15 +6493,23 @@
6393
6493
  if (projectContractLifecycle === 'filter-checkpoint') return 'Attach the drawing set again in Drawing Filter to restart the read. The earlier request is no longer available to receive a saved filter.';
6394
6494
  return 'Read and save a Drawing Filter first. The model will unlock after the first drawing read.';
6395
6495
  }
6396
- if (waitingForInitial) return `The ${step === 'exports' ? 'steel model' : 'first model'} must be ready before ${step === 'exports' ? 'exports' : 'history'} is available.`;
6496
+ // The History step's own gate names the step; its Approvals view's gate (#2470 R6.5b) names that view, and RFIs names RFIs.
6497
+ const later = step === 'exports' ? 'Exports' : step === 'rfis' ? 'RFIs' : opts?.ledger ? 'Approvals' : 'History';
6498
+ if (waitingForInitial) return `The ${step === 'exports' ? 'steel model' : 'first model'} must be ready before ${step === 'exports' ? 'exports' : step === 'rfis' ? 'RFIs' : opts?.ledger ? 'approvals' : 'history'} ${opts?.ledger || step === 'rfis' ? 'are' : 'is'} available.`;
6397
6499
  if (projectContractLifecycle === 'filter-checkpoint' && !revisionListKnown) return 'Checking the drawing read. Stages open once FloLess knows where it stands.';
6398
- if (projectContractLifecycle === 'filter-checkpoint') return `Attach the drawing set again in Drawing Filter before opening ${step === 'exports' ? 'Exports' : 'History'}. The earlier request can no longer continue.`;
6399
- return `Create the first steel model before opening ${step === 'exports' ? 'Exports' : 'History'}.`;
6500
+ if (projectContractLifecycle === 'filter-checkpoint') return `Attach the drawing set again in Drawing Filter before opening ${later}. The earlier request can no longer continue.`;
6501
+ return `Create the first steel model before opening ${later}.`;
6400
6502
  }
6401
6503
 
6402
6504
  function applyStageGating() {
6403
6505
  const d = wsApp();
6404
6506
  if (!$stepTabs) return;
6507
+ // The History step's Approvals view has its own gate (#2470 R6.5b): repaint the switch as the model arrives or goes.
6508
+ if (typeof syncHistoryViews === 'function' && typeof currentStep !== 'undefined') {
6509
+ const activity = syncHistoryViews(currentStep, d);
6510
+ // A gate that appears under the open ledger moves the step to Activity (once: setStep leaves the panes matching).
6511
+ if (currentStep === 'history' && activity && !$wsHistory.hidden) setStep('history');
6512
+ }
6405
6513
  if (!d || !d.filter) {
6406
6514
  // The tab strip is shared across projects. Remove every steel-only gate when switching to an
6407
6515
  // app without a Drawing Filter, or the next app inherits disabled tabs from the previous one.
@@ -6505,7 +6613,7 @@
6505
6613
  return;
6506
6614
  }
6507
6615
  const guidance = stagedInitial
6508
- ? 'The drawing read is complete · Open Drawing Filter and choose Review changes before moving to Model, Exports, or History.'
6616
+ ? 'The drawing read is complete · Open Drawing Filter and choose Review changes before moving to Model, Exports, or Approvals in History.'
6509
6617
  : failedInitial
6510
6618
  ? (revCardReq?.canClear === true
6511
6619
  ? 'The drawing read failed · Return to Drawing Filter, press Dismiss, then attach the drawing set again.'
@@ -6548,7 +6656,7 @@
6548
6656
  : 'Checking the drawing read · FloLess is looking up this project’s drawing request.')
6549
6657
  : projectContractLifecycle === 'filter-checkpoint'
6550
6658
  ? 'Drawing read needs restarting · The earlier drawing request is no longer available. Attach the drawing set again in Drawing Filter to restart the read.'
6551
- : 'Start in Drawing Filter by attaching a PDF drawing set. The Model, Exports, and History stages unlock after the first steel model is created.';
6659
+ : 'Start in Drawing Filter by attaching a PDF drawing set. The Model and Exports stages, and Approvals in History, unlock after the first steel model is created. History’s Activity is open now.';
6552
6660
  paintStageGuidance(guidance, failedInitial || unavailableInitial ? 'failed' : 'info');
6553
6661
  if (waitingForInitial && revCardReq?.prepassReady && !revCardReq?.filterCheckpointCurrent) {
6554
6662
  appendStageGuidanceFilterAction();
@@ -6594,6 +6702,60 @@
6594
6702
  return true;
6595
6703
  }
6596
6704
 
6705
+ /**
6706
+ * Show or hide the History view switch for step `s` and say which view it is on. Returns true when the step shows the
6707
+ * activity journal instead of the ledger. Called from setStep, which reaches it through `typeof` (harnesses lift
6708
+ * setStep alone).
6709
+ */
6710
+ function syncHistoryViews(s, d) {
6711
+ const project = typeof current !== 'undefined' ? current : null;
6712
+ const shown = s === 'history' && hasHistoryViews(d) && !!project;
6713
+ // Before a Steel project's first model the ledger has nothing to show and its readiness checks would refuse, so the
6714
+ // step opens on Activity and Approvals says why instead (nothing refuses: the step still opens).
6715
+ const ledgerGate = shown ? stageGateFor('history', { ledger: true }) : '';
6716
+ // Opened on Activity for that reason, it stays there when the model arrives: the view never changes under the person.
6717
+ if (ledgerGate) historyView = { project: historyViewKey(project), view: 'activity' };
6718
+ const view = shown && historyView.project === historyViewKey(project) ? historyView.view : 'approvals';
6719
+ const box = document.getElementById('ws-history-views');
6720
+ if (box) {
6721
+ box.hidden = !shown;
6722
+ for (const b of box.querySelectorAll('[data-history-view]')) {
6723
+ const on = b.dataset.historyView === view;
6724
+ b.setAttribute('aria-checked', String(on));
6725
+ b.setAttribute('tabindex', on ? '0' : '-1');
6726
+ if (b.dataset.historyView !== 'approvals') continue;
6727
+ if (ledgerGate) { b.setAttribute('aria-disabled', 'true'); b.dataset.tip = ledgerGate; }
6728
+ else { b.removeAttribute('aria-disabled'); b.dataset.tip = APPROVALS_TIP; }
6729
+ }
6730
+ }
6731
+ return shown && view === 'activity';
6732
+ }
6733
+ /** The person picked a History view: remember it for this project, show it, and keep focus on the choice. */
6734
+ function chooseHistoryView(view) {
6735
+ if (!current || currentStep !== 'history' || (view !== 'approvals' && view !== 'activity')) return;
6736
+ const ledgerGate = view === 'approvals' ? stageGateFor('history', { ledger: true }) : '';
6737
+ if (ledgerGate) { showToast(ledgerGate, 'warn'); return; }
6738
+ const was = syncHistoryViews('history', wsApp()) ? 'activity' : 'approvals';
6739
+ historyView = { project: historyViewKey(current), view };
6740
+ if (was === view) return;
6741
+ setStep('history');
6742
+ document.querySelector(`#ws-history-views [data-history-view="${view}"]`)?.focus();
6743
+ }
6744
+ {
6745
+ const box = document.getElementById('ws-history-views');
6746
+ box?.addEventListener('click', (e) => {
6747
+ const b = e.target.closest('[data-history-view]');
6748
+ if (b) chooseHistoryView(b.dataset.historyView);
6749
+ });
6750
+ // Arrow keys move the choice, as in any radio group; Space and Enter press the focused one (a button already does).
6751
+ box?.addEventListener('keydown', (e) => {
6752
+ if (!['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown'].includes(e.key)) return;
6753
+ e.preventDefault();
6754
+ const checked = box.querySelector('[aria-checked="true"]')?.dataset.historyView;
6755
+ chooseHistoryView(checked === 'activity' ? 'approvals' : 'activity');
6756
+ });
6757
+ }
6758
+
6597
6759
  /**
6598
6760
  * A step the PERSON picked (a tab or a "go to" link), as opposed to one the shell restores. While a
6599
6761
  * project opens, `pendingPresenceStep` holds the step to restore once the lifecycle probe answers;
@@ -6631,6 +6793,7 @@
6631
6793
  b.classList.toggle('active', on);
6632
6794
  b.setAttribute('aria-selected', String(on));
6633
6795
  });
6796
+ if (typeof revealActiveStepTab === 'function') revealActiveStepTab();
6634
6797
  // An app with no filter (vectorize) has an empty `drawings` frame URL — never src it; its Source
6635
6798
  // step shows a lightweight placeholder pane instead of an about:blank iframe.
6636
6799
  const d = wsApp();
@@ -6685,8 +6848,12 @@
6685
6848
  const showExports = s === 'exports';
6686
6849
  $wsExports.hidden = !showExports;
6687
6850
  if (showExports) safeRenderExports('when you opened the Exports step');
6688
- // History is likewise a shell-rendered pane: the project's version ledger.
6689
- const showHistory = s === 'history';
6851
+ // History is likewise a shell-rendered pane: the project's version ledger. On a module project its step has a second
6852
+ // view, the activity journal (#2470 R6.5b), which shows in the journal pane below instead of the ledger.
6853
+ const historyActivity = typeof syncHistoryViews === 'function' && syncHistoryViews(s, d);
6854
+ const showHistory = s === 'history' && !historyActivity;
6855
+ // Leaving the ledger by any route (another step, its Activity view, or a gate that appeared) ends what it started.
6856
+ if (!showHistory && !$wsHistory.hidden && typeof leaveHistoryLedger === 'function') leaveHistoryLedger();
6690
6857
  $wsHistory.hidden = !showHistory;
6691
6858
  if (showHistory) renderHistory();
6692
6859
  else { closeRollbackConfirm(); closeBaseMenu(); } // don't leave a popover open behind a step switch
@@ -6732,14 +6899,15 @@
6732
6899
  const project = typeof current !== 'undefined' ? current : null;
6733
6900
  if (showModules && project && window.flolessProjectModules) window.flolessProjectModules.render($modulesPane, project);
6734
6901
  }
6735
- // #2470 R6.5: a General project's History is a shell-rendered pane too: its journal (project-history.js). Reached
6902
+ // #2470 R6.5: a General project's History is a shell-rendered pane too: its journal (project-history.js); #2470 R6.5b:
6903
+ // so is a module project's History step on its Activity view (historyActivity, above). Reached
6736
6904
  // through globalThis, like the RFIs one, so a harness that lifts setStep without it still runs.
6737
6905
  const $journalPane = document.getElementById('ws-journal');
6738
6906
  if ($journalPane) {
6739
- const showJournal = s === 'journal';
6907
+ const showJournal = s === 'journal' || historyActivity;
6740
6908
  $journalPane.hidden = !showJournal;
6741
6909
  const project = typeof current !== 'undefined' ? current : null;
6742
- if (showJournal && project) globalThis.flolessProjectHistory?.render?.($journalPane, project);
6910
+ if (showJournal && project) globalThis.flolessProjectHistory?.render?.($journalPane, project, historyActivity ? { variant: 'module' } : undefined);
6743
6911
  }
6744
6912
  // Knowledge is a shell-rendered pane too: the project's Knowledge Base (References column).
6745
6913
  const showKnowledge = s === 'knowledge';
@@ -6752,6 +6920,48 @@
6752
6920
  applyStageGating();
6753
6921
  syncWorkspaceReporter();
6754
6922
  }
6923
+ // When the window is too narrow for every step tab, the tabs scroll sideways inside the row (web/app.css
6924
+ // .ws-steps-row) so the step's own control at the end stays on screen. Mark which side has more tabs, keep the
6925
+ // chosen tab in view, and let a plain mouse wheel scroll them (a trackpad and Shift+wheel already do).
6926
+ function syncStepTabsOverflow() {
6927
+ const rest = $stepTabs.scrollWidth - $stepTabs.clientWidth - $stepTabs.scrollLeft;
6928
+ const start = $stepTabs.scrollLeft > 1;
6929
+ const end = rest > 1;
6930
+ const fade = start && end ? 'both' : start ? 'start' : end ? 'end' : 'none';
6931
+ if ($stepTabs.dataset.fade !== fade) $stepTabs.dataset.fade = fade;
6932
+ }
6933
+ function revealActiveStepTab() {
6934
+ revealStepTab($stepTabs.querySelector('button.active'));
6935
+ }
6936
+ function revealStepTab(b) {
6937
+ if (b && !b.hidden && $stepTabs.scrollWidth > $stepTabs.clientWidth) {
6938
+ // Clear of the 24px fade, so the chosen tab is never half-faded. Scrolled by hand rather than scrollIntoView,
6939
+ // which would also scroll the clipped workspace panes around it.
6940
+ const before = b.offsetLeft - 24;
6941
+ const after = b.offsetLeft + b.offsetWidth + 24 - $stepTabs.clientWidth;
6942
+ if (before < $stepTabs.scrollLeft) $stepTabs.scrollLeft = Math.max(0, before);
6943
+ else if (after > $stepTabs.scrollLeft) $stepTabs.scrollLeft = after;
6944
+ }
6945
+ syncStepTabsOverflow();
6946
+ }
6947
+ $stepTabs.addEventListener('scroll', syncStepTabsOverflow, { passive: true });
6948
+ // The browser brings a focused tab only to the edge, under the fade; bring it clear of it like the chosen tab.
6949
+ $stepTabs.addEventListener('focusin', (e) => revealStepTab(e.target.closest('button[data-step]')));
6950
+ $stepTabs.addEventListener('wheel', (e) => {
6951
+ if (e.deltaX || !e.deltaY || e.ctrlKey) return;
6952
+ const from = $stepTabs.scrollLeft;
6953
+ // A wheel that counts in lines or pages (Firefox) is turned into pixels, or one notch would move about 3px.
6954
+ const unit = e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? $stepTabs.clientWidth : 1;
6955
+ $stepTabs.scrollLeft = from + e.deltaY * unit;
6956
+ if ($stepTabs.scrollLeft !== from) e.preventDefault();
6957
+ }, { passive: false });
6958
+ // A tab shown, hidden, relabelled or locked changes how much room the tabs need, and the window or a side panel
6959
+ // changes how much they have: either can start or end the overflow.
6960
+ if (typeof ResizeObserver === 'function') {
6961
+ const stepTabsSize = new ResizeObserver(() => revealActiveStepTab());
6962
+ stepTabsSize.observe($stepTabs);
6963
+ $stepTabs.querySelectorAll('button[data-step]').forEach((b) => stepTabsSize.observe(b));
6964
+ }
6755
6965
  $stepTabs.addEventListener('click', (e) => {
6756
6966
  const b = e.target.closest('button[data-step]');
6757
6967
  if (b?.getAttribute('aria-disabled') === 'true') {
@@ -8229,6 +8439,7 @@
8229
8439
  // than a switch into an empty History pane.
8230
8440
  function wsOpenHistory() {
8231
8441
  if (!current) return;
8442
+ historyView = { project: historyViewKey(current), view: 'approvals' }; // reverting is the ledger's (#2470 R6.5b)
8232
8443
  setStep('history');
8233
8444
  // Move focus with the step. The click that gets here comes from a button inside the Model
8234
8445
  // iframe, which setStep() has just hidden — focus would otherwise collapse to <body>, leaving a
@@ -9634,7 +9845,10 @@
9634
9845
  return '<section class="kb-col kb-viewer kb-page"><div class="kb-view-head">' +
9635
9846
  `<span class="kb-view-name" data-tip="${escapeAttr(pg.title)}">${escapeHtml(pg.title)}</span>${type}${cited}` +
9636
9847
  '<button type="button" class="kb-x" data-kb-close data-tip="Back to graph" aria-label="Back to graph">✕</button></div>' +
9637
- `<div class="kb-page-body"><div class="kb-page-body-measure">${escapeHtml(pg.body)}</div></div></section>`;
9848
+ // #3003: rendered like the chat viewers (markdown, [[links]] as page titles); raw text only if chat is not loaded.
9849
+ (window.flolessChat?.knowledgePageHtml
9850
+ ? `<div class="kb-page-body"><div class="kb-page-body-measure kb-page-md">${window.flolessChat.knowledgePageHtml(pg.body, pg.links, 'workspace.kb-page-link')}</div></div></section>`
9851
+ : `<div class="kb-page-body"><div class="kb-page-body-measure">${escapeHtml(pg.body)}</div></div></section>`);
9638
9852
  }
9639
9853
  function kbPageLoading() { return '<section class="kb-col kb-viewer kb-page"><div class="kb-view-head"><span class="kb-view-name">Loading…</span></div><div class="kb-view-msg"><div class="kb-view-spin" role="status" aria-label="Loading page"></div></div></section>'; }
9640
9854
  /** `opts.citedGone` — the read carried a pinned generation and the server does not have it.
@@ -10058,7 +10272,7 @@
10058
10272
  // drift flag says the opposite in that state, so the strip and the page would disagree.
10059
10273
  const cur = knowledgeState && knowledgeState.currentGeneration ? knowledgeState.currentGeneration.generationId : null;
10060
10274
  const cited = !!generationId && cur !== generationId;
10061
- const h = kbViewHost(); if (h) h.innerHTML = kbPageShell(body.page, { cited });
10275
+ const h = kbViewHost(); if (h) { h.innerHTML = kbPageShell(body.page, { cited }); h.dataset.kbGeneration = body.generationId || ''; }
10062
10276
  } catch (err) {
10063
10277
  if (err && err.name === 'AbortError') return;
10064
10278
  // One sentence used to cover five causes with no record anywhere. The status separates the one
@@ -11894,6 +12108,9 @@
11894
12108
  // One delegated listener for the whole pane — the column is re-rendered wholesale on every state
11895
12109
  // change, so per-render wiring would leak handlers.
11896
12110
  $wsKnowledge.addEventListener('click', (e) => {
12111
+ // #3003: a [[link]] on an open page opens the page it names, at the version this one was read from.
12112
+ const kbLink = e.target.closest('button[data-kb-link]');
12113
+ if (kbLink && current) { openKnowledgePage(current.id, kbLink.dataset.kbLink, kbViewHost()?.dataset.kbGeneration || null); return; }
11897
12114
  // #2491 R6.9: categories, selection and Move to… first — their menus share the design set's menu look.
11898
12115
  const rowAct = e.target.closest('[data-kb-row-act]');
11899
12116
  if (rowAct) { kbRowAct(rowAct); return; }
@@ -12438,7 +12655,7 @@
12438
12655
  ];
12439
12656
  };
12440
12657
  /** The units this project's bill is written in: the server's answer, else the client's own copy. */
12441
- const bomUnits = () => exportUnits ?? (current && current.displayUnits === 'mm' ? 'mm' : 'ft-in');
12658
+ const bomUnits = () => exportUnits ?? (current?.displayUnits === 'mm' || current?.displayUnits === 'ft-in' ? current.displayUnits : current?.environment === 'UK' ? 'mm' : 'ft-in');
12442
12659
  const BOM_DESCRIPTIVE = ['profile', 'grade', 'type'];
12443
12660
  const DEFAULT_BOM_FORMATS = ['csv', 'xlsx'];
12444
12661
  const DEFAULT_BOM_COLUMNS = ['profile', 'qty', 'length', 'lbft', 'weight'];
@@ -14542,7 +14759,12 @@
14542
14759
  let selector = option.selector;
14543
14760
  if (option.selector.kind === 'working') {
14544
14761
  const win = frames.model && frames.model.contentWindow;
14545
- if (win && typeof win.flushContract === 'function') await win.flushContract();
14762
+ // Only an editor with unsaved input is flushed (#2981), as approval does. A flush always PUTs the
14763
+ // whole in-memory contract, including the presentation defaults the editor fills in on load, so an
14764
+ // export from an untouched model wrote a new working revision nobody made. An unknown state (no
14765
+ // editor loaded yet) still flushes.
14766
+ const saveState = win && typeof win.contractSaveState === 'function' ? win.contractSaveState() : null;
14767
+ if (win && typeof win.flushContract === 'function' && saveState !== 'clean') await win.flushContract();
14546
14768
  const fresh = await api(`/api/projects/${encodeURIComponent(projectId)}/export-sources`);
14547
14769
  if (!fresh || !fresh.working || typeof fresh.working.etag !== 'string') throw new Error('Working revision identity is unavailable.');
14548
14770
  selector = { kind: 'working', expectedEtag: fresh.working.etag };
@@ -16294,7 +16516,7 @@
16294
16516
  // into test harnesses, where a free name it assigns would not exist. A review opened before this
16295
16517
  // settles (a fresh page, a slow disk) reads in millimetres, never in nothing.
16296
16518
  import('./display-units.js').then((m) => { reviewUnitsModule = m; }, () => {});
16297
- const reviewUnits = () => (current && current.displayUnits === 'mm' ? 'mm' : 'ft-in');
16519
+ const reviewUnits = () => (current?.displayUnits === 'mm' || current?.displayUnits === 'ft-in' ? current.displayUnits : current?.environment === 'UK' ? 'mm' : 'ft-in');
16298
16520
  const reviewElevation = (mm) => (reviewUnitsModule ? reviewUnitsModule.formatElevation(mm, reviewUnits()) : `${Math.round(mm)} mm`);
16299
16521
  const reviewLength = (mm) => (reviewUnitsModule ? reviewUnitsModule.formatLength(mm, reviewUnits()) : `${Math.round(mm)} mm`);
16300
16522
  const isEndpointValue = (v) => !!v && typeof v === 'object' && !Array.isArray(v)
@@ -18127,14 +18349,27 @@
18127
18349
  return `<section class="saved-work" aria-labelledby="saved-work-title"><div class="saved-work-head"><h3 id="saved-work-title">Saved work</h3><span>Unapproved checkpoints</span></div>${body}</section>`;
18128
18350
  }
18129
18351
 
18352
+ // #2470 R6.5b: each ledger render is numbered, so one overtaken by a newer render (the person went to Activity and back
18353
+ // while it was reading) neither paints nor speaks.
18354
+ let historyRenderGen = 0;
18355
+ /**
18356
+ * The ledger was on screen and is being hidden (setStep): a render still reading neither paints nor speaks, and a
18357
+ * revision-note editor it opened will not reopen or repaint it. A note the person already pressed Save on is still
18358
+ * saved to its own project and version; only the hidden ledger is left alone.
18359
+ */
18360
+ function leaveHistoryLedger() {
18361
+ historyRenderGen++;
18362
+ revisionNoteEditorGeneration++;
18363
+ }
18130
18364
  async function renderHistory() {
18131
18365
  if (!current) return;
18132
18366
  const id = current.id;
18367
+ const renderGen = ++historyRenderGen;
18133
18368
  const previousHistory = $wsHistory.dataset.historyProjectId === id ? $wsHistory.innerHTML : '';
18134
18369
  closeBaseMenu(); // this re-render replaces the History HTML — drop any open base-picker's listener first
18135
18370
  $wsHistory.innerHTML = HIST_HEAD + '<div class="hist-note">Loading history…</div>';
18136
18371
  await awaitApprovalVerdict();
18137
- if (!current || current.id !== id || $wsHistory.hidden) return; // switched away while it settled
18372
+ if (!current || current.id !== id || $wsHistory.hidden || renderGen !== historyRenderGen) return; // switched away while it settled
18138
18373
  let rows = [];
18139
18374
  let approvedAt;
18140
18375
  let nextDiffSupported = false;
@@ -18164,7 +18399,7 @@
18164
18399
  try {
18165
18400
  const r = await api(`/api/projects/${encodeURIComponent(id)}/versions`);
18166
18401
  strictHistoryUnavailable = r.historyAvailable === false;
18167
- if (r.revisionNotesUnavailable) showToast('Revision notes are unavailable. Approved history is unchanged.', 'warn');
18402
+ if (r.revisionNotesUnavailable && renderGen === historyRenderGen) showToast('Revision notes are unavailable. Approved history is unchanged.', 'warn');
18168
18403
  rows = Array.isArray(r.versions) ? r.versions : [];
18169
18404
  // Absent on an older server → fall back to the descriptor, which is the pre-change behaviour.
18170
18405
  nextDiffSupported = typeof r.diffSupported === 'boolean' ? r.diffSupported : !!(wsApp() && wsApp().diff);
@@ -18184,6 +18419,7 @@
18184
18419
  // `defaultUnavailable`, and reaches here through this throw. A bare network failure has no
18185
18420
  // body, so it still gets the retry line it deserves.
18186
18421
  const served = err && err.body && typeof err.body.error === 'string' ? err.body.error.trim() : '';
18422
+ if (renderGen !== historyRenderGen) return;
18187
18423
  showToast('We couldn’t load this history because FloLess could not reach it. Try again.', 'warn');
18188
18424
  if (current && current.id === id && !$wsHistory.hidden) {
18189
18425
  // The header comes too. A step that keeps its band while loading and while listing but drops
@@ -18197,7 +18433,7 @@
18197
18433
  const { saved } = await checkpointPromise;
18198
18434
  if (saved === null) checkpointsUnavailable = true;
18199
18435
  else checkpoints = Array.isArray(saved.checkpoints) ? saved.checkpoints : [];
18200
- if (!current || current.id !== id || $wsHistory.hidden) return; // switched away mid-await
18436
+ if (!current || current.id !== id || $wsHistory.hidden || renderGen !== historyRenderGen) return; // switched away mid-await
18201
18437
  if (strictHistoryUnavailable) {
18202
18438
  if (previousHistory) $wsHistory.innerHTML = previousHistory;
18203
18439
  else $wsHistory.innerHTML = HIST_HEAD + '<div class="hist-empty">Model readiness unavailable — History could not be verified within its safety limits.</div>';
@@ -18227,7 +18463,7 @@
18227
18463
  // same "don't route it through a string template at all" rule `importFailedCmdRow` follows.
18228
18464
  const gen = ++modelPresenceGen;
18229
18465
  const hasModel = await projectContractState(id, current.app);
18230
- if (gen !== modelPresenceGen || !current || current.id !== id || $wsHistory.hidden) return;
18466
+ if (gen !== modelPresenceGen || !current || current.id !== id || $wsHistory.hidden || renderGen !== historyRenderGen) return;
18231
18467
  applyModelPresence(hasModel); // one answer, every surface — History used to keep its own
18232
18468
  const empty = document.createElement('div');
18233
18469
  empty.className = 'hist-empty';
@@ -19781,11 +20017,13 @@
19781
20017
  const member = !!target && !validId(target.jointId) && validId(target.memberId);
19782
20018
  // #2874: or one RFI a chat message mentioned, shown on the project's RFIs step (in the editor, or the shell's own pane).
19783
20019
  const rfi = !!target && !validId(target.jointId) && !member && validId(target.rfiId) && /^RFI-\d{3,16}$/.test(target.rfiId);
20020
+ // #2521 row 9: or Make precise itself, opened in the editor for the chat's "Open Make precise".
20021
+ const precise = !!target && !validId(target.jointId) && !member && !rfi && target.makePrecise === true;
19784
20022
  // Sentences say "the member was not shown", but "RFI-007 was not shown".
19785
- const thing = member ? 'the member' : rfi ? target.rfiId : 'the connection';
19786
- const again = member ? 'Show in the model' : rfi ? `${target.rfiId} in the chat` : 'Open in the model';
20023
+ const thing = member ? 'the member' : rfi ? target.rfiId : precise ? 'Make precise' : 'the connection';
20024
+ const again = member ? 'Show in the model' : rfi ? `${target.rfiId} in the chat` : precise ? 'Open Make precise' : 'Open in the model';
19787
20025
  const step = rfi ? 'rfis' : 'model';
19788
- if (!target || !validId(target.projectId) || !(validId(target.jointId) || member || rfi)) throw connectionError(`That ${member ? 'member' : rfi ? 'RFI' : 'connection'} could not be opened. Open its project from Workspaces.`);
20026
+ if (!target || !validId(target.projectId) || !(validId(target.jointId) || member || rfi || precise)) throw connectionError(`That ${member ? 'member' : rfi ? 'RFI' : precise ? 'model' : 'connection'} could not be opened. Open its project from Workspaces.`);
19789
20027
  const mine = { id: `connection-${++connectionRequestSeq}`, page: null };
19790
20028
  withdrawConnectionRequest(connectionRequest);
19791
20029
  connectionRequest = mine;
@@ -19892,7 +20130,7 @@
19892
20130
  if (citedElsewhere()) throw citedGone();
19893
20131
  // The frame's window survives a reload; its DOCUMENT does not. That is what tells a reload apart.
19894
20132
  page = child; doc = child.document;
19895
- answer = child.flolessEditorFocus(member ? { memberId: target.memberId, requestId: mine.id } : rfi ? { rfiId: target.rfiId, requestId: mine.id } : { jointId: target.jointId, requestId: mine.id,
20133
+ answer = child.flolessEditorFocus(member ? { memberId: target.memberId, requestId: mine.id } : precise ? { makePrecise: true, requestId: mine.id } : rfi ? { rfiId: target.rfiId, requestId: mine.id } : { jointId: target.jointId, requestId: mine.id,
19896
20134
  // #2450: the readiness card's "Raise an RFI" also opens the editor's review dialog for it.
19897
20135
  ...(target.raiseRfi === true ? { raiseRfi: true } : {}), ...(validId(target.checkId) ? { checkId: target.checkId } : {}) });
19898
20136
  if (!answer || typeof answer.then !== 'function') return { ok: false, said: notTaken };