@floless/app 0.140.0 → 0.141.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -319,6 +319,12 @@
319
319
  model: document.getElementById('ws-frame-model'),
320
320
  drawings: document.getElementById('ws-frame-drawings'),
321
321
  };
322
+ // A project's editors autosave, but a Stop FloLess / Sign Out mid-save would still lose the last
323
+ // change — let the leave guard see (and flush) them. See web/leave-guard.js.
324
+ if (window.flolessLeaveGuard) {
325
+ window.flolessLeaveGuard.registerFrame(frames.model, 'workspace-model');
326
+ window.flolessLeaveGuard.registerFrame(frames.drawings, 'workspace-drawings');
327
+ }
322
328
  let lastModelDisposeReceipt = null;
323
329
  function disposeModelEditorFrame(reason) {
324
330
  // The left Model section drops the departing editor's tree now, not at the next load event, so a
@@ -1148,8 +1154,19 @@
1148
1154
  let modeChangeSequence = 0;
1149
1155
  function showWorkflowOpening(opening) {
1150
1156
  if (!$workflowTab) return;
1151
- $workflowTab.toggleAttribute('aria-busy', opening);
1152
- $workflowTab.toggleAttribute('aria-disabled', opening);
1157
+ // Explicit ARIA "true", never toggleAttribute: that writes a valueless `aria-busy=""`, which is not
1158
+ // a valid ARIA state and matches neither setMode()'s `=== 'true'` re-click guard nor the app.css
1159
+ // `[aria-busy="true"]` rule — so every re-click started another read (#1489).
1160
+ // Instructor reads aria-disabled="true" as blocked; data-blocked-reason is what `?` then says.
1161
+ if (opening) {
1162
+ $workflowTab.setAttribute('aria-busy', 'true');
1163
+ $workflowTab.setAttribute('aria-disabled', 'true');
1164
+ $workflowTab.setAttribute('data-blocked-reason', 'Workflows is already opening. Wait a moment, or choose Workspaces to stay where you are.');
1165
+ } else {
1166
+ $workflowTab.removeAttribute('aria-busy');
1167
+ $workflowTab.removeAttribute('aria-disabled');
1168
+ $workflowTab.removeAttribute('data-blocked-reason');
1169
+ }
1153
1170
  if (opening) {
1154
1171
  $workflowTab.setAttribute('aria-label', 'Opening Workflows');
1155
1172
  $workflowTab.innerHTML = '<span class="rtn-spinner" aria-hidden="true"></span><span>Opening Workflows…</span>';
@@ -2412,7 +2429,7 @@
2412
2429
  const $projectSetupName = document.getElementById('project-setup-name');
2413
2430
  const $projectSetupStandard = document.getElementById('project-setup-standard');
2414
2431
  const $projectSetupError = document.getElementById('project-setup-error');
2415
- const $projectSetupChatMeta = document.getElementById('project-setup-chat-meta');
2432
+ const $projectSetupProvider = document.getElementById('project-setup-provider');
2416
2433
  const $projectSetupCancel = document.getElementById('project-setup-cancel');
2417
2434
  const $projectSetupCreateOnly = document.getElementById('project-setup-create-only');
2418
2435
  const $projectSetupCreate = document.getElementById('project-setup-create');
@@ -2482,24 +2499,153 @@
2482
2499
  projectSetupState.busy = !!busy;
2483
2500
  $projectSetup.setAttribute('aria-busy', String(!!busy));
2484
2501
  for (const control of $projectSetup.querySelectorAll('button, input')) control.disabled = !!busy;
2502
+ // Waiting for FloLess to set an AI up creates nothing yet, so Cancel stays usable (#1607).
2503
+ if (busy && projectSetupState.settingUp) $projectSetupCancel.disabled = false;
2485
2504
  $projectSetupCreate.textContent = label || 'Create project & start chat';
2486
- $projectSetupCreateOnly.textContent = busy ? 'Creating…' : (projectSetupState.kind === 'rvt' ? 'Create project' : 'Create project only');
2505
+ $projectSetupCreateOnly.textContent = busy && !projectSetupState.settingUp ? 'Creating…' : (projectSetupState.kind === 'rvt' ? 'Create project' : 'Create project only');
2487
2506
  if (!busy) {
2488
2507
  $projectSetupCreate.disabled = !projectSetupReady();
2489
2508
  $projectSetupCreateOnly.disabled = !projectSetupReady();
2490
2509
  }
2491
2510
  }
2492
2511
 
2512
+ const PROJECT_CHAT_PROVIDER_NAMES = { claude: 'Claude', codex: 'Codex' };
2513
+
2514
+ // Whether this dialog may start the conversation with this AI (#1607): the one answer the default
2515
+ // (preferredChatProvider), the Requests Start affordances and the AI Chat empty state share —
2516
+ // 'ready', 'setup' (FloLess sets up its own copy when the conversation opens) or 'unavailable'.
2517
+ function projectSetupProviderReadiness(runtime) {
2518
+ return runtime ? (bridge.chatRuntimeReadiness?.(runtime) || 'unavailable') : 'unavailable';
2519
+ }
2520
+
2521
+ // Which AI "Create project & start chat" starts the conversation with (#1605): the person's own
2522
+ // pick while it can still start, otherwise the AI FloLess would pick anyway — so the one-click
2523
+ // path still works for anyone who does not care. A Revit project starts no chat, so it has none.
2524
+ // Every answer is checked against what can start now: preferredChatProvider() prefers the open
2525
+ // conversation's AI, which may since have been uninstalled, and a choice that cannot start must
2526
+ // never be the one shown as chosen and sent.
2527
+ function projectSetupProvider(state) {
2528
+ if (!state || state.kind === 'rvt') return null;
2529
+ const runtimes = bridge.chatProviderRuntimes?.() || [];
2530
+ const readiness = (id) => (id ? projectSetupProviderReadiness(runtimes.find((runtime) => runtime.id === id)) : 'unavailable');
2531
+ const canStart = (id) => readiness(id) !== 'unavailable';
2532
+ if (canStart(state.chatProvider)) return state.chatProvider;
2533
+ const preferred = bridge.preferredChatProvider?.() || null;
2534
+ if (canStart(preferred)) return preferred;
2535
+ // An AI that is ready now before one FloLess still has to set up (#1607).
2536
+ const ids = Object.keys(PROJECT_CHAT_PROVIDER_NAMES);
2537
+ return ids.find((id) => readiness(id) === 'ready') || ids.find(canStart) || null;
2538
+ }
2539
+
2540
+ // The per-AI line under the choice (#1607). A copy FloLess sets up itself is offered, and its line
2541
+ // says it is not set up yet, so the wait after Create is no surprise.
2542
+ function projectSetupProviderLine(id, runtime, readiness, state, accountLabel) {
2543
+ const name = PROJECT_CHAT_PROVIDER_NAMES[id] || id;
2544
+ const managed = runtime && runtime.managed && typeof runtime.managed === 'object' ? runtime.managed : null;
2545
+ if (readiness === 'ready') {
2546
+ return typeof accountLabel !== 'function' ? name
2547
+ : accountLabel(id, state.providersRead ? runtime.account : { state: 'checking' });
2548
+ }
2549
+ if (readiness === 'setup') {
2550
+ if (managed?.state === 'preparing') return `${name} · setting up…`;
2551
+ // Nothing retries on its own here: pressing Create is what tries the setup again.
2552
+ if (managed?.state === 'failed') return `${name} · setup failed, Create tries again`;
2553
+ return `${name} · not set up yet`;
2554
+ }
2555
+ return managed ? `${name} · couldn’t be set up` : `${name} · not found`;
2556
+ }
2557
+
2558
+ // Why an AI that cannot start cannot be chosen here, and where to go instead.
2559
+ function projectSetupBlockedReason(id, runtime) {
2560
+ const name = PROJECT_CHAT_PROVIDER_NAMES[id] || id;
2561
+ const other = PROJECT_CHAT_PROVIDER_NAMES[id === 'claude' ? 'codex' : 'claude'];
2562
+ // FloLess runs its own copy here, and that copy failed in a way it cannot retry by itself.
2563
+ if (runtime && runtime.managed && typeof runtime.managed === 'object') {
2564
+ return `FloLess could not set up ${name} on this computer. Choose ${other} here, or open AI Chat with ${name} to see why.`;
2565
+ }
2566
+ // "Did not find", not "not installed": the sentence says only what is known.
2567
+ return `FloLess did not find ${name} on this computer. Choose ${other} here, or open AI Chat to set ${name} up.`;
2568
+ }
2569
+
2570
+ // The Claude / Codex choice, in the same shape as the AI Chat empty state: two buttons, and each
2571
+ // one's own sign-in underneath. With no AI able to start, the whole choice is hidden together with
2572
+ // Create project & start chat, rather than offering buttons that cannot be pressed. An AI that
2573
+ // cannot start next to one that can stays visible and focusable, and says why it cannot be chosen.
2574
+ function paintProjectSetupProviders(state, provider) {
2575
+ if (!$projectSetupProvider) return;
2576
+ $projectSetupProvider.hidden = !provider;
2577
+ if (!provider) return;
2578
+ const runtimes = bridge.chatProviderRuntimes?.() || [];
2579
+ const accountLabel = window.flolessChat?.providerAccountLabel;
2580
+ for (const button of $projectSetupProvider.querySelectorAll('[data-chat-provider]')) {
2581
+ const id = button.dataset.chatProvider;
2582
+ const name = PROJECT_CHAT_PROVIDER_NAMES[id] || id;
2583
+ const runtime = runtimes.find((row) => row.id === id);
2584
+ const readiness = projectSetupProviderReadiness(runtime);
2585
+ button.setAttribute('aria-pressed', String(id === provider));
2586
+ if (readiness !== 'unavailable') {
2587
+ button.removeAttribute('aria-disabled');
2588
+ delete button.dataset.tip;
2589
+ delete button.dataset.blockedReason;
2590
+ } else {
2591
+ const why = projectSetupBlockedReason(id, runtime);
2592
+ button.setAttribute('aria-disabled', 'true');
2593
+ button.dataset.tip = why;
2594
+ button.dataset.blockedReason = why;
2595
+ }
2596
+ const status = $projectSetupProvider.querySelector(`[data-chat-provider-status="${id}"]`);
2597
+ if (!status) continue;
2598
+ // While FloLess sets this AI up for the dialog, its line carries the AI Chat panel's own
2599
+ // sentence for that setup (a polite region, so it is read once per change).
2600
+ const text = state.settingUp && state.settingUp.provider === id && state.settingUp.text
2601
+ ? state.settingUp.text
2602
+ : projectSetupProviderLine(id, runtime, readiness, state, accountLabel);
2603
+ // The row is a polite live region: an unchanged line must not be read out again.
2604
+ if (status.textContent !== text) status.textContent = text;
2605
+ }
2606
+ }
2607
+
2608
+ // Pressing Claude or Codex. An AI that cannot start is aria-disabled (focusable, so its reason can
2609
+ // be read) and pressing it changes nothing; nor does a press while the project is being created.
2610
+ function chooseProjectSetupProvider(button) {
2611
+ if (!button || !projectSetupState || projectSetupState.busy) return;
2612
+ if (button.getAttribute('aria-disabled') === 'true') return;
2613
+ projectSetupState.chatProvider = button.dataset.chatProvider;
2614
+ renderProjectSetup();
2615
+ }
2616
+
2617
+ // Reads which AIs can start and who each is signed in as, when the dialog opens. A read that
2618
+ // failed, or a sign-in the server could not settle (a slow or failed CLI status read), is
2619
+ // transient, so it is asked again a few times while the dialog stays open instead of leaving
2620
+ // "could not check" — or no choice at all — as the only basis for the choice.
2621
+ async function refreshProjectSetupProviders(state, attempt = 0) {
2622
+ const read = await bridge.refreshChatProviders?.();
2623
+ if (projectSetupState !== state) return;
2624
+ state.providersRead = true;
2625
+ renderProjectSetup();
2626
+ // Only a READY AI's sign-in can settle: a copy FloLess has not set up yet answers "unknown" by
2627
+ // construction, and asking again would never change that (#1607).
2628
+ const unsettled = read === false || (bridge.chatProviderRuntimes?.() || []).some((runtime) => projectSetupProviderReadiness(runtime) === 'ready'
2629
+ && !['signed-in', 'signed-out', 'no-identity'].includes(runtime.account?.state));
2630
+ if (unsettled && attempt < 3) {
2631
+ setTimeout(() => {
2632
+ if (projectSetupState === state) void refreshProjectSetupProviders(state, attempt + 1);
2633
+ }, 4000);
2634
+ }
2635
+ }
2636
+
2637
+ // Repaint only the AI lines while the dialog waits for a setup; a full render would re-enable the
2638
+ // create buttons under the wait.
2639
+ function renderProjectSetupWhileBusy(state) {
2640
+ if (projectSetupState !== state) return;
2641
+ paintProjectSetupProviders(state, projectSetupProvider(state));
2642
+ }
2643
+
2493
2644
  function renderProjectSetup() {
2494
2645
  const state = projectSetupState;
2495
2646
  if (!state) return;
2496
- const provider = state.kind === 'rvt' ? null : (bridge.preferredChatProvider?.() || null);
2497
- if ($projectSetupChatMeta) {
2498
- $projectSetupChatMeta.hidden = !provider;
2499
- $projectSetupChatMeta.textContent = provider
2500
- ? `Starts with ${provider === 'claude' ? 'Claude Code' : provider === 'codex' ? 'Codex' : provider} · can edit this project folder`
2501
- : '';
2502
- }
2647
+ const provider = projectSetupProvider(state);
2648
+ paintProjectSetupProviders(state, provider);
2503
2649
  $projectSetupCreate.hidden = !provider;
2504
2650
  $projectSetupCreateOnly.classList.toggle('primary', !provider);
2505
2651
  $projectSetupTitle.textContent = `New ${descDisplayName(state.templateId)} project`;
@@ -2529,7 +2675,11 @@
2529
2675
 
2530
2676
  function closeProjectSetup({ restoreFocus = true } = {}) {
2531
2677
  const state = projectSetupState;
2532
- if (!state || state.busy) return;
2678
+ // Busy refuses a close, except while FloLess is only setting an AI up: nothing exists yet, and
2679
+ // clearing projectSetupState is what tells that wait to stop (the install itself carries on).
2680
+ if (!state || (state.busy && !state.settingUp)) return;
2681
+ // Leave no control disabled behind for the next time the dialog opens.
2682
+ if (state.busy) { state.settingUp = null; setProjectSetupBusy(false); }
2533
2683
  projectSetupState = null;
2534
2684
  $projectSetup.classList.remove('show');
2535
2685
  $projectSetup.removeAttribute('aria-busy');
@@ -2574,11 +2724,41 @@
2574
2724
  async function createProjectFromSetup(startChat = true) {
2575
2725
  const state = projectSetupState;
2576
2726
  if (!projectSetupReady(state) || state.busy) return;
2577
- if (startChat && !bridge.preferredChatProvider?.()) {
2727
+ const provider = startChat ? projectSetupProvider(state) : null;
2728
+ if (startChat && !provider) {
2578
2729
  setProjectSetupError('Sign in to Claude or Codex before starting this project in AI Chat. You can still create the project only.');
2579
2730
  return;
2580
2731
  }
2581
2732
  setProjectSetupError('');
2733
+ if (startChat && projectSetupProviderReadiness((bridge.chatProviderRuntimes?.() || []).find((row) => row.id === provider)) === 'setup') {
2734
+ // FloLess has to set its own copy of this AI up before the conversation's first message can be
2735
+ // sent (#1607). Wait for that here, before anything is created, so a failed or cancelled setup
2736
+ // leaves no project and no dead conversation behind.
2737
+ const name = PROJECT_CHAT_PROVIDER_NAMES[provider] || provider;
2738
+ state.settingUp = { provider, text: '' };
2739
+ setProjectSetupBusy(true, `Setting up ${name}…`);
2740
+ renderProjectSetupWhileBusy(state);
2741
+ // The pressed button is now disabled; keep keyboard focus on the one control that still acts.
2742
+ $projectSetupCancel.focus();
2743
+ const ready = await bridge.ensureChatRuntimeReady(provider, {
2744
+ isCancelled: () => projectSetupState !== state,
2745
+ onProgress: (status) => {
2746
+ if (projectSetupState !== state || !state.settingUp) return;
2747
+ const notice = window.flolessChat?.runtimeNotice?.(provider, status);
2748
+ state.settingUp.text = notice?.body || `FloLess is setting ${name} up. This happens once per FloLess update.`;
2749
+ renderProjectSetupWhileBusy(state);
2750
+ },
2751
+ });
2752
+ if (projectSetupState !== state) return;
2753
+ state.settingUp = null;
2754
+ renderProjectSetupWhileBusy(state);
2755
+ if (!ready.ok) {
2756
+ setProjectSetupBusy(false);
2757
+ renderProjectSetup();
2758
+ setProjectSetupError(ready.reason);
2759
+ return;
2760
+ }
2761
+ }
2582
2762
  setProjectSetupBusy(true, startChat ? 'Preparing chat…' : 'Creating…');
2583
2763
  try {
2584
2764
  if (!startChat) {
@@ -2616,7 +2796,7 @@
2616
2796
  ...(state.askCatalogue ? { environment: state.environment } : {}),
2617
2797
  directorySelectionId: state.directory.selectionId,
2618
2798
  snapshots,
2619
- provider: bridge.preferredChatProvider(),
2799
+ provider,
2620
2800
  });
2621
2801
  const project = result.project;
2622
2802
  state.project = project;
@@ -2692,6 +2872,8 @@
2692
2872
  templateId,
2693
2873
  files,
2694
2874
  kind,
2875
+ chatProvider: null,
2876
+ providersRead: false,
2695
2877
  askCatalogue: kind === 'drawings' && templateId === 'steel-model',
2696
2878
  environment: null,
2697
2879
  directory: null,
@@ -2707,6 +2889,7 @@
2707
2889
  renderProjectSetup();
2708
2890
  $projectSetup.classList.add('show');
2709
2891
  $projectSetupFolderChoose.focus();
2892
+ if (kind !== 'rvt') void refreshProjectSetupProviders(state);
2710
2893
  try {
2711
2894
  await Promise.all(files.map(assertProjectSourceReadable));
2712
2895
  if (projectSetupState !== state) return;
@@ -2744,13 +2927,16 @@
2744
2927
  projectSetupState.environment = button.dataset.environment;
2745
2928
  renderProjectSetup();
2746
2929
  });
2930
+ $projectSetupProvider?.addEventListener('click', (event) => {
2931
+ chooseProjectSetupProvider(event.target.closest('[data-chat-provider]'));
2932
+ });
2747
2933
  $projectSetupCancel.addEventListener('click', () => closeProjectSetup());
2748
2934
  $projectSetupCreate.addEventListener('click', () => createProjectFromSetup(true));
2749
2935
  $projectSetupCreateOnly.addEventListener('click', () => createProjectFromSetup(false));
2750
2936
  onBackdropDismiss($projectSetup, () => closeProjectSetup(), () => !!projectSetupState && !projectSetupState.busy);
2751
2937
  $projectSetup.addEventListener('keydown', (event) => {
2752
2938
  if (!projectSetupState) return;
2753
- if (event.key === 'Escape' && !projectSetupState.busy) {
2939
+ if (event.key === 'Escape' && (!projectSetupState.busy || projectSetupState.settingUp)) {
2754
2940
  event.preventDefault();
2755
2941
  closeProjectSetup();
2756
2942
  return;
@@ -3498,6 +3684,25 @@
3498
3684
  // Keep steel projects stage-by-stage while the first drawing read is in progress. The later tabs
3499
3685
  // stay visible so the user can see what comes next, but explain their prerequisite instead of
3500
3686
  // opening empty destinations during a potentially long terminal-AI read.
3687
+ function savedFilterNextStep(req) {
3688
+ const continuation = req?.filterSaveContinuation;
3689
+ if (continuation?.state === 'queued') return 'FloLess will continue the drawing read in the linked AI Chat when that conversation is ready.';
3690
+ if (continuation?.state === 'continuing') return 'FloLess sent the saved filter to the linked AI Chat. Follow that conversation for the drawing read.';
3691
+ if (continuation?.state === 'completed') return 'The linked AI Chat finished its response. Review its result in that conversation.';
3692
+ if (continuation?.nextAction) return continuation.nextAction;
3693
+ // No continuation record: nothing has said FloLess will carry this on, so the user must. Name
3694
+ // the session they actually have to go back to — "the terminal AI" is wrong for a read AI Chat
3695
+ // started, and sending someone to a terminal that is not doing the work is the same defect as
3696
+ // telling them to start a read that is already running.
3697
+ return `Return to the same ${readSessionName(req)} that prepared this Drawing Filter and tell it to continue the drawing read.`;
3698
+ }
3699
+
3700
+ function readyFilterNextStep(req) {
3701
+ return readRunsInChat(req)
3702
+ ? 'Then press Save filter in the top-right corner. FloLess will continue the drawing read in the linked AI Chat.'
3703
+ : 'Then press Save filter in the top-right corner. After Save, return to the terminal AI that prepared it and tell it to continue.';
3704
+ }
3705
+
3501
3706
  function stageGateFor(step) {
3502
3707
  const d = wsApp();
3503
3708
  if (!d || !d.filter || !['model', 'exports', 'history'].includes(step)) return '';
@@ -3518,11 +3723,12 @@
3518
3723
  if (projectContractLifecycle === 'unknown') return '';
3519
3724
  if (step === 'model') {
3520
3725
  if (waitingForInitial && revCardReq?.preparationState === 'blocked') return 'FloLess could not finish drawing preparation. Restart FloLess, then open Requests and follow the detailed instructions if it remains blocked.';
3521
- if (waitingForInitial && revCardReq?.preparationState === 'manifest-published' && !revCardReq?.prepassReady) return 'Drawing preparation is complete and saved. Return to the same terminal AI session and tell it to continue creating the Drawing Filter.';
3522
- if (waitingForInitial && revCardReq?.filterCheckpointCurrent) return 'The Drawing Filter is saved. Return to the same terminal AI session that prepared it and tell it to continue the drawing read.';
3523
- if (waitingForInitial && revCardReq?.prepassReady) return 'Review the selected lines, then press Save filter. After Save, return to the terminal AI that prepared it and tell it to continue.';
3524
- if (waitingForInitial && revCardReq?.preparationRetryable) return 'Steel Filter preparation was interrupted. Your drawings are still attached. Return to the same terminal AI and retry preparation for this same request.';
3525
- if (waitingForInitial) return 'The initial drawing read is waiting for your terminal AI. The model unlocks after you review the Drawing Filter and press Save filter.';
3726
+ if (waitingForInitial && revCardReq?.preparationState === 'manifest-published' && !revCardReq?.prepassReady) return `Drawing preparation is complete and saved. Return to the same ${readSessionName(revCardReq)} and tell it to continue creating the Drawing Filter.`;
3727
+ if (waitingForInitial && revCardReq?.filterSaveContinuation?.state === 'recovery-needed') return `The Drawing Filter needs attention. ${savedFilterNextStep(revCardReq)}`;
3728
+ if (waitingForInitial && revCardReq?.filterCheckpointCurrent) return `The Drawing Filter is saved. ${savedFilterNextStep(revCardReq)}`;
3729
+ if (waitingForInitial && revCardReq?.prepassReady) return `Check steel, member marks, grids, dimensions, and relevant callouts. Ask in AI Chat on the left if you need help. ${readyFilterNextStep(revCardReq)}`;
3730
+ if (waitingForInitial && revCardReq?.preparationRetryable) return `Steel Filter preparation was interrupted. Your drawings are still attached. Return to the same ${readSessionName(revCardReq)} and retry preparation for this same request.`;
3731
+ if (waitingForInitial) return `The initial drawing read is waiting for ${readRunsInChat(revCardReq) ? 'AI Chat' : 'your terminal AI'}. The model unlocks after you review the Drawing Filter and press Save filter.`;
3526
3732
  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.';
3527
3733
  return 'Read and save a Drawing Filter first. The model will unlock after the first drawing read.';
3528
3734
  }
@@ -3619,15 +3825,33 @@
3619
3825
  : waitingForInitial && revCardReq?.preparationState === 'blocked'
3620
3826
  ? 'FloLess could not finish drawing preparation · Restart FloLess, then open Requests and follow the detailed instructions if it remains blocked. Your drawings are still attached.'
3621
3827
  : waitingForInitial && revCardReq?.preparationState === 'manifest-published' && !revCardReq?.prepassReady
3622
- ? 'Drawing preparation is complete and saved · Return to the same terminal AI session and tell it to continue creating the Drawing Filter. Do not start or copy this request again.'
3828
+ ? `Drawing preparation is complete and saved · Return to the same ${readSessionName(revCardReq)} and tell it to continue creating the Drawing Filter. Do not start or copy this request again.`
3829
+ : waitingForInitial && revCardReq?.filterSaveContinuation?.state === 'recovery-needed'
3830
+ ? `Drawing Filter needs attention · ${savedFilterNextStep(revCardReq)}`
3623
3831
  : waitingForInitial && revCardReq?.filterCheckpointCurrent
3624
- ? 'The Drawing Filter is saved · Return to the same terminal AI session that prepared it and tell it to continue the drawing read. Live progress appears here once it starts.'
3832
+ ? `The Drawing Filter is saved · ${savedFilterNextStep(revCardReq)} Live progress appears here once the read starts.`
3625
3833
  : waitingForInitial && revCardReq?.prepassReady
3626
- ? 'Drawing Filter ready for review · Review the selected layers, line weights, and colours below. Then press Save filter in the top-right corner, return to the terminal AI that prepared it, and tell it to continue.'
3834
+ ? 'Drawing Filter ready for review · ' + (window.FilterGuidance?.scope || 'Check what this steel read may use — not only the steel. Keep the steel plus member labels and sizes, grid references, scale or location dimensions, and relevant detail or section callouts.') + ' Ask in AI Chat on the left if you are unsure. ' + readyFilterNextStep(revCardReq)
3627
3835
  : waitingForInitial && revCardReq?.preparationRetryable
3628
- ? 'Steel Filter preparation was interrupted · Your drawings are still attached. Return to the same terminal AI and retry preparation for this same request.'
3836
+ ? `Steel Filter preparation was interrupted · Your drawings are still attached. Return to the same ${readSessionName(revCardReq)} and retry preparation for this same request.`
3837
+ : waitingForInitial && readWorkingInChat(revCardReq)
3838
+ ? 'Drawing read is running in AI Chat · Follow it in AI Chat on the left (expand that panel if it is collapsed). Nothing to do here — FloLess updates this when the Drawing Filter is ready for your review.'
3839
+ : waitingForInitial && readChatBlockedAction(revCardReq)
3840
+ ? `Drawing read is waiting for you in AI Chat · ${OPEN_AI_CHAT} and ${readChatBlockedAction(revCardReq)}. The read continues once you do.`
3841
+ : waitingForInitial && readChatUnreadable(revCardReq)
3842
+ ? `FloLess cannot read this drawing read’s AI Chat conversation · ${OPEN_AI_CHAT} to check it. If it will not open, use Report an issue.`
3843
+ : waitingForInitial && readChatArchived(revCardReq)
3844
+ ? `Drawing read is in an archived AI Chat conversation · ${OPEN_AI_CHAT} and restore that conversation — its composer stays disabled until you do. Then tell it to continue the drawing read.`
3845
+ : waitingForInitial && readChatBusyElsewhere(revCardReq)
3846
+ ? 'Drawing read is waiting on a reply in AI Chat · If you told AI Chat to continue the drawing read, this updates as it goes. If not, tell it to continue once that reply is done — the read will not resume on its own.'
3847
+ : waitingForInitial && readChatFailed(revCardReq)
3848
+ ? `Drawing read stopped with an error in AI Chat · AI Chat’s last reply ended with an error. ${OPEN_AI_CHAT} to see what went wrong, then ask it to try the drawing read again.`
3849
+ : waitingForInitial && readChatInterrupted(revCardReq)
3850
+ ? `Drawing read was interrupted in AI Chat · AI Chat’s reply stopped before it finished. ${OPEN_AI_CHAT} and tell it to continue the drawing read.`
3851
+ : waitingForInitial && readRunsInChat(revCardReq)
3852
+ ? `Drawing read is paused in AI Chat · ${OPEN_AI_CHAT} and tell it to continue the drawing read.`
3629
3853
  : waitingForInitial
3630
- ? 'Drawing read not started · Open Requests, copy it into Claude Code, Codex, or OpenCode, then return to review and save the Drawing Filter.'
3854
+ ? 'Drawing read not started · Open Requests — if Start in AI Chat is shown, choose it; otherwise copy the request into Claude Code or Codex. Then return to review and save the Drawing Filter.'
3631
3855
  : projectContractLifecycle === 'filter-checkpoint'
3632
3856
  ? 'Drawing read needs restarting · The earlier drawing request is no longer available. Attach the drawing set again in Drawing Filter to restart the read.'
3633
3857
  : 'Start in Drawing Filter by attaching a PDF or image. The Model, Exports, and History stages unlock after the first steel model is created.';
@@ -4382,6 +4606,7 @@
4382
4606
  const KB_LOCK_STALE_MS = 10 * 60 * 1000; // = knowledge-store.ts LOCK_STALE_MS; when to warn "taking longer"
4383
4607
  const KB_MB = (n) => Math.round(n / (1024 * 1024));
4384
4608
  let knowledgePoll = null;
4609
+ let knowledgePollInFlight = false;
4385
4610
  let knowledgeState = null;
4386
4611
  let companyKnowledgeState = null;
4387
4612
  let companyKnowledgePromotion = null; // { sourceId, filename }
@@ -4477,7 +4702,10 @@
4477
4702
  if (knowledgePoll) return; // already ticking — don't stack intervals across re-renders
4478
4703
  knowledgePoll = setInterval(() => {
4479
4704
  if (!current || $wsKnowledge.hidden) { stopKnowledgePoll(); return; }
4480
- renderKnowledge();
4705
+ // Skip, don't stack (#1604): each render reads /api/requests, which can outlast this interval.
4706
+ if (knowledgePollInFlight) return;
4707
+ knowledgePollInFlight = true;
4708
+ renderKnowledge().finally(() => { knowledgePollInFlight = false; });
4481
4709
  }, 3000);
4482
4710
  }
4483
4711
 
@@ -4485,10 +4713,13 @@
4485
4713
  // (the store writes organize.json at `start`), so "pending" must be the UNION of both reads — never
4486
4714
  // /status alone. The request queue is advisory: a blip there must not blank the sources column.
4487
4715
  async function loadKnowledgeState(proj) {
4716
+ // Each read is bounded (#1604): the 3-second poll skips its ticks while a render is out, so a
4717
+ // request that never answered would stop the column refreshing for good.
4718
+ const bounded = () => ({ signal: AbortSignal.timeout(90_000) });
4488
4719
  const [status, reqs, company] = await Promise.all([
4489
- api(kbUrl(proj.id, '/status')),
4490
- api('/api/requests').catch(() => []),
4491
- api(`/api/company-knowledge?projectId=${encodeURIComponent(proj.id)}`)
4720
+ api(kbUrl(proj.id, '/status'), bounded()),
4721
+ api('/api/requests', bounded()).catch(() => []),
4722
+ api(`/api/company-knowledge?projectId=${encodeURIComponent(proj.id)}`, bounded())
4492
4723
  .catch((error) => ({ configured: false, loadError: String((error && error.message) || error) })),
4493
4724
  ]);
4494
4725
  const list = Array.isArray(reqs) ? reqs : (reqs.requests || []);
@@ -8651,6 +8882,66 @@
8651
8882
  $revisionCard.replaceChildren();
8652
8883
  }
8653
8884
  const isInitialRevisionRead = (req) => !req || !req.baseVersion || req.baseVersion <= 0;
8885
+ // ── Who is actually driving this drawing read ───────────────────────────────────────────────
8886
+ // `chatConversation` is server-owned (request-list-route). `executionOwner: 'chat'` is stamped
8887
+ // only when the read was really STARTED in the built-in AI Chat panel — which is what the
8888
+ // "Create project & start chat" flow does for you the moment a drawing set is uploaded.
8889
+ // 'discussion' means a conversation is merely open, so the handoff is still the user's to make.
8890
+ const readRunsInChat = (req) => req?.chatConversation?.executionOwner === 'chat';
8891
+ // …and ownership NEVER expires, so it cannot answer "is it working right now". A conversation
8892
+ // that finished, failed or was interrupted still owns its request, and a card reading ownership
8893
+ // alone would go on claiming motion nothing can see — the same misleading-instruction defect this
8894
+ // wording exists to remove, just relocated. The conversation's own state is the part that moves.
8895
+ // An unrecognised state (an older or newer build) counts as NOT working: the paused wording is
8896
+ // always safe to show, the running wording is not.
8897
+ // WORKING means the conversation is moving on its own. `awaiting-approval` and `recovery` are NOT
8898
+ // that, and putting them here was the same defect this wording exists to remove: a chat that has
8899
+ // STOPPED and is waiting on the person, described to that person as "nothing to do here".
8900
+ // awaiting-approval — the turn is parked on an approval only they can answer (chat-coordinator
8901
+ // patches the active turn to it and renders a decision card); the Tekla model read always
8902
+ // raises one, so this is the common case, not the exotic one.
8903
+ // recovery — the turn broke. AI Chat disables its own composer, shows a recovery control, and
8904
+ // `turnIsVisiblyActive` returns false for it; ensureRequestChatLink refuses to link a Request
8905
+ // to a chat in this state at all. Nothing will ever move it except the user.
8906
+ // They get their own wording because their ACTIONS differ, so they cannot share a sentence.
8907
+ const CHAT_WORKING_STATES = ['starting', 'running'];
8908
+ const CHAT_BLOCKED_ACTIONS = { 'awaiting-approval': 'answer the question it is waiting on', recovery: 'use its recovery control' };
8909
+ const readChatState = (req) => (readRunsInChat(req) ? req?.chatConversation?.chatState ?? null : null);
8910
+ const readWorkingInChat = (req) => CHAT_WORKING_STATES.includes(readChatState(req));
8911
+ const readChatBlockedAction = (req) => CHAT_BLOCKED_ACTIONS[readChatState(req)] || '';
8912
+ // The conversation exists but the server could not read it. Saying "it is paused, go continue it"
8913
+ // here sends the user to open the very conversation the server just failed to read.
8914
+ const readChatUnreadable = (req) => readChatState(req) === 'unreadable';
8915
+ // BUSY WITH SOMETHING ELSE is a third honest answer, and it exists because one conversation can
8916
+ // hold several Requests (`startRequest` reuses the selected chat when it is idle) and the person
8917
+ // can ask it anything else at any time. The conversation is moving, but not on THIS read, so
8918
+ // neither of the other two answers is true — "running" claims motion this request is not getting,
8919
+ // and "tell it to continue" cannot be done yet: Send is disabled while any reply is in flight. Nor
8920
+ // is the read QUEUED behind that reply — a read's own turn never waits in line (acceptTurn refuses
8921
+ // a second active turn), so when the other reply finishes nothing picks the read up. The person
8922
+ // has to wait for it, then tell AI Chat to continue (#1610). And FloLess cannot tell WHAT that
8923
+ // reply is about: a message the person typed — including "continue the drawing read", the very
8924
+ // instruction these cards give — is not provably this read's, so the wording must hold for both
8925
+ // a reply that is continuing the read and one about something else.
8926
+ const readChatBusyElsewhere = (req) => readChatState(req) === 'busy-elsewhere';
8927
+ // ARCHIVED IS NOT PAUSED: AI Chat disables an archived conversation's composer, so "tell it to
8928
+ // continue" cannot be carried out until the user restores it. The guidance names the restore.
8929
+ const readChatArchived = (req) => readChatState(req) === 'archived';
8930
+ // FAILED AND INTERRUPTED ARE NOT "PAUSED" (#1611). Both used to fall into the stopped bucket and
8931
+ // read as "paused … tell it to continue", which is softer than the truth: a failed reply ended with
8932
+ // an error the person should look at before asking again, and an interrupted one stopped before it
8933
+ // finished. The composer stays usable after either, so each names its own next step.
8934
+ const readChatFailed = (req) => readChatState(req) === 'failed';
8935
+ const readChatInterrupted = (req) => readChatState(req) === 'interrupted';
8936
+ // WHERE AI CHAT IS. The left panel can be collapsed (persisted, and the default on touch), and then
8937
+ // no panel called AI Chat is on screen — "open the AI Chat panel on the left and …" was an
8938
+ // instruction a person could not follow without first doing a step it never named (#1611). One
8939
+ // phrase, true in both layouts, used by every instruction that sends someone to AI Chat.
8940
+ const OPEN_AI_CHAT = 'Open AI Chat on the left (expand that panel if it is collapsed)';
8941
+ // Name the session the user has to go back to. Every "return to the terminal AI that prepared
8942
+ // it" line is wrong for a read AI Chat started, and sending someone to a terminal that is not
8943
+ // doing the work is the same defect as telling them to start a read that is already running.
8944
+ const readSessionName = (req) => readRunsInChat(req) ? 'AI Chat conversation' : 'terminal AI session';
8654
8945
  function isRevisionStale(req) {
8655
8946
  return !!req && Number.isInteger(req.baseVersion) && Number.isInteger(req.headVersion)
8656
8947
  && req.baseVersion !== req.headVersion;
@@ -8664,9 +8955,20 @@
8664
8955
  return req.status === 'staged' && req.steelAuditPolicy === 1;
8665
8956
  }
8666
8957
  function stopRevisionPoll() { if (revisionPoll) { clearInterval(revisionPoll); revisionPoll = null; } }
8958
+ // A tick is SKIPPED while the previous poll is still out, never stacked behind it (#1604). Each render
8959
+ // reads /api/requests, which can outlast this 3-second interval on a busy machine; stacking one per
8960
+ // tick held more and more of the browser's ~6 connections to this server until AI Chat and every
8961
+ // other request queued behind them. Only the poll is gated: a render started by a user action still
8962
+ // runs at once.
8963
+ let revisionPollInFlight = false;
8667
8964
  function startRevisionPoll() {
8668
8965
  stopRevisionPoll();
8669
- revisionPoll = setInterval(() => { if (current) renderRevisionCard(); else stopRevisionPoll(); }, 3000);
8966
+ revisionPoll = setInterval(() => {
8967
+ if (!current) { stopRevisionPoll(); return; }
8968
+ if (revisionPollInFlight) return;
8969
+ revisionPollInFlight = true;
8970
+ renderRevisionCard().finally(() => { revisionPollInFlight = false; });
8971
+ }, 3000);
8670
8972
  }
8671
8973
  const revEl = (tag, cls, text) => {
8672
8974
  const e = document.createElement(tag);
@@ -8756,14 +9058,24 @@
8756
9058
  const dot = revEl('span', 'wrc-dot'); dot.setAttribute('aria-hidden', 'true');
8757
9059
  const txt = revEl('span', 'wrc-text');
8758
9060
  txt.appendChild(revEl('b', null, 'Drawing preparation is complete and saved.'));
8759
- txt.appendChild(document.createTextNode(' Return to the same terminal AI session and tell it to continue creating the Drawing Filter. Do not start or copy this request again.'));
9061
+ txt.appendChild(document.createTextNode(` Return to the same ${readSessionName(req)} and tell it to continue creating the Drawing Filter. Do not start or copy this request again.`));
8760
9062
  return [dot, txt];
8761
9063
  }
9064
+ if (req.filterSaveContinuation?.state === 'recovery-needed') {
9065
+ const dot = revEl('span', 'wrc-warn-ico', '⚠'); dot.setAttribute('aria-hidden', 'true');
9066
+ const txt = revEl('span', 'wrc-text');
9067
+ txt.appendChild(revEl('b', null, 'Drawing Filter needs attention.'));
9068
+ txt.appendChild(document.createTextNode(` ${savedFilterNextStep(req)}`));
9069
+ const review = revEl('button', 'btn-mini', 'Open Drawing Filter');
9070
+ review.type = 'button'; review.dataset.revfilter = ''; review.dataset.commandId = 'shell.revision-filter-open';
9071
+ review.setAttribute('data-tip', 'Focus the Drawing Filter below');
9072
+ return [dot, txt, review];
9073
+ }
8762
9074
  if (req.prepassReady && req.filterCheckpointCurrent) {
8763
9075
  const dot = revEl('span', 'wrc-dot'); dot.setAttribute('aria-hidden', 'true');
8764
9076
  const txt = revEl('span', 'wrc-text');
8765
9077
  txt.appendChild(revEl('b', null, 'Drawing Filter saved.'));
8766
- txt.appendChild(document.createTextNode(' Return to the same terminal AI session that prepared this Drawing Filter and tell it to continue the drawing read.'));
9078
+ txt.appendChild(document.createTextNode(` ${savedFilterNextStep(req)}`));
8767
9079
  return [dot, txt];
8768
9080
  }
8769
9081
  // Defensive fallback for a strip that could not paint; ordinary initial reads put this action in
@@ -8772,7 +9084,7 @@
8772
9084
  const dot = revEl('span', 'wrc-dot'); dot.setAttribute('aria-hidden', 'true');
8773
9085
  const txt = revEl('span', 'wrc-text');
8774
9086
  txt.appendChild(revEl('b', null, 'Drawing Filter is ready.'));
8775
- txt.appendChild(document.createTextNode(' Review the selected layers, line weights, and colours. Then press Save filter in the top-right corner, return to the terminal AI that prepared it, and tell it to continue the drawing read.'));
9087
+ txt.appendChild(document.createTextNode(' ' + (window.FilterGuidance?.scope || 'Check what this steel read may use — not only the steel. Keep the steel plus member labels and sizes, grid references, scale or location dimensions, and relevant detail or section callouts.') + ' Ask in AI Chat on the left if you are unsure. ' + readyFilterNextStep(req)));
8776
9088
  const review = revEl('button', 'btn-mini', 'Open Drawing Filter');
8777
9089
  review.type = 'button'; review.dataset.revfilter = ''; review.dataset.commandId = 'shell.revision-filter-open';
8778
9090
  review.setAttribute('data-tip', 'Focus the Drawing Filter below');
@@ -8784,12 +9096,31 @@
8784
9096
  const txt = revEl('span', 'wrc-text');
8785
9097
  const active = runState === 'queued' || runState === 'running';
8786
9098
  txt.appendChild(revEl('b', null, active ? 'Retrying Steel Filter preparation.' : 'Steel Filter preparation was interrupted.'));
9099
+ // CHAT OWNERSHIP IS CHECKED FIRST, ahead of `canRun`. `canRun` is server policy about whether
9100
+ // FloLess *could* start a headless retry; it stays true while AI Chat holds the request, and
9101
+ // the Requests row withholds Retry preparation from a chat-owned row exactly as it withholds
9102
+ // Copy. Reading `canRun` first therefore named a button that is not on screen — the one class
9103
+ // of instruction this work exists to remove.
9104
+ //
9105
+ // And a conversation stalled on the person, or one FloLess cannot read, cannot be asked to
9106
+ // retry: "ask that conversation to retry" is unfollowable until the user unblocks it. Those
9107
+ // two states name their own action instead, the same three buckets the rest of this file uses.
9108
+ const chatBlocked = readChatBlockedAction(req);
8787
9109
  txt.appendChild(document.createTextNode(active
8788
9110
  ? ' FloLess is continuing this same request with the attached drawings.'
9111
+ : readChatUnreadable(req)
9112
+ ? ` Your drawings are still attached, but FloLess cannot read the AI Chat conversation that holds this request. ${OPEN_AI_CHAT} to check it. If it will not open, use Report an issue.`
9113
+ : chatBlocked
9114
+ ? ` Your drawings are still attached. The AI Chat conversation that holds this request is waiting for you. ${OPEN_AI_CHAT} and ${chatBlocked}, then ask it to retry preparation.`
9115
+ : readRunsInChat(req)
9116
+ ? ` Your drawings are still attached. ${OPEN_AI_CHAT} and ask that conversation to retry preparation for this same request.`
8789
9117
  : req.canRun
8790
9118
  ? ' Your drawings are still attached. Open Requests and choose Retry preparation to continue this same request.'
8791
- : ' Your drawings are still attached. Return to the same terminal AI and retry preparation for this same request, or copy the retry request from here.'));
8792
- if (!active && !req.canRun) {
9119
+ : ` Your drawings are still attached. Return to the same ${readSessionName(req)} and retry preparation for this same request, or copy the retry request from here.`));
9120
+ // No Copy when AI Chat owns the request, for the same reason the pending branch withholds it:
9121
+ // a second handoff cannot help while the first one holds the request, and pasting it into a
9122
+ // terminal is how two writers end up in one project folder.
9123
+ if (!active && !req.canRun && !readRunsInChat(req)) {
8793
9124
  const copy = revEl('button', 'btn-mini', '⧉ Copy retry');
8794
9125
  copy.type = 'button'; copy.dataset.revcopy = ''; copy.dataset.commandId = 'shell.revision-request-copy';
8795
9126
  copy.setAttribute('data-tip', 'Copy the retained request to retry preparation');
@@ -8810,17 +9141,58 @@
8810
9141
  txt.appendChild(document.createTextNode(` Your terminal AI is preparing ${n} file${n > 1 ? 's' : ''}. Leave FloLess open — you can keep working elsewhere in it. Progress and what to do next appear here. Open Requests if you need to stop it.`));
8811
9142
  return [dot, txt];
8812
9143
  }
9144
+ // AI CHAT ALREADY HAS IT. The "Create project & start chat" flow hands the first read straight to
9145
+ // the AI Chat panel on the left, so the handoff copy below — the whole point of which is to tell
9146
+ // someone to start a read — describes work that is already happening. Like the background-run
9147
+ // branch above, this offers NO Copy: a second handoff is not a useful fallback while the first
9148
+ // one is active, and here it would also try to take a request AI Chat owns. Ownership alone does
9149
+ // not prove motion (readWorkingInChat), so a stopped conversation gets the wording that asks the
9150
+ // user to continue it rather than a claim of progress nothing can see.
9151
+ if (readRunsInChat(req)) {
9152
+ const dot = revEl('span', 'wrc-dot'); dot.setAttribute('aria-hidden', 'true');
9153
+ const txt = revEl('span', 'wrc-text');
9154
+ const blockedAction = readChatBlockedAction(req);
9155
+ const lead = readWorkingInChat(req) ? 'running in AI Chat'
9156
+ : blockedAction ? 'waiting for you in AI Chat'
9157
+ : readChatUnreadable(req) ? 'in an AI Chat conversation FloLess cannot read'
9158
+ : readChatArchived(req) ? 'in an archived AI Chat conversation'
9159
+ : readChatBusyElsewhere(req) ? 'waiting on a reply in AI Chat'
9160
+ : readChatFailed(req) ? 'stopped by an error in AI Chat'
9161
+ : readChatInterrupted(req) ? 'interrupted in AI Chat'
9162
+ : 'paused in AI Chat';
9163
+ txt.appendChild(revEl('b', null, `${isInitialRevisionRead(req) ? 'Initial' : 'Updated'} drawing read is ${lead}.`));
9164
+ txt.appendChild(document.createTextNode(readWorkingInChat(req)
9165
+ ? ` AI Chat on the left is reading ${n} file${n > 1 ? 's' : ''}. There is nothing to do here — leave FloLess open. Larger drawing sets take longer; FloLess updates this card when the Drawing Filter is ready for your review.`
9166
+ : blockedAction
9167
+ ? ` Your drawings are still attached. ${OPEN_AI_CHAT} and ${blockedAction}; the read continues once you do.`
9168
+ : readChatUnreadable(req)
9169
+ ? ` Your drawings are still attached. ${OPEN_AI_CHAT} to check that conversation. If it will not open, use Report an issue — FloLess could not read it.`
9170
+ : readChatArchived(req)
9171
+ ? ` Your drawings are still attached. ${OPEN_AI_CHAT} and restore that conversation — its composer stays disabled while it is archived — then tell it to continue the drawing read.`
9172
+ : readChatBusyElsewhere(req)
9173
+ ? ' Your drawings are still attached. If you already asked AI Chat to continue, this card updates as the read moves forward. If not, tell it to continue once the current reply is done — the read will not resume on its own.'
9174
+ : readChatFailed(req)
9175
+ ? ` Your drawings are still attached, but AI Chat’s last reply ended with an error. ${OPEN_AI_CHAT} to see what went wrong, then ask it to try the drawing read again.`
9176
+ : readChatInterrupted(req)
9177
+ ? ` Your drawings are still attached, but AI Chat’s reply stopped before it finished. ${OPEN_AI_CHAT} and tell it to continue the drawing read.`
9178
+ : ` Your drawings are still attached, but AI Chat is not working on them right now. ${OPEN_AI_CHAT} and tell it to continue the drawing read.`));
9179
+ return [dot, txt];
9180
+ }
8813
9181
  // `pending` means the request is waiting for the terminal AI handoff; it does not prove that an
8814
9182
  // AI is actively reading. A spinner made a pasted instruction look like an already-running job.
8815
9183
  const dot = revEl('span', 'wrc-dot'); dot.setAttribute('aria-hidden', 'true');
8816
9184
  const txt = revEl('span', 'wrc-text');
8817
9185
  txt.appendChild(revEl('b', null, `${isInitialRevisionRead(req) ? 'Initial' : 'Updated'} drawing read is waiting for your terminal AI.`));
8818
9186
  // Runtime discovery belongs to the Requests surface, not this workspace card. `canRun` is only
8819
- // server policy; it does not prove that a supported terminal AI is installed on this machine.
8820
- // Phrase the optional shortcut conditionally so the card never points to a hidden control.
9187
+ // server policy; it does not prove that a supported terminal AI is installed on this machine, and
9188
+ // Start in AI Chat needs a signed-in chat provider plus a request in chat scope. So BOTH halves
9189
+ // name their control conditionally — "if it is shown, choose it" is true either way and never
9190
+ // points at a hidden one. The terminal is one route among them, not the only instruction.
9191
+ // OpenCode is deliberately absent: FloLess cannot run it, so naming it as a destination sends
9192
+ // people to a terminal that will not be able to finish the read.
8821
9193
  const handoff = !isInitialRevisionRead(req) && req.canRun
8822
- ? 'Open Requests. If Start automatically is shown, choose it; otherwise copy the request into Claude Code, Codex, or OpenCode.'
8823
- : 'Open Requests and copy the request into Claude Code, Codex, or OpenCode.';
9194
+ ? 'Open Requests. If Start automatically is shown, choose it; otherwise copy the request into Claude Code or Codex.'
9195
+ : 'Open Requests. If Start in AI Chat is shown, choose it; otherwise copy the request into Claude Code or Codex.';
8824
9196
  // No numeric cap. "up to 30 minutes" was a promise this card cannot keep: the read runs in
8825
9197
  // someone else's terminal AI over a drawing set whose size we do not bound, and a stated
8826
9198
  // ceiling that is routinely blown past reads as a stall or a hang rather than as normal work.
@@ -8949,7 +9321,10 @@
8949
9321
  // to remove, and enough to fail the console-clean bar every E2E is held to. Silence was still
8950
9322
  // wrong (a stuck card had no trace at all), so the first failure speaks and the recovery resets it.
8951
9323
  try {
8952
- const b = await api('/api/requests');
9324
+ // Bounded (#1604): the poll skips its ticks while this is out, so a read that never answered
9325
+ // would stop the card for good. 90 s, like the Requests window: the route's own lock waits
9326
+ // give up after 60 s.
9327
+ const b = await api('/api/requests', { signal: AbortSignal.timeout(90_000) });
8953
9328
  reqs = Array.isArray(b) ? b : (b.requests || []);
8954
9329
  // Every owned success is fresh evidence of server contact, even if a later-started poll is in
8955
9330
  // flight or has failed. The route can legitimately outlast the 3-second polling interval.
@@ -9092,7 +9467,15 @@
9092
9467
  // card too produced the two contradictory-looking status bands in the reported UI.
9093
9468
  if (retireRevisionCardForStrip(pending)) return;
9094
9469
  const cardKey = `${state}:${revCardReq ? revCardReq.id : ''}:${pending && pending.filterCheckpointCurrent ? 'filter-saved' : pending && pending.prepassReady ? 'filter-ready' : 'read-pending'}:${pending && pending.run ? pending.run.state || '' : ''}`
9095
- + (pending ? `:${pending.preparationState || ''}:${pending.preparationRetryable === true}:${pending.canRun === true}:${pending.canCopy === true}:${pending.canClear === true}:${pending.clearWhy || ''}` : '')
9470
+ + (pending ? `:${pending.preparationState || ''}:${pending.preparationRetryable === true}:${pending.canRun === true}:${pending.canCopy === true}:${pending.canClear === true}:${pending.clearWhy || ''}:${pending.filterSaveContinuation?.state || ''}:${pending.filterSaveContinuation?.nextAction || ''}` : '')
9471
+ // WHO IS DRIVING THE READ, and whether that conversation is working, both change the card's
9472
+ // words AND whether it offers Copy — and neither is implied by any field above. Without them
9473
+ // the three-second poll short-circuits on an unchanged key, so a read that AI Chat picks up
9474
+ // keeps its "… drawing read is waiting for your terminal AI." card indefinitely while the
9475
+ // banner two lines up already says the read is running in AI Chat. Measured in a real browser.
9476
+ // (`applyStageGating()` still runs on the short-circuit path, which is why only one of the two
9477
+ // surfaces went stale — and why the contradiction was visible at all.)
9478
+ + `:${revCardReq?.chatConversation?.executionOwner || ''}:${revCardReq?.chatConversation?.chatState || ''}`
9096
9479
  + (staged ? `:${staged.baseVersion}:${staged.headVersion}:${staged.stageId || ''}:${staged.canDiscardRevision === true}:${staged.discardState || ''}:${staged.discardWhy || ''}:${staged.canClear === true}:${staged.clearWhy || ''}:${unavailableRevisionReviewStages.has(staged.stageId)}` : '');
9097
9480
  // The key below exists to preserve focus in the card across the three-second poll. It says
9098
9481
  // nothing about the strip, whose progress record advances on its own revision, so the strip is