@floless/app 0.149.1 → 0.150.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 +101814 -88311
- package/dist/schemas/drawing-check.profile.v1.schema.json +45 -2
- package/dist/schemas/steel.model.v2.schema.json +9 -0
- package/dist/skills/floless-app-approval/SKILL.md +79 -4
- package/dist/skills/floless-app-onboarding/SKILL.md +4 -4
- package/dist/skills/floless-app-onboarding/references/aware-runtime.md +1 -1
- package/dist/skills/floless-app-onboarding/references/floless-app-tour.md +15 -13
- package/dist/skills/floless-app-routines/SKILL.md +4 -1
- package/dist/skills/floless-app-routines/references/routines-api.md +14 -2
- package/dist/skills/floless-app-steel-model/SKILL.md +4 -2
- package/dist/skills/floless-app-steel-takeoff/SKILL.md +14 -9
- package/dist/skills/floless-app-workflows/SKILL.md +2 -2
- package/dist/templates/tekla-parser.flo +13 -3
- package/dist/web/agents.js +887 -0
- package/dist/web/app.css +458 -23
- package/dist/web/app.js +20 -5
- package/dist/web/aware.js +1339 -134
- package/dist/web/chat.css +50 -1
- package/dist/web/chat.js +1582 -52
- package/dist/web/commands-drawing-check.js +15 -0
- package/dist/web/commands-revit.js +5 -0
- package/dist/web/commands-shell.js +761 -47
- package/dist/web/commands-tekla-parser.js +8 -1
- package/dist/web/connections.js +57 -14
- package/dist/web/drawing-check-editor.html +10 -2
- package/dist/web/drawing-check-editor.js +569 -40
- package/dist/web/drawing-check-overlay.js +45 -2
- package/dist/web/index.html +98 -27
- package/dist/web/instructor.js +85 -8
- package/dist/web/leave-guard.js +1 -0
- package/dist/web/left-pane.js +20 -1
- package/dist/web/local-discovery.js +12 -2
- package/dist/web/model-editor.css +32 -32
- package/dist/web/model-panel-bridge.js +11 -3
- package/dist/web/model-viewport-lighting.js +4 -2
- package/dist/web/model-viewport-revit-adapter.js +3 -0
- package/dist/web/model-viewport-toolbar.js +6 -3
- package/dist/web/model-viewport.js +11 -1
- package/dist/web/revit-editor.css +14 -14
- package/dist/web/revit-editor.js +64 -12
- package/dist/web/steel-3d-core.js +133 -0
- package/dist/web/steel-3d-view.js +10 -0
- package/dist/web/steel-editor.html +171 -39
- package/dist/web/steel-model-v2-client-validation.js +11 -0
- package/dist/web/steel-model-v2-commands.js +80 -5
- package/dist/web/tool-updates.js +367 -0
- package/dist/web/workspaces.js +679 -59
- package/package.json +1 -1
package/dist/web/chat.js
CHANGED
|
@@ -31,19 +31,28 @@
|
|
|
31
31
|
context: el('left-chat-context'),
|
|
32
32
|
teklaChip: el('chat-tekla-context'),
|
|
33
33
|
connectors: el('chat-connectors'),
|
|
34
|
+
changeAllowance: el('chat-change-allowance'),
|
|
35
|
+
scopeControls: el('chat-scope-controls'), scopeToggle: el('chat-scope-toggle'),
|
|
36
|
+
scopePicker: el('chat-scope-picker'), scopeDisclosure: el('chat-scope-disclosure'),
|
|
37
|
+
checkAllowance: el('chat-check-allowance'),
|
|
34
38
|
workspaceUnits: el('chat-units'),
|
|
39
|
+
moveNotice: el('chat-move-notice'), moveCopy: el('chat-move-copy'), movePrimary: el('chat-move-primary'),
|
|
40
|
+
moveSecondary: el('chat-move-secondary'), moveDismiss: el('chat-move-dismiss'),
|
|
35
41
|
};
|
|
36
42
|
|
|
37
43
|
const state = {
|
|
44
|
+
scopeView: null, scopeViewChatId: null, scopeChoice: null, scopeEditing: false, scopePickerOpen: false,
|
|
38
45
|
// signInPending is keyed by provider: a wait started in one conversation must not paint an
|
|
39
46
|
// unrelated conversation's button as Waiting for sign-in… for the next two minutes.
|
|
40
47
|
// #1798: the chat owner's display units as the server last answered them (null = not known yet), and the
|
|
41
48
|
// generation that answer belongs to. Receipts show recorded kilograms until they are known.
|
|
42
49
|
displayUnits: null, displayUnitsGeneration: 0,
|
|
50
|
+
// #1890 PR 3b: the workspace history's pointer rows, the move notice on screen, and moves being followed now.
|
|
51
|
+
movedChats: [], movedChatsKnown: null, moveNotice: null, moveNoticeTimer: null, followingMoves: new Set(), movingPoll: null,
|
|
43
52
|
sessionReady: false, scope: null, chats: [], archivedChats: [], unreadableChats: [], chat: null, events: [], capability: null, signInPending: new Set(), desktop: null,
|
|
44
53
|
source: null, eventReconnectTimer: null, eventReconnectAttempt: 0, eventReconnectChatId: null, attachments: [], imageLimitChatId: null, followupSubmitting: false, followupUnknownId: null, resolvingFollowupIds: new Set(), retryingFollowupIds: new Set(), integrations: null, historyOpen: false, historyOpenings: 0, historyFilter: 'all', archivedHistoryOpen: false,
|
|
45
54
|
instructorAnswers: [], historyLoading: false, historyRequestGeneration: 0, picker: null, loading: false,
|
|
46
|
-
draftTimer: null, localDraft: null, backgroundDrafts: new Map(), draftWrites: new Map(), draftVersions: new Map(), unknownFollowups: new Map(), refreshTimer: null, scopeGeneration: 0, selectionGeneration: 0, choosingProvider: false,
|
|
55
|
+
draftTimer: null, localDraft: null, backgroundDrafts: new Map(), draftWrites: new Map(), draftVersions: new Map(), unknownFollowups: new Map(), refreshTimer: null, scopeGeneration: 0, selectionGeneration: 0, openInGeneration: 0, choosingProvider: false,
|
|
47
56
|
answerJump: null, answerJumpTimer: null, scopeInitialized: false, renaming: null, historyRename: null, pendingSubmissionId: null, recoveryMessage: null, recoveryCanEnd: false,
|
|
48
57
|
stream: null, liveStatusTurnId: null, decidingApprovalIds: new Set(), revokingApprovalTurns: new Set(), uploadingChatIds: new Set(),
|
|
49
58
|
// #1653 stage 4: this chat owner's (project or workflow, #1890) questions linked to live Tekla parts, the card's open lists, and the receipt showing it.
|
|
@@ -147,6 +156,11 @@
|
|
|
147
156
|
error.reason = body?.reason || null;
|
|
148
157
|
error.recovery = Array.isArray(body?.recovery) ? body.recovery : null;
|
|
149
158
|
error.status = response.status;
|
|
159
|
+
// #1890 PR 3b: the conversation moved — wherever this was asked from, the open tab follows it.
|
|
160
|
+
if (error.code === 'chat-moved' && body?.to?.chatId) {
|
|
161
|
+
error.movedTo = body.to;
|
|
162
|
+
queueMicrotask(() => { void followMovedChat(body.to); });
|
|
163
|
+
}
|
|
150
164
|
throw error;
|
|
151
165
|
}
|
|
152
166
|
return body;
|
|
@@ -198,6 +212,11 @@
|
|
|
198
212
|
// #1907: the server marks a not-sent reason it already wrote for the person; it is shown as is.
|
|
199
213
|
if (code === 'chat-send-refused-plain' && raw) return raw;
|
|
200
214
|
const codeMessages = {
|
|
215
|
+
// #1890 PR 3b: the server's own sentences name the workflow.
|
|
216
|
+
'chat-moving': raw,
|
|
217
|
+
'chat-moved': raw,
|
|
218
|
+
'chat-arriving': raw,
|
|
219
|
+
'chat-move-busy': raw,
|
|
201
220
|
'chat-origin-refused': 'This chat can only be used from the FloLess app. Reload the page and try again.',
|
|
202
221
|
'chat-owner-stale': 'This conversation no longer matches the current project or workflow folder. Reopen the project or workflow, then try again.',
|
|
203
222
|
'chat-cwd-stale': 'This conversation no longer matches the current project or workflow folder. Reopen the project or workflow, then try again.',
|
|
@@ -371,6 +390,8 @@
|
|
|
371
390
|
|
|
372
391
|
function report(error, prefix = '', messages = null) {
|
|
373
392
|
const code = String(error && error.code || '');
|
|
393
|
+
// #1890 PR 3b: a conversation that moved is not a failure — request() already follows it into its workflow.
|
|
394
|
+
if (code === 'chat-moved' && error?.movedTo) return;
|
|
374
395
|
const message = `${prefix}${prefix ? ': ' : ''}${messages?.[code] || errorMessage(error)}`;
|
|
375
396
|
// Keep the raw cause (#1604): the user-facing sentence deliberately drops it, and without it a
|
|
376
397
|
// failure could only be diagnosed from the server log. A timeout, a network failure or a server
|
|
@@ -536,13 +557,15 @@
|
|
|
536
557
|
const dashboardVisible = document.getElementById('dashboard')?.hidden === false;
|
|
537
558
|
// #1890: the Workflows landing (the list of workflows), not the canvas of the workflow loaded underneath.
|
|
538
559
|
const workflowLanding = document.getElementById('wf-landing')?.hidden === false;
|
|
539
|
-
|
|
560
|
+
// #2007: the Agents tab is its own surface; where you are adds context only.
|
|
561
|
+
const agentsMode = document.body.classList.contains('mode-agents');
|
|
562
|
+
const surface = agentsMode && !reportOpen ? (window.flolessAgents?.surface?.() || 'agent-list') : reportOpen ? (threeDimensionalReport ? '3d-report' : 'report')
|
|
540
563
|
: editorOpen ? 'model-editor'
|
|
541
564
|
: workspaceMode ? (workspaceProjectOpen ? workspaceSurface : 'project-list')
|
|
542
565
|
: workflowLanding ? 'workflow-list' : dashboardVisible ? 'dashboard' : 'workflow-canvas';
|
|
543
566
|
if (options.surfaceOnly) return { surface };
|
|
544
567
|
return {
|
|
545
|
-
mode: workspaceMode ? 'workspaces' : workflowMode ? 'workflows' : 'canvas',
|
|
568
|
+
mode: agentsMode ? 'agents' : workspaceMode ? 'workspaces' : workflowMode ? 'workflows' : 'canvas',
|
|
546
569
|
surface,
|
|
547
570
|
activity: workflowRunning ? 'workflow-running' : 'idle',
|
|
548
571
|
visibleText: visibleFloLessSurfaceText(surface),
|
|
@@ -575,6 +598,7 @@
|
|
|
575
598
|
case 'project-knowledge': return shellText('ws-knowledge');
|
|
576
599
|
case 'project-list': return shellText('ws-landing');
|
|
577
600
|
case 'workflow-list': return shellText('wf-landing');
|
|
601
|
+
case 'agent-list': case 'agent-page': return shellText('agents-surface');
|
|
578
602
|
case 'workflow-canvas': return shellText('canvas-main', 'inspect');
|
|
579
603
|
case 'dashboard': return shellText('dashboard');
|
|
580
604
|
case 'report': return boundedVisibleText(readVisibleFrameText('report-frame'), shellText('report-title', 'report-sub', 'report-overlay'));
|
|
@@ -589,7 +613,7 @@
|
|
|
589
613
|
'drawing-filter': 'Drawing Filter', 'project-model': 'project model', 'project-exports': 'project exports',
|
|
590
614
|
'project-history': 'project history', 'project-knowledge': 'project Knowledge', 'project-list': 'project list',
|
|
591
615
|
'workflow-canvas': 'workflow canvas', dashboard: 'dashboard', report: 'report', '3d-report': '3D report',
|
|
592
|
-
'model-editor': 'model editor', 'workflow-list': 'workflow list',
|
|
616
|
+
'model-editor': 'model editor', 'workflow-list': 'workflow list', 'agent-list': 'list of agents', 'agent-page': 'agent page',
|
|
593
617
|
};
|
|
594
618
|
return `${labels[context.surface] || 'FloLess'} · visible state${context.activity === 'workflow-running' ? ' · workflow running' : ''}`;
|
|
595
619
|
}
|
|
@@ -779,6 +803,21 @@
|
|
|
779
803
|
ui.disclosure.hidden = options.opening === true || Boolean(state.chat) || !state.scope?.owner;
|
|
780
804
|
}
|
|
781
805
|
|
|
806
|
+
// Everything a conversation paints above the composer is painted from `state.chat`, which is null on the
|
|
807
|
+
// chooser. Repaint each one so none of it is left over from another conversation: the pending approval card
|
|
808
|
+
// and its Deny / Approve buttons (#1958 — they did nothing, with no chat to decide on, and the shell still
|
|
809
|
+
// reported an approval waiting), the "Auto-approval on" scope card, the library chip ("added to this chat"),
|
|
810
|
+
// the "connectors are on" line and allowances (#1907), the allowed changes (#1890) and checks (#1956), and the
|
|
811
|
+
// scope control. Each paints itself back when its conversation is opened again.
|
|
812
|
+
function clearOtherConversationLines() {
|
|
813
|
+
paintApproval();
|
|
814
|
+
paintTeklaChip();
|
|
815
|
+
paintConnectorAllowance();
|
|
816
|
+
paintChangeAllowance();
|
|
817
|
+
paintScopeControl();
|
|
818
|
+
paintCheckAllowance();
|
|
819
|
+
}
|
|
820
|
+
|
|
782
821
|
function providerChooser() {
|
|
783
822
|
paintComposerDisclosure();
|
|
784
823
|
// Without a conversation owner there is no provider, history, or refresh to offer: none of those
|
|
@@ -787,6 +826,11 @@
|
|
|
787
826
|
// conversation must go with it — and so must the previous conversation's units line.
|
|
788
827
|
shell.querySelector('.ai-chat-runtime')?.remove(); stopRuntimePoll();
|
|
789
828
|
if (ui.workspaceUnits) { ui.workspaceUnits.hidden = true; ui.workspaceUnits.replaceChildren(); delete ui.workspaceUnits.dataset.painted; }
|
|
829
|
+
// And its recovery banner, with its Stop response / Check again (#1921). The banner is painted from
|
|
830
|
+
// the selected conversation, so it is repainted here — on every way onto the chooser, not only + New
|
|
831
|
+
// conversation — and paints itself back when that conversation is opened again.
|
|
832
|
+
paintRecovery();
|
|
833
|
+
clearOtherConversationLines();
|
|
790
834
|
if (!state.scope?.owner) { showUnscoped(); return; }
|
|
791
835
|
ui.feed.replaceChildren();
|
|
792
836
|
updateOffscreenActivity();
|
|
@@ -984,7 +1028,7 @@
|
|
|
984
1028
|
clearProviderChoice();
|
|
985
1029
|
closeSource();
|
|
986
1030
|
clearLiveStream(true);
|
|
987
|
-
state.chats = []; state.archivedChats = []; state.unreadableChats = []; state.chat = null; state.events = []; state.capability = null; state.attachments = []; state.followupUnknownId = null;
|
|
1031
|
+
state.chats = []; state.archivedChats = []; state.unreadableChats = []; state.movedChats = []; state.movedChatsKnown = null; state.chat = null; state.events = []; state.capability = null; state.attachments = []; state.followupUnknownId = null;
|
|
988
1032
|
ui.feed.replaceChildren();
|
|
989
1033
|
updateOffscreenActivity();
|
|
990
1034
|
const empty = document.createElement('div');
|
|
@@ -1169,8 +1213,10 @@
|
|
|
1169
1213
|
const archivedChats = state.archivedChats.filter((chat) => Boolean(chat.archivedAt));
|
|
1170
1214
|
const unreadableChats = state.unreadableChats || [];
|
|
1171
1215
|
if (unreadableChats.length) appendUnreadableChats(unreadableChats, ui.history);
|
|
1216
|
+
const movedChats = state.scope.owner.kind === 'workspace' ? (state.movedChats || []) : [];
|
|
1217
|
+
if (movedChats.length) appendMovedChats(movedChats, ui.history);
|
|
1172
1218
|
if (!state.chats.length && !archivedChats.length) {
|
|
1173
|
-
if (unreadableChats.length) { restoreHistoryFocus(focusedCommand); return; }
|
|
1219
|
+
if (unreadableChats.length || movedChats.length) { restoreHistoryFocus(focusedCommand); return; }
|
|
1174
1220
|
const empty = document.createElement('div'); empty.className = 'ai-chat-history-empty';
|
|
1175
1221
|
empty.textContent = 'No conversations here yet.';
|
|
1176
1222
|
ui.history.append(empty); return;
|
|
@@ -1280,6 +1326,240 @@
|
|
|
1280
1326
|
// A conversation whose saved file is damaged (#1619). The server knows nothing trustworthy about it
|
|
1281
1327
|
// beyond its id — no title, no provider — so the row says what happened and offers the one thing
|
|
1282
1328
|
// that can be done here. It opens nothing, so it is not a button; only Discard acts.
|
|
1329
|
+
/*
|
|
1330
|
+
* #1890 PR 3b: a conversation that moved into the workflow it built. Its old home keeps a pointer row that opens it
|
|
1331
|
+
* there; a row whose new home is gone says so and offers Remove (the pointer only, never a conversation).
|
|
1332
|
+
*/
|
|
1333
|
+
function appendMovedChats(entries, destination) {
|
|
1334
|
+
const group = document.createElement('section'); group.className = 'ai-chat-history-group ai-chat-history-moved';
|
|
1335
|
+
group.setAttribute('aria-label', 'Conversations that moved into a workflow');
|
|
1336
|
+
const label = document.createElement('div'); label.className = 'ai-chat-history-label'; label.textContent = 'Moved';
|
|
1337
|
+
group.append(label);
|
|
1338
|
+
for (const entry of entries) {
|
|
1339
|
+
if (entry.targetGone) {
|
|
1340
|
+
const row = document.createElement('div');
|
|
1341
|
+
row.className = 'ai-chat-history-row unreadable moved-gone';
|
|
1342
|
+
row.dataset.chatId = entry.chatId;
|
|
1343
|
+
const title = document.createElement('span'); title.className = 'ai-chat-history-title'; title.textContent = entry.title;
|
|
1344
|
+
const meta = document.createElement('span'); meta.className = 'ai-chat-history-meta';
|
|
1345
|
+
meta.textContent = 'This conversation’s workflow is no longer here.';
|
|
1346
|
+
const actions = document.createElement('span'); actions.className = 'ai-chat-history-actions always-on';
|
|
1347
|
+
const remove = document.createElement('button');
|
|
1348
|
+
remove.type = 'button'; remove.className = 'ai-chat-history-moved-remove'; remove.textContent = 'Remove';
|
|
1349
|
+
remove.dataset.commandId = `shell.chat-moved-remove#${entry.chatId}`;
|
|
1350
|
+
remove.dataset.commandInstanceLabel = entry.title;
|
|
1351
|
+
remove.setAttribute('aria-label', `Remove ${entry.title}`);
|
|
1352
|
+
remove.dataset.tip = 'Removes only this row';
|
|
1353
|
+
remove.addEventListener('click', (event) => { event.preventDefault(); event.stopPropagation(); void removeMovedPointer(entry, remove); });
|
|
1354
|
+
actions.append(remove);
|
|
1355
|
+
row.append(title, meta, actions);
|
|
1356
|
+
group.append(row);
|
|
1357
|
+
continue;
|
|
1358
|
+
}
|
|
1359
|
+
const row = button('', `shell.chat-moved-open#${entry.chatId}`, 'ai-chat-history-row moved');
|
|
1360
|
+
row.dataset.commandInstanceLabel = `${entry.title} · ${entry.to.label}`;
|
|
1361
|
+
row.setAttribute('aria-label', `${entry.title}, moved to workflow ${entry.to.label}. Open it there`);
|
|
1362
|
+
const title = document.createElement('span'); title.className = 'ai-chat-history-title'; title.textContent = entry.title;
|
|
1363
|
+
const meta = document.createElement('span'); meta.className = 'ai-chat-history-meta'; meta.textContent = `Moved to workflow ${entry.to.label}`;
|
|
1364
|
+
row.append(title, meta);
|
|
1365
|
+
row.addEventListener('click', () => { void openMovedChat(movedTarget(entry)).catch((error) => report(error, 'Could not open that conversation')); });
|
|
1366
|
+
group.append(row);
|
|
1367
|
+
}
|
|
1368
|
+
destination.append(group);
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
async function removeMovedPointer(entry, trigger) {
|
|
1372
|
+
const snapshot = captureScope();
|
|
1373
|
+
if (!snapshot) return;
|
|
1374
|
+
trigger.hidden = true;
|
|
1375
|
+
try {
|
|
1376
|
+
await request(`/api/chat/conversations/${encodeURIComponent(entry.chatId)}/moved-pointer`, {
|
|
1377
|
+
method: 'DELETE', body: JSON.stringify({ owner: snapshot.scope.owner }),
|
|
1378
|
+
});
|
|
1379
|
+
if (!sameScope(snapshot.scope, snapshot.generation)) return;
|
|
1380
|
+
state.movedChats = (state.movedChats || []).filter((item) => item.chatId !== entry.chatId);
|
|
1381
|
+
paintHistory();
|
|
1382
|
+
announce(`Removed ${entry.title} from this list.`);
|
|
1383
|
+
(ui.history.querySelector('.ai-chat-history-row:not(.unreadable)') || ui.history.querySelector('button'))?.focus();
|
|
1384
|
+
} catch (error) {
|
|
1385
|
+
trigger.hidden = false;
|
|
1386
|
+
report(error, 'Could not remove that row');
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
|
|
1390
|
+
/** New pointer rows since the last history read: a conversation not on screen moved — say so, with Open workflow. */
|
|
1391
|
+
function noteMovedChats(rows) {
|
|
1392
|
+
const list = Array.isArray(rows) ? rows : [];
|
|
1393
|
+
const known = state.movedChatsKnown;
|
|
1394
|
+
state.movedChats = list;
|
|
1395
|
+
state.movedChatsKnown = new Set(list.map((row) => row.chatId));
|
|
1396
|
+
if (!known) return;
|
|
1397
|
+
const fresh = list.find((row) => !known.has(row.chatId) && !row.targetGone && !state.followingMoves.has(row.chatId));
|
|
1398
|
+
if (!fresh) return;
|
|
1399
|
+
showMoveNotice({
|
|
1400
|
+
neutral: true, text: `${fresh.title} moved into workflow ${fresh.to.label}.`,
|
|
1401
|
+
primary: { label: 'Open workflow', command: 'shell.chat-move-open', run: () => openMovedChat(movedTarget(fresh)) }, dismiss: true,
|
|
1402
|
+
});
|
|
1403
|
+
announce(`${fresh.title} moved into workflow ${fresh.to.label}.`);
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
/** Where a pointer row's conversation lives now, in the shape the server's "moved" answer uses. */
|
|
1407
|
+
function movedTarget(pointer) {
|
|
1408
|
+
return { owner: { kind: 'workflow', workflowId: pointer.to.workflowId }, chatId: pointer.chatId, label: pointer.to.label };
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1411
|
+
/**
|
|
1412
|
+
* #2007: show one conversation of any owner — an agent run's — without the location changing. Loads that owner's
|
|
1413
|
+
* history when it is not the one on screen, then selects the conversation. The last call wins.
|
|
1414
|
+
*/
|
|
1415
|
+
async function openConversationIn(scope, chatId) {
|
|
1416
|
+
const ticket = ++state.openInGeneration;
|
|
1417
|
+
if (!scope?.owner || typeof chatId !== 'string') return false;
|
|
1418
|
+
if (scopeKey(scope) !== scopeKey(state.scope)) await loadScope({ ...scope, chatId });
|
|
1419
|
+
else if (scope.label && state.scope && scope.label !== state.scope.label) { state.scope = { ...state.scope, label: scope.label }; ui.scope.textContent = scope.label; }
|
|
1420
|
+
if (ticket !== state.openInGeneration) return false;
|
|
1421
|
+
if (state.chat?.chatId !== chatId) await selectConversation(chatId, { replaceProviderChoice: true, focus: false });
|
|
1422
|
+
return ticket === state.openInGeneration && state.chat?.chatId === chatId;
|
|
1423
|
+
}
|
|
1424
|
+
|
|
1425
|
+
/** Open a moved conversation in its new home: the workflow (published or draft), then the conversation there. */
|
|
1426
|
+
async function openMovedChat(to) {
|
|
1427
|
+
const bridge = window.flolessBridge;
|
|
1428
|
+
if (typeof bridge?.openOwnedWorkflow !== 'function') throw new Error('Open the workflow from Workflows to see this conversation.');
|
|
1429
|
+
await bridge.openOwnedWorkflow(to.owner.workflowId);
|
|
1430
|
+
await refreshScope(true);
|
|
1431
|
+
if (state.scope?.owner?.kind !== 'workflow' || state.scope.owner.workflowId !== to.owner.workflowId) return false;
|
|
1432
|
+
await selectConversation(to.chatId, { replaceProviderChoice: true, focus: false });
|
|
1433
|
+
return true;
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1436
|
+
/*
|
|
1437
|
+
* The conversation on screen moved (its stream said so, or a request was answered 410): follow it into the workflow,
|
|
1438
|
+
* keep the person's unsent text — it wins over the copied draft — and keep their focus where it was.
|
|
1439
|
+
*/
|
|
1440
|
+
async function followMovedChat(to) {
|
|
1441
|
+
const chatId = to?.chatId;
|
|
1442
|
+
if (!chatId || state.followingMoves.has(chatId)) return;
|
|
1443
|
+
if (state.chat?.chatId !== chatId || state.scope?.owner?.kind !== 'workspace') return;
|
|
1444
|
+
state.followingMoves.add(chatId);
|
|
1445
|
+
// The newest text the person typed wins — including anything typed while the workflow opens. Loading clears the
|
|
1446
|
+
// box without an input event, so only the person's own typing updates this.
|
|
1447
|
+
let draft = ui.input.value;
|
|
1448
|
+
let typed = false;
|
|
1449
|
+
const keepTyping = () => { draft = ui.input.value; typed = true; };
|
|
1450
|
+
ui.input.addEventListener('input', keepTyping);
|
|
1451
|
+
const hadFocus = document.activeElement === ui.input || ui.feed.contains(document.activeElement);
|
|
1452
|
+
closeSource();
|
|
1453
|
+
try {
|
|
1454
|
+
let opened;
|
|
1455
|
+
try { opened = await openMovedChat(to); } finally { ui.input.removeEventListener('input', keepTyping); }
|
|
1456
|
+
if (!opened) return;
|
|
1457
|
+
if ((draft || typed) && state.chat?.chatId === chatId && ui.input.value !== draft) {
|
|
1458
|
+
ui.input.value = draft; autosize(); saveDraftSoon(); updateSendState();
|
|
1459
|
+
}
|
|
1460
|
+
if (hadFocus && state.chat?.chatId === chatId) ui.input.focus({ preventScroll: true });
|
|
1461
|
+
showMoveNotice({ neutral: true, text: `This conversation moved into workflow ${to.label}.`, autoDismissMs: 8000 });
|
|
1462
|
+
announce(`This conversation moved into workflow ${to.label}.`);
|
|
1463
|
+
} catch (error) {
|
|
1464
|
+
report(error, 'Could not open the workflow this conversation moved into');
|
|
1465
|
+
} finally { state.followingMoves.delete(chatId); }
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
/*
|
|
1469
|
+
* While the conversation on screen moves: look at the history list, never at the conversation itself — once the move
|
|
1470
|
+
* lands its old address answers "moved", which the browser would log as a failed request. The list says either that it
|
|
1471
|
+
* is still moving (its row) or where it went (its pointer row), and the tab follows from the pointer.
|
|
1472
|
+
*/
|
|
1473
|
+
async function checkMoveProgress(chatId) {
|
|
1474
|
+
const snapshot = captureChat();
|
|
1475
|
+
if (!snapshot || snapshot.chatId !== chatId) return;
|
|
1476
|
+
let listed;
|
|
1477
|
+
try { listed = await request(`/api/chat/conversations?${ownerQuery(snapshot.scope.owner)}`); }
|
|
1478
|
+
catch { if (sameChat(snapshot)) updateSendState(); return; }
|
|
1479
|
+
if (!sameChat(snapshot)) return;
|
|
1480
|
+
const pointer = (listed.movedChats || []).find((row) => row.chatId === chatId);
|
|
1481
|
+
if (pointer) {
|
|
1482
|
+
void followMovedChat(movedTarget(pointer));
|
|
1483
|
+
return;
|
|
1484
|
+
}
|
|
1485
|
+
const row = (listed.chats || []).find((item) => item.chatId === chatId);
|
|
1486
|
+
if (row && state.chat) {
|
|
1487
|
+
state.chat = { ...state.chat, ...row };
|
|
1488
|
+
paintConversation();
|
|
1489
|
+
}
|
|
1490
|
+
updateSendState();
|
|
1491
|
+
}
|
|
1492
|
+
|
|
1493
|
+
function showMoveNotice(notice) {
|
|
1494
|
+
clearTimeout(state.moveNoticeTimer);
|
|
1495
|
+
state.moveNotice = notice;
|
|
1496
|
+
if (notice?.autoDismissMs) {
|
|
1497
|
+
state.moveNoticeTimer = setTimeout(() => { if (state.moveNotice === notice) { state.moveNotice = null; paintMoveNotice(); } }, notice.autoDismissMs);
|
|
1498
|
+
}
|
|
1499
|
+
paintMoveNotice();
|
|
1500
|
+
}
|
|
1501
|
+
|
|
1502
|
+
/** A waiting move with a warning, for the conversation on screen: the sentence and the person's choices. */
|
|
1503
|
+
function moveNoticeForChat(chat) {
|
|
1504
|
+
const rehome = chat?.rehome;
|
|
1505
|
+
if (!rehome || state.scope?.owner?.kind !== 'workspace' || rehome.state !== 'pending' || !rehome.warning) return null;
|
|
1506
|
+
const keep = { label: 'Keep it here', command: 'shell.chat-move-keep', run: () => keepConversationHere(chat.chatId) };
|
|
1507
|
+
const retry = { label: 'Try again', command: 'shell.chat-move-retry', run: () => retryConversationMove(chat.chatId) };
|
|
1508
|
+
return rehome.targetGone
|
|
1509
|
+
? { neutral: false, text: rehome.warning, primary: keep, secondary: retry, chatId: chat.chatId }
|
|
1510
|
+
: { neutral: false, text: rehome.warning, primary: retry, chatId: chat.chatId };
|
|
1511
|
+
}
|
|
1512
|
+
|
|
1513
|
+
function paintMoveNotice() {
|
|
1514
|
+
if (!ui.moveNotice) return;
|
|
1515
|
+
const notice = (state.moveBusy && state.moveBusy.chatId === state.chat?.chatId ? state.moveBusy : null)
|
|
1516
|
+
|| moveNoticeForChat(state.chat) || state.moveNotice;
|
|
1517
|
+
ui.moveNotice.hidden = !notice;
|
|
1518
|
+
if (!notice) return;
|
|
1519
|
+
ui.moveNotice.classList.toggle('neutral', Boolean(notice.neutral));
|
|
1520
|
+
const text = notice.busyText || notice.text;
|
|
1521
|
+
if (ui.moveCopy.textContent !== text) ui.moveCopy.textContent = text;
|
|
1522
|
+
for (const [control, action] of [[ui.movePrimary, notice.primary], [ui.moveSecondary, notice.secondary]]) {
|
|
1523
|
+
// A choice that cannot apply right now is hidden, not disabled.
|
|
1524
|
+
control.hidden = !action || Boolean(notice.busyText);
|
|
1525
|
+
if (!action) continue;
|
|
1526
|
+
control.textContent = action.label;
|
|
1527
|
+
control.dataset.commandId = action.command;
|
|
1528
|
+
control.onclick = () => { void runMoveAction(notice, action); };
|
|
1529
|
+
}
|
|
1530
|
+
ui.moveDismiss.hidden = !notice.dismiss;
|
|
1531
|
+
ui.moveDismiss.onclick = () => { state.moveNotice = null; paintMoveNotice(); ui.input.focus({ preventScroll: true }); };
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1534
|
+
async function runMoveAction(notice, action) {
|
|
1535
|
+
state.moveBusy = { ...notice, chatId: notice.chatId ?? state.chat?.chatId ?? null, busyText: action.label === 'Try again' ? 'Trying again…' : 'One moment…' };
|
|
1536
|
+
paintMoveNotice();
|
|
1537
|
+
try { await action.run(); }
|
|
1538
|
+
catch (error) { report(error, 'Could not do that'); }
|
|
1539
|
+
finally {
|
|
1540
|
+
state.moveBusy = null;
|
|
1541
|
+
if (state.moveNotice === notice) state.moveNotice = null;
|
|
1542
|
+
paintMoveNotice();
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
|
|
1546
|
+
async function retryConversationMove(chatId) {
|
|
1547
|
+
const snapshot = captureChat();
|
|
1548
|
+
const result = await request(`/api/chat/conversations/${encodeURIComponent(chatId)}/move/retry`, {
|
|
1549
|
+
method: 'POST', body: JSON.stringify({ owner: { kind: 'workspace' } }),
|
|
1550
|
+
});
|
|
1551
|
+
if (result?.outcome !== 'moved' && snapshot && sameChat(snapshot)) await refreshConversation(chatId, false);
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
async function keepConversationHere(chatId) {
|
|
1555
|
+
await request(`/api/chat/conversations/${encodeURIComponent(chatId)}/move/keep`, {
|
|
1556
|
+
method: 'POST', body: JSON.stringify({ owner: { kind: 'workspace' } }),
|
|
1557
|
+
});
|
|
1558
|
+
await refreshConversation(chatId, false);
|
|
1559
|
+
announce('This conversation stays in the workspace.');
|
|
1560
|
+
ui.input.focus({ preventScroll: true });
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1283
1563
|
function appendUnreadableChats(entries, destination) {
|
|
1284
1564
|
const group = document.createElement('section'); group.className = 'ai-chat-history-group ai-chat-history-unreadable';
|
|
1285
1565
|
group.setAttribute('aria-label', 'Conversations that can’t be opened');
|
|
@@ -1933,6 +2213,403 @@
|
|
|
1933
2213
|
return item;
|
|
1934
2214
|
}
|
|
1935
2215
|
|
|
2216
|
+
/** A refusal FloLess wrote for the person (`plain`), shown as is: what happened, why, and what to do next. */
|
|
2217
|
+
function renderPlainNotice(event) {
|
|
2218
|
+
const item = document.createElement('div');
|
|
2219
|
+
item.className = 'ai-chat-event error';
|
|
2220
|
+
item.dataset.eventSequence = String(event.sequence);
|
|
2221
|
+
item.dataset.eventId = event.eventId;
|
|
2222
|
+
const label = document.createElement('strong');
|
|
2223
|
+
label.textContent = 'Not done';
|
|
2224
|
+
item.append(label, document.createTextNode(` · ${event.payload.message}`));
|
|
2225
|
+
return item;
|
|
2226
|
+
}
|
|
2227
|
+
|
|
2228
|
+
/** #2007: the first line of an agent run — who started it and the scope it was given. Information, not a refusal. */
|
|
2229
|
+
function renderAgentRunLine(event) {
|
|
2230
|
+
const item = document.createElement('div');
|
|
2231
|
+
item.className = 'ai-chat-event connector agent-run';
|
|
2232
|
+
item.dataset.eventSequence = String(event.sequence);
|
|
2233
|
+
item.dataset.eventId = event.eventId;
|
|
2234
|
+
const label = document.createElement('strong');
|
|
2235
|
+
label.textContent = 'Agent run';
|
|
2236
|
+
item.append(label, document.createTextNode(` · ${String(event.payload.message || '')}`));
|
|
2237
|
+
return item;
|
|
2238
|
+
}
|
|
2239
|
+
|
|
2240
|
+
function renderChangeReceipt(event) {
|
|
2241
|
+
const item = document.createElement('div');
|
|
2242
|
+
item.className = 'ai-chat-event connector';
|
|
2243
|
+
item.dataset.eventSequence = String(event.sequence);
|
|
2244
|
+
item.dataset.eventId = event.eventId;
|
|
2245
|
+
const change = event.payload.change;
|
|
2246
|
+
const label = document.createElement('strong');
|
|
2247
|
+
if (event.payload.reason) {
|
|
2248
|
+
label.textContent = 'Not changed';
|
|
2249
|
+
item.append(label, document.createTextNode(' · FloLess could not confirm this change could still go ahead. Ask the AI to check the current files and scope, then try again.'));
|
|
2250
|
+
return item;
|
|
2251
|
+
}
|
|
2252
|
+
label.textContent = event.payload.coveredBy === 'create' ? 'Part of creating the workflow' : 'Allowed for this chat';
|
|
2253
|
+
// The receipt records the approval FloLess gave; whether the file was then written is the AI's own reply to report.
|
|
2254
|
+
const owners = Array.isArray(change?.owners) ? change.owners : [];
|
|
2255
|
+
const paths = owners.flatMap((owner) => owner.paths || []);
|
|
2256
|
+
const detail = paths.length === 1 ? `Approved a change to ${paths[0]}`
|
|
2257
|
+
: owners.length === 1 ? `Approved changes to ${paths.length} files in ${owners[0].label}` : `Approved changes to ${paths.length} files in ${changeNames(change)}`;
|
|
2258
|
+
item.append(label, document.createTextNode(` · ${detail}`));
|
|
2259
|
+
return item;
|
|
2260
|
+
}
|
|
2261
|
+
|
|
2262
|
+
/*
|
|
2263
|
+
* #1900 — the AI suggests connecting something to FloLess. The card never connects anything: every button is the
|
|
2264
|
+
* person's own act on a part A surface (Check it works, or Integrations). It shows what is connected NOW, read live
|
|
2265
|
+
* from /api/connections/services when painted and again when the person comes back to it, never the state the AI saw.
|
|
2266
|
+
* The feed repaints on every streamed word, so each card is painted once per state and reused: a check in progress,
|
|
2267
|
+
* its inline question and its result all live in the card itself and survive the repaint.
|
|
2268
|
+
*/
|
|
2269
|
+
const connectionCards = new Map();
|
|
2270
|
+
const CONNECTION_CARDS_KEPT = 200;
|
|
2271
|
+
const connectionLive = { services: null, loading: false, loadedAt: 0, error: '' };
|
|
2272
|
+
const connectionsApi = () => window.flolessConnections || null;
|
|
2273
|
+
|
|
2274
|
+
/** Re-reads what is connected (and the latest checks) when the copy on screen is older than `maxAgeMs`. */
|
|
2275
|
+
function refreshConnectionLive(maxAgeMs = 15000) {
|
|
2276
|
+
const api = connectionsApi();
|
|
2277
|
+
if (!api || connectionLive.loading) return;
|
|
2278
|
+
if (connectionLive.loadedAt && Date.now() - connectionLive.loadedAt < maxAgeMs) return;
|
|
2279
|
+
connectionLive.loading = true;
|
|
2280
|
+
Promise.all([api.loadServices(), api.loadReceipts()])
|
|
2281
|
+
.then(([services]) => { connectionLive.services = services; connectionLive.error = ''; })
|
|
2282
|
+
.catch((error) => { connectionLive.error = api.sentenceOf(error); })
|
|
2283
|
+
.finally(() => { connectionLive.loading = false; connectionLive.loadedAt = Date.now(); repaintConnectionCards(); });
|
|
2284
|
+
}
|
|
2285
|
+
|
|
2286
|
+
function repaintConnectionCards() {
|
|
2287
|
+
for (const old of ui.feed?.querySelectorAll('.ai-chat-connection-card[data-proposal-id]') || []) {
|
|
2288
|
+
const event = state.events.find((known) => known.eventId === old.dataset.eventId);
|
|
2289
|
+
if (!event) continue;
|
|
2290
|
+
const next = renderConnectionProposal(event);
|
|
2291
|
+
if (next !== old) {
|
|
2292
|
+
const focused = old.contains(document.activeElement) ? document.activeElement.dataset.commandId : null;
|
|
2293
|
+
old.replaceWith(next);
|
|
2294
|
+
if (focused) [...next.querySelectorAll('[data-command-id]')].find((node) => node.dataset.commandId === focused && !node.disabled)?.focus({ preventScroll: true });
|
|
2295
|
+
}
|
|
2296
|
+
}
|
|
2297
|
+
}
|
|
2298
|
+
|
|
2299
|
+
window.addEventListener('focus', () => { if (ui.feed?.querySelector('.ai-chat-connection-card[data-proposal-id]')) refreshConnectionLive(0); });
|
|
2300
|
+
|
|
2301
|
+
/**
|
|
2302
|
+
* Did the person answer Not now to this target? Dismissal is per target. The newest Not now / Show again in the
|
|
2303
|
+
* transcript decides; with none loaded, the conversation record's own list does.
|
|
2304
|
+
*/
|
|
2305
|
+
function connectionDismissed(target) {
|
|
2306
|
+
let latest = null;
|
|
2307
|
+
for (const event of state.events) {
|
|
2308
|
+
if (event.type === 'connection-proposal-update' && event.payload?.target === target) latest = event;
|
|
2309
|
+
}
|
|
2310
|
+
if (latest) return latest.payload.dismissed === true;
|
|
2311
|
+
return Array.isArray(state.chat?.connectionDismissals) && state.chat.connectionDismissals.some((row) => row.target === target);
|
|
2312
|
+
}
|
|
2313
|
+
|
|
2314
|
+
function renderConnectionProposal(event) {
|
|
2315
|
+
const payload = event.payload || {};
|
|
2316
|
+
const proposalId = String(payload.proposalId || event.eventId || '');
|
|
2317
|
+
refreshConnectionLive();
|
|
2318
|
+
let entry = connectionCards.get(proposalId);
|
|
2319
|
+
if (!entry) {
|
|
2320
|
+
entry = { node: null, signature: '', error: '', said: '', busy: false };
|
|
2321
|
+
connectionCards.set(proposalId, entry);
|
|
2322
|
+
while (connectionCards.size > CONNECTION_CARDS_KEPT) connectionCards.delete(connectionCards.keys().next().value);
|
|
2323
|
+
}
|
|
2324
|
+
const dismissed = connectionDismissed(payload.target);
|
|
2325
|
+
const services = connectionLive.services;
|
|
2326
|
+
const service = payload.targetKind === 'host' || !services ? null : services.find((row) => row.id === payload.target) || null;
|
|
2327
|
+
const alias = payload.targetKind === 'host' ? null : service?.choice?.source === 'floless' ? (service.choice.alias ?? null) : undefined;
|
|
2328
|
+
const receipt = payload.checkAgent && alias !== undefined ? connectionsApi()?.cachedReceipt(payload.checkAgent, alias) : null;
|
|
2329
|
+
const signature = JSON.stringify([event.eventId, dismissed, service, Boolean(services?.choicesUnreadable), Boolean(services),
|
|
2330
|
+
connectionLive.error, receipt?.probedAt || null, receipt?.state || null, entry.error, entry.busy]);
|
|
2331
|
+
if (entry.node && entry.signature === signature) return entry.node;
|
|
2332
|
+
// A check running, or its inline question open, lives in this node: keep it until it settles.
|
|
2333
|
+
if (entry.node && entry.node.querySelector('[aria-busy="true"], [aria-expanded="true"]')) return entry.node;
|
|
2334
|
+
entry.node = paintConnectionProposal(event, payload, proposalId, entry, { dismissed, service, alias });
|
|
2335
|
+
entry.signature = signature;
|
|
2336
|
+
return entry.node;
|
|
2337
|
+
}
|
|
2338
|
+
|
|
2339
|
+
function connectionButton(label, commandId, target, name, className = '') {
|
|
2340
|
+
const control = button(label, `${commandId}#${target}`, className);
|
|
2341
|
+
control.dataset.commandInstanceLabel = name;
|
|
2342
|
+
return control;
|
|
2343
|
+
}
|
|
2344
|
+
|
|
2345
|
+
function paintConnectionProposal(event, payload, proposalId, entry, { dismissed, service, alias }) {
|
|
2346
|
+
const api = connectionsApi();
|
|
2347
|
+
const target = String(payload.target || '');
|
|
2348
|
+
const name = String(payload.name || target || 'this');
|
|
2349
|
+
const card = document.createElement('section');
|
|
2350
|
+
card.className = 'ai-chat-filter-card ai-chat-connection-card';
|
|
2351
|
+
card.dataset.eventId = event.eventId;
|
|
2352
|
+
card.dataset.eventSequence = String(event.sequence);
|
|
2353
|
+
card.dataset.proposalId = proposalId;
|
|
2354
|
+
card.dataset.target = target;
|
|
2355
|
+
// Coming back to the card (after Integrations, say) reads what is connected again.
|
|
2356
|
+
card.addEventListener('focusin', () => refreshConnectionLive(3000));
|
|
2357
|
+
card.addEventListener('pointerenter', () => refreshConnectionLive(3000));
|
|
2358
|
+
const error = document.createElement('p');
|
|
2359
|
+
error.className = 'ai-chat-filter-note ai-chat-connection-error';
|
|
2360
|
+
error.setAttribute('role', 'status');
|
|
2361
|
+
error.textContent = entry.error;
|
|
2362
|
+
if (dismissed) {
|
|
2363
|
+
card.classList.add('is-dismissed');
|
|
2364
|
+
card.setAttribute('aria-label', `Suggestion to connect ${name}, set aside`);
|
|
2365
|
+
const line = document.createElement('div');
|
|
2366
|
+
line.className = 'ai-chat-connection-collapsed';
|
|
2367
|
+
const text = document.createElement('span');
|
|
2368
|
+
text.textContent = 'Not now — you can ask again any time';
|
|
2369
|
+
const again = connectionButton('Show again', 'shell.chat-connection-show-again', target, name);
|
|
2370
|
+
again.setAttribute('aria-label', `Show the suggestion to connect ${name} again`);
|
|
2371
|
+
again.dataset.tip = `Shows this card again, so you can connect ${name} or check it.`;
|
|
2372
|
+
again.disabled = entry.busy;
|
|
2373
|
+
again.addEventListener('click', () => { void setConnectionDismissed(event, false); });
|
|
2374
|
+
line.append(text, again);
|
|
2375
|
+
card.append(line, error);
|
|
2376
|
+
return card;
|
|
2377
|
+
}
|
|
2378
|
+
const head = document.createElement('div'); head.className = 'ai-chat-filter-card-head';
|
|
2379
|
+
const title = document.createElement('strong');
|
|
2380
|
+
title.id = `chat-connection-title-${proposalId}`;
|
|
2381
|
+
title.textContent = `Would you like me to connect ${name} to FloLess?`;
|
|
2382
|
+
card.setAttribute('aria-labelledby', title.id);
|
|
2383
|
+
head.append(title);
|
|
2384
|
+
card.append(head);
|
|
2385
|
+
// The AI's own words: plain text only.
|
|
2386
|
+
const why = typeof payload.why === 'string' ? payload.why.trim() : '';
|
|
2387
|
+
if (why) {
|
|
2388
|
+
const reason = document.createElement('p'); reason.className = 'ai-chat-filter-why';
|
|
2389
|
+
reason.textContent = why;
|
|
2390
|
+
card.append(reason);
|
|
2391
|
+
}
|
|
2392
|
+
const stateLine = document.createElement('p'); stateLine.className = 'ai-chat-filter-note ai-chat-connection-state';
|
|
2393
|
+
const actions = document.createElement('div'); actions.className = 'ai-chat-filter-actions';
|
|
2394
|
+
const confirmHost = document.createElement('div'); confirmHost.className = 'conn-confirm-host';
|
|
2395
|
+
const receiptHost = document.createElement('div'); receiptHost.className = 'conn-receipt-host';
|
|
2396
|
+
receiptHost.setAttribute('role', 'status');
|
|
2397
|
+
const said = document.createElement('p'); said.className = 'ai-chat-filter-note ai-chat-connection-said';
|
|
2398
|
+
said.setAttribute('role', 'status');
|
|
2399
|
+
said.textContent = entry.said;
|
|
2400
|
+
const say = (text) => { entry.said = text; said.textContent = text; };
|
|
2401
|
+
const integrations = (label, commandId, tip, primary = false) => {
|
|
2402
|
+
const control = connectionButton(label, commandId, target, name, primary ? 'ai-chat-filter-apply' : '');
|
|
2403
|
+
control.setAttribute('aria-label', `${label}: open Integrations at ${name}`);
|
|
2404
|
+
control.dataset.tip = tip;
|
|
2405
|
+
control.addEventListener('click', () => {
|
|
2406
|
+
if (typeof window.openIntegrations === 'function') window.openIntegrations(target);
|
|
2407
|
+
else say('FloLess couldn’t open Integrations. Open it from the menu, then find ' + name + '.');
|
|
2408
|
+
});
|
|
2409
|
+
return control;
|
|
2410
|
+
};
|
|
2411
|
+
const check = (checkAlias, pinned) => {
|
|
2412
|
+
const control = api.checkButton({ commandId: 'shell.chat-connection-check', agent: payload.checkAgent, alias: checkAlias, label: name, receiptHost, confirmHost, announce: say,
|
|
2413
|
+
onReceipt: () => repaintConnectionCards(), ...pinned });
|
|
2414
|
+
control.classList.add('ai-chat-filter-apply');
|
|
2415
|
+
const latest = api.cachedReceipt(payload.checkAgent, checkAlias);
|
|
2416
|
+
if (latest) receiptHost.replaceChildren(api.receiptNode(latest));
|
|
2417
|
+
return control;
|
|
2418
|
+
};
|
|
2419
|
+
const services = connectionLive.services;
|
|
2420
|
+
let keyCode = null;
|
|
2421
|
+
if (payload.targetKind === 'host') {
|
|
2422
|
+
if (payload.checkAgent && api) {
|
|
2423
|
+
actions.append(check(null, {}));
|
|
2424
|
+
stateLine.textContent = receiptHost.childElementCount ? `The last check of ${name} is below.` : `${name} has not been checked yet. Check it works runs a read-only check on this computer.`;
|
|
2425
|
+
} else {
|
|
2426
|
+
stateLine.textContent = `FloLess can’t check ${name} from here. Open Discover Local Tools to connect it.`;
|
|
2427
|
+
}
|
|
2428
|
+
} else if (!api || (!services && connectionLive.error)) {
|
|
2429
|
+
stateLine.textContent = connectionLive.error || 'FloLess couldn’t load what is connected. Try again.';
|
|
2430
|
+
const retry = connectionButton('Try again', 'shell.chat-connection-retry', target, name);
|
|
2431
|
+
retry.dataset.tip = 'Reads again what is connected to FloLess.';
|
|
2432
|
+
retry.addEventListener('click', () => refreshConnectionLive(0));
|
|
2433
|
+
if (api) actions.append(retry);
|
|
2434
|
+
} else if (!services) {
|
|
2435
|
+
stateLine.textContent = 'Checking what is connected…';
|
|
2436
|
+
} else if (!service) {
|
|
2437
|
+
stateLine.textContent = `FloLess can’t find ${name} in its connections right now. Open Integrations to see what is connected.`;
|
|
2438
|
+
actions.append(integrations('Open Integrations', 'shell.chat-connection-connect', `Opens Integrations at ${name}.`, true));
|
|
2439
|
+
} else if (service.statusUnknown) {
|
|
2440
|
+
stateLine.textContent = `FloLess couldn’t read whether the key for ${name} is saved. Open Integrations to see it.`;
|
|
2441
|
+
actions.append(integrations('Open Integrations', 'shell.chat-connection-connect', `Opens Integrations at ${name}.`, true));
|
|
2442
|
+
} else if (service.kind === 'key' && !service.connected) {
|
|
2443
|
+
// A key is added in a terminal, never typed into FloLess: the command, and a button that copies it.
|
|
2444
|
+
const command = `aware credential put ${service.id}`;
|
|
2445
|
+
stateLine.textContent = `${name} needs a key from the service. Run this in a terminal, then paste your key when it asks:`;
|
|
2446
|
+
keyCode = document.createElement('code'); keyCode.className = 'conn-code ai-chat-connection-command';
|
|
2447
|
+
keyCode.textContent = command;
|
|
2448
|
+
const copyLabel = 'Copy the command';
|
|
2449
|
+
const copy = connectionButton(copyLabel, 'shell.chat-connection-copy-key', target, name, 'ai-chat-filter-apply');
|
|
2450
|
+
copy.setAttribute('aria-label', `Copy the command that adds your key for ${name}`);
|
|
2451
|
+
copy.dataset.tip = 'Copies the terminal command. FloLess never sees the key you paste.';
|
|
2452
|
+
copy.addEventListener('click', async () => {
|
|
2453
|
+
try {
|
|
2454
|
+
await navigator.clipboard.writeText(command);
|
|
2455
|
+
say('Command copied. Run it in a terminal, then paste your key when it asks.');
|
|
2456
|
+
} catch { say('FloLess couldn’t copy the command. Select it and copy it yourself.'); }
|
|
2457
|
+
});
|
|
2458
|
+
actions.append(copy);
|
|
2459
|
+
} else if (!services.choicesUnreadable && service.choice?.source === 'native') {
|
|
2460
|
+
// Their own Claude/Codex connection is the choice, whatever FloLess's own accounts look like (#1900 review): the
|
|
2461
|
+
// way out is Change account, never Connect or Reconnect of an account FloLess was told not to use.
|
|
2462
|
+
stateLine.textContent = `FloLess uses your Claude or Codex connection for ${name}. FloLess can’t see or check that connection.`;
|
|
2463
|
+
actions.append(integrations('Change account', 'shell.chat-connection-change-account', `Opens Integrations at ${name}, where you choose the account FloLess uses.`));
|
|
2464
|
+
} else if (api.signInExpired(service)) {
|
|
2465
|
+
stateLine.textContent = `The sign-in for ${name} expired. Reconnect it in Integrations, then check it works.`;
|
|
2466
|
+
actions.append(integrations('Reconnect', 'shell.chat-connection-connect', `Opens Integrations at ${name} so you can sign in again.`, true));
|
|
2467
|
+
} else if (!service.connected) {
|
|
2468
|
+
stateLine.textContent = `${name} is not connected yet. Connect opens Integrations, where you sign in.`;
|
|
2469
|
+
actions.append(integrations('Connect', 'shell.chat-connection-connect', `Opens Integrations at ${name} so you can connect it.`, true));
|
|
2470
|
+
} else if (services.choicesUnreadable) {
|
|
2471
|
+
stateLine.textContent = `FloLess couldn’t read which account it uses for ${name}. Open Integrations to choose it again.`;
|
|
2472
|
+
actions.append(integrations('Open Integrations', 'shell.chat-connection-change-account', `Opens Integrations at ${name}.`, true));
|
|
2473
|
+
} else if (service.choice?.source === 'floless') {
|
|
2474
|
+
stateLine.textContent = `FloLess uses ${service.choice.alias ? service.choice.alias : 'the default account'} for ${name}.`;
|
|
2475
|
+
// The card checks the CHOSEN account at the choice it was painted on: the server refuses a card that is out of date.
|
|
2476
|
+
if (payload.checkAgent && alias !== undefined) {
|
|
2477
|
+
actions.append(check(alias, { integration: target, expectedChoiceRevision: service.choice.revision }));
|
|
2478
|
+
}
|
|
2479
|
+
actions.append(integrations('Change account', 'shell.chat-connection-change-account', `Opens Integrations at ${name}, where you choose the account FloLess uses.`));
|
|
2480
|
+
} else {
|
|
2481
|
+
const count = (service.accounts || []).length;
|
|
2482
|
+
stateLine.textContent = `${count === 1 ? 'An account is' : `${count} accounts are`} already connected for ${name}, but FloLess hasn’t been told which one to use. Integrations is where you choose it.`;
|
|
2483
|
+
actions.append(
|
|
2484
|
+
integrations('Use existing connection', 'shell.chat-connection-use-existing', `Opens Integrations at ${name}, where you choose the account FloLess uses.`, true),
|
|
2485
|
+
integrations('Set up a separate connection', 'shell.chat-connection-set-up-separate', `Opens Integrations at ${name}, where you can connect another account for FloLess.`),
|
|
2486
|
+
);
|
|
2487
|
+
}
|
|
2488
|
+
const notNow = connectionButton('Not now', 'shell.chat-connection-not-now', target, name);
|
|
2489
|
+
notNow.setAttribute('aria-label', `Not now: don’t connect ${name}`);
|
|
2490
|
+
notNow.dataset.tip = `Sets this suggestion aside. The AI won’t suggest ${name} again in this chat unless you choose Show again.`;
|
|
2491
|
+
notNow.disabled = entry.busy;
|
|
2492
|
+
notNow.addEventListener('click', () => { void setConnectionDismissed(event, true); });
|
|
2493
|
+
actions.append(notNow);
|
|
2494
|
+
card.append(stateLine, ...(keyCode ? [keyCode] : []), actions, confirmHost, receiptHost, said, error);
|
|
2495
|
+
return card;
|
|
2496
|
+
}
|
|
2497
|
+
|
|
2498
|
+
async function setConnectionDismissed(event, dismiss) {
|
|
2499
|
+
const payload = event.payload || {};
|
|
2500
|
+
const proposalId = String(payload.proposalId || '');
|
|
2501
|
+
const entry = connectionCards.get(proposalId);
|
|
2502
|
+
const snapshot = captureChat();
|
|
2503
|
+
if (!snapshot || !entry || entry.busy || !proposalId) return;
|
|
2504
|
+
const name = String(payload.name || payload.target || 'this');
|
|
2505
|
+
entry.busy = true; entry.error = '';
|
|
2506
|
+
repaintConnectionCards();
|
|
2507
|
+
try {
|
|
2508
|
+
const result = await request(`/api/chat/conversations/${encodeURIComponent(snapshot.chatId)}/connection-proposals/${encodeURIComponent(proposalId)}/${dismiss ? 'dismiss' : 'undismiss'}`, {
|
|
2509
|
+
method: 'POST', body: JSON.stringify({ owner: snapshot.scope.owner }),
|
|
2510
|
+
});
|
|
2511
|
+
if (!sameChat(snapshot)) return;
|
|
2512
|
+
if (result?.chat?.chatId === snapshot.chatId) state.chat = { ...state.chat, connectionDismissals: result.chat.connectionDismissals ?? [] };
|
|
2513
|
+
if (result?.event && !state.events.some((known) => known.eventId === result.event.eventId)) state.events.push(result.event);
|
|
2514
|
+
announce(dismiss ? `Not now. The AI won’t suggest connecting ${name} again in this chat unless you choose Show again.`
|
|
2515
|
+
: `The suggestion to connect ${name} is back.`);
|
|
2516
|
+
} catch (error) {
|
|
2517
|
+
if (sameChat(snapshot)) entry.error = errorMessage(error);
|
|
2518
|
+
} finally {
|
|
2519
|
+
entry.busy = false;
|
|
2520
|
+
if (sameChat(snapshot)) {
|
|
2521
|
+
repaintConnectionCards();
|
|
2522
|
+
// The pressed button is gone with the card's old face: keep the keyboard on this card.
|
|
2523
|
+
const card = ui.feed?.querySelector(`.ai-chat-connection-card[data-proposal-id="${CSS.escape(proposalId)}"]`);
|
|
2524
|
+
const next = card?.querySelector(entry.error ? 'button' : dismiss ? '[data-command-id^="shell.chat-connection-show-again"]' : '.ai-chat-filter-actions button');
|
|
2525
|
+
next?.focus({ preventScroll: true });
|
|
2526
|
+
}
|
|
2527
|
+
}
|
|
2528
|
+
}
|
|
2529
|
+
|
|
2530
|
+
/** The result of a check the person approved in chat: the same receipt Discover and Integrations show. */
|
|
2531
|
+
function renderConnectionCheck(event) {
|
|
2532
|
+
const payload = event.payload || {};
|
|
2533
|
+
const api = connectionsApi();
|
|
2534
|
+
const name = String(payload.name || payload.agent || 'this tool');
|
|
2535
|
+
const card = document.createElement('section');
|
|
2536
|
+
card.className = 'ai-chat-filter-card ai-chat-connection-card ai-chat-connection-receipt';
|
|
2537
|
+
card.dataset.eventId = event.eventId;
|
|
2538
|
+
card.dataset.eventSequence = String(event.sequence);
|
|
2539
|
+
const head = document.createElement('div'); head.className = 'ai-chat-filter-card-head';
|
|
2540
|
+
const title = document.createElement('strong');
|
|
2541
|
+
title.id = `chat-connection-check-${event.eventId}`;
|
|
2542
|
+
title.textContent = `Connection check · ${name}`;
|
|
2543
|
+
card.setAttribute('aria-labelledby', title.id);
|
|
2544
|
+
head.append(title);
|
|
2545
|
+
card.append(head);
|
|
2546
|
+
const receipt = payload.receipt && typeof payload.receipt === 'object' ? payload.receipt : null;
|
|
2547
|
+
const identity = receipt?.reported?.identity || 'a different account';
|
|
2548
|
+
if (receipt && api) {
|
|
2549
|
+
// The transcript is a record: a check reads "Checked · when", never "Verified". Whether it still holds is shown
|
|
2550
|
+
// live on the suggestion card, Discover and Integrations (#1900 review, owner ruling: history only).
|
|
2551
|
+
const shown = { ...receipt, historical: true };
|
|
2552
|
+
// A changed account gets its own line below, worded for this moment, instead of the receipt's general one.
|
|
2553
|
+
card.append(api.receiptNode(payload.changedTarget ? { ...shown, previousIdentity: null } : shown,
|
|
2554
|
+
payload.ok ? null : (typeof payload.error === 'string' && payload.error) || null));
|
|
2555
|
+
}
|
|
2556
|
+
if (payload.changedTarget) {
|
|
2557
|
+
const changed = document.createElement('p');
|
|
2558
|
+
changed.className = 'ai-chat-filter-note ai-chat-approval-warning';
|
|
2559
|
+
changed.textContent = `The account behind ${name} is now ${identity}, not ${payload.previousIdentity || 'the one checked before'}. Nothing else was read.`;
|
|
2560
|
+
card.append(changed);
|
|
2561
|
+
}
|
|
2562
|
+
if (payload.restarted) {
|
|
2563
|
+
const restarted = document.createElement('p');
|
|
2564
|
+
restarted.className = 'ai-chat-filter-note';
|
|
2565
|
+
restarted.textContent = 'The program was restarted since the last check.';
|
|
2566
|
+
card.append(restarted);
|
|
2567
|
+
}
|
|
2568
|
+
if (!payload.ok && !(receipt && api)) {
|
|
2569
|
+
const failed = document.createElement('p');
|
|
2570
|
+
// A check that was stopped is not a failed one (#1900): its outcome is unknown, said plainly, not in error red.
|
|
2571
|
+
failed.className = payload.stopped === true ? 'ai-chat-filter-note' : 'ai-chat-filter-note ai-chat-connection-error';
|
|
2572
|
+
failed.textContent = (typeof payload.error === 'string' && payload.error) || `The check of ${name} did not succeed. Ask the AI to try again.`;
|
|
2573
|
+
card.append(failed);
|
|
2574
|
+
}
|
|
2575
|
+
return card;
|
|
2576
|
+
}
|
|
2577
|
+
|
|
2578
|
+
/** A check that ran under "Allow checks … for this chat": one line, like a connector's receipt. */
|
|
2579
|
+
function renderConnectionCheckAllowed(event) {
|
|
2580
|
+
const item = document.createElement('div');
|
|
2581
|
+
item.className = 'ai-chat-event connector';
|
|
2582
|
+
item.dataset.eventSequence = String(event.sequence);
|
|
2583
|
+
item.dataset.eventId = event.eventId;
|
|
2584
|
+
const label = document.createElement('strong');
|
|
2585
|
+
label.textContent = 'Allowed for this chat';
|
|
2586
|
+
const name = String(event.payload.connectionCheck?.name || event.payload.connectionCheck?.agent || 'a connection');
|
|
2587
|
+
item.append(label, document.createTextNode(` · checked ${name}`));
|
|
2588
|
+
return item;
|
|
2589
|
+
}
|
|
2590
|
+
|
|
2591
|
+
/** One line for a decided workflow create (#1890 PR 3a): approved, denied, or stopped at FloLess's last check. */
|
|
2592
|
+
function renderCreateReceipt(event) {
|
|
2593
|
+
const item = document.createElement('div');
|
|
2594
|
+
item.className = 'ai-chat-event connector';
|
|
2595
|
+
item.dataset.eventSequence = String(event.sequence);
|
|
2596
|
+
item.dataset.eventId = event.eventId;
|
|
2597
|
+
const create = event.payload.create;
|
|
2598
|
+
const label = document.createElement('strong');
|
|
2599
|
+
const what = `the workflow “${create.name}” ${createWhere(create)}`;
|
|
2600
|
+
if (event.payload.reason) {
|
|
2601
|
+
label.textContent = 'Not created';
|
|
2602
|
+
item.append(label, document.createTextNode(` · ${event.payload.reason}`));
|
|
2603
|
+
} else if (event.payload.decision === 'allow') {
|
|
2604
|
+
label.textContent = 'Approved once';
|
|
2605
|
+
item.append(label, document.createTextNode(` · Create ${what}`));
|
|
2606
|
+
} else {
|
|
2607
|
+
label.textContent = 'Not created';
|
|
2608
|
+
item.append(label, document.createTextNode(` · ${what}`));
|
|
2609
|
+
}
|
|
2610
|
+
return item;
|
|
2611
|
+
}
|
|
2612
|
+
|
|
1936
2613
|
function renderEvent(event) {
|
|
1937
2614
|
if (event.type === 'user-message' && event.payload?.source === 'request' && event.payload?.filterAi) return renderFilterQuestion(event);
|
|
1938
2615
|
if (event.type === 'user-message' && event.payload?.source === 'request') return renderRequestCard(event);
|
|
@@ -1940,10 +2617,20 @@
|
|
|
1940
2617
|
if (event.type === 'user-message') return withFilterNotShared(renderMessage(event, 'user', payloadText(event)), event);
|
|
1941
2618
|
if (event.type === 'filter-proposal') return renderServerProposal(event);
|
|
1942
2619
|
if (event.type === 'filter-proposal-update') return null;
|
|
2620
|
+
// #1900: a connection the AI suggested, the result of a check it asked for, and a check run under "Allow for this chat".
|
|
2621
|
+
if (event.type === 'connection-proposal') return renderConnectionProposal(event);
|
|
2622
|
+
if (event.type === 'connection-proposal-update') return null;
|
|
2623
|
+
if (event.type === 'connection-check') return renderConnectionCheck(event);
|
|
2624
|
+
if (event.type === 'approval-decided' && event.payload?.automatic === true && event.payload?.connectionCheck) return renderConnectionCheckAllowed(event);
|
|
1943
2625
|
if (event.type === 'assistant-message') return renderMessage(event, 'assistant', payloadText(event), Boolean(event.payload?.delta));
|
|
1944
2626
|
// #1907: a connector call that ran under "Allow for this chat" leaves a visible receipt; every other decision is audit only.
|
|
1945
2627
|
if (event.type === 'approval-decided' && event.payload?.automatic === true && event.payload?.connector) return renderConnectorReceipt(event);
|
|
2628
|
+
// #1890 PR 2b: a workspace change that ran under "Allow for this chat", or one FloLess stopped at the last check.
|
|
2629
|
+
if (event.type === 'approval-decided' && event.payload?.change && (event.payload?.automatic === true || event.payload?.reason)) return renderChangeReceipt(event);
|
|
2630
|
+
// #1890 PR 3a: a decided workflow create stays visible as one line, so a reload never shows it as pending.
|
|
2631
|
+
if (event.type === 'approval-decided' && event.payload?.create) return renderCreateReceipt(event);
|
|
1946
2632
|
if (event.type === 'approval-requested' || event.type === 'approval-decided' || event.type === 'state' || event.type === 'followup-status') return null;
|
|
2633
|
+
if (event.type === 'tool' && event.payload?.tool === 'agent' && typeof event.payload?.message === 'string') return renderAgentRunLine(event);
|
|
1947
2634
|
if (event.type === 'tekla-read') return renderTeklaReadEvent(event);
|
|
1948
2635
|
if (event.type === 'height-question') return renderHeightQuestion(event);
|
|
1949
2636
|
if (event.type === 'setup-question') return renderSetupQuestion(event);
|
|
@@ -2048,6 +2735,22 @@
|
|
|
2048
2735
|
const heightEndKey = (row) => `${row.memberId}\u0000${row.end}`;
|
|
2049
2736
|
const heightEndWord = (row) => (row.endWord === 'from' ? 'start' : 'end');
|
|
2050
2737
|
const heightAnswerText = (answer) => (answer?.how === 'typed' ? `You typed ${answer.typed}` : `Confirmed ${answer?.shownAs || ''}`);
|
|
2738
|
+
/*
|
|
2739
|
+
* #1903: a row about a member ALREADY in the model. The server snapshotted that end when the question was
|
|
2740
|
+
* asked; the card says what it held THEN (the model can change before the person answers, and the review
|
|
2741
|
+
* always compares against the model as it is when the read is staged), and that the answer is only
|
|
2742
|
+
* proposed. The number is shown in the question's own units through the shared helper; until that helper
|
|
2743
|
+
* has loaded it reads in millimetres rather than not at all.
|
|
2744
|
+
*/
|
|
2745
|
+
const heightInModelValue = (mm, units) => (displayUnitsModule ? displayUnitsModule.formatElevation(mm, units) : `${Math.round(mm)} mm`);
|
|
2746
|
+
const heightInModelText = (snapshot, units) => {
|
|
2747
|
+
if (!snapshot) return '';
|
|
2748
|
+
if (snapshot.state === 'unknown' || typeof snapshot.value !== 'number') return 'In the model when asked: no height.';
|
|
2749
|
+
const value = heightInModelValue(snapshot.value, units);
|
|
2750
|
+
const tail = snapshot.state === 'assumed' ? ' (placed, not from the drawings)' : snapshot.state === 'answered' ? ' (your earlier answer)' : '';
|
|
2751
|
+
return `In the model when asked: ${value}${tail}.`;
|
|
2752
|
+
};
|
|
2753
|
+
const HEIGHT_PROPOSED_TEXT = 'Proposed in the review; the model changes only if you accept it there.';
|
|
2051
2754
|
// The server's sentence, then what to do next when it names a step (a damaged record says to discard the read).
|
|
2052
2755
|
const heightErrorText = (error, fallback) => {
|
|
2053
2756
|
const next = (error?.recovery || []).map((step) => step && typeof step.action === 'string' ? step.action : '').filter(Boolean);
|
|
@@ -2066,7 +2769,13 @@
|
|
|
2066
2769
|
if (entry.loading) return;
|
|
2067
2770
|
entry.loading = true;
|
|
2068
2771
|
request(`/api/chat/height-questions/${encodeURIComponent(entry.requestId)}/${encodeURIComponent(entry.questionId)}?${new URLSearchParams({ chatId: entry.chatId || '' })}`)
|
|
2069
|
-
.then((result) => {
|
|
2772
|
+
.then((result) => {
|
|
2773
|
+
if (result?.readClosed) { entry.finished = true; entry.view = null; } else entry.view = result.question;
|
|
2774
|
+
entry.loadError = '';
|
|
2775
|
+
// #1903: an existing member's "in the model" height is shown in the question's units, which needs
|
|
2776
|
+
// the shared helper; repaint once it has loaded.
|
|
2777
|
+
if (entry.view?.ends?.some((row) => row.inModel) && !displayUnitsModule) loadDisplayUnitsModule().then(() => repaintHeightCard(entry));
|
|
2778
|
+
})
|
|
2070
2779
|
.catch((error) => {
|
|
2071
2780
|
if (CARD_READ_FINISHED.has(error?.code)) { entry.finished = true; entry.loadError = ''; return; }
|
|
2072
2781
|
entry.loadError = heightErrorText(error, 'FloLess could not load this height question.');
|
|
@@ -2141,7 +2850,12 @@
|
|
|
2141
2850
|
note.textContent = !view
|
|
2142
2851
|
? (entry.finished ? CARD_FINISHED_TEXT : entry.loadError || 'Loading the heights this read is asking about…')
|
|
2143
2852
|
: open
|
|
2144
|
-
?
|
|
2853
|
+
? (rows.some((row) => row.inModel)
|
|
2854
|
+
// #1903: never say "straight into the model" about a member already in it — that answer is proposed.
|
|
2855
|
+
// Neutral about the drawings: an existing member's end may well be drawn, and the person is being
|
|
2856
|
+
// asked whether it still holds (code review).
|
|
2857
|
+
? 'Only you can answer these heights — the AI can’t fill this in. For a new member, what you confirm or type goes straight into the model; for one already in the model, it is proposed in the review.'
|
|
2858
|
+
: 'The drawings don’t settle these heights. Only you can answer — the AI can’t fill this in. What you confirm or type goes straight into the model.')
|
|
2145
2859
|
: 'This read is no longer waiting for an answer.';
|
|
2146
2860
|
card.append(note);
|
|
2147
2861
|
if (!view) {
|
|
@@ -2319,8 +3033,15 @@
|
|
|
2319
3033
|
label.dataset.tip = row.label;
|
|
2320
3034
|
labelLine.append(label);
|
|
2321
3035
|
const meta = document.createElement('div'); meta.className = 'ai-chat-height-meta';
|
|
2322
|
-
|
|
3036
|
+
// #1903: an existing member's PROFILE comes from the model, not from the read's label, so a label that
|
|
3037
|
+
// names the wrong member is visibly at odds with what the id really is.
|
|
3038
|
+
meta.textContent = [row.inModel?.profile, row.memberId, heightEndWord(row)].filter(Boolean).join(' · ');
|
|
2323
3039
|
item.append(labelLine, meta);
|
|
3040
|
+
if (row.inModel) {
|
|
3041
|
+
const inModel = document.createElement('div'); inModel.className = 'ai-chat-height-inmodel';
|
|
3042
|
+
inModel.textContent = `${heightInModelText(row.inModel, entry.view?.units)} ${HEIGHT_PROPOSED_TEXT}`;
|
|
3043
|
+
item.append(inModel);
|
|
3044
|
+
}
|
|
2324
3045
|
|
|
2325
3046
|
if (row.status === 'superseded') {
|
|
2326
3047
|
const gone = document.createElement('div'); gone.className = 'ai-chat-height-answered';
|
|
@@ -2457,7 +3178,21 @@
|
|
|
2457
3178
|
target?.focus({ preventScroll: true });
|
|
2458
3179
|
}
|
|
2459
3180
|
|
|
2460
|
-
|
|
3181
|
+
/*
|
|
3182
|
+
* The words the person sees for a card in "Tell the read" (#1911): its place among the cards of its own kind
|
|
3183
|
+
* actually shown in this conversation, never the ledger's running record number (`view.n`, which also counts
|
|
3184
|
+
* answers and so jumps from 1 to 13). The read does not need the number: it reads the ledger, never the
|
|
3185
|
+
* prose (#1882 plan), so the visible text carries no id at all.
|
|
3186
|
+
*/
|
|
3187
|
+
const CARD_ORDINALS = ['first', 'second', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth', 'ninth', 'tenth'];
|
|
3188
|
+
function cardPlace(entry, attribute, noun) {
|
|
3189
|
+
const keys = [...(ui.feed?.querySelectorAll(`[${attribute}]`) || [])].map((node) => node.getAttribute(attribute));
|
|
3190
|
+
const at = keys.indexOf(entry.key);
|
|
3191
|
+
if (keys.length < 2 || at < 0) return `the ${noun}`;
|
|
3192
|
+
return at < CARD_ORDINALS.length ? `the ${CARD_ORDINALS[at]} ${noun}` : `${noun} ${at + 1} of ${keys.length}`;
|
|
3193
|
+
}
|
|
3194
|
+
const heightTellText = (entry) => `I've answered ${cardPlace(entry, 'data-height-question', 'height card')}.`;
|
|
3195
|
+
const setupTellText = (entry) => `I've answered ${cardPlace(entry, 'data-setup-question', 'read setup card')}.`;
|
|
2461
3196
|
|
|
2462
3197
|
/*
|
|
2463
3198
|
* TELL THE READ puts one short message in the composer and moves focus to Send; the PERSON sends it
|
|
@@ -2911,7 +3646,7 @@
|
|
|
2911
3646
|
: 'All answered. Press Tell the read, then Send: the read looks at what you sent and asks you to confirm its reading here.';
|
|
2912
3647
|
card.append(done);
|
|
2913
3648
|
const tell = heightActionButton('Tell the read', `shell.chat-setup-tell-read#${entry.questionId}`, questionLabel, 'ai-chat-filter-apply', null);
|
|
2914
|
-
tell.addEventListener('click', () => tellReadAnswered(entry,
|
|
3649
|
+
tell.addEventListener('click', () => tellReadAnswered(entry, setupTellText(entry), repaintSetupCard));
|
|
2915
3650
|
actions.append(tell);
|
|
2916
3651
|
}
|
|
2917
3652
|
actions.hidden = !actions.childNodes.length;
|
|
@@ -3297,7 +4032,7 @@
|
|
|
3297
4032
|
fact('Library', payload.library);
|
|
3298
4033
|
fact('Checked', checkedTime(payload.checkedAt));
|
|
3299
4034
|
card.append(facts);
|
|
3300
|
-
const note = document.createElement('p'); note.textContent = 'The generated
|
|
4035
|
+
const note = document.createElement('p'); note.textContent = 'The generated tool\'s commands remain unverified.';
|
|
3301
4036
|
card.append(note);
|
|
3302
4037
|
} else {
|
|
3303
4038
|
const message = document.createElement('p');
|
|
@@ -3745,6 +4480,8 @@
|
|
|
3745
4480
|
announceLiveResponseOnce();
|
|
3746
4481
|
const focusedCommand = ui.feed.contains(document.activeElement)
|
|
3747
4482
|
? document.activeElement?.dataset?.commandId : null;
|
|
4483
|
+
// A card painted once and reused across repaints (a connection suggestion, #1900) keeps its own control focused.
|
|
4484
|
+
const focusedNode = ui.feed.contains(document.activeElement) ? document.activeElement : null;
|
|
3748
4485
|
const nearBottom = ui.feed.scrollHeight - ui.feed.scrollTop - ui.feed.clientHeight < 56;
|
|
3749
4486
|
const scrollTop = ui.feed.scrollTop;
|
|
3750
4487
|
ui.feed.replaceChildren();
|
|
@@ -3777,8 +4514,26 @@
|
|
|
3777
4514
|
}
|
|
3778
4515
|
continue;
|
|
3779
4516
|
}
|
|
4517
|
+
// Something FloLess itself refused during the answer (a file change it declined, a connector it turned away,
|
|
4518
|
+
// #1890 PR 2b / #1907), written for the person: held and shown under the answer, like the receipts below.
|
|
4519
|
+
if (event.type === 'tool' && event.payload?.plain === true && event.payload?.tool !== 'agent'
|
|
4520
|
+
&& typeof event.payload?.message === 'string' && event.payload.message) {
|
|
4521
|
+
links.push({ turnId: event.turnId, node: renderPlainNotice(event) });
|
|
4522
|
+
continue;
|
|
4523
|
+
}
|
|
3780
4524
|
// Provider tools commonly split one answer into before/after chunks. They are not prose,
|
|
3781
4525
|
// so keep collecting same-turn deltas across them instead of rendering abandoned fragments.
|
|
4526
|
+
// #1900: a connection suggestion's Not now / Show again only changes its card, never a reason to split the answer;
|
|
4527
|
+
// the suggestion and a check's result are receipts like the ones below, held under the answer they were written during.
|
|
4528
|
+
// #2007: an agent run's first line (who started it, its scope) is a tool event too, but it is the conversation's
|
|
4529
|
+
// opening line, not a tool: shown where it was written, before the instructions.
|
|
4530
|
+
if (event.type === 'tool' && event.payload?.tool === 'agent' && typeof event.payload?.message === 'string') {
|
|
4531
|
+
flushAssistant();
|
|
4532
|
+
ui.feed.append(renderAgentRunLine(event));
|
|
4533
|
+
continue;
|
|
4534
|
+
}
|
|
4535
|
+
if (event.type === 'connection-proposal-update') continue;
|
|
4536
|
+
if (event.type === 'connection-proposal' || event.type === 'connection-check') { links.push({ turnId: event.turnId, node: renderEvent(event) }); continue; }
|
|
3782
4537
|
if (['tool', 'usage', 'knowledge-citation', 'attachment', 'compaction', 'state'].includes(event.type)) continue;
|
|
3783
4538
|
// FloLess's own receipts (object links #1653; evidence looks and suggestion cards #1859) are written mid-answer while a tool runs:
|
|
3784
4539
|
// held and shown under the answer, so they never cut one answer into fragments.
|
|
@@ -3794,7 +4549,9 @@
|
|
|
3794
4549
|
// never looks like a failed response. Recovery deliberately has no live indicator.
|
|
3795
4550
|
if (turnIsVisiblyActive()) ui.feed.append(renderLiveStatus());
|
|
3796
4551
|
}
|
|
3797
|
-
|
|
4552
|
+
if (focusedNode?.isConnected && ui.feed.contains(focusedNode)) {
|
|
4553
|
+
if (document.activeElement !== focusedNode) focusedNode.focus({ preventScroll: true });
|
|
4554
|
+
} else restoreFeedFocus(focusedCommand);
|
|
3798
4555
|
// Removing a focused control makes the browser lay out the half-built feed, which clamps its scroll near the top.
|
|
3799
4556
|
// Scrolled up, the reader stays where they were.
|
|
3800
4557
|
if (!nearBottom) ui.feed.scrollTop = scrollTop;
|
|
@@ -3898,10 +4655,16 @@
|
|
|
3898
4655
|
// Keep the same buttons during polling so keyboard focus and pointer clicks survive. A Tekla card
|
|
3899
4656
|
// also carries the permission view it offers "Allow for this chat" on, so a change repaints it.
|
|
3900
4657
|
const teklaBinding = teklaAllowableApproval(approval) ? currentTeklaBinding(state.chat) : null;
|
|
4658
|
+
// #1890 PR 2b: a workspace conversation's file change, with the projects/workflows it touches.
|
|
4659
|
+
const change = approval.change && typeof approval.change === 'object' ? approval.change : null;
|
|
3901
4660
|
// #1907: a call to one of the person's connectors FloLess could identify may be allowed for the whole chat.
|
|
3902
4661
|
const connector = approval.connector?.verified ? approval.connector : null;
|
|
3903
|
-
|
|
3904
|
-
|
|
4662
|
+
// #1900: a connection check the AI asked for; "Allow for this chat" only when the server says it may be.
|
|
4663
|
+
const connectionCheck = approval.connectionCheck && typeof approval.connectionCheck === 'object' ? approval.connectionCheck : null;
|
|
4664
|
+
const allowanceRevision = connectionCheck ? String(state.chat?.integrationReadAllowance?.revision ?? 0)
|
|
4665
|
+
: change ? String(state.chat?.changeAllowance?.revision ?? 0)
|
|
4666
|
+
: teklaBinding ? String(teklaAllowanceRevision(teklaBinding))
|
|
4667
|
+
: connector ? String(state.chat?.connectorAllowance?.revision ?? 0) : '';
|
|
3905
4668
|
if (existing?.dataset.approvalId === approval.approvalId && (existing.dataset.allowanceRevision || '') === allowanceRevision) return;
|
|
3906
4669
|
// A permission change repaints the same approval: keep keyboard focus on the same control.
|
|
3907
4670
|
const refocus = existing?.dataset.approvalId === approval.approvalId && existing.contains(document.activeElement)
|
|
@@ -3909,14 +4672,57 @@
|
|
|
3909
4672
|
existing?.remove();
|
|
3910
4673
|
const card = document.createElement('section'); card.className = 'ai-chat-approval';
|
|
3911
4674
|
card.dataset.approvalId = approval.approvalId;
|
|
3912
|
-
if (teklaBinding || connector) card.dataset.allowanceRevision = allowanceRevision;
|
|
4675
|
+
if (teklaBinding || connector || change || connectionCheck) card.dataset.allowanceRevision = allowanceRevision;
|
|
4676
|
+
// #1890 PR 3a: the AI asking to create a workflow, with where it would go.
|
|
4677
|
+
const create = approval.create && typeof approval.create === 'object' ? approval.create : null;
|
|
4678
|
+
if (approval.scopeAdd) {
|
|
4679
|
+
const scope = approval.scopeAdd;
|
|
4680
|
+
card.classList.add('ai-chat-scope-add');
|
|
4681
|
+
card.setAttribute('role', 'group');
|
|
4682
|
+
const heading = document.createElement('strong');
|
|
4683
|
+
heading.id = `chat-scope-add-heading-${approval.approvalId}`;
|
|
4684
|
+
heading.textContent = `Let this conversation also work on ${scope.target.kind} “${scope.label}”?`;
|
|
4685
|
+
card.setAttribute('aria-labelledby', heading.id);
|
|
4686
|
+
const copy = document.createElement('p');
|
|
4687
|
+
const readOnly = state.chat?.settings?.permissionProfile === 'read-only';
|
|
4688
|
+
const writeProfile = state.chat?.owner?.kind === 'workspace' ? 'Make changes (asks first)' : 'Working folder write';
|
|
4689
|
+
copy.textContent = readOnly
|
|
4690
|
+
? 'The AI’s file tools cannot change files while Read only is on. Commands keep their own approvals and may authorize file changes.'
|
|
4691
|
+
+ (scope.allowsFileChanges ? ` If you choose ${writeProfile}, file changes here will also be allowed without asking.` : '')
|
|
4692
|
+
: scope.allowsFileChanges ? 'File changes here will also be allowed without asking. Commands and tools keep their own approvals.'
|
|
4693
|
+
: 'Adds this folder to the conversation. Your current file approval setting stays unchanged.';
|
|
4694
|
+
const actions = document.createElement('div'); actions.className = 'ai-chat-approval-actions';
|
|
4695
|
+
const deny = button('Deny', 'shell.chat-approval-deny');
|
|
4696
|
+
const allow = button(scope.allowsFileChanges ? readOnly ? 'Add scope for later file changes' : 'Add scope and allow file changes' : 'Approve once', 'shell.chat-scope-add-approve', 'allow');
|
|
4697
|
+
deny.addEventListener('click', () => decideApproval('deny'));
|
|
4698
|
+
allow.addEventListener('click', () => decideApproval('allow'));
|
|
4699
|
+
actions.append(deny, allow); card.append(heading, copy, actions);
|
|
4700
|
+
ui.approvalTray.append(card);
|
|
4701
|
+
if (refocus) [...card.querySelectorAll('button')].find((node) => node.dataset.commandId === refocus)?.focus();
|
|
4702
|
+
ui.approvalTray.scrollTop = ui.approvalTray.scrollHeight;
|
|
4703
|
+
return;
|
|
4704
|
+
}
|
|
4705
|
+
if (create) {
|
|
4706
|
+
paintCreateCard(card, approval, create);
|
|
4707
|
+
ui.approvalTray.append(card);
|
|
4708
|
+
if (refocus) [...card.querySelectorAll('button')].find((node) => node.dataset.commandId === refocus)?.focus();
|
|
4709
|
+
ui.approvalTray.scrollTop = ui.approvalTray.scrollHeight;
|
|
4710
|
+
return;
|
|
4711
|
+
}
|
|
4712
|
+
if (change) {
|
|
4713
|
+
paintChangeCard(card, approval, change, Number(allowanceRevision));
|
|
4714
|
+
ui.approvalTray.append(card);
|
|
4715
|
+
if (refocus) [...card.querySelectorAll('button')].find((node) => node.dataset.commandId === refocus)?.focus();
|
|
4716
|
+
ui.approvalTray.scrollTop = ui.approvalTray.scrollHeight;
|
|
4717
|
+
return;
|
|
4718
|
+
}
|
|
3913
4719
|
const heading = document.createElement('strong'); heading.textContent = 'Approval needed';
|
|
3914
4720
|
const copy = document.createElement('p'); copy.textContent = approval.summary;
|
|
3915
4721
|
const actions = document.createElement('div'); actions.className = 'ai-chat-approval-actions';
|
|
3916
4722
|
const deny = button('Deny', 'shell.chat-approval-deny');
|
|
3917
4723
|
const allow = button('Approve once', 'shell.chat-approval-allow', 'allow');
|
|
3918
4724
|
// A Tekla read is never covered by a request-wide grant; it may instead be allowed for the whole chat (below).
|
|
3919
|
-
const explicitOnly = approvalIsExplicitOnly(approval);
|
|
4725
|
+
const explicitOnly = approvalIsExplicitOnly(approval) || Boolean(connectionCheck);
|
|
3920
4726
|
const allowRequest = explicitOnly ? null : button('Approve for this request', 'shell.chat-approval-request', 'allow');
|
|
3921
4727
|
const scope = document.createElement('span');
|
|
3922
4728
|
scope.className = 'sr-only';
|
|
@@ -3929,6 +4735,14 @@
|
|
|
3929
4735
|
allowRequest.setAttribute('aria-describedby', scope.id);
|
|
3930
4736
|
allowRequest.addEventListener('click', () => decideApproval('allow-request'));
|
|
3931
4737
|
actions.append(deny, allow, allowRequest); card.append(heading, copy, actions, scope);
|
|
4738
|
+
} else if (connectionCheck) {
|
|
4739
|
+
paintConnectionCheckApproval(card, approval, connectionCheck, { heading, copy, actions, deny, allow }, Number(allowanceRevision));
|
|
4740
|
+
ui.approvalTray.append(card);
|
|
4741
|
+
if (refocus) [...card.querySelectorAll('button')].find((node) => node.dataset.commandId === refocus)?.focus();
|
|
4742
|
+
// A new question: Deny is the safe default, unless the person is typing a message.
|
|
4743
|
+
else if (existing?.dataset.approvalId !== approval.approvalId && !(document.activeElement === ui.input && ui.input.value)) deny.focus({ preventScroll: true });
|
|
4744
|
+
ui.approvalTray.scrollTop = ui.approvalTray.scrollHeight;
|
|
4745
|
+
return;
|
|
3932
4746
|
} else if (connector) {
|
|
3933
4747
|
card.dataset.explicitOnly = 'true';
|
|
3934
4748
|
// The warning is the part that decides it: on its own line, not at the end of the question.
|
|
@@ -3972,6 +4786,253 @@
|
|
|
3972
4786
|
ui.approvalTray.scrollTop = ui.approvalTray.scrollHeight;
|
|
3973
4787
|
}
|
|
3974
4788
|
|
|
4789
|
+
/**
|
|
4790
|
+
* #1900 — the card for a connection check the AI asked for. The server's summary is the whole question; the two
|
|
4791
|
+
* things that decide it (a tool FloLess has not reviewed, a key sent to an address) are pulled out onto their own
|
|
4792
|
+
* lines. Never "Approve for this request": each check is approved once, or allowed for this chat when the server
|
|
4793
|
+
* says that is safe (reviewed, no custom key, an identified account, a pinned tool).
|
|
4794
|
+
*/
|
|
4795
|
+
const CONNECTION_UNREVIEWED_SENTENCE = 'This check comes from a tool FloLess has not reviewed.';
|
|
4796
|
+
|
|
4797
|
+
function paintConnectionCheckApproval(card, approval, check, parts, allowanceRevision) {
|
|
4798
|
+
const { heading, copy, actions, deny, allow } = parts;
|
|
4799
|
+
card.dataset.explicitOnly = 'true';
|
|
4800
|
+
card.classList.add('ai-chat-connection-approval');
|
|
4801
|
+
const name = String(check.name || check.agent || 'this tool');
|
|
4802
|
+
const keySentence = check.sendsCustomKey && check.origin ? `Your ${check.credentialHandle} key will be sent to ${check.origin}.` : '';
|
|
4803
|
+
copy.textContent = String(approval.summary || `Check ${name}.`)
|
|
4804
|
+
.replace(CONNECTION_UNREVIEWED_SENTENCE, '').replace(keySentence || '\u0000', '').replace(/\s{2,}/g, ' ').trim();
|
|
4805
|
+
const extra = [];
|
|
4806
|
+
if (check.reviewed === false) {
|
|
4807
|
+
const badge = document.createElement('span');
|
|
4808
|
+
badge.className = 'local-discovery-found conn-chip is-chat-warning ai-chat-connection-badge';
|
|
4809
|
+
badge.textContent = 'Not reviewed';
|
|
4810
|
+
heading.append(' ', badge);
|
|
4811
|
+
const warning = document.createElement('p');
|
|
4812
|
+
warning.className = 'ai-chat-approval-warning';
|
|
4813
|
+
warning.textContent = 'FloLess has not reviewed the tool this check comes from, so it can’t confirm the check only reads.';
|
|
4814
|
+
extra.push(warning);
|
|
4815
|
+
}
|
|
4816
|
+
if (check.sendsCustomKey) {
|
|
4817
|
+
const warning = document.createElement('p');
|
|
4818
|
+
warning.className = 'ai-chat-approval-warning';
|
|
4819
|
+
const handle = check.credentialHandle ? `${check.credentialHandle} ` : '';
|
|
4820
|
+
if (check.origin) {
|
|
4821
|
+
const address = document.createElement('code'); address.className = 'conn-code'; address.textContent = check.origin;
|
|
4822
|
+
warning.append(`Your ${handle}key will be sent to `, address, '. Only approve if you trust that address.');
|
|
4823
|
+
} else warning.textContent = `Your ${handle}key will be sent to an address this tool chose. Only approve if you trust it.`;
|
|
4824
|
+
extra.push(warning);
|
|
4825
|
+
}
|
|
4826
|
+
// Deny and Approve once already answer through paintApproval's own listeners.
|
|
4827
|
+
actions.append(deny, allow);
|
|
4828
|
+
const nodes = [heading, copy, ...extra, actions];
|
|
4829
|
+
if (check.chatAllowable === true) {
|
|
4830
|
+
const label = check.kind === 'host' ? `Allow checks of ${name} for this chat` : `Allow checks of ${name} with this account for this chat`;
|
|
4831
|
+
const key = `${check.agent}${check.alias ? `.${check.alias}` : ''}`;
|
|
4832
|
+
const allowChat = button(label, `shell.chat-connection-check-allow-chat#${key}`, 'allow');
|
|
4833
|
+
allowChat.dataset.commandInstanceLabel = name;
|
|
4834
|
+
const help = document.createElement('span');
|
|
4835
|
+
help.className = 'sr-only';
|
|
4836
|
+
help.id = `chat-approval-check-scope-help-${approval.approvalId}`;
|
|
4837
|
+
help.textContent = `Let Chat check ${name}${check.kind === 'host' ? '' : ' with this account'} whenever it asks in this conversation, without asking you each time. Each check is shown in the chat. Revoke it above the message box.`;
|
|
4838
|
+
allowChat.dataset.tip = help.textContent;
|
|
4839
|
+
allowChat.setAttribute('aria-describedby', help.id);
|
|
4840
|
+
allowChat.addEventListener('click', () => decideApproval('allow-chat', allowanceRevision));
|
|
4841
|
+
actions.append(allowChat);
|
|
4842
|
+
nodes.push(help);
|
|
4843
|
+
}
|
|
4844
|
+
card.append(...nodes);
|
|
4845
|
+
}
|
|
4846
|
+
|
|
4847
|
+
// #1890 PR 2b — why a workspace change can only be dismissed. Mirrors the server's reasons in plain words.
|
|
4848
|
+
const CHANGE_REFUSED_COPY = {
|
|
4849
|
+
'outside-workspace': 'This file is outside your FloLess workspace folder, so nothing was changed. Ask the AI to keep the change inside a project or workflow.',
|
|
4850
|
+
'conversation-records': 'This would change FloLess’s own conversation records, which the AI never changes, so nothing was changed. Ask the AI to put the change in a project or workflow.',
|
|
4851
|
+
'not-in-project': 'FloLess can’t tell which project or workflow this file belongs to, so nothing was changed. Ask the AI to save it in a project or workflow folder instead.',
|
|
4852
|
+
'unreadable-path': 'FloLess couldn’t confirm where this file really is, because the path goes through a folder link, so nothing was changed. Ask the AI to use the project’s own folder.',
|
|
4853
|
+
'ambiguous-path': 'FloLess cannot confirm how the provider expands this path, so nothing was changed. Use an absolute file path in the intended project or workflow, then retry.',
|
|
4854
|
+
'provider-settings': 'FloLess doesn’t let the AI change its own settings files, so nothing was changed. Ask it to make the change somewhere else.',
|
|
4855
|
+
'too-many': 'This change touches too many files to review at once, so nothing was changed. Ask the AI to make it in smaller steps.',
|
|
4856
|
+
};
|
|
4857
|
+
const CHANGE_PATHS_SHOWN = 5;
|
|
4858
|
+
|
|
4859
|
+
function changeFileCount(change) {
|
|
4860
|
+
return (change.owners || []).reduce((sum, owner) => sum + (owner.paths?.length || 0), 0);
|
|
4861
|
+
}
|
|
4862
|
+
|
|
4863
|
+
function changeNames(change) {
|
|
4864
|
+
const names = (change.owners || []).map((owner) => owner.label);
|
|
4865
|
+
return names.length <= 1 ? (names[0] || 'this project') : `${names.slice(0, -1).join(', ')} and ${names.at(-1)}`;
|
|
4866
|
+
}
|
|
4867
|
+
|
|
4868
|
+
/** The card for a workspace conversation's file change: where it lands, then Deny / Approve once / Allow for this chat. */
|
|
4869
|
+
function paintChangeCard(card, approval, change, allowanceRevision) {
|
|
4870
|
+
card.dataset.explicitOnly = 'true';
|
|
4871
|
+
card.classList.add('ai-chat-change');
|
|
4872
|
+
card.setAttribute('role', 'group');
|
|
4873
|
+
const id = approval.approvalId;
|
|
4874
|
+
const denyOnly = Boolean(change.refused || change.busy);
|
|
4875
|
+
const heading = document.createElement('strong');
|
|
4876
|
+
heading.id = `chat-change-heading-${id}`;
|
|
4877
|
+
heading.textContent = denyOnly ? 'Can’t change this' : 'Approval needed';
|
|
4878
|
+
card.setAttribute('aria-labelledby', heading.id);
|
|
4879
|
+
const provider = providerLabels[state.chat?.provider] || 'The AI';
|
|
4880
|
+
const files = changeFileCount(change);
|
|
4881
|
+
const copy = document.createElement('p');
|
|
4882
|
+
copy.id = `chat-change-copy-${id}`;
|
|
4883
|
+
copy.textContent = files === 1 ? `${provider} wants to change a file in your workspace.`
|
|
4884
|
+
: files > 1 ? `${provider} wants to change these ${files} files in your workspace.` : `${provider} wants to change files in your workspace.`;
|
|
4885
|
+
card.setAttribute('aria-describedby', copy.id);
|
|
4886
|
+
const actions = document.createElement('div'); actions.className = 'ai-chat-approval-actions';
|
|
4887
|
+
if (denyOnly) {
|
|
4888
|
+
// Nothing is waiting for approval: one way out, and a plain reason why.
|
|
4889
|
+
card.setAttribute('role', 'status');
|
|
4890
|
+
const reason = document.createElement('p');
|
|
4891
|
+
reason.className = 'ai-chat-change-reason';
|
|
4892
|
+
reason.textContent = change.refused
|
|
4893
|
+
? (CHANGE_REFUSED_COPY[change.refused] || CHANGE_REFUSED_COPY['not-in-project'])
|
|
4894
|
+
: change.busy?.chatTitle
|
|
4895
|
+
? `${changeNames(change)} ${change.owners.length > 1 ? 'are' : 'is'} being changed by another conversation (“${change.busy.chatTitle}”), so nothing was changed here. Ask again when it’s finished.`
|
|
4896
|
+
: `${changeNames(change)} ${change.owners.length > 1 ? 'are' : 'is'} being changed by other work right now, so nothing was changed here. Ask again when it’s finished.`;
|
|
4897
|
+
const dismiss = button('Dismiss', 'shell.chat-approval-deny');
|
|
4898
|
+
dismiss.addEventListener('click', () => decideApproval('deny'));
|
|
4899
|
+
actions.append(dismiss);
|
|
4900
|
+
card.append(heading, ...(change.owners?.length ? [copy, changeOwnerList(change)] : []), reason, actions);
|
|
4901
|
+
return;
|
|
4902
|
+
}
|
|
4903
|
+
const deny = button('Deny', 'shell.chat-approval-deny');
|
|
4904
|
+
const allow = button('Approve once', 'shell.chat-approval-allow', 'allow');
|
|
4905
|
+
deny.addEventListener('click', () => decideApproval('deny'));
|
|
4906
|
+
allow.addEventListener('click', () => decideApproval('allow'));
|
|
4907
|
+
actions.append(deny, allow);
|
|
4908
|
+
if (change.owners?.length) {
|
|
4909
|
+
const label = 'Allow file changes for this chat';
|
|
4910
|
+
const key = change.owners.map((owner) => owner.key).join('+');
|
|
4911
|
+
const allowChat = button(label, `shell.chat-change-allow-chat#${key}`, 'allow');
|
|
4912
|
+
allowChat.dataset.commandInstanceLabel = changeNames(change);
|
|
4913
|
+
const help = document.createElement('span');
|
|
4914
|
+
help.className = 'ai-chat-change-scope-help';
|
|
4915
|
+
help.id = `chat-change-scope-help-${id}`;
|
|
4916
|
+
help.textContent = 'Allows file changes in this conversation’s scope, including folders you add later, without asking you each time. Commands and tools still ask. Your home folder keeps its current permission setting. Revoke it above the message box.';
|
|
4917
|
+
allowChat.dataset.tip = help.textContent;
|
|
4918
|
+
allowChat.setAttribute('aria-describedby', help.id);
|
|
4919
|
+
allowChat.addEventListener('click', () => decideApproval('allow-chat', allowanceRevision));
|
|
4920
|
+
actions.append(allowChat);
|
|
4921
|
+
card.append(heading, copy, changeOwnerList(change), actions, help);
|
|
4922
|
+
return;
|
|
4923
|
+
}
|
|
4924
|
+
card.append(heading, copy, actions);
|
|
4925
|
+
}
|
|
4926
|
+
|
|
4927
|
+
/** Why a workflow the AI asked to create can only be dismissed (#1890 PR 3a); the server says the same to the AI. */
|
|
4928
|
+
const CREATE_REFUSED_COPY = {
|
|
4929
|
+
'bad-name': 'A workflow name needs 1 to 120 characters you can see, so nothing was created. Ask the AI for a shorter or plainer name.',
|
|
4930
|
+
'project-missing': 'That project isn’t in your workspace any more (it may have been archived or renamed), so nothing was created. Ask the AI to pick another project, or to create the workflow on its own.',
|
|
4931
|
+
};
|
|
4932
|
+
|
|
4933
|
+
function createWhere(create) {
|
|
4934
|
+
return create.destination?.kind === 'project' ? `in project ${create.destination.label}` : 'on its own, outside any project';
|
|
4935
|
+
}
|
|
4936
|
+
|
|
4937
|
+
/** The card for the AI asking to create a workflow: what and where, then Deny / Create workflow. Approve once only. */
|
|
4938
|
+
function paintCreateCard(card, approval, create) {
|
|
4939
|
+
card.dataset.explicitOnly = 'true';
|
|
4940
|
+
card.classList.add('ai-chat-change', 'ai-chat-create');
|
|
4941
|
+
card.setAttribute('role', 'group');
|
|
4942
|
+
const id = approval.approvalId;
|
|
4943
|
+
const denyOnly = Boolean(create.refused || create.busy);
|
|
4944
|
+
const heading = document.createElement('strong');
|
|
4945
|
+
heading.id = `chat-create-heading-${id}`;
|
|
4946
|
+
heading.textContent = denyOnly ? 'Can’t create this yet' : 'Create a workflow?';
|
|
4947
|
+
card.setAttribute('aria-labelledby', heading.id);
|
|
4948
|
+
const provider = providerLabels[state.chat?.provider] || 'The AI';
|
|
4949
|
+
const copy = document.createElement('p');
|
|
4950
|
+
copy.id = `chat-create-copy-${id}`;
|
|
4951
|
+
copy.textContent = `${provider} wants to create a workflow.`;
|
|
4952
|
+
card.setAttribute('aria-describedby', copy.id);
|
|
4953
|
+
// One row in the change card's own style: the new workflow's name, and where it would go.
|
|
4954
|
+
const list = document.createElement('ul');
|
|
4955
|
+
list.className = 'ai-chat-change-owners';
|
|
4956
|
+
const row = document.createElement('li');
|
|
4957
|
+
const name = document.createElement('span');
|
|
4958
|
+
name.className = 'ai-chat-change-owner';
|
|
4959
|
+
const strong = document.createElement('b');
|
|
4960
|
+
strong.textContent = create.name;
|
|
4961
|
+
strong.dataset.tip = create.name;
|
|
4962
|
+
const kind = document.createElement('span');
|
|
4963
|
+
kind.className = 'ai-chat-change-kind';
|
|
4964
|
+
kind.textContent = 'new workflow';
|
|
4965
|
+
name.append(strong, kind);
|
|
4966
|
+
const where = document.createElement('span');
|
|
4967
|
+
where.className = 'ai-chat-change-paths';
|
|
4968
|
+
const whereLine = document.createElement('span');
|
|
4969
|
+
whereLine.className = 'ai-chat-change-path ai-chat-create-where';
|
|
4970
|
+
whereLine.textContent = createWhere(create);
|
|
4971
|
+
where.append(whereLine);
|
|
4972
|
+
row.append(name, where);
|
|
4973
|
+
list.append(row);
|
|
4974
|
+
const actions = document.createElement('div'); actions.className = 'ai-chat-approval-actions';
|
|
4975
|
+
if (denyOnly) {
|
|
4976
|
+
card.setAttribute('role', 'status');
|
|
4977
|
+
const reason = document.createElement('p');
|
|
4978
|
+
reason.className = 'ai-chat-change-reason';
|
|
4979
|
+
const place = create.destination?.kind === 'project' ? create.destination.label : 'that workflow';
|
|
4980
|
+
reason.textContent = create.refused
|
|
4981
|
+
? (CREATE_REFUSED_COPY[create.refused] || CREATE_REFUSED_COPY['project-missing'])
|
|
4982
|
+
: create.busy?.chatTitle
|
|
4983
|
+
? `Another conversation (“${create.busy.chatTitle}”) is changing ${place} right now, so nothing was created. Ask again when it’s finished.`
|
|
4984
|
+
: `Other work is changing ${place} right now, so nothing was created. Ask again when it’s finished.`;
|
|
4985
|
+
const dismiss = button('Dismiss', 'shell.chat-approval-deny');
|
|
4986
|
+
dismiss.addEventListener('click', () => decideApproval('deny'));
|
|
4987
|
+
actions.append(dismiss);
|
|
4988
|
+
card.append(heading, copy, list, reason, actions);
|
|
4989
|
+
return;
|
|
4990
|
+
}
|
|
4991
|
+
const deny = button('Deny', 'shell.chat-approval-deny');
|
|
4992
|
+
const allow = button('Create workflow', 'shell.chat-workflow-create-approve', 'allow');
|
|
4993
|
+
deny.addEventListener('click', () => decideApproval('deny'));
|
|
4994
|
+
allow.addEventListener('click', () => decideApproval('allow'));
|
|
4995
|
+
actions.append(deny, allow);
|
|
4996
|
+
card.append(heading, copy, list, actions);
|
|
4997
|
+
}
|
|
4998
|
+
|
|
4999
|
+
/** Each project or workflow the change touches, with up to five of its files. */
|
|
5000
|
+
function changeOwnerList(change) {
|
|
5001
|
+
const list = document.createElement('ul');
|
|
5002
|
+
list.className = 'ai-chat-change-owners';
|
|
5003
|
+
for (const owner of change.owners || []) {
|
|
5004
|
+
const row = document.createElement('li');
|
|
5005
|
+
const name = document.createElement('span');
|
|
5006
|
+
name.className = 'ai-chat-change-owner';
|
|
5007
|
+
const strong = document.createElement('b');
|
|
5008
|
+
strong.textContent = owner.label;
|
|
5009
|
+
const kind = document.createElement('span');
|
|
5010
|
+
kind.className = 'ai-chat-change-kind';
|
|
5011
|
+
kind.textContent = owner.kind === 'workflow' ? 'workflow' : 'project';
|
|
5012
|
+
name.append(strong, kind);
|
|
5013
|
+
const paths = document.createElement('span');
|
|
5014
|
+
paths.className = 'ai-chat-change-paths';
|
|
5015
|
+
const shown = (owner.paths || []).slice(0, CHANGE_PATHS_SHOWN);
|
|
5016
|
+
for (const path of shown) {
|
|
5017
|
+
const line = document.createElement('span');
|
|
5018
|
+
line.className = 'ai-chat-change-path';
|
|
5019
|
+
line.textContent = path;
|
|
5020
|
+
line.dataset.tip = path;
|
|
5021
|
+
paths.append(line);
|
|
5022
|
+
}
|
|
5023
|
+
const more = (owner.paths?.length || 0) - shown.length;
|
|
5024
|
+
if (more > 0) {
|
|
5025
|
+
const extra = document.createElement('span');
|
|
5026
|
+
extra.className = 'ai-chat-change-more';
|
|
5027
|
+
extra.textContent = `and ${more} more file${more === 1 ? '' : 's'}`;
|
|
5028
|
+
paths.append(extra);
|
|
5029
|
+
}
|
|
5030
|
+
row.append(name, paths);
|
|
5031
|
+
list.append(row);
|
|
5032
|
+
}
|
|
5033
|
+
return list;
|
|
5034
|
+
}
|
|
5035
|
+
|
|
3975
5036
|
function approvalIsExplicitOnly(approval) {
|
|
3976
5037
|
if (!approval) return false;
|
|
3977
5038
|
if (approval.explicitOnly === true) return true;
|
|
@@ -4453,6 +5514,7 @@
|
|
|
4453
5514
|
}
|
|
4454
5515
|
|
|
4455
5516
|
function paintSettings() {
|
|
5517
|
+
if (ui.scopeControls) paintScopeControl();
|
|
4456
5518
|
const chat = state.chat;
|
|
4457
5519
|
ui.settingsToggle.disabled = !chat;
|
|
4458
5520
|
const answer = capabilityAnswer(state.capability);
|
|
@@ -4478,8 +5540,8 @@
|
|
|
4478
5540
|
ui.model.querySelector('strong').textContent = chat?.settings.model ? (model?.label || chat.settings.model) : (model?.label || 'Choose model');
|
|
4479
5541
|
const medium = (model?.efforts || []).find((effort) => effort.toLowerCase() === 'medium');
|
|
4480
5542
|
ui.effort.querySelector('strong').textContent = effortLabel(chat?.settings.effort || medium || model?.efforts?.[0]) || 'Choose effort';
|
|
4481
|
-
ui.permission.querySelector('strong').textContent =
|
|
4482
|
-
if (state.scope?.owner?.kind === 'workspace') ui.permission.dataset.tip = 'From the workspace, AI Chat
|
|
5543
|
+
ui.permission.querySelector('strong').textContent = permissionLabel(chat?.settings.permissionProfile);
|
|
5544
|
+
if (state.scope?.owner?.kind === 'workspace') ui.permission.dataset.tip = 'From the workspace, AI Chat asks before it changes a file in a project or workflow. Full access isn’t offered here.';
|
|
4483
5545
|
else delete ui.permission.dataset.tip;
|
|
4484
5546
|
paintWorkspaceUnits();
|
|
4485
5547
|
const bindings = chat?.integrationBindings || [];
|
|
@@ -4560,6 +5622,7 @@
|
|
|
4560
5622
|
}
|
|
4561
5623
|
|
|
4562
5624
|
function paintRecovery() {
|
|
5625
|
+
paintMoveNotice();
|
|
4563
5626
|
const recovery = state.chat?.state === 'recovery';
|
|
4564
5627
|
ui.recovery.hidden = !recovery;
|
|
4565
5628
|
ui.recoveryStop.hidden = !recovery;
|
|
@@ -4570,9 +5633,12 @@
|
|
|
4570
5633
|
}
|
|
4571
5634
|
|
|
4572
5635
|
function paintConversation() {
|
|
5636
|
+
paintScopeControl();
|
|
4573
5637
|
paintComposerDisclosure();
|
|
4574
5638
|
paintTeklaChip();
|
|
4575
5639
|
paintConnectorAllowance();
|
|
5640
|
+
paintChangeAllowance();
|
|
5641
|
+
paintCheckAllowance();
|
|
4576
5642
|
const chat = state.chat;
|
|
4577
5643
|
if (!chat) { providerChooser(); paintHistory(); return; }
|
|
4578
5644
|
ui.historyToggle.disabled = false;
|
|
@@ -4705,7 +5771,20 @@
|
|
|
4705
5771
|
paintEvents(); paintUnread();
|
|
4706
5772
|
if (!document.hidden && !ui.feed.closest('[hidden]')) markRead();
|
|
4707
5773
|
if (['approval-requested', 'approval-decided', 'error', 'interrupted', 'state', 'followup-status'].includes(event.type)
|
|
4708
|
-
|| (event.type === 'user-message' && event.payload?.followup))
|
|
5774
|
+
|| (event.type === 'user-message' && event.payload?.followup)) {
|
|
5775
|
+
// #1890 PR 3b: a reply ending in a conversation waiting to move is when it moves; read the history list then,
|
|
5776
|
+
// because the conversation's own address answers "moved" the moment the move lands.
|
|
5777
|
+
const moveDue = state.scope?.owner?.kind === 'workspace' && state.chat?.rehome?.state === 'pending'
|
|
5778
|
+
&& ['state', 'error', 'interrupted'].includes(event.type);
|
|
5779
|
+
if (moveDue) void checkMoveProgress(chatId); else refreshConversation(chatId, false);
|
|
5780
|
+
}
|
|
5781
|
+
});
|
|
5782
|
+
// #1890 PR 3b: the conversation moved into the workflow it built; the stream closes and the tab follows.
|
|
5783
|
+
source.addEventListener('chat-moved', (message) => {
|
|
5784
|
+
if (state.source !== source) return;
|
|
5785
|
+
let payload = null;
|
|
5786
|
+
try { payload = JSON.parse(message.data); } catch { return; }
|
|
5787
|
+
if (payload?.to?.chatId) void followMovedChat(payload.to);
|
|
4709
5788
|
});
|
|
4710
5789
|
source.addEventListener('ready', () => {
|
|
4711
5790
|
if (state.source !== source || !sameScope(scope, generation) || state.chat?.chatId !== chatId) return;
|
|
@@ -5002,7 +6081,7 @@
|
|
|
5002
6081
|
state.scope = scope;
|
|
5003
6082
|
state.scopeInitialized = true;
|
|
5004
6083
|
if (scopeChanged) { try { window.flolessLeftPane?.chatLinksChanged?.(); } catch { /* the card refreshes on its next read */ } }
|
|
5005
|
-
state.chat = null; state.chats = []; state.archivedChats = []; state.unreadableChats = []; state.events = []; state.capability = null; state.desktop = null; state.attachments = []; state.integrations = null;
|
|
6084
|
+
state.chat = null; state.chats = []; state.archivedChats = []; state.unreadableChats = []; state.movedChats = []; state.movedChatsKnown = null; state.events = []; state.capability = null; state.desktop = null; state.attachments = []; state.integrations = null;
|
|
5006
6085
|
if (scopeChanged) clearReport();
|
|
5007
6086
|
state.filterCardMessages.clear();
|
|
5008
6087
|
updateOffscreenActivity();
|
|
@@ -5019,17 +6098,19 @@
|
|
|
5019
6098
|
const result = await request(`/api/chat/conversations?${ownerQuery(scope.owner)}`);
|
|
5020
6099
|
if (generation !== state.scopeGeneration) return;
|
|
5021
6100
|
state.chats = result.chats || [];
|
|
5022
|
-
state.unreadableChats = result.unreadableChats || [];
|
|
6101
|
+
state.unreadableChats = result.unreadableChats || []; noteMovedChats(result.movedChats);
|
|
5023
6102
|
seedReadCursors(state.chats, scope.owner);
|
|
5024
6103
|
paintHistory(); paintUnread();
|
|
5025
|
-
|
|
6104
|
+
// #2007: a scope may name the conversation it is for (an agent run's); otherwise the newest one opens.
|
|
6105
|
+
const wanted = scope.chatId && state.chats.some((chat) => chat.chatId === scope.chatId) ? scope.chatId : state.chats[0]?.chatId;
|
|
6106
|
+
if (wanted) await selectConversation(wanted);
|
|
5026
6107
|
else providerChooser();
|
|
5027
6108
|
} catch (error) {
|
|
5028
6109
|
if (generation === state.scopeGeneration) {
|
|
5029
6110
|
// A history read can fail independently of the selected project (for example while an
|
|
5030
6111
|
// older, stale conversation is being recovered). Do not erase the scope and disable the
|
|
5031
6112
|
// whole panel: the user can still start a new conversation in the project that is open.
|
|
5032
|
-
state.chats = []; state.archivedChats = []; state.unreadableChats = []; state.chat = null; state.events = []; state.capability = null;
|
|
6113
|
+
state.chats = []; state.archivedChats = []; state.unreadableChats = []; state.movedChats = []; state.movedChatsKnown = null; state.chat = null; state.events = []; state.capability = null;
|
|
5033
6114
|
updateOffscreenActivity();
|
|
5034
6115
|
ui.scope.textContent = scope.label;
|
|
5035
6116
|
ui.context.textContent = scope.owner.kind === 'project' ? 'Project conversation' : scope.owner.kind === 'workflow' ? 'Workflow conversation' : 'Workspace conversation';
|
|
@@ -5202,7 +6283,7 @@
|
|
|
5202
6283
|
const result = await request(`/api/chat/conversations?${ownerQuery()}&filter=instructor-answers`);
|
|
5203
6284
|
if (requestGeneration !== state.historyRequestGeneration || scopeGeneration !== state.scopeGeneration) return;
|
|
5204
6285
|
state.chats = result.chats || [];
|
|
5205
|
-
state.unreadableChats = result.unreadableChats || [];
|
|
6286
|
+
state.unreadableChats = result.unreadableChats || []; noteMovedChats(result.movedChats);
|
|
5206
6287
|
state.instructorAnswers = result.instructorAnswers || [];
|
|
5207
6288
|
} catch (error) {
|
|
5208
6289
|
if (requestGeneration === state.historyRequestGeneration) report(error, 'Could not load Instructor answers');
|
|
@@ -5348,13 +6429,22 @@
|
|
|
5348
6429
|
selected: (state.chat.settings.effort || 'medium').toLowerCase() === effort.toLowerCase(), patch: { effort } }));
|
|
5349
6430
|
}
|
|
5350
6431
|
|
|
6432
|
+
/** #1890 PR 2b: in a workspace conversation, "Make changes" — every change outside the AI's own folder asks first. */
|
|
6433
|
+
function permissionLabel(value) {
|
|
6434
|
+
if (state.scope?.owner?.kind === 'workspace' && value === 'workspace-write') return 'Make changes (asks first)';
|
|
6435
|
+
return permissionLabels[value] || 'Read only';
|
|
6436
|
+
}
|
|
6437
|
+
|
|
5351
6438
|
function permissionChoices() {
|
|
5352
|
-
// #1890: from the workspace,
|
|
5353
|
-
const
|
|
5354
|
-
|
|
5355
|
-
|
|
5356
|
-
|
|
5357
|
-
|
|
6439
|
+
// #1890 PR 2b: from the workspace, Full access is not offered — it would remove the approvals each change needs.
|
|
6440
|
+
const workspace = state.scope?.owner?.kind === 'workspace';
|
|
6441
|
+
const offered = workspace
|
|
6442
|
+
? Object.keys(permissionLabels).filter((value) => value !== 'full-access')
|
|
6443
|
+
: Object.keys(permissionLabels);
|
|
6444
|
+
return offered.map((value) => ({
|
|
6445
|
+
id: `permission:${value}`, label: permissionLabel(value),
|
|
6446
|
+
meta: value === 'full-access' ? 'all local files'
|
|
6447
|
+
: value === 'workspace-write' ? (workspace ? 'asks before changing project files' : 'project or workflow folder') : 'no file changes',
|
|
5358
6448
|
selected: state.chat.settings.permissionProfile === value, patch: { permissionProfile: value },
|
|
5359
6449
|
}));
|
|
5360
6450
|
}
|
|
@@ -5464,8 +6554,21 @@
|
|
|
5464
6554
|
const settingUp = Boolean(state.capability?.runtime && state.capability.runtime.state !== 'installed');
|
|
5465
6555
|
const uploading = Boolean(state.chat?.chatId && state.uploadingChatIds.has(state.chat.chatId));
|
|
5466
6556
|
ui.input.disabled = state.followupSubmitting || !state.chat || Boolean(state.chat?.archivedAt) || recovery || blocked;
|
|
6557
|
+
// #1890 PR 3b: while the conversation moves, typing goes on (the draft is kept) and Send waits. Inline, not a helper:
|
|
6558
|
+
// several harnesses run this function on its own.
|
|
6559
|
+
const movingTo = state.chat?.rehome && ['freezing', 'copying', 'publishing'].includes(state.chat.rehome.state)
|
|
6560
|
+
&& state.scope?.owner?.kind === 'workspace' ? state.chat.rehome.to.label : null;
|
|
6561
|
+
const moving = Boolean(movingTo);
|
|
6562
|
+
if (moving) {
|
|
6563
|
+
ui.hint.textContent = `Moving this conversation into workflow ${movingTo} — one moment.`;
|
|
6564
|
+
if (!state.movingPoll) {
|
|
6565
|
+
const movingChatId = state.chat.chatId;
|
|
6566
|
+
state.movingPoll = setTimeout(() => { state.movingPoll = null; void checkMoveProgress(movingChatId); }, 800);
|
|
6567
|
+
}
|
|
6568
|
+
}
|
|
5467
6569
|
ui.send.disabled = state.loading || state.followupSubmitting || Boolean(state.followupUnknownId) || hasUnknownFollowup() || uploading || !state.chat || blocked || frozen
|
|
5468
6570
|
|| (!ui.input.value.trim() && state.attachments.length === 0) || settingUp;
|
|
6571
|
+
if (moving) ui.send.disabled = true;
|
|
5469
6572
|
// The paperclip is the same on every surface, the Drawing Filter included (#1681, #1859): a message
|
|
5470
6573
|
// there carries the filter's context AND whatever the person attached, under the general rules only.
|
|
5471
6574
|
ui.attach.disabled = state.loading || state.followupSubmitting || Boolean(state.followupUnknownId) || hasUnknownFollowup() || uploading || !state.chat || blocked || frozen;
|
|
@@ -6490,12 +7593,22 @@
|
|
|
6490
7593
|
paintConversation();
|
|
6491
7594
|
announce('Applying your choice…');
|
|
6492
7595
|
try {
|
|
6493
|
-
await request(`/api/chat/conversations/${encodeURIComponent(snapshot.chatId)}/approvals/${encodeURIComponent(approvalId)}`, {
|
|
7596
|
+
const result = await request(`/api/chat/conversations/${encodeURIComponent(snapshot.chatId)}/approvals/${encodeURIComponent(approvalId)}`, {
|
|
6494
7597
|
method: 'POST', body: JSON.stringify({ owner: snapshot.scope.owner, decision,
|
|
6495
7598
|
...(decision === 'allow-chat' ? { allowanceRevision } : {}) }),
|
|
6496
7599
|
});
|
|
6497
7600
|
if (!sameChat(snapshot)) return;
|
|
6498
|
-
|
|
7601
|
+
// #1890 PR 2b: the server says what it actually did. A change it refused at its last check is announced with the
|
|
7602
|
+
// reason it gave, never as allowed.
|
|
7603
|
+
const outcome = result?.outcome;
|
|
7604
|
+
const refusal = typeof outcome?.reason === 'string' && outcome.reason ? outcome.reason : '';
|
|
7605
|
+
announce(refusal ? refusal
|
|
7606
|
+
// The request ended before the choice reached the AI (it was stopped or withdrawn): claim nothing about it.
|
|
7607
|
+
: outcome?.delivered === false ? 'This request ended before your choice reached the AI.'
|
|
7608
|
+
: decision === 'allow-request' ? 'Access auto-approval is on for this request.'
|
|
7609
|
+
: decision === 'allow-chat' && approval.change ? 'File changes in this conversation’s scope are allowed for this chat. Commands and tools still ask. Revoke above the message box.'
|
|
7610
|
+
: decision === 'allow-chat' && approval.connectionCheck ? `Checks of ${approval.connectionCheck.name || 'this tool'} are allowed for this chat. Revoke them above the message box.`
|
|
7611
|
+
: decision === 'allow-chat' && approval.connector ? `${connectorLabel(approval.connector)} is allowed for this chat. Revoke it above the message box.`
|
|
6499
7612
|
: decision === 'allow-chat' ? 'Tekla reads are allowed for this chat. Revoke them from the Tekla box above the message.'
|
|
6500
7613
|
: decision === 'allow' ? 'Approved once.' : 'Action denied.');
|
|
6501
7614
|
await refreshConversation(snapshot.chatId, false);
|
|
@@ -6538,12 +7651,15 @@
|
|
|
6538
7651
|
}
|
|
6539
7652
|
|
|
6540
7653
|
/**
|
|
6541
|
-
* The cut a large data file gets, said on its chip, or ''. Measured in
|
|
6542
|
-
*
|
|
6543
|
-
*
|
|
7654
|
+
* The cut a large data file gets, said on its chip, or ''. Measured in the characters the server decoded
|
|
7655
|
+
* (`textChars`), because a UTF-16 file has about half as many characters as bytes and is read whole well
|
|
7656
|
+
* past 16,000 bytes (#1889). A file stored before that was recorded falls back to bytes: a UTF-8 file never
|
|
7657
|
+
* has more characters than bytes, so one at or under the limit is always read whole, and "up to" keeps the
|
|
7658
|
+
* sentence true for one just over it.
|
|
6544
7659
|
*/
|
|
6545
7660
|
function dataCutTip(attachment) {
|
|
6546
|
-
|
|
7661
|
+
const size = Number.isFinite(attachment.textChars) ? attachment.textChars : (attachment.bytes || 0);
|
|
7662
|
+
if (!DATA_TYPES.has(attachment.mediaType) || size <= MAX_DATA_TEXT_CHARS) return '';
|
|
6547
7663
|
return 'Large file. The AI reads up to its first 16,000 characters.';
|
|
6548
7664
|
}
|
|
6549
7665
|
|
|
@@ -6551,19 +7667,42 @@
|
|
|
6551
7667
|
* Can FloLess read this data file, and what is it? The browser-side twin of server/attachment-text.ts
|
|
6552
7668
|
* (isDwg + sniffTextKind), run on the WHOLE file before anything in the batch uploads, so a refused
|
|
6553
7669
|
* file never reaches the server (#1853). A parity test runs both over the same fixtures.
|
|
6554
|
-
* Returns 'dwg', 'ifc', 'dxf', 'text', or null for a file that is not readable text.
|
|
7670
|
+
* Returns 'dwg', 'ifc', 'dxf', 'text', 'utf16' (a UTF-16 file that could not be read), or null for a file that is not readable text.
|
|
6555
7671
|
*/
|
|
6556
7672
|
function sniffDataFile(bytes) {
|
|
6557
7673
|
// A DWG is named only when the file is not text: a CSV may begin "AC1234,…" (isDwg).
|
|
6558
7674
|
const dwg = bytes.length >= 6 && bytes[0] === 0x41 && bytes[1] === 0x43
|
|
6559
7675
|
&& [2, 3, 4, 5].every((i) => bytes[i] >= 0x30 && bytes[i] <= 0x39);
|
|
6560
7676
|
const kind = sniffTextBytes(bytes);
|
|
6561
|
-
|
|
7677
|
+
if (kind) return kind;
|
|
7678
|
+
// A UTF-16 file (FF FE / FE FF) the sniffer could not read is named, so the refusal can say "save it as CSV UTF-8" (#1889).
|
|
7679
|
+
if (bytes.length >= 2 && ((bytes[0] === 0xff && bytes[1] === 0xfe) || (bytes[0] === 0xfe && bytes[1] === 0xff))) return 'utf16';
|
|
7680
|
+
return dwg ? 'dwg' : null;
|
|
6562
7681
|
}
|
|
6563
7682
|
|
|
6564
7683
|
/** The text half of sniffDataFile: 'ifc', 'dxf', 'text', or null (server/attachment-text.ts sniffTextKind). */
|
|
6565
7684
|
function sniffTextBytes(bytes) {
|
|
6566
|
-
if (!bytes.length
|
|
7685
|
+
if (!bytes.length) return null;
|
|
7686
|
+
const headKind = (head) => head.startsWith('ISO-10303-21') ? 'ifc' : /^\s*0\s*[\r\n]+\s*SECTION/.test(head) ? 'dxf' : 'text';
|
|
7687
|
+
// A UTF-16 file (Excel "Unicode Text") is full of NULs by design: judge its DECODED text (server decodeUtf16, #1889).
|
|
7688
|
+
if ((bytes[0] === 0xff && bytes[1] === 0xfe) || (bytes[0] === 0xfe && bytes[1] === 0xff)) {
|
|
7689
|
+
let body = bytes.subarray(2);
|
|
7690
|
+
if (body.length % 2) return null;
|
|
7691
|
+
if (bytes[0] === 0xfe) {
|
|
7692
|
+
body = new Uint8Array(body);
|
|
7693
|
+
for (let i = 0; i < body.length; i += 2) { const t = body[i]; body[i] = body[i + 1]; body[i + 1] = t; }
|
|
7694
|
+
}
|
|
7695
|
+
let text;
|
|
7696
|
+
try { text = new TextDecoder('utf-16le', { fatal: true }).decode(body); } catch { return null; }
|
|
7697
|
+
if (!text.length || text.includes('\0')) return null;
|
|
7698
|
+
let readable = 0;
|
|
7699
|
+
for (let i = 0; i < text.length; i++) {
|
|
7700
|
+
const c = text.charCodeAt(i);
|
|
7701
|
+
if (c === 0x09 || c === 0x0a || c === 0x0d || (c >= 0x20 && c !== 0x7f)) readable++;
|
|
7702
|
+
}
|
|
7703
|
+
return readable / text.length <= 0.9 ? null : headKind(text.slice(0, 512));
|
|
7704
|
+
}
|
|
7705
|
+
if (bytes.includes(0)) return null;
|
|
6567
7706
|
let printable = 0;
|
|
6568
7707
|
for (const byte of bytes) {
|
|
6569
7708
|
if (byte === 0x09 || byte === 0x0a || byte === 0x0d || (byte >= 0x20 && byte !== 0x7f)) printable++;
|
|
@@ -6574,9 +7713,7 @@
|
|
|
6574
7713
|
if (!utf8 && bytes.filter((byte) => byte >= 0x80).length / bytes.length > 0.3) return null;
|
|
6575
7714
|
let head = '';
|
|
6576
7715
|
for (const byte of bytes.subarray(0, 512)) head += String.fromCharCode(byte);
|
|
6577
|
-
|
|
6578
|
-
if (/^\s*0\s*[\r\n]+\s*SECTION/.test(head)) return 'dxf';
|
|
6579
|
-
return 'text';
|
|
7716
|
+
return headKind(head);
|
|
6580
7717
|
}
|
|
6581
7718
|
|
|
6582
7719
|
/**
|
|
@@ -6593,6 +7730,7 @@
|
|
|
6593
7730
|
return `“${file.name}” could not be read. Check that the file is still there, then attach it again. Nothing was attached.`;
|
|
6594
7731
|
}
|
|
6595
7732
|
if (kind === 'dwg') return `“${file.name}” is a DWG, which FloLess can’t read. Export it as IFC or PDF and attach that instead. Nothing was sent.`;
|
|
7733
|
+
if (kind === 'utf16') return `“${file.name}” is a UTF-16 text file that FloLess couldn’t read. Save it as “CSV UTF-8” and attach that instead. Nothing was sent.`;
|
|
6596
7734
|
if (kind) return null;
|
|
6597
7735
|
if (String(file.type || '').startsWith('image/')) {
|
|
6598
7736
|
return `“${file.name}” is a picture format FloLess can’t send. Save it as PNG, JPEG or WebP and attach that instead. Nothing was sent.`;
|
|
@@ -6600,6 +7738,33 @@
|
|
|
6600
7738
|
return `“${file.name}” isn’t a file type FloLess can read. Attach a picture, PDF, IFC, DXF, or a text file such as CSV. Nothing was sent.`;
|
|
6601
7739
|
}
|
|
6602
7740
|
|
|
7741
|
+
/**
|
|
7742
|
+
* The browser twin of server/attachment-text.ts pictureMismatchSentence (#1888): a file the browser
|
|
7743
|
+
* calls a picture or PDF is only that when its first bytes say so, so a DWG renamed .pdf is turned
|
|
7744
|
+
* away at the chooser. Returns the plain sentence, or null when the bytes match the declared type.
|
|
7745
|
+
*/
|
|
7746
|
+
async function pictureFileRefusal(file) {
|
|
7747
|
+
let bytes;
|
|
7748
|
+
try { bytes = new Uint8Array(await file.slice(0, 1024).arrayBuffer()); }
|
|
7749
|
+
catch (error) {
|
|
7750
|
+
console.warn('[ai-chat] a chosen file could not be read', error);
|
|
7751
|
+
return `“${file.name}” could not be read. Check that the file is still there, then attach it again. Nothing was attached.`;
|
|
7752
|
+
}
|
|
7753
|
+
const at = (offset, sig) => sig.every((byte, i) => bytes[offset + i] === byte);
|
|
7754
|
+
const ascii = (text) => [...text].map((ch) => ch.charCodeAt(0));
|
|
7755
|
+
// A PDF may carry a short preamble: the header can sit anywhere in the first 1024 bytes (server twin).
|
|
7756
|
+
const hasPdfHeader = () => { for (let i = 0; i + 5 <= bytes.length; i++) if (at(i, ascii('%PDF-'))) return true; return false; };
|
|
7757
|
+
const kind = at(0, [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]) ? 'image/png'
|
|
7758
|
+
: at(0, [0xff, 0xd8, 0xff]) ? 'image/jpeg'
|
|
7759
|
+
: at(0, ascii('RIFF')) && at(8, ascii('WEBP')) ? 'image/webp'
|
|
7760
|
+
: hasPdfHeader() ? 'application/pdf' : null;
|
|
7761
|
+
if (kind === file.type) return null;
|
|
7762
|
+
const dwg = bytes.length >= 6 && bytes[0] === 0x41 && bytes[1] === 0x43 && [2, 3, 4, 5].every((i) => bytes[i] >= 0x30 && bytes[i] <= 0x39);
|
|
7763
|
+
if (dwg) return `“${file.name}” is a DWG, which FloLess can’t read. Export it as IFC or PDF and attach that instead. Nothing was sent.`;
|
|
7764
|
+
const words = { 'image/png': 'a real PNG picture', 'image/jpeg': 'a real JPEG picture', 'image/webp': 'a real WebP picture', 'application/pdf': 'a real PDF' }[file.type] || 'a real picture';
|
|
7765
|
+
return `“${file.name}” doesn’t look like ${words} inside, so FloLess can’t send it. Save or export it again from the program that made it, then attach it. Nothing was sent.`;
|
|
7766
|
+
}
|
|
7767
|
+
|
|
6603
7768
|
/**
|
|
6604
7769
|
* An error whose message is already the whole plain sentence the person should read. Without the mark
|
|
6605
7770
|
* errorMessage() replaces an unrecognised message with "FloLess could not complete this chat action",
|
|
@@ -6652,6 +7817,11 @@
|
|
|
6652
7817
|
if (!sameChat(snapshot)) return;
|
|
6653
7818
|
if (refusal) { report(plainError(refusal)); return; }
|
|
6654
7819
|
}
|
|
7820
|
+
for (const file of incoming.filter((item) => !isData(item))) {
|
|
7821
|
+
const refusal = await pictureFileRefusal(file);
|
|
7822
|
+
if (!sameChat(snapshot)) return;
|
|
7823
|
+
if (refusal) { report(plainError(refusal)); return; }
|
|
7824
|
+
}
|
|
6655
7825
|
for (const file of incoming) {
|
|
6656
7826
|
const data = await fileBase64(file);
|
|
6657
7827
|
if (!sameChat(snapshot)) return;
|
|
@@ -6708,7 +7878,7 @@
|
|
|
6708
7878
|
}
|
|
6709
7879
|
if (!sameScope(scope, generation)) return;
|
|
6710
7880
|
state.chats = result.chats || [];
|
|
6711
|
-
state.unreadableChats = result.unreadableChats || [];
|
|
7881
|
+
state.unreadableChats = result.unreadableChats || []; noteMovedChats(result.movedChats);
|
|
6712
7882
|
const active = state.chats.find((item) => item.chatId === state.chat?.chatId);
|
|
6713
7883
|
if (active && state.chat) {
|
|
6714
7884
|
// An event-stream completion can win the race against this list request. Never let a
|
|
@@ -6855,9 +8025,22 @@
|
|
|
6855
8025
|
|
|
6856
8026
|
async function openConversation(chatId, options = {}) {
|
|
6857
8027
|
await refreshScope();
|
|
8028
|
+
if (options.owner !== undefined) {
|
|
8029
|
+
const owner = options.owner;
|
|
8030
|
+
const validId = (id) => typeof id === 'string' && !!id && id.length <= 200;
|
|
8031
|
+
if (!owner || typeof owner !== 'object'
|
|
8032
|
+
|| !(owner.kind === 'workspace' || owner.kind === 'project' && validId(owner.projectId)
|
|
8033
|
+
|| owner.kind === 'workflow' && validId(owner.workflowId))) throw new Error('That conversation has no valid home to open.');
|
|
8034
|
+
if (scopeKey({ owner }) !== scopeKey(state.scope)) {
|
|
8035
|
+
if (typeof window.flolessWorkspaces?.openChatOwner !== 'function') throw new Error('Open the project or workflow this conversation belongs to, then choose Show in chat again.');
|
|
8036
|
+
await window.flolessWorkspaces.openChatOwner(owner);
|
|
8037
|
+
await refreshScope(true);
|
|
8038
|
+
}
|
|
8039
|
+
if (scopeKey({ owner }) !== scopeKey(state.scope)) throw new Error('The conversation’s home could not be opened. Try Show in chat again.');
|
|
8040
|
+
}
|
|
6858
8041
|
if (!state.scope?.owner) throw new Error('Open this conversation’s project or workflow, then try again.');
|
|
6859
|
-
//
|
|
6860
|
-
if (typeof options.projectId === 'string' && (state.scope.owner.kind !== 'project' || state.scope.owner.projectId !== options.projectId)) {
|
|
8042
|
+
// Legacy object cards name only their project. New cross-project pins carry the server-resolved chat home.
|
|
8043
|
+
if (options.owner === undefined && typeof options.projectId === 'string' && (state.scope.owner.kind !== 'project' || state.scope.owner.projectId !== options.projectId)) {
|
|
6861
8044
|
throw new Error('Open this project in Workspaces to see that conversation.');
|
|
6862
8045
|
}
|
|
6863
8046
|
if (typeof options.ownerKey === 'string' && scopeKey(state.scope) !== options.ownerKey) {
|
|
@@ -6865,7 +8048,9 @@
|
|
|
6865
8048
|
}
|
|
6866
8049
|
window.flolessBridge?.revealAiChat?.();
|
|
6867
8050
|
ui.tab.click();
|
|
8051
|
+
const requestedScope = scopeKey(state.scope);
|
|
6868
8052
|
const listed = await request(`/api/chat/conversations?${ownerQuery()}`);
|
|
8053
|
+
if (scopeKey(state.scope) !== requestedScope) throw new Error('The project or workflow changed while this conversation was opening. Choose Show in chat again.');
|
|
6869
8054
|
state.chats = listed.chats || [];
|
|
6870
8055
|
paintHistory(); paintUnread();
|
|
6871
8056
|
const messageEventId = typeof options.messageEventId === 'string' ? options.messageEventId : undefined;
|
|
@@ -7053,6 +8238,346 @@
|
|
|
7053
8238
|
}
|
|
7054
8239
|
}
|
|
7055
8240
|
|
|
8241
|
+
function paintScopeControl() {
|
|
8242
|
+
if (!ui.scopeControls) return;
|
|
8243
|
+
const chat = state.chat;
|
|
8244
|
+
ui.scopeControls.hidden = !chat || Boolean(chat.archivedAt);
|
|
8245
|
+
if (!chat) { closeScopePicker(); return; }
|
|
8246
|
+
if (state.scopeViewChatId !== chat.chatId) { state.scopeView = null; closeScopePicker(); }
|
|
8247
|
+
if (state.scopeView && state.scopeView.scope.revision !== (chat.scopeRevision ?? 0)) {
|
|
8248
|
+
state.scopeView = null; closeScopePicker();
|
|
8249
|
+
}
|
|
8250
|
+
const count = Array.isArray(chat.scopeExtensions) ? chat.scopeExtensions.length : 0;
|
|
8251
|
+
const home = state.scopeView?.scope?.home?.label || state.scope?.label || 'Home';
|
|
8252
|
+
ui.scopeToggle.textContent = `Scope · ${home}${count ? ` + ${count}` : ''}`;
|
|
8253
|
+
ui.scopeToggle.dataset.tip = 'See the conversation’s home folder and add or remove other projects and workflows.';
|
|
8254
|
+
ui.scopeToggle.disabled = state.loading;
|
|
8255
|
+
if (ui.scopeToggle.disabled) ui.scopeToggle.dataset.blockedReason = 'The conversation is still loading.';
|
|
8256
|
+
else delete ui.scopeToggle.dataset.blockedReason;
|
|
8257
|
+
const disclosure = chat.settings?.permissionProfile === 'read-only'
|
|
8258
|
+
? 'Read only: the AI’s file tools cannot change files. Commands keep their own approvals and may authorize file changes.'
|
|
8259
|
+
: chat.settings?.permissionProfile === 'full-access' ? 'Full access is on. The AI can change files without asking.'
|
|
8260
|
+
: chat.changeAllowance?.allowedForChat ? 'File changes in scope, including folders you add later, are allowed for this chat.' : '';
|
|
8261
|
+
if (ui.scopeDisclosure.textContent !== disclosure) ui.scopeDisclosure.textContent = disclosure;
|
|
8262
|
+
// Poll/SSE can change permissions or pause a reply while Scope stays open. Refresh only when
|
|
8263
|
+
// these states change, retaining its selected add choice and focus on an enabled control.
|
|
8264
|
+
const picker = ui.scopePicker;
|
|
8265
|
+
const availability = JSON.stringify([Boolean(chat.activeTurn), Boolean(chat.pendingApproval), Boolean(state.scopeEditing), chat.settings?.permissionProfile, Boolean(chat.changeAllowance?.allowedForChat)]);
|
|
8266
|
+
if (state.scopePickerOpen && state.scopeView && picker?.dataset.availability !== availability) {
|
|
8267
|
+
const focused = picker.contains(document.activeElement) ? document.activeElement?.dataset?.commandId : null;
|
|
8268
|
+
paintScopePicker();
|
|
8269
|
+
if (focused) {
|
|
8270
|
+
const buttons = [...picker.querySelectorAll('button')];
|
|
8271
|
+
const target = buttons.find((node) => node.dataset.commandId === focused && !node.disabled)
|
|
8272
|
+
|| buttons.find((node) => !node.disabled);
|
|
8273
|
+
target?.focus();
|
|
8274
|
+
}
|
|
8275
|
+
}
|
|
8276
|
+
}
|
|
8277
|
+
|
|
8278
|
+
function closeScopePicker(restoreFocus = false) {
|
|
8279
|
+
state.scopePickerOpen = false; state.scopeChoice = null;
|
|
8280
|
+
if (ui.scopePicker) { ui.scopePicker.hidden = true; ui.scopePicker.replaceChildren(); }
|
|
8281
|
+
ui.scopeToggle?.setAttribute('aria-expanded', 'false');
|
|
8282
|
+
if (restoreFocus) ui.scopeToggle?.focus();
|
|
8283
|
+
}
|
|
8284
|
+
|
|
8285
|
+
async function openScopePicker() {
|
|
8286
|
+
if (state.scopePickerOpen) { closeScopePicker(true); return; }
|
|
8287
|
+
const snapshot = captureChat();
|
|
8288
|
+
if (!snapshot || state.chat.archivedAt) return;
|
|
8289
|
+
closePicker(); state.scopeChoice = null; state.scopePickerOpen = true; state.scopeViewChatId = snapshot.chatId;
|
|
8290
|
+
ui.scopePicker.hidden = false; ui.scopeToggle.setAttribute('aria-expanded', 'true');
|
|
8291
|
+
ui.scopePicker.textContent = 'Loading conversation scope…';
|
|
8292
|
+
try {
|
|
8293
|
+
const result = await request(`/api/chat/conversations/${encodeURIComponent(snapshot.chatId)}/scope?${ownerQuery(snapshot.scope.owner)}`);
|
|
8294
|
+
if (!sameChat(snapshot) || !state.scopePickerOpen) return;
|
|
8295
|
+
state.scopeView = result; state.scopeViewChatId = snapshot.chatId;
|
|
8296
|
+
state.chat = { ...state.chat, scopeExtensions: result.scope.extensions.map((entry) => entry.target), scopeRevision: result.scope.revision, changeAllowance: result.changeAllowance };
|
|
8297
|
+
paintScopePicker(); paintScopeControl();
|
|
8298
|
+
ui.scopePicker.querySelector('button')?.focus();
|
|
8299
|
+
} catch (error) {
|
|
8300
|
+
if (sameChat(snapshot) && state.scopePickerOpen) { closeScopePicker(true); report(error, 'Could not load conversation scope'); }
|
|
8301
|
+
}
|
|
8302
|
+
}
|
|
8303
|
+
|
|
8304
|
+
function paintScopePicker() {
|
|
8305
|
+
const host = ui.scopePicker;
|
|
8306
|
+
if (!host || !state.scopePickerOpen || !state.scopeView) return;
|
|
8307
|
+
const view = state.scopeView;
|
|
8308
|
+
const profile = state.chat?.settings?.permissionProfile;
|
|
8309
|
+
const readOnly = profile === 'read-only';
|
|
8310
|
+
const globalAllowance = Boolean(state.chat?.changeAllowance?.allowedForChat);
|
|
8311
|
+
host.dataset.availability = JSON.stringify([Boolean(state.chat?.activeTurn), Boolean(state.chat?.pendingApproval), Boolean(state.scopeEditing), profile, globalAllowance]);
|
|
8312
|
+
host.replaceChildren();
|
|
8313
|
+
const heading = document.createElement('strong'); heading.textContent = 'Conversation scope';
|
|
8314
|
+
const close = button('×', 'shell.chat-scope-close', 'ai-chat-scope-close');
|
|
8315
|
+
close.setAttribute('aria-label', 'Close conversation scope'); close.dataset.tip = 'Close conversation scope';
|
|
8316
|
+
close.addEventListener('click', () => closeScopePicker(true));
|
|
8317
|
+
const head = document.createElement('div'); head.className = 'ai-chat-scope-head'; head.append(heading, close); host.append(head);
|
|
8318
|
+
const note = document.createElement('p'); note.className = 'ai-chat-scope-note';
|
|
8319
|
+
note.textContent = readOnly ? 'The AI’s file tools cannot change files while Read only is on. Commands keep their own approvals and may authorize file changes. Scope adds folders and project data; it does not limit file reads.'
|
|
8320
|
+
+ (globalAllowance ? ' Your saved file-change allowance does not override Read only.' : '')
|
|
8321
|
+
: profile === 'full-access' ? 'Full access is on. The AI can change files without asking.'
|
|
8322
|
+
: globalAllowance ? 'File changes in this scope, including folders you add later, are allowed without asking. Commands and tools keep their own approvals. Scope does not limit file reads.'
|
|
8323
|
+
: 'File edits outside your home folder ask for approval unless you allow file changes for this chat. Scope adds folders and project data to this conversation; it does not limit file reads. Your home folder keeps its native provider permissions.';
|
|
8324
|
+
host.append(note);
|
|
8325
|
+
if (view.scope.dropped?.length) {
|
|
8326
|
+
const dropped = document.createElement('p'); dropped.className = 'ai-chat-scope-note'; dropped.setAttribute('role', 'status');
|
|
8327
|
+
dropped.textContent = 'An added project or workflow is no longer available and has been removed from this conversation’s scope.';
|
|
8328
|
+
host.append(dropped);
|
|
8329
|
+
}
|
|
8330
|
+
const home = document.createElement('div'); home.className = 'ai-chat-scope-row';
|
|
8331
|
+
const homeName = document.createElement('span'); homeName.textContent = view.scope.home.label;
|
|
8332
|
+
const pinned = document.createElement('small'); pinned.textContent = 'Home'; home.append(homeName, pinned); host.append(home);
|
|
8333
|
+
for (const entry of view.scope.extensions) {
|
|
8334
|
+
const row = document.createElement('div'); row.className = 'ai-chat-scope-row';
|
|
8335
|
+
const name = document.createElement('span'); name.textContent = `${entry.target.kind === 'project' ? 'Project' : 'Workflow'} · ${entry.label}`;
|
|
8336
|
+
const targetId = entry.target.kind === 'project' ? entry.target.projectId : entry.target.workflowId;
|
|
8337
|
+
const remove = button('Remove', `shell.chat-scope-remove#${commandInstance(`${entry.target.kind}:${targetId}`)}`, 'ai-chat-scope-action');
|
|
8338
|
+
remove.dataset.commandInstanceLabel = entry.label;
|
|
8339
|
+
remove.setAttribute('aria-label', `Remove ${entry.target.kind} ${entry.label} from this conversation’s scope`);
|
|
8340
|
+
const removeBlocked = state.scopeEditing ? 'Saving conversation scope…'
|
|
8341
|
+
: state.chat?.activeTurn && !state.chat?.pendingApproval ? 'Wait for the current reply to finish before removing scope.' : '';
|
|
8342
|
+
remove.disabled = Boolean(removeBlocked);
|
|
8343
|
+
if (removeBlocked) { remove.dataset.blockedReason = removeBlocked; remove.dataset.tip = removeBlocked; }
|
|
8344
|
+
remove.addEventListener('click', () => { void mutateScope('remove', entry.target, entry.label); });
|
|
8345
|
+
row.append(name, remove); host.append(row);
|
|
8346
|
+
}
|
|
8347
|
+
if (state.chat?.activeTurn) {
|
|
8348
|
+
const busy = document.createElement('p'); busy.className = 'ai-chat-scope-note';
|
|
8349
|
+
busy.textContent = state.chat.pendingApproval ? 'You can remove a folder while this reply waits for approval. Add folders after the reply finishes.' : 'Wait for the current reply to finish before changing scope.';
|
|
8350
|
+
host.append(busy);
|
|
8351
|
+
}
|
|
8352
|
+
if (state.scopeChoice) {
|
|
8353
|
+
const choice = state.scopeChoice;
|
|
8354
|
+
const choiceKey = choice.target.kind === 'project' ? choice.target.projectId : choice.target.workflowId;
|
|
8355
|
+
const question = document.createElement('p'); question.className = 'ai-chat-scope-note';
|
|
8356
|
+
const writeProfile = state.chat?.owner?.kind === 'workspace' ? 'Make changes (asks first)' : 'Working folder write';
|
|
8357
|
+
question.textContent = `Add ${choice.target.kind} “${choice.label}” to this conversation?${globalAllowance ? readOnly
|
|
8358
|
+
? ` If you choose ${writeProfile}, file changes here will also be allowed without asking.`
|
|
8359
|
+
: ' File changes here will also be allowed without asking.' : ''}`;
|
|
8360
|
+
const add = button(globalAllowance ? readOnly ? 'Add scope for later file changes' : 'Add scope and allow file changes' : 'Add scope', `shell.chat-scope-add#${commandInstance(`${choice.target.kind}:${choiceKey}`)}`, 'ai-chat-scope-action');
|
|
8361
|
+
add.dataset.commandInstanceLabel = choice.label; add.disabled = state.scopeEditing || Boolean(state.chat?.activeTurn);
|
|
8362
|
+
if (add.disabled) { add.dataset.blockedReason = state.scopeEditing ? 'Saving conversation scope…' : 'Wait for the current reply to finish before adding scope.'; add.dataset.tip = add.dataset.blockedReason; }
|
|
8363
|
+
add.addEventListener('click', () => { void mutateScope('add', choice.target, choice.label); });
|
|
8364
|
+
const back = button('Back', 'shell.chat-scope-back', 'ai-chat-scope-action'); back.disabled = state.scopeEditing;
|
|
8365
|
+
if (back.disabled) { back.dataset.blockedReason = 'Saving conversation scope…'; back.dataset.tip = back.dataset.blockedReason; }
|
|
8366
|
+
back.addEventListener('click', () => { state.scopeChoice = null; paintScopePicker(); host.querySelector('button')?.focus(); });
|
|
8367
|
+
host.append(question, add, back);
|
|
8368
|
+
} else {
|
|
8369
|
+
const title = document.createElement('strong'); title.textContent = 'Add project or workflow'; host.append(title);
|
|
8370
|
+
const options = (view.options || []).filter((option) => !option.inScope);
|
|
8371
|
+
if (!options.length) {
|
|
8372
|
+
const empty = document.createElement('p'); empty.className = 'ai-chat-scope-note'; empty.textContent = 'No other projects or workflows to add.'; host.append(empty);
|
|
8373
|
+
}
|
|
8374
|
+
for (const option of options) {
|
|
8375
|
+
const key = option.target.kind === 'project' ? option.target.projectId : option.target.workflowId;
|
|
8376
|
+
const choose = button(`${option.target.kind === 'project' ? 'Project' : 'Workflow'} · ${option.label}`, `shell.chat-scope-choose#${commandInstance(`${option.target.kind}:${key}`)}`, 'ai-chat-choice');
|
|
8377
|
+
choose.dataset.commandInstanceLabel = option.label; choose.disabled = state.scopeEditing || Boolean(state.chat?.activeTurn);
|
|
8378
|
+
if (choose.disabled) { choose.dataset.blockedReason = state.scopeEditing ? 'Saving conversation scope…' : 'Wait for the current reply to finish before adding scope.'; choose.dataset.tip = choose.dataset.blockedReason; }
|
|
8379
|
+
choose.addEventListener('click', () => { state.scopeChoice = option; paintScopePicker(); host.querySelector('[data-command-id^="shell.chat-scope-add#"]')?.focus(); });
|
|
8380
|
+
host.append(choose);
|
|
8381
|
+
}
|
|
8382
|
+
}
|
|
8383
|
+
}
|
|
8384
|
+
|
|
8385
|
+
async function mutateScope(verb, target, label) {
|
|
8386
|
+
const snapshot = captureChat();
|
|
8387
|
+
if (!snapshot || state.scopeEditing || !state.scopeView) return;
|
|
8388
|
+
const view = state.scopeView;
|
|
8389
|
+
state.scopeEditing = true; paintScopePicker();
|
|
8390
|
+
try {
|
|
8391
|
+
const result = await request(`/api/chat/conversations/${encodeURIComponent(snapshot.chatId)}/scope/${verb}`, {
|
|
8392
|
+
method: 'POST', body: JSON.stringify({ owner: snapshot.scope.owner, target, revision: view.scope.revision,
|
|
8393
|
+
...(verb === 'add' ? { allowanceRevision: view.changeAllowance?.revision ?? 0 } : {}) }),
|
|
8394
|
+
});
|
|
8395
|
+
if (!sameChat(snapshot)) return;
|
|
8396
|
+
state.scopeView = result; state.scopeViewChatId = snapshot.chatId; state.scopeChoice = null;
|
|
8397
|
+
state.chat = { ...state.chat, scopeExtensions: result.scope.extensions.map((entry) => entry.target), scopeRevision: result.scope.revision, changeAllowance: result.changeAllowance };
|
|
8398
|
+
announce(verb === 'add' ? `${label} added to this conversation’s scope.` : `${label} removed from this conversation’s scope. Changes already made are kept.`);
|
|
8399
|
+
paintScopeControl(); paintChangeAllowance();
|
|
8400
|
+
} catch (error) {
|
|
8401
|
+
if (sameChat(snapshot)) {
|
|
8402
|
+
report(error, 'Could not change conversation scope');
|
|
8403
|
+
// A different tab can change either revision while this confirmation is open.
|
|
8404
|
+
// Refresh the disclosed permission before offering another Add; never retry silently.
|
|
8405
|
+
if (error?.status === 409 && state.scopePickerOpen) {
|
|
8406
|
+
try {
|
|
8407
|
+
const current = await request(`/api/chat/conversations/${encodeURIComponent(snapshot.chatId)}/scope?${ownerQuery(snapshot.scope.owner)}`);
|
|
8408
|
+
if (sameChat(snapshot) && state.scopePickerOpen) {
|
|
8409
|
+
state.scopeView = current; state.scopeChoice = null;
|
|
8410
|
+
state.chat = { ...state.chat, scopeExtensions: current.scope.extensions.map((entry) => entry.target), scopeRevision: current.scope.revision, changeAllowance: current.changeAllowance };
|
|
8411
|
+
paintScopeControl(); paintChangeAllowance();
|
|
8412
|
+
}
|
|
8413
|
+
} catch { /* Keep the original refusal visible; the person can reopen Scope to retry. */ }
|
|
8414
|
+
}
|
|
8415
|
+
}
|
|
8416
|
+
} finally {
|
|
8417
|
+
state.scopeEditing = false;
|
|
8418
|
+
if (sameChat(snapshot) && state.scopePickerOpen) { paintScopePicker(); ui.scopePicker.querySelector('button')?.focus(); }
|
|
8419
|
+
}
|
|
8420
|
+
}
|
|
8421
|
+
|
|
8422
|
+
// Legacy per-owner allowances remain removable when no conversation-wide file allowance covers them.
|
|
8423
|
+
function paintChangeAllowance() {
|
|
8424
|
+
const host = ui.changeAllowance;
|
|
8425
|
+
if (!host) return;
|
|
8426
|
+
const chat = state.chat;
|
|
8427
|
+
const allowed = chat && !chat.archivedAt && Array.isArray(chat.changeAllowance?.allowed)
|
|
8428
|
+
? chat.changeAllowance.allowed : [];
|
|
8429
|
+
const global = chat && !chat.archivedAt && chat.changeAllowance?.allowedForChat;
|
|
8430
|
+
const readOnly = chat?.settings?.permissionProfile === 'read-only';
|
|
8431
|
+
const painted = `${chat?.chatId || ''}|${allowed.map((entry) => entry.key).join(',')}|${Boolean(global)}|${readOnly}|${state.changeRevoking || ''}`;
|
|
8432
|
+
if (host.dataset.painted === painted) return;
|
|
8433
|
+
host.dataset.painted = painted;
|
|
8434
|
+
host.replaceChildren();
|
|
8435
|
+
host.hidden = !allowed.length && !global;
|
|
8436
|
+
if (!allowed.length && !global) return;
|
|
8437
|
+
if (global) {
|
|
8438
|
+
const copy = document.createElement('span'); copy.textContent = readOnly ? 'File-change allowance saved; Read only blocks file tools' : 'File changes allowed for this chat';
|
|
8439
|
+
const revoke = button('Revoke', 'shell.chat-change-allowance-revoke-all', 'ai-chat-connector-revoke');
|
|
8440
|
+
revoke.dataset.tip = 'Future file changes will ask again where your permission setting requires approval. Your home folder keeps its current permissions.';
|
|
8441
|
+
revoke.disabled = state.changeRevoking === 'all';
|
|
8442
|
+
if (revoke.disabled) revoke.dataset.blockedReason = 'Revoking file-change allowance…';
|
|
8443
|
+
revoke.addEventListener('click', () => { void revokeChangeAllowance({ key: null, label: 'file changes in this chat' }); });
|
|
8444
|
+
host.append(copy, revoke);
|
|
8445
|
+
// A legacy owner-specific Revoke would imply that folder stops being allowed, but the
|
|
8446
|
+
// conversation-wide grant still covers it. Its one Revoke ends every standing file grant.
|
|
8447
|
+
return;
|
|
8448
|
+
}
|
|
8449
|
+
const title = document.createElement('span');
|
|
8450
|
+
title.className = 'ai-chat-connectors-title';
|
|
8451
|
+
title.textContent = readOnly ? 'Saved change allowances; Read only blocks file tools:' : 'Changes allowed for this chat:';
|
|
8452
|
+
host.append(title);
|
|
8453
|
+
for (const entry of allowed) {
|
|
8454
|
+
const pill = document.createElement('span');
|
|
8455
|
+
pill.className = 'ai-chat-connector-pill';
|
|
8456
|
+
const name = document.createElement('span');
|
|
8457
|
+
name.textContent = entry.label;
|
|
8458
|
+
const revoke = button('Revoke', `shell.chat-change-allowance-revoke#${entry.key}`, 'ai-chat-connector-revoke');
|
|
8459
|
+
revoke.dataset.commandInstanceLabel = entry.label;
|
|
8460
|
+
revoke.setAttribute('aria-label', `Stop allowing changes to ${entry.label}`);
|
|
8461
|
+
revoke.dataset.tip = readOnly ? `Remove the saved allowance for ${entry.label}. Read only continues to block file tools.` : `The AI will ask you again before it changes ${entry.label}.`;
|
|
8462
|
+
revoke.disabled = state.changeRevoking === entry.key;
|
|
8463
|
+
if (revoke.disabled) revoke.dataset.blockedReason = 'Revoking file-change allowance…';
|
|
8464
|
+
revoke.addEventListener('click', () => { void revokeChangeAllowance(entry); });
|
|
8465
|
+
pill.append(name, revoke);
|
|
8466
|
+
host.append(pill);
|
|
8467
|
+
}
|
|
8468
|
+
}
|
|
8469
|
+
|
|
8470
|
+
async function revokeChangeAllowance(entry) {
|
|
8471
|
+
const snapshot = captureChat();
|
|
8472
|
+
if (!snapshot) return;
|
|
8473
|
+
const revokingKey = entry.key ?? 'all';
|
|
8474
|
+
state.changeRevoking = revokingKey;
|
|
8475
|
+
paintChangeAllowance();
|
|
8476
|
+
try {
|
|
8477
|
+
const result = await request(`/api/chat/conversations/${encodeURIComponent(snapshot.chatId)}/change-allowance/revoke`, {
|
|
8478
|
+
method: 'POST', body: JSON.stringify({ owner: snapshot.scope.owner, key: entry.key }),
|
|
8479
|
+
});
|
|
8480
|
+
if (!sameChat(snapshot)) return;
|
|
8481
|
+
// Only the server's own record, without that project, may say it ended.
|
|
8482
|
+
const updated = result?.chat;
|
|
8483
|
+
if (!updated || updated.chatId !== snapshot.chatId || (entry.key === null
|
|
8484
|
+
? updated.changeAllowance?.allowedForChat || (updated.changeAllowance?.allowed || []).length
|
|
8485
|
+
: (updated.changeAllowance?.allowed || []).some((row) => row.key === entry.key))) {
|
|
8486
|
+
report(new Error(`FloLess could not confirm that ${entry.label} will ask again. Choose Revoke again.`), 'Could not revoke');
|
|
8487
|
+
return;
|
|
8488
|
+
}
|
|
8489
|
+
state.chat = { ...state.chat, changeAllowance: updated.changeAllowance };
|
|
8490
|
+
if (state.scopeViewChatId === snapshot.chatId && state.scopeView) state.scopeView.changeAllowance = updated.changeAllowance;
|
|
8491
|
+
announce(entry.key === null ? 'File change approval is restored where your permission setting requires it. Your home folder keeps its current permissions. Actions already approved may finish.' : `The AI will ask you again before it changes ${entry.label}.`);
|
|
8492
|
+
state.changeRevoking = null;
|
|
8493
|
+
paintChangeAllowance();
|
|
8494
|
+
(ui.changeAllowance?.querySelector('.ai-chat-connector-revoke') || ui.input)?.focus();
|
|
8495
|
+
} catch (error) {
|
|
8496
|
+
if (sameChat(snapshot)) report(error, 'Could not revoke');
|
|
8497
|
+
} finally {
|
|
8498
|
+
if (state.changeRevoking === revokingKey) state.changeRevoking = null;
|
|
8499
|
+
paintChangeAllowance();
|
|
8500
|
+
}
|
|
8501
|
+
}
|
|
8502
|
+
|
|
8503
|
+
// #1900: the connection checks this conversation may run without asking, each with its own Revoke (and Revoke all).
|
|
8504
|
+
function checkGrantKey(grant) { return `${grant.agent}${grant.alias ? `.${grant.alias}` : ''}`; }
|
|
8505
|
+
function checkGrantLabel(grant) { return `${grant.name || grant.agent} · ${grant.identity || grant.alias || 'this computer'}`; }
|
|
8506
|
+
|
|
8507
|
+
function paintCheckAllowance() {
|
|
8508
|
+
const host = ui.checkAllowance;
|
|
8509
|
+
if (!host) return;
|
|
8510
|
+
const chat = state.chat;
|
|
8511
|
+
const grants = chat && !chat.archivedAt && Array.isArray(chat.integrationReadAllowance?.grants) ? chat.integrationReadAllowance.grants : [];
|
|
8512
|
+
const painted = `${chat?.chatId || ''}|${grants.map((grant) => `${checkGrantKey(grant)}:${grant.identity || ''}`).join(',')}|${state.checkRevoking || ''}`;
|
|
8513
|
+
if (host.dataset.painted === painted) return;
|
|
8514
|
+
host.dataset.painted = painted;
|
|
8515
|
+
host.replaceChildren();
|
|
8516
|
+
host.hidden = !grants.length;
|
|
8517
|
+
if (!grants.length) return;
|
|
8518
|
+
const title = document.createElement('span');
|
|
8519
|
+
title.className = 'ai-chat-connectors-title';
|
|
8520
|
+
title.textContent = 'Checks allowed for this chat:';
|
|
8521
|
+
host.append(title);
|
|
8522
|
+
for (const grant of grants) {
|
|
8523
|
+
const pill = document.createElement('span');
|
|
8524
|
+
pill.className = 'ai-chat-connector-pill';
|
|
8525
|
+
const name = document.createElement('span');
|
|
8526
|
+
name.textContent = checkGrantLabel(grant);
|
|
8527
|
+
const key = checkGrantKey(grant);
|
|
8528
|
+
const who = grant.name || grant.agent;
|
|
8529
|
+
const revoke = button('Revoke', `shell.chat-check-allowance-revoke#${key}`, 'ai-chat-connector-revoke');
|
|
8530
|
+
revoke.dataset.commandInstanceLabel = checkGrantLabel(grant);
|
|
8531
|
+
revoke.setAttribute('aria-label', `Stop allowing checks of ${checkGrantLabel(grant)}`);
|
|
8532
|
+
revoke.dataset.tip = `Chat will ask you again before it checks ${who}.`;
|
|
8533
|
+
revoke.disabled = Boolean(state.checkRevoking);
|
|
8534
|
+
revoke.addEventListener('click', () => { void revokeCheckAllowance(grant); });
|
|
8535
|
+
pill.append(name, revoke);
|
|
8536
|
+
host.append(pill);
|
|
8537
|
+
}
|
|
8538
|
+
if (grants.length > 1) {
|
|
8539
|
+
const all = button('Revoke all', 'shell.chat-check-allowance-revoke-all', 'ai-chat-connector-revoke');
|
|
8540
|
+
all.setAttribute('aria-label', 'Stop allowing every connection check in this chat');
|
|
8541
|
+
all.dataset.tip = 'Chat will ask you again before every connection check in this conversation.';
|
|
8542
|
+
all.disabled = Boolean(state.checkRevoking);
|
|
8543
|
+
all.addEventListener('click', () => { void revokeCheckAllowance(null); });
|
|
8544
|
+
host.append(all);
|
|
8545
|
+
}
|
|
8546
|
+
}
|
|
8547
|
+
|
|
8548
|
+
/** Ends one grant (or, with none named, all of them). Only the server's own record, without it, may say it ended. */
|
|
8549
|
+
async function revokeCheckAllowance(grant) {
|
|
8550
|
+
const snapshot = captureChat();
|
|
8551
|
+
if (!snapshot || state.checkRevoking) return;
|
|
8552
|
+
const key = grant ? checkGrantKey(grant) : '*';
|
|
8553
|
+
state.checkRevoking = key;
|
|
8554
|
+
paintCheckAllowance();
|
|
8555
|
+
try {
|
|
8556
|
+
const result = await request(`/api/chat/conversations/${encodeURIComponent(snapshot.chatId)}/integration-read-allowance/revoke`, {
|
|
8557
|
+
method: 'POST', body: JSON.stringify(grant ? { owner: snapshot.scope.owner, agent: grant.agent, alias: grant.alias ?? null } : { owner: snapshot.scope.owner }),
|
|
8558
|
+
});
|
|
8559
|
+
if (!sameChat(snapshot)) return;
|
|
8560
|
+
const updated = result?.chat;
|
|
8561
|
+
const left = updated?.integrationReadAllowance?.grants || [];
|
|
8562
|
+
if (!updated || updated.chatId !== snapshot.chatId || (grant ? left.some((row) => checkGrantKey(row) === key) : left.length)) {
|
|
8563
|
+
report(new Error(grant ? `FloLess could not confirm that checks of ${grant.name || grant.agent} will ask again. Choose Revoke again.`
|
|
8564
|
+
: 'FloLess could not confirm that every connection check will ask again. Choose Revoke all again.'), 'Could not revoke');
|
|
8565
|
+
return;
|
|
8566
|
+
}
|
|
8567
|
+
state.chat = { ...state.chat, integrationReadAllowance: updated.integrationReadAllowance };
|
|
8568
|
+
announce(grant ? `Chat will ask you again before it checks ${grant.name || grant.agent}.` : 'Chat will ask you again before every connection check.');
|
|
8569
|
+
state.checkRevoking = null;
|
|
8570
|
+
paintCheckAllowance();
|
|
8571
|
+
// The pressed Revoke is gone with its pill: keep keyboard focus on the next one, or on the message box.
|
|
8572
|
+
(ui.checkAllowance?.querySelector('.ai-chat-connector-revoke') || ui.input)?.focus();
|
|
8573
|
+
} catch (error) {
|
|
8574
|
+
if (sameChat(snapshot)) report(error, 'Could not revoke');
|
|
8575
|
+
} finally {
|
|
8576
|
+
if (state.checkRevoking === key) state.checkRevoking = null;
|
|
8577
|
+
paintCheckAllowance();
|
|
8578
|
+
}
|
|
8579
|
+
}
|
|
8580
|
+
|
|
7056
8581
|
async function turnOffOwnConnectors() {
|
|
7057
8582
|
state.ownConnectorsSaving = true;
|
|
7058
8583
|
paintConnectorAllowance();
|
|
@@ -7229,7 +8754,7 @@
|
|
|
7229
8754
|
// The earlier model name is deliberately left out: the open model may have changed since, and
|
|
7230
8755
|
// the AI would repeat a stale name as current. A fresh read shows the name at that moment.
|
|
7231
8756
|
return `Earlier FloLess check: reading the open model name through the Tekla model library at ${receipt.sourcePath} `
|
|
7232
|
-
+ `worked (Tekla ${receipt.hostVersion}${checked}). The generated
|
|
8757
|
+
+ `worked (Tekla ${receipt.hostVersion}${checked}). The generated tool's commands remain unverified. `
|
|
7233
8758
|
+ 'You can ask to read the open model name or the parts I have selected in Tekla. Help me use these reads in this project.';
|
|
7234
8759
|
}
|
|
7235
8760
|
|
|
@@ -7242,10 +8767,8 @@
|
|
|
7242
8767
|
closeSource(); clearLiveStream(true);
|
|
7243
8768
|
state.chat = null; state.events = []; state.attachments = []; state.integrations = null; state.capability = null;
|
|
7244
8769
|
updateOffscreenActivity();
|
|
7245
|
-
//
|
|
7246
|
-
|
|
7247
|
-
// Nor the left chat's "connectors are on" line and its allowances (#1907).
|
|
7248
|
-
paintConnectorAllowance();
|
|
8770
|
+
// What the left chat painted above the composer is cleared by providerChooser(), which every route onto
|
|
8771
|
+
// the chooser runs (#1958) — not only this one.
|
|
7249
8772
|
}
|
|
7250
8773
|
|
|
7251
8774
|
// Graft receipt → unsent Chat draft. Opening performs no binding, sends nothing and never
|
|
@@ -7372,6 +8895,13 @@
|
|
|
7372
8895
|
if (event.key === 'Enter' && !event.shiftKey && !event.isComposing) { event.preventDefault(); sendTurn(); }
|
|
7373
8896
|
else if (event.key === 'Escape') { ui.skills.hidden = true; closePicker(); }
|
|
7374
8897
|
});
|
|
8898
|
+
ui.scopeToggle?.addEventListener('click', () => { void openScopePicker(); });
|
|
8899
|
+
ui.scopePicker?.addEventListener('keydown', (event) => {
|
|
8900
|
+
if (event.key === 'Escape') { event.preventDefault(); closeScopePicker(true); }
|
|
8901
|
+
});
|
|
8902
|
+
document.addEventListener('pointerdown', (event) => {
|
|
8903
|
+
if (state.scopePickerOpen && !ui.scopeControls?.contains(event.target)) closeScopePicker();
|
|
8904
|
+
});
|
|
7375
8905
|
// Capture phase: the control's own handler runs after, so a sentence it reports is held afresh.
|
|
7376
8906
|
shell.addEventListener('click', releaseReportOnControl, true);
|
|
7377
8907
|
shell.addEventListener('dragover', (event) => { if (event.dataTransfer?.types.includes('Files')) event.preventDefault(); });
|
|
@@ -7429,7 +8959,7 @@
|
|
|
7429
8959
|
paintAttachments();
|
|
7430
8960
|
});
|
|
7431
8961
|
window.flolessChat = {
|
|
7432
|
-
refreshScope, refreshActivity, refreshIndex, startRequest, openConversation, openDraft, openVerifiedTeklaDraft,
|
|
8962
|
+
refreshScope, refreshActivity, refreshIndex, startRequest, openConversation, openConversationIn, openDraft, openVerifiedTeklaDraft,
|
|
7433
8963
|
startProjectIntake, resumeProjectIntake,
|
|
7434
8964
|
// The plain-English sentence for a refusal the chat routes named, so a Start outside this panel
|
|
7435
8965
|
// (the upload modal, Requests) says what happened and what to do next instead of a generic toast (#1779).
|