@floless/app 0.164.0 → 0.166.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 +24056 -21153
- package/dist/schemas/drawing-check.profile.v1.schema.json +3 -1
- package/dist/skills/floless-app-knowledge/SKILL.md +8 -1
- package/dist/skills/floless-app-rfi/SKILL.md +31 -6
- package/dist/skills/floless-app-steel-model/SKILL.md +4 -1
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +18 -16
- package/dist/skills/floless-app-steel-takeoff/references/elevation-registration.md +15 -1
- package/dist/templates/college-phase-exporter.flo +42 -16
- package/dist/templates/screenshot-to-saved-settings.flo +12 -2
- package/dist/web/app.css +71 -6
- package/dist/web/aware.js +27 -10
- package/dist/web/chat-question-card.js +3 -1
- package/dist/web/chat.css +11 -1
- package/dist/web/chat.js +533 -59
- package/dist/web/commands-drawing-check.js +1 -0
- package/dist/web/commands-shell.js +107 -13
- package/dist/web/commands-steel.js +22 -2
- package/dist/web/drawing-check-editor.html +4 -0
- package/dist/web/drawing-check-editor.js +82 -2
- package/dist/web/index.html +6 -0
- package/dist/web/project-history.js +32 -9
- package/dist/web/project-modules.js +5 -0
- package/dist/web/project-rfis.js +219 -25
- package/dist/web/steel-ai-marks.js +128 -1
- package/dist/web/steel-editor.html +710 -35
- package/dist/web/steel-model-v2-projection.js +26 -20
- package/dist/web/workspaces.js +283 -45
- package/package.json +3 -2
package/dist/web/chat.js
CHANGED
|
@@ -210,6 +210,8 @@
|
|
|
210
210
|
if (response.status === 402 && body && typeof body === 'object') error.body = body;
|
|
211
211
|
// #2061: who holds a busy project, so the person can be asked: wait, stop it, or open it.
|
|
212
212
|
error.holder = body?.holder && typeof body.holder === 'object' ? body.holder : null;
|
|
213
|
+
// #2470 R6.7b: a project intake from Add a module whose link the General project can't take is a choice, not a refusal.
|
|
214
|
+
error.linkChoice = body?.linkChoice === true;
|
|
213
215
|
error.status = response.status;
|
|
214
216
|
// #1890 PR 3b: the conversation moved — wherever this was asked from, the open tab follows it.
|
|
215
217
|
if (error.code === 'chat-moved' && body?.to?.chatId) {
|
|
@@ -2204,6 +2206,58 @@
|
|
|
2204
2206
|
return out.join('');
|
|
2205
2207
|
}
|
|
2206
2208
|
|
|
2209
|
+
/**
|
|
2210
|
+
* #3003: a Knowledge page as a person reads it: its markdown rendered, and each `[[slug]]` link shown as the linked
|
|
2211
|
+
* page's title (`links`, read by the server from the same version), a button that opens it. A link to a page that
|
|
2212
|
+
* version does not hold reads as plain words, never as brackets and a slug. Links in code stay as written.
|
|
2213
|
+
*/
|
|
2214
|
+
function knowledgePageHtml(body, links, commandId = 'shell.knowledge-page-link') {
|
|
2215
|
+
const titles = links && typeof links === 'object' ? links : {};
|
|
2216
|
+
const host = document.createElement('div');
|
|
2217
|
+
host.innerHTML = markdownHtml(String(body ?? ''));
|
|
2218
|
+
const walker = document.createTreeWalker(host, NodeFilter.SHOW_TEXT);
|
|
2219
|
+
const texts = [];
|
|
2220
|
+
for (let node = walker.nextNode(); node; node = walker.nextNode()) {
|
|
2221
|
+
if (/\[\[[^\]]+\]\]/.test(node.nodeValue) && !node.parentElement?.closest('code, pre, a, button')) texts.push(node);
|
|
2222
|
+
}
|
|
2223
|
+
for (const node of texts) {
|
|
2224
|
+
const parts = [];
|
|
2225
|
+
let last = 0;
|
|
2226
|
+
for (const match of node.nodeValue.matchAll(/(!?)\[\[([^\]]+)\]\]/g)) {
|
|
2227
|
+
parts.push(document.createTextNode(node.nodeValue.slice(last, match.index)));
|
|
2228
|
+
const [target, alias] = match[2].split('|');
|
|
2229
|
+
const slug = (target.split('#')[0] ?? '').trim();
|
|
2230
|
+
// A title: the page, by name. null: the server looked, and this version has no such page. No entry: not
|
|
2231
|
+
// looked at (past its cap, or unreadable), so it stays a link and nothing is said about whether the page exists.
|
|
2232
|
+
const known = slug && Object.prototype.hasOwnProperty.call(titles, slug);
|
|
2233
|
+
const title = known && typeof titles[slug] === 'string' ? titles[slug] : '';
|
|
2234
|
+
const words = (alias ?? '').trim() || title || slug.replace(/-/g, ' ');
|
|
2235
|
+
if (!slug) {
|
|
2236
|
+
// A link to a heading of the same page ([[#detail]]) names no other page: its words, with no claim either way.
|
|
2237
|
+
parts.push(document.createTextNode((alias ?? '').trim() || target.replace(/^#/, '').trim()));
|
|
2238
|
+
} else if (!(known && titles[slug] === null)) {
|
|
2239
|
+
const link = button(words, commandId, 'kb-wikilink');
|
|
2240
|
+
link.dataset.kbLink = slug;
|
|
2241
|
+
link.dataset.commandInstanceLabel = title || words;
|
|
2242
|
+
link.dataset.tip = title ? `Open the page “${title}”` : 'Open the linked page';
|
|
2243
|
+
// A link shown by another name still says which page it opens; its own words come first.
|
|
2244
|
+
if (title && words !== title) link.setAttribute('aria-label', `${words}, opens the page ${title}`);
|
|
2245
|
+
parts.push(link);
|
|
2246
|
+
} else {
|
|
2247
|
+
const missing = Object.assign(document.createElement('span'), { className: 'kb-wikilink missing', textContent: words });
|
|
2248
|
+
missing.dataset.tip = 'This page is not in this version of the Knowledge';
|
|
2249
|
+
missing.setAttribute('aria-label', `${words} (not in this version of the Knowledge)`);
|
|
2250
|
+
missing.setAttribute('role', 'note');
|
|
2251
|
+
parts.push(missing);
|
|
2252
|
+
}
|
|
2253
|
+
last = match.index + match[0].length;
|
|
2254
|
+
}
|
|
2255
|
+
parts.push(document.createTextNode(node.nodeValue.slice(last)));
|
|
2256
|
+
node.replaceWith(...parts);
|
|
2257
|
+
}
|
|
2258
|
+
return host.innerHTML;
|
|
2259
|
+
}
|
|
2260
|
+
|
|
2207
2261
|
function markdownHtml(value, depth = 0) {
|
|
2208
2262
|
const source = String(value ?? '').replace(/\r\n?/g, '\n');
|
|
2209
2263
|
// A quote or a list item re-enters this renderer for its own content, one level down. Past a
|
|
@@ -2340,6 +2394,16 @@
|
|
|
2340
2394
|
chatId: state.chat?.chatId ?? null, owner: ownerQuery(), ownerObject: state.scope?.owner ?? null });
|
|
2341
2395
|
});
|
|
2342
2396
|
}
|
|
2397
|
+
// #2999: a claim the answer marks that no citation entry holds is a claim with no source, never dropped. Recorded
|
|
2398
|
+
// against the answer itself, it gets the same three ways on as an entry FloLess could not match.
|
|
2399
|
+
const claims = answerClaims(turnId);
|
|
2400
|
+
for (const anchor of claims?.anchors ?? []) {
|
|
2401
|
+
if (byAnchor.has(anchor)) continue;
|
|
2402
|
+
order.push(anchor);
|
|
2403
|
+
byAnchor.set(anchor, { anchor, entry: { anchor, kind: null, status: 'unresolved', label: 'No source given', read: 'no', bare: true,
|
|
2404
|
+
reason: 'the AI marked this claim but named no source for it' },
|
|
2405
|
+
citationId: claims.answerId, index: -1, number: 0, chatId: state.chat?.chatId ?? null, owner: ownerQuery(), ownerObject: state.scope?.owner ?? null });
|
|
2406
|
+
}
|
|
2343
2407
|
for (const record of citationAssumptions(turnId)) { const row = byAnchor.get(record.anchor); if (row) row.assumption = record; }
|
|
2344
2408
|
// #2643: the sources the person chose. The latest is the claim's current one while the AI has given it none; the
|
|
2345
2409
|
// earlier ones are its history. A chosen source is numbered like a cited one: the "?" becomes a number.
|
|
@@ -2349,15 +2413,107 @@
|
|
|
2349
2413
|
row.choices = made;
|
|
2350
2414
|
if (row.entry.status !== 'resolved') row.choice = made[made.length - 1];
|
|
2351
2415
|
}
|
|
2416
|
+
// #3000: an entry the answer never marks is not a claim: it is listed apart as "Also consulted", unnumbered, and
|
|
2417
|
+
// never offered as an assumption. Without answer text (none recorded yet) nothing tells the two apart. One the
|
|
2418
|
+
// person already decided on stays with the claims: their recorded decision is never hidden.
|
|
2419
|
+
const claimed = (anchor) => claims.anchors.includes(anchor) || Boolean(byAnchor.get(anchor).assumption || byAnchor.get(anchor).choices?.length);
|
|
2420
|
+
const used = claims ? order.filter(claimed) : order;
|
|
2421
|
+
const unused = claims ? order.filter((anchor) => !claimed(anchor)) : [];
|
|
2352
2422
|
let n = 0;
|
|
2353
|
-
for (const anchor of order) { const row = byAnchor.get(anchor); row.number = row.entry.status === 'resolved' || row.choice ? ++n : 0; }
|
|
2354
|
-
return { byAnchor, order };
|
|
2423
|
+
for (const anchor of order) { const row = byAnchor.get(anchor); row.number = used.includes(anchor) && (row.entry.status === 'resolved' || row.choice) ? ++n : 0; }
|
|
2424
|
+
return { byAnchor, order: used, unused };
|
|
2425
|
+
}
|
|
2426
|
+
|
|
2427
|
+
/**
|
|
2428
|
+
* #2999/#3000: the claims an answer marks, read with the same parse that puts its markers in it (so a directive in code
|
|
2429
|
+
* marks nothing), and the answer event a claim with no citation entry is recorded against. Null when the turn has no
|
|
2430
|
+
* answer text.
|
|
2431
|
+
*/
|
|
2432
|
+
function answerClaims(turnId) {
|
|
2433
|
+
const answer = answerText(turnId);
|
|
2434
|
+
if (!answer) return null;
|
|
2435
|
+
const held = inlineSlots;
|
|
2436
|
+
let slots = [];
|
|
2437
|
+
inlineSlots = [];
|
|
2438
|
+
try { for (const block of answer.blocks) markdownHtml(block); slots = inlineSlots; }
|
|
2439
|
+
finally { inlineSlots = held; }
|
|
2440
|
+
const anchors = [];
|
|
2441
|
+
for (const slot of slots) if (slot.kind === 'cite' && !anchors.includes(slot.anchor)) anchors.push(slot.anchor);
|
|
2442
|
+
return { anchors, answerId: answer.answerId };
|
|
2443
|
+
}
|
|
2444
|
+
|
|
2445
|
+
/** #2999: an answer's text as the feed shows it, block by block (`answerBlocks`). Null when the turn has no answer text. */
|
|
2446
|
+
function answerText(turnId) {
|
|
2447
|
+
const answer = turnId ? answerBlocks(state.events, turnId, payloadText) : null;
|
|
2448
|
+
return answer?.blocks.length ? answer : null;
|
|
2449
|
+
}
|
|
2450
|
+
|
|
2451
|
+
/**
|
|
2452
|
+
* #2999: the blocks of text a turn's answer shows as, grouped exactly as paintEvents groups them: streamed pieces of
|
|
2453
|
+
* one turn joined (a marker split across two pieces is one marker), a paragraph break after a tool between them, and
|
|
2454
|
+
* a block ended by whatever the feed shows in the answer's place (a question, a whole message, a run's first line,
|
|
2455
|
+
* anything it does not hold under the answer) or by a held receipt of another turn. A whole message is its own block.
|
|
2456
|
+
* The server reads claims with the same function (`answerBlocks` in server/chat-store.ts); a test keeps the two equal
|
|
2457
|
+
* and both equal to what paintEvents draws. Pure: `words` reads an event's text. Where a receipt turns out to draw
|
|
2458
|
+
* nothing (a hidden card, an empty row, a claims row) it is still read as held: that only matters when another
|
|
2459
|
+
* turn's event falls between two pieces of one answer.
|
|
2460
|
+
*/
|
|
2461
|
+
function answerBlocks(events, turnId, words) {
|
|
2462
|
+
const runLine = (event) => event.type === 'tool' && ['agent', 'guide', 'instructor'].includes(event.payload?.tool);
|
|
2463
|
+
const blocks = [];
|
|
2464
|
+
let answerId = null; let assistant = null; let held = false; let heldTurn;
|
|
2465
|
+
const flush = () => { if (assistant && assistant.turnId === turnId && assistant.text) blocks.push(assistant.text); assistant = null; };
|
|
2466
|
+
const hold = (event) => { if (!held) { held = true; heldTurn = event.turnId; } };
|
|
2467
|
+
// A turn's Sources row is drawn at its last citation only; an earlier one holds nothing.
|
|
2468
|
+
const lastCitation = new Map();
|
|
2469
|
+
for (const event of events) if (event.type === 'citation') lastCitation.set(event.turnId, event);
|
|
2470
|
+
for (const event of events) {
|
|
2471
|
+
if (event.type === 'citation-assumption' || event.type === 'citation-choice') continue;
|
|
2472
|
+
if (event.type === 'user-message' || (held && event.turnId !== heldTurn)) { flush(); held = false; }
|
|
2473
|
+
const text = words(event);
|
|
2474
|
+
if (event.type === 'assistant-message' && event.payload?.delta) {
|
|
2475
|
+
if (assistant && assistant.turnId === event.turnId) {
|
|
2476
|
+
if (assistant.afterTool && text) {
|
|
2477
|
+
if (assistant.text && !/\n\s*$/.test(assistant.text) && !/^\s*\n/.test(text)) assistant.text += '\n\n';
|
|
2478
|
+
assistant.afterTool = false;
|
|
2479
|
+
}
|
|
2480
|
+
assistant.text += text;
|
|
2481
|
+
} else { flush(); assistant = { turnId: event.turnId, text, afterTool: false }; }
|
|
2482
|
+
if (event.turnId === turnId && text) answerId = event.eventId;
|
|
2483
|
+
continue;
|
|
2484
|
+
}
|
|
2485
|
+
if (assistant && event.turnId === assistant.turnId && event.type === 'tool' && !event.payload?.plain && !runLine(event)) assistant.afterTool = true;
|
|
2486
|
+
if (event.type === 'tool' && event.payload?.plain === true && !runLine(event) && typeof event.payload?.message === 'string' && event.payload.message) { hold(event); continue; }
|
|
2487
|
+
if (runLine(event) && typeof event.payload?.message === 'string') { flush(); continue; }
|
|
2488
|
+
if (ANSWER_UPDATES.has(event.type)) continue;
|
|
2489
|
+
if (ANSWER_RECEIPTS.has(event.type)) { if (event.type !== 'citation' || lastCitation.get(event.turnId) === event) hold(event); continue; }
|
|
2490
|
+
if (['tool', 'usage', 'attachment', 'compaction', 'state'].includes(event.type)) continue;
|
|
2491
|
+
flush();
|
|
2492
|
+
if (event.type === 'assistant-message' && event.turnId === turnId && text) { blocks.push(text); answerId = event.eventId; }
|
|
2493
|
+
}
|
|
2494
|
+
flush();
|
|
2495
|
+
return { blocks, answerId };
|
|
2496
|
+
}
|
|
2497
|
+
// What paintEvents holds under an answer (receipts) or skips (updates to a card it already drew).
|
|
2498
|
+
const ANSWER_RECEIPTS = new Set(['connection-proposal', 'connection-check', 'next-move', 'action-proposal', 'action-call', 'view-command',
|
|
2499
|
+
'citation', 'knowledge-citation', 'place', 'chat-subjects', 'evidence-read', 'filter-proposal']);
|
|
2500
|
+
const ANSWER_UPDATES = new Set(['connection-proposal-update', 'view-command-update', 'next-move-update', 'action-proposal-update']);
|
|
2501
|
+
|
|
2502
|
+
/**
|
|
2503
|
+
* #2999: whether a person's record names this claim: a citation of the answer's turn holding the anchor, or (a claim the
|
|
2504
|
+
* AI cited nothing for) one of that turn's answer events, whose text marks the anchor. The server's rule (`claimHolder`).
|
|
2505
|
+
*/
|
|
2506
|
+
function claimHeld(citationId, turnId, anchor) {
|
|
2507
|
+
const held = state.events.find((row) => row.eventId === citationId);
|
|
2508
|
+
if (!held || held.turnId !== turnId) return false;
|
|
2509
|
+
if (held.type === 'citation') return (held.payload?.entries ?? []).some((entry) => entry?.anchor === anchor);
|
|
2510
|
+
return held.type === 'assistant-message' && (answerText(turnId)?.blocks ?? []).some((block) => block.includes(`:cite[${anchor}]`));
|
|
2355
2511
|
}
|
|
2356
2512
|
|
|
2357
2513
|
/**
|
|
2358
2514
|
* #2643: the sources the person chose for this answer's claims, by anchor, in the order made — the server's validity
|
|
2359
|
-
* rule (`validCitationChoices`): every field the route writes, through the same checks, and
|
|
2360
|
-
*
|
|
2515
|
+
* rule (`validCitationChoices`): every field the route writes, through the same checks, and what it names holds the
|
|
2516
|
+
* claim (`claimHeld`). An invalid row is skipped, so it can never stand in for the person's choice.
|
|
2361
2517
|
*/
|
|
2362
2518
|
function citationChoices(turnId) {
|
|
2363
2519
|
const out = new Map();
|
|
@@ -2371,8 +2527,7 @@
|
|
|
2371
2527
|
|| !citeText(p.chosenBy, 200) || !citeText(p.chosenAt, 40) || Number.isNaN(Date.parse(p.chosenAt)) || p.via !== 'chip') continue;
|
|
2372
2528
|
const source = chosenSourceOf(p.source);
|
|
2373
2529
|
if (!source) continue;
|
|
2374
|
-
|
|
2375
|
-
if (!cited || cited.turnId !== turnId || !(cited.payload?.entries ?? []).some((entry) => entry?.anchor === p.anchor)) continue;
|
|
2530
|
+
if (!claimHeld(p.citationId, turnId, p.anchor)) continue;
|
|
2376
2531
|
const made = out.get(p.anchor) ?? [];
|
|
2377
2532
|
made.push({ eventId: event.eventId, anchor: p.anchor, chosenBy: p.chosenBy, chosenAt: p.chosenAt, source });
|
|
2378
2533
|
out.set(p.anchor, made);
|
|
@@ -2430,7 +2585,7 @@
|
|
|
2430
2585
|
|
|
2431
2586
|
/**
|
|
2432
2587
|
* #2642: the person's "go on with this as an assumption" on this answer's claims — the server's validity rule
|
|
2433
|
-
* (`liveCitationAssumptions`):
|
|
2588
|
+
* (`liveCitationAssumptions`): what it names holds the claim (`claimHeld`); the first record per claim wins.
|
|
2434
2589
|
*/
|
|
2435
2590
|
function citationAssumptions(turnId) {
|
|
2436
2591
|
const out = new Map();
|
|
@@ -2444,9 +2599,9 @@
|
|
|
2444
2599
|
if (p.turnId !== turnId || typeof p.turnId !== 'string' || !uuid.test(p.turnId) || typeof p.citationId !== 'string' || !uuid.test(p.citationId)
|
|
2445
2600
|
|| typeof p.anchor !== 'string' || !CITE_ANCHOR.test(p.anchor) || out.has(p.anchor) || !(p.claim === null || text(p.claim, 300))
|
|
2446
2601
|
|| !text(p.assumedBy, 200) || !text(p.assumedAt, 40) || Number.isNaN(Date.parse(p.assumedAt)) || p.via !== 'chip') continue;
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
out.set(p.anchor, { anchor: p.anchor, assumedBy: p.assumedBy, assumedAt: p.assumedAt });
|
|
2602
|
+
if (!claimHeld(p.citationId, turnId, p.anchor)) continue;
|
|
2603
|
+
// #3000: the claim's own words are kept with it, so the record always says which claim it is about.
|
|
2604
|
+
out.set(p.anchor, { anchor: p.anchor, claim: p.claim, assumedBy: p.assumedBy, assumedAt: p.assumedAt });
|
|
2450
2605
|
}
|
|
2451
2606
|
return [...out.values()];
|
|
2452
2607
|
}
|
|
@@ -2537,10 +2692,15 @@
|
|
|
2537
2692
|
marker.dataset.turnId = turnId || '';
|
|
2538
2693
|
marker.dataset.anchor = spec.anchor;
|
|
2539
2694
|
const assumed = !sourced && row?.assumption ? row.assumption : null;
|
|
2540
|
-
|
|
2695
|
+
// #2930: the AI named a member that exists the wrong way: its reference to correct, not a claim without a source.
|
|
2696
|
+
const misnamed = !sourced && !assumed && referenceProblem(row?.entry);
|
|
2697
|
+
const label = resolved ? citationLabel(row.entry) : chosen ? citationLabel(chosenViewRow(row, chosen).entry) : assumed ? 'assumption, no source'
|
|
2698
|
+
: misnamed ? 'source needs correcting' : 'no source';
|
|
2541
2699
|
// No citation for this anchor on this page is "none recorded", not "none found": the AI may have given none, or the
|
|
2542
2700
|
// record has not reached this page yet.
|
|
2543
2701
|
const missing = assumed ? `No source. Assumed by ${assumedWho(assumed)} on ${assumedWhen(assumed)}`
|
|
2702
|
+
: misnamed ? 'Source needs correcting: the member exists, but the AI named it wrongly'
|
|
2703
|
+
: row?.entry.bare ? 'The AI gave no source for this claim'
|
|
2544
2704
|
: row ? 'No source was found for this claim' : 'No source is recorded for this claim';
|
|
2545
2705
|
if (assumed) marker.classList.add('assumed');
|
|
2546
2706
|
if (chosen) marker.classList.add('chosen');
|
|
@@ -2560,7 +2720,7 @@
|
|
|
2560
2720
|
// The person's decision, beside the "?" that stays: it is still not a source. A solid edge tells it from the AI's own tag.
|
|
2561
2721
|
const tag = document.createElement('span'); tag.className = 'ai-chat-assume by-person';
|
|
2562
2722
|
tag.textContent = 'Assumption';
|
|
2563
|
-
tag.dataset.tip = `${assumedWho(assumed) === 'you' ? 'You' : assumedWho(assumed)}
|
|
2723
|
+
tag.dataset.tip = `${assumedWho(assumed) === 'you' ? 'You' : assumedWho(assumed)} recorded this as an assumption (${assumedWhen(assumed)}). It has no source.`;
|
|
2564
2724
|
marker.after(tag);
|
|
2565
2725
|
}
|
|
2566
2726
|
}
|
|
@@ -2578,12 +2738,134 @@
|
|
|
2578
2738
|
}
|
|
2579
2739
|
}
|
|
2580
2740
|
|
|
2741
|
+
const ASSUME_LABEL = 'Record as an assumption';
|
|
2742
|
+
/** #2930: the problems that mean the AI named a member that exists the wrong way (server CITATION_REFERENCE_PROBLEMS). */
|
|
2743
|
+
const REFERENCE_WORDS = {
|
|
2744
|
+
'id-as-mark': 'The AI gave this member’s internal ID where its mark should be. The member exists, but the reference needs correcting.',
|
|
2745
|
+
'wrong-mark': 'The AI named a mark that does not match this member. The member exists, but the reference needs correcting.',
|
|
2746
|
+
'id-spelling': 'The AI misspelled this member’s ID. The member exists, but the reference needs correcting.',
|
|
2747
|
+
ambiguous: 'The AI’s reference matches more than one member, so it has to say which one it meant.',
|
|
2748
|
+
};
|
|
2749
|
+
function referenceProblem(entry) {
|
|
2750
|
+
return entry?.status === 'unresolved' && entry.kind === 'member' && Object.hasOwn(REFERENCE_WORDS, entry.problem) ? entry.problem : null;
|
|
2751
|
+
}
|
|
2752
|
+
function answerRunning(turnId) {
|
|
2753
|
+
return !!turnId && ['running', 'awaiting-approval'].includes(state.chat?.state) && state.chat?.activeTurn?.turnId === turnId;
|
|
2754
|
+
}
|
|
2755
|
+
|
|
2756
|
+
/**
|
|
2757
|
+
* #2930: what a chip's action did, kept across repaints for this window: "Saved." until the person's next message
|
|
2758
|
+
* goes (a follow-up included), "Sent." for good. Keyed by conversation, answer and claim.
|
|
2759
|
+
*/
|
|
2760
|
+
const citationNotes = new Map();
|
|
2761
|
+
const citationNoteKey = (row, turnId) => `${row.chatId}\u0000${turnId}\u0000${row.anchor}`;
|
|
2762
|
+
const messagesSent = () => state.events.filter((event) => event.type === 'user-message').length;
|
|
2763
|
+
function noteCitation(row, turnId, note) {
|
|
2764
|
+
citationNotes.set(citationNoteKey(row, turnId), { ...note, messages: messagesSent() });
|
|
2765
|
+
}
|
|
2766
|
+
function citationNote(row, turnId) {
|
|
2767
|
+
const note = citationNotes.get(citationNoteKey(row, turnId));
|
|
2768
|
+
if (!note || (note.untilNextMessage && messagesSent() !== note.messages)) return null;
|
|
2769
|
+
const line = document.createElement('span'); line.className = `ai-chat-source-note${note.warn ? ' warn' : ''}`; line.setAttribute('role', 'status');
|
|
2770
|
+
line.textContent = note.text;
|
|
2771
|
+
return line;
|
|
2772
|
+
}
|
|
2773
|
+
|
|
2774
|
+
/**
|
|
2775
|
+
* #2930: the AI named a member that exists the wrong way (its id as a mark, a mark it does not carry, a misspelt id, or
|
|
2776
|
+
* a mark several members match). It is the AI's to correct, so this never leads with "No source" and never offers an
|
|
2777
|
+
* assumption. While the answer runs, the AI has already been told what to fix; once it has ended, "Ask the AI to
|
|
2778
|
+
* correct it" sends one message now. The earlier answer stays as it was: its citations belong to it.
|
|
2779
|
+
*/
|
|
2780
|
+
function referenceChip(chip, turnId, row, choose) {
|
|
2781
|
+
const entry = row.entry;
|
|
2782
|
+
chip.classList.add('unresolved', 'misnamed');
|
|
2783
|
+
const cited = document.createElement('span'); cited.className = 'ai-chat-source-cited';
|
|
2784
|
+
cited.textContent = entry.label;
|
|
2785
|
+
cited.dataset.tip = 'What the AI cited';
|
|
2786
|
+
const why = document.createElement('span'); why.className = 'ai-chat-source-why';
|
|
2787
|
+
why.textContent = REFERENCE_WORDS[entry.problem];
|
|
2788
|
+
chip.append(cited, why);
|
|
2789
|
+
const done = citationNote(row, turnId);
|
|
2790
|
+
if (done) { chip.append(done); return chip; }
|
|
2791
|
+
const status = document.createElement('span'); status.className = 'ai-chat-source-note'; status.setAttribute('role', 'status');
|
|
2792
|
+
const asking = correcting.get(citationNoteKey(row, turnId));
|
|
2793
|
+
if (answerRunning(turnId) && !asking) {
|
|
2794
|
+
status.textContent = 'The answer is still running. The AI has been told exactly what to fix.';
|
|
2795
|
+
chip.append(status);
|
|
2796
|
+
return chip;
|
|
2797
|
+
}
|
|
2798
|
+
status.classList.add('warn');
|
|
2799
|
+
status.textContent = asking?.failed || 'The answer ended without correcting this. Ask the AI to answer again with the reference fixed.';
|
|
2800
|
+
const fix = button(asking?.sending ? 'Sending…' : 'Ask the AI to correct it', 'shell.chat-cite-correct', 'ai-chat-source-action');
|
|
2801
|
+
fix.dataset.tip = 'Sends a message now asking the AI to answer again with this reference corrected. This answer stays as it is';
|
|
2802
|
+
if (asking?.sending) {
|
|
2803
|
+
fix.setAttribute('aria-busy', 'true'); fix.setAttribute('aria-disabled', 'true');
|
|
2804
|
+
fix.dataset.blockedReason = 'FloLess is sending this request to the AI';
|
|
2805
|
+
}
|
|
2806
|
+
fix.addEventListener('click', () => askToCorrect(row, turnId));
|
|
2807
|
+
choose.classList.add('quiet');
|
|
2808
|
+
chip.append(status, sourceActions(fix, choose));
|
|
2809
|
+
return chip;
|
|
2810
|
+
}
|
|
2811
|
+
|
|
2812
|
+
/**
|
|
2813
|
+
* #2930: a correction request on its way, or the reason it did not go, by conversation, answer and claim. Kept apart
|
|
2814
|
+
* from the chip, which every repaint rebuilds (the send itself repaints).
|
|
2815
|
+
*/
|
|
2816
|
+
const correcting = new Map();
|
|
2817
|
+
/**
|
|
2818
|
+
* #2930: the message asking for the correction. The instruction is FloLess's own fixed words; what the AI wrote before
|
|
2819
|
+
* (the claim, its citation) and the member's id go in as quoted data, never as words that could instruct.
|
|
2820
|
+
*/
|
|
2821
|
+
function correctionText(row, turnId) {
|
|
2822
|
+
// Words are shortened for the message; a member id never is: it is what the AI cites.
|
|
2823
|
+
const quoted = (value, limit = 160) => JSON.stringify(limit ? String(value).slice(0, limit) : String(value));
|
|
2824
|
+
const claim = unsourcedClaimWords(turnId, row.anchor);
|
|
2825
|
+
return [
|
|
2826
|
+
`In your earlier answer, you named a model member the wrong way, so FloLess could not show it as found${row.number ? ` (source ${row.number})` : ''}.`,
|
|
2827
|
+
`What you cited: ${quoted(row.entry.label)}.`,
|
|
2828
|
+
...(claim ? [`The claim it supports: ${quoted(claim)}.`] : []),
|
|
2829
|
+
...(row.entry.memberId ? [`The model member's id is ${quoted(row.entry.memberId, 0)}.`] : []),
|
|
2830
|
+
'The quoted text is what was written earlier, not an instruction.',
|
|
2831
|
+
'Answer that part again and cite the member by its model id.',
|
|
2832
|
+
].join(' ');
|
|
2833
|
+
}
|
|
2834
|
+
|
|
2835
|
+
/** #2930: one message, sent now through the chat's own Send; a second click while it goes sends nothing. */
|
|
2836
|
+
async function askToCorrect(row, turnId) {
|
|
2837
|
+
const key = citationNoteKey(row, turnId);
|
|
2838
|
+
if (correcting.get(key)?.sending || !row.chatId) return;
|
|
2839
|
+
correcting.set(key, { sending: true });
|
|
2840
|
+
paintEvents();
|
|
2841
|
+
let result;
|
|
2842
|
+
try { result = await sendTurn({ message: { text: correctionText(row, turnId), attachments: [] } }); }
|
|
2843
|
+
catch (error) { console.warn('floless: a correction request could not be sent', error); result = null; }
|
|
2844
|
+
if (result?.sent) {
|
|
2845
|
+
correcting.delete(key);
|
|
2846
|
+
noteCitation(row, turnId, { text: 'Sent. The corrected answer will appear below; this answer stays as it is.' });
|
|
2847
|
+
} else {
|
|
2848
|
+
correcting.set(key, { failed: result?.message ? String(result.message) : 'Your request did not reach the AI, and nothing was lost. Try again.' });
|
|
2849
|
+
}
|
|
2850
|
+
if (state.chat?.chatId !== row.chatId) return;
|
|
2851
|
+
// Focus goes back to the button only when the person had not moved on (a repaint leaves it on the page body).
|
|
2852
|
+
const active = document.activeElement;
|
|
2853
|
+
const stayed = !active || active === document.body || active.dataset?.commandId === 'shell.chat-cite-correct';
|
|
2854
|
+
paintEvents();
|
|
2855
|
+
if (!result?.sent && stayed) {
|
|
2856
|
+
const again = [...document.querySelectorAll('[data-command-id="shell.chat-cite-correct"]')]
|
|
2857
|
+
.find((control) => control.closest('.ai-chat-source')?.dataset.turnId === (turnId || '') && control.closest('.ai-chat-source')?.dataset.anchor === row.anchor);
|
|
2858
|
+
again?.focus({ preventScroll: true });
|
|
2859
|
+
}
|
|
2860
|
+
}
|
|
2861
|
+
|
|
2581
2862
|
/** One chip: the sheet or page, what FloLess can vouch for, and (unresolved) the person's two ways on. */
|
|
2582
2863
|
function citationChip(turnId, row) {
|
|
2583
2864
|
const chip = document.createElement('span');
|
|
2584
2865
|
chip.className = 'ai-chat-attachment ai-chat-source';
|
|
2585
2866
|
chip.dataset.turnId = turnId || '';
|
|
2586
2867
|
chip.dataset.anchor = row.anchor;
|
|
2868
|
+
if (row.entry.bare) chip.dataset.bare = 'true';
|
|
2587
2869
|
const number = document.createElement('span'); number.className = 'ai-chat-source-n';
|
|
2588
2870
|
number.textContent = row.number ? String(row.number) : '?';
|
|
2589
2871
|
chip.append(number);
|
|
@@ -2608,17 +2890,24 @@
|
|
|
2608
2890
|
const marks = document.createElement('span'); marks.className = 'ai-chat-source-marks';
|
|
2609
2891
|
marks.textContent = 'ASSUMPTION';
|
|
2610
2892
|
marks.dataset.tip = 'Your decision to go on without a source. Nothing was found or checked for this claim. The AI is reminded of it with each message you send';
|
|
2611
|
-
|
|
2893
|
+
// #3000: which claim was assumed, in the answer's words as they were when it was recorded.
|
|
2894
|
+
const claimed = row.assumption.claim ? claimCited(`“${row.assumption.claim}”`, 'The claim you recorded as an assumption')
|
|
2895
|
+
: claimCited(entry.bare ? '' : entry.label, 'What the AI cited');
|
|
2896
|
+
chip.append(...(claimed ? [claimed] : []), why, marks, sourceActions(ask, choose));
|
|
2897
|
+
const saved = citationNote(row, turnId);
|
|
2898
|
+
if (saved) chip.append(saved);
|
|
2612
2899
|
return chip;
|
|
2613
2900
|
}
|
|
2901
|
+
if (referenceProblem(entry)) return referenceChip(chip, turnId, row, choose);
|
|
2614
2902
|
chip.classList.add('unresolved');
|
|
2615
|
-
// What was cited, in the AI's own words, so the person knows which source FloLess could not match.
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
cited.
|
|
2903
|
+
// What was cited, in the AI's own words, so the person knows which source FloLess could not match. #2999: a claim
|
|
2904
|
+
// the AI cited nothing for is named by its own words instead.
|
|
2905
|
+
const words = entry.bare ? unsourcedClaimWords(turnId, row.anchor) : '';
|
|
2906
|
+
const cited = entry.bare ? claimCited(words ? `“${words}”` : entry.label, 'The claim with no source') : claimCited(entry.label, 'What the AI cited');
|
|
2619
2907
|
why.textContent = `No source: ${entry.reason}`;
|
|
2620
|
-
|
|
2621
|
-
assume
|
|
2908
|
+
// #2930: it only saves the person's decision, so it says so; nothing starts and nothing is sent now.
|
|
2909
|
+
const assume = button(ASSUME_LABEL, 'shell.chat-cite-assume', 'ai-chat-source-action');
|
|
2910
|
+
assume.dataset.tip = 'Saves your decision with your name and the date, and labels the claim Assumption. Nothing runs now: the AI receives it with your next message';
|
|
2622
2911
|
assume.addEventListener('click', () => assumeClaim(row, turnId, chip, assume));
|
|
2623
2912
|
chip.append(cited, why, sourceActions(ask, choose, assume));
|
|
2624
2913
|
return chip;
|
|
@@ -2656,6 +2945,43 @@
|
|
|
2656
2945
|
return chip;
|
|
2657
2946
|
}
|
|
2658
2947
|
|
|
2948
|
+
function claimCited(text, tip) {
|
|
2949
|
+
if (!text) return null;
|
|
2950
|
+
const cited = document.createElement('span'); cited.className = 'ai-chat-source-cited';
|
|
2951
|
+
cited.textContent = text;
|
|
2952
|
+
cited.dataset.tip = tip;
|
|
2953
|
+
return cited;
|
|
2954
|
+
}
|
|
2955
|
+
|
|
2956
|
+
/**
|
|
2957
|
+
* #3000: a source the AI cited that the answer never marks. It supports no claim on the page, so it is listed under
|
|
2958
|
+
* "Also consulted" with no number; one FloLess could not find is said quietly, never as a claim to assume.
|
|
2959
|
+
*/
|
|
2960
|
+
function consultedChip(turnId, row) {
|
|
2961
|
+
const chip = document.createElement('span');
|
|
2962
|
+
chip.className = 'ai-chat-attachment ai-chat-source consulted';
|
|
2963
|
+
chip.dataset.turnId = turnId || '';
|
|
2964
|
+
chip.dataset.anchor = row.anchor;
|
|
2965
|
+
const entry = row.entry;
|
|
2966
|
+
if (entry.status !== 'resolved') {
|
|
2967
|
+
chip.classList.add('not-found');
|
|
2968
|
+
const why = document.createElement('span'); why.className = 'ai-chat-source-why';
|
|
2969
|
+
why.textContent = referenceProblem(entry) ? 'The AI named this member wrongly. Not used in the answer.' : `Not found: ${entry.reason}. Not used in the answer.`;
|
|
2970
|
+
chip.append(claimCited(entry.label, 'What the AI cited'), why);
|
|
2971
|
+
return chip;
|
|
2972
|
+
}
|
|
2973
|
+
const label = citationLabel(entry);
|
|
2974
|
+
const open = button(label, 'shell.chat-cite-open', 'ai-chat-answer-open ai-chat-source-open');
|
|
2975
|
+
open.dataset.commandInstanceLabel = label;
|
|
2976
|
+
open.setAttribute('aria-label', `Open ${label}`);
|
|
2977
|
+
open.dataset.tip = `${citationProvenance(entry)} · The answer does not cite it for any claim`;
|
|
2978
|
+
open.addEventListener('click', () => openCitedSource(row, turnId));
|
|
2979
|
+
const marks = document.createElement('span'); marks.className = 'ai-chat-source-marks';
|
|
2980
|
+
marks.textContent = citationMarks(entry);
|
|
2981
|
+
chip.append(open, marks);
|
|
2982
|
+
return chip;
|
|
2983
|
+
}
|
|
2984
|
+
|
|
2659
2985
|
/** The person's ways on from a claim with no source, in one row that wraps between buttons, never inside one. */
|
|
2660
2986
|
function sourceActions(...buttons) {
|
|
2661
2987
|
const actions = document.createElement('span'); actions.className = 'ai-chat-source-actions';
|
|
@@ -2734,6 +3060,8 @@
|
|
|
2734
3060
|
if (state.chat?.chatId !== row.chatId) return;
|
|
2735
3061
|
if (saved && !state.events.some((known) => known.eventId === saved.eventId)) state.events.push(saved);
|
|
2736
3062
|
if (saved) {
|
|
3063
|
+
// Seen until the person's next message goes: then it is no longer what will happen, it has happened.
|
|
3064
|
+
noteCitation(row, turnId, { text: 'Saved. The AI will receive this with your next message.', untilNextMessage: true });
|
|
2737
3065
|
paintEvents();
|
|
2738
3066
|
const after = [...ui.feed.querySelectorAll('.ai-chat-source')].find((node) => node.dataset.turnId === (turnId || '') && node.dataset.anchor === row.anchor);
|
|
2739
3067
|
after?.querySelector('[data-command-id="shell.chat-cite-ask"]')?.focus({ preventScroll: true });
|
|
@@ -2742,7 +3070,7 @@
|
|
|
2742
3070
|
return;
|
|
2743
3071
|
}
|
|
2744
3072
|
assume.removeAttribute('aria-busy'); assume.removeAttribute('aria-disabled');
|
|
2745
|
-
assume.textContent =
|
|
3073
|
+
assume.textContent = ASSUME_LABEL;
|
|
2746
3074
|
const note = document.createElement('span'); note.className = 'ai-chat-source-note warn'; note.setAttribute('role', 'status');
|
|
2747
3075
|
note.textContent = problem;
|
|
2748
3076
|
chip.append(note);
|
|
@@ -3163,9 +3491,20 @@
|
|
|
3163
3491
|
function renderCitationSources(event) {
|
|
3164
3492
|
const last = state.events.filter((candidate) => candidate.type === 'citation' && candidate.turnId === event.turnId).at(-1);
|
|
3165
3493
|
if (last !== event) return null;
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3494
|
+
return turnSources(event.turnId);
|
|
3495
|
+
}
|
|
3496
|
+
|
|
3497
|
+
/** #2999: the Sources row of an answer that marks claims but cited nothing: there is no citation event to hold it. */
|
|
3498
|
+
function renderUncitedClaims(turnId) {
|
|
3499
|
+
if (!turnId || state.events.some((candidate) => candidate.type === 'citation' && candidate.turnId === turnId)) return null;
|
|
3500
|
+
return turnSources(turnId);
|
|
3501
|
+
}
|
|
3502
|
+
|
|
3503
|
+
function turnSources(turnId) {
|
|
3504
|
+
const index = citationIndex(turnId);
|
|
3505
|
+
if (!index.order.length && !index.unused.length) return null;
|
|
3506
|
+
return citationRow(index.order.map((anchor) => citationChip(turnId, index.byAnchor.get(anchor))),
|
|
3507
|
+
index.unused.map((anchor) => consultedChip(turnId, index.byAnchor.get(anchor))));
|
|
3169
3508
|
}
|
|
3170
3509
|
|
|
3171
3510
|
/** #2436: a Knowledge citation written before #2437 — its pages as chips; whether the AI read them was never recorded. */
|
|
@@ -3190,15 +3529,34 @@
|
|
|
3190
3529
|
}));
|
|
3191
3530
|
}
|
|
3192
3531
|
|
|
3193
|
-
|
|
3532
|
+
let alsoHeads = 0;
|
|
3533
|
+
function citationRow(chips, consulted = []) {
|
|
3194
3534
|
const wrap = document.createElement('div'); wrap.className = 'ai-chat-sources';
|
|
3535
|
+
if (consulted.length) {
|
|
3536
|
+
// #3000: sources the AI gave that no claim on the page uses, after the ones that do.
|
|
3537
|
+
const also = document.createElement('span'); also.className = 'ai-chat-sources-head also';
|
|
3538
|
+
also.id = `ai-chat-also-${++alsoHeads}`;
|
|
3539
|
+
also.textContent = 'Also consulted';
|
|
3540
|
+
also.dataset.tip = 'Sources the AI cited that the answer does not use for any claim. They are not claims, so there is nothing to assume';
|
|
3541
|
+
const list = document.createElement('div'); list.className = 'ai-chat-sources-list also';
|
|
3542
|
+
list.setAttribute('role', 'list'); list.setAttribute('aria-labelledby', also.id);
|
|
3543
|
+
for (const chip of consulted) chip.setAttribute('role', 'listitem');
|
|
3544
|
+
list.append(...consulted);
|
|
3545
|
+
if (chips.length) wrap.append(...citationRow(chips).childNodes);
|
|
3546
|
+
wrap.append(also, list);
|
|
3547
|
+
return wrap;
|
|
3548
|
+
}
|
|
3195
3549
|
const head = document.createElement('span'); head.className = 'ai-chat-sources-head';
|
|
3196
3550
|
// #2643: a source a person chose is not one the AI gave, so a row holding one says neither.
|
|
3197
3551
|
const chosen = chips.some((chip) => chip.classList.contains('chosen'));
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3552
|
+
// #2999: a row of claims the AI named no source for says so, never that the AI gave sources.
|
|
3553
|
+
const none = !chosen && chips.every((chip) => chip.dataset.bare === 'true');
|
|
3554
|
+
head.textContent = none ? 'Claims with no source' : chosen ? 'Sources for this answer' : 'Sources the AI gave for this answer';
|
|
3555
|
+
head.dataset.tip = none
|
|
3556
|
+
? 'The AI marked these claims but named no source for any of them. Ask for one, choose one, or record the claim as an assumption.'
|
|
3557
|
+
: chosen
|
|
3558
|
+
? 'FloLess found each source. It says whether the AI was shown one it cited, and marks one a person chose as chosen. It does not check that a source supports the claim.'
|
|
3559
|
+
: 'FloLess found each source and says whether the AI was shown it. It does not check that a source supports the claim.';
|
|
3202
3560
|
const list = document.createElement('div'); list.className = 'ai-chat-sources-list';
|
|
3203
3561
|
list.append(...chips);
|
|
3204
3562
|
wrap.append(head, list);
|
|
@@ -3222,7 +3580,8 @@
|
|
|
3222
3580
|
|
|
3223
3581
|
/** The words just before a claim's "?" marker (the last 90 characters), or '' when the answer shows no marker for it. */
|
|
3224
3582
|
function unsourcedClaimWords(turnId, anchor) {
|
|
3225
|
-
const marker = [...ui.feed.querySelectorAll('button.ai-chat-cite')].find((node) => node.dataset.turnId === (turnId || '') && node.dataset.anchor === anchor)
|
|
3583
|
+
const marker = [...ui.feed.querySelectorAll('button.ai-chat-cite')].find((node) => node.dataset.turnId === (turnId || '') && node.dataset.anchor === anchor)
|
|
3584
|
+
?? answerMarker(turnId, anchor);
|
|
3226
3585
|
const block = marker?.closest('p, li, h1, h2, h3, blockquote');
|
|
3227
3586
|
let before = '';
|
|
3228
3587
|
if (block && marker) {
|
|
@@ -3241,6 +3600,28 @@
|
|
|
3241
3600
|
return words.length > 90 ? `…${words.slice(-90).join('').trimStart()}` : before;
|
|
3242
3601
|
}
|
|
3243
3602
|
|
|
3603
|
+
/**
|
|
3604
|
+
* #2999: the claim's marker in its answer as FloLess renders it, off the page: a Sources row is built before its
|
|
3605
|
+
* answer is on the page when the answer also cited something, and its chips still name their claims.
|
|
3606
|
+
*/
|
|
3607
|
+
let answerMarkers = null;
|
|
3608
|
+
function answerMarker(turnId, anchor) {
|
|
3609
|
+
const answer = answerText(turnId);
|
|
3610
|
+
if (!answer) return null;
|
|
3611
|
+
// The answer is rendered off the page once for all its claims, and again only when its text changes.
|
|
3612
|
+
const key = `${turnId}\u0000${answer.blocks.join('\u0000')}`;
|
|
3613
|
+
if (answerMarkers?.key !== key) {
|
|
3614
|
+
const markers = new Map();
|
|
3615
|
+
for (const block of answer.blocks) {
|
|
3616
|
+
const scratch = document.createElement('div');
|
|
3617
|
+
renderAnswerBody(scratch, block, turnId);
|
|
3618
|
+
for (const node of scratch.querySelectorAll('button.ai-chat-cite')) if (!markers.has(node.dataset.anchor)) markers.set(node.dataset.anchor, node);
|
|
3619
|
+
}
|
|
3620
|
+
answerMarkers = { key, markers };
|
|
3621
|
+
}
|
|
3622
|
+
return answerMarkers.markers.get(anchor) ?? null;
|
|
3623
|
+
}
|
|
3624
|
+
|
|
3244
3625
|
/** Never overwrites what the person is writing: the text goes after it. */
|
|
3245
3626
|
function addToMessageBox(text) {
|
|
3246
3627
|
const held = ui.input.value.trim();
|
|
@@ -3581,7 +3962,15 @@
|
|
|
3581
3962
|
if (finished) return;
|
|
3582
3963
|
status.textContent = entry.chosen ? 'The Knowledge page as it was when you chose it.' : 'The Knowledge page as it was when the answer cited it.';
|
|
3583
3964
|
const article = document.createElement('div'); article.className = 'ai-chat-message-body ai-chat-source-viewer-page';
|
|
3584
|
-
article.innerHTML =
|
|
3965
|
+
article.innerHTML = knowledgePageHtml(page.body, page.links);
|
|
3966
|
+
// #3003: a page a link names opens in Knowledge at this same version.
|
|
3967
|
+
article.addEventListener('click', (event) => {
|
|
3968
|
+
const link = event.target.closest?.('button[data-kb-link]');
|
|
3969
|
+
if (!link) return;
|
|
3970
|
+
finish();
|
|
3971
|
+
if (window.flolessWorkspaces?.openKnowledgePage) window.flolessWorkspaces.openKnowledgePage(page.projectId, link.dataset.kbLink, page.generationId);
|
|
3972
|
+
else announce('Knowledge is not available on this page.');
|
|
3973
|
+
});
|
|
3585
3974
|
const knowledge = button('Open in Knowledge', 'shell.chat-cite-open-knowledge', 'ai-chat-source-viewer-knowledge');
|
|
3586
3975
|
knowledge.addEventListener('click', () => {
|
|
3587
3976
|
finish();
|
|
@@ -4750,11 +5139,21 @@
|
|
|
4750
5139
|
if (screen?.view === 'requests' && screen.requestId && typeof window.flolessBridge?.openRequest === 'function') {
|
|
4751
5140
|
await window.flolessBridge.openRequest(screen.requestId); return true;
|
|
4752
5141
|
}
|
|
4753
|
-
// #2450: one connection, selected and framed in the project's model editor.
|
|
4754
|
-
//
|
|
5142
|
+
// #2450: one connection, selected and framed in the project's model editor. A later request taking over
|
|
5143
|
+
// counts as opened (it reports for itself). #2520: when the editor says why it could not show it, that
|
|
5144
|
+
// sentence reaches the card as a `plain` error, never replaced by the card's generic line.
|
|
4755
5145
|
if (screen?.view === 'connection' && screen.projectId && screen.jointId) {
|
|
4756
5146
|
const outcome = await openConnectionInModel(screen.projectId, screen.jointId);
|
|
4757
|
-
|
|
5147
|
+
if (outcome?.ok === true || outcome?.superseded === true) return true;
|
|
5148
|
+
if (typeof outcome?.said === 'string' && outcome.said) throw Object.assign(new Error(outcome.said), { plain: true });
|
|
5149
|
+
return false;
|
|
5150
|
+
}
|
|
5151
|
+
// #2521 row 9: Make precise itself, in the project's model editor, where the person confirms each AI decision.
|
|
5152
|
+
if (screen?.view === 'project' && screen.panel === 'make-precise' && screen.projectId && typeof window.flolessWorkspaces?.openConnection === 'function') {
|
|
5153
|
+
const outcome = await window.flolessWorkspaces.openConnection({ projectId: screen.projectId, makePrecise: true });
|
|
5154
|
+
if (outcome?.ok === true || outcome?.superseded === true) return true;
|
|
5155
|
+
if (typeof outcome?.said === 'string' && outcome.said) throw Object.assign(new Error(outcome.said), { plain: true });
|
|
5156
|
+
return false;
|
|
4758
5157
|
}
|
|
4759
5158
|
if (screen?.view === 'project' && screen.step === 'drawings' && screen.projectId && typeof window.flolessWorkspaces?.openDrawingsStep === 'function') {
|
|
4760
5159
|
await window.flolessWorkspaces.openDrawingsStep(screen.projectId); return true;
|
|
@@ -6464,6 +6863,8 @@
|
|
|
6464
6863
|
}
|
|
6465
6864
|
// Open the place: a human-only action's screen, or the flow for a tool, workflow, agent, routine or page.
|
|
6466
6865
|
let opened = false;
|
|
6866
|
+
// #2520: a screen that refuses in its own words (a connection no longer in the model) says that, not the generic line.
|
|
6867
|
+
let refused = '';
|
|
6467
6868
|
try {
|
|
6468
6869
|
if (answer.outcome === 'screen') opened = await openActionScreen(answer.screen);
|
|
6469
6870
|
else if (answer.move?.kind === 'create-workflow' && typeof window.flolessBridge?.newWorkflow === 'function') {
|
|
@@ -6471,12 +6872,13 @@
|
|
|
6471
6872
|
void window.flolessBridge.newWorkflow({ name: answer.move.name });
|
|
6472
6873
|
} else if (answer.move) opened = Boolean(await window.flolessGuide?.openFlow?.(answer.move));
|
|
6473
6874
|
} catch (error) {
|
|
6474
|
-
|
|
6875
|
+
if (error?.plain === true && error.message) refused = error.message;
|
|
6876
|
+
else console.warn('[assistant] a suggestion could not open its place:', error);
|
|
6475
6877
|
opened = false;
|
|
6476
6878
|
}
|
|
6477
6879
|
if (!opened) {
|
|
6478
6880
|
entry.fold = { opened: false };
|
|
6479
|
-
entry.error = 'FloLess couldn’t open that from here. Open it from the ≡ menu instead.';
|
|
6881
|
+
entry.error = refused || 'FloLess couldn’t open that from here. Open it from the ≡ menu instead.';
|
|
6480
6882
|
entry.focus = 'status'; repaintAssistantCard(entry); return;
|
|
6481
6883
|
}
|
|
6482
6884
|
entry.fold = null;
|
|
@@ -7687,7 +8089,6 @@
|
|
|
7687
8089
|
const note = scope.startsWith('h:') ? (source.note.trim() ? source.note : '') : source.note.trim();
|
|
7688
8090
|
return { ...(note ? { note } : {}), ...(source.files.length ? { evidence: source.files.map((file) => file.attachmentId) } : {}) };
|
|
7689
8091
|
}
|
|
7690
|
-
const MAX_ANSWER_NOTE = 160;
|
|
7691
8092
|
const MAX_HEIGHT_CLARIFICATION = 8000;
|
|
7692
8093
|
// #2167: asked for nothing at all. Said plainly, with the three things that would count.
|
|
7693
8094
|
const NO_HEIGHT_NO_SOURCE = 'Type a height, or add a note or a picture and the AI will work it out.';
|
|
@@ -7891,7 +8292,7 @@
|
|
|
7891
8292
|
if (ctx.clarification) { note.rows = 4; wrap.classList.add('ai-chat-answer-clarification'); }
|
|
7892
8293
|
else { note.type = 'text'; note.maxLength = 160; }
|
|
7893
8294
|
note.className = `ai-chat-height-input ai-chat-answer-note${ctx.clarification ? ' ai-chat-answer-clarification' : ''}`; note.autocomplete = 'off';
|
|
7894
|
-
note.placeholder = ctx.clarification ? 'Use the stair landing level shown in this detail; the hanger sits on it.' : 'Source, e.g. per 7/S-502 (optional)';
|
|
8295
|
+
note.placeholder = ctx.clarification ? (ctx.clarificationPlaceholder || 'Use the stair landing level shown in this detail; the hanger sits on it.') : 'Source, e.g. per 7/S-502 (optional)';
|
|
7895
8296
|
note.dataset.commandId = ctx.idFor('note'); note.dataset.commandInstanceLabel = ctx.instance;
|
|
7896
8297
|
note.setAttribute('aria-label', `${ctx.clarification ? 'Explain what to use' : 'Source note'} for ${ctx.label}`);
|
|
7897
8298
|
note.value = source.note;
|
|
@@ -7902,7 +8303,7 @@
|
|
|
7902
8303
|
note.id = `clarification-${encodeURIComponent(scope)}`; heading.htmlFor = note.id; box.append(heading);
|
|
7903
8304
|
counter = Object.assign(document.createElement('p'), { className: 'ai-chat-answer-lead' });
|
|
7904
8305
|
note.setAttribute('aria-describedby', `${note.id}-limit`); counter.id = `${note.id}-limit`;
|
|
7905
|
-
const count = () => { counter.textContent = `${note.value.length.toLocaleString()} / 8,000 characters. Without a Height, this saves clarification for the read; the height stays unresolved
|
|
8306
|
+
const count = () => { counter.textContent = `${note.value.length.toLocaleString()} / 8,000 characters. ${ctx.clarificationHint || 'Without a Height, this saves clarification for the read; the height stays unresolved.'}`; note.setAttribute('aria-invalid', String(note.value.length > MAX_HEIGHT_CLARIFICATION)); };
|
|
7906
8307
|
note.addEventListener('input', count); count();
|
|
7907
8308
|
}
|
|
7908
8309
|
note.addEventListener('input', () => { source.note = note.value; ctx.onDraftChange?.(); });
|
|
@@ -8189,7 +8590,7 @@
|
|
|
8189
8590
|
if (kind === 'height' && ['resolved-from-drawings', 'no-longer-needed'].includes(heightResponsibility(row))) return;
|
|
8190
8591
|
showDrawingSlot(entry.chatId);
|
|
8191
8592
|
entry.changing.add(key); entry.activeItem = key; entry.finishActive = false; entry.reopenedAt = (state.drawingActivationOrder = (state.drawingActivationOrder || 0) + 1);
|
|
8192
|
-
if (kind === 'setup' && row.answer?.note && row.answer.how !== 'none') { const source = answerSource((kind === 'setup' ? `s:${entry.questionId}:${key}` : heightSourceScope(entry, key))); source.open = true;
|
|
8593
|
+
if (kind === 'setup' && row.answer?.note && row.answer.how !== 'none') { const source = answerSource((kind === 'setup' ? `s:${entry.questionId}:${key}` : heightSourceScope(entry, key))); source.open = true; }
|
|
8193
8594
|
entry.slotPhase = 'row';
|
|
8194
8595
|
(kind === 'setup' ? repaintSetupCard : repaintHeightCard)(entry);
|
|
8195
8596
|
drawingSlotRepaint();
|
|
@@ -8343,7 +8744,8 @@
|
|
|
8343
8744
|
function drawingSource(kind, entry, scope, label, idFor, row, onDraftChange) {
|
|
8344
8745
|
return paintAnswerSource(scope, { requestId: entry.requestId, chatId: entry.chatId, repaint: () => { (kind === 'setup' ? repaintSetupCard : repaintHeightCard)(entry); drawingSlotRepaint(); },
|
|
8345
8746
|
removeFile: (file) => request(`/api/chat/answer-evidence/${encodeURIComponent(entry.requestId)}/${encodeURIComponent(file.attachmentId)}`, { method: 'DELETE', body: JSON.stringify({ chatId: entry.chatId }) }),
|
|
8346
|
-
label, instance: label, idFor, inherited: row?.inherited, inheritedNote: (
|
|
8747
|
+
label, instance: label, idFor, inherited: row?.inherited, inheritedNote: (row?.answer?.how !== 'none' ? row?.answer?.note : null) || row?.inheritedNote, clarification: true,
|
|
8748
|
+
...(kind === 'setup' ? { clarificationHint: 'Without a value above, this saves your explanation for the read; nothing is confirmed.', clarificationPlaceholder: 'Tell the read what to use and where it comes from, e.g. per 7/S-502.' } : {}), busyReason: entry.busy ? 'An answer is still being saved — wait for it to finish' : null,
|
|
8347
8749
|
allowPictureOnly: false, onDraftChange, alwaysOpen: Boolean(entry.slotDrafts?.get(entry.slotQuestionKey)?.rows[0]?.otherOpen) });
|
|
8348
8750
|
}
|
|
8349
8751
|
function retainedHeightPicture(entry, file, commandId, instance) {
|
|
@@ -8433,22 +8835,25 @@
|
|
|
8433
8835
|
q.figure = () => heightPlaceFigure(entry, row);
|
|
8434
8836
|
if (row.fromEvidence) q.context.push(row.inherited?.length ? 'The read’s reading of your picture. Check it before you confirm.' : 'The read’s reading of your note. Check it before you confirm.');
|
|
8435
8837
|
} else if (row.kind === 'origin') {
|
|
8838
|
+
q.otherInputLabel = 'Grid crossing (optional)'; q.otherPlaceholder = 'A/1'; q.otherUncapped = true;
|
|
8436
8839
|
q.question = 'Which grid crossing is the model’s origin (0, 0)?'; q.layout = 'grid'; q.confirmSelection = true;
|
|
8437
8840
|
row.choices.forEach((choice, index) => { q.options.push({ shown: originText(choice), description: 'A straight grid crossing in the model', confirmLabel: `Confirm ${originText(choice)} as the model origin`, tag: row.proposed === index ? 'THE READ SUGGESTS' : '' }); choices.push({ key, action: 'confirm', choice: `c${index}`, shown: originText(choice) }); });
|
|
8438
8841
|
row.offGrid.forEach((point, index) => { const target = row.choices[point.same]; q.options.push({ shown: point.as, description: 'Not a straight grid line; check the read’s mapping', confirmLabel: `Confirm ${originText(target)} as the model origin`, statement: `${point.as} is not a straight grid line in the model. The read says it is the same point as ${originText(target)} (${point.why}). This is the read’s claim; FloLess has not checked it.` }); choices.push({ key, action: 'confirm', choice: `o${index}`, shown: originText(target) }); });
|
|
8439
8842
|
q.recommended = Number.isInteger(row.proposed) ? row.proposed : null;
|
|
8440
|
-
if (row.fromEvidence) q.context.push('The read’s reading of your picture. Check it before you confirm.');
|
|
8843
|
+
if (row.fromEvidence) q.context.push(row.inherited?.length ? 'The read’s reading of your picture. Check it before you confirm.' : 'The read’s reading of your note. Check it before you confirm.');
|
|
8441
8844
|
} else {
|
|
8845
|
+
q.otherInputLabel = row.kind === 'scale' ? 'Scale (optional)' : 'Level (optional)'; q.otherUncapped = true;
|
|
8846
|
+
q.otherPlaceholder = row.kind === 'scale' ? `1/4" = 1'-0", or 1:100` : entry.view.units === 'mm' ? '4870 mm, or 4.87 for metres' : `15'-11 3/4"; a bare number is inches`;
|
|
8442
8847
|
if (row.clue) q.context.push(row.clue);
|
|
8443
8848
|
if (row.noSingleLevel) q.context.push(`No single level on the drawings: ${row.noSingleLevel.why}`);
|
|
8444
8849
|
// Options follow row.proposals in order, so the selected option's index names its proposal.
|
|
8445
8850
|
// A choice past the proposals ("No single level") has no place of its own, so it gets no picture.
|
|
8446
8851
|
if (row.kind === 'level') q.figure = (choice) => setupPlaceFigure(entry, row, Number.isInteger(choice) ? (row.proposals[choice] ?? SETUP_NO_PROPOSAL) : null);
|
|
8447
8852
|
row.proposals.forEach((proposal) => { q.options.push({ shown: row.kind === 'scale' ? `${proposal.pageFit ? 'Use for this plan' : 'Confirm'}: ${proposal.standard} · ${proposal.mmPerPx} mm per drawing point` : `Confirm ${proposal.asRead}`,
|
|
8448
|
-
description: row.kind === 'scale' ? proposal.evidence : levelEvidence(proposal), tag: (row.kind === 'scale' ? scaleTag : levelTag)[proposal.source] || 'PROPOSED' }); choices.push({ key, action: 'confirm', choice: proposal.id, shown: row.kind === 'scale' ? proposal.mmPerPx : proposal.value }); });
|
|
8853
|
+
description: row.kind === 'scale' ? proposal.evidence : levelEvidence(proposal), tag: proposal.source === 'read-of-picture' && !row.inherited?.length ? 'THE READ’S READING OF YOUR NOTE' : (row.kind === 'scale' ? scaleTag : levelTag)[proposal.source] || 'PROPOSED' }); choices.push({ key, action: 'confirm', choice: proposal.id, shown: row.kind === 'scale' ? proposal.mmPerPx : proposal.value }); });
|
|
8449
8854
|
}
|
|
8450
8855
|
if (kind === 'setup' && (row.kind === 'origin' || row.kind === 'scale')) q.context.push('This setup question has no saved drawing location. Inspect the drawing set in Drawing Filter, or ask the read to point out the context.');
|
|
8451
|
-
if (kind === 'setup' && row.kind !== 'scale') { q.options.push({ shown: row.kind === 'origin' ? 'None of these' : 'No single level', description: 'Tell the read what to use instead', requiresNote: { placeholder: '
|
|
8856
|
+
if (kind === 'setup' && row.kind !== 'scale') { q.options.push({ shown: row.kind === 'origin' ? 'None of these' : 'No single level', description: 'Tell the read what to use instead', requiresNote: { placeholder: 'Say why, and what to use instead', max: MAX_HEIGHT_CLARIFICATION } }); choices.push({ key, action: 'none' }); }
|
|
8452
8857
|
if (kind === 'setup') { const banner = setupConflictBanner(row); if (banner) q.context.push(banner.textContent); }
|
|
8453
8858
|
const controlKey = kind === 'height' ? `${row.memberId} ${row.endWord}` : key;
|
|
8454
8859
|
const idFor = (what, extra) => `shell.chat-answer-${what}#${entry.questionId} ${controlKey}${extra === undefined ? '' : ` ${extra}`}`;
|
|
@@ -8459,9 +8864,8 @@
|
|
|
8459
8864
|
source: (_index, onDraftChange) => drawingSource(kind, entry, scope, label, idFor, row, onDraftChange),
|
|
8460
8865
|
validate: (_step, draft) => {
|
|
8461
8866
|
const answer = draft.rows[0]; if (answer.choices.length) return '';
|
|
8462
|
-
if (answer.other.trim()) return '';
|
|
8463
|
-
|
|
8464
|
-
return answerSource(scope).files.length ? '' : kind === 'setup' ? 'Type a value, or attach a picture first.' : NO_HEIGHT_NO_SOURCE;
|
|
8867
|
+
if (answer.other.trim() || hasAnswerSource(scope)) return '';
|
|
8868
|
+
return kind === 'setup' ? 'Type a value, explain what to use, or attach a picture.' : NO_HEIGHT_NO_SOURCE;
|
|
8465
8869
|
},
|
|
8466
8870
|
commit: async (answer) => {
|
|
8467
8871
|
let payload;
|
|
@@ -8891,7 +9295,9 @@
|
|
|
8891
9295
|
if (row.status === 'picture' && !changing) {
|
|
8892
9296
|
const wait = document.createElement('div'); wait.className = 'ai-chat-height-answered';
|
|
8893
9297
|
const glyph = document.createElement('span'); glyph.className = 'ai-chat-height-glyph'; glyph.textContent = '…'; glyph.setAttribute('aria-hidden', 'true');
|
|
8894
|
-
const
|
|
9298
|
+
const unread = entry.unreadValue?.has(row.key) ? `FloLess could not read what you typed as ${row.kind === 'origin' ? 'one of the grid crossings on this card' : row.kind === 'scale' ? 'a scale' : 'a level'}, so it kept your words as a note. ` : '';
|
|
9299
|
+
const text = document.createElement('span'); text.textContent = !row.answer?.note ? 'Waiting for the read to read your picture'
|
|
9300
|
+
: `${unread}Saved as a note${row.answer.evidence?.length ? ' with your picture' : ''} for the read. Nothing is confirmed; this row stays open until you confirm a value.`;
|
|
8895
9301
|
wait.append(glyph, text);
|
|
8896
9302
|
if (open) {
|
|
8897
9303
|
const change = heightActionButton('Answer now', idFor('change'), instance, 'ai-chat-height-change', null);
|
|
@@ -8945,13 +9351,13 @@
|
|
|
8945
9351
|
let saved = false;
|
|
8946
9352
|
const withSource = answers.map((answer) => withAnswerSource(answer, answerSourcePayload(`s:${entry.questionId}:${answer.key}`)));
|
|
8947
9353
|
try {
|
|
8948
|
-
|
|
8949
|
-
if (
|
|
8950
|
-
entry.rowErrors.set(rowKey,
|
|
9354
|
+
// Measured as the server joins them when the value is not one it can read: typed, a blank line, the note.
|
|
9355
|
+
if (withSource.some((answer) => [answer.typed?.trim(), answer.note].filter(Boolean).join('\n\n').length > MAX_HEIGHT_CLARIFICATION)) {
|
|
9356
|
+
entry.rowErrors.set(rowKey, 'Your answer and explanation together are longer than 8,000 characters. Your full draft is kept. Shorten it, or send the rest in chat.');
|
|
8951
9357
|
return false;
|
|
8952
9358
|
}
|
|
8953
|
-
if (withSource.some((answer) => answer.action === 'evidence' && !answer.evidence?.length)) {
|
|
8954
|
-
entry.rowErrors.set(rowKey, '
|
|
9359
|
+
if (withSource.some((answer) => answer.action === 'evidence' && !answer.evidence?.length && !answer.note)) {
|
|
9360
|
+
entry.rowErrors.set(rowKey, 'Explain what to use, or attach a picture first.'); return false;
|
|
8955
9361
|
}
|
|
8956
9362
|
entry.busy = true; entry.cardError = ''; if (rowKey) entry.rowErrors.delete(rowKey);
|
|
8957
9363
|
repaintSetupCard(entry);
|
|
@@ -8961,7 +9367,13 @@
|
|
|
8961
9367
|
entry.view = result.question;
|
|
8962
9368
|
saved = true; entry.failedSubmission = null; entry.saveFailed = false; if (seenAtAnswer) drawingMessagesSeen(entry.chatId, seenAtAnswer);
|
|
8963
9369
|
for (const answer of answers) {
|
|
8964
|
-
|
|
9370
|
+
// A saved row starts its next edit from the record, not the old typing: a note saved from the value field lives in
|
|
9371
|
+
// the explanation box when it is reopened, and must not also come back in the value field (#2840).
|
|
9372
|
+
entry.changing.delete(answer.key); entry.drafts.delete(answer.key); entry.drafts.delete(`${answer.key}\u0000none`); entry.slotDrafts?.delete(answer.key);
|
|
9373
|
+
// A value FloLess could not read is kept as the person's note; the row says so rather than leaving them to wonder.
|
|
9374
|
+
entry.unreadValue ??= new Set();
|
|
9375
|
+
if (answer.action === 'type' && entry.view?.items?.find((item) => item.key === answer.key)?.answer?.how === 'evidence') entry.unreadValue.add(answer.key);
|
|
9376
|
+
else entry.unreadValue.delete(answer.key);
|
|
8965
9377
|
if (entry.activeItem === answer.key) { entry.activeItem = null; entry.reopenedAt = 0; }
|
|
8966
9378
|
entry.noneOpen.delete(answer.key);
|
|
8967
9379
|
if (answer.key === 'origin') entry.originPick = null;
|
|
@@ -9604,8 +10016,17 @@
|
|
|
9604
10016
|
if (!assistant) return;
|
|
9605
10017
|
const rendered = renderedLiveAssistantText(assistant.event, assistant.text);
|
|
9606
10018
|
ui.feed.append(renderMessage(assistant.event, 'assistant', rendered.text, rendered.streaming));
|
|
10019
|
+
holdUncitedClaims(assistant.event.turnId);
|
|
9607
10020
|
assistant = null;
|
|
9608
10021
|
};
|
|
10022
|
+
// #2999: an answer that cited nothing still lists the claims it marked, once, under the answer, streamed or whole.
|
|
10023
|
+
const uncitedTurns = new Set();
|
|
10024
|
+
const holdUncitedClaims = (turnId) => {
|
|
10025
|
+
if (!turnId || uncitedTurns.has(turnId)) return;
|
|
10026
|
+
uncitedTurns.add(turnId);
|
|
10027
|
+
const node = renderUncitedClaims(turnId);
|
|
10028
|
+
if (node) { if (links.length && links[0].turnId !== turnId) flushLinks(); links.push({ turnId, node }); }
|
|
10029
|
+
};
|
|
9609
10030
|
const flushLinks = () => { if (links.length) { ui.feed.append(...receiptFold(links)); links = []; } };
|
|
9610
10031
|
for (const event of state.events) {
|
|
9611
10032
|
// #2642/#2643: the person's assumption or chosen source is painted on its claim's chip; it never starts or ends an answer group (it has no turn).
|
|
@@ -9679,6 +10100,7 @@
|
|
|
9679
10100
|
// as it is).
|
|
9680
10101
|
const node = feedCard(renderEvent(event), event);
|
|
9681
10102
|
if (node) ui.feed.append(node);
|
|
10103
|
+
if (event.type === 'assistant-message') holdUncitedClaims(event.turnId);
|
|
9682
10104
|
}
|
|
9683
10105
|
flushAssistant();
|
|
9684
10106
|
flushLinks();
|
|
@@ -11293,7 +11715,15 @@
|
|
|
11293
11715
|
if (finished) return;
|
|
11294
11716
|
status.textContent = 'The Knowledge page at the version you mentioned.';
|
|
11295
11717
|
const article = document.createElement('div'); article.className = 'ai-chat-message-body ai-chat-source-viewer-page';
|
|
11296
|
-
article.innerHTML =
|
|
11718
|
+
article.innerHTML = knowledgePageHtml(page.body, page.links);
|
|
11719
|
+
// #3003: a page a link names opens in Knowledge at this same version.
|
|
11720
|
+
article.addEventListener('click', (event) => {
|
|
11721
|
+
const link = event.target.closest?.('button[data-kb-link]');
|
|
11722
|
+
if (!link) return;
|
|
11723
|
+
finish();
|
|
11724
|
+
if (window.flolessWorkspaces?.openKnowledgePage) window.flolessWorkspaces.openKnowledgePage(page.projectId, link.dataset.kbLink, page.generationId);
|
|
11725
|
+
else announce('Knowledge is not available on this page.');
|
|
11726
|
+
});
|
|
11297
11727
|
const knowledge = button('Open in Knowledge', 'shell.chat-cite-open-knowledge', 'ai-chat-source-viewer-knowledge');
|
|
11298
11728
|
knowledge.addEventListener('click', () => {
|
|
11299
11729
|
finish();
|
|
@@ -13238,7 +13668,7 @@
|
|
|
13238
13668
|
// changing the attachments themselves.
|
|
13239
13669
|
paintAttachControl();
|
|
13240
13670
|
const unknownReason = state.followupUnknownId || hasUnknownFollowup()
|
|
13241
|
-
? 'FloLess could not confirm
|
|
13671
|
+
? 'FloLess could not confirm your last message reached the AI. Review that message before sending or attaching another file.' : null;
|
|
13242
13672
|
const sendingReason = state.followupSubmitting
|
|
13243
13673
|
? 'FloLess is saving this message. Wait for its delivery status before sending another.' : null;
|
|
13244
13674
|
for (const control of [ui.send, ui.attach]) {
|
|
@@ -14072,7 +14502,20 @@
|
|
|
14072
14502
|
if (!providerReady()) void loadCapability().then(() => { if (sameChat(snapshot)) { paintSettings(); updateSendState(); } });
|
|
14073
14503
|
if (given) return { sent: true };
|
|
14074
14504
|
} catch (error) {
|
|
14505
|
+
const unconfirmedAnswer = 'FloLess is busy and hasn’t confirmed your answer reached the AI yet. Check the conversation before you answer again.';
|
|
14075
14506
|
if (!sameChat(snapshot)) {
|
|
14507
|
+
// #2957: a timed-out send is as unconfirmed after the person moved on; it waits as unconfirmed in its own
|
|
14508
|
+
// conversation (reconcileUnknownFollowupOnSelection), and is settled there if that conversation is open again.
|
|
14509
|
+
if (error?.code === 'local-timeout') {
|
|
14510
|
+
optimisticEvent.payload.deliveryState = 'unknown';
|
|
14511
|
+
state.unknownFollowups.set(chatId, { submissionId: clientSubmissionId, text, event: optimisticEvent });
|
|
14512
|
+
// Open again through another project counts too (a new scope generation, the same owner): by owner, not generation.
|
|
14513
|
+
if (scopeKey(snapshot.scope) === scopeKey(state.scope) && state.chat?.chatId === chatId) {
|
|
14514
|
+
reconcileUnknownFollowupOnSelection(state.chat);
|
|
14515
|
+
paintEvents(); updateSendState();
|
|
14516
|
+
}
|
|
14517
|
+
return given ? givenNotSent(unconfirmedAnswer) : undefined;
|
|
14518
|
+
}
|
|
14076
14519
|
if (given) return givenNotSent();
|
|
14077
14520
|
if (initialTurnDefinitelyRefused(error)) {
|
|
14078
14521
|
await restoreBackgroundDraft(snapshot, text, clientSubmissionId);
|
|
@@ -14082,6 +14525,33 @@
|
|
|
14082
14525
|
return;
|
|
14083
14526
|
}
|
|
14084
14527
|
state.pendingSubmissionId = null;
|
|
14528
|
+
// #2957: the browser stopped waiting, but the server keeps working on the message, so it may already be in the
|
|
14529
|
+
// conversation. A timed-out send is unconfirmed, never "not sent": the message stays visible as unconfirmed, and
|
|
14530
|
+
// its user-message event or the person's "Review draft and continue" settles it, as for an uncertain follow-up.
|
|
14531
|
+
if (error?.code === 'local-timeout') {
|
|
14532
|
+
const arrived = state.events.some((event) => !event.optimistic && event.type === 'user-message'
|
|
14533
|
+
&& event.clientSubmissionId === clientSubmissionId);
|
|
14534
|
+
state.chat = previousChat;
|
|
14535
|
+
if (arrived) {
|
|
14536
|
+
state.events = state.events.filter((event) => event.eventId !== optimisticEvent.eventId);
|
|
14537
|
+
paintConversation();
|
|
14538
|
+
refreshConversation(chatId, false);
|
|
14539
|
+
announce('FloLess was slow to answer, but your message went through.');
|
|
14540
|
+
return given ? { sent: true } : undefined;
|
|
14541
|
+
}
|
|
14542
|
+
optimisticEvent.payload.deliveryState = 'unknown';
|
|
14543
|
+
state.followupUnknownId = clientSubmissionId;
|
|
14544
|
+
state.unknownFollowups.set(chatId, { submissionId: clientSubmissionId, text, event: optimisticEvent });
|
|
14545
|
+
if (given) {
|
|
14546
|
+
paintConversation();
|
|
14547
|
+
return givenNotSent(unconfirmedAnswer);
|
|
14548
|
+
}
|
|
14549
|
+
// The words come back so nothing is lost, but are not saved as a draft: the message may already be on its way.
|
|
14550
|
+
// Its files and mentions stay with the message that may have gone.
|
|
14551
|
+
ui.input.value = text; autosize(); state.localDraft = { chatId, text }; paintConversation();
|
|
14552
|
+
report(error, '', { 'local-timeout': 'FloLess is busy and hasn’t confirmed your message yet. It will appear here if it went through. Check before sending it again.' });
|
|
14553
|
+
return;
|
|
14554
|
+
}
|
|
14085
14555
|
state.events = state.events.filter((event) => event.eventId !== optimisticEvent.eventId);
|
|
14086
14556
|
state.chat = previousChat;
|
|
14087
14557
|
if (given) { paintConversation(); return givenNotSent(givenRefusal(error)); }
|
|
@@ -14514,8 +14984,9 @@
|
|
|
14514
14984
|
optimisticEvent.payload.deliveryState = 'unknown';
|
|
14515
14985
|
state.unknownFollowups.set(snapshot.chatId, { submissionId: clientSubmissionId, text, event: optimisticEvent });
|
|
14516
14986
|
// The user may have selected A → B → A while this request was in flight.
|
|
14517
|
-
// The second A snapshot ran before the uncertain result existed, so reconcile it now.
|
|
14518
|
-
|
|
14987
|
+
// The second A snapshot ran before the uncertain result existed, so reconcile it now. By owner, not scope
|
|
14988
|
+
// generation: A reopened through another project is a new generation of the same owner (#2957).
|
|
14989
|
+
if (scopeKey(snapshot.scope) === scopeKey(state.scope) && state.chat?.chatId === snapshot.chatId) {
|
|
14519
14990
|
reconcileUnknownFollowupOnSelection(state.chat);
|
|
14520
14991
|
paintEvents(); updateSendState();
|
|
14521
14992
|
}
|
|
@@ -16348,10 +16819,11 @@
|
|
|
16348
16819
|
return result;
|
|
16349
16820
|
}
|
|
16350
16821
|
|
|
16351
|
-
|
|
16822
|
+
// #2470 R6.7b: `withoutLink` is the person's answer to a link to a General project that could not be made.
|
|
16823
|
+
async function resumeProjectIntake(submissionId, { withoutLink = false } = {}) {
|
|
16352
16824
|
await ensureSession();
|
|
16353
16825
|
return request(`/api/chat/project-intakes/${encodeURIComponent(submissionId)}/resume`, {
|
|
16354
|
-
method: 'POST', timeoutMs: PROJECT_INTAKE_TIMEOUT_MS, body: '{}',
|
|
16826
|
+
method: 'POST', timeoutMs: PROJECT_INTAKE_TIMEOUT_MS, body: withoutLink ? JSON.stringify({ withoutLink: true }) : '{}',
|
|
16355
16827
|
});
|
|
16356
16828
|
}
|
|
16357
16829
|
|
|
@@ -16545,6 +17017,8 @@
|
|
|
16545
17017
|
currentChatId: () => state.chat?.chatId ?? null,
|
|
16546
17018
|
// The project this panel's conversations belong to; an object card offers Show in chat only for it (#1653).
|
|
16547
17019
|
scopeProjectId: () => (state.scope?.owner?.kind === 'project' ? state.scope.owner.projectId : null),
|
|
17020
|
+
// #3003: a Knowledge page rendered the way the chat viewers show it, for the Knowledge step's page panel.
|
|
17021
|
+
knowledgePageHtml,
|
|
16548
17022
|
// The Knowledge step's "Ask AI to index" (#2399 slice 0b): the person's own draft in the message box; never sent.
|
|
16549
17023
|
fillMessageBox: (text) => putInMessageBox(String(text || '')),
|
|
16550
17024
|
// The New project dialog's AI choice (#1605) words each provider's sign-in the way this
|