@floless/app 0.127.3 → 0.127.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/web/app.css CHANGED
@@ -1305,14 +1305,16 @@
1305
1305
  justify-content: center;
1306
1306
  }
1307
1307
  .modal-backdrop.show { display: flex; animation: fade-in 0.15s ease-out; }
1308
- /* The shared form modal is the one every OTHER modal opens on top of itself — the run options
1309
- over Requests, the folder over Integrations — so it cannot share their z-index. Every backdrop
1308
+ /* The shared form and confirmation modals are the ones OTHER modals open on top of themselves —
1309
+ run options and desktop-claim release over Requests, the folder over Integrations — so they
1310
+ cannot share their z-index. Every backdrop
1310
1311
  sitting at 100 means DOM ORDER decides, and #form-modal is declared before #requests-modal:
1311
- the form painted UNDERNEATH, its buttons swallowed by the .req-item behind it. Not a paint bug
1312
+ the nested modal paints UNDERNEATH, its buttons swallowed by the .req-item behind it. Not a paint bug
1312
1313
  you could see, either — the dialog looked fine and simply refused to respond, which is why it
1313
1314
  is pinned here rather than fixed by moving the element and hoping. Still below toasts (200),
1314
1315
  which must stay readable over anything. */
1315
- #form-modal { z-index: 110; }
1316
+ #form-modal,
1317
+ #confirm-modal { z-index: 110; }
1316
1318
  @keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
1317
1319
  .modal {
1318
1320
  background: var(--surface);
@@ -2067,6 +2069,36 @@
2067
2069
  .req-run-resume-command:hover { border-color: var(--accent-dim); background: var(--accent-soft); color: var(--text); }
2068
2070
  .req-run-resume-command:active { background: var(--surface-3); }
2069
2071
  .req-run-resume-command:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
2072
+ .req-app-recovery, .req-app-claimed { display: flex; flex-direction: column; gap: 7px;
2073
+ padding: 9px; border: 1px solid var(--border-strong); border-radius: 5px; background: var(--surface-2); }
2074
+ .req-app-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
2075
+ .req-app-handoff, .req-app-release { min-height: 40px; padding: 0 12px; border: 1px solid var(--border-strong);
2076
+ border-radius: 4px; display: inline-flex; align-items: center; justify-content: center; text-align: center;
2077
+ appearance: none; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
2078
+ color: var(--accent-bright); background: transparent; transition: border-color .12s, background .12s, color .12s; }
2079
+ .req-app-handoff { width: auto; flex: 0 0 auto; }
2080
+ .req-app-handoff:disabled { cursor: wait; opacity: .65; }
2081
+ .req-app-handoff-primary { color: var(--text); border-color: var(--accent); background: var(--accent); }
2082
+ .req-app-handoff:hover, .req-app-release:hover { border-color: var(--accent-dim); background: var(--accent-soft); color: var(--text); }
2083
+ .req-app-handoff-primary:hover { border-color: var(--accent-bright); background: var(--accent-bright); color: var(--bg); }
2084
+ .req-app-handoff:focus-visible, .req-app-release:focus-visible, .req-app-copy:focus-visible,
2085
+ .req-terminal-fallback > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
2086
+ .req-app-launch-status { min-height: 16px; color: var(--text-muted); font-size: 10.5px; }
2087
+ .req-app-launch-status:empty { display: none; }
2088
+ .req-app-copy { width: fit-content; min-height: 40px; padding: 0; appearance: none; border: 0;
2089
+ background: transparent; color: var(--text-muted); font: inherit; font-size: 10.5px; cursor: pointer; }
2090
+ .req-app-copy:hover { color: var(--accent-bright); }
2091
+ .req-app-claimed strong { color: var(--text); }
2092
+ .req-app-claimed span { color: var(--text-muted); }
2093
+ .req-app-release { width: 100%; color: var(--text-muted); }
2094
+ .req-terminal-fallback { padding-top: 2px; }
2095
+ .req-terminal-fallback > summary { min-height: 40px; display: flex; align-items: center; list-style: none;
2096
+ cursor: pointer; color: var(--text-dim); user-select: none; }
2097
+ .req-terminal-fallback > summary::-webkit-details-marker { display: none; }
2098
+ .req-terminal-fallback > summary::before { content: '▸'; margin-right: 6px; color: var(--text-dim); }
2099
+ .req-terminal-fallback[open] > summary::before { content: '▾'; }
2100
+ .req-terminal-fallback .req-run-resume { margin-top: 5px; }
2101
+ .req-terminal-fallback .req-run-where { margin-top: 5px; }
2070
2102
  /* The agent's question, VERBATIM. A quote, deliberately — the warn rule and the italic say
2071
2103
  "somebody said this to you", where a plain paragraph would read as floless's own prose and a
2072
2104
  field would read as somewhere to answer. There is nowhere to answer; that is the point. */
package/dist/web/aware.js CHANGED
@@ -3249,35 +3249,58 @@
3249
3249
  function hideModal(el) { el.classList.remove('show'); }
3250
3250
 
3251
3251
  // Save-on-switch confirmation. Resolves with 'save' | 'discard' | 'cancel'.
3252
- // Save is the primary (Enter); Esc and the backdrop both cancel (the safe,
3252
+ // Enter belongs to the focused native button; Esc and the backdrop cancel (the safe,
3253
3253
  // non-destructive default — never lose edits to a stray key/click).
3254
3254
  const $confirmModal = document.getElementById('confirm-modal');
3255
- function confirmUnsavedSwitch(appName, subMsg, titleMsg) {
3255
+ let _confirmModalOpen = false;
3256
+ function confirmUnsavedSwitch(appName, subMsg, titleMsg, actionLabels) {
3256
3257
  return new Promise((resolve) => {
3258
+ if (_confirmModalOpen) { console.warn('confirmUnsavedSwitch: confirmation already open'); resolve('cancel'); return; }
3259
+ const returnFocus = document.activeElement instanceof HTMLElement ? document.activeElement : null;
3257
3260
  const $title = document.getElementById('confirm-modal-title');
3258
3261
  const $sub = document.getElementById('confirm-modal-sub');
3259
3262
  const $save = document.getElementById('confirm-save');
3260
3263
  const $dont = document.getElementById('confirm-dont-save');
3261
3264
  const $cancel = document.getElementById('confirm-cancel');
3265
+ $save.textContent = (actionLabels && actionLabels.confirm) || 'Save';
3266
+ $dont.textContent = (actionLabels && actionLabels.discard) || 'Don’t save';
3267
+ $cancel.textContent = (actionLabels && actionLabels.cancel) || 'Cancel';
3268
+ $dont.hidden = !!(actionLabels && actionLabels.hideDiscard);
3262
3269
  $title.textContent = titleMsg || 'Unsaved input changes'; // reset each call (default = the inputs-switch copy)
3263
3270
  $sub.textContent = subMsg || `You changed the inputs for “${appName}” but haven’t saved them yet. What would you like to do?`;
3264
3271
  showModal($confirmModal);
3265
- setTimeout(() => $save.focus(), 0);
3272
+ _confirmModalOpen = true;
3273
+ setTimeout(() => ((actionLabels && actionLabels.initialFocus === 'cancel') ? $cancel : $save).focus(), 0);
3274
+ let settled = false;
3266
3275
  const done = (result) => {
3276
+ if (settled) return;
3277
+ settled = true;
3278
+ _confirmModalOpen = false;
3267
3279
  hideModal($confirmModal);
3268
- $save.onclick = $dont.onclick = $cancel.onclick = $confirmModal.onclick = null;
3269
- document.removeEventListener('keydown', onKey, true);
3280
+ $dont.hidden = false;
3281
+ $save.onclick = $dont.onclick = $cancel.onclick = $confirmModal.onclick = $confirmModal.onkeydown = null;
3282
+ if (returnFocus && returnFocus.isConnected && !returnFocus.matches(':disabled,[aria-disabled="true"]')) returnFocus.focus();
3270
3283
  resolve(result);
3271
3284
  };
3272
3285
  const onKey = (e) => {
3273
- if (e.key === 'Escape') { e.preventDefault(); done('cancel'); }
3274
- else if (e.key === 'Enter') { e.preventDefault(); done('save'); }
3286
+ if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); done('cancel'); }
3287
+ else if (e.key === 'Tab') {
3288
+ const focusable = Array.from($confirmModal.querySelectorAll('button:not([disabled]):not([hidden]), [tabindex]:not([tabindex="-1"])'))
3289
+ .filter((el) => el instanceof HTMLElement && !el.hidden && el.getClientRects().length);
3290
+ if (!focusable.length) { e.preventDefault(); return; }
3291
+ const first = focusable[0]; const last = focusable[focusable.length - 1];
3292
+ if (e.shiftKey && (document.activeElement === first || !$confirmModal.contains(document.activeElement))) {
3293
+ e.preventDefault(); last.focus();
3294
+ } else if (!e.shiftKey && (document.activeElement === last || !$confirmModal.contains(document.activeElement))) {
3295
+ e.preventDefault(); first.focus();
3296
+ }
3297
+ }
3275
3298
  };
3276
3299
  $save.onclick = () => done('save');
3277
3300
  $dont.onclick = () => done('discard');
3278
3301
  $cancel.onclick = () => done('cancel');
3279
3302
  onBackdropDismiss($confirmModal, () => done('cancel'));
3280
- document.addEventListener('keydown', onKey, true);
3303
+ $confirmModal.onkeydown = onKey;
3281
3304
  });
3282
3305
  }
3283
3306
 
@@ -7065,13 +7088,13 @@
7065
7088
  const RUN_VIEW = {
7066
7089
  queued: { badge: 'Queued', cls: 'active', spin: true, note: (rt) => `Starting ${rt}.` },
7067
7090
  running: { badge: 'Running', cls: 'active', spin: true, note: (rt) => `${rt} is working on this. It clears itself when it’s done.` },
7068
- 'needs-you': { badge: 'Needs you', cls: 'warn', note: () => 'Your terminal AI stopped because this needs a decision from you:' },
7069
- interrupted: { badge: 'Interrupted', cls: 'warn', note: () => 'floless restarted while this was running, so the run stopped. The request is still queued — pick the session up in your terminal, or run it again.' },
7091
+ 'needs-you': { badge: 'Needs your input', cls: 'warn', note: () => 'Your input is needed:' },
7092
+ interrupted: { badge: 'Interrupted', cls: 'warn', note: () => 'This request stopped before finishing.' },
7070
7093
  // Never the identifier `contract-violation` — the user did not write the contract.
7071
- 'contract-violation': { badge: 'Unverified', cls: 'err', note: () => 'The run ended without a final answer floless could read, so it may or may not have changed anything. Check in your terminal before running it again.' },
7072
- 'exited-unresolved': { badge: 'Finished, unconfirmed', cls: 'warn', note: () => 'The run ended cleanly but left this request queued, so floless can’t say the work was done.' },
7094
+ 'contract-violation': { badge: 'Unverified', cls: 'err', note: () => 'This request finished without a verified result.' },
7095
+ 'exited-unresolved': { badge: 'Finished, unconfirmed', cls: 'warn', note: () => 'Review and confirm this request in a desktop app.' },
7073
7096
  failed: { badge: 'Failed', cls: 'err', note: () => 'The run failed.' },
7074
- stopped: { badge: 'Stopped', cls: 'muted', note: () => 'You stopped this run.' },
7097
+ stopped: { badge: 'Stopped', cls: 'muted', note: () => 'Continue this request in a desktop app.' },
7075
7098
  };
7076
7099
 
7077
7100
  // A parked run is a hand-off, not a browser-owned conversation (§G). The server stamps a command
@@ -7084,7 +7107,7 @@
7084
7107
  return (await copyToClipboard(command)) ? 'ok' : 'denied';
7085
7108
  }
7086
7109
 
7087
- function runStatusHtml(run, stampedResumeCommand) {
7110
+ function runStatusHtml(run, stampedResumeCommand, desktopHandoffs, requestId) {
7088
7111
  if (!run || !run.state) return '';
7089
7112
  const v = RUN_VIEW[run.state] || { badge: String(run.state), cls: 'muted', note: () => '' };
7090
7113
  const rt = runtimeLabel(run.runtime);
@@ -7092,6 +7115,27 @@
7092
7115
  // `resumeCommand` belongs to the SERVER'S request view, not persisted `run` metadata: the
7093
7116
  // store deliberately carries only runtime/session identity, while terminal-runtime.ts owns argv.
7094
7117
  const resumeCommand = RESUMABLE_RUN_STATES.has(run.state) ? stampedResumeCommand : null;
7118
+ const handoffs = desktopHandoffs && RESUMABLE_RUN_STATES.has(run.state) ? desktopHandoffs : null;
7119
+ const claim = handoffs && handoffs.claim;
7120
+ const providers = handoffs && handoffs.preferredProvider === 'claude' ? ['claude', 'codex'] : ['codex', 'claude'];
7121
+ const availableProviders = handoffs ? providers.filter((provider) => handoffs[provider].available) : [];
7122
+ const copyProvider = handoffs ? (availableProviders[0] || handoffs.preferredProvider) : null;
7123
+ const appButtons = handoffs && !claim ? availableProviders.map((provider, i) => {
7124
+ const app = handoffs[provider];
7125
+ const label = provider === 'codex' ? 'Codex' : 'Claude';
7126
+ return `<button type="button" class="req-app-handoff ${i === 0 ? 'req-app-handoff-primary' : ''}" data-id="${escapeAttr(requestId)}" data-attempt-id="${escapeAttr(run.leaseId)}" data-provider="${provider}" data-handoff-prompt="${escapeAttr(app.prompt)}" data-tip="Open this request in ${label} Desktop">Open ${label}</button>`;
7127
+ }).join('') : '';
7128
+ const desktop = handoffs
7129
+ ? claim
7130
+ ? `<div class="req-app-claimed"><strong>Continuing in ${claim.provider === 'claude' ? 'Claude' : 'Codex'}</strong><span>That app owns this recovery.</span><button type="button" class="req-app-release" data-id="${escapeAttr(requestId)}" data-attempt-id="${escapeAttr(claim.attemptId)}" data-claim-id="${escapeAttr(claim.claimId)}">Release and choose another app</button></div>`
7131
+ : `<div class="req-app-recovery"><div class="req-app-actions">${appButtons}</div><div class="req-app-launch-status" aria-live="polite"></div><button type="button" class="req-app-copy" data-handoff-prompt="${escapeAttr(handoffs[copyProvider].prompt)}" data-tip="Copy this handoff to paste in a desktop app or terminal AI">${appButtons ? 'Didn’t open? Copy handoff' : 'Copy handoff'}</button></div>`
7132
+ : '';
7133
+ // Never expose a reusable resume command beside a claim-aware handoff bootstrap. A user could
7134
+ // copy one, claim the other, and later start two writers in the same folder. The bootstrap remains
7135
+ // copyable even when native launch fails or no protocol fits, and is safe to paste in an app or CLI.
7136
+ const terminalFallback = !handoffs && resumeCommand
7137
+ ? `<details class="req-terminal-fallback"><summary>Terminal fallback</summary><div class="req-run-resume"><button type="button" class="req-run-resume-command" data-resume-command="${escapeAttr(resumeCommand)}" data-tip="Copy command to continue this session" aria-label="Copy terminal fallback command"><code>${escapeHtml(resumeCommand)}</code></button></div>${run.cwd ? `<div class="req-run-where">Run in · ${escapeHtml(run.cwd)}</div>` : ''}</details>`
7138
+ : '';
7095
7139
  return `
7096
7140
  <div class="req-run-status">
7097
7141
  <div class="req-run-head">
@@ -7100,8 +7144,9 @@
7100
7144
  </div>
7101
7145
  ${note ? `<p class="req-run-note">${escapeHtml(note)}</p>` : ''}
7102
7146
  ${run.question ? `<p class="req-run-question">${escapeHtml(run.question)}</p>` : ''}
7103
- ${resumeCommand ? `<div class="req-run-resume"><span class="req-run-resume-label">Continue in terminal</span><button type="button" class="req-run-resume-command" data-resume-command="${escapeAttr(resumeCommand)}" data-tip="Copy command to continue this session" aria-label="Copy resume command: ${escapeAttr(resumeCommand)}"><code>${escapeHtml(resumeCommand)}</code></button></div>` : ''}
7104
- ${run.cwd ? `<div class="req-run-where">Run in · ${escapeHtml(run.cwd)}</div>` : ''}
7147
+ ${desktop}
7148
+ ${terminalFallback}
7149
+ ${!handoffs && run.cwd ? `<div class="req-run-where">Run in · ${escapeHtml(run.cwd)}</div>` : ''}
7105
7150
  ${run.lastOutput ? `<details class="req-run-output"><summary>Show what it printed</summary><pre>${escapeHtml(run.lastOutput)}</pre></details>` : ''}
7106
7151
  </div>`;
7107
7152
  }
@@ -7520,8 +7565,8 @@
7520
7565
  * per-id loop rather than the atomic verb.
7521
7566
  */
7522
7567
  function bulkClearPlan(painted, all, filterActive) {
7523
- const keep = painted.filter((r) => r && r.type === 'knowledge-organize');
7524
- const drop = painted.filter((r) => r && r.type !== 'knowledge-organize');
7568
+ const keep = painted.filter((r) => r && (r.type === 'knowledge-organize' || (r.desktopHandoffs && r.desktopHandoffs.claim)));
7569
+ const drop = painted.filter((r) => r && r.type !== 'knowledge-organize' && !(r.desktopHandoffs && r.desktopHandoffs.claim));
7525
7570
  return { atomic: !filterActive && !keep.length && painted.length === all.length, keep, drop };
7526
7571
  }
7527
7572
 
@@ -7617,19 +7662,20 @@
7617
7662
  // and stranding the organize lock until its stale timeout. Show why it can't be cleared instead.
7618
7663
  const run = r.run || null;
7619
7664
  const inFlight = !!run && (run.state === 'queued' || run.state === 'running');
7665
+ const desktopClaimed = !!(r.desktopHandoffs && r.desktopHandoffs.claim);
7620
7666
  const lifecycleOwned = r.type === 'knowledge-organize';
7621
7667
  // ✕ goes away while a run is live, for the same reason it goes away on a knowledge-organize:
7622
7668
  // deleting the request out from under a working agent leaves it unable to clear its own work,
7623
7669
  // and the run then lands in `exited-unresolved` for a reason the user caused and cannot see.
7624
7670
  const del = lifecycleOwned
7625
7671
  ? '<span class="req-lifecycle" data-tip="This clears itself when your terminal AI finishes or fails the organize">finishing in your terminal</span>'
7626
- : inFlight
7672
+ : inFlight || desktopClaimed
7627
7673
  ? '<span class="req-lifecycle" data-tip="Stop the run first — clearing it now would leave the agent working on a request that no longer exists">running</span>'
7628
7674
  : `<button class="req-del" data-id="${escapeAttr(r.id)}" data-tip="${r.resumeCommand ? 'Clear this request and discard its saved terminal session' : 'Clear this request'}">×</button>`;
7629
7675
  // A server-stamped handoff gets NO re-run. The original terminal session may already be live;
7630
7676
  // starting a second headless agent would put two writers in one folder. The browser decides no
7631
7677
  // policy here: it simply withholds ▶ whenever the server supplied the resume command.
7632
- const canRunNow = headlessReady() && r.canRun && !inFlight && !r.resumeCommand;
7678
+ const canRunNow = headlessReady() && r.canRun && !inFlight && !r.desktopHandoffs && !r.resumeCommand;
7633
7679
  const runBtn = inFlight
7634
7680
  ? `<button class="req-stop" data-id="${escapeAttr(r.id)}" data-tip="Stop this run">■</button>`
7635
7681
  : canRunNow
@@ -7641,12 +7687,12 @@
7641
7687
  <div class="req-head"><span class="${badgeCls}">${label}</span> ${owner ? `<span class="req-owner">${highlightQuery(owner, requestQuery)}</span>` : ''}${time}</div>
7642
7688
  <div class="req-instruction">${highlightQuery(instructionFor(r), requestQuery) || 'This request has no instruction, so it can’t be handed to your terminal AI. Clear it and queue it again.'}</div>
7643
7689
  ${r.snapshots && r.snapshots.length ? `<div class="req-thumbs">${r.snapshots.map((sp, i) => { const pdf = /\.pdf$/i.test(String(sp)); return `<button type="button" class="req-thumb" data-id="${escapeAttr(r.id)}" data-n="${i}" aria-label="View ${pdf ? 'PDF' : 'screenshot'} ${i + 1}">${pdf ? '<span class="req-thumb-pdf">PDF</span>' : `<img src="/api/requests/${encodeURIComponent(r.id)}/snapshot/${i}" alt="">`}</button>`; }).join('')}</div>` : ''}
7644
- ${runStatusHtml(run, r.resumeCommand)}
7690
+ ${runStatusHtml(run, r.resumeCommand, r.desktopHandoffs, r.id)}
7645
7691
  ${!r.canRun && r.runWhy && anyRunnable ? `<div class="req-why-not">Runs only from your terminal — ${escapeHtml(r.runWhy)}</div>` : ''}
7646
7692
  </div>
7647
7693
  <div class="req-actions">
7648
7694
  ${runBtn}
7649
- ${r.resumeCommand ? '' : `<button class="req-copy" data-id="${escapeAttr(r.id)}" data-tip="Copy this instruction">⧉</button>`}
7695
+ ${r.desktopHandoffs || r.resumeCommand ? '' : `<button class="req-copy" data-id="${escapeAttr(r.id)}" data-tip="Copy this instruction">⧉</button>`}
7650
7696
  ${del}
7651
7697
  </div>
7652
7698
  </div>`;
@@ -7680,6 +7726,76 @@
7680
7726
  else showToast('Could not copy — select the command and copy it manually', 'err');
7681
7727
  };
7682
7728
  });
7729
+ $list.querySelectorAll('.req-app-handoff').forEach((button) => {
7730
+ button.onclick = async () => {
7731
+ const requestId = button.dataset.id || '';
7732
+ const attemptId = button.dataset.attemptId || '';
7733
+ const provider = button.dataset.provider === 'claude' ? 'claude' : 'codex';
7734
+ const label = provider === 'claude' ? 'Claude' : 'Codex';
7735
+ const choice = await confirmUnsavedSwitch(
7736
+ '',
7737
+ `FloLess will open this request and its project folder in ${label}.`,
7738
+ `Open ${label} Desktop?`,
7739
+ { confirm: `Open ${label}`, hideDiscard: true, initialFocus: 'cancel' },
7740
+ );
7741
+ if (choice !== 'save') return;
7742
+ const exactButton = Array.from($list.querySelectorAll('.req-app-handoff')).find((candidate) =>
7743
+ candidate.dataset.id === requestId
7744
+ && candidate.dataset.attemptId === attemptId
7745
+ && candidate.dataset.provider === provider);
7746
+ if (!exactButton) { await loadRequests(); renderRequests(); return; }
7747
+ const card = exactButton.closest('.req-run-status');
7748
+ const status = card && card.querySelector('.req-app-launch-status');
7749
+ const copy = card && card.querySelector('.req-app-copy');
7750
+ const controls = card ? Array.from(card.querySelectorAll('.req-app-handoff')) : [];
7751
+ controls.forEach((control) => { control.disabled = true; });
7752
+ if (status) status.textContent = `Starting ${label} Desktop…`;
7753
+ if (copy) copy.dataset.handoffPrompt = exactButton.dataset.handoffPrompt || '';
7754
+ try {
7755
+ await api(`/api/requests/${encodeURIComponent(requestId)}/desktop-handoff/launch`, {
7756
+ method: 'POST', body: JSON.stringify({ provider, attemptId }),
7757
+ });
7758
+ const stillCurrent = Array.from($list.querySelectorAll('.req-app-handoff')).some((candidate) =>
7759
+ candidate.dataset.id === requestId
7760
+ && candidate.dataset.attemptId === attemptId
7761
+ && candidate.dataset.provider === provider);
7762
+ if (stillCurrent && status) status.textContent = `Windows was asked to open ${label} Desktop.`;
7763
+ } catch (error) {
7764
+ if (/no longer available|already requested/i.test(String(error && error.message))) {
7765
+ await loadRequests(); renderRequests();
7766
+ } else if (status) {
7767
+ status.textContent = `${label} couldn’t be started.`;
7768
+ }
7769
+ } finally {
7770
+ controls.forEach((control) => { if (control.isConnected) control.disabled = false; });
7771
+ }
7772
+ };
7773
+ });
7774
+ $list.querySelectorAll('.req-app-copy').forEach((b) => {
7775
+ b.onclick = async () => {
7776
+ const result = await copyToClipboard(b.dataset.handoffPrompt || '');
7777
+ showToast(result ? 'Handoff copied — paste it into a desktop app or terminal AI' : 'Could not copy the handoff', result ? 'ok' : 'err');
7778
+ };
7779
+ });
7780
+ $list.querySelectorAll('.req-app-release').forEach((b) => {
7781
+ b.onclick = async () => {
7782
+ const choice = await confirmUnsavedSwitch(
7783
+ '',
7784
+ 'The first desktop app may still be working. Stop it there before releasing this claim.',
7785
+ 'Release desktop recovery?',
7786
+ { confirm: 'Release and choose another app', hideDiscard: true, initialFocus: 'cancel' },
7787
+ );
7788
+ if (choice !== 'save') return;
7789
+ try {
7790
+ await api(`/api/requests/${encodeURIComponent(b.dataset.id)}/desktop-handoff`, {
7791
+ method: 'DELETE',
7792
+ body: JSON.stringify({ attemptId: b.dataset.attemptId, claimId: b.dataset.claimId }),
7793
+ });
7794
+ await loadRequests();
7795
+ renderRequests();
7796
+ } catch (e) { reportErr(e); }
7797
+ };
7798
+ });
7683
7799
  $list.querySelectorAll('.req-del').forEach((b) => { b.onclick = () => deleteOneRequest(b.dataset.id); });
7684
7800
  $list.querySelectorAll('.req-thumb').forEach((b) => {
7685
7801
  b.onclick = () => window.open(`/api/requests/${encodeURIComponent(b.dataset.id)}/snapshot/${b.dataset.n}`, '_blank');
@@ -679,7 +679,8 @@
679
679
 
680
680
  <!-- Save-on-switch confirmation — shown when switching workflows with unsaved
681
681
  input changes. Reuses the shared modal styling; no new backdrop look. -->
682
- <div class="modal-backdrop" id="confirm-modal">
682
+ <div class="modal-backdrop" id="confirm-modal" role="dialog" aria-modal="true"
683
+ aria-labelledby="confirm-modal-title" aria-describedby="confirm-modal-sub">
683
684
  <div class="modal">
684
685
  <div class="modal-title" id="confirm-modal-title">Unsaved input changes</div>
685
686
  <div class="modal-sub" id="confirm-modal-sub"></div>
@@ -72,6 +72,7 @@ const groupHidden = new Set(); // profile keys hidden via the legen
72
72
  let soloGroups = new Set(); // profile keys isolated via the legend (dbl-click; Ctrl/Shift add to the set)
73
73
  let isolatedIds = null; // Tekla "isolate selected": Set of ids shown exclusively, or null for off
74
74
  let connHidden = new Set(); // explicit per-PART hide (legend connection rows) — lets a shared part-kind (weld/nut) hide per-connection by id, not per group
75
+ let selectionHidden = new Set(); // session-only per-mesh hide from the toolbar's Hide selected action; raw renderer ids never enter the tagged saved-view contract
75
76
  let cube = null; // ViewCube { renderer, scene, cam, mesh, faces }
76
77
  let triad = null; // world-axis triad { renderer, scene, cam, group } — passive X/Y/Z readout
77
78
  const DRAG_TOL_PX = 4; // movement past this = a drag (not a click)
@@ -888,8 +889,11 @@ function buildFromScene(sc) {
888
889
  buildRefLines();
889
890
  syncMemberLabels(); // refresh the member-label pool from the (possibly edited) member set
890
891
  syncPropLabels(); // re-anchor the property labels too (member geometry may have moved)
891
- if (isolatedIds) { isolatedIds = new Set([...isolatedIds].filter((id) => meshById.has(id))); if (!isolatedIds.size) { isolatedIds = null; if (api && api.onIsolateChange) api.onIsolateChange(false); } } // drop ids an edit removed; if none survive, exit isolation + refresh the host's Show-all button
892
+ const hadVisibilityFilter = hasVisibilityFilter();
893
+ if (isolatedIds) { isolatedIds = new Set([...isolatedIds].filter((id) => meshById.has(id))); if (!isolatedIds.size) isolatedIds = null; } // drop ids an edit removed; if none survive, exit isolation
892
894
  if (connHidden.size) connHidden = new Set([...connHidden].filter((id) => meshById.has(id))); // drop per-part hides whose mesh an edit removed
895
+ if (selectionHidden.size) selectionHidden = new Set([...selectionHidden].filter((id) => meshById.has(id))); // drop transient hides whose mesh an edit removed
896
+ if (hadVisibilityFilter !== hasVisibilityFilter()) notifyVisibilityChange(); // keep the host's recovery control honest when an edit removes the last hidden/isolated mesh
893
897
  applyGroupVisibility(); applyDisplayMode();
894
898
  built = true;
895
899
  if (fitPending) { fitCamera(box); fitPending = false; } // fit only on entering 3D (rebuild(true)) — NOT on every edit
@@ -2439,7 +2443,7 @@ function visibleIgnoringWorkArea(m) {
2439
2443
  const k = m.userData && m.userData.group;
2440
2444
  const byGroup = !groupHidden.has(k) && (soloGroups.size === 0 || soloGroups.has(k));
2441
2445
  const byIso = isolatedIds === null || isolatedIds.has(m.userData.id); // isolate-selected: only the isolated ids show
2442
- return byGroup && byIso && !connHidden.has(m.userData.id);
2446
+ return byGroup && byIso && !connHidden.has(m.userData.id) && !selectionHidden.has(m.userData.id);
2443
2447
  }
2444
2448
  function applyGroupVisibility() {
2445
2449
  for (const m of meshById.values()) m.visible = visibleIgnoringWorkArea(m) && meshInWorkArea(m); // meshInWorkArea: work-area whole-parts spatial filter
@@ -2449,17 +2453,18 @@ function visibleMemberIds() {
2449
2453
  for (const [id, m] of meshById) if (m.visible && !m.userData.derived) out.push(id);
2450
2454
  return out;
2451
2455
  }
2452
- function toggleGroup(k) { if (groupHidden.has(k)) groupHidden.delete(k); else groupHidden.add(k); soloGroups.clear(); applyGroupVisibility(); rebuildEndpoints(); refreshOverlayDims(); refreshDims(); }
2456
+ function notifyVisibilityChange() { if (api && api.onIsolateChange) api.onIsolateChange(isolatedIds !== null); }
2457
+ function toggleGroup(k) { if (groupHidden.has(k)) groupHidden.delete(k); else groupHidden.add(k); soloGroups.clear(); applyGroupVisibility(); rebuildEndpoints(); refreshOverlayDims(); refreshDims(); notifyVisibilityChange(); }
2453
2458
  // Hide/show a SET of groups in one pass (a legend type-category master toggle) — deterministic (not a flip),
2454
2459
  // so "hide all" / "show all" for the category is exact. Clears solo, like toggleGroup.
2455
- function setGroupsHidden(keys, hidden) { for (const k of (keys || [])) { if (hidden) groupHidden.add(k); else groupHidden.delete(k); } soloGroups.clear(); applyGroupVisibility(); rebuildEndpoints(); refreshOverlayDims(); refreshDims(); }
2460
+ function setGroupsHidden(keys, hidden) { const target = new Set(keys || []); for (const k of target) { if (hidden) groupHidden.add(k); else groupHidden.delete(k); } if (!hidden && selectionHidden.size) selectionHidden = new Set([...selectionHidden].filter((id) => { const m = meshById.get(id); return !m || !target.has(m.userData && m.userData.group); })); soloGroups.clear(); applyGroupVisibility(); rebuildEndpoints(); refreshOverlayDims(); refreshDims(); notifyVisibilityChange(); }
2456
2461
  // Hide/show specific PART ids (a legend connection row / connection master). Per-id so a connection's own
2457
2462
  // nuts/welds toggle independently of the other connection's (the part-kind group is shared across joints).
2458
- function setIdsHidden(ids, hidden) { for (const id of (ids || [])) { if (hidden) connHidden.add(id); else connHidden.delete(id); } applyGroupVisibility(); rebuildEndpoints(); refreshOverlayDims(); refreshDims(); }
2463
+ function setIdsHidden(ids, hidden) { for (const id of (ids || [])) { if (hidden) connHidden.add(id); else { connHidden.delete(id); selectionHidden.delete(id); } } applyGroupVisibility(); rebuildEndpoints(); refreshOverlayDims(); refreshDims(); notifyVisibilityChange(); }
2459
2464
  // Isolate an explicit SET of profile groups (the editor's legend builds it from Ctrl/Shift dbl-clicks, Explorer-style).
2460
- function setSoloGroups(keys) { soloGroups = new Set((keys || []).filter((k) => k != null)); if (soloGroups.size) groupHidden.clear(); applyGroupVisibility(); rebuildEndpoints(); refreshOverlayDims(); refreshDims(); }
2465
+ function setSoloGroups(keys) { soloGroups = new Set((keys || []).filter((k) => k != null)); if (soloGroups.size) groupHidden.clear(); applyGroupVisibility(); rebuildEndpoints(); refreshOverlayDims(); refreshDims(); notifyVisibilityChange(); }
2461
2466
  function soloToggle(k) { setSoloGroups(soloGroups.size === 1 && soloGroups.has(k) ? [] : [k]); } // plain dbl-click: isolate just this group (or clear if it's already the only one)
2462
- function showAllGroups() { groupHidden.clear(); soloGroups.clear(); isolatedIds = null; connHidden.clear(); applyGroupVisibility(); rebuildEndpoints(); refreshOverlayDims(); refreshDims(); if (api && api.onIsolateChange) api.onIsolateChange(false); }
2467
+ function showAllGroups() { groupHidden.clear(); soloGroups.clear(); isolatedIds = null; connHidden.clear(); selectionHidden.clear(); applyGroupVisibility(); rebuildEndpoints(); refreshOverlayDims(); refreshDims(); updateStatusChip(); notifyVisibilityChange(); }
2463
2468
  function groupState() { return { hidden: [...groupHidden], solo: [...soloGroups] }; }
2464
2469
  // One serialisable snapshot of the objects-list pane's PERSISTENT visibility state — group hide/solo +
2465
2470
  // isolate-selected + per-part legend hides. This is what a saved view (Views Organizer) captures; it
@@ -2475,14 +2480,19 @@ function applyObjectsPaneState(s) {
2475
2480
  soloGroups = new Set(Array.isArray(s.solo) ? s.solo : []);
2476
2481
  isolatedIds = (Array.isArray(s.isolated) && s.isolated.length) ? new Set(s.isolated) : null;
2477
2482
  connHidden = new Set(Array.isArray(s.connHidden) ? s.connHidden : []);
2483
+ selectionHidden.clear(); // Hide selected is session-only; applying a saved view restores its authored persistent visibility without leaking the current session filter
2478
2484
  applyGroupVisibility(); rebuildEndpoints(); refreshOverlayDims(); refreshDims();
2479
- if (api && api.onIsolateChange) api.onIsolateChange(isolatedIds !== null);
2485
+ notifyVisibilityChange();
2480
2486
  }
2481
2487
  // Tekla "isolate selected": show ONLY the currently-selected parts (a snapshot taken now — distinct from
2482
2488
  // soloToggle, which isolates a whole PROFILE group from the legend). clearIsolation / showAllGroups restore all.
2483
- function isolateSelected() { if (!selIds.size) return false; isolatedIds = new Set(selIds); applyGroupVisibility(); rebuildEndpoints(); refreshOverlayDims(); refreshDims(); updateStatusChip(); if (api && api.onIsolateChange) api.onIsolateChange(true); return true; }
2484
- function clearIsolation() { if (isolatedIds === null) return; isolatedIds = null; applyGroupVisibility(); rebuildEndpoints(); refreshOverlayDims(); refreshDims(); updateStatusChip(); if (api && api.onIsolateChange) api.onIsolateChange(false); }
2489
+ function isolateSelected() { if (!selIds.size) return false; isolatedIds = new Set(selIds); applyGroupVisibility(); rebuildEndpoints(); refreshOverlayDims(); refreshDims(); updateStatusChip(); notifyVisibilityChange(); return true; }
2490
+ // Hide the current selection by explicit mesh id. This remains session-only because v2 saved views require tagged
2491
+ // SceneRefs while the renderer owns raw ids; broadening that contract is a separate migration, not toolbar state.
2492
+ function hideSelected() { const ids = [...selIds].filter((id) => meshById.has(id)); if (!ids.length) return 0; for (const id of ids) selectionHidden.add(id); applyGroupVisibility(); rebuildEndpoints(); refreshOverlayDims(); refreshDims(); updateStatusChip(); notifyVisibilityChange(); return ids.length; }
2493
+ function clearIsolation() { if (isolatedIds === null) return; isolatedIds = null; applyGroupVisibility(); rebuildEndpoints(); refreshOverlayDims(); refreshDims(); updateStatusChip(); notifyVisibilityChange(); }
2485
2494
  function isIsolated() { return isolatedIds !== null; }
2495
+ function hasVisibilityFilter() { return isolatedIds !== null || groupHidden.size > 0 || soloGroups.size > 0 || connHidden.size > 0 || selectionHidden.size > 0; }
2486
2496
  function getGroups() { return sceneGroups.map((g) => ({ ...g })); }
2487
2497
 
2488
2498
  // ---- clip planes / clip boxes (Tekla-style sectioning) ----
@@ -5616,6 +5626,7 @@ function updateStatusChip() {
5616
5626
  else if (showId) { const m = memberById(showId); txt = m ? `${m.id} · ${m.profile || '—'}` : ''; }
5617
5627
  else if (selIds.size > 1) txt = `${selIds.size} members selected`;
5618
5628
  else if (isolatedIds) txt = `Isolated: ${isolatedIds.size} · Show all to restore`;
5629
+ else if (selectionHidden.size) txt = `${selectionHidden.size} objects hidden · Show all to restore`;
5619
5630
  // A read-only host (the vector 3D viewer) supplies its own idle hint — the default speaks editing
5620
5631
  // verbs (move/stretch/elevate) a viewer's no-op api would silently ignore. Otherwise the default
5621
5632
  // tells the truth about the drag-move/copy toggle (ON = drag-move + Ctrl-drag-copy; OFF = click-select).
@@ -5741,7 +5752,7 @@ function debug() {
5741
5752
  // the pixels valid. Exists so a MATERIAL change can be checked by looking at it, not only by
5742
5753
  // asserting on state — the whole point of Realistic is how it looks.
5743
5754
  snapshot: (quality = 0.82) => { renderer.render(scene, camera); return canvasEl.toDataURL('image/jpeg', quality); },
5744
- hidden: [...groupHidden], solo: [...soloGroups], isolated: isolatedIds ? [...isolatedIds] : null, visible: [...meshById.values()].filter((m) => m.visible).length,
5755
+ hidden: [...groupHidden], solo: [...soloGroups], isolated: isolatedIds ? [...isolatedIds] : null, selectionHidden: [...selectionHidden], visible: [...meshById.values()].filter((m) => m.visible).length,
5745
5756
  endpoints: epGroup ? epGroup.children.length : 0,
5746
5757
  endpointColors: epGroup ? epGroup.children.map((c) => '#' + c.material.color.getHexString()) : [],
5747
5758
  hoverId, hoverGlowIds: [...hoverGlowIds], hoverEp, dragEp, refLine: refLineOn, // hoverGlowIds = the group the hover glow is computed over (whole connection at root, one part once drilled) — hoverId alone can't show that grouping. Selection still beats hover, so a selected id in this set glows brand blue, not sky
@@ -5880,9 +5891,9 @@ window.Steel3DView = {
5880
5891
  if (!wpGroup) return { group: false, extent: wpExtent };
5881
5892
  return { group: true, extent: wpExtent, children: wpGroup.children.map((c) => ({ type: c.type, color: c.material && '#' + c.material.color.getHexString(), opacity: c.material && c.material.opacity, w: c.geometry && c.geometry.parameters ? c.geometry.parameters.width : null, h: c.geometry && c.geometry.parameters ? c.geometry.parameters.height : null })) };
5882
5893
  },
5883
- toggleGroup, setGroupsHidden, setIdsHidden, connHiddenIds: () => [...connHidden], soloToggle, setSoloGroups, showAllGroups, groupState, getGroups, visibleMemberIds,
5894
+ toggleGroup, setGroupsHidden, setIdsHidden, connHiddenIds: () => [...connHidden], selectionHiddenIds: () => [...selectionHidden], soloToggle, setSoloGroups, showAllGroups, groupState, getGroups, visibleMemberIds,
5884
5895
  setClipMode, clipMode: clipModeOn, addClipBox, toggleClip, removeClip, clearClips, getClips, renameClip, selectClip, setSelectedClips, selectedClips, deleteSelectedClips, clipState, setClipState,
5885
- isolateSelected, clearIsolation, isIsolated,
5896
+ isolateSelected, hideSelected, clearIsolation, isIsolated, hasVisibilityFilter,
5886
5897
  cameraState, setCameraState, sectionViewState, sceneBounds, objectsPaneState, applyObjectsPaneState, // saved-view snapshot surface (Views Organizer + F11 generated cuts)
5887
5898
  workAreaSetAll, workAreaFromSelection, workAreaToggle, workAreaSetWhole, clearWorkArea, workAreaState,
5888
5899
  armWorkPlanePick, setWorkPlanePrincipal, clearWorkPlane, toggleWorkPlaneVisible, workPlaneInfo,