@floless/app 0.163.0 → 0.164.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 +41379 -40421
- package/dist/web/app.css +2 -0
- package/dist/web/chat.css +10 -0
- package/dist/web/chat.js +290 -36
- package/dist/web/commands-filter.js +35 -0
- package/dist/web/commands-shell.js +18 -7
- package/dist/web/commands-steel.js +9 -0
- package/dist/web/model-editor-steel-adapter.js +2 -0
- package/dist/web/project-rfis.js +53 -3
- package/dist/web/steel-3d-view.js +154 -0
- package/dist/web/steel-ai-marks.js +233 -0
- package/dist/web/steel-editor.html +509 -24
- package/dist/web/steel-filter-flo.js +225 -0
- package/dist/web/steel-filter.html +118 -4
- package/dist/web/workspaces.js +137 -20
- package/package.json +1 -1
package/dist/web/workspaces.js
CHANGED
|
@@ -5867,6 +5867,90 @@
|
|
|
5867
5867
|
};
|
|
5868
5868
|
}
|
|
5869
5869
|
|
|
5870
|
+
// #2926: no picture asked for in this long, and a conversation that is not running, means a chat-run read is not
|
|
5871
|
+
// reading. A terminal-run read has only its pictures to prove that once its progress record is stale.
|
|
5872
|
+
const FLO_FRESH_WORK_MS = 2 * 60_000;
|
|
5873
|
+
const FLO_HASH = /^[0-9a-f]{64}$/;
|
|
5874
|
+
function floLookOk(l) {
|
|
5875
|
+
return !!l && typeof l === 'object' && typeof l.pageId === 'string' && FLO_HASH.test(l.sourceHash)
|
|
5876
|
+
&& Number.isSafeInteger(l.pageNumber) && l.pageNumber >= 1 && Number.isSafeInteger(l.part) && l.part >= 0 && l.part <= 9
|
|
5877
|
+
&& Number.isSafeInteger(l.seq) && Number.isFinite(l.ageMs) && l.ageMs >= 0
|
|
5878
|
+
&& (l.rect === null || (Array.isArray(l.rect) && l.rect.length === 4 && l.rect.every((v) => Number.isFinite(v) && v >= 0 && v <= 1)
|
|
5879
|
+
&& l.rect[2] > l.rect[0] && l.rect[3] > l.rect[1]));
|
|
5880
|
+
}
|
|
5881
|
+
|
|
5882
|
+
/**
|
|
5883
|
+
* #2926: what the Drawing Filter's Flo shows for the read the progress strip speaks for, from that read's own
|
|
5884
|
+
* signals only. `reading` while it is evidently working (with the sheet pictures it last asked for), `waiting`
|
|
5885
|
+
* only while the AI has really asked the person something, and `off` otherwise, with the reason.
|
|
5886
|
+
*
|
|
5887
|
+
* `view` is drawingProgressView()'s projection of the same request (null when the strip shows no live progress).
|
|
5888
|
+
* ctx: { contactLost, chatAsking (AI Chat shows a question or approval on this read's conversation), pendingSave }.
|
|
5889
|
+
*/
|
|
5890
|
+
function filterFloState(req, view, ctx) {
|
|
5891
|
+
ctx = ctx || {};
|
|
5892
|
+
const off = (why) => ({ mode: 'off', why });
|
|
5893
|
+
if (!req || !view) return off('no-read');
|
|
5894
|
+
// Before Save, and while it holds unsaved edits, the stage is the person's own work: Flo stays off it.
|
|
5895
|
+
if (req.filterCheckpointCurrent !== true || ctx.pendingSave) return off('not-saved');
|
|
5896
|
+
if (ctx.contactLost) return off('contact-lost');
|
|
5897
|
+
const progress = req.steelProgress;
|
|
5898
|
+
const raw = progress && progress.status;
|
|
5899
|
+
if (raw === 'cancelled') return off('cancelled');
|
|
5900
|
+
const chat = req.chatConversation || null;
|
|
5901
|
+
const inChat = chat?.executionOwner === 'chat' && typeof chat.chatId === 'string' && !!chat.chatId;
|
|
5902
|
+
const code = req.attention?.code;
|
|
5903
|
+
// Only an asked question or approval counts: `needs-you` alone also means a read nobody linked to a chat,
|
|
5904
|
+
// a stopped run or an answer to read, and the progress view's own `waiting` also covers a stale record.
|
|
5905
|
+
const approval = code === 'approval' || chat?.chatState === 'awaiting-approval';
|
|
5906
|
+
const asked = code === 'ai-question' || approval || ctx.chatAsking === true;
|
|
5907
|
+
const chatWorking = inChat && (chat.chatState === 'starting' || chat.chatState === 'running');
|
|
5908
|
+
// The AI writes `waiting`, then asks or stops. A conversation still running past it has moved on (the person
|
|
5909
|
+
// pressed Save and FloLess continued the read) and the record is stale until the AI next writes it: not a question.
|
|
5910
|
+
const recordWaits = raw === 'waiting' && !chatWorking;
|
|
5911
|
+
if (recordWaits || asked) {
|
|
5912
|
+
const note = recordWaits ? progressText(progress.items.find((item) => item.state === 'waiting')?.note) : null;
|
|
5913
|
+
const question = code === 'ai-question' ? progressText(req.run?.question) : null;
|
|
5914
|
+
// AI Chat's own flag cannot tell a question from an approval, so alone it says neither.
|
|
5915
|
+
const text = note || question || (approval ? 'The AI is waiting for your approval.'
|
|
5916
|
+
: code === 'ai-question' ? 'The AI has asked you a question.' : 'The AI is waiting for you in AI Chat.');
|
|
5917
|
+
return { mode: 'waiting', text, chat: inChat };
|
|
5918
|
+
}
|
|
5919
|
+
if (raw !== 'active') return off('not-active');
|
|
5920
|
+
const looks = (Array.isArray(req.steelLooks) ? req.steelLooks : []).filter(floLookOk);
|
|
5921
|
+
const freshPictures = looks.some((l) => l.ageMs < FLO_FRESH_WORK_MS);
|
|
5922
|
+
// A record the AI has not rewritten for 8 minutes is stale, but pictures it asked for in the last two, or its
|
|
5923
|
+
// conversation still running, prove it is still at work (seen on a real read, #2926: tiles seconds old, sentence
|
|
5924
|
+
// 9 minutes old). Flo keeps going then, and says the sentence is the last one reported, the strip's own words.
|
|
5925
|
+
if (view.state !== 'active') {
|
|
5926
|
+
return freshPictures || chatWorking ? { mode: 'reading', now: view.now, looks, label: 'Last reported:' } : off('not-active');
|
|
5927
|
+
}
|
|
5928
|
+
// Pictures for this very read are proof of work even when the chat calls its turn busy elsewhere, which it
|
|
5929
|
+
// does whenever the person typed into the read's conversation and the read carried on.
|
|
5930
|
+
const working = freshPictures || !inChat || chatWorking;
|
|
5931
|
+
if (!working) return off('idle');
|
|
5932
|
+
return { mode: 'reading', now: view.now, looks };
|
|
5933
|
+
}
|
|
5934
|
+
|
|
5935
|
+
// Keeps the last read and view applyStageGating() painted (`syncFilterFlo.last`), so a chat question opening
|
|
5936
|
+
// between polls re-syncs at once.
|
|
5937
|
+
function syncFilterFlo(req, view) {
|
|
5938
|
+
syncFilterFlo.last = { req, view };
|
|
5939
|
+
const frame = frames.drawings;
|
|
5940
|
+
if (!frame || !frame.dataset.loaded) return;
|
|
5941
|
+
const chatId = req?.chatConversation?.chatId;
|
|
5942
|
+
const chatAsking = !!chatId && document.getElementById('ai-chat-shell')?.dataset.approvalPending === 'true'
|
|
5943
|
+
&& window.flolessChat?.currentChatId?.() === chatId;
|
|
5944
|
+
// `read` lets the page drop a picture another read asked for.
|
|
5945
|
+
const state = { ...filterFloState(req, view, { contactLost: revRequestsFailed, chatAsking, pendingSave: drawingFilterPendingSave() }), read: req?.id ?? null };
|
|
5946
|
+
try { frame.contentWindow?.flolessFilterFlo?.(state); }
|
|
5947
|
+
catch (err) {
|
|
5948
|
+
// A frame showing a browser error page is another origin; the next poll tells the reloaded page. Anything
|
|
5949
|
+
// else is a defect in Flo's own code: said once, not on every poll.
|
|
5950
|
+
if (err?.name !== 'SecurityError' && !syncFilterFlo.warned) { syncFilterFlo.warned = true; console.warn('Flo could not show the drawing read', err); }
|
|
5951
|
+
}
|
|
5952
|
+
}
|
|
5953
|
+
|
|
5870
5954
|
/** Revised drawing reads keep their own card; the strip owns every initial-read handoff it paints. */
|
|
5871
5955
|
function stageGuidanceOwnsSavedCheckpoint(req) {
|
|
5872
5956
|
return !!(req && isInitialRevisionRead(req) && (
|
|
@@ -6382,6 +6466,7 @@
|
|
|
6382
6466
|
const unavailableInitial = initialRead && lastRevState === 'unavailable';
|
|
6383
6467
|
const ownsProgress = waitingForInitial && stageGuidanceOwnsSavedCheckpoint(revCardReq);
|
|
6384
6468
|
const liveProgress = ownsProgress ? drawingProgressView(revCardReq, Date.now(), revRequestsFailed) : null;
|
|
6469
|
+
syncFilterFlo(liveProgress ? revCardReq : null, liveProgress);
|
|
6385
6470
|
if (ownsProgress && revCardReq?.steelProgress && !liveProgress) {
|
|
6386
6471
|
const revision = Number.isSafeInteger(revCardReq.steelProgress.revision)
|
|
6387
6472
|
? String(revCardReq.steelProgress.revision) : `invalid:${String(revCardReq.steelProgress.revision)}`;
|
|
@@ -16017,6 +16102,20 @@
|
|
|
16017
16102
|
// the Drawing Filter tab and the Model tab's tooltip all read that state, so repaint them now rather
|
|
16018
16103
|
// than at the next three-second poll — or never, on a step that has no poll running.
|
|
16019
16104
|
window.addEventListener('floless:filter-ai-changed', () => { if (current) applyStageGating(); });
|
|
16105
|
+
// #2926: a question or approval opening in AI Chat between polls moves the Drawing Filter's Flo to its waiting corner now.
|
|
16106
|
+
function resyncFilterFlo() {
|
|
16107
|
+
const last = syncFilterFlo.last;
|
|
16108
|
+
// Only the open project's read: between a project switch and its first poll, `last` is the project left.
|
|
16109
|
+
if (current && last?.req?.project === current.id) syncFilterFlo(last.req, last.view);
|
|
16110
|
+
}
|
|
16111
|
+
document.addEventListener('floless:chat-indicator', resyncFilterFlo);
|
|
16112
|
+
// #2926: Flo's "Answer in AI Chat" opens the read's own conversation, where the question is.
|
|
16113
|
+
window.addEventListener('floless:filter-flo-answer', () => {
|
|
16114
|
+
const chatId = syncFilterFlo.last?.req?.chatConversation?.chatId;
|
|
16115
|
+
if (!chatId) return;
|
|
16116
|
+
Promise.resolve().then(() => window.flolessChat.openConversation(chatId))
|
|
16117
|
+
.catch((err) => showFailureToast(err, { action: 'open the question in AI Chat' }));
|
|
16118
|
+
});
|
|
16020
16119
|
frames.drawings.addEventListener('load', () => {
|
|
16021
16120
|
requestAnimationFrame(() => {
|
|
16022
16121
|
reconcileDrawingRevisionRequestAfterLoad();
|
|
@@ -19680,9 +19779,13 @@
|
|
|
19680
19779
|
const validId = (id) => typeof id === 'string' && !!id && id.length <= 200;
|
|
19681
19780
|
// #2471: or one member an AI Chat answer cited, with the project identity it was cited in (checked at handover).
|
|
19682
19781
|
const member = !!target && !validId(target.jointId) && validId(target.memberId);
|
|
19683
|
-
|
|
19684
|
-
const
|
|
19685
|
-
|
|
19782
|
+
// #2874: or one RFI a chat message mentioned, shown on the project's RFIs step (in the editor, or the shell's own pane).
|
|
19783
|
+
const rfi = !!target && !validId(target.jointId) && !member && validId(target.rfiId) && /^RFI-\d{3,16}$/.test(target.rfiId);
|
|
19784
|
+
// Sentences say "the member was not shown", but "RFI-007 was not shown".
|
|
19785
|
+
const thing = member ? 'the member' : rfi ? target.rfiId : 'the connection';
|
|
19786
|
+
const again = member ? 'Show in the model' : rfi ? `${target.rfiId} in the chat` : 'Open in the model';
|
|
19787
|
+
const step = rfi ? 'rfis' : 'model';
|
|
19788
|
+
if (!target || !validId(target.projectId) || !(validId(target.jointId) || member || rfi)) throw connectionError(`That ${member ? 'member' : rfi ? 'RFI' : 'connection'} could not be opened. Open its project from Workspaces.`);
|
|
19686
19789
|
const mine = { id: `connection-${++connectionRequestSeq}`, page: null };
|
|
19687
19790
|
withdrawConnectionRequest(connectionRequest);
|
|
19688
19791
|
connectionRequest = mine;
|
|
@@ -19690,8 +19793,8 @@
|
|
|
19690
19793
|
// Once this call has ended, for any reason, a project change it started gives way before it lands.
|
|
19691
19794
|
let ended = false;
|
|
19692
19795
|
const stillWanted = () => !ended && !superseded();
|
|
19693
|
-
const stayedOutside = () => connectionError(`You stayed where you were, so
|
|
19694
|
-
const leftWorkspaces = () => connectionError(`You left Workspaces, so
|
|
19796
|
+
const stayedOutside = () => connectionError(`You stayed where you were, so ${thing} was not shown. Open the project from Workspaces, then press ${again} again.`);
|
|
19797
|
+
const leftWorkspaces = () => connectionError(`You left Workspaces, so ${thing} was not shown. Open the project from Workspaces, then press ${again} again.`);
|
|
19695
19798
|
const pause = () => new Promise((resolve) => setTimeout(resolve, 100));
|
|
19696
19799
|
/**
|
|
19697
19800
|
* Wait for a step of getting there, watched: a later click ends it at once. `bounded` adds the deadline,
|
|
@@ -19708,12 +19811,12 @@
|
|
|
19708
19811
|
await Promise.race([finished, pause()]);
|
|
19709
19812
|
if (done) { if (done.error) throw done.error; return done.value; }
|
|
19710
19813
|
if (superseded()) return { superseded: true };
|
|
19711
|
-
if (Date.now() >= bound) throw connectionError(`The project did not open in time, so
|
|
19814
|
+
if (Date.now() >= bound) throw connectionError(`The project did not open in time, so ${thing} was not shown. Open it from Workspaces, then press ${again} again.`);
|
|
19712
19815
|
}
|
|
19713
19816
|
};
|
|
19714
19817
|
// A project removed and made again under the same id is not the one the answer cited.
|
|
19715
19818
|
const citedElsewhere = () => validId(target.projectUuid) && String(current?.uuid || '').toLowerCase() !== target.projectUuid.toLowerCase();
|
|
19716
|
-
const citedGone = () => connectionError(`This project is no longer the one the answer cited, so
|
|
19819
|
+
const citedGone = () => connectionError(`This project is no longer the one ${rfi ? 'the message mentioned' : 'the answer cited'}, so ${thing} was not shown.`);
|
|
19717
19820
|
let until = Infinity;
|
|
19718
19821
|
// #2605: the document the model frame held before this call opened the project. Left for the Workspaces list,
|
|
19719
19822
|
// a project's editor page stays in the hidden frame, and openProject's reset of it lands only later: until
|
|
@@ -19723,13 +19826,16 @@
|
|
|
19723
19826
|
const interrupted = () => {
|
|
19724
19827
|
if (superseded()) return { superseded: true };
|
|
19725
19828
|
if (mode !== 'workspaces') throw leftWorkspaces();
|
|
19726
|
-
if (current?.id !== target.projectId) throw connectionError(`You moved to another project, so
|
|
19829
|
+
if (current?.id !== target.projectId) throw connectionError(`You moved to another project, so ${thing} was not shown.`);
|
|
19727
19830
|
// The project's stages kept the Model step locked, or the person went to another step: the step's
|
|
19728
19831
|
// own message says why, and there is nothing to wait for.
|
|
19729
|
-
|
|
19730
|
-
|
|
19832
|
+
// An RFI's step is RFIs, which in a steel project shows this same editor frame (and the editor may switch to it).
|
|
19833
|
+
const steps = rfi ? ['model', 'rfis'] : ['model'];
|
|
19834
|
+
if (!steps.includes(currentStep) && !(pendingPresenceStep && steps.includes(pendingPresenceStep.step))) {
|
|
19835
|
+
throw connectionError(rfi ? `The RFIs step is not open, so ${thing} was not shown. Open the RFIs step, then press ${again} again.`
|
|
19836
|
+
: `The Model step is not open, so ${thing} was not shown. Open the Model step, then press ${again} again.`);
|
|
19731
19837
|
}
|
|
19732
|
-
if (Date.now() >= until) throw connectionError(`The model did not open in time, so
|
|
19838
|
+
if (Date.now() >= until) throw connectionError(`The model did not open in time, so ${thing} was not shown. Open the Model step, then press ${again} again.`);
|
|
19733
19839
|
return null;
|
|
19734
19840
|
};
|
|
19735
19841
|
try {
|
|
@@ -19738,16 +19844,27 @@
|
|
|
19738
19844
|
if (mode !== 'workspaces') throw stayedOutside();
|
|
19739
19845
|
if (current?.id !== target.projectId) {
|
|
19740
19846
|
try { pageLeftBehind = frames.model.contentWindow?.document ?? null; } catch { pageLeftBehind = null; }
|
|
19741
|
-
const opened = await navigating(openProject(target.projectId,
|
|
19847
|
+
const opened = await navigating(openProject(target.projectId, step, { stillWanted }), true);
|
|
19742
19848
|
if (opened?.superseded || superseded()) return { superseded: true };
|
|
19743
19849
|
// openProject answers "stayed" for several causes (the person chose to stay, the project's folder is
|
|
19744
19850
|
// not available and its dialog is open, another navigation took over): say only what is certain.
|
|
19745
|
-
if (opened === STAYED_IN_PROJECT) throw connectionError(`That project did not open, so
|
|
19851
|
+
if (opened === STAYED_IN_PROJECT) throw connectionError(`That project did not open, so ${thing} was not shown. Open it from Workspaces to see why, then press ${again} again.`);
|
|
19746
19852
|
if (current?.id !== target.projectId) throw connectionError('That project could not be opened. Open it from Workspaces.');
|
|
19747
|
-
} else if (currentStep !==
|
|
19748
|
-
setStep(
|
|
19853
|
+
} else if (currentStep !== step) {
|
|
19854
|
+
setStep(step);
|
|
19855
|
+
}
|
|
19856
|
+
// #2874: a General project's RFIs are the shell's own pane (project-rfis.js), which shows the RFI itself.
|
|
19857
|
+
if (rfi && !wsApp()?.rfisInEditor) {
|
|
19858
|
+
if (citedElsewhere()) throw citedGone();
|
|
19859
|
+
if (typeof globalThis.flolessProjectRfis?.focus !== 'function') throw connectionError(`FloLess could not show ${thing} here. Open the RFIs step and find it there.`);
|
|
19860
|
+
const outcome = await navigating(Promise.resolve(globalThis.flolessProjectRfis.focus(target.projectId, target.rfiId)), true);
|
|
19861
|
+
if (outcome?.superseded || superseded()) return { superseded: true };
|
|
19862
|
+
if (mode !== 'workspaces' || current?.id !== target.projectId) throw connectionError(`You moved to another project, so ${thing} was not shown.`);
|
|
19863
|
+
// The list may finish loading after the person has moved on: what it showed is out of sight, so say that.
|
|
19864
|
+
if (currentStep !== 'rfis') throw connectionError(`You moved to another step, so ${thing} was not shown. Press ${again} again to see it.`);
|
|
19865
|
+
return outcome && typeof outcome === 'object' ? { ...outcome } : { ok: false, said: `FloLess could not show ${thing}. Open the RFIs step and find it there.` };
|
|
19749
19866
|
}
|
|
19750
|
-
if (!frames.model.dataset.want) throw connectionError(`This project has no model editor to show
|
|
19867
|
+
if (!frames.model.dataset.want) throw connectionError(`This project has no model editor to show ${thing} in.`);
|
|
19751
19868
|
// The editor's deadline starts once the person is in the project.
|
|
19752
19869
|
until = Date.now() + CONNECTION_FRAME_WAIT_MS;
|
|
19753
19870
|
let answer = null, settled = null, page = null, doc = null;
|
|
@@ -19760,8 +19877,8 @@
|
|
|
19760
19877
|
if (superseded()) return { superseded: true };
|
|
19761
19878
|
// The Model step may have been left after the selection, but not Workspaces: hidden, it shows nothing.
|
|
19762
19879
|
if (mode !== 'workspaces') throw leftWorkspaces();
|
|
19763
|
-
if (current?.id !== target.projectId) throw connectionError(`You moved to another project, so
|
|
19764
|
-
if (frames.model.contentWindow !== page || page.document !== doc) throw connectionError(`The model reloaded, so
|
|
19880
|
+
if (current?.id !== target.projectId) throw connectionError(`You moved to another project, so ${thing} was not shown.`);
|
|
19881
|
+
if (frames.model.contentWindow !== page || page.document !== doc) throw connectionError(`The model reloaded, so ${thing} was not shown. Press ${again} again.`);
|
|
19765
19882
|
const outcome = settled.outcome;
|
|
19766
19883
|
return outcome && typeof outcome === 'object' ? { ...outcome } : { ok: false, said: notTaken };
|
|
19767
19884
|
}
|
|
@@ -19775,7 +19892,7 @@
|
|
|
19775
19892
|
if (citedElsewhere()) throw citedGone();
|
|
19776
19893
|
// The frame's window survives a reload; its DOCUMENT does not. That is what tells a reload apart.
|
|
19777
19894
|
page = child; doc = child.document;
|
|
19778
|
-
answer = child.flolessEditorFocus(member ? { memberId: target.memberId, requestId: mine.id } : { jointId: target.jointId, requestId: mine.id,
|
|
19895
|
+
answer = child.flolessEditorFocus(member ? { memberId: target.memberId, requestId: mine.id } : rfi ? { rfiId: target.rfiId, requestId: mine.id } : { jointId: target.jointId, requestId: mine.id,
|
|
19779
19896
|
// #2450: the readiness card's "Raise an RFI" also opens the editor's review dialog for it.
|
|
19780
19897
|
...(target.raiseRfi === true ? { raiseRfi: true } : {}), ...(validId(target.checkId) ? { checkId: target.checkId } : {}) });
|
|
19781
19898
|
if (!answer || typeof answer.then !== 'function') return { ok: false, said: notTaken };
|
|
@@ -19786,7 +19903,7 @@
|
|
|
19786
19903
|
});
|
|
19787
19904
|
}
|
|
19788
19905
|
} else if (child !== page || child.document !== doc) {
|
|
19789
|
-
throw connectionError(`The model reloaded, so
|
|
19906
|
+
throw connectionError(`The model reloaded, so ${thing} was not shown. Press ${again} again.`);
|
|
19790
19907
|
}
|
|
19791
19908
|
await pause();
|
|
19792
19909
|
}
|