@floless/app 0.84.0 → 0.86.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/floless-server.cjs +2180 -791
- package/dist/schemas/steel.takeoff.v1.schema.json +34 -4
- package/dist/skills/floless-app-knowledge/SKILL.md +206 -0
- package/dist/skills/floless-app-knowledge/references/schema.md +132 -0
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +380 -28
- package/dist/skills/floless-app-workflows/SKILL.md +33 -7
- package/dist/skills/floless-app-workflows/references/dev-server-and-run-trace.md +2 -1
- package/dist/skills/floless-app-workflows/references/exec-contract.md +1 -1
- package/dist/skills/floless-app-workflows/references/workspace-data.md +111 -0
- package/dist/skills/reading-structural-drawings/SKILL.md +102 -1
- package/dist/skills/steel-drawing-abbreviations/SKILL.md +33 -1
- package/dist/templates/floless-workspace-read.flo +161 -0
- package/dist/templates/steel-model.flo +6 -0
- package/dist/templates/vectorize.flo +6 -0
- package/dist/web/analytics.js +31 -0
- package/dist/web/app.css +330 -15
- package/dist/web/aware.js +488 -54
- package/dist/web/grid-core.js +40 -6
- package/dist/web/index.html +60 -11
- package/dist/web/steel-3d-view.js +117 -20
- package/dist/web/steel-editor.html +1424 -294
- package/dist/web/steel-filter.html +3 -1
- package/dist/web/vector-3d.html +3 -3
- package/dist/web/vector-editor.html +41 -12
- package/dist/web/workspaces.js +1307 -78
- package/package.json +1 -1
package/dist/web/aware.js
CHANGED
|
@@ -575,7 +575,66 @@
|
|
|
575
575
|
// The beacon pulses while a workflow is new to the user.
|
|
576
576
|
function beaconIsNew(id) { const g = guideFor(id); return !g.firstRunDone && !g.dismissed; }
|
|
577
577
|
|
|
578
|
+
// ── Workspaces variant of the SAME beacon ───────────────────────────────────
|
|
579
|
+
// Workspaces is the DOCUMENT archetype (drop → review → approve → export), not the
|
|
580
|
+
// pipeline archetype (inputs → compile → run). One beacon element, two content
|
|
581
|
+
// sources: in Workspaces mode with a project open, this layer drives #guide-beacon +
|
|
582
|
+
// #guide-modal instead of the workflow layer. It REUSES the LS_GUIDE store and its
|
|
583
|
+
// get/set helpers — no parallel system — but keys its record under `ws:<app>` so a
|
|
584
|
+
// Workflows Run of an app (firstRunDone) never calms its Workspaces beacon and vice
|
|
585
|
+
// versa (vectorize is BOTH a pipeline app and a workspace app). "New" here calms on the
|
|
586
|
+
// first Approve for the app, mirroring how the workflow beacon calms on the first Run.
|
|
587
|
+
// workspaces.js owns the project state, so it hands us a small snapshot (app id + which
|
|
588
|
+
// lifecycle signals are true) via flolessBridge; we own the chrome, glyphs, and copy.
|
|
589
|
+
let wsGuideCtx = null; // { app, name, displayName, approved, exported } | null (name = the open project's name)
|
|
590
|
+
const wsGuideKey = (app) => `ws:${app}`;
|
|
591
|
+
const inWorkspacesMode = () => { const a = document.getElementById('app'); return !!(a && a.classList.contains('mode-workspaces')); };
|
|
592
|
+
// The Workspaces beacon is active only in Workspaces mode with a project open (a ctx set).
|
|
593
|
+
const wsGuideActive = () => inWorkspacesMode() && !!wsGuideCtx;
|
|
594
|
+
function wsBeaconIsNew(app) { const g = guideFor(wsGuideKey(app)); return !g.approveDone && !g.dismissed; }
|
|
595
|
+
|
|
596
|
+
// The document-lifecycle checklist. Approve/Export carry an honest boolean from project
|
|
597
|
+
// state; "Review" borrows Approve's boolean (you can't sign off without having looked —
|
|
598
|
+
// Approve sits next to the editor), never a faked "opened the tab" signal; "Drop" is
|
|
599
|
+
// done whenever the guide is open (a project only exists after a drawing was dropped —
|
|
600
|
+
// a cancelled/failed drop is rolled back, never left as an empty project). The current
|
|
601
|
+
// step = the first not-done row, so the arrow lands on the next real action.
|
|
602
|
+
function workspaceGuideSteps(ctx) {
|
|
603
|
+
return [
|
|
604
|
+
{ label: 'Drop a drawing', note: 'PDF or image — traced linework comes out editable', done: true },
|
|
605
|
+
{ label: 'Review the traced lines', note: 'check layers, isolate low-confidence traces', done: !!ctx.approved },
|
|
606
|
+
{ label: 'Approve', note: 'signs off this version, unlocks Export', done: !!ctx.approved },
|
|
607
|
+
{ label: 'Export SVG', note: 'clean SVG linework, take it anywhere', done: !!ctx.exported },
|
|
608
|
+
];
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
// Paint #guide-beacon for the open workspace project (called by paintBeacon when in
|
|
612
|
+
// Workspaces mode). Same glyphs/label/pulse dialect as the workflow beacon; names the
|
|
613
|
+
// open PROJECT (not the app id), matching the crumb/picker.
|
|
614
|
+
function paintWorkspaceBeacon() {
|
|
615
|
+
const $b = document.getElementById('guide-beacon');
|
|
616
|
+
if (!$b) return;
|
|
617
|
+
const ctx = wsGuideCtx;
|
|
618
|
+
if (!ctx) { $b.hidden = true; $b.classList.remove('is-new', 'spotlit'); return; }
|
|
619
|
+
const isNew = wsBeaconIsNew(ctx.app);
|
|
620
|
+
$b.hidden = false;
|
|
621
|
+
$b.classList.remove('spotlit');
|
|
622
|
+
$b.classList.toggle('is-new', isNew);
|
|
623
|
+
const ico = $b.querySelector('.guide-beacon-ico');
|
|
624
|
+
const label = $b.querySelector('.guide-beacon-label');
|
|
625
|
+
if (ico) ico.textContent = isNew ? '✦' : '?';
|
|
626
|
+
if (label) label.textContent = isNew ? 'Start here' : 'Guide';
|
|
627
|
+
// No "workflow"/"Run" vocabulary — this is a document project.
|
|
628
|
+
$b.dataset.tip = isNew
|
|
629
|
+
? 'New here? See what this project does and how to take it from drawing to export.'
|
|
630
|
+
: 'Open the guide for this project.';
|
|
631
|
+
$b.setAttribute('aria-label', (isNew ? 'Start here — guide for ' : 'Guide for ') + (ctx.name || ctx.displayName || ctx.app));
|
|
632
|
+
}
|
|
633
|
+
|
|
578
634
|
function paintBeacon(app) {
|
|
635
|
+
// In Workspaces mode the beacon belongs to the open project, not the last-loaded
|
|
636
|
+
// workflow — hand off to the workspace layer (which hides it when no project is open).
|
|
637
|
+
if (inWorkspacesMode()) { paintWorkspaceBeacon(); return; }
|
|
579
638
|
const $b = document.getElementById('guide-beacon');
|
|
580
639
|
if (!$b) return;
|
|
581
640
|
if (!app) { $b.hidden = true; $b.classList.remove('is-new', 'spotlit'); return; }
|
|
@@ -624,30 +683,66 @@
|
|
|
624
683
|
return steps;
|
|
625
684
|
}
|
|
626
685
|
|
|
686
|
+
// Shared checklist renderer — shape carries state (✓ done · → current · ☐ to-do), never
|
|
687
|
+
// colour alone. The current step is the first not-done row. Labels/notes are authored
|
|
688
|
+
// constants but still pass escapeHtml (defence-in-depth; the security hook forbids raw
|
|
689
|
+
// string→DOM). Both the workflow and workspace guides render through this.
|
|
690
|
+
function guideStepsHtml(steps) {
|
|
691
|
+
const curIdx = steps.findIndex((s) => !s.done);
|
|
692
|
+
return `<ol class="guide-steps" role="list">${steps.map((s, i) => {
|
|
693
|
+
const state = s.done ? 'done' : i === curIdx ? 'current' : 'todo';
|
|
694
|
+
const box = s.done ? '✓' : i === curIdx ? '→' : '☐';
|
|
695
|
+
const cur = i === curIdx ? ' aria-current="step"' : '';
|
|
696
|
+
return `<li class="guide-step ${state}"${cur}><span class="guide-box" aria-hidden="true">${box}</span>` +
|
|
697
|
+
`<span class="guide-step-text"><span class="guide-step-label">${escapeHtml(s.label)}</span> ` +
|
|
698
|
+
`<span class="guide-step-note">— ${escapeHtml(s.note)}</span></span>` +
|
|
699
|
+
`<span class="sr-only">${s.done ? '(done)' : i === curIdx ? '(next step)' : '(to do)'}</span></li>`;
|
|
700
|
+
}).join('')}</ol>`;
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
// The Workspaces guide body — the document life-cycle, not node mechanics. No
|
|
704
|
+
// "Compile"/"Run"/"Save" language (those pipeline verbs are absent here; the verb is
|
|
705
|
+
// Approve). "Walk me through it" is a Workflows relay (terminal AI + the workflow's own
|
|
706
|
+
// skill), so it's hidden for a workspace — the beacon is a self-contained checklist here.
|
|
707
|
+
// The title is the open project's user-authored name → set via textContent only (never
|
|
708
|
+
// into innerHTML); the body innerHTML is authored constants + escaped step labels/notes.
|
|
709
|
+
function renderWorkspaceGuide() {
|
|
710
|
+
const ctx = wsGuideCtx;
|
|
711
|
+
const $body = document.getElementById('guide-body');
|
|
712
|
+
const $title = document.getElementById('guide-title');
|
|
713
|
+
const $eyebrow = document.getElementById('guide-eyebrow');
|
|
714
|
+
const $sub = document.querySelector('#guide-modal .modal-sub');
|
|
715
|
+
if (!ctx || !$body) return;
|
|
716
|
+
if ($title) $title.textContent = ctx.name || ctx.displayName || ctx.app;
|
|
717
|
+
if ($eyebrow) $eyebrow.textContent = wsBeaconIsNew(ctx.app) ? '✦ Start here' : '✦ Project guide';
|
|
718
|
+
if ($sub) $sub.textContent = 'What this project does, and how to take it from drawing to export.';
|
|
719
|
+
const descHtml = `<div class="guide-desc"><p>Drop in a drawing — a PDF, scan, or photo — and it comes back as clean, editable traced linework. Anything the trace wasn’t sure about gets flagged for you to check before you approve and export.</p></div>`;
|
|
720
|
+
const stepsHtml = guideStepsHtml(workspaceGuideSteps(ctx));
|
|
721
|
+
$body.innerHTML =
|
|
722
|
+
`<div class="guide-section-label">What this does</div>` + descHtml +
|
|
723
|
+
`<div class="guide-section-label">How to go through it</div>` + stepsHtml;
|
|
724
|
+
}
|
|
725
|
+
|
|
627
726
|
function renderGuide() {
|
|
727
|
+
// In Workspaces mode with a project open, the guide describes the document life-cycle.
|
|
728
|
+
if (wsGuideActive()) { renderWorkspaceGuide(); return; }
|
|
628
729
|
const app = currentId && apps.get(currentId);
|
|
629
730
|
const $body = document.getElementById('guide-body');
|
|
630
731
|
const $title = document.getElementById('guide-title');
|
|
631
732
|
const $eyebrow = document.getElementById('guide-eyebrow');
|
|
733
|
+
const $sub = document.querySelector('#guide-modal .modal-sub');
|
|
632
734
|
if (!app || !$body) return;
|
|
633
735
|
if ($title) $title.textContent = app.displayName || app.id;
|
|
634
736
|
if ($eyebrow) $eyebrow.textContent = beaconIsNew(app.id) ? '✦ Start here' : '✦ Workflow guide';
|
|
737
|
+
// Restore the workflow sub in case a prior Workspaces open overwrote it.
|
|
738
|
+
if ($sub) $sub.textContent = 'What this workflow does, and how to go through it.';
|
|
635
739
|
const desc = (app.description || '').trim();
|
|
636
740
|
const descHtml = desc
|
|
637
741
|
? `<div class="guide-desc">${desc.split(/\n{2,}/).map((p) => `<p>${mdInline(escapeHtml(p.trim()))}</p>`).join('')}</div>`
|
|
638
742
|
: `<div class="guide-desc guide-desc-empty"><p>A ${app.nodes.length}-step workflow. Set its inputs, Compile to freeze the approved lock, then Run it against your live host.</p></div>`;
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
const stepsHtml =
|
|
642
|
-
const state = s.done ? 'done' : i === curIdx ? 'current' : 'todo';
|
|
643
|
-
// Shape carries state, not colour alone: ✓ done · → current · ☐ to-do.
|
|
644
|
-
const box = s.done ? '✓' : i === curIdx ? '→' : '☐';
|
|
645
|
-
const cur = i === curIdx ? ' aria-current="step"' : '';
|
|
646
|
-
return `<li class="guide-step ${state}"${cur}><span class="guide-box" aria-hidden="true">${box}</span>` +
|
|
647
|
-
`<span class="guide-step-text"><span class="guide-step-label">${escapeHtml(s.label)}</span> ` +
|
|
648
|
-
`<span class="guide-step-note">— ${escapeHtml(s.note)}</span></span>` +
|
|
649
|
-
`<span class="sr-only">${s.done ? '(done)' : i === curIdx ? '(next step)' : '(to do)'}</span></li>`;
|
|
650
|
-
}).join('')}</ol>`;
|
|
743
|
+
// Static authored strings + escapeHtml on every dynamic value (app.description, step
|
|
744
|
+
// label/note) — no raw user string reaches the DOM (the established guide pattern).
|
|
745
|
+
const stepsHtml = guideStepsHtml(guideSteps(app));
|
|
651
746
|
const walkHint = `<div class="guide-walk-hint">A bigger workflow? <strong>Walk me through it</strong> hands off to your terminal AI for a step-by-step tour using this workflow's own skill.</div>`;
|
|
652
747
|
$body.innerHTML =
|
|
653
748
|
`<div class="guide-section-label">What this does</div>` + descHtml +
|
|
@@ -655,9 +750,15 @@
|
|
|
655
750
|
}
|
|
656
751
|
|
|
657
752
|
function openGuide() {
|
|
658
|
-
|
|
753
|
+
const ws = wsGuideActive();
|
|
754
|
+
if (!ws && !currentId) { showToast('open a workflow first', 'warn'); return; }
|
|
659
755
|
renderGuide();
|
|
660
756
|
const $m = document.getElementById('guide-modal');
|
|
757
|
+
// "Walk me through it →" relays to the terminal AI using a WORKFLOW's own skill — a
|
|
758
|
+
// pipeline concept with no document-workspace analog. Hide it (never disable — an
|
|
759
|
+
// absent control, not a dead one) for the self-contained workspace guide.
|
|
760
|
+
const $walk = document.getElementById('guide-walk');
|
|
761
|
+
if ($walk) $walk.hidden = ws;
|
|
661
762
|
showModal($m);
|
|
662
763
|
// Focus the dialog shell (not a button) so the checklist is read first; Tab then
|
|
663
764
|
// moves to Got it → Walk me through it. Focus returns to the beacon on close.
|
|
@@ -665,9 +766,13 @@
|
|
|
665
766
|
if (shell) { try { shell.focus(); } catch { /* not focusable */ } }
|
|
666
767
|
}
|
|
667
768
|
// Closing the guide (Got it / backdrop / Esc) marks it seen → the beacon stops
|
|
668
|
-
// pulsing even before a first run (the user has looked; don't nag).
|
|
769
|
+
// pulsing even before a first run/approve (the user has looked; don't nag). In
|
|
770
|
+
// Workspaces mode this marks the project's app workspace-guide key, not the workflow.
|
|
669
771
|
function closeGuide() {
|
|
670
|
-
if (
|
|
772
|
+
if (wsGuideActive()) {
|
|
773
|
+
setGuide(wsGuideKey(wsGuideCtx.app), { dismissed: true });
|
|
774
|
+
paintWorkspaceBeacon();
|
|
775
|
+
} else if (currentId) {
|
|
671
776
|
setGuide(currentId, { dismissed: true });
|
|
672
777
|
const app = apps.get(currentId);
|
|
673
778
|
if (app) paintBeacon(app);
|
|
@@ -1259,13 +1364,18 @@
|
|
|
1259
1364
|
function inputNodeId() {
|
|
1260
1365
|
const app = currentId && apps.get(currentId);
|
|
1261
1366
|
if (!app || !Array.isArray(app.inputs) || !app.inputs.length) return null;
|
|
1367
|
+
// The input node is the first node templating {{ inputs.* }} ANYWHERE in its
|
|
1368
|
+
// config. An exec node carries it under `config.args`, but a REST/agent node
|
|
1369
|
+
// (e.g. floless-workspace/read-approved) carries it in a plain config field,
|
|
1370
|
+
// so scan the whole config recursively — not just args.
|
|
1371
|
+
const usesInput = (v) => {
|
|
1372
|
+
if (typeof v === 'string') return /\{\{\s*inputs\.[A-Za-z0-9._-]+\s*\}\}/.test(v);
|
|
1373
|
+
if (Array.isArray(v)) return v.some(usesInput);
|
|
1374
|
+
if (v && typeof v === 'object') return Object.values(v).some(usesInput);
|
|
1375
|
+
return false;
|
|
1376
|
+
};
|
|
1262
1377
|
for (const n of app.nodes) {
|
|
1263
|
-
|
|
1264
|
-
if (args && typeof args === 'object') {
|
|
1265
|
-
for (const v of Object.values(args)) {
|
|
1266
|
-
if (typeof v === 'string' && /\{\{\s*inputs\.[A-Za-z0-9._-]+\s*\}\}/.test(v)) return n.id;
|
|
1267
|
-
}
|
|
1268
|
-
}
|
|
1378
|
+
if (n.config && usesInput(n.config)) return n.id;
|
|
1269
1379
|
}
|
|
1270
1380
|
return null;
|
|
1271
1381
|
}
|
|
@@ -1555,6 +1665,21 @@
|
|
|
1555
1665
|
}
|
|
1556
1666
|
}
|
|
1557
1667
|
|
|
1668
|
+
// Friendly app label for a workspace project row (steel-model → "Steel model").
|
|
1669
|
+
const APP_LABELS = { 'steel-model': 'Steel model', vectorize: 'Vectorize' };
|
|
1670
|
+
const appLabel = (a) => APP_LABELS[a] || String(a || '').replace(/[-_]+/g, ' ').replace(/\b\w/g, (c) => c.toUpperCase());
|
|
1671
|
+
|
|
1672
|
+
// Approved Workspace projects for a `widget: workspace-project` input picker. Returns
|
|
1673
|
+
// [] on any error (→ the picker shows its "approve a project first" empty state).
|
|
1674
|
+
async function fetchApprovedProjects(appFilter) {
|
|
1675
|
+
try {
|
|
1676
|
+
const url = '/api/workspace-projects/approved' + (appFilter ? `?app=${encodeURIComponent(appFilter)}` : '');
|
|
1677
|
+
const r = await fetch(url);
|
|
1678
|
+
const j = await r.json().catch(() => null);
|
|
1679
|
+
return j && j.ok && Array.isArray(j.projects) ? j.projects : [];
|
|
1680
|
+
} catch { return []; }
|
|
1681
|
+
}
|
|
1682
|
+
|
|
1558
1683
|
// Double-click the input node → styled dialog to set the declared inputs. Writes
|
|
1559
1684
|
// to appInputValues; the header "▶ Run workflow" uses them. No native window.prompt.
|
|
1560
1685
|
async function openInputsDialog() {
|
|
@@ -1562,21 +1687,47 @@
|
|
|
1562
1687
|
if (!app || !Array.isArray(app.inputs) || !app.inputs.length) return;
|
|
1563
1688
|
const cur = currentInputs();
|
|
1564
1689
|
const isVisual = (inp) => inp.widget === 'file' || inp.type === 'image' || inp.type === 'file';
|
|
1690
|
+
const isProject = (inp) => inp.widget === 'workspace-project';
|
|
1565
1691
|
const visualNames = new Set(app.inputs.filter(isVisual).map((i) => i.name));
|
|
1566
|
-
|
|
1567
|
-
|
|
1692
|
+
// A project-picker input needs the live list of approved projects — fetch once per open.
|
|
1693
|
+
const approved = app.inputs.some(isProject) ? await fetchApprovedProjects() : [];
|
|
1694
|
+
const fields = app.inputs.map((inp) => {
|
|
1695
|
+
if (isVisual(inp)) return {
|
|
1696
|
+
name: inp.name,
|
|
1697
|
+
label: inp.name + (inp.description ? ` — ${inp.description}` : ''),
|
|
1698
|
+
type: 'file',
|
|
1699
|
+
accept: inp.accept,
|
|
1700
|
+
value: cur[inp.name] != null ? cur[inp.name] : '',
|
|
1701
|
+
};
|
|
1702
|
+
if (isProject(inp)) {
|
|
1703
|
+
const wantApp = typeof inp.workspaceApp === 'string' ? inp.workspaceApp : null;
|
|
1704
|
+
const options = approved
|
|
1705
|
+
.filter((p) => !wantApp || p.app === wantApp)
|
|
1706
|
+
.slice().sort((a, b) => String(a.name).localeCompare(String(b.name)))
|
|
1707
|
+
.map((p) => ({
|
|
1708
|
+
value: p.id,
|
|
1709
|
+
label: p.name,
|
|
1710
|
+
meta: `${appLabel(p.app)} · v${p.latestApprovedVersion}`,
|
|
1711
|
+
search: `${p.name} ${p.app} ${appLabel(p.app)}`,
|
|
1712
|
+
}));
|
|
1713
|
+
return {
|
|
1568
1714
|
name: inp.name,
|
|
1569
1715
|
label: inp.name + (inp.description ? ` — ${inp.description}` : ''),
|
|
1570
|
-
type: '
|
|
1571
|
-
|
|
1716
|
+
type: 'select',
|
|
1717
|
+
options,
|
|
1572
1718
|
value: cur[inp.name] != null ? cur[inp.name] : '',
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1719
|
+
placeholder: 'Select an approved project…',
|
|
1720
|
+
disabledLabel: 'Approve a project first',
|
|
1721
|
+
emptyNote: 'No approved projects yet — open <strong>Workspaces</strong>, create a project, and Approve it to use it here.',
|
|
1722
|
+
};
|
|
1723
|
+
}
|
|
1724
|
+
return {
|
|
1725
|
+
name: inp.name,
|
|
1726
|
+
label: inp.name + (inp.description ? ` — ${inp.description}` : ''),
|
|
1727
|
+
type: inp.type === 'integer' || inp.type === 'number' ? 'number' : 'text',
|
|
1728
|
+
value: cur[inp.name] != null ? cur[inp.name] : inp.default != null ? inp.default : '',
|
|
1729
|
+
};
|
|
1730
|
+
});
|
|
1580
1731
|
const res = await formModal({ title: `Inputs · ${app.displayName}`, sub: 'Set the values this run uses, then ▶ Run workflow.', fields, okLabel: 'Set inputs' });
|
|
1581
1732
|
if (!res) return;
|
|
1582
1733
|
const store = {};
|
|
@@ -1845,7 +1996,7 @@
|
|
|
1845
1996
|
}
|
|
1846
1997
|
document.getElementById('contract-editor-close').onclick = closeContractEditor;
|
|
1847
1998
|
|
|
1848
|
-
// Export 3D ▸ — render the approved
|
|
1999
|
+
// Export 3D ▸ — render the approved model as an interactive 3D model. Calls the server's
|
|
1849
2000
|
// export-3d (transform → companion viewer-3d app → compile → run) and paints the returned
|
|
1850
2001
|
// interactive report in the same viewer a normal run uses. api() throws on any failure (non-2xx
|
|
1851
2002
|
// OR in-band ok:false), so one catch covers "no contract", "all RFI", and compile/render errors.
|
|
@@ -1853,7 +2004,7 @@
|
|
|
1853
2004
|
const app = currentId && apps.get(currentId);
|
|
1854
2005
|
if (!app) return;
|
|
1855
2006
|
$reportTitle.textContent = `3D Viewer · ${app.displayName}`;
|
|
1856
|
-
$reportSub.textContent = 'Rendering the 3D model from the approved
|
|
2007
|
+
$reportSub.textContent = 'Rendering the 3D model from the approved version…';
|
|
1857
2008
|
$reportModal.dataset.nodeId = appId;
|
|
1858
2009
|
showModal($reportModal);
|
|
1859
2010
|
clearReportFrames(); // reset both frames + the ↗ Open buffer so a failure can't show a stale report
|
|
@@ -1868,7 +2019,7 @@
|
|
|
1868
2019
|
// surface that, never let an incomplete model read as complete.
|
|
1869
2020
|
const dropped = Array.isArray(res.skipped) ? res.skipped.length : 0;
|
|
1870
2021
|
$reportSub.textContent = (dropped ? `${dropped} member(s) not shown (no AISC size — RFI). ` : '')
|
|
1871
|
-
+ 'Live 3D view from the approved
|
|
2022
|
+
+ 'Live 3D view from the approved model — drag to orbit, scroll to zoom, click an element to inspect.';
|
|
1872
2023
|
if (dropped) showToast(`3D: ${dropped} member(s) skipped — no resolvable AISC size`, 'info');
|
|
1873
2024
|
paintReport(html, true);
|
|
1874
2025
|
lastReportByApp.set(currentId, { nodeId: res.report.nodeId, label: '3D', html, interactive: true });
|
|
@@ -1880,7 +2031,7 @@
|
|
|
1880
2031
|
}
|
|
1881
2032
|
}
|
|
1882
2033
|
|
|
1883
|
-
// Export IFC ▸ — write the approved
|
|
2034
|
+
// Export IFC ▸ — write the approved model OUT to a universal .ifc and download it. The server
|
|
1884
2035
|
// builds a model-free ifc companion, runs it, and returns the .ifc text (res.content); the browser
|
|
1885
2036
|
// turns it into a download. api() throws on any failure (no contract, all-RFI, compile/write error).
|
|
1886
2037
|
async function exportContractIfc(appId, isVector) {
|
|
@@ -1906,7 +2057,7 @@
|
|
|
1906
2057
|
}
|
|
1907
2058
|
}
|
|
1908
2059
|
|
|
1909
|
-
// Export BOM ▸ — write the approved
|
|
2060
|
+
// Export BOM ▸ — write the approved model's Bill of Materials OUT to a CSV or a real .xlsx and
|
|
1910
2061
|
// download it. Generated host-side (no model): the server reuses the same BOM aggregation the
|
|
1911
2062
|
// canvas BOM node shows, saves the file under ~/.floless/exports/<appId>/, and returns the bytes
|
|
1912
2063
|
// (csv text, or xlsx base64) which the browser turns into a download. api() throws on any failure
|
|
@@ -1940,7 +2091,7 @@
|
|
|
1940
2091
|
return out;
|
|
1941
2092
|
}
|
|
1942
2093
|
|
|
1943
|
-
// Send to Tekla ▸ — create native parts in the OPEN Tekla model from the approved
|
|
2094
|
+
// Send to Tekla ▸ — create native parts in the OPEN Tekla model from the approved model. Needs
|
|
1944
2095
|
// Tekla running with a model; when it's not, the server returns a clear needsTekla state (api()
|
|
1945
2096
|
// throws with err.body.needsTekla) — surfaced as an informational nudge, not a hard error.
|
|
1946
2097
|
async function exportContractTekla(appId) {
|
|
@@ -2356,6 +2507,29 @@
|
|
|
2356
2507
|
<input type="file" accept="${escapeAttr(acceptAttr)}" multiple class="fm-file-input" tabindex="-1" aria-hidden="true">
|
|
2357
2508
|
<div class="fm-files-list" aria-live="polite" hidden></div>
|
|
2358
2509
|
</div>`;
|
|
2510
|
+
} else if (f.type === 'select') {
|
|
2511
|
+
// Themed picker (reuses the .wf-combo/.wf-popover/.wf-option language). The VALUE
|
|
2512
|
+
// lives in a hidden [data-fm] input so collect() reads it like any other field;
|
|
2513
|
+
// the combo just displays a friendly label and updates that input. Popover flows
|
|
2514
|
+
// in-line (not absolute) so it can't be clipped by the modal body's scroll.
|
|
2515
|
+
const opts = Array.isArray(f.options) ? f.options : [];
|
|
2516
|
+
const sel = opts.find((o) => String(o.value) === val);
|
|
2517
|
+
const disabled = !opts.length;
|
|
2518
|
+
const trigLabel = disabled ? (f.disabledLabel || 'None available')
|
|
2519
|
+
: sel ? sel.label + (sel.meta ? ` (${sel.meta})` : '') : (f.placeholder || 'Select…');
|
|
2520
|
+
const rows = opts.map((o) =>
|
|
2521
|
+
`<div class="wf-option" role="option" data-id="${escapeAttr(String(o.value))}" data-search="${escapeAttr(String(o.search || o.label).toLowerCase())}" tabindex="-1" aria-selected="${String(o.value) === val ? 'true' : 'false'}"><span class="wf-option-name">${escapeHtml(o.label)}</span>${o.meta ? `<span class="wf-option-meta">${escapeHtml(o.meta)}</span>` : ''}</div>`).join('');
|
|
2522
|
+
ctl = `<div class="wf-combo fm-select" data-fm-select="${escapeAttr(f.name)}">
|
|
2523
|
+
<input type="hidden" data-fm="${escapeHtml(f.name)}" value="${escapeAttr(val)}">
|
|
2524
|
+
<button type="button" class="wf-trigger fm-select-trigger" aria-haspopup="listbox" aria-expanded="false"${disabled ? ' disabled' : ''}>
|
|
2525
|
+
<span class="wf-trigger-label fm-select-label"${sel ? '' : ' data-empty="1"'}>${escapeHtml(trigLabel)}</span>
|
|
2526
|
+
<svg class="wf-caret" width="10" height="6" viewBox="0 0 10 6" aria-hidden="true"><path fill="currentColor" d="M0 0l5 6 5-6z"/></svg>
|
|
2527
|
+
</button>
|
|
2528
|
+
<div class="wf-popover fm-select-popover" role="listbox" aria-label="${escapeAttr(f.label || f.name)}" hidden>
|
|
2529
|
+
<div class="wf-search-wrap"><input class="wf-search fm-select-search" type="text" placeholder="Search…" autocomplete="off" aria-label="Search"></div>
|
|
2530
|
+
<div class="wf-list fm-select-list">${rows}<div class="wf-empty-search" hidden>No matches</div></div>
|
|
2531
|
+
</div>${disabled && f.emptyNote ? `<div class="fm-select-note">${f.emptyNote}</div>` : ''}
|
|
2532
|
+
</div>`;
|
|
2359
2533
|
} else {
|
|
2360
2534
|
ctl = f.multiline
|
|
2361
2535
|
? `<textarea id="${id}" rows="4" data-fm="${escapeHtml(f.name)}" placeholder="${ph}">${escapeHtml(val)}</textarea>`
|
|
@@ -2544,6 +2718,67 @@
|
|
|
2544
2718
|
if (box.dataset.required) fileGateProbes.push(() => (state.some((s) => s.reading) ? 0 : readyCount()));
|
|
2545
2719
|
renderList(); syncDrop();
|
|
2546
2720
|
});
|
|
2721
|
+
// ── select field setup (themed picker: search + keyboard + click-to-choose) ──
|
|
2722
|
+
$body.querySelectorAll('.fm-select').forEach((box) => {
|
|
2723
|
+
const hidden = box.querySelector('input[type="hidden"][data-fm]');
|
|
2724
|
+
const trigger = box.querySelector('.fm-select-trigger');
|
|
2725
|
+
const label = box.querySelector('.fm-select-label');
|
|
2726
|
+
const popover = box.querySelector('.fm-select-popover');
|
|
2727
|
+
const search = box.querySelector('.fm-select-search');
|
|
2728
|
+
const list = box.querySelector('.fm-select-list');
|
|
2729
|
+
if (!trigger || trigger.disabled || !popover || !list) return;
|
|
2730
|
+
let hi = -1;
|
|
2731
|
+
const opts = () => [...list.querySelectorAll('.wf-option')];
|
|
2732
|
+
const visible = () => opts().filter((o) => !o.hidden);
|
|
2733
|
+
const clearHi = () => { list.querySelectorAll('.wf-option.highlighted').forEach((o) => o.classList.remove('highlighted')); hi = -1; };
|
|
2734
|
+
const filter = (q) => {
|
|
2735
|
+
q = (q || '').toLowerCase().trim();
|
|
2736
|
+
let any = false;
|
|
2737
|
+
opts().forEach((o) => { const m = !q || o.dataset.search.includes(q); o.hidden = !m; if (m) any = true; });
|
|
2738
|
+
const empty = list.querySelector('.wf-empty-search'); if (empty) empty.hidden = any;
|
|
2739
|
+
clearHi();
|
|
2740
|
+
};
|
|
2741
|
+
const move = (d) => {
|
|
2742
|
+
const vis = visible(); if (!vis.length) return;
|
|
2743
|
+
hi = hi < 0 ? (d > 0 ? 0 : vis.length - 1) : Math.max(0, Math.min(vis.length - 1, hi + d));
|
|
2744
|
+
vis.forEach((o, i) => o.classList.toggle('highlighted', i === hi));
|
|
2745
|
+
vis[hi].scrollIntoView({ block: 'nearest' });
|
|
2746
|
+
};
|
|
2747
|
+
const open = () => { popover.hidden = false; trigger.classList.add('open'); trigger.setAttribute('aria-expanded', 'true'); if (search) { search.value = ''; filter(''); setTimeout(() => search.focus(), 0); } };
|
|
2748
|
+
const close = (focusTrig) => { popover.hidden = true; trigger.classList.remove('open'); trigger.setAttribute('aria-expanded', 'false'); clearHi(); if (focusTrig) trigger.focus(); };
|
|
2749
|
+
const choose = (opt) => {
|
|
2750
|
+
if (hidden) hidden.value = opt.dataset.id;
|
|
2751
|
+
opts().forEach((o) => { const s = o === opt; o.classList.toggle('selected', s); o.setAttribute('aria-selected', s ? 'true' : 'false'); });
|
|
2752
|
+
const nm = opt.querySelector('.wf-option-name');
|
|
2753
|
+
const mt = opt.querySelector('.wf-option-meta');
|
|
2754
|
+
if (label) { label.textContent = (nm ? nm.textContent : opt.dataset.id) + (mt ? ` (${mt.textContent})` : ''); label.removeAttribute('data-empty'); }
|
|
2755
|
+
close(true);
|
|
2756
|
+
};
|
|
2757
|
+
trigger.addEventListener('click', (e) => { e.stopPropagation(); popover.hidden ? open() : close(false); });
|
|
2758
|
+
trigger.addEventListener('keydown', (e) => { if (e.key === 'ArrowDown' || e.key === 'Enter' || e.key === ' ') { e.preventDefault(); open(); } });
|
|
2759
|
+
list.addEventListener('click', (e) => { const o = e.target.closest('.wf-option'); if (o) { e.stopPropagation(); choose(o); } });
|
|
2760
|
+
if (search) search.addEventListener('input', () => filter(search.value));
|
|
2761
|
+
// Keep combo keys inside the combo — don't submit/cancel the whole modal.
|
|
2762
|
+
box.addEventListener('keydown', (e) => {
|
|
2763
|
+
if (popover.hidden) return;
|
|
2764
|
+
if (e.key === 'ArrowDown') { e.preventDefault(); e.stopPropagation(); move(1); }
|
|
2765
|
+
else if (e.key === 'ArrowUp') { e.preventDefault(); e.stopPropagation(); move(-1); }
|
|
2766
|
+
else if (e.key === 'Enter') { e.preventDefault(); e.stopPropagation(); const vis = visible(); if (hi >= 0 && vis[hi]) choose(vis[hi]); }
|
|
2767
|
+
else if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); close(true); }
|
|
2768
|
+
});
|
|
2769
|
+
});
|
|
2770
|
+
// Click elsewhere in the form closes any open select popover (trigger/option clicks
|
|
2771
|
+
// stopPropagation, so this only fires for genuine outside clicks). Cleared in done().
|
|
2772
|
+
$body.onclick = (e) => {
|
|
2773
|
+
$body.querySelectorAll('.fm-select').forEach((box) => {
|
|
2774
|
+
const pop = box.querySelector('.fm-select-popover');
|
|
2775
|
+
if (pop && !pop.hidden && !box.contains(e.target)) {
|
|
2776
|
+
pop.hidden = true;
|
|
2777
|
+
const t = box.querySelector('.fm-select-trigger');
|
|
2778
|
+
if (t) { t.classList.remove('open'); t.setAttribute('aria-expanded', 'false'); }
|
|
2779
|
+
}
|
|
2780
|
+
});
|
|
2781
|
+
};
|
|
2547
2782
|
// ── paste support: an image into the modal → the images field, else the file field ──
|
|
2548
2783
|
$body.onpaste = (e) => {
|
|
2549
2784
|
const items = Array.from((e.clipboardData && e.clipboardData.items) || []);
|
|
@@ -2624,7 +2859,7 @@
|
|
|
2624
2859
|
_formModalOpen = false;
|
|
2625
2860
|
modalClosed = true;
|
|
2626
2861
|
hideModal($formModal);
|
|
2627
|
-
$ok.onclick = null; $cancel.onclick = null; $formModal.onclick = null; $formModal.onkeydown = null; $body.onpaste = null; $body.ondragover = null; $body.ondrop = null;
|
|
2862
|
+
$ok.onclick = null; $cancel.onclick = null; $formModal.onclick = null; $formModal.onkeydown = null; $body.onpaste = null; $body.onclick = null; $body.ondragover = null; $body.ondrop = null;
|
|
2628
2863
|
$ok.classList.remove('danger'); $ok.classList.add('primary'); $cancel.classList.remove('primary'); $ok.disabled = false; // reset chrome for the next caller
|
|
2629
2864
|
resolve(result);
|
|
2630
2865
|
};
|
|
@@ -3145,13 +3380,18 @@
|
|
|
3145
3380
|
if ($canvasMain && $dropTarget) {
|
|
3146
3381
|
// dragenter stays file-only on purpose: it shows the ".flo import" overlay ($dropTarget),
|
|
3147
3382
|
// which must NOT appear for a node-card drag. dragover alone suppresses the no-drop cursor.
|
|
3148
|
-
|
|
3383
|
+
// Gate all handlers: .flo import is Workflows-only, not available in Workspaces mode.
|
|
3384
|
+
$canvasMain.addEventListener('dragenter', (e) => {
|
|
3385
|
+
if ($app.classList.contains('mode-workspaces')) return; // .flo not used in Workspaces
|
|
3386
|
+
if (isFileDrag(e)) { e.preventDefault(); $dropTarget.classList.add('active'); }
|
|
3387
|
+
});
|
|
3149
3388
|
$canvasMain.addEventListener('dragover', (e) => {
|
|
3150
3389
|
if (isFileDrag(e)) { e.preventDefault(); return; } // required to allow the file drop
|
|
3151
3390
|
if (isCardDrag(e)) { e.preventDefault(); e.dataTransfer.dropEffect = 'copy'; } // suppress the no-drop cursor (#96)
|
|
3152
3391
|
});
|
|
3153
3392
|
$canvasMain.addEventListener('dragleave', (e) => { if (!$canvasMain.contains(e.relatedTarget)) $dropTarget.classList.remove('active'); });
|
|
3154
3393
|
$canvasMain.addEventListener('drop', (e) => {
|
|
3394
|
+
if ($app.classList.contains('mode-workspaces')) return; // .flo not used in Workspaces
|
|
3155
3395
|
// A card dropped on the bare canvas is a no-op: saving as a Template only happens on the
|
|
3156
3396
|
// Templates bar (its own drop handler, which runs first as the drop bubbles up). Now that
|
|
3157
3397
|
// the canvas accepts the dragover we must swallow that drop so the browser performs no
|
|
@@ -4656,11 +4896,45 @@
|
|
|
4656
4896
|
return `Help me build a brand-new floless workflow from scratch, step by step, with your floless-app-new-workflow skill. Ask me what I want it to do, then before writing any node confirm the agents it needs are installed (offer to install a missing one from the catalogue, or to report a not-yet-existing agent as an idea). Author the .flo node by node, verifying each step is correct (plain-English descriptions, validate, compile, a real run), and finish by installing → Compile → ▶ Run so I can see it work and approve.`;
|
|
4657
4897
|
}
|
|
4658
4898
|
if (req.type === 'revision-read') {
|
|
4899
|
+
const isInitialRead = !req.baseVersion || req.baseVersion <= 0;
|
|
4659
4900
|
const snaps = req.snapshots && req.snapshots.length
|
|
4660
|
-
? `\
|
|
4901
|
+
? `\n${isInitialRead ? 'Initial' : 'Revised'} drawing${req.snapshots.length > 1 ? 's' : ''} (read these): ${req.snapshots.join(', ')}`
|
|
4661
4902
|
: '';
|
|
4662
4903
|
const note = req.instruction ? `\nMy note: ${req.instruction}` : '';
|
|
4663
|
-
|
|
4904
|
+
const messageHint = isInitialRead ? '<plain-English what was read>' : '<plain-English what changed>';
|
|
4905
|
+
const post = `Only after the review checkpoint is complete, POST /api/projects/${req.project}/revision-read with { contract, message: "${messageHint}", requestId: "${req.id}" }. The server derives the base version + source provenance from this queued request, records a "revision-read" version, and clears the request — do NOT DELETE the request yourself. If you can't read the set, POST /api/projects/${req.project}/revision-requests/${req.id}/fail with { error }.`;
|
|
4906
|
+
// App-aware: the target contract shape differs per workspace app. A vectorize project holds a
|
|
4907
|
+
// drawing.vector/v1 (clean editable 2D linework), NOT a steel takeoff — instructing the AI to
|
|
4908
|
+
// read steel members would produce the wrong contract for the vector editor (spec §3.3g).
|
|
4909
|
+
if (req.appId === 'vectorize') {
|
|
4910
|
+
if (isInitialRead) {
|
|
4911
|
+
return `In floless project "${req.project}" (app "${req.appId}"), an initial drawing was attached — trace it into this project as its first version (do NOT create a new project). Vectorize the drawing per the floless-app-vectorize skill into a drawing.vector/v1 contract: emit clean, editable 2D vector geometry (sheets → elements: lines / polylines / curves / text, each on its layer), NOT steel members or a takeoff. A vector PDF is read deterministically (exact geometry, no guessing); a photo, scan or hand sketch is traced by a fenced vision extraction that flags every uncertain stroke (low confidence) for the user's review. ${post}${snaps}${note}`;
|
|
4912
|
+
}
|
|
4913
|
+
return `In floless project "${req.project}" (app "${req.appId}"), a REVISED drawing was attached — re-read (vectorize) it into the SAME project as a new version (do NOT create a new project). Vectorize the drawing per the floless-app-vectorize skill into a drawing.vector/v1 contract: emit clean, editable 2D vector geometry (sheets → elements: lines / polylines / curves / text, each on its layer), NOT steel members or a takeoff. A vector PDF is read deterministically (exact geometry, no guessing); a photo, scan or hand sketch is traced by a fenced vision extraction that flags every uncertain stroke (low confidence) for the user's review. ${post}${snaps}${note}`;
|
|
4914
|
+
}
|
|
4915
|
+
if (isInitialRead) {
|
|
4916
|
+
return `In floless project "${req.project}" (app "${req.appId}"), an initial drawing set was attached — read it into this project as its first steel model version (do NOT create a new project). Follow the floless-app-steel-takeoff skill's mandatory two-phase gate. FIRST, do the deterministic PyMuPDF steel-filter pass only: identify the framing-plan sheets, enumerate the drawing elements by layer/thickness/color into contract.filter.sheets/facets, PUT that project contract to /api/contract/${req.appId}?project=${req.project}, then STOP and tell me to open Drawings → Steel Filter, review/narrow the steel facets, and Save. Do NOT read members, build the model, open 3D, or POST /revision-read until I explicitly come back after saving the filter. AFTER that saved-filter checkpoint, read members from the saved filter selection and compose the steel.takeoff/v1 contract. ${post}${snaps}${note}`;
|
|
4917
|
+
}
|
|
4918
|
+
return `In floless project "${req.project}" (app "${req.appId}"), a REVISED drawing set was attached — re-read it into the SAME project as a new version (do NOT create a new project). Follow the floless-app-steel-takeoff skill's mandatory two-phase gate. FIRST, GET /api/contract/${req.appId}?project=${req.project} to read the CURRENT contract, then do the deterministic PyMuPDF steel-filter pass only for the revised drawing set: identify the framing-plan sheets, enumerate drawing elements by layer/thickness/color into contract.filter.sheets/facets, preserve any compatible existing filter selections, PUT that project contract back to /api/contract/${req.appId}?project=${req.project}, then STOP and tell me to open Drawings → Steel Filter, review/narrow the steel facets, and Save. Do NOT read members, build the model, open 3D, or POST /revision-read until I explicitly come back after saving the filter. AFTER that saved-filter checkpoint, read members from the saved filter selection, compose the updated steel.takeoff/v1 contract, and PRESERVE each still-present member's id AND its sheet label (mint a NEW id only for a genuinely new member; drop the id of a member the revision deleted) so the version comparison matches members — do NOT renumber the whole model. ${post}${snaps}${note}`;
|
|
4919
|
+
}
|
|
4920
|
+
// The Knowledge step's Organize verb. The lifecycle is SERVER-owned: start claims the organize
|
|
4921
|
+
// lock and mints the generation dir; finish publishes it and clears this request; fail releases
|
|
4922
|
+
// the lock. Naming the exact project-scoped routes matters — /api/requests/<id> is NOT the
|
|
4923
|
+
// completion path here, and a stray DELETE would strand the lock until its stale timeout.
|
|
4924
|
+
if (req.type === 'knowledge-organize') {
|
|
4925
|
+
const kb = `/api/projects/${req.project}/knowledge`;
|
|
4926
|
+
return `In floless project "${req.project}", organize the Project Knowledge Base with your floless-app-knowledge skill. ` +
|
|
4927
|
+
`Claim the pass with POST ${kb}/requests/${req.id}/start — it takes the organize lock and returns { baseRevision, generationId, wikiDir }. ` +
|
|
4928
|
+
`Read the source set from GET ${kb}/status (the rows it marks state:"organizing" ARE this pass's snapshot), read each source's bytes from that project's knowledge/blobs/<blobSha256>, ` +
|
|
4929
|
+
`and compile the project wiki INTO the returned wikiDir — never invent a path. ` +
|
|
4930
|
+
`Publish with POST ${kb}/requests/${req.id}/finish { generationId, lintSummary }; on any failure release the lock with POST ${kb}/requests/${req.id}/fail { error }. ` +
|
|
4931
|
+
`Do NOT DELETE this request and do NOT use /api/requests/${req.id} — finish/fail resolves it server-side. ` +
|
|
4932
|
+
`If finish returns { rerun: true } the sources changed mid-pass: POST ${kb}/organize once for a FRESH request, then run start → compile → finish on that new id exactly once.`;
|
|
4933
|
+
}
|
|
4934
|
+
// The KB "reshape it" box (its UI lands in a later slice; the verb + route already exist).
|
|
4935
|
+
if (req.type === 'knowledge-adjust') {
|
|
4936
|
+
return `In floless project "${req.project}", reshape the Project Knowledge Base with your floless-app-knowledge skill: ${req.instruction || 'apply the requested change'}. ` +
|
|
4937
|
+
`Edit the project's wiki notes accordingly, then re-organize so the published generation reflects the change.`;
|
|
4664
4938
|
}
|
|
4665
4939
|
return '';
|
|
4666
4940
|
}
|
|
@@ -4678,6 +4952,9 @@
|
|
|
4678
4952
|
guide: 'floless-app-onboarding',
|
|
4679
4953
|
// Build-a-workflow-from-scratch: its own guide skill (interview → author → verify).
|
|
4680
4954
|
'new-workflow': 'floless-app-new-workflow',
|
|
4955
|
+
// Project Knowledge Base: one self-contained skill drives both the organize lifecycle and adjusts.
|
|
4956
|
+
'knowledge-organize': 'floless-app-knowledge',
|
|
4957
|
+
'knowledge-adjust': 'floless-app-knowledge',
|
|
4681
4958
|
};
|
|
4682
4959
|
|
|
4683
4960
|
// The COPIED form of a request: instructionFor() prefixed with a self-identifying
|
|
@@ -4688,13 +4965,22 @@
|
|
|
4688
4965
|
function markedInstruction(req) {
|
|
4689
4966
|
const body = instructionFor(req);
|
|
4690
4967
|
if (!body) return '';
|
|
4691
|
-
|
|
4968
|
+
// revision-read's skill is app-specific: steel takeoff by default, floless-app-vectorize for a
|
|
4969
|
+
// vector project — keep the clipboard marker in step with the app-aware instruction body above.
|
|
4970
|
+
let skill = REQUEST_SKILL[req.type] || 'floless-app-workflows';
|
|
4971
|
+
if (req.type === 'revision-read' && req.appId === 'vectorize') skill = 'floless-app-vectorize';
|
|
4692
4972
|
const base = (typeof location !== 'undefined' && location.origin) ? location.origin : 'http://127.0.0.1:4317';
|
|
4693
|
-
// A revision-read is cleared by its own /revision-read POST — a separate DELETE would 404.
|
|
4694
|
-
//
|
|
4973
|
+
// A revision-read is cleared by its own /revision-read POST — a separate DELETE would 404. A
|
|
4974
|
+
// knowledge-organize is likewise lifecycle-owned: its finish/fail POST clears it, and a stray
|
|
4975
|
+
// DELETE would strand the organize lock until the stale timeout. Every other type is
|
|
4976
|
+
// applied-then-DELETEd by the terminal AI.
|
|
4695
4977
|
const clears = req.type === 'revision-read'
|
|
4696
|
-
?
|
|
4697
|
-
|
|
4978
|
+
? (req.appId === 'steel-model'
|
|
4979
|
+
? `apply it in two phases: first write the Steel Filter checkpoint to the project contract and stop for user Save; only after that checkpoint use the route in the line below (that POST clears this request — do NOT DELETE it separately).`
|
|
4980
|
+
: `apply it via the route in the line below (that POST clears this request — do NOT DELETE it separately).`)
|
|
4981
|
+
: req.type === 'knowledge-organize'
|
|
4982
|
+
? `drive it through the start → finish/fail lifecycle routes in the line below (finish or fail clears this request — do NOT DELETE it separately, that would strand the organize lock).`
|
|
4983
|
+
: `apply that request, then DELETE ${base}/api/requests/${req.id}.`;
|
|
4698
4984
|
const marker =
|
|
4699
4985
|
`[floless-request type=${req.type} id=${req.id}] — queued from the FloLess Dashboard. ` +
|
|
4700
4986
|
`Apply it with your ${skill} skill: fetch the authoritative spec from GET ${base}/api/requests, ` +
|
|
@@ -4706,6 +4992,47 @@
|
|
|
4706
4992
|
try { await navigator.clipboard.writeText(text); return true; } catch { return false; }
|
|
4707
4993
|
}
|
|
4708
4994
|
|
|
4995
|
+
let requestHelpReq = null;
|
|
4996
|
+
let requestHelpReturnFocus = null;
|
|
4997
|
+
function closeRequestHelp({ restoreFocus = true } = {}) {
|
|
4998
|
+
const $m = document.getElementById('request-help-modal');
|
|
4999
|
+
if ($m) hideModal($m);
|
|
5000
|
+
const target = requestHelpReturnFocus;
|
|
5001
|
+
requestHelpReturnFocus = null;
|
|
5002
|
+
if (restoreFocus && target && target.isConnected) {
|
|
5003
|
+
try { target.focus(); } catch { /* focus is best-effort */ }
|
|
5004
|
+
}
|
|
5005
|
+
}
|
|
5006
|
+
function showRequestQueuedModal(req, opts = {}) {
|
|
5007
|
+
const $m = document.getElementById('request-help-modal');
|
|
5008
|
+
if (!$m || !req) return;
|
|
5009
|
+
requestHelpReq = req;
|
|
5010
|
+
requestHelpReturnFocus = opts.returnFocus || document.activeElement;
|
|
5011
|
+
const copied = opts.copied !== false;
|
|
5012
|
+
const n = Number(opts.fileCount || (req.snapshots && req.snapshots.length) || 1);
|
|
5013
|
+
const isRevisionRead = req.type === 'revision-read';
|
|
5014
|
+
const isInitial = isRevisionRead && (!req.baseVersion || req.baseVersion <= 0);
|
|
5015
|
+
const $title = document.getElementById('request-help-title');
|
|
5016
|
+
const $sub = document.getElementById('request-help-sub');
|
|
5017
|
+
const $note = document.getElementById('request-help-note');
|
|
5018
|
+
const $copy = document.getElementById('request-help-copy');
|
|
5019
|
+
if ($title) $title.textContent = isRevisionRead
|
|
5020
|
+
? `${isInitial ? 'Initial drawing read' : 'Revision read'} queued`
|
|
5021
|
+
: 'Request queued';
|
|
5022
|
+
if ($sub) {
|
|
5023
|
+
$sub.textContent = copied
|
|
5024
|
+
? `${n} drawing file${n === 1 ? '' : 's'} added to Requests. The terminal instructions were copied to your clipboard.`
|
|
5025
|
+
: `${n} drawing file${n === 1 ? '' : 's'} added to Requests. Copy the terminal instructions from here or from the Requests panel.`;
|
|
5026
|
+
}
|
|
5027
|
+
if ($note) $note.textContent = isRevisionRead
|
|
5028
|
+
? 'The web UI queues the drawing read; your terminal agent applies it and reports progress back here.'
|
|
5029
|
+
: 'The web UI queues the request; your terminal agent applies it and reports progress back here.';
|
|
5030
|
+
if ($copy) $copy.hidden = copied;
|
|
5031
|
+
showModal($m);
|
|
5032
|
+
const shell = $m.querySelector('.modal.request-help');
|
|
5033
|
+
if (shell) { try { shell.focus(); } catch { /* not focusable */ } }
|
|
5034
|
+
}
|
|
5035
|
+
|
|
4709
5036
|
async function useTemplate(templateId) {
|
|
4710
5037
|
if (!currentId) { showToast('open a workflow first', 'warn'); return; }
|
|
4711
5038
|
try {
|
|
@@ -4746,6 +5073,9 @@
|
|
|
4746
5073
|
}
|
|
4747
5074
|
|
|
4748
5075
|
let pendingRequests = [];
|
|
5076
|
+
let previousRequestCount = 0;
|
|
5077
|
+
let previousRequestIds = null;
|
|
5078
|
+
let reqPulseTimer = null;
|
|
4749
5079
|
async function loadRequests() {
|
|
4750
5080
|
try {
|
|
4751
5081
|
const { requests } = await api('/api/requests');
|
|
@@ -4754,6 +5084,20 @@
|
|
|
4754
5084
|
const $rs = document.getElementById('req-stat');
|
|
4755
5085
|
if ($rc) $rc.textContent = requests.length;
|
|
4756
5086
|
if ($rs) $rs.classList.toggle('has-pending', requests.length > 0);
|
|
5087
|
+
const ids = new Set(requests.map((r) => r && r.id).filter(Boolean));
|
|
5088
|
+
const hasNewId = previousRequestIds
|
|
5089
|
+
? requests.some((r) => r && r.id && !previousRequestIds.has(r.id))
|
|
5090
|
+
: requests.length > previousRequestCount;
|
|
5091
|
+
// Add the shake animation when a new request appears in the poll/SSE refresh.
|
|
5092
|
+
if ((hasNewId || requests.length > previousRequestCount) && $rs) {
|
|
5093
|
+
$rs.classList.remove('req-pulse'); // force reflow to restart animation
|
|
5094
|
+
void $rs.offsetWidth; // trigger reflow
|
|
5095
|
+
$rs.classList.add('req-pulse');
|
|
5096
|
+
if (reqPulseTimer) clearTimeout(reqPulseTimer);
|
|
5097
|
+
reqPulseTimer = setTimeout(() => { $rs.classList.remove('req-pulse'); reqPulseTimer = null; }, 2100);
|
|
5098
|
+
}
|
|
5099
|
+
previousRequestCount = requests.length;
|
|
5100
|
+
previousRequestIds = ids;
|
|
4757
5101
|
const $rm = document.getElementById('requests-modal');
|
|
4758
5102
|
if ($rm && $rm.classList.contains('show')) renderRequests(); // keep an open list live
|
|
4759
5103
|
} catch { /* non-fatal */ }
|
|
@@ -4777,8 +5121,8 @@
|
|
|
4777
5121
|
return;
|
|
4778
5122
|
}
|
|
4779
5123
|
$list.innerHTML = pendingRequests.map((r) => {
|
|
4780
|
-
const label = r.type === 'use-template' ? 'template' : r.type === 'ui-customize' ? 'dashboard' : r.type === 'rebake' ? 're-bake' : r.type === 'revision-read' ? 'revision' : r.type === 'guide' ? 'guide' : r.type === 'new-workflow' ? 'new workflow' : 'tweak';
|
|
4781
|
-
const badgeCls = r.type === 'tweak' || r.type === 'ui-customize' || r.type === 'rebake' || r.type === 'revision-read' ? 'req-type req-type-tweak' : 'req-type';
|
|
5124
|
+
const label = r.type === 'use-template' ? 'template' : r.type === 'ui-customize' ? 'dashboard' : r.type === 'rebake' ? 're-bake' : r.type === 'revision-read' ? 'revision' : r.type === 'guide' ? 'guide' : r.type === 'new-workflow' ? 'new workflow' : r.type === 'knowledge-organize' ? 'organize' : r.type === 'knowledge-adjust' ? 'adjust' : 'tweak';
|
|
5125
|
+
const badgeCls = r.type === 'tweak' || r.type === 'ui-customize' || r.type === 'rebake' || r.type === 'revision-read' || r.type === 'knowledge-organize' || r.type === 'knowledge-adjust' ? 'req-type req-type-tweak' : 'req-type';
|
|
4782
5126
|
const target = r.type === 'tweak' && r.nodeId
|
|
4783
5127
|
? ` · node <code>${escapeHtml(r.nodeId)}</code>`
|
|
4784
5128
|
: r.type === 'rebake' && r.inputName
|
|
@@ -4786,6 +5130,13 @@
|
|
|
4786
5130
|
: '';
|
|
4787
5131
|
const when = r.createdAt ? new Date(r.createdAt) : null;
|
|
4788
5132
|
const time = when && !isNaN(when) ? `<span class="req-time">${escapeHtml(nowStamp(when))}</span>` : '';
|
|
5133
|
+
// A knowledge-organize is resolved by its own finish/fail lifecycle POST. Offering a ✕ here
|
|
5134
|
+
// would let the user delete a request the terminal AI is mid-way through, 404-ing finish/fail
|
|
5135
|
+
// and stranding the organize lock until its stale timeout. Show why it can't be cleared instead.
|
|
5136
|
+
const lifecycleOwned = r.type === 'knowledge-organize';
|
|
5137
|
+
const del = lifecycleOwned
|
|
5138
|
+
? '<span class="req-lifecycle" data-tip="This clears itself when your terminal AI finishes or fails the organize">finishing in your terminal</span>'
|
|
5139
|
+
: `<button class="req-del" data-id="${escapeAttr(r.id)}" data-tip="Clear this request">×</button>`;
|
|
4789
5140
|
return `
|
|
4790
5141
|
<div class="req-item">
|
|
4791
5142
|
<div class="req-info">
|
|
@@ -4795,7 +5146,7 @@
|
|
|
4795
5146
|
</div>
|
|
4796
5147
|
<div class="req-actions">
|
|
4797
5148
|
<button class="req-copy" data-id="${escapeAttr(r.id)}" data-tip="Copy this instruction">⧉</button>
|
|
4798
|
-
|
|
5149
|
+
${del}
|
|
4799
5150
|
</div>
|
|
4800
5151
|
</div>`;
|
|
4801
5152
|
}).join('');
|
|
@@ -4817,14 +5168,36 @@
|
|
|
4817
5168
|
try { await api(`/api/requests/${encodeURIComponent(id)}`, { method: 'DELETE' }); await loadRequests(); renderRequests(); }
|
|
4818
5169
|
catch (e) { reportErr(e); }
|
|
4819
5170
|
}
|
|
5171
|
+
// Clear-all must never take out a knowledge-organize: the bulk DELETE would 404 its finish/fail and
|
|
5172
|
+
// strand the organize lock until the stale timeout. The request list can't tell "queued" from
|
|
5173
|
+
// "already started", so ALL organizes are kept — they clear themselves via their lifecycle.
|
|
4820
5174
|
async function clearAllRequests() {
|
|
4821
5175
|
if (!pendingRequests.length) return;
|
|
4822
|
-
|
|
4823
|
-
|
|
5176
|
+
const keep = pendingRequests.filter((r) => r && r.type === 'knowledge-organize');
|
|
5177
|
+
try {
|
|
5178
|
+
if (!keep.length) {
|
|
5179
|
+
await api('/api/requests', { method: 'DELETE' }); // nothing lifecycle-owned — the atomic bulk clear is fine
|
|
5180
|
+
} else {
|
|
5181
|
+
const drop = pendingRequests.filter((r) => r && r.type !== 'knowledge-organize');
|
|
5182
|
+
for (const r of drop) await api(`/api/requests/${encodeURIComponent(r.id)}`, { method: 'DELETE' });
|
|
5183
|
+
}
|
|
5184
|
+
await loadRequests();
|
|
5185
|
+
renderRequests();
|
|
5186
|
+
showToast(
|
|
5187
|
+
keep.length
|
|
5188
|
+
? `Cleared the other requests — kept ${keep.length} in-progress organize${keep.length === 1 ? '' : 's'}`
|
|
5189
|
+
: 'Cleared all requests',
|
|
5190
|
+
'ok',
|
|
5191
|
+
);
|
|
5192
|
+
} catch (e) { reportErr(e); }
|
|
4824
5193
|
}
|
|
4825
|
-
|
|
4826
|
-
|
|
5194
|
+
// Re-fetch before showing: there is no server `request-added` broadcast, so a request queued in
|
|
5195
|
+
// another tab (or by the Knowledge step) would otherwise render from a stale cache.
|
|
5196
|
+
async function openRequests() {
|
|
4827
5197
|
document.getElementById('requests-modal').classList.add('show');
|
|
5198
|
+
renderRequests(); // paint the cache immediately — no empty flash
|
|
5199
|
+
await loadRequests();
|
|
5200
|
+
renderRequests(); // then reconcile with the truth
|
|
4828
5201
|
}
|
|
4829
5202
|
|
|
4830
5203
|
// ── Agents library: real installed agents + their commands ───────────────────
|
|
@@ -6272,7 +6645,32 @@
|
|
|
6272
6645
|
const copied = await copyToClipboard(text);
|
|
6273
6646
|
showToast(copied ? `Copied ${pendingRequests.length} request(s) — paste to your terminal AI` : 'copy failed', copied ? 'ok' : 'err');
|
|
6274
6647
|
};
|
|
6648
|
+
const $requestHelpModal = document.getElementById('request-help-modal');
|
|
6649
|
+
const $requestHelpOpen = document.getElementById('request-help-open');
|
|
6650
|
+
const $requestHelpKeep = document.getElementById('request-help-keep');
|
|
6651
|
+
const $requestHelpCopy = document.getElementById('request-help-copy');
|
|
6652
|
+
if ($requestHelpOpen) $requestHelpOpen.onclick = () => {
|
|
6653
|
+
closeRequestHelp({ restoreFocus: false });
|
|
6654
|
+
openRequests();
|
|
6655
|
+
};
|
|
6656
|
+
if ($requestHelpKeep) $requestHelpKeep.onclick = () => closeRequestHelp();
|
|
6657
|
+
if ($requestHelpCopy) $requestHelpCopy.onclick = async () => {
|
|
6658
|
+
if (!requestHelpReq) return;
|
|
6659
|
+
const copied = await copyToClipboard(markedInstruction(requestHelpReq));
|
|
6660
|
+
showToast(copied ? 'Copied — paste it to your terminal AI' : 'copy failed', copied ? 'ok' : 'err');
|
|
6661
|
+
if (copied) {
|
|
6662
|
+
$requestHelpCopy.hidden = true;
|
|
6663
|
+
const $sub = document.getElementById('request-help-sub');
|
|
6664
|
+
if ($sub) $sub.textContent = 'Terminal instructions copied. Open the terminal agent and paste them there.';
|
|
6665
|
+
}
|
|
6666
|
+
};
|
|
6667
|
+
if ($requestHelpModal) onBackdropDismiss($requestHelpModal, () => closeRequestHelp());
|
|
6275
6668
|
document.addEventListener('keydown', (e) => {
|
|
6669
|
+
if (e.key === 'Escape' && $requestHelpModal && $requestHelpModal.classList.contains('show')) {
|
|
6670
|
+
e.preventDefault();
|
|
6671
|
+
closeRequestHelp();
|
|
6672
|
+
return;
|
|
6673
|
+
}
|
|
6276
6674
|
if (e.key === 'Escape' && $reqModal && $reqModal.classList.contains('show')) $reqModal.classList.remove('show');
|
|
6277
6675
|
});
|
|
6278
6676
|
|
|
@@ -6458,7 +6856,43 @@
|
|
|
6458
6856
|
copyToClipboard,
|
|
6459
6857
|
instructionFor,
|
|
6460
6858
|
markedInstruction, // marked (paste-safe) form for clipboard copies — panels.js uses it (#73)
|
|
6859
|
+
showRequestQueuedModal,
|
|
6461
6860
|
formModal, // the shared styled prompt/form modal — workspaces.js reuses it (never a native prompt)
|
|
6861
|
+
// ── Workspaces guide beacon (the SAME #guide-beacon/#guide-modal, document variant) ──
|
|
6862
|
+
// workspaces.js owns the open project + its lifecycle state; aware.js owns the beacon
|
|
6863
|
+
// chrome. workspaces.js calls setWorkspaceGuide() with a small snapshot whenever the
|
|
6864
|
+
// open project (or its approve/export state) changes, clearWorkspaceGuide() on close/
|
|
6865
|
+
// Workflows-mode, and markWorkspaceApproved() the first time an Approve succeeds (which
|
|
6866
|
+
// calms the beacon, mirroring markFirstRunDone for a workflow's first Run).
|
|
6867
|
+
setWorkspaceGuide(ctx) {
|
|
6868
|
+
// ctx: { app, name, displayName?, approved, exported }. Null/!app → treat as clear.
|
|
6869
|
+
wsGuideCtx = (ctx && ctx.app) ? { ...ctx } : null;
|
|
6870
|
+
if (inWorkspacesMode()) {
|
|
6871
|
+
paintWorkspaceBeacon();
|
|
6872
|
+
const $m = document.getElementById('guide-modal');
|
|
6873
|
+
if ($m && $m.classList.contains('show') && wsGuideCtx) renderWorkspaceGuide();
|
|
6874
|
+
}
|
|
6875
|
+
},
|
|
6876
|
+
clearWorkspaceGuide() {
|
|
6877
|
+
wsGuideCtx = null;
|
|
6878
|
+
// Repaint through the mode-correct painter. In Workspaces mode paintWorkspaceBeacon() hides the
|
|
6879
|
+
// (now-cleared) workspace beacon. On the mode-switch-BACK path we're already in Workflows mode,
|
|
6880
|
+
// so repaint the WORKFLOW beacon for the current app instead of no-op'ing — otherwise the stale
|
|
6881
|
+
// workspace label/tooltip/is-new lingers until the next workflow load. paintBeacon(null) is safe
|
|
6882
|
+
// (it just hides the workflow beacon when no app is open).
|
|
6883
|
+
if (inWorkspacesMode()) paintWorkspaceBeacon();
|
|
6884
|
+
else paintBeacon(currentId ? apps.get(currentId) : null);
|
|
6885
|
+
},
|
|
6886
|
+
markWorkspaceApproved(app) {
|
|
6887
|
+
if (!app || guideFor(wsGuideKey(app)).approveDone) return;
|
|
6888
|
+
setGuide(wsGuideKey(app), { approveDone: true });
|
|
6889
|
+
if (wsGuideCtx && wsGuideCtx.app === app) {
|
|
6890
|
+
wsGuideCtx.approved = true;
|
|
6891
|
+
if (inWorkspacesMode()) paintWorkspaceBeacon();
|
|
6892
|
+
const $m = document.getElementById('guide-modal');
|
|
6893
|
+
if ($m && $m.classList.contains('show')) renderWorkspaceGuide();
|
|
6894
|
+
}
|
|
6895
|
+
},
|
|
6462
6896
|
};
|
|
6463
6897
|
|
|
6464
6898
|
// ── boot ──────────────────────────────────────────────────────────────────────
|