@floless/app 0.165.0 → 0.167.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 +30794 -25371
- package/dist/schemas/drawing-check.profile.v1.schema.json +4 -2
- package/dist/schemas/steel.model.v2.schema.json +2 -1
- package/dist/skills/floless-app-knowledge/SKILL.md +8 -1
- package/dist/skills/floless-app-rfi/SKILL.md +7 -2
- package/dist/skills/floless-app-steel-model/SKILL.md +4 -1
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +31 -17
- package/dist/skills/floless-app-steel-takeoff/references/elevation-registration.md +15 -1
- package/dist/templates/college-phase-exporter.flo +41 -49
- package/dist/templates/screenshot-to-saved-settings.flo +12 -2
- package/dist/web/app.css +120 -1
- package/dist/web/aware.js +385 -88
- package/dist/web/chat-question-card.js +3 -1
- package/dist/web/chat.css +32 -0
- package/dist/web/chat.js +1021 -88
- package/dist/web/commands-drawing-check.js +1 -0
- package/dist/web/commands-filter.js +23 -0
- package/dist/web/commands-shell.js +231 -19
- 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 +14 -6
- package/dist/web/project-history.js +163 -19
- package/dist/web/project-modules.js +5 -0
- package/dist/web/project-rfis.js +206 -20
- package/dist/web/steel-ai-marks.js +173 -2
- package/dist/web/steel-editor.html +770 -49
- package/dist/web/steel-filter-flo.js +171 -7
- package/dist/web/steel-filter.html +36 -10
- package/dist/web/steel-model-v2-projection.js +26 -20
- package/dist/web/terminal-requests.js +5 -0
- package/dist/web/tool-updates.js +65 -20
- package/dist/web/workspaces.js +632 -85
- 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,24 +2394,136 @@
|
|
|
2340
2394
|
chatId: state.chat?.chatId ?? null, owner: ownerQuery(), ownerObject: state.scope?.owner ?? null });
|
|
2341
2395
|
});
|
|
2342
2396
|
}
|
|
2343
|
-
|
|
2344
|
-
//
|
|
2345
|
-
|
|
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
|
+
}
|
|
2407
|
+
// #2643: the sources the person chose. The latest live one is the claim's current one (#3017: on a claim with no
|
|
2408
|
+
// source, or on one whose cited source FloLess found gone, while that citation is still the claim's); the others are
|
|
2409
|
+
// its history. A chosen source is numbered like a cited one: the "?" becomes a number.
|
|
2346
2410
|
for (const [anchor, made] of citationChoices(turnId)) {
|
|
2347
2411
|
const row = byAnchor.get(anchor);
|
|
2348
2412
|
if (!row) continue;
|
|
2349
2413
|
row.choices = made;
|
|
2350
|
-
|
|
2414
|
+
const live = made.filter((choice) => decisionLiveOn(row, choice)).at(-1);
|
|
2415
|
+
if (live) row.choice = live;
|
|
2351
2416
|
}
|
|
2417
|
+
// #2642: the person's assumption. The live one (none while a live choice stands) is the claim's current decision;
|
|
2418
|
+
// otherwise its first record is history ("Earlier assumed").
|
|
2419
|
+
for (const record of citationAssumptions(turnId)) {
|
|
2420
|
+
const row = byAnchor.get(record.anchor);
|
|
2421
|
+
if (!row) continue;
|
|
2422
|
+
const live = !row.choice && decisionLiveOn(row, record);
|
|
2423
|
+
if (live && !row.assumptionLive) { row.assumption = record; row.assumptionLive = true; }
|
|
2424
|
+
else if (!row.assumption) row.assumption = record;
|
|
2425
|
+
}
|
|
2426
|
+
// #3000: an entry the answer never marks is not a claim: it is listed apart as "Also consulted", unnumbered, and
|
|
2427
|
+
// never offered as an assumption. Without answer text (none recorded yet) nothing tells the two apart. One the
|
|
2428
|
+
// person already decided on stays with the claims: their recorded decision is never hidden.
|
|
2429
|
+
const claimed = (anchor) => claims.anchors.includes(anchor) || Boolean(byAnchor.get(anchor).assumption || byAnchor.get(anchor).choices?.length);
|
|
2430
|
+
const used = claims ? order.filter(claimed) : order;
|
|
2431
|
+
const unused = claims ? order.filter((anchor) => !claimed(anchor)) : [];
|
|
2352
2432
|
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 };
|
|
2433
|
+
for (const anchor of order) { const row = byAnchor.get(anchor); row.number = used.includes(anchor) && ((row.entry.status === 'resolved' && !row.assumptionLive) || row.choice) ? ++n : 0; }
|
|
2434
|
+
return { byAnchor, order: used, unused };
|
|
2435
|
+
}
|
|
2436
|
+
|
|
2437
|
+
/**
|
|
2438
|
+
* #2999/#3000: the claims an answer marks, read with the same parse that puts its markers in it (so a directive in code
|
|
2439
|
+
* marks nothing), and the answer event a claim with no citation entry is recorded against. Null when the turn has no
|
|
2440
|
+
* answer text.
|
|
2441
|
+
*/
|
|
2442
|
+
function answerClaims(turnId) {
|
|
2443
|
+
const answer = answerText(turnId);
|
|
2444
|
+
if (!answer) return null;
|
|
2445
|
+
const held = inlineSlots;
|
|
2446
|
+
let slots = [];
|
|
2447
|
+
inlineSlots = [];
|
|
2448
|
+
try { for (const block of answer.blocks) markdownHtml(block); slots = inlineSlots; }
|
|
2449
|
+
finally { inlineSlots = held; }
|
|
2450
|
+
const anchors = [];
|
|
2451
|
+
for (const slot of slots) if (slot.kind === 'cite' && !anchors.includes(slot.anchor)) anchors.push(slot.anchor);
|
|
2452
|
+
return { anchors, answerId: answer.answerId };
|
|
2453
|
+
}
|
|
2454
|
+
|
|
2455
|
+
/** #2999: an answer's text as the feed shows it, block by block (`answerBlocks`). Null when the turn has no answer text. */
|
|
2456
|
+
function answerText(turnId) {
|
|
2457
|
+
const answer = turnId ? answerBlocks(state.events, turnId, payloadText) : null;
|
|
2458
|
+
return answer?.blocks.length ? answer : null;
|
|
2459
|
+
}
|
|
2460
|
+
|
|
2461
|
+
/**
|
|
2462
|
+
* #2999: the blocks of text a turn's answer shows as, grouped exactly as paintEvents groups them: streamed pieces of
|
|
2463
|
+
* one turn joined (a marker split across two pieces is one marker), a paragraph break after a tool between them, and
|
|
2464
|
+
* a block ended by whatever the feed shows in the answer's place (a question, a whole message, a run's first line,
|
|
2465
|
+
* anything it does not hold under the answer) or by a held receipt of another turn. A whole message is its own block.
|
|
2466
|
+
* The server reads claims with the same function (`answerBlocks` in server/chat-store.ts); a test keeps the two equal
|
|
2467
|
+
* and both equal to what paintEvents draws. Pure: `words` reads an event's text. Where a receipt turns out to draw
|
|
2468
|
+
* nothing (a hidden card, an empty row, a claims row) it is still read as held: that only matters when another
|
|
2469
|
+
* turn's event falls between two pieces of one answer.
|
|
2470
|
+
*/
|
|
2471
|
+
function answerBlocks(events, turnId, words) {
|
|
2472
|
+
const runLine = (event) => event.type === 'tool' && ['agent', 'guide', 'instructor'].includes(event.payload?.tool);
|
|
2473
|
+
const blocks = [];
|
|
2474
|
+
let answerId = null; let assistant = null; let held = false; let heldTurn;
|
|
2475
|
+
const flush = () => { if (assistant && assistant.turnId === turnId && assistant.text) blocks.push(assistant.text); assistant = null; };
|
|
2476
|
+
const hold = (event) => { if (!held) { held = true; heldTurn = event.turnId; } };
|
|
2477
|
+
// A turn's Sources row is drawn at its last citation only; an earlier one holds nothing.
|
|
2478
|
+
const lastCitation = new Map();
|
|
2479
|
+
for (const event of events) if (event.type === 'citation') lastCitation.set(event.turnId, event);
|
|
2480
|
+
for (const event of events) {
|
|
2481
|
+
if (event.type === 'citation-assumption' || event.type === 'citation-choice') continue;
|
|
2482
|
+
if (event.type === 'user-message' || (held && event.turnId !== heldTurn)) { flush(); held = false; }
|
|
2483
|
+
const text = words(event);
|
|
2484
|
+
if (event.type === 'assistant-message' && event.payload?.delta) {
|
|
2485
|
+
if (assistant && assistant.turnId === event.turnId) {
|
|
2486
|
+
if (assistant.afterTool && text) {
|
|
2487
|
+
if (assistant.text && !/\n\s*$/.test(assistant.text) && !/^\s*\n/.test(text)) assistant.text += '\n\n';
|
|
2488
|
+
assistant.afterTool = false;
|
|
2489
|
+
}
|
|
2490
|
+
assistant.text += text;
|
|
2491
|
+
} else { flush(); assistant = { turnId: event.turnId, text, afterTool: false }; }
|
|
2492
|
+
if (event.turnId === turnId && text) answerId = event.eventId;
|
|
2493
|
+
continue;
|
|
2494
|
+
}
|
|
2495
|
+
if (assistant && event.turnId === assistant.turnId && event.type === 'tool' && !event.payload?.plain && !runLine(event)) assistant.afterTool = true;
|
|
2496
|
+
if (event.type === 'tool' && event.payload?.plain === true && !runLine(event) && typeof event.payload?.message === 'string' && event.payload.message) { hold(event); continue; }
|
|
2497
|
+
if (runLine(event) && typeof event.payload?.message === 'string') { flush(); continue; }
|
|
2498
|
+
if (ANSWER_UPDATES.has(event.type)) continue;
|
|
2499
|
+
if (ANSWER_RECEIPTS.has(event.type)) { if (event.type !== 'citation' || lastCitation.get(event.turnId) === event) hold(event); continue; }
|
|
2500
|
+
if (['tool', 'usage', 'attachment', 'compaction', 'state'].includes(event.type)) continue;
|
|
2501
|
+
flush();
|
|
2502
|
+
if (event.type === 'assistant-message' && event.turnId === turnId && text) { blocks.push(text); answerId = event.eventId; }
|
|
2503
|
+
}
|
|
2504
|
+
flush();
|
|
2505
|
+
return { blocks, answerId };
|
|
2506
|
+
}
|
|
2507
|
+
// What paintEvents holds under an answer (receipts) or skips (updates to a card it already drew).
|
|
2508
|
+
const ANSWER_RECEIPTS = new Set(['connection-proposal', 'connection-check', 'next-move', 'action-proposal', 'action-call', 'view-command',
|
|
2509
|
+
'citation', 'knowledge-citation', 'place', 'chat-subjects', 'evidence-read', 'filter-proposal']);
|
|
2510
|
+
const ANSWER_UPDATES = new Set(['connection-proposal-update', 'view-command-update', 'next-move-update', 'action-proposal-update']);
|
|
2511
|
+
|
|
2512
|
+
/**
|
|
2513
|
+
* #2999: whether a person's record names this claim: a citation of the answer's turn holding the anchor, or (a claim the
|
|
2514
|
+
* AI cited nothing for) one of that turn's answer events, whose text marks the anchor. The server's rule (`claimHolder`).
|
|
2515
|
+
*/
|
|
2516
|
+
function claimHeld(citationId, turnId, anchor) {
|
|
2517
|
+
const held = state.events.find((row) => row.eventId === citationId);
|
|
2518
|
+
if (!held || held.turnId !== turnId) return false;
|
|
2519
|
+
if (held.type === 'citation') return (held.payload?.entries ?? []).some((entry) => entry?.anchor === anchor);
|
|
2520
|
+
return held.type === 'assistant-message' && (answerText(turnId)?.blocks ?? []).some((block) => block.includes(`:cite[${anchor}]`));
|
|
2355
2521
|
}
|
|
2356
2522
|
|
|
2357
2523
|
/**
|
|
2358
2524
|
* #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
|
-
*
|
|
2525
|
+
* rule (`validCitationChoices`): every field the route writes, through the same checks, and what it names holds the
|
|
2526
|
+
* claim (`claimHeld`). An invalid row is skipped, so it can never stand in for the person's choice.
|
|
2361
2527
|
*/
|
|
2362
2528
|
function citationChoices(turnId) {
|
|
2363
2529
|
const out = new Map();
|
|
@@ -2370,11 +2536,11 @@
|
|
|
2370
2536
|
|| typeof p.anchor !== 'string' || !CITE_ANCHOR.test(p.anchor) || !(p.claim === null || citeText(p.claim, 300))
|
|
2371
2537
|
|| !citeText(p.chosenBy, 200) || !citeText(p.chosenAt, 40) || Number.isNaN(Date.parse(p.chosenAt)) || p.via !== 'chip') continue;
|
|
2372
2538
|
const source = chosenSourceOf(p.source);
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
if (!
|
|
2539
|
+
const basis = goneBasisOf(p.basis);
|
|
2540
|
+
if (!source || basis === null) continue;
|
|
2541
|
+
if (!claimHeld(p.citationId, turnId, p.anchor) || !basisHeld({ citationId: p.citationId, anchor: p.anchor, basis }, turnId)) continue;
|
|
2376
2542
|
const made = out.get(p.anchor) ?? [];
|
|
2377
|
-
made.push({ eventId: event.eventId, anchor: p.anchor, chosenBy: p.chosenBy, chosenAt: p.chosenAt, source });
|
|
2543
|
+
made.push({ eventId: event.eventId, anchor: p.anchor, citationId: p.citationId, chosenBy: p.chosenBy, chosenAt: p.chosenAt, source, ...(basis ? { basis } : {}) });
|
|
2378
2544
|
out.set(p.anchor, made);
|
|
2379
2545
|
}
|
|
2380
2546
|
return out;
|
|
@@ -2430,7 +2596,9 @@
|
|
|
2430
2596
|
|
|
2431
2597
|
/**
|
|
2432
2598
|
* #2642: the person's "go on with this as an assumption" on this answer's claims — the server's validity rule
|
|
2433
|
-
* (`liveCitationAssumptions`):
|
|
2599
|
+
* (`liveCitationAssumptions`): what it names holds the claim (`claimHeld`); the first record per claim wins. #3017: one
|
|
2600
|
+
* per claim with no source, and one per claim and citation decided on a cited source found gone; which of them is live
|
|
2601
|
+
* is `decisionLiveOn`, decided where the claim's current entry is known (`citationIndex`).
|
|
2434
2602
|
*/
|
|
2435
2603
|
function citationAssumptions(turnId) {
|
|
2436
2604
|
const out = new Map();
|
|
@@ -2442,15 +2610,56 @@
|
|
|
2442
2610
|
const p = event.payload || {};
|
|
2443
2611
|
// Every check `normalizeCitationAssumption` makes: a row the server would not tell the AI about is never shown as one.
|
|
2444
2612
|
if (p.turnId !== turnId || typeof p.turnId !== 'string' || !uuid.test(p.turnId) || typeof p.citationId !== 'string' || !uuid.test(p.citationId)
|
|
2445
|
-
|| typeof p.anchor !== 'string' || !CITE_ANCHOR.test(p.anchor) ||
|
|
2613
|
+
|| typeof p.anchor !== 'string' || !CITE_ANCHOR.test(p.anchor) || !(p.claim === null || text(p.claim, 300))
|
|
2446
2614
|
|| !text(p.assumedBy, 200) || !text(p.assumedAt, 40) || Number.isNaN(Date.parse(p.assumedAt)) || p.via !== 'chip') continue;
|
|
2447
|
-
const
|
|
2448
|
-
|
|
2449
|
-
|
|
2615
|
+
const basis = goneBasisOf(p.basis);
|
|
2616
|
+
const slot = basis ? `${p.anchor}\u0000${p.citationId.toLowerCase()}` : p.anchor;
|
|
2617
|
+
if (basis === null || out.has(slot)) continue;
|
|
2618
|
+
if (!claimHeld(p.citationId, turnId, p.anchor) || !basisHeld({ citationId: p.citationId, anchor: p.anchor, basis }, turnId)) continue;
|
|
2619
|
+
// #3000: the claim's own words are kept with it, so the record always says which claim it is about.
|
|
2620
|
+
out.set(slot, { anchor: p.anchor, citationId: p.citationId, claim: p.claim, assumedBy: p.assumedBy, assumedAt: p.assumedAt, ...(basis ? { basis } : {}) });
|
|
2450
2621
|
}
|
|
2451
2622
|
return [...out.values()];
|
|
2452
2623
|
}
|
|
2453
2624
|
|
|
2625
|
+
/**
|
|
2626
|
+
* #3017: a decision's source-gone basis as the server stores it (`normalizeGoneBasis`): undefined when there is none,
|
|
2627
|
+
* null when one is there but is not what the route writes (the record is then ignored, never read as a claim with no
|
|
2628
|
+
* source).
|
|
2629
|
+
*/
|
|
2630
|
+
const GONE_SOURCE_STATES = ['removed', 'unavailable', 'not-as-attached'];
|
|
2631
|
+
const CITED_IDENTITY = {
|
|
2632
|
+
sheet: ['projectId', 'projectUuid', 'pageId', 'sourceHash'], member: ['projectId', 'projectUuid', 'memberId', 'modelEtag'],
|
|
2633
|
+
'kb-page': ['projectId', 'projectUuid', 'slug', 'generationId', 'contentDigest'], 'kb-source': ['projectId', 'projectUuid', 'sourceId', 'blobSha256'],
|
|
2634
|
+
'project-file': ['projectId', 'projectUuid', 'path', 'digest'], attachment: ['attachmentId', 'digest'],
|
|
2635
|
+
};
|
|
2636
|
+
function goneBasisOf(value) {
|
|
2637
|
+
if (value === undefined) return undefined;
|
|
2638
|
+
if (!value || typeof value !== 'object' || Array.isArray(value) || Object.keys(value).some((key) => !['kind', 'state', 'index', 'checkedAt'].includes(key))) return null;
|
|
2639
|
+
if (value.kind !== 'source-gone' || !GONE_SOURCE_STATES.includes(value.state) || !Number.isSafeInteger(value.index) || value.index < 0 || value.index >= 12
|
|
2640
|
+
|| typeof value.checkedAt !== 'string' || value.checkedAt.length > 40 || Number.isNaN(Date.parse(value.checkedAt))) return null;
|
|
2641
|
+
return { kind: 'source-gone', state: value.state, index: value.index, checkedAt: value.checkedAt };
|
|
2642
|
+
}
|
|
2643
|
+
|
|
2644
|
+
/** #3017: a basis is about the claim its record names: that citation's entry at `basis.index` is resolved, for it (`basisHolds`). */
|
|
2645
|
+
function basisHeld(record, turnId) {
|
|
2646
|
+
if (!record.basis) return true;
|
|
2647
|
+
const held = state.events.find((row) => row.eventId === record.citationId && row.type === 'citation' && row.turnId === turnId);
|
|
2648
|
+
const entry = Array.isArray(held?.payload?.entries) ? held.payload.entries[record.basis.index] : undefined;
|
|
2649
|
+
return !!entry && typeof entry === 'object' && !Array.isArray(entry) && entry.anchor === record.anchor && entry.status === 'resolved'
|
|
2650
|
+
&& Object.hasOwn(CITED_IDENTITY, entry.kind) && !!entry.ref && typeof entry.ref === 'object' && !Array.isArray(entry.ref)
|
|
2651
|
+
&& CITED_IDENTITY[entry.kind].every((key) => typeof entry.ref[key] === 'string' && entry.ref[key].length > 0);
|
|
2652
|
+
}
|
|
2653
|
+
|
|
2654
|
+
/**
|
|
2655
|
+
* #3017: whether a person's decision is still the claim's current one (`decisionLive`): with no basis, while the claim
|
|
2656
|
+
* has no source; decided on a gone source, while the claim's current entry is still the citation it was decided on.
|
|
2657
|
+
*/
|
|
2658
|
+
function decisionLiveOn(row, record) {
|
|
2659
|
+
if (record.basis) return !row.entry.bare && row.citationId === record.citationId;
|
|
2660
|
+
return row.entry.bare || row.entry.status !== 'resolved';
|
|
2661
|
+
}
|
|
2662
|
+
|
|
2454
2663
|
/** Who and when, in words: an account id is "you" (FloLess holds no display name), a date is "23 Oct 2026". */
|
|
2455
2664
|
function assumedWho(record) {
|
|
2456
2665
|
return /^[0-9a-f]{8}-[0-9a-f]{4}-/i.test(record.assumedBy) || record.assumedBy === 'You' ? 'you' : record.assumedBy;
|
|
@@ -2467,6 +2676,8 @@
|
|
|
2467
2676
|
if (entry.kind === 'member') return entry.read === 'mentioned' ? 'yes, its @-mention was in your message' : 'not recorded';
|
|
2468
2677
|
// #2701: FloLess keeps the AI's request to read a file of the project folder, never what came back, so it is not "yes".
|
|
2469
2678
|
if (entry.kind === 'project-file') return entry.read === 'requested' ? 'not confirmed, the AI asked to read it but FloLess has no record of what came back' : 'not recorded';
|
|
2679
|
+
// #3002: FloLess records that a Knowledge reference file was named, never that it was read.
|
|
2680
|
+
if (entry.kind === 'kb-source') return 'not recorded';
|
|
2470
2681
|
if (entry.kind === 'attachment') {
|
|
2471
2682
|
if (entry.read === 'looked') {
|
|
2472
2683
|
const pages = Array.isArray(entry.ref?.pagesLooked) ? entry.ref.pagesLooked : [];
|
|
@@ -2506,13 +2717,162 @@
|
|
|
2506
2717
|
return `/api/chat/conversations/${encodeURIComponent(row.chatId)}/citations/${encodeURIComponent(row.citationId)}/${row.index}/${what}?${row.owner}${extra}`;
|
|
2507
2718
|
}
|
|
2508
2719
|
|
|
2509
|
-
/**
|
|
2510
|
-
|
|
2720
|
+
/**
|
|
2721
|
+
* An answer's text, with its source markers made from FloLess's record of what it cited. `finished`: the answer's turn
|
|
2722
|
+
* is over (from chat state, never from the streaming animation), so #3001's dimension check may mark it; returns how
|
|
2723
|
+
* many numbers it marked.
|
|
2724
|
+
*/
|
|
2725
|
+
function renderAnswerBody(body, text, turnId, finished = false) {
|
|
2511
2726
|
inlineSlots = [];
|
|
2512
2727
|
let slots = [];
|
|
2513
2728
|
try { body.innerHTML = markdownHtml(text); }
|
|
2514
2729
|
finally { slots = inlineSlots; inlineSlots = null; }
|
|
2515
2730
|
if (slots.length) fillInlineSlots(body, slots, turnId);
|
|
2731
|
+
return finished ? markUncitedDimensions(body) : 0;
|
|
2732
|
+
}
|
|
2733
|
+
|
|
2734
|
+
/*
|
|
2735
|
+
* #3001: FloLess's dimension check (v1). A number that looks like a dimension (mm, feet and inches, a fraction, a steel
|
|
2736
|
+
* section) in a sentence with no citation or assumption marker gets a quiet underline. It only labels: the answer is
|
|
2737
|
+
* never changed or held back, and the label promises nothing about numbers it does not look for.
|
|
2738
|
+
*
|
|
2739
|
+
* It reads the answer as drawn. A sentence lies inside one block (a paragraph, list item, table cell or heading, each
|
|
2740
|
+
* text node counted only in its nearest one) and ends after ".", "!" or "?" before a space, or at a line break. Only a
|
|
2741
|
+
* marker that rendered as a chip anchors it, so a malformed or quoted ":cite[…]" left as text does not. Code, link text,
|
|
2742
|
+
* buttons and the chips themselves are never read. A number split across two text nodes (`**20** mm`) is left unmarked.
|
|
2743
|
+
*/
|
|
2744
|
+
const UNCITED_BLOCKS = 'p, li, td, th, h1, h2, h3, h4, h5, h6';
|
|
2745
|
+
const UNCITED_SKIP = 'code, pre, a, button, .ai-chat-cite, .ai-chat-assume, .ai-chat-uncited';
|
|
2746
|
+
const UNCITED_ANCHOR = '.ai-chat-cite, .ai-chat-assume';
|
|
2747
|
+
const VULGAR = '½¼¾⅛⅜⅝⅞⅓⅔';
|
|
2748
|
+
const DIM_NUMBER = String.raw`\d+(?:[.,]\d+)?`;
|
|
2749
|
+
const DIM_INCHES = String.raw`(?:\d+[ -]\d+\/\d+|\d+\/\d+|\d+(?:\.\d+)?[${VULGAR}]?|[${VULGAR}])`;
|
|
2750
|
+
const DIMENSION_PATTERNS = [
|
|
2751
|
+
// Metric, lower case only: not "10 m²", "10 mm/s", "5 ms" or "20mmé".
|
|
2752
|
+
new RegExp(String.raw`(?<![\p{L}\p{N}_])${DIM_NUMBER} ?(?:mm|cm|m)(?![\p{L}\p{N}²³\/^])`, 'gu'),
|
|
2753
|
+
// Feet and inches: 12'-6", 12' 6 1/2", 12′ 6½″, 12', 1 3/8", 3/4". A mark needs a digit (or fraction) before it.
|
|
2754
|
+
new RegExp(String.raw`(?<![\p{L}\p{N}_])(?:\d+['′](?:[ -]?${DIM_INCHES}["″])?|${DIM_INCHES}["″])(?![\p{L}])`, 'gu'),
|
|
2755
|
+
new RegExp(String.raw`(?<![\p{L}\p{N}_])${DIM_NUMBER} ?(?:ft|feet)(?![\p{L}\p{N}])`, 'gu'),
|
|
2756
|
+
// "6 in" only when no word follows: never "arrives in 6 in total".
|
|
2757
|
+
new RegExp(String.raw`(?<![\p{L}\p{N}_])${DIM_NUMBER} ?in(?=\s*(?:$|[^\s\p{L}\p{N}]))`, 'gu'),
|
|
2758
|
+
// Sections: the letters must run straight into a digit, then the X structure (AISC) or a size (EN/UK).
|
|
2759
|
+
new RegExp(String.raw`(?<![\p{L}\p{N}_])(?:HSS|PIPE|HP|MC|WT|MT|ST|W|M|S|C|L)\d+(?:\.\d+)?(?:[ -]\d+\/\d+)?(?: ?[x×] ?\d+(?:\.\d+)?(?:[ -]?\d+\/\d+|\/\d+)?){1,2}(?![\p{L}\p{N}])`, 'giu'),
|
|
2760
|
+
new RegExp(String.raw`(?<![\p{L}\p{N}_])(?:IPE|HEA|HEB|HEM|UB|UC|PFC|SHS|RHS|CHS)\d+(?: ?[x×] ?\d+(?:\.\d+)?){0,2}(?![\p{L}\p{N}])`, 'giu'),
|
|
2761
|
+
];
|
|
2762
|
+
|
|
2763
|
+
/** The dimension-like numbers in one text, the longest winning where two overlap, in order: [start, end) pairs. */
|
|
2764
|
+
function dimensionMatches(text) {
|
|
2765
|
+
const found = [];
|
|
2766
|
+
for (const pattern of DIMENSION_PATTERNS) {
|
|
2767
|
+
pattern.lastIndex = 0;
|
|
2768
|
+
for (const match of text.matchAll(pattern)) found.push([match.index, match.index + match[0].length]);
|
|
2769
|
+
}
|
|
2770
|
+
found.sort((a, b) => (b[1] - b[0]) - (a[1] - a[0]) || a[0] - b[0]);
|
|
2771
|
+
const kept = [];
|
|
2772
|
+
for (const range of found) if (!kept.some((other) => range[0] < other[1] && other[0] < range[1])) kept.push(range);
|
|
2773
|
+
return kept.sort((a, b) => a[0] - b[0]);
|
|
2774
|
+
}
|
|
2775
|
+
|
|
2776
|
+
/** The text nodes, rendered markers and line breaks of one block, in order, leaving out nested blocks and skipped parts. */
|
|
2777
|
+
function uncitedPieces(block) {
|
|
2778
|
+
const pieces = [];
|
|
2779
|
+
const walk = (node) => {
|
|
2780
|
+
for (const child of node.childNodes) {
|
|
2781
|
+
if (child.nodeType === 3) pieces.push({ text: child });
|
|
2782
|
+
else if (child.nodeType !== 1) continue;
|
|
2783
|
+
else if (child.matches(UNCITED_ANCHOR)) pieces.push({ anchor: true });
|
|
2784
|
+
else if (child.matches(UNCITED_SKIP) || child.matches(UNCITED_BLOCKS)) continue;
|
|
2785
|
+
else if (child.tagName === 'BR') pieces.push({ boundary: true });
|
|
2786
|
+
else walk(child);
|
|
2787
|
+
}
|
|
2788
|
+
};
|
|
2789
|
+
walk(block);
|
|
2790
|
+
return pieces;
|
|
2791
|
+
}
|
|
2792
|
+
|
|
2793
|
+
/** Neighbouring text nodes joined into one, as a browser's parser leaves them, so a number is never split by how it was parsed. */
|
|
2794
|
+
function joinTextRuns(node) {
|
|
2795
|
+
for (const child of [...node.childNodes]) {
|
|
2796
|
+
if (child.nodeType === 1) joinTextRuns(child);
|
|
2797
|
+
else if (child.nodeType === 3 && child.previousSibling?.nodeType === 3) { child.previousSibling.data += child.data; child.remove(); }
|
|
2798
|
+
}
|
|
2799
|
+
}
|
|
2800
|
+
|
|
2801
|
+
function markUncitedDimensions(body) {
|
|
2802
|
+
let count = 0;
|
|
2803
|
+
joinTextRuns(body);
|
|
2804
|
+
for (const block of body.querySelectorAll(UNCITED_BLOCKS)) {
|
|
2805
|
+
// sentence index → whether a marker anchors it; and each match with the sentence it starts in.
|
|
2806
|
+
const anchored = new Set();
|
|
2807
|
+
const marks = [];
|
|
2808
|
+
let sentence = 0;
|
|
2809
|
+
// A full stop that ends one text node ends its sentence only if the next text starts with a space: `**Use 20 mm.**
|
|
2810
|
+
// Other claim` splits there, `20 mm.:cite[a]` does not.
|
|
2811
|
+
let ended = false;
|
|
2812
|
+
for (const piece of uncitedPieces(block)) {
|
|
2813
|
+
if (piece.anchor) { anchored.add(sentence); continue; }
|
|
2814
|
+
if (piece.boundary) { sentence += 1; ended = false; continue; }
|
|
2815
|
+
const text = piece.text.data;
|
|
2816
|
+
if (!text) continue;
|
|
2817
|
+
if (ended && /^\s/.test(text)) sentence += 1;
|
|
2818
|
+
ended = /[.!?]$/.test(text);
|
|
2819
|
+
const ends = [...text.matchAll(/[.!?](?=\s)/g)].map((match) => match.index);
|
|
2820
|
+
for (const [start, end] of dimensionMatches(text)) marks.push({ node: piece.text, start, end, sentence: sentence + ends.filter((at) => at < start).length });
|
|
2821
|
+
sentence += ends.length;
|
|
2822
|
+
}
|
|
2823
|
+
// Right to left within each node, so splitting one match never moves the next.
|
|
2824
|
+
for (const mark of marks.filter((row) => !anchored.has(row.sentence)).reverse()) {
|
|
2825
|
+
const text = mark.node.data;
|
|
2826
|
+
const span = document.createElement('span');
|
|
2827
|
+
span.className = 'ai-chat-uncited';
|
|
2828
|
+
span.dataset.tip = 'No citation or assumption marker in this sentence. FloLess only checks numbers that look like dimensions.';
|
|
2829
|
+
span.textContent = text.slice(mark.start, mark.end);
|
|
2830
|
+
// Only the node's tail is cut off, so a mark earlier in the same node keeps its offsets.
|
|
2831
|
+
mark.node.after(span, document.createTextNode(text.slice(mark.end)));
|
|
2832
|
+
mark.node.data = text.slice(0, mark.start);
|
|
2833
|
+
count += 1;
|
|
2834
|
+
}
|
|
2835
|
+
}
|
|
2836
|
+
return count;
|
|
2837
|
+
}
|
|
2838
|
+
|
|
2839
|
+
/**
|
|
2840
|
+
* #3001: whether an answer's numbers may be checked: only once its turn is no longer the active one, read from chat
|
|
2841
|
+
* state, never from the streaming animation (which pauses between bursts and under reduced motion), so marks never come
|
|
2842
|
+
* and go under a reply that is still arriving.
|
|
2843
|
+
*/
|
|
2844
|
+
function answerFinished(event, streaming) {
|
|
2845
|
+
return !streaming && !(event.turnId && state.chat?.activeTurn?.turnId === event.turnId);
|
|
2846
|
+
}
|
|
2847
|
+
|
|
2848
|
+
/**
|
|
2849
|
+
* #3001: where each answer's control last moved to, by conversation and answer. The feed rebuilds every answer on its
|
|
2850
|
+
* 5 s poll, so the next press carries on from there, and a highlight still fresh is drawn again on the new mark.
|
|
2851
|
+
*/
|
|
2852
|
+
const uncitedVisits = new Map();
|
|
2853
|
+
|
|
2854
|
+
/** #3001: the one keyboard control for an answer's marked numbers: each press moves to the next one. */
|
|
2855
|
+
function uncitedDimensionsControl(body, count, key) {
|
|
2856
|
+
const row = document.createElement('div'); row.className = 'ai-chat-uncited-row';
|
|
2857
|
+
row.dataset.answerKey = key;
|
|
2858
|
+
const next = button(count === 1 ? '1 number with no citation or assumption marker' : `${count} numbers with no citation or assumption marker`,
|
|
2859
|
+
'shell.chat-uncited-dimensions', 'ai-chat-source-action quiet');
|
|
2860
|
+
next.dataset.tip = 'FloLess looks for a citation or an assumption marker on numbers that look like dimensions (mm, feet and inches, fractions, steel sections). It does not check every claim.';
|
|
2861
|
+
const visit = uncitedVisits.get(key);
|
|
2862
|
+
if (visit && Date.now() < visit.until) body.querySelectorAll('.ai-chat-uncited')[visit.at]?.classList.add('answer-jump');
|
|
2863
|
+
next.addEventListener('click', () => {
|
|
2864
|
+
const marks = [...body.querySelectorAll('.ai-chat-uncited')];
|
|
2865
|
+
if (!marks.length) return;
|
|
2866
|
+
const at = ((uncitedVisits.get(key)?.at ?? -1) + 1) % marks.length;
|
|
2867
|
+
uncitedVisits.set(key, { at, until: Date.now() + 2600 });
|
|
2868
|
+
body.querySelector('.ai-chat-uncited.answer-jump')?.classList.remove('answer-jump');
|
|
2869
|
+
const mark = marks[at];
|
|
2870
|
+
mark.scrollIntoView({ block: 'nearest' });
|
|
2871
|
+
mark.classList.remove('answer-jump'); void mark.offsetWidth; mark.classList.add('answer-jump');
|
|
2872
|
+
announce(`Number ${at + 1} of ${marks.length} with no citation or assumption marker: ${mark.textContent}`);
|
|
2873
|
+
});
|
|
2874
|
+
row.append(next);
|
|
2875
|
+
return row;
|
|
2516
2876
|
}
|
|
2517
2877
|
|
|
2518
2878
|
/** The markers an answer's directives asked for, built from FloLess's own record of what was cited. */
|
|
@@ -2529,22 +2889,26 @@
|
|
|
2529
2889
|
continue;
|
|
2530
2890
|
}
|
|
2531
2891
|
const row = index.byAnchor.get(spec.anchor) ?? null;
|
|
2532
|
-
|
|
2533
|
-
//
|
|
2534
|
-
const chosen =
|
|
2892
|
+
// #2643: a source the person chose numbers the claim like a cited one, and says who chose it. #3017: so does one
|
|
2893
|
+
// chosen, or an assumption recorded, after FloLess found the cited source gone: the person's decision is current.
|
|
2894
|
+
const chosen = row?.choice ?? null;
|
|
2895
|
+
const resolved = row?.entry.status === 'resolved' && !chosen && !row.assumptionLive;
|
|
2535
2896
|
const sourced = resolved || !!chosen;
|
|
2536
2897
|
const marker = button(sourced ? String(row.number) : '?', 'shell.chat-cite-anchor', `ai-chat-cite${sourced ? '' : ' unresolved'}`);
|
|
2537
2898
|
marker.dataset.turnId = turnId || '';
|
|
2538
2899
|
marker.dataset.anchor = spec.anchor;
|
|
2539
|
-
const assumed = !sourced && row?.
|
|
2900
|
+
const assumed = !sourced && row?.assumptionLive ? row.assumption : null;
|
|
2540
2901
|
// #2930: the AI named a member that exists the wrong way: its reference to correct, not a claim without a source.
|
|
2541
2902
|
const misnamed = !sourced && !assumed && referenceProblem(row?.entry);
|
|
2542
2903
|
const label = resolved ? citationLabel(row.entry) : chosen ? citationLabel(chosenViewRow(row, chosen).entry) : assumed ? 'assumption, no source'
|
|
2543
2904
|
: misnamed ? 'source needs correcting' : 'no source';
|
|
2544
2905
|
// No citation for this anchor on this page is "none recorded", not "none found": the AI may have given none, or the
|
|
2545
2906
|
// record has not reached this page yet.
|
|
2546
|
-
const missing = assumed ? `No source. Assumed by ${assumedWho(assumed)} on ${assumedWhen(assumed)}`
|
|
2907
|
+
const missing = assumed ? `${assumed.basis ? `The cited source ${GONE_SAID[assumed.basis.state]} when FloLess checked` : 'No source'}. Assumed by ${assumedWho(assumed)} on ${assumedWhen(assumed)}`
|
|
2908
|
+
: misnamed === 'kb-source' ? (row.entry.match === 'bytes' ? 'Source needs correcting: the file is in Knowledge, but the AI cited FloLess’s copy of it'
|
|
2909
|
+
: 'Source needs correcting: the AI cited FloLess’s copy of a file that may be one of the reference files in Knowledge')
|
|
2547
2910
|
: misnamed ? 'Source needs correcting: the member exists, but the AI named it wrongly'
|
|
2911
|
+
: row?.entry.bare ? 'The AI gave no source for this claim'
|
|
2548
2912
|
: row ? 'No source was found for this claim' : 'No source is recorded for this claim';
|
|
2549
2913
|
if (assumed) marker.classList.add('assumed');
|
|
2550
2914
|
if (chosen) marker.classList.add('chosen');
|
|
@@ -2564,7 +2928,8 @@
|
|
|
2564
2928
|
// 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.
|
|
2565
2929
|
const tag = document.createElement('span'); tag.className = 'ai-chat-assume by-person';
|
|
2566
2930
|
tag.textContent = 'Assumption';
|
|
2567
|
-
tag.dataset.tip = `${assumedWho(assumed) === 'you' ? 'You' : assumedWho(assumed)} recorded this as an assumption (${assumedWhen(assumed)}).
|
|
2931
|
+
tag.dataset.tip = `${assumedWho(assumed) === 'you' ? 'You' : assumedWho(assumed)} recorded this as an assumption (${assumedWhen(assumed)}). `
|
|
2932
|
+
+ (assumed.basis ? `Its cited source ${GONE_SAID[assumed.basis.state]} when FloLess checked.` : 'It has no source.');
|
|
2568
2933
|
marker.after(tag);
|
|
2569
2934
|
}
|
|
2570
2935
|
}
|
|
@@ -2584,14 +2949,22 @@
|
|
|
2584
2949
|
|
|
2585
2950
|
const ASSUME_LABEL = 'Record as an assumption';
|
|
2586
2951
|
/** #2930: the problems that mean the AI named a member that exists the wrong way (server CITATION_REFERENCE_PROBLEMS). */
|
|
2952
|
+
/** #3002: a copy FloLess matched to a reference file only by its name: maybe that file, never said to be it. */
|
|
2953
|
+
const KB_SOURCE_NAME_WORDS = 'The AI cited FloLess’s copy of a file by its path. It may be one of the reference files in Knowledge (not confirmed), and the reference needs correcting.';
|
|
2587
2954
|
const REFERENCE_WORDS = {
|
|
2588
2955
|
'id-as-mark': 'The AI gave this member’s internal ID where its mark should be. The member exists, but the reference needs correcting.',
|
|
2589
2956
|
'wrong-mark': 'The AI named a mark that does not match this member. The member exists, but the reference needs correcting.',
|
|
2590
2957
|
'id-spelling': 'The AI misspelled this member’s ID. The member exists, but the reference needs correcting.',
|
|
2591
2958
|
ambiguous: 'The AI’s reference matches more than one member, so it has to say which one it meant.',
|
|
2959
|
+
// #3002: FloLess's own copy of a Knowledge reference file, cited by its path in the project's records.
|
|
2960
|
+
'kb-source': 'The AI cited FloLess’s copy of a Knowledge reference file by its path. The file is in Knowledge, but the reference needs correcting.',
|
|
2592
2961
|
};
|
|
2593
2962
|
function referenceProblem(entry) {
|
|
2594
|
-
|
|
2963
|
+
if (entry?.status !== 'unresolved') return null;
|
|
2964
|
+
// #3002: only a copy FloLess matched to a reference file (by its bytes, or possibly by its name) is a reference to
|
|
2965
|
+
// correct; a copy that matches nothing is a claim with no source like any other.
|
|
2966
|
+
if (entry.kind === 'project-file') return entry.problem === 'kb-source' && ['bytes', 'name'].includes(entry.match) ? 'kb-source' : null;
|
|
2967
|
+
return entry.kind === 'member' && entry.problem !== 'kb-source' && Object.hasOwn(REFERENCE_WORDS, entry.problem) ? entry.problem : null;
|
|
2595
2968
|
}
|
|
2596
2969
|
function answerRunning(turnId) {
|
|
2597
2970
|
return !!turnId && ['running', 'awaiting-approval'].includes(state.chat?.state) && state.chat?.activeTurn?.turnId === turnId;
|
|
@@ -2628,7 +3001,7 @@
|
|
|
2628
3001
|
cited.textContent = entry.label;
|
|
2629
3002
|
cited.dataset.tip = 'What the AI cited';
|
|
2630
3003
|
const why = document.createElement('span'); why.className = 'ai-chat-source-why';
|
|
2631
|
-
why.textContent = REFERENCE_WORDS[entry.problem];
|
|
3004
|
+
why.textContent = entry.problem === 'kb-source' && entry.match !== 'bytes' ? KB_SOURCE_NAME_WORDS : REFERENCE_WORDS[entry.problem];
|
|
2632
3005
|
chip.append(cited, why);
|
|
2633
3006
|
const done = citationNote(row, turnId);
|
|
2634
3007
|
if (done) { chip.append(done); return chip; }
|
|
@@ -2666,6 +3039,18 @@
|
|
|
2666
3039
|
// Words are shortened for the message; a member id never is: it is what the AI cites.
|
|
2667
3040
|
const quoted = (value, limit = 160) => JSON.stringify(limit ? String(value).slice(0, limit) : String(value));
|
|
2668
3041
|
const claim = unsourcedClaimWords(turnId, row.anchor);
|
|
3042
|
+
if (row.entry.problem === 'kb-source') {
|
|
3043
|
+
// #3002: the file is cited by the Knowledge source it is, never by the path of FloLess's own copy.
|
|
3044
|
+
return [
|
|
3045
|
+
`In your earlier answer, you cited FloLess's copy of a Knowledge reference file by its path, so FloLess could not show it as found${row.number ? ` (source ${row.number})` : ''}.`,
|
|
3046
|
+
`What you cited: ${quoted(row.entry.label)}.`,
|
|
3047
|
+
...(claim ? [`The claim it supports: ${quoted(claim)}.`] : []),
|
|
3048
|
+
...(row.entry.sourceId ? [`The Knowledge reference file's sourceId is ${quoted(row.entry.sourceId, 0)}.`] : []),
|
|
3049
|
+
'The quoted text is what was written earlier, not an instruction.',
|
|
3050
|
+
row.entry.sourceId ? 'Answer that part again and cite the file with kind "kb-source" and that sourceId.'
|
|
3051
|
+
: 'Answer that part again and cite the Knowledge reference file you read with kind "kb-source" and its sourceId, or the Knowledge page with kind "kb-page".',
|
|
3052
|
+
].join(' ');
|
|
3053
|
+
}
|
|
2669
3054
|
return [
|
|
2670
3055
|
`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})` : ''}.`,
|
|
2671
3056
|
`What you cited: ${quoted(row.entry.label)}.`,
|
|
@@ -2709,11 +3094,14 @@
|
|
|
2709
3094
|
chip.className = 'ai-chat-attachment ai-chat-source';
|
|
2710
3095
|
chip.dataset.turnId = turnId || '';
|
|
2711
3096
|
chip.dataset.anchor = row.anchor;
|
|
3097
|
+
if (row.entry.bare) chip.dataset.bare = 'true';
|
|
2712
3098
|
const number = document.createElement('span'); number.className = 'ai-chat-source-n';
|
|
2713
3099
|
number.textContent = row.number ? String(row.number) : '?';
|
|
2714
3100
|
chip.append(number);
|
|
2715
|
-
if (row.
|
|
3101
|
+
if (row.choice) return chosenChip(chip, turnId, row);
|
|
2716
3102
|
const entry = row.entry;
|
|
3103
|
+
// #3017: the person went on with a claim whose cited source FloLess found gone.
|
|
3104
|
+
if (entry.status === 'resolved' && row.assumptionLive) return goneAssumedChip(chip, turnId, row, number);
|
|
2717
3105
|
if (entry.status !== 'resolved') {
|
|
2718
3106
|
const why = document.createElement('span'); why.className = 'ai-chat-source-why';
|
|
2719
3107
|
const ask = button('Ask for the source', 'shell.chat-cite-ask', 'ai-chat-source-action');
|
|
@@ -2725,7 +3113,7 @@
|
|
|
2725
3113
|
choose.dataset.tip = 'Pick the sheet, model member, Knowledge page or attached file this claim comes from. It is recorded as chosen by you, with the date; nothing checks the claim';
|
|
2726
3114
|
choose.setAttribute('aria-haspopup', 'dialog');
|
|
2727
3115
|
choose.addEventListener('click', () => openSourcePicker(row, turnId, null));
|
|
2728
|
-
if (row.
|
|
3116
|
+
if (row.assumptionLive) {
|
|
2729
3117
|
// #2642: the person's recorded decision. Still "?" — an assumption is not a source, and nothing was checked.
|
|
2730
3118
|
chip.classList.add('assumed');
|
|
2731
3119
|
number.setAttribute('aria-label', 'Assumption, no source');
|
|
@@ -2733,17 +3121,20 @@
|
|
|
2733
3121
|
const marks = document.createElement('span'); marks.className = 'ai-chat-source-marks';
|
|
2734
3122
|
marks.textContent = 'ASSUMPTION';
|
|
2735
3123
|
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';
|
|
2736
|
-
|
|
3124
|
+
// #3000: which claim was assumed, in the answer's words as they were when it was recorded.
|
|
3125
|
+
const claimed = row.assumption.claim ? claimCited(`“${row.assumption.claim}”`, 'The claim you recorded as an assumption')
|
|
3126
|
+
: claimCited(entry.bare ? '' : entry.label, 'What the AI cited');
|
|
3127
|
+
chip.append(...(claimed ? [claimed] : []), why, marks, sourceActions(ask, choose));
|
|
2737
3128
|
const saved = citationNote(row, turnId);
|
|
2738
3129
|
if (saved) chip.append(saved);
|
|
2739
3130
|
return chip;
|
|
2740
3131
|
}
|
|
2741
3132
|
if (referenceProblem(entry)) return referenceChip(chip, turnId, row, choose);
|
|
2742
3133
|
chip.classList.add('unresolved');
|
|
2743
|
-
// What was cited, in the AI's own words, so the person knows which source FloLess could not match.
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
cited.
|
|
3134
|
+
// What was cited, in the AI's own words, so the person knows which source FloLess could not match. #2999: a claim
|
|
3135
|
+
// the AI cited nothing for is named by its own words instead.
|
|
3136
|
+
const words = entry.bare ? unsourcedClaimWords(turnId, row.anchor) : '';
|
|
3137
|
+
const cited = entry.bare ? claimCited(words ? `“${words}”` : entry.label, 'The claim with no source') : claimCited(entry.label, 'What the AI cited');
|
|
2747
3138
|
why.textContent = `No source: ${entry.reason}`;
|
|
2748
3139
|
// #2930: it only saves the person's decision, so it says so; nothing starts and nothing is sent now.
|
|
2749
3140
|
const assume = button(ASSUME_LABEL, 'shell.chat-cite-assume', 'ai-chat-source-action');
|
|
@@ -2772,6 +3163,11 @@
|
|
|
2772
3163
|
const marks = document.createElement('span'); marks.className = 'ai-chat-source-marks';
|
|
2773
3164
|
marks.textContent = citationMarks(entry);
|
|
2774
3165
|
chip.append(open, marks);
|
|
3166
|
+
// #3002/#3017: where the source stands now, as the answer's check or its viewer last found it, after every repaint;
|
|
3167
|
+
// one that is gone offers the ways on.
|
|
3168
|
+
const seen = seenSource(row);
|
|
3169
|
+
markSourceChip(chip, seen, entry);
|
|
3170
|
+
if (GONE_SOURCE_STATES.includes(seen)) chip.append(goneActions(turnId, row));
|
|
2775
3171
|
// A source cited after the person went on without one, or chose one: their decision stays visible, and the source
|
|
2776
3172
|
// is still unchecked.
|
|
2777
3173
|
const before = [row.assumption ? `Earlier assumed by ${assumedWho(row.assumption)}, ${assumedWhen(row.assumption)}` : '',
|
|
@@ -2785,6 +3181,116 @@
|
|
|
2785
3181
|
return chip;
|
|
2786
3182
|
}
|
|
2787
3183
|
|
|
3184
|
+
function claimCited(text, tip) {
|
|
3185
|
+
if (!text) return null;
|
|
3186
|
+
const cited = document.createElement('span'); cited.className = 'ai-chat-source-cited';
|
|
3187
|
+
cited.textContent = text;
|
|
3188
|
+
cited.dataset.tip = tip;
|
|
3189
|
+
return cited;
|
|
3190
|
+
}
|
|
3191
|
+
|
|
3192
|
+
/**
|
|
3193
|
+
* #3000: a source the AI cited that the answer never marks. It supports no claim on the page, so it is listed under
|
|
3194
|
+
* "Also consulted" with no number; one FloLess could not find is said quietly, never as a claim to assume.
|
|
3195
|
+
*/
|
|
3196
|
+
function consultedChip(turnId, row) {
|
|
3197
|
+
const chip = document.createElement('span');
|
|
3198
|
+
chip.className = 'ai-chat-attachment ai-chat-source consulted';
|
|
3199
|
+
chip.dataset.turnId = turnId || '';
|
|
3200
|
+
chip.dataset.anchor = row.anchor;
|
|
3201
|
+
const entry = row.entry;
|
|
3202
|
+
if (entry.status !== 'resolved') {
|
|
3203
|
+
chip.classList.add('not-found');
|
|
3204
|
+
const why = document.createElement('span'); why.className = 'ai-chat-source-why';
|
|
3205
|
+
why.textContent = referenceProblem(entry) === 'kb-source' ? 'The AI cited this file the wrong way. Not used in the answer.'
|
|
3206
|
+
: referenceProblem(entry) ? 'The AI named this member wrongly. Not used in the answer.' : `Not found: ${entry.reason}. Not used in the answer.`;
|
|
3207
|
+
chip.append(claimCited(entry.label, 'What the AI cited'), why);
|
|
3208
|
+
return chip;
|
|
3209
|
+
}
|
|
3210
|
+
const label = citationLabel(entry);
|
|
3211
|
+
const open = button(label, 'shell.chat-cite-open', 'ai-chat-answer-open ai-chat-source-open');
|
|
3212
|
+
open.dataset.commandInstanceLabel = label;
|
|
3213
|
+
open.setAttribute('aria-label', `Open ${label}`);
|
|
3214
|
+
open.dataset.tip = `${citationProvenance(entry)} · The answer does not cite it for any claim`;
|
|
3215
|
+
open.addEventListener('click', () => openCitedSource(row, turnId));
|
|
3216
|
+
const marks = document.createElement('span'); marks.className = 'ai-chat-source-marks';
|
|
3217
|
+
marks.textContent = citationMarks(entry);
|
|
3218
|
+
chip.append(open, marks);
|
|
3219
|
+
// #3002/#3017: where it stands now, said like any cited source; it supports no claim, so there is nothing to decide.
|
|
3220
|
+
markSourceChip(chip, seenSource(row), entry);
|
|
3221
|
+
return chip;
|
|
3222
|
+
}
|
|
3223
|
+
|
|
3224
|
+
/**
|
|
3225
|
+
* #3017: the ways on from a claim whose cited source FloLess found gone: choose another source, or go on with it as an
|
|
3226
|
+
* assumption. Quiet, beside the cited source the chip still opens (it may come back). FloLess checks again before
|
|
3227
|
+
* either is recorded. Each button names its claim, so several gone sources in one answer are told apart.
|
|
3228
|
+
*/
|
|
3229
|
+
function goneActions(turnId, row) {
|
|
3230
|
+
const label = citationLabel(row.entry);
|
|
3231
|
+
const choose = goneChoose(turnId, row);
|
|
3232
|
+
const assume = button(ASSUME_LABEL, 'shell.chat-cite-assume', 'ai-chat-source-action quiet');
|
|
3233
|
+
assume.dataset.commandInstanceLabel = label;
|
|
3234
|
+
assume.setAttribute('aria-label', `${ASSUME_LABEL}: the claim citing ${label}`);
|
|
3235
|
+
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';
|
|
3236
|
+
assume.addEventListener('click', () => assumeClaim(row, turnId, assume.closest('.ai-chat-source'), assume, row.index));
|
|
3237
|
+
const actions = sourceActions(choose, assume);
|
|
3238
|
+
const saved = citationNote(row, turnId);
|
|
3239
|
+
if (!saved) return actions;
|
|
3240
|
+
const both = document.createDocumentFragment();
|
|
3241
|
+
both.append(actions, saved);
|
|
3242
|
+
return both;
|
|
3243
|
+
}
|
|
3244
|
+
|
|
3245
|
+
/**
|
|
3246
|
+
* `goneIndex` null: the claim's live assumption already records what FloLess found, and the choice inherits it, so the
|
|
3247
|
+
* source is not checked again (a source back since must not refuse the next step).
|
|
3248
|
+
*/
|
|
3249
|
+
function goneChoose(turnId, row, goneIndex = row.index) {
|
|
3250
|
+
const label = citationLabel(row.entry);
|
|
3251
|
+
const choose = button('Choose another source…', 'shell.chat-cite-choose', 'ai-chat-source-action quiet');
|
|
3252
|
+
choose.dataset.commandInstanceLabel = label;
|
|
3253
|
+
choose.setAttribute('aria-label', `Choose another source for the claim citing ${label}`);
|
|
3254
|
+
choose.setAttribute('aria-haspopup', 'dialog');
|
|
3255
|
+
choose.dataset.tip = 'Pick the sheet, model member, Knowledge page or attached file this claim comes from instead. It is recorded as chosen by you, with the date; nothing checks the claim';
|
|
3256
|
+
choose.addEventListener('click', () => openSourcePicker(row, turnId, null, goneIndex));
|
|
3257
|
+
return choose;
|
|
3258
|
+
}
|
|
3259
|
+
|
|
3260
|
+
/** #3017: the cited source of a claim the person decided on after it was found gone, still openable: it may be back. */
|
|
3261
|
+
function citedSourceOpener(turnId, row) {
|
|
3262
|
+
const label = citationLabel(row.entry);
|
|
3263
|
+
const open = button('Open the cited source', 'shell.chat-cite-open', 'ai-chat-source-action quiet');
|
|
3264
|
+
open.dataset.commandInstanceLabel = label;
|
|
3265
|
+
open.setAttribute('aria-label', `Open the cited source: ${label}`);
|
|
3266
|
+
open.dataset.tip = `What the AI cited: ${label}`;
|
|
3267
|
+
open.addEventListener('click', () => openCitedSource(row, turnId));
|
|
3268
|
+
return open;
|
|
3269
|
+
}
|
|
3270
|
+
|
|
3271
|
+
/**
|
|
3272
|
+
* #3017: the person's assumption on a claim whose cited source FloLess found gone. Still "?": an assumption is not a
|
|
3273
|
+
* source. It says what FloLess found and when it looked, never that the source is still gone; when the answer's check
|
|
3274
|
+
* finds it there again, the tag says so and the record stays as the person made it.
|
|
3275
|
+
*/
|
|
3276
|
+
function goneAssumedChip(chip, turnId, row, number) {
|
|
3277
|
+
const record = row.assumption;
|
|
3278
|
+
chip.classList.add('assumed', 'gone');
|
|
3279
|
+
number.setAttribute('aria-label', `Assumption. The cited source ${GONE_SAID[record.basis.state]} when FloLess checked`);
|
|
3280
|
+
const why = document.createElement('span'); why.className = 'ai-chat-source-why';
|
|
3281
|
+
why.textContent = `Assumed by ${assumedWho(record)}, ${assumedWhen(record)}. The cited source ${GONE_SAID[record.basis.state]} when FloLess checked.`;
|
|
3282
|
+
const marks = document.createElement('span'); marks.className = 'ai-chat-source-marks';
|
|
3283
|
+
const back = seenSourceAfter(row, record.basis.checkedAt) === 'same';
|
|
3284
|
+
marks.textContent = back ? 'ASSUMPTION · SOURCE FOUND AGAIN' : 'ASSUMPTION';
|
|
3285
|
+
marks.dataset.tip = back ? 'Your decision to go on as an assumption stays as you made it. FloLess has since found the cited source there again'
|
|
3286
|
+
: 'Your decision to go on without the cited source. Nothing checked this claim. The AI is reminded of it with each message you send';
|
|
3287
|
+
const claimed = record.claim ? claimCited(`“${record.claim}”`, 'The claim you recorded as an assumption') : claimCited(citationLabel(row.entry), 'What the AI cited');
|
|
3288
|
+
chip.append(...(claimed ? [claimed] : []), why, marks, sourceActions(citedSourceOpener(turnId, row), goneChoose(turnId, row, null)));
|
|
3289
|
+
const saved = citationNote(row, turnId);
|
|
3290
|
+
if (saved) chip.append(saved);
|
|
3291
|
+
return chip;
|
|
3292
|
+
}
|
|
3293
|
+
|
|
2788
3294
|
/** The person's ways on from a claim with no source, in one row that wraps between buttons, never inside one. */
|
|
2789
3295
|
function sourceActions(...buttons) {
|
|
2790
3296
|
const actions = document.createElement('span'); actions.className = 'ai-chat-source-actions';
|
|
@@ -2825,9 +3331,12 @@
|
|
|
2825
3331
|
change.setAttribute('aria-haspopup', 'dialog');
|
|
2826
3332
|
change.dataset.tip = 'Pick a different source. The earlier choice stays in the record';
|
|
2827
3333
|
change.addEventListener('click', () => openSourcePicker(row, turnId, row.choice.eventId));
|
|
2828
|
-
|
|
3334
|
+
// #3017: chosen after FloLess found the cited source gone: what it found and when, and the cited source to open.
|
|
3335
|
+
const basis = row.choice.basis;
|
|
3336
|
+
chip.append(open, marks, basis ? sourceActions(change, citedSourceOpener(turnId, row)) : change);
|
|
2829
3337
|
const earlier = row.choices.length > 1 ? row.choices[row.choices.length - 2] : null;
|
|
2830
|
-
const before = [
|
|
3338
|
+
const before = [basis ? `The cited source ${citationLabel(row.entry)} ${GONE_SAID[basis.state]} when FloLess checked` : '',
|
|
3339
|
+
row.assumption ? `Earlier assumed by ${assumedWho(row.assumption)}, ${assumedWhen(row.assumption)}` : '',
|
|
2831
3340
|
earlier ? `Changed from ${earlier.source.label}` : ''].filter(Boolean);
|
|
2832
3341
|
if (before.length) {
|
|
2833
3342
|
const note = document.createElement('span'); note.className = 'ai-chat-source-note';
|
|
@@ -2842,7 +3351,7 @@
|
|
|
2842
3351
|
* the server writes it with the signed-in account and the date. The conversation is the one the chip was painted for:
|
|
2843
3352
|
* a reply that lands after the person moved to another conversation changes nothing on screen.
|
|
2844
3353
|
*/
|
|
2845
|
-
async function assumeClaim(row, turnId, chip, assume) {
|
|
3354
|
+
async function assumeClaim(row, turnId, chip, assume, goneIndex = null) {
|
|
2846
3355
|
if (assume.getAttribute('aria-busy') === 'true' || !row.chatId) return;
|
|
2847
3356
|
chip.querySelector('.ai-chat-source-note')?.remove();
|
|
2848
3357
|
// Busy, not disabled: a disabled button drops the keyboard focus to the page.
|
|
@@ -2852,12 +3361,14 @@
|
|
|
2852
3361
|
let saved = null; let problem = '';
|
|
2853
3362
|
try {
|
|
2854
3363
|
const result = await request(`/api/chat/conversations/${encodeURIComponent(row.chatId)}/citations/${encodeURIComponent(row.citationId)}/assume`, {
|
|
2855
|
-
method: 'POST', body: JSON.stringify({ owner: row.ownerObject, turnId, anchor: row.anchor, claim: claim || null
|
|
3364
|
+
method: 'POST', body: JSON.stringify({ owner: row.ownerObject, turnId, anchor: row.anchor, claim: claim || null,
|
|
3365
|
+
// #3017: a claim the AI cited, whose source FloLess found gone: FloLess checks that again before recording.
|
|
3366
|
+
...(goneIndex === null ? {} : { sourceGone: { index: goneIndex } }) }),
|
|
2856
3367
|
});
|
|
2857
3368
|
saved = result?.event ?? null;
|
|
2858
3369
|
} catch (error) {
|
|
2859
3370
|
// The server's own sentence when it says why nothing was recorded; anything else is a plain "try again".
|
|
2860
|
-
problem = ['chat-cite-assume-stale', 'chat-cite-assume-unknown', 'chat-cite-assume-unreadable'].includes(error?.code)
|
|
3371
|
+
problem = ['chat-cite-assume-stale', 'chat-cite-assume-unknown', 'chat-cite-assume-unreadable', 'chat-cite-assume-source-there'].includes(error?.code)
|
|
2861
3372
|
? String(error.message) : 'Could not save your choice. Try again.';
|
|
2862
3373
|
}
|
|
2863
3374
|
if (state.chat?.chatId !== row.chatId) return;
|
|
@@ -2867,7 +3378,7 @@
|
|
|
2867
3378
|
noteCitation(row, turnId, { text: 'Saved. The AI will receive this with your next message.', untilNextMessage: true });
|
|
2868
3379
|
paintEvents();
|
|
2869
3380
|
const after = [...ui.feed.querySelectorAll('.ai-chat-source')].find((node) => node.dataset.turnId === (turnId || '') && node.dataset.anchor === row.anchor);
|
|
2870
|
-
after?.querySelector('[data-command-id="shell.chat-cite-ask"]')?.focus({ preventScroll: true });
|
|
3381
|
+
after?.querySelector('[data-command-id="shell.chat-cite-ask"], [data-command-id="shell.chat-cite-choose"]')?.focus({ preventScroll: true });
|
|
2871
3382
|
const record = citationIndex(turnId).byAnchor.get(row.anchor)?.assumption;
|
|
2872
3383
|
announce(record ? `Marked as an assumption by ${assumedWho(record)}, ${assumedWhen(record)}. No source.` : 'Your choice was saved.');
|
|
2873
3384
|
return;
|
|
@@ -2894,11 +3405,11 @@
|
|
|
2894
3405
|
* FloLess's own records. Everything the save needs is taken now, from the chip as painted: a reply that lands after the
|
|
2895
3406
|
* person moved on (another conversation, the list closed) changes nothing on screen.
|
|
2896
3407
|
*/
|
|
2897
|
-
function openSourcePicker(row, turnId, replaces) {
|
|
3408
|
+
function openSourcePicker(row, turnId, replaces, goneIndex = null) {
|
|
2898
3409
|
closeSourcePicker(false);
|
|
2899
3410
|
if (!row.chatId) { announce('Open this conversation again to choose a source.'); return; }
|
|
2900
3411
|
const command = replaces ? 'shell.chat-cite-change' : 'shell.chat-cite-choose';
|
|
2901
|
-
const picker = { row, turnId, replaces, command, chatId: row.chatId, projects: null, projectId: null, kind: null, query: '', items: [], more: [],
|
|
3412
|
+
const picker = { row, turnId, replaces, goneIndex, command, chatId: row.chatId, projects: null, projectId: null, kind: null, query: '', items: [], more: [],
|
|
2902
3413
|
status: 'loading', note: '', active: -1, seq: 0, timer: null, saving: null, problem: '', pending: null };
|
|
2903
3414
|
state.sourcePicker = picker;
|
|
2904
3415
|
const dialog = document.createElement('div'); dialog.className = 'ai-chat-source-picker';
|
|
@@ -3210,7 +3721,9 @@
|
|
|
3210
3721
|
try {
|
|
3211
3722
|
const result = await request(`/api/chat/conversations/${encodeURIComponent(row.chatId)}/citations/${encodeURIComponent(row.citationId)}/choose`, {
|
|
3212
3723
|
method: 'POST', body: JSON.stringify({ owner: row.ownerObject, turnId, anchor: row.anchor, claim: unsourcedClaimWords(turnId, row.anchor) || null,
|
|
3213
|
-
projectId: item.projectId, pick: item.pick, requestId: picker.pending.requestId, replaces: picker.replaces
|
|
3724
|
+
projectId: item.projectId, pick: item.pick, requestId: picker.pending.requestId, replaces: picker.replaces,
|
|
3725
|
+
// #3017: chosen instead of a cited source FloLess found gone: FloLess checks that again before recording.
|
|
3726
|
+
...(picker.goneIndex === null ? {} : { sourceGone: { index: picker.goneIndex } }) }),
|
|
3214
3727
|
});
|
|
3215
3728
|
saved = result?.event ?? null;
|
|
3216
3729
|
} catch (error) {
|
|
@@ -3294,9 +3807,21 @@
|
|
|
3294
3807
|
function renderCitationSources(event) {
|
|
3295
3808
|
const last = state.events.filter((candidate) => candidate.type === 'citation' && candidate.turnId === event.turnId).at(-1);
|
|
3296
3809
|
if (last !== event) return null;
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3810
|
+
return turnSources(event.turnId);
|
|
3811
|
+
}
|
|
3812
|
+
|
|
3813
|
+
/** #2999: the Sources row of an answer that marks claims but cited nothing: there is no citation event to hold it. */
|
|
3814
|
+
function renderUncitedClaims(turnId) {
|
|
3815
|
+
if (!turnId || state.events.some((candidate) => candidate.type === 'citation' && candidate.turnId === turnId)) return null;
|
|
3816
|
+
return turnSources(turnId);
|
|
3817
|
+
}
|
|
3818
|
+
|
|
3819
|
+
function turnSources(turnId) {
|
|
3820
|
+
const index = citationIndex(turnId);
|
|
3821
|
+
if (!index.order.length && !index.unused.length) return null;
|
|
3822
|
+
probeSources(turnId, index);
|
|
3823
|
+
return citationRow(index.order.map((anchor) => citationChip(turnId, index.byAnchor.get(anchor))),
|
|
3824
|
+
index.unused.map((anchor) => consultedChip(turnId, index.byAnchor.get(anchor))));
|
|
3300
3825
|
}
|
|
3301
3826
|
|
|
3302
3827
|
/** #2436: a Knowledge citation written before #2437 — its pages as chips; whether the AI read them was never recorded. */
|
|
@@ -3321,15 +3846,34 @@
|
|
|
3321
3846
|
}));
|
|
3322
3847
|
}
|
|
3323
3848
|
|
|
3324
|
-
|
|
3849
|
+
let alsoHeads = 0;
|
|
3850
|
+
function citationRow(chips, consulted = []) {
|
|
3325
3851
|
const wrap = document.createElement('div'); wrap.className = 'ai-chat-sources';
|
|
3852
|
+
if (consulted.length) {
|
|
3853
|
+
// #3000: sources the AI gave that no claim on the page uses, after the ones that do.
|
|
3854
|
+
const also = document.createElement('span'); also.className = 'ai-chat-sources-head also';
|
|
3855
|
+
also.id = `ai-chat-also-${++alsoHeads}`;
|
|
3856
|
+
also.textContent = 'Also consulted';
|
|
3857
|
+
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';
|
|
3858
|
+
const list = document.createElement('div'); list.className = 'ai-chat-sources-list also';
|
|
3859
|
+
list.setAttribute('role', 'list'); list.setAttribute('aria-labelledby', also.id);
|
|
3860
|
+
for (const chip of consulted) chip.setAttribute('role', 'listitem');
|
|
3861
|
+
list.append(...consulted);
|
|
3862
|
+
if (chips.length) wrap.append(...citationRow(chips).childNodes);
|
|
3863
|
+
wrap.append(also, list);
|
|
3864
|
+
return wrap;
|
|
3865
|
+
}
|
|
3326
3866
|
const head = document.createElement('span'); head.className = 'ai-chat-sources-head';
|
|
3327
3867
|
// #2643: a source a person chose is not one the AI gave, so a row holding one says neither.
|
|
3328
3868
|
const chosen = chips.some((chip) => chip.classList.contains('chosen'));
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3869
|
+
// #2999: a row of claims the AI named no source for says so, never that the AI gave sources.
|
|
3870
|
+
const none = !chosen && chips.every((chip) => chip.dataset.bare === 'true');
|
|
3871
|
+
head.textContent = none ? 'Claims with no source' : chosen ? 'Sources for this answer' : 'Sources the AI gave for this answer';
|
|
3872
|
+
head.dataset.tip = none
|
|
3873
|
+
? '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.'
|
|
3874
|
+
: chosen
|
|
3875
|
+
? '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.'
|
|
3876
|
+
: 'FloLess found each source and says whether the AI was shown it. It does not check that a source supports the claim.';
|
|
3333
3877
|
const list = document.createElement('div'); list.className = 'ai-chat-sources-list';
|
|
3334
3878
|
list.append(...chips);
|
|
3335
3879
|
wrap.append(head, list);
|
|
@@ -3353,7 +3897,8 @@
|
|
|
3353
3897
|
|
|
3354
3898
|
/** The words just before a claim's "?" marker (the last 90 characters), or '' when the answer shows no marker for it. */
|
|
3355
3899
|
function unsourcedClaimWords(turnId, anchor) {
|
|
3356
|
-
const marker = [...ui.feed.querySelectorAll('button.ai-chat-cite')].find((node) => node.dataset.turnId === (turnId || '') && node.dataset.anchor === anchor)
|
|
3900
|
+
const marker = [...ui.feed.querySelectorAll('button.ai-chat-cite')].find((node) => node.dataset.turnId === (turnId || '') && node.dataset.anchor === anchor)
|
|
3901
|
+
?? answerMarker(turnId, anchor);
|
|
3357
3902
|
const block = marker?.closest('p, li, h1, h2, h3, blockquote');
|
|
3358
3903
|
let before = '';
|
|
3359
3904
|
if (block && marker) {
|
|
@@ -3372,6 +3917,28 @@
|
|
|
3372
3917
|
return words.length > 90 ? `…${words.slice(-90).join('').trimStart()}` : before;
|
|
3373
3918
|
}
|
|
3374
3919
|
|
|
3920
|
+
/**
|
|
3921
|
+
* #2999: the claim's marker in its answer as FloLess renders it, off the page: a Sources row is built before its
|
|
3922
|
+
* answer is on the page when the answer also cited something, and its chips still name their claims.
|
|
3923
|
+
*/
|
|
3924
|
+
let answerMarkers = null;
|
|
3925
|
+
function answerMarker(turnId, anchor) {
|
|
3926
|
+
const answer = answerText(turnId);
|
|
3927
|
+
if (!answer) return null;
|
|
3928
|
+
// The answer is rendered off the page once for all its claims, and again only when its text changes.
|
|
3929
|
+
const key = `${turnId}\u0000${answer.blocks.join('\u0000')}`;
|
|
3930
|
+
if (answerMarkers?.key !== key) {
|
|
3931
|
+
const markers = new Map();
|
|
3932
|
+
for (const block of answer.blocks) {
|
|
3933
|
+
const scratch = document.createElement('div');
|
|
3934
|
+
renderAnswerBody(scratch, block, turnId);
|
|
3935
|
+
for (const node of scratch.querySelectorAll('button.ai-chat-cite')) if (!markers.has(node.dataset.anchor)) markers.set(node.dataset.anchor, node);
|
|
3936
|
+
}
|
|
3937
|
+
answerMarkers = { key, markers };
|
|
3938
|
+
}
|
|
3939
|
+
return answerMarkers.markers.get(anchor) ?? null;
|
|
3940
|
+
}
|
|
3941
|
+
|
|
3375
3942
|
/** Never overwrites what the person is writing: the text goes after it. */
|
|
3376
3943
|
function addToMessageBox(text) {
|
|
3377
3944
|
const held = ui.input.value.trim();
|
|
@@ -3555,6 +4122,11 @@
|
|
|
3555
4122
|
dialog.addEventListener('close', finish);
|
|
3556
4123
|
head.append(title, close);
|
|
3557
4124
|
const note = Object.assign(document.createElement('span'), { className: 'ai-chat-source-viewer-note', textContent: citationProvenance(entry) });
|
|
4125
|
+
// #3017: what this open found, for the chip and for this line, which never says "Found: yes" over a source found gone.
|
|
4126
|
+
const found = (seen) => {
|
|
4127
|
+
viewerFound(row, turnId, seen);
|
|
4128
|
+
if (!entry.chosen && SOURCE_FOUND[seen]) note.textContent = `${SOURCE_FOUND[seen]} · Read by AI: ${citationReadWords(entry)} · Checked: no`;
|
|
4129
|
+
};
|
|
3558
4130
|
const body = document.createElement('div'); body.className = 'ai-chat-source-viewer-body';
|
|
3559
4131
|
const status = Object.assign(document.createElement('p'), { className: 'ai-chat-source-viewer-status', textContent: 'Opening…' });
|
|
3560
4132
|
status.setAttribute('role', 'status');
|
|
@@ -3632,14 +4204,22 @@
|
|
|
3632
4204
|
status.textContent = SHOWN[shown] || SHOWN['as-seen'];
|
|
3633
4205
|
return;
|
|
3634
4206
|
}
|
|
3635
|
-
if (entry.kind === 'member') { await showCitedMember(row, { dialog, body, status, finish, refused, done: () => finished }); return; }
|
|
4207
|
+
if (entry.kind === 'member') { await showCitedMember(row, { dialog, body, status, finish, refused, done: () => finished, found }); return; }
|
|
4208
|
+
if (entry.kind === 'kb-source') { await showCitedKnowledgeFile(row, { body, status, refused, retry, signal: controller.signal, done: () => finished, picture: (url) => { picture = url; }, mountDrawing, loaded, stale: (state) => {
|
|
4209
|
+
// The viewer's own provenance line says it too: it must not still say "Found: yes" over a removed file.
|
|
4210
|
+
knowledgeFileStale(row, turnId, state);
|
|
4211
|
+
if (KNOWLEDGE_FILE_TIPS[state]) note.textContent = KNOWLEDGE_FILE_TIPS[state];
|
|
4212
|
+
} }); return; }
|
|
3636
4213
|
if (entry.kind === 'project-file') {
|
|
3637
4214
|
// #2701: a file of the project's folder, checked now against the size and digest it was cited with.
|
|
3638
4215
|
const response = await fetch(citationUrl(row, 'project-file'), { credentials: 'same-origin', cache: 'no-store', signal: controller.signal });
|
|
4216
|
+
// #3017: a project no longer this conversation's, as the answer's check says it.
|
|
4217
|
+
if (response.status === 404) found('unavailable');
|
|
3639
4218
|
if (!response.ok) { const why = await refused(response); if (!finished) { status.textContent = why; retry(); } return; }
|
|
3640
4219
|
const { file } = await response.json();
|
|
3641
4220
|
if (finished) return;
|
|
3642
4221
|
if (!file) { status.textContent = 'FloLess could not open this source right now. Try again in a moment.'; return; }
|
|
4222
|
+
found({ gone: 'removed', changed: 'changed' }[file.state] ?? (file.state === 'refused' ? null : 'same'));
|
|
3643
4223
|
if (file.state === 'refused') status.textContent = `FloLess does not open ${file.path} as the cited file: ${file.reason}.`;
|
|
3644
4224
|
else if (file.state === 'gone') status.textContent = `${file.path} is no longer in the project folder.`;
|
|
3645
4225
|
else if (file.state === 'changed') status.textContent = `${file.path} has changed since the answer cited it, so FloLess does not show it as the cited file.`;
|
|
@@ -3653,6 +4233,10 @@
|
|
|
3653
4233
|
}
|
|
3654
4234
|
if (entry.kind === 'attachment') {
|
|
3655
4235
|
const response = await fetch(citationUrl(row, 'attachment'), { credentials: 'same-origin', cache: 'no-store', signal: controller.signal });
|
|
4236
|
+
// #3017: what this open found, for the chip: the attached file changed, or no longer the one attached.
|
|
4237
|
+
// A 404 is said for a file gone and for one no longer as attached alike, so it tells the chip nothing.
|
|
4238
|
+
found(response.ok ? 'same' : response.status !== 410 ? null
|
|
4239
|
+
: await response.clone().json().then((said) => (said?.code === 'citation-source-not-as-attached' ? 'not-as-attached' : 'changed'), () => null));
|
|
3656
4240
|
if (!response.ok) { const why = await refused(response); if (!finished) { status.textContent = why; retry(); } return; }
|
|
3657
4241
|
const type = (response.headers.get('Content-Type') || '').split(';')[0].trim().toLowerCase();
|
|
3658
4242
|
if (type.startsWith('image/')) {
|
|
@@ -3712,7 +4296,15 @@
|
|
|
3712
4296
|
if (finished) return;
|
|
3713
4297
|
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.';
|
|
3714
4298
|
const article = document.createElement('div'); article.className = 'ai-chat-message-body ai-chat-source-viewer-page';
|
|
3715
|
-
article.innerHTML =
|
|
4299
|
+
article.innerHTML = knowledgePageHtml(page.body, page.links);
|
|
4300
|
+
// #3003: a page a link names opens in Knowledge at this same version.
|
|
4301
|
+
article.addEventListener('click', (event) => {
|
|
4302
|
+
const link = event.target.closest?.('button[data-kb-link]');
|
|
4303
|
+
if (!link) return;
|
|
4304
|
+
finish();
|
|
4305
|
+
if (window.flolessWorkspaces?.openKnowledgePage) window.flolessWorkspaces.openKnowledgePage(page.projectId, link.dataset.kbLink, page.generationId);
|
|
4306
|
+
else announce('Knowledge is not available on this page.');
|
|
4307
|
+
});
|
|
3716
4308
|
const knowledge = button('Open in Knowledge', 'shell.chat-cite-open-knowledge', 'ai-chat-source-viewer-knowledge');
|
|
3717
4309
|
knowledge.addEventListener('click', () => {
|
|
3718
4310
|
finish();
|
|
@@ -3735,12 +4327,231 @@
|
|
|
3735
4327
|
* is now, not as the answer described it. The member's route is asked again right before moving, so a project that
|
|
3736
4328
|
* left the conversation since is never opened.
|
|
3737
4329
|
*/
|
|
4330
|
+
/**
|
|
4331
|
+
* #3002: a Knowledge reference file the answer cited, checked now against the bytes it was cited with. FloLess shows
|
|
4332
|
+
* only those verified bytes; a file replaced since says so and offers the file as it is now, labelled as not the cited one.
|
|
4333
|
+
*/
|
|
4334
|
+
async function showCitedKnowledgeFile(row, view) {
|
|
4335
|
+
const { body, status, refused, retry, signal, done } = view;
|
|
4336
|
+
const entry = row.entry;
|
|
4337
|
+
const response = await fetch(citationUrl(row, 'project-file'), { credentials: 'same-origin', cache: 'no-store', signal });
|
|
4338
|
+
if (!response.ok) { const why = await refused(response); if (!done()) { status.textContent = why; retry(); } return; }
|
|
4339
|
+
const { file } = await response.json();
|
|
4340
|
+
if (done()) return;
|
|
4341
|
+
if (!file) { status.textContent = 'FloLess could not open this source right now. Try again in a moment.'; return; }
|
|
4342
|
+
const name = file.filename || entry.label;
|
|
4343
|
+
const showText = (text, label) => {
|
|
4344
|
+
const pre = Object.assign(document.createElement('pre'), { className: 'ai-chat-source-viewer-text', tabIndex: 0, textContent: text });
|
|
4345
|
+
pre.setAttribute('aria-label', label);
|
|
4346
|
+
body.append(pre);
|
|
4347
|
+
};
|
|
4348
|
+
const stale = (state) => knowledgeFileStaleView(view, file, name, state);
|
|
4349
|
+
if (file.state === 'same') {
|
|
4350
|
+
view.stale?.('same');
|
|
4351
|
+
if (file.preview === 'text' && typeof file.text === 'string') {
|
|
4352
|
+
status.textContent = `${name} in Knowledge, as it was cited${file.truncated ? '. Showing the start of the file' : ''}.`;
|
|
4353
|
+
showText(file.text, `Text of ${name}`);
|
|
4354
|
+
return;
|
|
4355
|
+
}
|
|
4356
|
+
const mime = String(file.mime || '');
|
|
4357
|
+
if (file.preview === 'bytes' && (mime.startsWith('image/') || mime === 'application/pdf')) {
|
|
4358
|
+
// Only the bytes this request verified against the cited digest; a file replaced or removed since says so here.
|
|
4359
|
+
const bytes = await fetch(citationUrl(row, 'project-file', '&bytes=1'), { credentials: 'same-origin', cache: 'no-store', signal });
|
|
4360
|
+
if (bytes.status === 410) {
|
|
4361
|
+
const said = await bytes.json().catch(() => null);
|
|
4362
|
+
if (!done()) stale(KNOWLEDGE_FILE_MARKS[said?.state] ? said.state : 'changed');
|
|
4363
|
+
return;
|
|
4364
|
+
}
|
|
4365
|
+
if (!bytes.ok) { const why = await refused(bytes); if (!done()) status.textContent = why; return; }
|
|
4366
|
+
const blob = await bytes.blob();
|
|
4367
|
+
if (done()) return;
|
|
4368
|
+
const url = URL.createObjectURL(blob);
|
|
4369
|
+
view.picture(url);
|
|
4370
|
+
if (mime === 'application/pdf') {
|
|
4371
|
+
const frame = document.createElement('iframe');
|
|
4372
|
+
frame.className = 'ai-chat-source-viewer-pdf';
|
|
4373
|
+
frame.setAttribute('aria-label', `${name}, as it was cited`);
|
|
4374
|
+
frame.src = url;
|
|
4375
|
+
body.append(frame);
|
|
4376
|
+
} else {
|
|
4377
|
+
const image = Object.assign(document.createElement('img'), { src: url, alt: name });
|
|
4378
|
+
if (!await view.mountDrawing().setImage(image, () => !done(), true)) return;
|
|
4379
|
+
view.loaded();
|
|
4380
|
+
}
|
|
4381
|
+
status.textContent = `${name} in Knowledge, as it was cited.`;
|
|
4382
|
+
return;
|
|
4383
|
+
}
|
|
4384
|
+
status.textContent = `${name} in Knowledge, as it was cited (${Number(file.bytes).toLocaleString()} bytes). FloLess does not show this kind of file here.`;
|
|
4385
|
+
return;
|
|
4386
|
+
}
|
|
4387
|
+
stale(file.state);
|
|
4388
|
+
}
|
|
4389
|
+
|
|
4390
|
+
/**
|
|
4391
|
+
* #3002: what a cited Knowledge file's viewer found out — replaced, removed, or its cited version unreadable — said in
|
|
4392
|
+
* the viewer and kept on its chip, so the warning outlives the viewer. Only the chip's tag and tip change: nothing else.
|
|
4393
|
+
*/
|
|
4394
|
+
const KNOWLEDGE_FILE_MARKS = { changed: 'CHANGED', removed: 'REMOVED', 'bytes-missing': 'CITED VERSION UNREADABLE' };
|
|
4395
|
+
const KNOWLEDGE_FILE_TIPS = {
|
|
4396
|
+
changed: 'Found: yes, but replaced after this answer · Read by AI: not recorded · Checked: no',
|
|
4397
|
+
removed: 'Found: no, removed from Knowledge after this answer · Read by AI: not recorded · Checked: no',
|
|
4398
|
+
'bytes-missing': 'Found: yes, but FloLess can no longer read the version this answer cited · Read by AI: not recorded · Checked: no',
|
|
4399
|
+
};
|
|
4400
|
+
const KNOWLEDGE_FILE_SAID = {
|
|
4401
|
+
changed: 'replaced after this answer',
|
|
4402
|
+
removed: 'removed from Knowledge after this answer',
|
|
4403
|
+
'bytes-missing': 'the cited version can no longer be read',
|
|
4404
|
+
};
|
|
4405
|
+
/**
|
|
4406
|
+
* #3017: the same for any cited source, found by the answer's own check (`source-states`) as well as by a viewer: the
|
|
4407
|
+
* chip's tag, what its tip says was found, and what its button's name adds. A Knowledge file keeps its own words.
|
|
4408
|
+
*/
|
|
4409
|
+
const SOURCE_MARKS = { ...KNOWLEDGE_FILE_MARKS, unavailable: 'NOT IN THIS CONVERSATION', 'not-as-attached': 'NOT AS ATTACHED' };
|
|
4410
|
+
const SOURCE_FOUND = {
|
|
4411
|
+
changed: 'Found: yes, but changed after this answer',
|
|
4412
|
+
removed: 'Found: no, removed after this answer',
|
|
4413
|
+
unavailable: 'Found: no, FloLess cannot reach it from this conversation now',
|
|
4414
|
+
'not-as-attached': 'Found: no, the file kept with this conversation is not the one that was attached',
|
|
4415
|
+
};
|
|
4416
|
+
const SOURCE_SAID = {
|
|
4417
|
+
changed: 'changed after this answer', removed: 'removed after this answer', unavailable: 'not available from this conversation now',
|
|
4418
|
+
'not-as-attached': 'no longer the file that was attached',
|
|
4419
|
+
};
|
|
4420
|
+
/** #3017: a decided claim's cited source, as what FloLess found when it checked, never that it still is so. */
|
|
4421
|
+
const GONE_SAID = { removed: 'was removed', unavailable: 'could not be reached from this conversation', 'not-as-attached': 'was no longer the file that was attached' };
|
|
4422
|
+
const PROBE_STATES = new Set(['same', 'changed', 'removed', 'unavailable', 'not-as-attached']);
|
|
4423
|
+
const knowledgeFileKey = (row) => `${row.chatId}\u0000${row.citationId}\u0000${row.index}`;
|
|
4424
|
+
|
|
4425
|
+
/**
|
|
4426
|
+
* #3002/#3017: where each cited source stands, as FloLess last found it: by the answer's check (each time the
|
|
4427
|
+
* conversation is opened) or by a viewer that opened it, the later finding kept, so a slow check never overwrites what a
|
|
4428
|
+
* viewer found after it began. Display state only: never a source, never recorded. Keyed by conversation, citation, entry.
|
|
4429
|
+
*/
|
|
4430
|
+
const sourceSeen = new Map();
|
|
4431
|
+
const probedTurns = new Set();
|
|
4432
|
+
function seeSource(key, seen, at) {
|
|
4433
|
+
const was = sourceSeen.get(key);
|
|
4434
|
+
if (!was || was.at <= at) sourceSeen.set(key, { state: seen, at });
|
|
4435
|
+
}
|
|
4436
|
+
function seenSource(row) { return sourceSeen.get(knowledgeFileKey(row))?.state; }
|
|
4437
|
+
/** What FloLess found after `iso` only: a check begun before a decision says nothing about the source since it. */
|
|
4438
|
+
function seenSourceAfter(row, iso) {
|
|
4439
|
+
const seen = sourceSeen.get(knowledgeFileKey(row));
|
|
4440
|
+
return seen && seen.at > Date.parse(iso) ? seen.state : undefined;
|
|
4441
|
+
}
|
|
4442
|
+
|
|
4443
|
+
/** Marks a chip with where its source stands now; `same` puts the chip back as it was cited. */
|
|
4444
|
+
function markSourceChip(chip, seen, entry) {
|
|
4445
|
+
const fresh = seen === 'same';
|
|
4446
|
+
if (!chip || !entry || (!fresh && !SOURCE_MARKS[seen])) return;
|
|
4447
|
+
// A person's decision (an assumption, a chosen source) is not the cited source's chip: it says what it says by its record.
|
|
4448
|
+
if (chip.classList.contains('assumed') || chip.classList.contains('chosen')) return;
|
|
4449
|
+
chip.classList.toggle('stale', GONE_SOURCE_STATES.includes(seen));
|
|
4450
|
+
const marks = chip.querySelector('.ai-chat-source-marks');
|
|
4451
|
+
if (marks) marks.textContent = fresh ? citationMarks(entry) : SOURCE_MARKS[seen];
|
|
4452
|
+
const open = chip.querySelector('.ai-chat-source-open');
|
|
4453
|
+
if (!open) return;
|
|
4454
|
+
const knowledge = entry.kind === 'kb-source' && Object.hasOwn(KNOWLEDGE_FILE_TIPS, seen);
|
|
4455
|
+
open.dataset.tip = (fresh ? citationProvenance(entry) : knowledge ? KNOWLEDGE_FILE_TIPS[seen] : `${SOURCE_FOUND[seen]} · Read by AI: ${citationReadWords(entry)} · Checked: no`)
|
|
4456
|
+
+ (chip.classList.contains('consulted') ? ' · The answer does not cite it for any claim' : '');
|
|
4457
|
+
// The tip is not read out: the button's own name carries the state for keyboard and screen-reader users.
|
|
4458
|
+
open.setAttribute('aria-label', `Open ${open.dataset.commandInstanceLabel}${fresh ? '' : `, ${knowledge ? KNOWLEDGE_FILE_SAID[seen] : SOURCE_SAID[seen]}`}`);
|
|
4459
|
+
}
|
|
4460
|
+
|
|
4461
|
+
/** What a cited Knowledge file's viewer found, kept for its chip; a gone file repaints so the chip offers the ways on. */
|
|
4462
|
+
function knowledgeFileStale(row, turnId, seen) {
|
|
4463
|
+
if (seen !== 'same' && !KNOWLEDGE_FILE_MARKS[seen]) return;
|
|
4464
|
+
viewerFound(row, turnId, seen);
|
|
4465
|
+
}
|
|
4466
|
+
|
|
4467
|
+
/**
|
|
4468
|
+
* #3017: what the viewer of a cited project file, attachment or member found, kept for its chip as the Knowledge file's
|
|
4469
|
+
* is. A source the person chose has no AI chip to mark.
|
|
4470
|
+
*/
|
|
4471
|
+
function viewerFound(row, turnId, seen) {
|
|
4472
|
+
if (row.entry.chosen || (seen !== 'same' && !SOURCE_MARKS[seen])) return;
|
|
4473
|
+
seeSource(knowledgeFileKey(row), seen, Date.now());
|
|
4474
|
+
const chip = sourceChip(turnId, row.anchor);
|
|
4475
|
+
const wasGone = !!chip?.classList.contains('stale');
|
|
4476
|
+
markSourceChip(chip, seen, row.entry);
|
|
4477
|
+
// A gone source gains the ways on, and one found again loses them; a decision chip is drawn again from its record
|
|
4478
|
+
// (an assumption may say "found again").
|
|
4479
|
+
if (GONE_SOURCE_STATES.includes(seen) || wasGone || chip?.classList.contains('assumed') || chip?.classList.contains('chosen')) paintEvents();
|
|
4480
|
+
}
|
|
4481
|
+
|
|
4482
|
+
/**
|
|
4483
|
+
* #3017: asks FloLess once per answer, each time the conversation is opened, where the sources it cited stand now, and
|
|
4484
|
+
* repaints when it hears. Not while the answer runs: its citations are not all in. A check that fails changes nothing
|
|
4485
|
+
* on the chips, and `unchecked` says nothing either: the chip keeps what it showed.
|
|
4486
|
+
*/
|
|
4487
|
+
function probeSources(turnId, index) {
|
|
4488
|
+
const chatId = state.chat?.chatId;
|
|
4489
|
+
if (!chatId || !turnId || answerRunning(turnId)) return;
|
|
4490
|
+
const key = `${chatId}\u0000${turnId}`;
|
|
4491
|
+
if (probedTurns.has(key) || ![...index.byAnchor.values()].some((row) => row.entry.status === 'resolved' && !row.entry.bare)) return;
|
|
4492
|
+
probedTurns.add(key);
|
|
4493
|
+
const at = Date.now();
|
|
4494
|
+
request(`/api/chat/conversations/${encodeURIComponent(chatId)}/turns/${encodeURIComponent(turnId)}/source-states?${ownerQuery()}`).then((result) => {
|
|
4495
|
+
if (state.chat?.chatId !== chatId || !Array.isArray(result?.states)) return;
|
|
4496
|
+
let found = false;
|
|
4497
|
+
for (const row of result.states) {
|
|
4498
|
+
if (!row || typeof row.citationId !== 'string' || !Number.isSafeInteger(row.index) || !PROBE_STATES.has(row.state)) continue;
|
|
4499
|
+
seeSource(`${chatId}\u0000${row.citationId}\u0000${row.index}`, row.state, at);
|
|
4500
|
+
found = true;
|
|
4501
|
+
}
|
|
4502
|
+
if (found) paintEvents();
|
|
4503
|
+
}, (error) => { console.warn('floless: the cited sources of an answer could not be checked', error); });
|
|
4504
|
+
}
|
|
4505
|
+
|
|
4506
|
+
/** The viewer's words for a cited Knowledge file that is no longer the cited version, and the current file on request. */
|
|
4507
|
+
function knowledgeFileStaleView(view, file, name, state) {
|
|
4508
|
+
const { body, status, signal, done } = view;
|
|
4509
|
+
view.stale?.(state);
|
|
4510
|
+
if (state === 'removed') { status.textContent = `${name} was removed from Knowledge after this answer.`; return; }
|
|
4511
|
+
status.textContent = state === 'bytes-missing'
|
|
4512
|
+
? `${name} is still in Knowledge, but FloLess can no longer read the version this answer cited.`
|
|
4513
|
+
: `${name} was replaced after this answer, so the cited text may differ. FloLess does not show the new file as the cited one.`;
|
|
4514
|
+
const showText = (text, label) => {
|
|
4515
|
+
const pre = Object.assign(document.createElement('pre'), { className: 'ai-chat-source-viewer-text', tabIndex: 0, textContent: text });
|
|
4516
|
+
pre.setAttribute('aria-label', label);
|
|
4517
|
+
body.append(pre);
|
|
4518
|
+
};
|
|
4519
|
+
if (state !== 'changed' || !file.projectId || !file.sourceId) return;
|
|
4520
|
+
const current = button('Show the file as it is now', 'shell.chat-cite-open-current', 'ai-chat-source-viewer-knowledge');
|
|
4521
|
+
current.dataset.tip = 'Shows the file as it is in Knowledge now. It is not the version this answer cited';
|
|
4522
|
+
current.addEventListener('click', async () => {
|
|
4523
|
+
current.remove();
|
|
4524
|
+
const now = await fetch(`/api/projects/${encodeURIComponent(file.projectId)}/knowledge/sources/${encodeURIComponent(file.sourceId)}/raw`,
|
|
4525
|
+
{ credentials: 'same-origin', cache: 'no-store', signal }).catch(() => null);
|
|
4526
|
+
if (done()) return;
|
|
4527
|
+
if (!now?.ok) { status.textContent = `FloLess could not open ${name} as it is now. Try again in a moment.`; return; }
|
|
4528
|
+
const type = (now.headers.get('Content-Type') || '').split(';')[0].trim().toLowerCase();
|
|
4529
|
+
// Said before anything is shown, and kept above it: this is not what the answer cited.
|
|
4530
|
+
const banner = Object.assign(document.createElement('p'), { className: 'ai-chat-source-viewer-status current', textContent: 'Showing the current file, not the version this answer cited.' });
|
|
4531
|
+
banner.setAttribute('role', 'status');
|
|
4532
|
+
body.append(banner);
|
|
4533
|
+
if (type.startsWith('text/') || type === 'application/json') {
|
|
4534
|
+
const chars = [...await now.text()];
|
|
4535
|
+
if (done()) return;
|
|
4536
|
+
showText(chars.slice(0, 16000).join(''), `Current text of ${name}`);
|
|
4537
|
+
if (chars.length > 16000) banner.textContent += ' Showing the start of the file.';
|
|
4538
|
+
} else {
|
|
4539
|
+
await now.body?.cancel().catch(() => {});
|
|
4540
|
+
banner.textContent += ' FloLess does not show this kind of file here.';
|
|
4541
|
+
}
|
|
4542
|
+
});
|
|
4543
|
+
body.append(current);
|
|
4544
|
+
}
|
|
4545
|
+
|
|
3738
4546
|
async function showCitedMember(row, view) {
|
|
3739
4547
|
const { dialog, body, status, finish, refused, done } = view;
|
|
3740
4548
|
const response = await fetch(citationUrl(row, 'member'), { credentials: 'same-origin', cache: 'no-store' });
|
|
4549
|
+
if (response.status === 404) view.found?.('unavailable');
|
|
3741
4550
|
if (!response.ok) { const why = await refused(response); if (!done()) status.textContent = why; return; }
|
|
3742
4551
|
const { member } = await response.json();
|
|
3743
4552
|
if (done()) return;
|
|
4553
|
+
// #3017: "no-model" is left unsaid on the chip: the member may well still be there once the model can be read.
|
|
4554
|
+
view.found?.({ same: 'same', changed: 'changed', gone: 'removed' }[member.model] ?? null);
|
|
3744
4555
|
const facts = document.createElement('dl'); facts.className = 'ai-chat-source-viewer-facts';
|
|
3745
4556
|
const fact = (term, value) => facts.append(Object.assign(document.createElement('dt'), { textContent: term }),
|
|
3746
4557
|
Object.assign(document.createElement('dd'), { textContent: value }));
|
|
@@ -3845,9 +4656,10 @@
|
|
|
3845
4656
|
if (role === 'assistant' || visibleText) {
|
|
3846
4657
|
const body = document.createElement('div'); body.className = 'ai-chat-message-body';
|
|
3847
4658
|
// #2437: only an answer's own directives become source markers; the person's words stay literal.
|
|
3848
|
-
|
|
3849
|
-
|
|
4659
|
+
const uncited = role === 'assistant' ? renderAnswerBody(body, visibleText, event.turnId, answerFinished(event, streaming)) : 0;
|
|
4660
|
+
if (role !== 'assistant') body.innerHTML = markdownHtml(visibleText);
|
|
3850
4661
|
item.append(body);
|
|
4662
|
+
if (uncited) item.append(uncitedDimensionsControl(body, uncited, `${state.chat?.chatId ?? ''}:${event.eventId}`));
|
|
3851
4663
|
}
|
|
3852
4664
|
if (role === 'user' && Array.isArray(event.payload?.attachmentIds)) {
|
|
3853
4665
|
const attachments = event.payload.attachmentIds
|
|
@@ -4881,11 +5693,21 @@
|
|
|
4881
5693
|
if (screen?.view === 'requests' && screen.requestId && typeof window.flolessBridge?.openRequest === 'function') {
|
|
4882
5694
|
await window.flolessBridge.openRequest(screen.requestId); return true;
|
|
4883
5695
|
}
|
|
4884
|
-
// #2450: one connection, selected and framed in the project's model editor.
|
|
4885
|
-
//
|
|
5696
|
+
// #2450: one connection, selected and framed in the project's model editor. A later request taking over
|
|
5697
|
+
// counts as opened (it reports for itself). #2520: when the editor says why it could not show it, that
|
|
5698
|
+
// sentence reaches the card as a `plain` error, never replaced by the card's generic line.
|
|
4886
5699
|
if (screen?.view === 'connection' && screen.projectId && screen.jointId) {
|
|
4887
5700
|
const outcome = await openConnectionInModel(screen.projectId, screen.jointId);
|
|
4888
|
-
|
|
5701
|
+
if (outcome?.ok === true || outcome?.superseded === true) return true;
|
|
5702
|
+
if (typeof outcome?.said === 'string' && outcome.said) throw Object.assign(new Error(outcome.said), { plain: true });
|
|
5703
|
+
return false;
|
|
5704
|
+
}
|
|
5705
|
+
// #2521 row 9: Make precise itself, in the project's model editor, where the person confirms each AI decision.
|
|
5706
|
+
if (screen?.view === 'project' && screen.panel === 'make-precise' && screen.projectId && typeof window.flolessWorkspaces?.openConnection === 'function') {
|
|
5707
|
+
const outcome = await window.flolessWorkspaces.openConnection({ projectId: screen.projectId, makePrecise: true });
|
|
5708
|
+
if (outcome?.ok === true || outcome?.superseded === true) return true;
|
|
5709
|
+
if (typeof outcome?.said === 'string' && outcome.said) throw Object.assign(new Error(outcome.said), { plain: true });
|
|
5710
|
+
return false;
|
|
4889
5711
|
}
|
|
4890
5712
|
if (screen?.view === 'project' && screen.step === 'drawings' && screen.projectId && typeof window.flolessWorkspaces?.openDrawingsStep === 'function') {
|
|
4891
5713
|
await window.flolessWorkspaces.openDrawingsStep(screen.projectId); return true;
|
|
@@ -4896,6 +5718,14 @@
|
|
|
4896
5718
|
if (['workspaces', 'workflows'].includes(screen?.view) && typeof window.flolessWorkspaces?.setMode === 'function') {
|
|
4897
5719
|
await window.flolessWorkspaces.setMode(screen.view); return true;
|
|
4898
5720
|
}
|
|
5721
|
+
// #2811: New project for a Steel model from drawings, Quick pressed when asked. Opened straight from the click (the
|
|
5722
|
+
// file picker needs it); the Drawing Filter question stays the person's, in the dialog.
|
|
5723
|
+
if (screen?.view === 'new-project' && typeof window.flolessWorkspaces?.openNewProjectFromDrawings === 'function') {
|
|
5724
|
+
const outcome = await window.flolessWorkspaces.openNewProjectFromDrawings({ quick: screen.buildMode === 'quick' });
|
|
5725
|
+
if (outcome?.ok === true) return true;
|
|
5726
|
+
if (typeof outcome?.said === 'string' && outcome.said) throw Object.assign(new Error(outcome.said), { plain: true });
|
|
5727
|
+
return false;
|
|
5728
|
+
}
|
|
4899
5729
|
// Automatic tool updates: the dialog where the person reads the wording and chooses (it opens nothing else, runs nothing).
|
|
4900
5730
|
if (screen?.view === 'tool-update-policy' && typeof window.openToolUpdatePolicy === 'function') {
|
|
4901
5731
|
window.openToolUpdatePolicy(); return true;
|
|
@@ -5210,7 +6040,8 @@
|
|
|
5210
6040
|
if (risk === 'human-only') {
|
|
5211
6041
|
const screen = payload.screen || {};
|
|
5212
6042
|
const open = actionButton(String(screen.label || 'Open it'), 'shell.chat-action-open', proposalId, summaryText, 'ai-chat-filter-apply');
|
|
5213
|
-
open.dataset.tip = 'Opens
|
|
6043
|
+
open.dataset.tip = screen.view === 'new-project' ? 'Opens your file picker for the drawings, then New project. Nothing is made until you press Create.'
|
|
6044
|
+
: 'Opens the screen where you do this yourself. Nothing runs from this card.';
|
|
5214
6045
|
open.addEventListener('click', async () => {
|
|
5215
6046
|
entry.error = '';
|
|
5216
6047
|
try { if (!(await openActionScreen(screen))) entry.error = screen.view === 'chat'
|
|
@@ -5226,7 +6057,9 @@
|
|
|
5226
6057
|
actions.append(later, open);
|
|
5227
6058
|
const note = document.createElement('p');
|
|
5228
6059
|
note.className = 'ai-chat-filter-note';
|
|
5229
|
-
|
|
6060
|
+
// #2811: the one question this dialog asks only the person, said on the card that takes them there.
|
|
6061
|
+
note.textContent = screen.view === 'new-project' ? 'In the dialog, only you decide whether the AI may choose the Drawing Filter. Nothing is made until you press Create.'
|
|
6062
|
+
: 'Only you can do this. Nothing runs from here.';
|
|
5230
6063
|
status.textContent = entry.error;
|
|
5231
6064
|
card.append(actions, note, status);
|
|
5232
6065
|
return card;
|
|
@@ -6595,6 +7428,8 @@
|
|
|
6595
7428
|
}
|
|
6596
7429
|
// Open the place: a human-only action's screen, or the flow for a tool, workflow, agent, routine or page.
|
|
6597
7430
|
let opened = false;
|
|
7431
|
+
// #2520: a screen that refuses in its own words (a connection no longer in the model) says that, not the generic line.
|
|
7432
|
+
let refused = '';
|
|
6598
7433
|
try {
|
|
6599
7434
|
if (answer.outcome === 'screen') opened = await openActionScreen(answer.screen);
|
|
6600
7435
|
else if (answer.move?.kind === 'create-workflow' && typeof window.flolessBridge?.newWorkflow === 'function') {
|
|
@@ -6602,12 +7437,13 @@
|
|
|
6602
7437
|
void window.flolessBridge.newWorkflow({ name: answer.move.name });
|
|
6603
7438
|
} else if (answer.move) opened = Boolean(await window.flolessGuide?.openFlow?.(answer.move));
|
|
6604
7439
|
} catch (error) {
|
|
6605
|
-
|
|
7440
|
+
if (error?.plain === true && error.message) refused = error.message;
|
|
7441
|
+
else console.warn('[assistant] a suggestion could not open its place:', error);
|
|
6606
7442
|
opened = false;
|
|
6607
7443
|
}
|
|
6608
7444
|
if (!opened) {
|
|
6609
7445
|
entry.fold = { opened: false };
|
|
6610
|
-
entry.error = 'FloLess couldn’t open that from here. Open it from the ≡ menu instead.';
|
|
7446
|
+
entry.error = refused || 'FloLess couldn’t open that from here. Open it from the ≡ menu instead.';
|
|
6611
7447
|
entry.focus = 'status'; repaintAssistantCard(entry); return;
|
|
6612
7448
|
}
|
|
6613
7449
|
entry.fold = null;
|
|
@@ -7818,7 +8654,6 @@
|
|
|
7818
8654
|
const note = scope.startsWith('h:') ? (source.note.trim() ? source.note : '') : source.note.trim();
|
|
7819
8655
|
return { ...(note ? { note } : {}), ...(source.files.length ? { evidence: source.files.map((file) => file.attachmentId) } : {}) };
|
|
7820
8656
|
}
|
|
7821
|
-
const MAX_ANSWER_NOTE = 160;
|
|
7822
8657
|
const MAX_HEIGHT_CLARIFICATION = 8000;
|
|
7823
8658
|
// #2167: asked for nothing at all. Said plainly, with the three things that would count.
|
|
7824
8659
|
const NO_HEIGHT_NO_SOURCE = 'Type a height, or add a note or a picture and the AI will work it out.';
|
|
@@ -8022,7 +8857,7 @@
|
|
|
8022
8857
|
if (ctx.clarification) { note.rows = 4; wrap.classList.add('ai-chat-answer-clarification'); }
|
|
8023
8858
|
else { note.type = 'text'; note.maxLength = 160; }
|
|
8024
8859
|
note.className = `ai-chat-height-input ai-chat-answer-note${ctx.clarification ? ' ai-chat-answer-clarification' : ''}`; note.autocomplete = 'off';
|
|
8025
|
-
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)';
|
|
8860
|
+
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)';
|
|
8026
8861
|
note.dataset.commandId = ctx.idFor('note'); note.dataset.commandInstanceLabel = ctx.instance;
|
|
8027
8862
|
note.setAttribute('aria-label', `${ctx.clarification ? 'Explain what to use' : 'Source note'} for ${ctx.label}`);
|
|
8028
8863
|
note.value = source.note;
|
|
@@ -8033,7 +8868,7 @@
|
|
|
8033
8868
|
note.id = `clarification-${encodeURIComponent(scope)}`; heading.htmlFor = note.id; box.append(heading);
|
|
8034
8869
|
counter = Object.assign(document.createElement('p'), { className: 'ai-chat-answer-lead' });
|
|
8035
8870
|
note.setAttribute('aria-describedby', `${note.id}-limit`); counter.id = `${note.id}-limit`;
|
|
8036
|
-
const count = () => { counter.textContent = `${note.value.length.toLocaleString()} / 8,000 characters. Without a Height, this saves clarification for the read; the height stays unresolved
|
|
8871
|
+
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)); };
|
|
8037
8872
|
note.addEventListener('input', count); count();
|
|
8038
8873
|
}
|
|
8039
8874
|
note.addEventListener('input', () => { source.note = note.value; ctx.onDraftChange?.(); });
|
|
@@ -8320,7 +9155,7 @@
|
|
|
8320
9155
|
if (kind === 'height' && ['resolved-from-drawings', 'no-longer-needed'].includes(heightResponsibility(row))) return;
|
|
8321
9156
|
showDrawingSlot(entry.chatId);
|
|
8322
9157
|
entry.changing.add(key); entry.activeItem = key; entry.finishActive = false; entry.reopenedAt = (state.drawingActivationOrder = (state.drawingActivationOrder || 0) + 1);
|
|
8323
|
-
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;
|
|
9158
|
+
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; }
|
|
8324
9159
|
entry.slotPhase = 'row';
|
|
8325
9160
|
(kind === 'setup' ? repaintSetupCard : repaintHeightCard)(entry);
|
|
8326
9161
|
drawingSlotRepaint();
|
|
@@ -8474,7 +9309,8 @@
|
|
|
8474
9309
|
function drawingSource(kind, entry, scope, label, idFor, row, onDraftChange) {
|
|
8475
9310
|
return paintAnswerSource(scope, { requestId: entry.requestId, chatId: entry.chatId, repaint: () => { (kind === 'setup' ? repaintSetupCard : repaintHeightCard)(entry); drawingSlotRepaint(); },
|
|
8476
9311
|
removeFile: (file) => request(`/api/chat/answer-evidence/${encodeURIComponent(entry.requestId)}/${encodeURIComponent(file.attachmentId)}`, { method: 'DELETE', body: JSON.stringify({ chatId: entry.chatId }) }),
|
|
8477
|
-
label, instance: label, idFor, inherited: row?.inherited, inheritedNote: (
|
|
9312
|
+
label, instance: label, idFor, inherited: row?.inherited, inheritedNote: (row?.answer?.how !== 'none' ? row?.answer?.note : null) || row?.inheritedNote, clarification: true,
|
|
9313
|
+
...(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,
|
|
8478
9314
|
allowPictureOnly: false, onDraftChange, alwaysOpen: Boolean(entry.slotDrafts?.get(entry.slotQuestionKey)?.rows[0]?.otherOpen) });
|
|
8479
9315
|
}
|
|
8480
9316
|
function retainedHeightPicture(entry, file, commandId, instance) {
|
|
@@ -8564,22 +9400,25 @@
|
|
|
8564
9400
|
q.figure = () => heightPlaceFigure(entry, row);
|
|
8565
9401
|
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.');
|
|
8566
9402
|
} else if (row.kind === 'origin') {
|
|
9403
|
+
q.otherInputLabel = 'Grid crossing (optional)'; q.otherPlaceholder = 'A/1'; q.otherUncapped = true;
|
|
8567
9404
|
q.question = 'Which grid crossing is the model’s origin (0, 0)?'; q.layout = 'grid'; q.confirmSelection = true;
|
|
8568
9405
|
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) }); });
|
|
8569
9406
|
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) }); });
|
|
8570
9407
|
q.recommended = Number.isInteger(row.proposed) ? row.proposed : null;
|
|
8571
|
-
if (row.fromEvidence) q.context.push('The read’s reading of your picture. Check it before you confirm.');
|
|
9408
|
+
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.');
|
|
8572
9409
|
} else {
|
|
9410
|
+
q.otherInputLabel = row.kind === 'scale' ? 'Scale (optional)' : 'Level (optional)'; q.otherUncapped = true;
|
|
9411
|
+
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`;
|
|
8573
9412
|
if (row.clue) q.context.push(row.clue);
|
|
8574
9413
|
if (row.noSingleLevel) q.context.push(`No single level on the drawings: ${row.noSingleLevel.why}`);
|
|
8575
9414
|
// Options follow row.proposals in order, so the selected option's index names its proposal.
|
|
8576
9415
|
// A choice past the proposals ("No single level") has no place of its own, so it gets no picture.
|
|
8577
9416
|
if (row.kind === 'level') q.figure = (choice) => setupPlaceFigure(entry, row, Number.isInteger(choice) ? (row.proposals[choice] ?? SETUP_NO_PROPOSAL) : null);
|
|
8578
9417
|
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}`,
|
|
8579
|
-
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 }); });
|
|
9418
|
+
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 }); });
|
|
8580
9419
|
}
|
|
8581
9420
|
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.');
|
|
8582
|
-
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: '
|
|
9421
|
+
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' }); }
|
|
8583
9422
|
if (kind === 'setup') { const banner = setupConflictBanner(row); if (banner) q.context.push(banner.textContent); }
|
|
8584
9423
|
const controlKey = kind === 'height' ? `${row.memberId} ${row.endWord}` : key;
|
|
8585
9424
|
const idFor = (what, extra) => `shell.chat-answer-${what}#${entry.questionId} ${controlKey}${extra === undefined ? '' : ` ${extra}`}`;
|
|
@@ -8590,9 +9429,8 @@
|
|
|
8590
9429
|
source: (_index, onDraftChange) => drawingSource(kind, entry, scope, label, idFor, row, onDraftChange),
|
|
8591
9430
|
validate: (_step, draft) => {
|
|
8592
9431
|
const answer = draft.rows[0]; if (answer.choices.length) return '';
|
|
8593
|
-
if (answer.other.trim()) return '';
|
|
8594
|
-
|
|
8595
|
-
return answerSource(scope).files.length ? '' : kind === 'setup' ? 'Type a value, or attach a picture first.' : NO_HEIGHT_NO_SOURCE;
|
|
9432
|
+
if (answer.other.trim() || hasAnswerSource(scope)) return '';
|
|
9433
|
+
return kind === 'setup' ? 'Type a value, explain what to use, or attach a picture.' : NO_HEIGHT_NO_SOURCE;
|
|
8596
9434
|
},
|
|
8597
9435
|
commit: async (answer) => {
|
|
8598
9436
|
let payload;
|
|
@@ -9022,7 +9860,9 @@
|
|
|
9022
9860
|
if (row.status === 'picture' && !changing) {
|
|
9023
9861
|
const wait = document.createElement('div'); wait.className = 'ai-chat-height-answered';
|
|
9024
9862
|
const glyph = document.createElement('span'); glyph.className = 'ai-chat-height-glyph'; glyph.textContent = '…'; glyph.setAttribute('aria-hidden', 'true');
|
|
9025
|
-
const
|
|
9863
|
+
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. ` : '';
|
|
9864
|
+
const text = document.createElement('span'); text.textContent = !row.answer?.note ? 'Waiting for the read to read your picture'
|
|
9865
|
+
: `${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.`;
|
|
9026
9866
|
wait.append(glyph, text);
|
|
9027
9867
|
if (open) {
|
|
9028
9868
|
const change = heightActionButton('Answer now', idFor('change'), instance, 'ai-chat-height-change', null);
|
|
@@ -9076,13 +9916,13 @@
|
|
|
9076
9916
|
let saved = false;
|
|
9077
9917
|
const withSource = answers.map((answer) => withAnswerSource(answer, answerSourcePayload(`s:${entry.questionId}:${answer.key}`)));
|
|
9078
9918
|
try {
|
|
9079
|
-
|
|
9080
|
-
if (
|
|
9081
|
-
entry.rowErrors.set(rowKey,
|
|
9919
|
+
// Measured as the server joins them when the value is not one it can read: typed, a blank line, the note.
|
|
9920
|
+
if (withSource.some((answer) => [answer.typed?.trim(), answer.note].filter(Boolean).join('\n\n').length > MAX_HEIGHT_CLARIFICATION)) {
|
|
9921
|
+
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.');
|
|
9082
9922
|
return false;
|
|
9083
9923
|
}
|
|
9084
|
-
if (withSource.some((answer) => answer.action === 'evidence' && !answer.evidence?.length)) {
|
|
9085
|
-
entry.rowErrors.set(rowKey, '
|
|
9924
|
+
if (withSource.some((answer) => answer.action === 'evidence' && !answer.evidence?.length && !answer.note)) {
|
|
9925
|
+
entry.rowErrors.set(rowKey, 'Explain what to use, or attach a picture first.'); return false;
|
|
9086
9926
|
}
|
|
9087
9927
|
entry.busy = true; entry.cardError = ''; if (rowKey) entry.rowErrors.delete(rowKey);
|
|
9088
9928
|
repaintSetupCard(entry);
|
|
@@ -9092,7 +9932,13 @@
|
|
|
9092
9932
|
entry.view = result.question;
|
|
9093
9933
|
saved = true; entry.failedSubmission = null; entry.saveFailed = false; if (seenAtAnswer) drawingMessagesSeen(entry.chatId, seenAtAnswer);
|
|
9094
9934
|
for (const answer of answers) {
|
|
9095
|
-
|
|
9935
|
+
// A saved row starts its next edit from the record, not the old typing: a note saved from the value field lives in
|
|
9936
|
+
// the explanation box when it is reopened, and must not also come back in the value field (#2840).
|
|
9937
|
+
entry.changing.delete(answer.key); entry.drafts.delete(answer.key); entry.drafts.delete(`${answer.key}\u0000none`); entry.slotDrafts?.delete(answer.key);
|
|
9938
|
+
// A value FloLess could not read is kept as the person's note; the row says so rather than leaving them to wonder.
|
|
9939
|
+
entry.unreadValue ??= new Set();
|
|
9940
|
+
if (answer.action === 'type' && entry.view?.items?.find((item) => item.key === answer.key)?.answer?.how === 'evidence') entry.unreadValue.add(answer.key);
|
|
9941
|
+
else entry.unreadValue.delete(answer.key);
|
|
9096
9942
|
if (entry.activeItem === answer.key) { entry.activeItem = null; entry.reopenedAt = 0; }
|
|
9097
9943
|
entry.noneOpen.delete(answer.key);
|
|
9098
9944
|
if (answer.key === 'origin') entry.originPick = null;
|
|
@@ -9706,6 +10552,8 @@
|
|
|
9706
10552
|
const focusedShell = focusedNode?.closest?.('.ai-chat-feed-card') || null;
|
|
9707
10553
|
const focusedLine = focusedNode?.matches?.('.ai-chat-feed > .ai-chat-feed-hidden') ? String(focusedNode.dataset.commandId || '').replace('shell.chat-feed-card-show#', '') : '';
|
|
9708
10554
|
const focusedChip = chipNode ? { turnId: chipNode.dataset.turnId, anchor: chipNode.dataset.anchor, command: focusedNode.dataset?.commandId || '' } : null;
|
|
10555
|
+
// #3001: an answer's control for its numbers with no marker is rebuilt with the answer: the keyboard stays on that answer's.
|
|
10556
|
+
const focusedUncited = focusedNode?.closest?.('.ai-chat-uncited-row')?.dataset.answerKey ?? null;
|
|
9709
10557
|
if (options.forceBottom) state.feedLeftEnd = false; // the person just sent: the end is where they are going
|
|
9710
10558
|
const nearBottom = !state.feedLeftEnd && ui.feed.scrollHeight - ui.feed.scrollTop - ui.feed.clientHeight < 56;
|
|
9711
10559
|
const scrollTop = ui.feed.scrollTop;
|
|
@@ -9735,8 +10583,17 @@
|
|
|
9735
10583
|
if (!assistant) return;
|
|
9736
10584
|
const rendered = renderedLiveAssistantText(assistant.event, assistant.text);
|
|
9737
10585
|
ui.feed.append(renderMessage(assistant.event, 'assistant', rendered.text, rendered.streaming));
|
|
10586
|
+
holdUncitedClaims(assistant.event.turnId);
|
|
9738
10587
|
assistant = null;
|
|
9739
10588
|
};
|
|
10589
|
+
// #2999: an answer that cited nothing still lists the claims it marked, once, under the answer, streamed or whole.
|
|
10590
|
+
const uncitedTurns = new Set();
|
|
10591
|
+
const holdUncitedClaims = (turnId) => {
|
|
10592
|
+
if (!turnId || uncitedTurns.has(turnId)) return;
|
|
10593
|
+
uncitedTurns.add(turnId);
|
|
10594
|
+
const node = renderUncitedClaims(turnId);
|
|
10595
|
+
if (node) { if (links.length && links[0].turnId !== turnId) flushLinks(); links.push({ turnId, node }); }
|
|
10596
|
+
};
|
|
9740
10597
|
const flushLinks = () => { if (links.length) { ui.feed.append(...receiptFold(links)); links = []; } };
|
|
9741
10598
|
for (const event of state.events) {
|
|
9742
10599
|
// #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).
|
|
@@ -9810,6 +10667,7 @@
|
|
|
9810
10667
|
// as it is).
|
|
9811
10668
|
const node = feedCard(renderEvent(event), event);
|
|
9812
10669
|
if (node) ui.feed.append(node);
|
|
10670
|
+
if (event.type === 'assistant-message') holdUncitedClaims(event.turnId);
|
|
9813
10671
|
}
|
|
9814
10672
|
flushAssistant();
|
|
9815
10673
|
flushLinks();
|
|
@@ -9830,6 +10688,9 @@
|
|
|
9830
10688
|
if (focusedNode?.isConnected && ui.feed.contains(focusedNode)) {
|
|
9831
10689
|
if (document.activeElement !== focusedNode) focusedNode.focus({ preventScroll: true });
|
|
9832
10690
|
refocused = focusedNode;
|
|
10691
|
+
} else if (focusedUncited) {
|
|
10692
|
+
refocused = [...ui.feed.querySelectorAll('.ai-chat-uncited-row')].find((row) => row.dataset.answerKey === focusedUncited)?.querySelector('button') ?? null;
|
|
10693
|
+
refocused?.focus({ preventScroll: true });
|
|
9833
10694
|
} else if (focusedChip) {
|
|
9834
10695
|
// #2642: a source chip is rebuilt on every repaint; the keyboard stays on the same claim's chip, on the same button
|
|
9835
10696
|
// when it is still there (a recorded assumption leaves "Ask for the source", never a jump to the top of the feed).
|
|
@@ -11424,7 +12285,15 @@
|
|
|
11424
12285
|
if (finished) return;
|
|
11425
12286
|
status.textContent = 'The Knowledge page at the version you mentioned.';
|
|
11426
12287
|
const article = document.createElement('div'); article.className = 'ai-chat-message-body ai-chat-source-viewer-page';
|
|
11427
|
-
article.innerHTML =
|
|
12288
|
+
article.innerHTML = knowledgePageHtml(page.body, page.links);
|
|
12289
|
+
// #3003: a page a link names opens in Knowledge at this same version.
|
|
12290
|
+
article.addEventListener('click', (event) => {
|
|
12291
|
+
const link = event.target.closest?.('button[data-kb-link]');
|
|
12292
|
+
if (!link) return;
|
|
12293
|
+
finish();
|
|
12294
|
+
if (window.flolessWorkspaces?.openKnowledgePage) window.flolessWorkspaces.openKnowledgePage(page.projectId, link.dataset.kbLink, page.generationId);
|
|
12295
|
+
else announce('Knowledge is not available on this page.');
|
|
12296
|
+
});
|
|
11428
12297
|
const knowledge = button('Open in Knowledge', 'shell.chat-cite-open-knowledge', 'ai-chat-source-viewer-knowledge');
|
|
11429
12298
|
knowledge.addEventListener('click', () => {
|
|
11430
12299
|
finish();
|
|
@@ -12503,6 +13372,8 @@
|
|
|
12503
13372
|
if (!historyReopened) closeHistoryPanel();
|
|
12504
13373
|
state.chat = chat;
|
|
12505
13374
|
state.events = snapshot.events || [];
|
|
13375
|
+
// #3017: each opening checks again where its answers' cited sources stand now.
|
|
13376
|
+
probedTurns.clear();
|
|
12506
13377
|
reconcileUnknownFollowupOnSelection(chat);
|
|
12507
13378
|
state.capability = capability;
|
|
12508
13379
|
state.desktop = desktop;
|
|
@@ -13369,7 +14240,7 @@
|
|
|
13369
14240
|
// changing the attachments themselves.
|
|
13370
14241
|
paintAttachControl();
|
|
13371
14242
|
const unknownReason = state.followupUnknownId || hasUnknownFollowup()
|
|
13372
|
-
? 'FloLess could not confirm
|
|
14243
|
+
? 'FloLess could not confirm your last message reached the AI. Review that message before sending or attaching another file.' : null;
|
|
13373
14244
|
const sendingReason = state.followupSubmitting
|
|
13374
14245
|
? 'FloLess is saving this message. Wait for its delivery status before sending another.' : null;
|
|
13375
14246
|
for (const control of [ui.send, ui.attach]) {
|
|
@@ -14203,7 +15074,20 @@
|
|
|
14203
15074
|
if (!providerReady()) void loadCapability().then(() => { if (sameChat(snapshot)) { paintSettings(); updateSendState(); } });
|
|
14204
15075
|
if (given) return { sent: true };
|
|
14205
15076
|
} catch (error) {
|
|
15077
|
+
const unconfirmedAnswer = 'FloLess is busy and hasn’t confirmed your answer reached the AI yet. Check the conversation before you answer again.';
|
|
14206
15078
|
if (!sameChat(snapshot)) {
|
|
15079
|
+
// #2957: a timed-out send is as unconfirmed after the person moved on; it waits as unconfirmed in its own
|
|
15080
|
+
// conversation (reconcileUnknownFollowupOnSelection), and is settled there if that conversation is open again.
|
|
15081
|
+
if (error?.code === 'local-timeout') {
|
|
15082
|
+
optimisticEvent.payload.deliveryState = 'unknown';
|
|
15083
|
+
state.unknownFollowups.set(chatId, { submissionId: clientSubmissionId, text, event: optimisticEvent });
|
|
15084
|
+
// Open again through another project counts too (a new scope generation, the same owner): by owner, not generation.
|
|
15085
|
+
if (scopeKey(snapshot.scope) === scopeKey(state.scope) && state.chat?.chatId === chatId) {
|
|
15086
|
+
reconcileUnknownFollowupOnSelection(state.chat);
|
|
15087
|
+
paintEvents(); updateSendState();
|
|
15088
|
+
}
|
|
15089
|
+
return given ? givenNotSent(unconfirmedAnswer) : undefined;
|
|
15090
|
+
}
|
|
14207
15091
|
if (given) return givenNotSent();
|
|
14208
15092
|
if (initialTurnDefinitelyRefused(error)) {
|
|
14209
15093
|
await restoreBackgroundDraft(snapshot, text, clientSubmissionId);
|
|
@@ -14213,6 +15097,33 @@
|
|
|
14213
15097
|
return;
|
|
14214
15098
|
}
|
|
14215
15099
|
state.pendingSubmissionId = null;
|
|
15100
|
+
// #2957: the browser stopped waiting, but the server keeps working on the message, so it may already be in the
|
|
15101
|
+
// conversation. A timed-out send is unconfirmed, never "not sent": the message stays visible as unconfirmed, and
|
|
15102
|
+
// its user-message event or the person's "Review draft and continue" settles it, as for an uncertain follow-up.
|
|
15103
|
+
if (error?.code === 'local-timeout') {
|
|
15104
|
+
const arrived = state.events.some((event) => !event.optimistic && event.type === 'user-message'
|
|
15105
|
+
&& event.clientSubmissionId === clientSubmissionId);
|
|
15106
|
+
state.chat = previousChat;
|
|
15107
|
+
if (arrived) {
|
|
15108
|
+
state.events = state.events.filter((event) => event.eventId !== optimisticEvent.eventId);
|
|
15109
|
+
paintConversation();
|
|
15110
|
+
refreshConversation(chatId, false);
|
|
15111
|
+
announce('FloLess was slow to answer, but your message went through.');
|
|
15112
|
+
return given ? { sent: true } : undefined;
|
|
15113
|
+
}
|
|
15114
|
+
optimisticEvent.payload.deliveryState = 'unknown';
|
|
15115
|
+
state.followupUnknownId = clientSubmissionId;
|
|
15116
|
+
state.unknownFollowups.set(chatId, { submissionId: clientSubmissionId, text, event: optimisticEvent });
|
|
15117
|
+
if (given) {
|
|
15118
|
+
paintConversation();
|
|
15119
|
+
return givenNotSent(unconfirmedAnswer);
|
|
15120
|
+
}
|
|
15121
|
+
// The words come back so nothing is lost, but are not saved as a draft: the message may already be on its way.
|
|
15122
|
+
// Its files and mentions stay with the message that may have gone.
|
|
15123
|
+
ui.input.value = text; autosize(); state.localDraft = { chatId, text }; paintConversation();
|
|
15124
|
+
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.' });
|
|
15125
|
+
return;
|
|
15126
|
+
}
|
|
14216
15127
|
state.events = state.events.filter((event) => event.eventId !== optimisticEvent.eventId);
|
|
14217
15128
|
state.chat = previousChat;
|
|
14218
15129
|
if (given) { paintConversation(); return givenNotSent(givenRefusal(error)); }
|
|
@@ -14645,8 +15556,9 @@
|
|
|
14645
15556
|
optimisticEvent.payload.deliveryState = 'unknown';
|
|
14646
15557
|
state.unknownFollowups.set(snapshot.chatId, { submissionId: clientSubmissionId, text, event: optimisticEvent });
|
|
14647
15558
|
// The user may have selected A → B → A while this request was in flight.
|
|
14648
|
-
// The second A snapshot ran before the uncertain result existed, so reconcile it now.
|
|
14649
|
-
|
|
15559
|
+
// The second A snapshot ran before the uncertain result existed, so reconcile it now. By owner, not scope
|
|
15560
|
+
// generation: A reopened through another project is a new generation of the same owner (#2957).
|
|
15561
|
+
if (scopeKey(snapshot.scope) === scopeKey(state.scope) && state.chat?.chatId === snapshot.chatId) {
|
|
14650
15562
|
reconcileUnknownFollowupOnSelection(state.chat);
|
|
14651
15563
|
paintEvents(); updateSendState();
|
|
14652
15564
|
}
|
|
@@ -15462,6 +16374,24 @@
|
|
|
15462
16374
|
return result;
|
|
15463
16375
|
}
|
|
15464
16376
|
|
|
16377
|
+
/**
|
|
16378
|
+
* #3053: the finished drawing read's "Start new chat" — the New chat button, from outside this panel: a fresh
|
|
16379
|
+
* conversation in the same project, the earlier one left in history. Nothing of the old transcript is carried over.
|
|
16380
|
+
*/
|
|
16381
|
+
async function startNewChat(projectId) {
|
|
16382
|
+
// `personCopy`: the sentence is written for the person, so the caller shows it as it is (not as an unknown failure).
|
|
16383
|
+
const refuse = (text) => Object.assign(new Error(text), { personCopy: true });
|
|
16384
|
+
await refreshScope();
|
|
16385
|
+
const owner = state.scope?.owner;
|
|
16386
|
+
if (!owner || (projectId && (owner.kind !== 'project' || owner.projectId !== projectId))) {
|
|
16387
|
+
throw refuse('AI Chat is not showing this project yet. Wait a moment, then choose Start new chat again.');
|
|
16388
|
+
}
|
|
16389
|
+
window.flolessBridge?.revealAiChat?.();
|
|
16390
|
+
ui.tab.click();
|
|
16391
|
+
if (ui.newChat.disabled) throw refuse('AI Chat is finishing a reply. Start a new chat once it is done, with New chat at the top of AI Chat.');
|
|
16392
|
+
ui.newChat.click();
|
|
16393
|
+
}
|
|
16394
|
+
|
|
15465
16395
|
async function openConversation(chatId, options = {}) {
|
|
15466
16396
|
await refreshScope();
|
|
15467
16397
|
if (options.owner !== undefined) {
|
|
@@ -16479,10 +17409,11 @@
|
|
|
16479
17409
|
return result;
|
|
16480
17410
|
}
|
|
16481
17411
|
|
|
16482
|
-
|
|
17412
|
+
// #2470 R6.7b: `withoutLink` is the person's answer to a link to a General project that could not be made.
|
|
17413
|
+
async function resumeProjectIntake(submissionId, { withoutLink = false } = {}) {
|
|
16483
17414
|
await ensureSession();
|
|
16484
17415
|
return request(`/api/chat/project-intakes/${encodeURIComponent(submissionId)}/resume`, {
|
|
16485
|
-
method: 'POST', timeoutMs: PROJECT_INTAKE_TIMEOUT_MS, body: '{}',
|
|
17416
|
+
method: 'POST', timeoutMs: PROJECT_INTAKE_TIMEOUT_MS, body: withoutLink ? JSON.stringify({ withoutLink: true }) : '{}',
|
|
16486
17417
|
});
|
|
16487
17418
|
}
|
|
16488
17419
|
|
|
@@ -16666,7 +17597,7 @@
|
|
|
16666
17597
|
paintAttachments();
|
|
16667
17598
|
});
|
|
16668
17599
|
window.flolessChat = {
|
|
16669
|
-
refreshScope, refreshActivity, refreshIndex, startRequest, openConversation, openConversationIn, openDraft, openVerifiedTeklaDraft,
|
|
17600
|
+
refreshScope, refreshActivity, refreshIndex, startRequest, openConversation, openConversationIn, startNewChat, openDraft, openVerifiedTeklaDraft,
|
|
16670
17601
|
startProjectIntake, resumeProjectIntake, startWorkflowBuild,
|
|
16671
17602
|
// The plain-English sentence for a refusal the chat routes named, so a Start outside this panel
|
|
16672
17603
|
// (the upload modal, Requests) says what happened and what to do next instead of a generic toast (#1779).
|
|
@@ -16676,6 +17607,8 @@
|
|
|
16676
17607
|
currentChatId: () => state.chat?.chatId ?? null,
|
|
16677
17608
|
// The project this panel's conversations belong to; an object card offers Show in chat only for it (#1653).
|
|
16678
17609
|
scopeProjectId: () => (state.scope?.owner?.kind === 'project' ? state.scope.owner.projectId : null),
|
|
17610
|
+
// #3003: a Knowledge page rendered the way the chat viewers show it, for the Knowledge step's page panel.
|
|
17611
|
+
knowledgePageHtml,
|
|
16679
17612
|
// The Knowledge step's "Ask AI to index" (#2399 slice 0b): the person's own draft in the message box; never sent.
|
|
16680
17613
|
fillMessageBox: (text) => putInMessageBox(String(text || '')),
|
|
16681
17614
|
// The New project dialog's AI choice (#1605) words each provider's sign-in the way this
|