@floless/app 0.165.0 → 0.167.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/floless-server.cjs +30794 -25371
  2. package/dist/schemas/drawing-check.profile.v1.schema.json +4 -2
  3. package/dist/schemas/steel.model.v2.schema.json +2 -1
  4. package/dist/skills/floless-app-knowledge/SKILL.md +8 -1
  5. package/dist/skills/floless-app-rfi/SKILL.md +7 -2
  6. package/dist/skills/floless-app-steel-model/SKILL.md +4 -1
  7. package/dist/skills/floless-app-steel-takeoff/SKILL.md +31 -17
  8. package/dist/skills/floless-app-steel-takeoff/references/elevation-registration.md +15 -1
  9. package/dist/templates/college-phase-exporter.flo +41 -49
  10. package/dist/templates/screenshot-to-saved-settings.flo +12 -2
  11. package/dist/web/app.css +120 -1
  12. package/dist/web/aware.js +385 -88
  13. package/dist/web/chat-question-card.js +3 -1
  14. package/dist/web/chat.css +32 -0
  15. package/dist/web/chat.js +1021 -88
  16. package/dist/web/commands-drawing-check.js +1 -0
  17. package/dist/web/commands-filter.js +23 -0
  18. package/dist/web/commands-shell.js +231 -19
  19. package/dist/web/commands-steel.js +22 -2
  20. package/dist/web/drawing-check-editor.html +4 -0
  21. package/dist/web/drawing-check-editor.js +82 -2
  22. package/dist/web/index.html +14 -6
  23. package/dist/web/project-history.js +163 -19
  24. package/dist/web/project-modules.js +5 -0
  25. package/dist/web/project-rfis.js +206 -20
  26. package/dist/web/steel-ai-marks.js +173 -2
  27. package/dist/web/steel-editor.html +770 -49
  28. package/dist/web/steel-filter-flo.js +171 -7
  29. package/dist/web/steel-filter.html +36 -10
  30. package/dist/web/steel-model-v2-projection.js +26 -20
  31. package/dist/web/terminal-requests.js +5 -0
  32. package/dist/web/tool-updates.js +65 -20
  33. package/dist/web/workspaces.js +632 -85
  34. package/package.json +3 -2
@@ -391,6 +391,15 @@
391
391
  let teklaUploadProjectId = null;
392
392
  const teklaAdmissionFailures = new Map();
393
393
  let currentStep = 'model';
394
+ // #3053: the finished-read band (see readCompletionNotice).
395
+ const READ_COMPLETION_SEEN = 'floless:read-complete-seen:';
396
+ // A read older than this is not news: without the limit, the first open after an update would announce every
397
+ // project's long-finished read.
398
+ const READ_COMPLETION_MAX_AGE_MS = 7 * 24 * 60 * 60 * 1000;
399
+ let readCompletion = null; // { projectId, seenKey, n, members, questions } for the open project, or null
400
+ // Newest-wins for History lookups: bumped by each lookup, a project switch and a newer read, so a late answer
401
+ // (A → B → A, or one that started before a new read appeared) can never install a band.
402
+ let readCompletionGen = 0;
394
403
 
395
404
  // Shared drawing-file picker for both the new-project seed tile and the in-project
396
405
  // "Attach revised drawings" button. Prefers the File System Access API so the native
@@ -1339,6 +1348,15 @@
1339
1348
  reads as a different pane rather than the same one in a different state. */
1340
1349
  const HIST_HEAD = '<div class="step-head"><span>History</span></div>';
1341
1350
 
1351
+ // #2470 R6.5b: a module project's History step has two views, its approval ledger ('approvals', the default) and its
1352
+ // activity journal ('activity'), chosen with the switch at the end of the step row. The choice holds while the same
1353
+ // project stays open; another project opens on Approvals, the view of record. Plan 2026-10-30-2470-r6-5b-module-journal-PLAN.md.
1354
+ let historyView = { project: null, view: 'approvals' };
1355
+ const historyViewKey = (project) => `${project.id}|${String(project.uuid || '').toLowerCase()}`;
1356
+ /** Whether kind `d`'s History step has the two views: it is the approval ledger's `history` step (a module kind). */
1357
+ function hasHistoryViews(d) { return !!d?.steps?.some((x) => x.key === 'history'); }
1358
+ const APPROVALS_TIP = 'Approved versions, saved work and rollback.';
1359
+
1342
1360
  /**
1343
1361
  * The server's own plain-English refusal for a project that cannot be signed off at all, or `''`
1344
1362
  * when approval is merely unavailable for the moment (loading, a failed probe, nothing read yet).
@@ -2092,11 +2110,11 @@
2092
2110
  || !['available', 'unavailable'].includes(registration.status)) {
2093
2111
  throw new Error('The project view no longer matches this registration.');
2094
2112
  }
2095
- const wasUnits = cached.displayUnits === 'mm' ? 'mm' : 'ft-in';
2113
+ const wasUnits = (cached?.displayUnits === 'mm' || cached?.displayUnits === 'ft-in' ? cached.displayUnits : cached?.environment === 'UK' ? 'mm' : 'ft-in');
2096
2114
  const wasApproved = cached.approvedAt;
2097
2115
  const wasSortKeys = { name: cached.name, createdAt: cached.createdAt, updatedAt: cached.updatedAt };
2098
2116
  Object.assign(cached, fresh, {
2099
- displayUnits: fresh.displayUnits === 'mm' ? 'mm' : 'ft-in',
2117
+ displayUnits: (fresh?.displayUnits === 'mm' || fresh?.displayUnits === 'ft-in' ? fresh.displayUnits : fresh?.environment === 'UK' ? 'mm' : 'ft-in'),
2100
2118
  registrationState: registration.status,
2101
2119
  registrationRevision: registration.entryRevision,
2102
2120
  registrationReason: registration.reason,
@@ -2288,7 +2306,7 @@
2288
2306
  // that never had a unit choice arrives as `undefined` — and assigning that raw made the
2289
2307
  // `!==` test true on every `projects-changed`, discarding the server's `exportUnits` and
2290
2308
  // repainting for nothing. (Review round 5.)
2291
- const freshUnits = mine.displayUnits === 'mm' ? 'mm' : 'ft-in';
2309
+ const freshUnits = (mine?.displayUnits === 'mm' || mine?.displayUnits === 'ft-in' ? mine.displayUnits : mine?.environment === 'UK' ? 'mm' : 'ft-in');
2292
2310
  const freshName = typeof mine.name === 'string' ? mine.name : current.name;
2293
2311
  if (current && current.id === id && current.name !== freshName) {
2294
2312
  current.name = freshName;
@@ -3312,13 +3330,16 @@
3312
3330
  * Start a create card's own flow. Called straight from the click, with nothing awaited first, so the native file
3313
3331
  * picker it may open still counts as the person's own gesture.
3314
3332
  */
3315
- async function activateSeedCard(seed, linkFrom = null) {
3333
+ async function activateSeedCard(seed, linkFrom = null, { buildMode = null } = {}) {
3316
3334
  // Two ids, and they are not interchangeable: create on the LIVE app (`seed-app`), but look the
3317
3335
  // descriptor up by its lineage ROOT (`seed-template`) — after a rename the live id answers to no
3318
3336
  // descriptor, and the built-in id answers to no installed app.
3319
3337
  const appId = seed.dataset.seedApp;
3320
3338
  const templateId = seed.dataset.seedTemplate || appId;
3321
3339
  if (!WORKSPACE_APPS[templateId]) return;
3340
+ // #2811: a Quick press kept for this press is used now, or dropped, whatever happens next (a cancelled picker, another
3341
+ // card): it never reaches a later, unrelated New project.
3342
+ const setupBuildMode = takePendingQuickPress(templateId, seed.dataset.seedAction, buildMode, linkFrom);
3322
3343
  // Each create kind has its own branch below. The 'drawing' check stays a check rather than an
3323
3344
  // assumption: a future kind must declare its own branch, not silently inherit the file picker.
3324
3345
  if (seed.dataset.seedAction === 'drawing') {
@@ -3334,7 +3355,7 @@
3334
3355
  showToast(missingWorkspaceWorkflowMessage(templateId), 'warn');
3335
3356
  return;
3336
3357
  }
3337
- createFromDrawing(appId, templateId, files, { linkFrom });
3358
+ createFromDrawing(appId, templateId, files, { linkFrom, buildMode: setupBuildMode });
3338
3359
  } else if (seed.dataset.seedAction === 'rvt') {
3339
3360
  const file = await pickRvtFile($seedRvt);
3340
3361
  if (file) createFromRvt(appId, templateId, file, linkFrom);
@@ -3888,9 +3909,20 @@
3888
3909
  else localStorage.removeItem(PROJECT_CHAT_INTAKE_KEY);
3889
3910
  }
3890
3911
 
3891
- function setProjectSetupError(message, { workspaceAction = false } = {}) {
3912
+ function setProjectSetupError(message, { workspaceAction = false, withoutLinkAction = null } = {}) {
3892
3913
  $projectSetupError.hidden = !message;
3893
3914
  $projectSetupError.textContent = message || '';
3915
+ // #2470 R6.7b: a link to the General project that can't be made is a choice, never a refusal.
3916
+ if (message && withoutLinkAction) {
3917
+ const action = document.createElement('button');
3918
+ action.type = 'button';
3919
+ action.className = 'project-setup-error-action';
3920
+ action.textContent = 'Create without linking';
3921
+ action.setAttribute('data-command-id', 'shell.project-setup-without-link');
3922
+ 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.');
3923
+ action.addEventListener('click', withoutLinkAction);
3924
+ $projectSetupError.append(' ', action);
3925
+ }
3894
3926
  if (message && workspaceAction) {
3895
3927
  const action = document.createElement('button');
3896
3928
  action.type = 'button';
@@ -3904,6 +3936,24 @@
3904
3936
  }
3905
3937
  }
3906
3938
 
3939
+ /**
3940
+ * #2470 R6.7b: why the General project can't take the link now, named the way the person knows it, and the choice. The
3941
+ * server's sentence is kept only where it already says what to do (a busy project says to wait).
3942
+ */
3943
+ function projectSetupLinkChoiceMessage(state, code, serverText) {
3944
+ const general = state.linkFrom?.name ? `“${state.linkFrom.name}”` : 'The General project';
3945
+ const why = {
3946
+ 'project-archived': `${general} was archived, so it can’t take the link.`,
3947
+ 'project-not-found': `${general} is no longer in this Workspace, so it can’t take the link.`,
3948
+ 'not-general': `${general} is no longer in this Workspace, so it can’t take the link.`,
3949
+ 'project-unavailable': `${general}’s folder can’t be read right now, so it can’t take the link.`,
3950
+ 'project-links-stale': `${general} or the Workspace changed since this dialog opened, so it can’t take the link.`,
3951
+ 'project-links-changed': `${general}’s modules changed since this dialog opened, so it can’t take the link.`,
3952
+ }[code] || String(serverText || `${general} can’t take the link right now.`).trim();
3953
+ const name = String(state.name || '').trim();
3954
+ return `${why} You can still create ${name ? `“${name}”` : 'the project'} without linking it.`;
3955
+ }
3956
+
3907
3957
  function projectSetupErrorMessage(error) {
3908
3958
  // A sentence the server wrote for the person (#1965 review) — what to fix, or what restarting costs —
3909
3959
  // names their own folders, so it is shown as written rather than run through the filter below.
@@ -3962,7 +4012,7 @@
3962
4012
  $projectSetupCreate.textContent = label || 'Create project & start chat';
3963
4013
  $projectSetupCreateOnly.textContent = busy && !projectSetupState.settingUp
3964
4014
  ? 'Creating…'
3965
- : projectSetupState.linkFrom ? 'Create project' : createOnlyLabel(projectSetupState.kind);
4015
+ : createOnlyLabel(projectSetupState.kind);
3966
4016
  if (!busy) {
3967
4017
  $projectSetupCreate.disabled = !projectSetupReady();
3968
4018
  $projectSetupCreateOnly.disabled = !projectSetupReady();
@@ -3995,7 +4045,7 @@
3995
4045
  // Setup kinds that start from no file at all: a Drawing Checker profile and a General project.
3996
4046
  const NO_FILE_SETUP_KINDS = ['drawing-check-profile', 'general-project'];
3997
4047
  function projectSetupProvider(state) {
3998
- if (!state || NO_CHAT_SETUP_KINDS.includes(state.kind) || state.linkFrom) return null;
4048
+ if (!state || NO_CHAT_SETUP_KINDS.includes(state.kind)) return null;
3999
4049
  const runtimes = bridge.chatProviderRuntimes?.() || [];
4000
4050
  const readiness = (id) => (id ? projectSetupProviderReadiness(runtimes.find((runtime) => runtime.id === id)) : 'unavailable');
4001
4051
  const canStart = (id) => readiness(id) !== 'unavailable';
@@ -4217,7 +4267,7 @@
4217
4267
  const $sourceKicker = $projectSetupSourceName.previousElementSibling;
4218
4268
  if ($sourceKicker) $sourceKicker.textContent = state.kind === 'general-project' ? 'Starting point' : 'Source';
4219
4269
  $projectSetupSourceName.parentElement?.setAttribute('aria-label', state.kind === 'general-project' ? 'Starting point' : 'Selected source drawings');
4220
- $projectSetupCreateOnly.textContent = state.busy ? 'Creating…' : state.linkFrom ? 'Create project' : createOnlyLabel(state.kind);
4270
+ $projectSetupCreateOnly.textContent = state.busy ? 'Creating…' : createOnlyLabel(state.kind);
4221
4271
  $projectSetupSourceCount.textContent = state.files.length > 1 ? `+ ${state.files.length - 1} more` : '';
4222
4272
  $projectSetupFolder.textContent = state.directory
4223
4273
  ? state.directory.path
@@ -4404,10 +4454,14 @@
4404
4454
  ...(state.sentBuildMode === 'quick' ? { buildMode: 'quick' } : {}),
4405
4455
  ...(state.sentBuildMode === 'quick' && state.sentFilterChoice === 'ai' ? { quickFilterByAi: true } : {}),
4406
4456
  ...(state.sentBuildMode === 'quick' && state.sentFilterChoice === 'ai' && state.sentExclusionsChoice === 'ai' ? { quickFilterExclusionsByAi: true } : {}),
4457
+ // #2470 R6.7b: added from a General project's Modules step, the project is made already linked there.
4458
+ ...(state.linkFrom ? { linkFrom: { projectId: state.linkFrom.projectId, sourceUuid: state.linkFrom.sourceUuid, rootId: state.linkFrom.rootId } } : {}),
4459
+ ...(state.linkFrom && state.withoutLink ? { withoutLink: true } : {}),
4407
4460
  });
4408
4461
  const project = result.project;
4409
4462
  state.project = project;
4410
4463
  state.request = result.request;
4464
+ state.moduleLink = result.moduleLink || null;
4411
4465
  state.buildModeNotice = result.buildModeNotice || null;
4412
4466
  if (!projects.some((item) => item.id === project.id)) {
4413
4467
  projects.unshift(project);
@@ -4428,13 +4482,25 @@
4428
4482
  $projectSetupFolderChoose.textContent = 'Choose…';
4429
4483
  }
4430
4484
  const outsideWorkspace = code === 'project-directory-outside-root';
4431
- setProjectSetupError(projectSetupErrorMessage(error), { workspaceAction: outsideWorkspace });
4485
+ // #2470 R6.7b: the server's own sentence on why the link can't be made, and the choice to go on without it.
4486
+ const linkChoice = startChat && state.linkFrom && error?.linkChoice === true;
4487
+ setProjectSetupError(linkChoice ? projectSetupLinkChoiceMessage(state, code, error.message) : projectSetupErrorMessage(error), {
4488
+ workspaceAction: outsideWorkspace,
4489
+ withoutLinkAction: linkChoice ? () => { state.withoutLink = true; void createProjectFromSetup(true); } : null,
4490
+ });
4432
4491
  setProjectSetupBusy(false);
4433
4492
  renderProjectSetup();
4434
4493
  return;
4435
4494
  }
4436
4495
  setProjectSetupBusy(false);
4437
4496
  closeProjectSetup({ restoreFocus: false });
4497
+ if (state.linkFrom) {
4498
+ // #2470 R6.7b: one message from the real outcome — the link to the General project, then what the chat is doing.
4499
+ globalThis.flolessProjectModules?.afterCreate?.({ project: state.project, linkFrom: state.linkFrom, moduleLink: state.moduleLink,
4500
+ outcome: 'ok', next: state.request?.buildMode === 'quick' ? 'The Quick model read is running in AI Chat.' : 'The drawing task is running in AI Chat.' });
4501
+ if (state.buildModeNotice?.why) showToast(state.buildModeNotice.why, 'warn');
4502
+ return;
4503
+ }
4438
4504
  // A General project's chat is Flo's kickoff; its first reply may still be on its way (#2470 R6.4).
4439
4505
  // #2521 row 7a: said from what was queued, never from the button still pressed.
4440
4506
  if (state.buildModeNotice?.why) showToast(`Project created. ${state.buildModeNotice.why}`, 'warn');
@@ -4444,6 +4510,24 @@
4444
4510
  : 'Project created — the drawing task is running in AI Chat.', 'ok');
4445
4511
  }
4446
4512
 
4513
+ // #2470 R6.7b: a recovery that asked the person to choose about the link is asked once per page.
4514
+ const projectChatIntakeLinkChoiceShown = new Set();
4515
+ async function recoverProjectChatIntake(submissionId, options) {
4516
+ const result = await bridge.resumeProjectChatIntake(submissionId, options);
4517
+ if (!result) return;
4518
+ if (!projects.some((item) => item.id === result.project.id)) projects.unshift(result.project);
4519
+ await openProject(result.project.id, result.project.app === 'floless-general' ? 'knowledge' : 'drawings');
4520
+ await bridge.openChatConversation(result.chat.chatId);
4521
+ forgetProjectChatIntake(submissionId);
4522
+ // #2470 R6.7b: started from a General project's Modules step: say what became of the link, never a silent "linked".
4523
+ const unlinked = result.moduleLink && result.moduleLink.ok === false
4524
+ ? (result.moduleLink.code === 'link-skipped' ? ' It isn’t linked to the General project, as you chose.'
4525
+ : ' It couldn’t be linked to the General project; link it from that project’s Modules step.')
4526
+ : '';
4527
+ // #2521 row 7a: a Quick choice queued Precise is said on recovery too, from the saved receipt.
4528
+ if (result.buildModeNotice?.why) showToast(`Recovered the project and its AI Chat.${unlinked} ${result.buildModeNotice.why}`, 'warn');
4529
+ else showToast(`Recovered the project and its AI Chat.${unlinked}`, unlinked && result.moduleLink.code !== 'link-skipped' ? 'warn' : 'ok');
4530
+ }
4447
4531
  async function resumeInterruptedProjectChatIntake() {
4448
4532
  if (projectChatIntakeRecoveryStarted) return;
4449
4533
  const submissionIds = pendingProjectChatIntakes();
@@ -4451,18 +4535,26 @@
4451
4535
  projectChatIntakeRecoveryStarted = true;
4452
4536
  for (const submissionId of submissionIds) {
4453
4537
  try {
4454
- const result = await bridge.resumeProjectChatIntake(submissionId);
4455
- if (!result) continue;
4456
- if (!projects.some((item) => item.id === result.project.id)) projects.unshift(result.project);
4457
- await openProject(result.project.id, result.project.app === 'floless-general' ? 'knowledge' : 'drawings');
4458
- await bridge.openChatConversation(result.chat.chatId);
4459
- forgetProjectChatIntake(submissionId);
4460
- // #2521 row 7a: a Quick choice queued Precise is said on recovery too, from the saved receipt.
4461
- if (result.buildModeNotice?.why) showToast(`Recovered the project and its AI Chat. ${result.buildModeNotice.why}`, 'warn');
4462
- else showToast('Recovered the project and its AI Chat.', 'ok');
4538
+ await recoverProjectChatIntake(submissionId);
4463
4539
  } catch (error) {
4464
4540
  const code = error && (error.code || error.body && error.body.code);
4465
- if (code === 'project-intake-not-found' || code === 'project-intake-damaged') {
4541
+ if (error?.linkChoice === true) {
4542
+ // The General project it was started from can't take the link now: ask once per page, never decide for them.
4543
+ // It stays until the person acts on it; a choice that fails is offered again.
4544
+ if (!projectChatIntakeLinkChoiceShown.has(submissionId)) {
4545
+ projectChatIntakeLinkChoiceShown.add(submissionId);
4546
+ showToast(`A project you started from a General project wasn’t created yet. ${projectSetupLinkChoiceMessage({}, code, error.message)}`, 'warn', {
4547
+ persistent: true,
4548
+ action: { label: 'Create without linking', commandId: 'shell.project-setup-recover-without-link',
4549
+ onClick: () => recoverProjectChatIntake(submissionId, { withoutLink: true }).catch((retryError) => {
4550
+ projectChatIntakeLinkChoiceShown.delete(submissionId);
4551
+ showToast(projectSetupErrorMessage(retryError), 'error');
4552
+ projectChatIntakeRecoveryStarted = false;
4553
+ void resumeInterruptedProjectChatIntake();
4554
+ }) },
4555
+ });
4556
+ }
4557
+ } else if (code === 'project-intake-not-found' || code === 'project-intake-damaged') {
4466
4558
  forgetProjectChatIntake(submissionId);
4467
4559
  } else if (code === 'project-intake-project-missing') {
4468
4560
  // The project this setup made was removed or replaced: nothing is left to resume, so say so once (#2470 R6.4).
@@ -4481,7 +4573,7 @@
4481
4573
  * working directory. Nothing is written while the dialog is open. Creation atomically publishes
4482
4574
  * project.json and an unsent initial-task draft; the headless provider is not contacted here.
4483
4575
  */
4484
- async function createFromDrawing(appId, templateId, files, { kind = 'drawings', sourceLabel = '', teklaSource = null, returnFocus = null, linkFrom = null } = {}) {
4576
+ async function createFromDrawing(appId, templateId, files, { kind = 'drawings', sourceLabel = '', teklaSource = null, returnFocus = null, linkFrom = null, buildMode = 'precise' } = {}) {
4485
4577
  if (!$projectSetup || projectSetupState) return false;
4486
4578
  // A Drawing Checker profile and a General project start with no source file: what goes in them comes later.
4487
4579
  if (!Array.isArray(files) || (!files.length && !NO_FILE_SETUP_KINDS.includes(kind))) return false;
@@ -4504,8 +4596,9 @@
4504
4596
  linkFrom,
4505
4597
  askCatalogue: kind === 'drawings' && templateId === 'steel-model',
4506
4598
  environment: null,
4507
- // #2521 row 7a: Precise unless the person presses Quick; what was sent is kept in `sentBuildMode`.
4508
- buildMode: 'precise',
4599
+ // #2521 row 7a: Precise unless the person presses Quick; what was sent is kept in `sentBuildMode`. #2811: a card
4600
+ // the person clicked in a chat may open the dialog with Quick already pressed; it is asked only where Quick is.
4601
+ buildMode: buildMode === 'quick' && kind === 'drawings' && templateId === 'steel-model' ? 'quick' : 'precise',
4509
4602
  // #2521 row 2c: the person's own Filter Save unless they press "Let the AI choose" (with Quick only).
4510
4603
  filterChoice: 'person',
4511
4604
  // Revision 3: with "Let the AI choose", the AI also approves what the read leaves out unless the person keeps it.
@@ -4523,7 +4616,7 @@
4523
4616
  renderProjectSetup();
4524
4617
  $projectSetup.classList.add('show');
4525
4618
  $projectSetupFolderChoose.focus();
4526
- if (!NO_CHAT_SETUP_KINDS.includes(kind) && !linkFrom) void refreshProjectSetupProviders(state);
4619
+ if (!NO_CHAT_SETUP_KINDS.includes(kind)) void refreshProjectSetupProviders(state);
4527
4620
  try {
4528
4621
  if (kind !== 'tekla-source') {
4529
4622
  await Promise.all(files.map(assertProjectSourceReadable));
@@ -5383,6 +5476,8 @@
5383
5476
  if (!nav.skipLeaveGuard && current && current.id !== p.id && !(await leaveOpenProject(nav.returnFocus))) return STAYED_IN_PROJECT;
5384
5477
  if (unwanted()) return STAYED_IN_PROJECT;
5385
5478
  if (current?.uuid !== p.uuid) revisionNoteEditorGeneration++;
5479
+ // #2470 R6.5b: the History view chosen on the project being left is not carried back to it after another one.
5480
+ if (current?.uuid !== p.uuid || current?.id !== p.id) historyView = { project: null, view: 'approvals' };
5386
5481
  current = p;
5387
5482
  // #2470 R6.6c: whatever editor is still loaded belongs to the project as it was before this open, and the frame is
5388
5483
  // reset below; until the new document says it is ready, no step message goes to the old one.
@@ -5470,6 +5565,8 @@
5470
5565
  refreshModelPresence(p.id, p.app).catch((e) => {
5471
5566
  console.error('[workspaces] could not resolve model presence', e);
5472
5567
  });
5568
+ // #3053: a read that finished while this project was closed, or before a reload, is still announced (where there is a strip).
5569
+ if (wsDescOf(p)?.filter) refreshReadCompletion(p).catch((e) => console.error('[workspaces] drawing-read notice failed', e));
5473
5570
  // BEFORE the first step renders, and that order is the fix rather than a tidy-up.
5474
5571
  //
5475
5572
  // `initialStep` is not always 'model' — a project re-opened from the picker keeps `currentStep`,
@@ -5530,7 +5627,9 @@
5530
5627
  applyModelPresence(present);
5531
5628
  // Restore only when this same project's authoritative answer says a model exists. A confirmed
5532
5629
  // preliminary lifecycle remains on Drawing Filter and gets the real prerequisite gate below.
5533
- if (present === 'model' && restore && currentStep === 'drawings') setStep(restore);
5630
+ // #2470 R6.5b: History on a kind with two views is never gated (its Activity view needs no model), so it is
5631
+ // restored on any known answer too, and opens on Activity when Approvals still has to wait.
5632
+ if (restore && currentStep === 'drawings' && (present === 'model' || (present !== 'unknown' && restore === 'history' && !stageGateFor(restore)))) setStep(restore);
5534
5633
  return true;
5535
5634
  })();
5536
5635
  modelPresenceProbe = { projectId, promise };
@@ -5737,6 +5836,24 @@
5737
5836
  return typeof value === 'string' && value.trim() ? value.trim() : null;
5738
5837
  }
5739
5838
 
5839
+ /**
5840
+ * The AI's latest sentence in the AI Chat conversation running this read (`req.chatNarration`, from the Requests
5841
+ * poll), when it is newer than the progress record stamped `recordAt`. Null for a terminal-run read, a narration
5842
+ * the record already covers, or anything malformed: the record then speaks alone, exactly as before.
5843
+ */
5844
+ // Words that belong to the software, not the drawings: the strip shows neither a record nor a chat sentence with them.
5845
+ const PROGRESS_INTERNAL_WORDS = /\b(?:schema|api|manifest|ledger|registration|binding|disposition|audit|reconcile|attestation|evidence|candidate|json|etag|floless-app-[a-z0-9-]+|reading-structural-drawings|steel-drawing-abbreviations|[a-z][a-z0-9.-]*\/v\d+)\b/i;
5846
+
5847
+ function chatNarrationView(req, recordAt, currentTime) {
5848
+ const n = req && req.chatNarration;
5849
+ if (req?.chatConversation?.executionOwner !== 'chat' || !n || typeof n !== 'object' || Array.isArray(n)) return null;
5850
+ const text = progressText(n.text);
5851
+ const at = typeof n.at === 'string' ? Date.parse(n.at) : NaN;
5852
+ if (!text || text.length > 600 || /[\u0000-\u0008\u000B\u000C\u000E-\u001F]/.test(text) || PROGRESS_INTERNAL_WORDS.test(text)) return null;
5853
+ if (!Number.isFinite(at) || at <= recordAt || currentTime - at < -PROGRESS_MAX_CLOCK_LEAD_MS) return null;
5854
+ return { text, at };
5855
+ }
5856
+
5740
5857
  /**
5741
5858
  * Turn the provider-neutral drawing checklist into the small, honest view this surface needs.
5742
5859
  * Returns null when the record cannot be shown truthfully — the caller then says so out loud
@@ -5751,7 +5868,6 @@
5751
5868
  const plainText = (value, max, nullable = false) => (nullable && value === null)
5752
5869
  || (typeof value === 'string' && !!value.trim() && value.length <= max
5753
5870
  && !/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/.test(value));
5754
- const internalVisible = /\b(?:schema|api|manifest|ledger|registration|binding|disposition|audit|reconcile|attestation|evidence|candidate|json|etag|floless-app-[a-z0-9-]+|reading-structural-drawings|steel-drawing-abbreviations|[a-z][a-z0-9.-]*\/v\d+)\b/i;
5755
5871
  const sourceSkills = new Set([
5756
5872
  'floless-app-steel-model', 'reading-structural-drawings', 'floless-app-steel-takeoff',
5757
5873
  'floless-app-approval', 'steel-drawing-abbreviations',
@@ -5764,22 +5880,22 @@
5764
5880
  && exactKeys(item, ['id', 'text', 'state', 'sources', 'verification', 'note'])
5765
5881
  && plainText(item.id, 100) && /^[a-z0-9][a-z0-9-]*$/.test(item.id)
5766
5882
  && !ids.has(item.id) && !!ids.add(item.id)
5767
- && plainText(item.text, 500) && !internalVisible.test(item.text)
5883
+ && plainText(item.text, 500) && !PROGRESS_INTERNAL_WORDS.test(item.text)
5768
5884
  && PROGRESS_ITEM_STATES.has(item.state)
5769
5885
  && Array.isArray(item.sources) && item.sources.length >= 1 && item.sources.length <= 10
5770
5886
  && item.sources.every((source) => source && typeof source === 'object' && !Array.isArray(source)
5771
5887
  && exactKeys(source, ['skill', 'section']) && sourceSkills.has(source.skill)
5772
5888
  && plainText(source.section, 200))
5773
5889
  && (item.verification === undefined || plainText(item.verification, 1_000))
5774
- && (item.note === undefined || (plainText(item.note, 1_000) && !internalVisible.test(item.note)))
5890
+ && (item.note === undefined || (plainText(item.note, 1_000) && !PROGRESS_INTERNAL_WORDS.test(item.note)))
5775
5891
  && (item.state !== 'done' || !!progressText(item.verification))
5776
5892
  && (!['blocked', 'waiting', 'provisional'].includes(item.state) || !!progressText(item.note)))
5777
5893
  || !Number.isSafeInteger(progress.revision) || progress.revision < 1
5778
5894
  || !plainText(progress.updatedAt, 50)
5779
5895
  || !/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(progress.updatedAt)
5780
- || !plainText(progress.done, 1_000) || internalVisible.test(progress.done)
5781
- || !plainText(progress.now, 1_000, true) || (progress.now && internalVisible.test(progress.now))
5782
- || !plainText(progress.next, 1_000, true) || (progress.next && internalVisible.test(progress.next))) return null;
5896
+ || !plainText(progress.done, 1_000) || PROGRESS_INTERNAL_WORDS.test(progress.done)
5897
+ || !plainText(progress.now, 1_000, true) || (progress.now && PROGRESS_INTERNAL_WORDS.test(progress.now))
5898
+ || !plainText(progress.next, 1_000, true) || (progress.next && PROGRESS_INTERNAL_WORDS.test(progress.next))) return null;
5783
5899
  // The checklist shape the server guarantees per status. A record that breaks it is corrupt or
5784
5900
  // from a future contract; either way its heading would be a claim about work nobody verified.
5785
5901
  const nowItems = progress.items.filter((item) => item.state === 'now').length;
@@ -5792,9 +5908,13 @@
5792
5908
  if (req.id && progress.requestId !== req.id) return null;
5793
5909
  const updatedAt = Date.parse(progress.updatedAt);
5794
5910
  if (!Number.isFinite(updatedAt)) return null;
5795
- const age = currentTime - updatedAt;
5796
- if (age < -PROGRESS_MAX_CLOCK_LEAD_MS) return null;
5797
- const stale = age >= PROGRESS_STALE_MS;
5911
+ if (currentTime - updatedAt < -PROGRESS_MAX_CLOCK_LEAD_MS) return null;
5912
+ // The record is the AI's checklist, rewritten only when the AI remembers to, while AI Chat shows every sentence
5913
+ // the AI writes as it reads. A real read narrated S-202 and S-203 in chat for eight minutes under a record still
5914
+ // saying it was reading the index sheets. So an active record yields to the newer chat narration, named as such.
5915
+ const narration = progress.status === 'active' ? chatNarrationView(req, updatedAt, currentTime) : null;
5916
+ const reportedAt = narration ? narration.at : updatedAt;
5917
+ const stale = currentTime - reportedAt >= PROGRESS_STALE_MS;
5798
5918
  // Count only completed checklist items. Their evidence is present, but this surface has not
5799
5919
  // independently audited it, so the UI must not promote "complete" into "verified".
5800
5920
  const doneCount = progress.items.filter((item) => item.state === 'done').length;
@@ -5845,19 +5965,22 @@
5845
5965
  now = `Return to ${backTo} for next steps.`;
5846
5966
  next = null;
5847
5967
  }
5968
+ if (narration) {
5969
+ nowLabel = 'Latest in AI Chat';
5970
+ now = narration.text;
5971
+ }
5848
5972
  // A heartbeat nobody can refresh is not a heartbeat. Both arms below replace the forward-looking
5849
5973
  // plan with a recovery route, because carrying "Next: check every connection" into a stalled or
5850
5974
  // unreachable state presents work that is not happening as though it were queued.
5851
5975
  if (contactLost && progress.status === 'active') {
5852
5976
  state = 'waiting';
5853
5977
  heading = 'Progress updates have stopped arriving';
5854
- nowLabel = 'Last reported';
5855
- now = progressText(progress.now) || now;
5978
+ nowLabel = narration ? 'Last reported in AI Chat' : 'Last reported';
5856
5979
  next = 'FloLess could not reach its own server. This refreshes by itself when the connection returns.';
5857
5980
  } else if (stale && progress.status === 'active') {
5858
5981
  state = 'waiting';
5859
5982
  heading = 'No progress update in the last 8 minutes';
5860
- nowLabel = 'Last reported';
5983
+ nowLabel = narration ? 'Last reported in AI Chat' : 'Last reported';
5861
5984
  next = inChat ? 'Ask the read in AI Chat to continue.' : 'Return to the same terminal AI session that prepared this read and ask it to continue.';
5862
5985
  } else if (stale && progress.status === 'complete') {
5863
5986
  state = 'waiting';
@@ -5876,13 +5999,18 @@
5876
5999
  next,
5877
6000
  requestId: progress.requestId,
5878
6001
  revision: progress.revision,
5879
- updatedAt: progress.updatedAt,
6002
+ updatedAt: narration ? new Date(narration.at).toISOString() : progress.updatedAt,
6003
+ ...(narration ? { fromChat: true } : {}),
5880
6004
  };
5881
6005
  }
5882
6006
 
5883
6007
  // #2926: no picture asked for in this long, and a conversation that is not running, means a chat-run read is not
5884
6008
  // reading. A terminal-run read has only its pictures to prove that once its progress record is stale.
5885
6009
  const FLO_FRESH_WORK_MS = 2 * 60_000;
6010
+ // A conversation still replying after it was handed this read's pictures is most likely still studying them: seen
6011
+ // on a real read in AI Chat (2026-11-01), all nine tiles of a sheet in under a minute, then minutes of study. It
6012
+ // keeps Flo thinking this long after the last picture, never longer: the reply might be to something else.
6013
+ const FLO_BUSY_LOOK_MS = 10 * 60_000;
5886
6014
  const FLO_HASH = /^[0-9a-f]{64}$/;
5887
6015
  function floLookOk(l) {
5888
6016
  return !!l && typeof l === 'object' && typeof l.pageId === 'string' && FLO_HASH.test(l.sourceHash)
@@ -5897,17 +6025,19 @@
5897
6025
  * signals only. `reading` while it is evidently working (with the sheet pictures it last asked for), `waiting`
5898
6026
  * only while the AI has really asked the person something, and `off` otherwise, with the reason.
5899
6027
  *
5900
- * `view` is drawingProgressView()'s projection of the same request (null when the strip shows no live progress).
6028
+ * `view` is drawingProgressView()'s projection of the same request: null when the AI has written no progress
6029
+ * record yet, or one the strip cannot show.
5901
6030
  * ctx: { contactLost, chatAsking (AI Chat shows a question or approval on this read's conversation), pendingSave }.
5902
6031
  */
5903
6032
  function filterFloState(req, view, ctx) {
5904
6033
  ctx = ctx || {};
5905
6034
  const off = (why) => ({ mode: 'off', why });
5906
- if (!req || !view) return off('no-read');
6035
+ if (!req) return off('no-read');
5907
6036
  // Before Save, and while it holds unsaved edits, the stage is the person's own work: Flo stays off it.
5908
6037
  if (req.filterCheckpointCurrent !== true || ctx.pendingSave) return off('not-saved');
5909
6038
  if (ctx.contactLost) return off('contact-lost');
5910
- const progress = req.steelProgress;
6039
+ // A record the strip cannot show is no record: only its question, approval or pictures speak for the read.
6040
+ const progress = view ? req.steelProgress : null;
5911
6041
  const raw = progress && progress.status;
5912
6042
  if (raw === 'cancelled') return off('cancelled');
5913
6043
  const chat = req.chatConversation || null;
@@ -5918,9 +6048,11 @@
5918
6048
  const approval = code === 'approval' || chat?.chatState === 'awaiting-approval';
5919
6049
  const asked = code === 'ai-question' || approval || ctx.chatAsking === true;
5920
6050
  const chatWorking = inChat && (chat.chatState === 'starting' || chat.chatState === 'running');
5921
- // The AI writes `waiting`, then asks or stops. A conversation still running past it has moved on (the person
5922
- // pressed Save and FloLess continued the read) and the record is stale until the AI next writes it: not a question.
5923
- const recordWaits = raw === 'waiting' && !chatWorking;
6051
+ const busy = inChat && chat.chatState === 'busy-elsewhere';
6052
+ // The AI writes `waiting`, then asks or stops. A conversation still replying past it has moved on (the person
6053
+ // pressed Save and FloLess continued the read, or typed "continue") and the record is stale until the AI next
6054
+ // writes it: not a question.
6055
+ const recordWaits = raw === 'waiting' && !chatWorking && !busy;
5924
6056
  if (recordWaits || asked) {
5925
6057
  const note = recordWaits ? progressText(progress.items.find((item) => item.state === 'waiting')?.note) : null;
5926
6058
  const question = code === 'ai-question' ? progressText(req.run?.question) : null;
@@ -5929,20 +6061,28 @@
5929
6061
  : code === 'ai-question' ? 'The AI has asked you a question.' : 'The AI is waiting for you in AI Chat.');
5930
6062
  return { mode: 'waiting', text, chat: inChat };
5931
6063
  }
5932
- if (raw !== 'active') return off('not-active');
5933
6064
  const looks = (Array.isArray(req.steelLooks) ? req.steelLooks : []).filter(floLookOk);
5934
- const freshPictures = looks.some((l) => l.ageMs < FLO_FRESH_WORK_MS);
6065
+ const freshPictures = looks.some((l) => l.ageMs < (busy ? FLO_BUSY_LOOK_MS : FLO_FRESH_WORK_MS));
6066
+ // Seen on a real read in AI Chat (2026-11-01): the AI fetched S-201 tile by tile before it wrote its first
6067
+ // progress record, and Flo stayed hidden while it read. Its pictures prove the work; the words say what is unknown.
6068
+ // The same after Save: the record still says "waiting for you to press Save filter" (a wait the conversation has
6069
+ // moved past, above) until the AI next writes it.
6070
+ if (!view || raw === 'waiting') {
6071
+ return freshPictures ? { mode: 'reading', now: 'The AI is looking at the drawings. Its progress list has not caught up yet.', looks }
6072
+ : off(view ? 'not-active' : 'no-record');
6073
+ }
6074
+ if (raw !== 'active') return off('not-active');
5935
6075
  // A record the AI has not rewritten for 8 minutes is stale, but pictures it asked for in the last two, or its
5936
6076
  // conversation still running, prove it is still at work (seen on a real read, #2926: tiles seconds old, sentence
5937
6077
  // 9 minutes old). Flo keeps going then, and says the sentence is the last one reported, the strip's own words.
5938
6078
  if (view.state !== 'active') {
5939
- return freshPictures || chatWorking ? { mode: 'reading', now: view.now, looks, label: 'Last reported:' } : off('not-active');
6079
+ return freshPictures || chatWorking ? { mode: 'reading', now: view.now, looks, label: `${view.nowLabel}:` } : off('not-active');
5940
6080
  }
5941
6081
  // Pictures for this very read are proof of work even when the chat calls its turn busy elsewhere, which it
5942
6082
  // does whenever the person typed into the read's conversation and the read carried on.
5943
6083
  const working = freshPictures || !inChat || chatWorking;
5944
6084
  if (!working) return off('idle');
5945
- return { mode: 'reading', now: view.now, looks };
6085
+ return view.fromChat ? { mode: 'reading', now: view.now, looks, label: `${view.nowLabel}:` } : { mode: 'reading', now: view.now, looks };
5946
6086
  }
5947
6087
 
5948
6088
  // Keeps the last read and view applyStageGating() painted (`syncFilterFlo.last`), so a chat question opening
@@ -6128,11 +6268,160 @@
6128
6268
 
6129
6269
  function wireStageGuidanceFilterAction() {
6130
6270
  $stageGuidance?.addEventListener('click', (e) => {
6271
+ const done = e.target.closest('[data-read-done]');
6272
+ if (done) { readCompletionAction(done.dataset.readDone); return; }
6131
6273
  if (!e.target.closest('[data-revfilter]')) return;
6132
6274
  openDrawingFilterNextAction();
6133
6275
  });
6134
6276
  }
6135
6277
 
6278
+ // ── #3053: "Your model is ready to view" ─────────────────────────────────────────────────────
6279
+ // A finished drawing read used to say so only in a toast, which a person working in the Drawing Filter, or
6280
+ // reading the AI's long summary, missed. The strip now keeps a completion band until they close it. It is
6281
+ // decided from History, never from the AI's words or a request disappearing: the newest version must be one a
6282
+ // drawing read saved, and no other read may be waiting, failed or staged (the strip shows those instead).
6283
+ // (Its state, READ_COMPLETION_* and `readCompletion`, is declared beside `currentStep`: the strip can paint early in boot.)
6284
+
6285
+ /** The completion band a project's History calls for, or null. `versions` newest first; `seen`: the newest version already closed. */
6286
+ function readCompletionNotice(versions, seen, now) {
6287
+ const tip = Array.isArray(versions) ? versions[0] : null;
6288
+ if (!tip || tip.kind !== 'revision-read' || !Number.isSafeInteger(tip.n) || tip.n <= seen) return null;
6289
+ const at = Date.parse(tip.ts || '');
6290
+ if (!Number.isFinite(at) || now - at > READ_COMPLETION_MAX_AGE_MS) return null;
6291
+ const count = (value) => (Number.isSafeInteger(value) && value >= 0 ? value : null);
6292
+ return { n: tip.n, members: count(tip.readiness?.physicalMemberCount), questions: count(tip.readiness?.currentUnansweredQuestionCount) };
6293
+ }
6294
+
6295
+ const readCompletionKey = (proj) => READ_COMPLETION_SEEN + (proj.uuid || proj.id);
6296
+ function readCompletionSeen(seenKey) {
6297
+ try { const n = Number(localStorage.getItem(seenKey)); return Number.isSafeInteger(n) ? n : 0; }
6298
+ catch { return 0; }
6299
+ }
6300
+ function markReadCompletionSeen(seenKey, n) {
6301
+ try { if (n > readCompletionSeen(seenKey)) localStorage.setItem(seenKey, String(n)); }
6302
+ catch { /* private mode: the band comes back on the next open, which is the safe side */ }
6303
+ }
6304
+
6305
+ /** Set the open project's band from its History (`vr`: an answer already in hand). Repaints the strip. */
6306
+ async function refreshReadCompletion(proj, vr = null) {
6307
+ if (!proj) return;
6308
+ const gen = ++readCompletionGen;
6309
+ let answer = vr;
6310
+ if (!answer) {
6311
+ try { answer = await api(`/api/projects/${encodeURIComponent(proj.id)}/versions`); }
6312
+ catch (err) {
6313
+ // History that cannot be read now shows no band; it is looked up again on the next open or read. No toast in
6314
+ // its place: a read that leaves the list unseen may have been discarded in another tab, and one applied here
6315
+ // was already confirmed by its review dialog ("Revision applied").
6316
+ if (current?.id === proj.id && gen === readCompletionGen) console.warn('[workspaces] could not read History for the drawing-read notice', err);
6317
+ return;
6318
+ }
6319
+ }
6320
+ if (current?.id !== proj.id || gen !== readCompletionGen) return;
6321
+ const seenKey = readCompletionKey(proj);
6322
+ const notice = readCompletionNotice(answer?.versions, readCompletionSeen(seenKey), Date.now());
6323
+ readCompletion = notice ? { projectId: proj.id, seenKey, ...notice } : null;
6324
+ applyStageGating();
6325
+ }
6326
+
6327
+ /**
6328
+ * A newer read for this project replaces the band of every version up to its starting point — painted or not, so
6329
+ * clearing that read later never announces an older one as new — and voids any History lookup still out.
6330
+ */
6331
+ function retireReadCompletion(proj, baseVersion) {
6332
+ if (!proj || !Number.isSafeInteger(baseVersion) || baseVersion <= 0) return;
6333
+ readCompletionGen++;
6334
+ markReadCompletionSeen(readCompletionKey(proj), baseVersion);
6335
+ if (readCompletion && readCompletion.n <= baseVersion) readCompletion = null;
6336
+ }
6337
+
6338
+ /** The band's own contents. `step`: the open project step (Open model is left out on Model, where it would do nothing). */
6339
+ function buildReadCompletion(notice, step) {
6340
+ const el = (tag, className, text) => {
6341
+ const node = document.createElement(tag);
6342
+ if (className) node.className = className;
6343
+ if (text) node.textContent = text;
6344
+ return node;
6345
+ };
6346
+ const plural = (n, one, many) => `${n} ${n === 1 ? one : many}`;
6347
+ const head = el('div', 'wsg-head');
6348
+ const signal = el('span', 'wsg-signal');
6349
+ signal.setAttribute('aria-hidden', 'true');
6350
+ head.append(signal, el('strong', '', 'Your model is ready to view.'));
6351
+ const line = el('p', 'wsg-done-line', `Drawing read finished. Version ${notice.n} is on History`
6352
+ + (notice.members === null ? '' : ` with ${plural(notice.members, 'member', 'members')}`)
6353
+ + `. ${step === 'model' ? 'You can explore it here.' : 'Open the Model tab to explore it.'} It has not been checked or approved.`);
6354
+ const parts = [head, line];
6355
+ if (notice.questions) {
6356
+ parts.push(el('p', 'wsg-done-line', `${plural(notice.questions, 'question', 'questions')} from the read still `
6357
+ + `${notice.questions === 1 ? 'needs' : 'need'} your answer.`));
6358
+ }
6359
+ const tip = el('p', 'wsg-done-line');
6360
+ tip.append(el('strong', '', 'We strongly recommend starting a new chat for your next task.'),
6361
+ document.createTextNode(' A chat that ran a drawing read holds a lot of context, so continuing in it may use more tokens and cost more.'));
6362
+ parts.push(tip);
6363
+ const actions = el('div', 'wsg-actions');
6364
+ const button = (action, label, className, commandId, hint) => {
6365
+ const b = el('button', className, label);
6366
+ b.type = 'button';
6367
+ b.dataset.readDone = action;
6368
+ b.dataset.commandId = commandId;
6369
+ b.setAttribute('data-tip', hint);
6370
+ actions.appendChild(b);
6371
+ };
6372
+ if (step !== 'model') button('open', 'Open model', 'btn-mini primary', 'shell.read-complete-open-model', 'Go to the Model tab to explore the model this read built');
6373
+ button('chat', 'Start new chat', 'btn-mini', 'shell.read-complete-new-chat', 'Open a fresh AI Chat conversation in this project. This one stays in your chat history.');
6374
+ button('dismiss', 'Dismiss', 'btn-mini wsg-dismiss', 'shell.read-complete-dismiss', 'Close this notice. The model and History are unchanged.');
6375
+ parts.push(actions);
6376
+ return parts;
6377
+ }
6378
+
6379
+ /** Paint the band into the strip: always expanded, announced once per version, never moving focus. */
6380
+ function paintReadCompletion(notice) {
6381
+ const key = `read-done:${notice.projectId}:${notice.n}:${notice.members}:${notice.questions}:${currentStep === 'model'}`;
6382
+ $stageGuidance.hidden = false;
6383
+ if ($stageGuidance._renderKey === key) return;
6384
+ const announced = String($stageGuidance._renderKey || '').startsWith(`read-done:${notice.projectId}:${notice.n}:`);
6385
+ $stageGuidance._renderKey = key;
6386
+ $stageGuidance.className = 'ws-stage-guidance state-complete';
6387
+ $stageGuidance.replaceChildren(...buildReadCompletion(notice, currentStep));
6388
+ markScrollable($stageGuidance);
6389
+ const live = document.getElementById('ws-stage-guidance-live');
6390
+ if (live && !announced) live.textContent = 'Drawing read finished. Your model is ready to view in the Model tab.';
6391
+ }
6392
+
6393
+ function readCompletionAction(action) {
6394
+ const notice = readCompletion;
6395
+ if (!notice || current?.id !== notice.projectId) return;
6396
+ if (action === 'open') {
6397
+ setStep('model');
6398
+ applyStageGating();
6399
+ // The band on Model has no Open model button, so focus follows the person to the tab they asked for.
6400
+ $stepTabs?.querySelector('button[data-step="model"]')?.focus();
6401
+ return;
6402
+ }
6403
+ if (action === 'chat') {
6404
+ Promise.resolve().then(() => {
6405
+ if (typeof window.flolessChat?.startNewChat !== 'function') {
6406
+ throw Object.assign(new Error('AI Chat is still loading. Try Start new chat again in a moment.'), { personCopy: true });
6407
+ }
6408
+ return window.flolessChat.startNewChat(notice.projectId);
6409
+ }).catch((err) => {
6410
+ // A reason AI Chat wrote for the person is shown as it is; anything else is an unexpected failure. Opening a
6411
+ // new chat changes nothing, so it is always safe to try again.
6412
+ if (err?.personCopy) showToast(`Couldn’t start a new chat. ${err.message}`, 'warn');
6413
+ else showFailureToast(err, { action: 'start a new chat', retrySafe: true });
6414
+ });
6415
+ return;
6416
+ }
6417
+ if (action !== 'dismiss') return;
6418
+ markReadCompletionSeen(notice.seenKey, notice.n);
6419
+ readCompletion = null;
6420
+ applyStageGating();
6421
+ // The button is gone with the band: put focus on the step the person is on rather than letting it drop to the page.
6422
+ $stepTabs?.querySelector('button[data-step].active')?.focus();
6423
+ }
6424
+
6136
6425
  function stageGuidanceRow(label, text) {
6137
6426
  const row = document.createElement('div');
6138
6427
  row.className = 'wsg-row';
@@ -6185,7 +6474,7 @@
6185
6474
  const scope = projectId ?? (typeof current !== 'undefined' && current ? current.id : '');
6186
6475
  const choices = $stageGuidance._collapseChoices ||= new Map();
6187
6476
  const key = `${scope}:` + (progress
6188
- ? `progress:${progress.requestId}:${progress.state}:${progress.revision}:${progress.heading}`
6477
+ ? `progress:${progress.requestId}:${progress.state}:${progress.revision}:${progress.heading}:${progress.updatedAt}`
6189
6478
  : `text:${state}:${typeof content === 'string' ? content : ''}`);
6190
6479
  $stageGuidance.hidden = false;
6191
6480
  if ($stageGuidance._renderKey === key) return;
@@ -6371,8 +6660,11 @@
6371
6660
  : 'Then press Save filter in the top-right corner. After Save, return to the terminal AI that prepared it and tell it to continue.';
6372
6661
  }
6373
6662
 
6374
- function stageGateFor(step) {
6663
+ function stageGateFor(step, opts) {
6375
6664
  const d = wsApp();
6665
+ // #2470 R6.5b: the History step's Activity view needs no model, so where the step has two views it is never locked;
6666
+ // only its Approvals view is (`{ ledger: true }` asks for that), and syncHistoryViews opens the step on Activity then.
6667
+ if (step === 'history' && !opts?.ledger && typeof hasHistoryViews === 'function' && hasHistoryViews(d)) return '';
6376
6668
  if (!d || !d.filter || !['model', 'rfis', 'exports', 'history'].includes(step)) return '';
6377
6669
  const initialRead = revCardReq && isInitialRevisionRead(revCardReq);
6378
6670
  const waitingForInitial = initialRead && lastRevState === 'pending';
@@ -6406,15 +6698,23 @@
6406
6698
  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.';
6407
6699
  return 'Read and save a Drawing Filter first. The model will unlock after the first drawing read.';
6408
6700
  }
6409
- if (waitingForInitial) return `The ${step === 'exports' ? 'steel model' : 'first model'} must be ready before ${step === 'exports' ? 'exports' : 'history'} is available.`;
6701
+ // The History step's own gate names the step; its Approvals view's gate (#2470 R6.5b) names that view, and RFIs names RFIs.
6702
+ const later = step === 'exports' ? 'Exports' : step === 'rfis' ? 'RFIs' : opts?.ledger ? 'Approvals' : 'History';
6703
+ 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.`;
6410
6704
  if (projectContractLifecycle === 'filter-checkpoint' && !revisionListKnown) return 'Checking the drawing read. Stages open once FloLess knows where it stands.';
6411
- 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.`;
6412
- return `Create the first steel model before opening ${step === 'exports' ? 'Exports' : 'History'}.`;
6705
+ if (projectContractLifecycle === 'filter-checkpoint') return `Attach the drawing set again in Drawing Filter before opening ${later}. The earlier request can no longer continue.`;
6706
+ return `Create the first steel model before opening ${later}.`;
6413
6707
  }
6414
6708
 
6415
6709
  function applyStageGating() {
6416
6710
  const d = wsApp();
6417
6711
  if (!$stepTabs) return;
6712
+ // The History step's Approvals view has its own gate (#2470 R6.5b): repaint the switch as the model arrives or goes.
6713
+ if (typeof syncHistoryViews === 'function' && typeof currentStep !== 'undefined') {
6714
+ const activity = syncHistoryViews(currentStep, d);
6715
+ // A gate that appears under the open ledger moves the step to Activity (once: setStep leaves the panes matching).
6716
+ if (currentStep === 'history' && activity && !$wsHistory.hidden) setStep('history');
6717
+ }
6418
6718
  if (!d || !d.filter) {
6419
6719
  // The tab strip is shared across projects. Remove every steel-only gate when switching to an
6420
6720
  // app without a Drawing Filter, or the next app inherits disabled tabs from the previous one.
@@ -6479,7 +6779,8 @@
6479
6779
  const unavailableInitial = initialRead && lastRevState === 'unavailable';
6480
6780
  const ownsProgress = waitingForInitial && stageGuidanceOwnsSavedCheckpoint(revCardReq);
6481
6781
  const liveProgress = ownsProgress ? drawingProgressView(revCardReq, Date.now(), revRequestsFailed) : null;
6482
- syncFilterFlo(liveProgress ? revCardReq : null, liveProgress);
6782
+ // Flo follows the read the strip owns even before its first progress record: its pictures are enough.
6783
+ syncFilterFlo(ownsProgress ? revCardReq : null, liveProgress);
6483
6784
  if (ownsProgress && revCardReq?.steelProgress && !liveProgress) {
6484
6785
  const revision = Number.isSafeInteger(revCardReq.steelProgress.revision)
6485
6786
  ? String(revCardReq.steelProgress.revision) : `invalid:${String(revCardReq.steelProgress.revision)}`;
@@ -6503,6 +6804,11 @@
6503
6804
  // Saving the Filter can unlock the tabs while its initial drawing read is still running.
6504
6805
  // Progress belongs to that read, not to the prerequisite gate; only idle guidance needs a gate.
6505
6806
  if (!locked && !stripPending) {
6807
+ // #3053: with nothing else to say and no other read in flight, a finished read's band stays up until closed.
6808
+ if (readCompletion && current?.id === readCompletion.projectId && lastRevState === 'none' && revisionListKnown) {
6809
+ paintReadCompletion(readCompletion);
6810
+ return;
6811
+ }
6506
6812
  clearStageGuidance();
6507
6813
  return;
6508
6814
  }
@@ -6518,7 +6824,7 @@
6518
6824
  return;
6519
6825
  }
6520
6826
  const guidance = stagedInitial
6521
- ? 'The drawing read is complete · Open Drawing Filter and choose Review changes before moving to Model, Exports, or History.'
6827
+ ? 'The drawing read is complete · Open Drawing Filter and choose Review changes before moving to Model, Exports, or Approvals in History.'
6522
6828
  : failedInitial
6523
6829
  ? (revCardReq?.canClear === true
6524
6830
  ? 'The drawing read failed · Return to Drawing Filter, press Dismiss, then attach the drawing set again.'
@@ -6561,7 +6867,7 @@
6561
6867
  : 'Checking the drawing read · FloLess is looking up this project’s drawing request.')
6562
6868
  : projectContractLifecycle === 'filter-checkpoint'
6563
6869
  ? 'Drawing read needs restarting · The earlier drawing request is no longer available. Attach the drawing set again in Drawing Filter to restart the read.'
6564
- : 'Start in Drawing Filter by attaching a PDF drawing set. The Model, Exports, and History stages unlock after the first steel model is created.';
6870
+ : '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.';
6565
6871
  paintStageGuidance(guidance, failedInitial || unavailableInitial ? 'failed' : 'info');
6566
6872
  if (waitingForInitial && revCardReq?.prepassReady && !revCardReq?.filterCheckpointCurrent) {
6567
6873
  appendStageGuidanceFilterAction();
@@ -6607,6 +6913,60 @@
6607
6913
  return true;
6608
6914
  }
6609
6915
 
6916
+ /**
6917
+ * Show or hide the History view switch for step `s` and say which view it is on. Returns true when the step shows the
6918
+ * activity journal instead of the ledger. Called from setStep, which reaches it through `typeof` (harnesses lift
6919
+ * setStep alone).
6920
+ */
6921
+ function syncHistoryViews(s, d) {
6922
+ const project = typeof current !== 'undefined' ? current : null;
6923
+ const shown = s === 'history' && hasHistoryViews(d) && !!project;
6924
+ // Before a Steel project's first model the ledger has nothing to show and its readiness checks would refuse, so the
6925
+ // step opens on Activity and Approvals says why instead (nothing refuses: the step still opens).
6926
+ const ledgerGate = shown ? stageGateFor('history', { ledger: true }) : '';
6927
+ // Opened on Activity for that reason, it stays there when the model arrives: the view never changes under the person.
6928
+ if (ledgerGate) historyView = { project: historyViewKey(project), view: 'activity' };
6929
+ const view = shown && historyView.project === historyViewKey(project) ? historyView.view : 'approvals';
6930
+ const box = document.getElementById('ws-history-views');
6931
+ if (box) {
6932
+ box.hidden = !shown;
6933
+ for (const b of box.querySelectorAll('[data-history-view]')) {
6934
+ const on = b.dataset.historyView === view;
6935
+ b.setAttribute('aria-checked', String(on));
6936
+ b.setAttribute('tabindex', on ? '0' : '-1');
6937
+ if (b.dataset.historyView !== 'approvals') continue;
6938
+ if (ledgerGate) { b.setAttribute('aria-disabled', 'true'); b.dataset.tip = ledgerGate; }
6939
+ else { b.removeAttribute('aria-disabled'); b.dataset.tip = APPROVALS_TIP; }
6940
+ }
6941
+ }
6942
+ return shown && view === 'activity';
6943
+ }
6944
+ /** The person picked a History view: remember it for this project, show it, and keep focus on the choice. */
6945
+ function chooseHistoryView(view) {
6946
+ if (!current || currentStep !== 'history' || (view !== 'approvals' && view !== 'activity')) return;
6947
+ const ledgerGate = view === 'approvals' ? stageGateFor('history', { ledger: true }) : '';
6948
+ if (ledgerGate) { showToast(ledgerGate, 'warn'); return; }
6949
+ const was = syncHistoryViews('history', wsApp()) ? 'activity' : 'approvals';
6950
+ historyView = { project: historyViewKey(current), view };
6951
+ if (was === view) return;
6952
+ setStep('history');
6953
+ document.querySelector(`#ws-history-views [data-history-view="${view}"]`)?.focus();
6954
+ }
6955
+ {
6956
+ const box = document.getElementById('ws-history-views');
6957
+ box?.addEventListener('click', (e) => {
6958
+ const b = e.target.closest('[data-history-view]');
6959
+ if (b) chooseHistoryView(b.dataset.historyView);
6960
+ });
6961
+ // Arrow keys move the choice, as in any radio group; Space and Enter press the focused one (a button already does).
6962
+ box?.addEventListener('keydown', (e) => {
6963
+ if (!['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown'].includes(e.key)) return;
6964
+ e.preventDefault();
6965
+ const checked = box.querySelector('[aria-checked="true"]')?.dataset.historyView;
6966
+ chooseHistoryView(checked === 'activity' ? 'approvals' : 'activity');
6967
+ });
6968
+ }
6969
+
6610
6970
  /**
6611
6971
  * A step the PERSON picked (a tab or a "go to" link), as opposed to one the shell restores. While a
6612
6972
  * project opens, `pendingPresenceStep` holds the step to restore once the lifecycle probe answers;
@@ -6644,6 +7004,7 @@
6644
7004
  b.classList.toggle('active', on);
6645
7005
  b.setAttribute('aria-selected', String(on));
6646
7006
  });
7007
+ if (typeof revealActiveStepTab === 'function') revealActiveStepTab();
6647
7008
  // An app with no filter (vectorize) has an empty `drawings` frame URL — never src it; its Source
6648
7009
  // step shows a lightweight placeholder pane instead of an about:blank iframe.
6649
7010
  const d = wsApp();
@@ -6698,8 +7059,12 @@
6698
7059
  const showExports = s === 'exports';
6699
7060
  $wsExports.hidden = !showExports;
6700
7061
  if (showExports) safeRenderExports('when you opened the Exports step');
6701
- // History is likewise a shell-rendered pane: the project's version ledger.
6702
- const showHistory = s === 'history';
7062
+ // History is likewise a shell-rendered pane: the project's version ledger. On a module project its step has a second
7063
+ // view, the activity journal (#2470 R6.5b), which shows in the journal pane below instead of the ledger.
7064
+ const historyActivity = typeof syncHistoryViews === 'function' && syncHistoryViews(s, d);
7065
+ const showHistory = s === 'history' && !historyActivity;
7066
+ // Leaving the ledger by any route (another step, its Activity view, or a gate that appeared) ends what it started.
7067
+ if (!showHistory && !$wsHistory.hidden && typeof leaveHistoryLedger === 'function') leaveHistoryLedger();
6703
7068
  $wsHistory.hidden = !showHistory;
6704
7069
  if (showHistory) renderHistory();
6705
7070
  else { closeRollbackConfirm(); closeBaseMenu(); } // don't leave a popover open behind a step switch
@@ -6745,14 +7110,15 @@
6745
7110
  const project = typeof current !== 'undefined' ? current : null;
6746
7111
  if (showModules && project && window.flolessProjectModules) window.flolessProjectModules.render($modulesPane, project);
6747
7112
  }
6748
- // #2470 R6.5: a General project's History is a shell-rendered pane too: its journal (project-history.js). Reached
7113
+ // #2470 R6.5: a General project's History is a shell-rendered pane too: its journal (project-history.js); #2470 R6.5b:
7114
+ // so is a module project's History step on its Activity view (historyActivity, above). Reached
6749
7115
  // through globalThis, like the RFIs one, so a harness that lifts setStep without it still runs.
6750
7116
  const $journalPane = document.getElementById('ws-journal');
6751
7117
  if ($journalPane) {
6752
- const showJournal = s === 'journal';
7118
+ const showJournal = s === 'journal' || historyActivity;
6753
7119
  $journalPane.hidden = !showJournal;
6754
7120
  const project = typeof current !== 'undefined' ? current : null;
6755
- if (showJournal && project) globalThis.flolessProjectHistory?.render?.($journalPane, project);
7121
+ if (showJournal && project) globalThis.flolessProjectHistory?.render?.($journalPane, project, historyActivity ? { variant: 'module' } : undefined);
6756
7122
  }
6757
7123
  // Knowledge is a shell-rendered pane too: the project's Knowledge Base (References column).
6758
7124
  const showKnowledge = s === 'knowledge';
@@ -6765,6 +7131,48 @@
6765
7131
  applyStageGating();
6766
7132
  syncWorkspaceReporter();
6767
7133
  }
7134
+ // When the window is too narrow for every step tab, the tabs scroll sideways inside the row (web/app.css
7135
+ // .ws-steps-row) so the step's own control at the end stays on screen. Mark which side has more tabs, keep the
7136
+ // chosen tab in view, and let a plain mouse wheel scroll them (a trackpad and Shift+wheel already do).
7137
+ function syncStepTabsOverflow() {
7138
+ const rest = $stepTabs.scrollWidth - $stepTabs.clientWidth - $stepTabs.scrollLeft;
7139
+ const start = $stepTabs.scrollLeft > 1;
7140
+ const end = rest > 1;
7141
+ const fade = start && end ? 'both' : start ? 'start' : end ? 'end' : 'none';
7142
+ if ($stepTabs.dataset.fade !== fade) $stepTabs.dataset.fade = fade;
7143
+ }
7144
+ function revealActiveStepTab() {
7145
+ revealStepTab($stepTabs.querySelector('button.active'));
7146
+ }
7147
+ function revealStepTab(b) {
7148
+ if (b && !b.hidden && $stepTabs.scrollWidth > $stepTabs.clientWidth) {
7149
+ // Clear of the 24px fade, so the chosen tab is never half-faded. Scrolled by hand rather than scrollIntoView,
7150
+ // which would also scroll the clipped workspace panes around it.
7151
+ const before = b.offsetLeft - 24;
7152
+ const after = b.offsetLeft + b.offsetWidth + 24 - $stepTabs.clientWidth;
7153
+ if (before < $stepTabs.scrollLeft) $stepTabs.scrollLeft = Math.max(0, before);
7154
+ else if (after > $stepTabs.scrollLeft) $stepTabs.scrollLeft = after;
7155
+ }
7156
+ syncStepTabsOverflow();
7157
+ }
7158
+ $stepTabs.addEventListener('scroll', syncStepTabsOverflow, { passive: true });
7159
+ // The browser brings a focused tab only to the edge, under the fade; bring it clear of it like the chosen tab.
7160
+ $stepTabs.addEventListener('focusin', (e) => revealStepTab(e.target.closest('button[data-step]')));
7161
+ $stepTabs.addEventListener('wheel', (e) => {
7162
+ if (e.deltaX || !e.deltaY || e.ctrlKey) return;
7163
+ const from = $stepTabs.scrollLeft;
7164
+ // A wheel that counts in lines or pages (Firefox) is turned into pixels, or one notch would move about 3px.
7165
+ const unit = e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? $stepTabs.clientWidth : 1;
7166
+ $stepTabs.scrollLeft = from + e.deltaY * unit;
7167
+ if ($stepTabs.scrollLeft !== from) e.preventDefault();
7168
+ }, { passive: false });
7169
+ // A tab shown, hidden, relabelled or locked changes how much room the tabs need, and the window or a side panel
7170
+ // changes how much they have: either can start or end the overflow.
7171
+ if (typeof ResizeObserver === 'function') {
7172
+ const stepTabsSize = new ResizeObserver(() => revealActiveStepTab());
7173
+ stepTabsSize.observe($stepTabs);
7174
+ $stepTabs.querySelectorAll('button[data-step]').forEach((b) => stepTabsSize.observe(b));
7175
+ }
6768
7176
  $stepTabs.addEventListener('click', (e) => {
6769
7177
  const b = e.target.closest('button[data-step]');
6770
7178
  if (b?.getAttribute('aria-disabled') === 'true') {
@@ -7480,6 +7888,12 @@
7480
7888
  const keptEdits = onProject() && editorHasUnsavedEdits();
7481
7889
  if (onProject() && !keptEdits) reloadModelFromServerTruth();
7482
7890
  const fresh = onProject() ? await refreshApprovalState(project.id) : null;
7891
+ // #3053: an approval puts its own version on top of History, so a finished-read band saying "It has not been
7892
+ // checked or approved" is over: History is asked again, and an approve row at the head shows no band.
7893
+ // (`typeof`: the approval tests lift this function on its own, without the band's code.)
7894
+ if (onProject() && typeof refreshReadCompletion === 'function') {
7895
+ refreshReadCompletion(project).catch((e) => console.error('[workspaces] drawing-read notice failed', e));
7896
+ }
7483
7897
  // A recovered receipt's count is from when it was approved; edits made since are pending now, so a
7484
7898
  // recovery reports the count just read back, and when that read failed it says so (null) rather than
7485
7899
  // claiming "No changes remain pending" over work it never looked at.
@@ -8242,6 +8656,7 @@
8242
8656
  // than a switch into an empty History pane.
8243
8657
  function wsOpenHistory() {
8244
8658
  if (!current) return;
8659
+ historyView = { project: historyViewKey(current), view: 'approvals' }; // reverting is the ledger's (#2470 R6.5b)
8245
8660
  setStep('history');
8246
8661
  // Move focus with the step. The click that gets here comes from a button inside the Model
8247
8662
  // iframe, which setStep() has just hidden — focus would otherwise collapse to <body>, leaving a
@@ -9647,7 +10062,10 @@
9647
10062
  return '<section class="kb-col kb-viewer kb-page"><div class="kb-view-head">' +
9648
10063
  `<span class="kb-view-name" data-tip="${escapeAttr(pg.title)}">${escapeHtml(pg.title)}</span>${type}${cited}` +
9649
10064
  '<button type="button" class="kb-x" data-kb-close data-tip="Back to graph" aria-label="Back to graph">✕</button></div>' +
9650
- `<div class="kb-page-body"><div class="kb-page-body-measure">${escapeHtml(pg.body)}</div></div></section>`;
10065
+ // #3003: rendered like the chat viewers (markdown, [[links]] as page titles); raw text only if chat is not loaded.
10066
+ (window.flolessChat?.knowledgePageHtml
10067
+ ? `<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>`
10068
+ : `<div class="kb-page-body"><div class="kb-page-body-measure">${escapeHtml(pg.body)}</div></div></section>`);
9651
10069
  }
9652
10070
  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>'; }
9653
10071
  /** `opts.citedGone` — the read carried a pinned generation and the server does not have it.
@@ -10071,7 +10489,7 @@
10071
10489
  // drift flag says the opposite in that state, so the strip and the page would disagree.
10072
10490
  const cur = knowledgeState && knowledgeState.currentGeneration ? knowledgeState.currentGeneration.generationId : null;
10073
10491
  const cited = !!generationId && cur !== generationId;
10074
- const h = kbViewHost(); if (h) h.innerHTML = kbPageShell(body.page, { cited });
10492
+ const h = kbViewHost(); if (h) { h.innerHTML = kbPageShell(body.page, { cited }); h.dataset.kbGeneration = body.generationId || ''; }
10075
10493
  } catch (err) {
10076
10494
  if (err && err.name === 'AbortError') return;
10077
10495
  // One sentence used to cover five causes with no record anywhere. The status separates the one
@@ -11907,6 +12325,9 @@
11907
12325
  // One delegated listener for the whole pane — the column is re-rendered wholesale on every state
11908
12326
  // change, so per-render wiring would leak handlers.
11909
12327
  $wsKnowledge.addEventListener('click', (e) => {
12328
+ // #3003: a [[link]] on an open page opens the page it names, at the version this one was read from.
12329
+ const kbLink = e.target.closest('button[data-kb-link]');
12330
+ if (kbLink && current) { openKnowledgePage(current.id, kbLink.dataset.kbLink, kbViewHost()?.dataset.kbGeneration || null); return; }
11910
12331
  // #2491 R6.9: categories, selection and Move to… first — their menus share the design set's menu look.
11911
12332
  const rowAct = e.target.closest('[data-kb-row-act]');
11912
12333
  if (rowAct) { kbRowAct(rowAct); return; }
@@ -12451,7 +12872,7 @@
12451
12872
  ];
12452
12873
  };
12453
12874
  /** The units this project's bill is written in: the server's answer, else the client's own copy. */
12454
- const bomUnits = () => exportUnits ?? (current && current.displayUnits === 'mm' ? 'mm' : 'ft-in');
12875
+ const bomUnits = () => exportUnits ?? (current?.displayUnits === 'mm' || current?.displayUnits === 'ft-in' ? current.displayUnits : current?.environment === 'UK' ? 'mm' : 'ft-in');
12455
12876
  const BOM_DESCRIPTIVE = ['profile', 'grade', 'type'];
12456
12877
  const DEFAULT_BOM_FORMATS = ['csv', 'xlsx'];
12457
12878
  const DEFAULT_BOM_COLUMNS = ['profile', 'qty', 'length', 'lbft', 'weight'];
@@ -14555,7 +14976,12 @@
14555
14976
  let selector = option.selector;
14556
14977
  if (option.selector.kind === 'working') {
14557
14978
  const win = frames.model && frames.model.contentWindow;
14558
- if (win && typeof win.flushContract === 'function') await win.flushContract();
14979
+ // Only an editor with unsaved input is flushed (#2981), as approval does. A flush always PUTs the
14980
+ // whole in-memory contract, including the presentation defaults the editor fills in on load, so an
14981
+ // export from an untouched model wrote a new working revision nobody made. An unknown state (no
14982
+ // editor loaded yet) still flushes.
14983
+ const saveState = win && typeof win.contractSaveState === 'function' ? win.contractSaveState() : null;
14984
+ if (win && typeof win.flushContract === 'function' && saveState !== 'clean') await win.flushContract();
14559
14985
  const fresh = await api(`/api/projects/${encodeURIComponent(projectId)}/export-sources`);
14560
14986
  if (!fresh || !fresh.working || typeof fresh.working.etag !== 'string') throw new Error('Working revision identity is unavailable.');
14561
14987
  selector = { kind: 'working', expectedEtag: fresh.working.etag };
@@ -15192,6 +15618,8 @@
15192
15618
  */
15193
15619
  let revisionBuildAsk = null; // #2521 row 7b: the open confirm step after the file picker, if any (askRevisionBuild)
15194
15620
  function resetRevisionState() {
15621
+ readCompletion = null; // #3053: the band belongs to the project being left
15622
+ readCompletionGen++;
15195
15623
  lastRevState = 'none';
15196
15624
  revisionListKnown = false;
15197
15625
  revCardReq = null;
@@ -15963,10 +16391,20 @@
15963
16391
  // rows describing a version that had just been superseded. Clicking Details then resolved
15964
16392
  // no receipt and did nothing at all — a control that answers a click with silence.
15965
16393
  if (!$wsExports.hidden) safeRenderExports('after the revision read');
15966
- showToast('Revision read complete — a new version is on History', 'ok');
16394
+ // #3053: the strip's completion band says it, and keeps saying it after a toast would have gone. An app with no
16395
+ // Drawing Filter (Vectorize) has no strip, so it keeps the toast.
16396
+ if (wsApp()?.filter) refreshReadCompletion(proj, vr).catch((e) => console.error('[workspaces] drawing-read notice failed', e));
16397
+ else showToast('Revision read complete — a new version is on History', 'ok');
15967
16398
  }
15968
16399
  }
16400
+ // #3053: a reviewed read goes staged → none when the person applies it, not pending → none, and publishes its version
16401
+ // from the review dialog. Any read leaving the list asks History again; only a new drawing-read version shows the band.
16402
+ if (lastRevState !== 'none' && lastRevState !== 'pending' && state === 'none' && wsApp()?.filter) {
16403
+ refreshReadCompletion(proj).catch((e) => console.error('[workspaces] drawing-read notice failed', e));
16404
+ }
15969
16405
  lastRevState = state;
16406
+ // #3053: another read for this project starts from a version; a band for that version or an older one is over.
16407
+ if (activeRequest) retireReadCompletion(proj, Number.isSafeInteger(activeRequest.baseVersion) ? activeRequest.baseVersion : 0);
15970
16408
  if (state === 'none') {
15971
16409
  revCardReq = null;
15972
16410
  syncDrawingRevisionRequest('');
@@ -16307,7 +16745,7 @@
16307
16745
  // into test harnesses, where a free name it assigns would not exist. A review opened before this
16308
16746
  // settles (a fresh page, a slow disk) reads in millimetres, never in nothing.
16309
16747
  import('./display-units.js').then((m) => { reviewUnitsModule = m; }, () => {});
16310
- const reviewUnits = () => (current && current.displayUnits === 'mm' ? 'mm' : 'ft-in');
16748
+ const reviewUnits = () => (current?.displayUnits === 'mm' || current?.displayUnits === 'ft-in' ? current.displayUnits : current?.environment === 'UK' ? 'mm' : 'ft-in');
16311
16749
  const reviewElevation = (mm) => (reviewUnitsModule ? reviewUnitsModule.formatElevation(mm, reviewUnits()) : `${Math.round(mm)} mm`);
16312
16750
  const reviewLength = (mm) => (reviewUnitsModule ? reviewUnitsModule.formatLength(mm, reviewUnits()) : `${Math.round(mm)} mm`);
16313
16751
  const isEndpointValue = (v) => !!v && typeof v === 'object' && !Array.isArray(v)
@@ -17631,6 +18069,13 @@
17631
18069
  if (current && current.id === st.projectId) {
17632
18070
  current.approvedAt = undefined; // applying a read clears the sign-off; exports re-lock
17633
18071
  if (!$wsHistory.hidden) renderHistory();
18072
+ // #3053: the version this review just published is the finished read the strip's band announces. The request
18073
+ // poll cannot see it as a completion any more (`lastRevState` is already 'none'), so do here what its completion
18074
+ // edge does: an applied FIRST read is what makes the model exist, so the tab gates and the approval header are
18075
+ // asked again (otherwise Model stays locked, and the band with it, until a reload), and History for the band.
18076
+ refreshModelPresence(current.id, current.app, true).catch((e) => console.error('[workspaces] post-apply model presence did not refresh', e));
18077
+ refreshApprovalState(current.id).catch((e) => console.error('[workspaces] approval header did not refresh after the apply', e));
18078
+ if (wsApp()?.filter) refreshReadCompletion(current).catch((e) => console.error('[workspaces] drawing-read notice failed', e));
17634
18079
  }
17635
18080
  $revReviewTitle.textContent = 'Revision applied';
17636
18081
  $revReviewSub.textContent = `Version v${res.version?.n ?? res.versionN ?? '—'} is now on History.`;
@@ -18140,14 +18585,27 @@
18140
18585
  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>`;
18141
18586
  }
18142
18587
 
18588
+ // #2470 R6.5b: each ledger render is numbered, so one overtaken by a newer render (the person went to Activity and back
18589
+ // while it was reading) neither paints nor speaks.
18590
+ let historyRenderGen = 0;
18591
+ /**
18592
+ * The ledger was on screen and is being hidden (setStep): a render still reading neither paints nor speaks, and a
18593
+ * revision-note editor it opened will not reopen or repaint it. A note the person already pressed Save on is still
18594
+ * saved to its own project and version; only the hidden ledger is left alone.
18595
+ */
18596
+ function leaveHistoryLedger() {
18597
+ historyRenderGen++;
18598
+ revisionNoteEditorGeneration++;
18599
+ }
18143
18600
  async function renderHistory() {
18144
18601
  if (!current) return;
18145
18602
  const id = current.id;
18603
+ const renderGen = ++historyRenderGen;
18146
18604
  const previousHistory = $wsHistory.dataset.historyProjectId === id ? $wsHistory.innerHTML : '';
18147
18605
  closeBaseMenu(); // this re-render replaces the History HTML — drop any open base-picker's listener first
18148
18606
  $wsHistory.innerHTML = HIST_HEAD + '<div class="hist-note">Loading history…</div>';
18149
18607
  await awaitApprovalVerdict();
18150
- if (!current || current.id !== id || $wsHistory.hidden) return; // switched away while it settled
18608
+ if (!current || current.id !== id || $wsHistory.hidden || renderGen !== historyRenderGen) return; // switched away while it settled
18151
18609
  let rows = [];
18152
18610
  let approvedAt;
18153
18611
  let nextDiffSupported = false;
@@ -18177,7 +18635,7 @@
18177
18635
  try {
18178
18636
  const r = await api(`/api/projects/${encodeURIComponent(id)}/versions`);
18179
18637
  strictHistoryUnavailable = r.historyAvailable === false;
18180
- if (r.revisionNotesUnavailable) showToast('Revision notes are unavailable. Approved history is unchanged.', 'warn');
18638
+ if (r.revisionNotesUnavailable && renderGen === historyRenderGen) showToast('Revision notes are unavailable. Approved history is unchanged.', 'warn');
18181
18639
  rows = Array.isArray(r.versions) ? r.versions : [];
18182
18640
  // Absent on an older server → fall back to the descriptor, which is the pre-change behaviour.
18183
18641
  nextDiffSupported = typeof r.diffSupported === 'boolean' ? r.diffSupported : !!(wsApp() && wsApp().diff);
@@ -18197,6 +18655,7 @@
18197
18655
  // `defaultUnavailable`, and reaches here through this throw. A bare network failure has no
18198
18656
  // body, so it still gets the retry line it deserves.
18199
18657
  const served = err && err.body && typeof err.body.error === 'string' ? err.body.error.trim() : '';
18658
+ if (renderGen !== historyRenderGen) return;
18200
18659
  showToast('We couldn’t load this history because FloLess could not reach it. Try again.', 'warn');
18201
18660
  if (current && current.id === id && !$wsHistory.hidden) {
18202
18661
  // The header comes too. A step that keeps its band while loading and while listing but drops
@@ -18210,7 +18669,7 @@
18210
18669
  const { saved } = await checkpointPromise;
18211
18670
  if (saved === null) checkpointsUnavailable = true;
18212
18671
  else checkpoints = Array.isArray(saved.checkpoints) ? saved.checkpoints : [];
18213
- if (!current || current.id !== id || $wsHistory.hidden) return; // switched away mid-await
18672
+ if (!current || current.id !== id || $wsHistory.hidden || renderGen !== historyRenderGen) return; // switched away mid-await
18214
18673
  if (strictHistoryUnavailable) {
18215
18674
  if (previousHistory) $wsHistory.innerHTML = previousHistory;
18216
18675
  else $wsHistory.innerHTML = HIST_HEAD + '<div class="hist-empty">Model readiness unavailable — History could not be verified within its safety limits.</div>';
@@ -18240,7 +18699,7 @@
18240
18699
  // same "don't route it through a string template at all" rule `importFailedCmdRow` follows.
18241
18700
  const gen = ++modelPresenceGen;
18242
18701
  const hasModel = await projectContractState(id, current.app);
18243
- if (gen !== modelPresenceGen || !current || current.id !== id || $wsHistory.hidden) return;
18702
+ if (gen !== modelPresenceGen || !current || current.id !== id || $wsHistory.hidden || renderGen !== historyRenderGen) return;
18244
18703
  applyModelPresence(hasModel); // one answer, every surface — History used to keep its own
18245
18704
  const empty = document.createElement('div');
18246
18705
  empty.className = 'hist-empty';
@@ -18440,6 +18899,9 @@
18440
18899
  { key: 'removed', label: 'Removed' },
18441
18900
  { key: 'resized', label: 'Resized' },
18442
18901
  { key: 'moved', label: 'Moved' },
18902
+ // #2997: ends moved by less than History's move threshold (server/steel-diff.ts MOVE_THRESHOLD_TEXT, the same two
18903
+ // strings). Named by the rule, not "small", so a 2" base drop never reads as ignorable. Optional on the wire.
18904
+ { key: 'nudged', label: 'Moved under 6 in', labelMm: 'Moved under 152.4 mm', optional: true },
18443
18905
  { key: 'material', label: 'Material' },
18444
18906
  { key: 'changed', label: 'Source questions' },
18445
18907
  { key: 'connections', label: 'Connections' },
@@ -18501,6 +18963,13 @@
18501
18963
  if (it.ref.sheet) line.appendChild(el('span', 'hd-sheet', it.ref.sheet));
18502
18964
  return line;
18503
18965
  }
18966
+ function diffMemberNudged(it) {
18967
+ const line = el('div', 'hd-item');
18968
+ line.appendChild(el('span', 'hd-mark', it.ref.mark || it.ref.id));
18969
+ line.appendChild(el('span', 'hd-prof', `moved up to ${it.text}`));
18970
+ if (it.ref.sheet) line.appendChild(el('span', 'hd-sheet', it.ref.sheet));
18971
+ return line;
18972
+ }
18504
18973
  function diffMemberConn(it) {
18505
18974
  const line = el('div', 'hd-item');
18506
18975
  line.appendChild(el('span', 'hd-mark', it.ref.mark || it.ref.id));
@@ -18520,14 +18989,15 @@
18520
18989
  if (key === 'added' || key === 'removed') return diffMemberBasic(it);
18521
18990
  if (key === 'resized' || key === 'material') return diffMemberXform(it.ref, it.from, it.to);
18522
18991
  if (key === 'moved') return diffMemberMoved(it);
18992
+ if (key === 'nudged') return diffMemberNudged(it);
18523
18993
  if (key === 'changed') return diffProvisionalChanged(it);
18524
18994
  return diffMemberConn(it);
18525
18995
  }
18526
- function diffGroup(g, items) {
18996
+ function diffGroup(g, items, units) {
18527
18997
  if (!items || !items.length) return null;
18528
18998
  const box = el('div', `hd-group ${g.key}`);
18529
18999
  const head = el('div', 'hd-type');
18530
- head.appendChild(el('span', null, g.label.toUpperCase()));
19000
+ head.appendChild(el('span', null, (units === 'mm' && g.labelMm ? g.labelMm : g.label).toUpperCase()));
18531
19001
  head.appendChild(document.createTextNode(' '));
18532
19002
  head.appendChild(el('span', 'hd-count', `(${items.length})`));
18533
19003
  box.appendChild(head);
@@ -18538,17 +19008,25 @@
18538
19008
  // the server spells them the same way (`server/bom-units.ts`), so the pane and the sentence beneath
18539
19009
  // it cannot disagree about what a number is.
18540
19010
  const DIFF_TONNAGE_WORD = { 'ft-in': 'tons', mm: 't' };
19011
+ const DIFF_WEIGHT_WORD = { 'ft-in': 'lb', mm: 'kg' };
19012
+ const diffWeightFormat = new Intl.NumberFormat('en-US', { maximumFractionDigits: 0 });
18541
19013
  function diffNetHeader(t) {
18542
19014
  const wrap = el('div', 'hd-net');
18543
- const net = t && typeof t.netTonnage === 'number' ? t.netTonnage : 0;
19015
+ const tonnage = t && typeof t.netTonnage === 'number' ? t.netTonnage : 0;
19016
+ const weight = t && typeof t.netWeight === 'number' && Number.isFinite(t.netWeight) ? t.netWeight : 0;
18544
19017
  // The units come off the comparison, never from a page-level preference: a panel showing an older
18545
19018
  // comparison must keep saying what THAT comparison measured. `wellFormedDiff` has already refused
18546
19019
  // anything whose `units` is not one of the two, so the fallback is unreachable rather than a guess.
18547
- const word = DIFF_TONNAGE_WORD[t && t.units] || DIFF_TONNAGE_WORD['ft-in'];
19020
+ const units = t && DIFF_TONNAGE_WORD[t.units] ? t.units : 'ft-in';
19021
+ // #2997: under a tenth of a ton the figure reads 0 and contradicts the row's own "increased by 3 lb", so
19022
+ // it drops to the weight — the same rule the History sentence uses (server/version-diff.ts).
19023
+ const byWeight = Math.abs(tonnage) < 0.1 && Math.round(Math.abs(weight)) >= 1; // a rounding residue is not a change
19024
+ const net = byWeight ? weight : tonnage;
19025
+ const shown = byWeight ? `${diffWeightFormat.format(Math.abs(weight))} ${DIFF_WEIGHT_WORD[units]}` : `${Math.abs(tonnage)} ${DIFF_TONNAGE_WORD[units]}`;
18548
19026
  if (net === 0) wrap.classList.add('flat');
18549
19027
  wrap.appendChild(el('span', 'hd-net-label', 'Net steel:'));
18550
19028
  wrap.appendChild(el('span', 'hd-net-arrow', net > 0 ? '▲' : net < 0 ? '▼' : '•'));
18551
- wrap.appendChild(el('span', 'hd-net-val', `${net > 0 ? '+' : ''}${net} ${word}`));
19029
+ wrap.appendChild(el('span', 'hd-net-val', `${net > 0 ? '+' : net < 0 ? '-' : ''}${shown}`));
18552
19030
  // #2735: the bill prices members on ASSUMED heights, so these totals can rest on them. Say so on its own
18553
19031
  // line under the figure (a label, not a reliability warning, so not an .hd-warn banner).
18554
19032
  const assumed = diffAssumedNoteText(t);
@@ -18619,10 +19097,20 @@
18619
19097
  panel.appendChild(diffNetHeader(diff.tonnage));
18620
19098
  let any = false;
18621
19099
  for (const g of DIFF_GROUPS) {
18622
- const grp = diffGroup(g, diff[g.key]);
19100
+ const grp = diffGroup(g, diff[g.key], diff.tonnage && diff.tonnage.units);
18623
19101
  if (grp) { panel.appendChild(grp); any = true; }
18624
19102
  }
18625
- if (!any) {
19103
+ if (!any && diff.tonnage && Math.round(Math.abs(Number(diff.tonnage.netWeight) || 0)) >= 1) {
19104
+ // #2997: never "No changes detected" beside a weight that changed — the two would contradict each other.
19105
+ const t = diff.tonnage;
19106
+ const units = DIFF_WEIGHT_WORD[t.units] ? t.units : 'ft-in';
19107
+ const by = `${t.netWeight > 0 ? '+' : '-'}${diffWeightFormat.format(Math.abs(t.netWeight))} ${DIFF_WEIGHT_WORD[units]}`;
19108
+ // A member that could not be compared may be the cause, so a partial comparison names no culprit.
19109
+ const uncompared = Array.isArray(diff.incomparable) ? diff.incomparable.length : 0;
19110
+ panel.appendChild(el('div', 'hd-empty', uncompared
19111
+ ? `The steel weight changed by ${by}. ${uncompared} ${uncompared === 1 ? 'member' : 'members'} could not be compared, so FloLess can’t say which change caused it.`
19112
+ : `The steel weight changed by ${by}, but FloLess found no member change that accounts for it.${diff.unchanged ? ` ${diff.unchanged} members compared.` : ''}`));
19113
+ } else if (!any) {
18626
19114
  panel.appendChild(el('div', 'hd-empty', `No changes detected${diff.unchanged ? ` — ${diff.unchanged} members unchanged` : ''}.`));
18627
19115
  } else if (diff.unchanged) {
18628
19116
  panel.appendChild(el('div', 'hd-tail', `${diff.unchanged} members unchanged`));
@@ -18656,9 +19144,12 @@
18656
19144
  && (!Object.prototype.hasOwnProperty.call(value, 'scaleUnknown') || typeof value.scaleUnknown === 'boolean');
18657
19145
  const connection = (value) => !!value && typeof value === 'object' && !Array.isArray(value)
18658
19146
  && ref(value.ref) && typeof value.summary === 'string';
18659
- const validators = { added: ref, removed: ref, resized: xform, moved, material: xform, changed: connection, connections: connection };
19147
+ const nudged = (value) => !!value && typeof value === 'object' && !Array.isArray(value)
19148
+ && ref(value.ref) && Number.isFinite(value.mm) && typeof value.text === 'string' && !!value.text;
19149
+ const validators = { added: ref, removed: ref, resized: xform, moved, nudged, material: xform, changed: connection, connections: connection };
18660
19150
  if (!DIFF_GROUPS.every((group) =>
18661
- Array.isArray(diff[group.key]) && diff[group.key].every(validators[group.key]))) return false;
19151
+ (group.optional && !Object.prototype.hasOwnProperty.call(diff, group.key))
19152
+ || (Array.isArray(diff[group.key]) && diff[group.key].every(validators[group.key])))) return false;
18662
19153
  return ['duplicateKeys', 'ambiguousJoints', 'mergedAmbiguous'].every((key) =>
18663
19154
  !Object.prototype.hasOwnProperty.call(diff.warnings, key)
18664
19155
  || (Array.isArray(diff.warnings[key]) && diff.warnings[key].every((value) => typeof value === 'string')));
@@ -19705,6 +20196,60 @@
19705
20196
  return { kind: 'create', done: activateSeedCard(seed, linkFrom) };
19706
20197
  }
19707
20198
 
20199
+ /**
20200
+ * #2811: New project for a Steel model from drawings, from a card the person clicked in a chat or a terminal request.
20201
+ * Called straight from that click, with nothing awaited first, so the file picker it opens is still the person's own
20202
+ * gesture. `quick` presses Quick model in the dialog. The Drawing Filter question is left as the dialog always asks
20203
+ * it (the person's own Save): whether the AI may choose the Filter is only ever the person's click there.
20204
+ */
20205
+ async function openNewProjectFromDrawings({ quick = false } = {}) {
20206
+ pendingQuickPress = 0; // a newer card replaces an older one's ask
20207
+ const seed = usableSteelDrawingSeed();
20208
+ if (seed) {
20209
+ // The picker opens inside the click; Workspaces is entered while it is open, so the project Create makes is the one
20210
+ // on screen (a card already drawn may be behind Workflows or Agents, and opening a project keeps the current view).
20211
+ const opened = activateSeedCard(seed, null, { buildMode: quick ? 'quick' : 'precise' });
20212
+ await setMode('workspaces');
20213
+ await opened;
20214
+ return { ok: true };
20215
+ }
20216
+ // Workspaces not drawn yet (another view was open), or Steel Model not set up: Workspaces, at its card. Waiting for
20217
+ // the cards uses up the click, so the picker cannot open from it; the person's own press on the card does that, and
20218
+ // a Quick asked for here is pressed for them then (within a few minutes, once).
20219
+ await setMode('workspaces');
20220
+ if (current) await leaveProjectToList();
20221
+ if (current) return { ok: false, said: 'You stayed in this project, so New project was not opened. Ask again when you are ready.' };
20222
+ for (let i = 0; i < 60 && !$landing.querySelector('[data-seed-app]'); i++) await new Promise((r) => setTimeout(r, 500));
20223
+ const ready = usableSteelDrawingSeed();
20224
+ const card = ready || $landing.querySelector('[data-seed-template="steel-model"]');
20225
+ card?.scrollIntoView?.({ block: 'nearest' });
20226
+ card?.focus?.();
20227
+ if (ready) {
20228
+ pendingQuickPress = quick ? Date.now() + PENDING_QUICK_PRESS_MS : 0;
20229
+ return { ok: false, said: `Workspaces is open at Steel model from drawings. Press it to choose your drawings${quick ? ', and New project opens with Quick model pressed.' : '.'}` };
20230
+ }
20231
+ return { ok: false, said: card
20232
+ ? 'Steel Model isn’t ready to start a project yet. Workspaces is open at its card, which says what it needs.'
20233
+ : 'Steel Model isn’t installed here, so there is no Steel model to start. Workspaces is open.' };
20234
+ }
20235
+ function usableSteelDrawingSeed() {
20236
+ const seed = $landing.querySelector('[data-seed-template="steel-model"][data-seed-action="drawing"]');
20237
+ return seed && !seed.classList.contains('ws-seed-remedy') && !createCardRemedy(seed) ? seed : null;
20238
+ }
20239
+ /**
20240
+ * #2811: a Quick press a chat card asked for, kept for the person's own press on the Steel model card. Every card press
20241
+ * takes it, used or not, so it applies to that one press at most; an explicit choice from a card wins.
20242
+ */
20243
+ const PENDING_QUICK_PRESS_MS = 5 * 60_000;
20244
+ let pendingQuickPress = 0;
20245
+ function takePendingQuickPress(templateId, seedAction, explicit, linkFrom) {
20246
+ // Only the landing's own Steel model card: a module added from a General project never inherits a chat card's ask.
20247
+ const quick = templateId === 'steel-model' && seedAction === 'drawing' && !linkFrom && pendingQuickPress > Date.now();
20248
+ pendingQuickPress = 0;
20249
+ if (explicit) return explicit;
20250
+ return quick ? 'quick' : 'precise';
20251
+ }
20252
+
19708
20253
  /** Open a project by id, from another project's Modules step: the same open a card on the landing does. */
19709
20254
  async function openLinkedProject(projectId) {
19710
20255
  await setMode('workspaces');
@@ -19794,11 +20339,13 @@
19794
20339
  const member = !!target && !validId(target.jointId) && validId(target.memberId);
19795
20340
  // #2874: or one RFI a chat message mentioned, shown on the project's RFIs step (in the editor, or the shell's own pane).
19796
20341
  const rfi = !!target && !validId(target.jointId) && !member && validId(target.rfiId) && /^RFI-\d{3,16}$/.test(target.rfiId);
20342
+ // #2521 row 9: or Make precise itself, opened in the editor for the chat's "Open Make precise".
20343
+ const precise = !!target && !validId(target.jointId) && !member && !rfi && target.makePrecise === true;
19797
20344
  // Sentences say "the member was not shown", but "RFI-007 was not shown".
19798
- const thing = member ? 'the member' : rfi ? target.rfiId : 'the connection';
19799
- const again = member ? 'Show in the model' : rfi ? `${target.rfiId} in the chat` : 'Open in the model';
20345
+ const thing = member ? 'the member' : rfi ? target.rfiId : precise ? 'Make precise' : 'the connection';
20346
+ const again = member ? 'Show in the model' : rfi ? `${target.rfiId} in the chat` : precise ? 'Open Make precise' : 'Open in the model';
19800
20347
  const step = rfi ? 'rfis' : 'model';
19801
- 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.`);
20348
+ 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.`);
19802
20349
  const mine = { id: `connection-${++connectionRequestSeq}`, page: null };
19803
20350
  withdrawConnectionRequest(connectionRequest);
19804
20351
  connectionRequest = mine;
@@ -19905,7 +20452,7 @@
19905
20452
  if (citedElsewhere()) throw citedGone();
19906
20453
  // The frame's window survives a reload; its DOCUMENT does not. That is what tells a reload apart.
19907
20454
  page = child; doc = child.document;
19908
- answer = child.flolessEditorFocus(member ? { memberId: target.memberId, requestId: mine.id } : rfi ? { rfiId: target.rfiId, requestId: mine.id } : { jointId: target.jointId, requestId: mine.id,
20455
+ 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,
19909
20456
  // #2450: the readiness card's "Raise an RFI" also opens the editor's review dialog for it.
19910
20457
  ...(target.raiseRfi === true ? { raiseRfi: true } : {}), ...(validId(target.checkId) ? { checkId: target.checkId } : {}) });
19911
20458
  if (!answer || typeof answer.then !== 'function') return { ok: false, said: notTaken };
@@ -20255,7 +20802,7 @@
20255
20802
  setMode, refresh: loadProjects, findActive: wsFindActive, find: wsFind, clearFind: wsClearFind,
20256
20803
  openHistory: wsOpenHistory, openKnowledgePage, openKnowledgeStep, openDrawingsStep, openWorkflowsStep, openConnection, openDrawingAt, drawingFilterCheckpointSaved,
20257
20804
  // #2470 R6.7: the Modules step of a General project (project-modules.js).
20258
- moduleCreateCardsHtml, activateCreateCard, openLinkedProject, openModulesStep, showArchivedProjects,
20805
+ moduleCreateCardsHtml, activateCreateCard, openNewProjectFromDrawings, openLinkedProject, openModulesStep, showArchivedProjects,
20259
20806
  syncWorkspaceReporter, openChatOwner, openPagesHome, folderDecisionCompleted,
20260
20807
  // Project access (project-access.js loads after this file): the project open now, or null.
20261
20808
  currentProject: () => ($app.classList.contains('mode-workspaces') && current ? current : null),