@floless/app 0.150.0 → 0.152.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 +19075 -10744
- package/dist/skills/floless-app-knowledge/SKILL.md +25 -2
- package/dist/skills/floless-app-onboarding/SKILL.md +217 -87
- package/dist/skills/floless-app-onboarding/references/aware-runtime.md +27 -18
- package/dist/skills/floless-app-onboarding/references/floless-surfaces.md +207 -0
- package/dist/skills/floless-app-report-issue/SKILL.md +10 -5
- package/dist/skills/floless-app-routines/SKILL.md +1 -1
- package/dist/skills/floless-app-routines/references/routines-api.md +14 -4
- package/dist/templates/revit-model.flo +6 -2
- package/dist/templates/tekla-parser.flo +6 -2
- package/dist/web/agents.js +254 -21
- package/dist/web/app.css +308 -39
- package/dist/web/app.js +67 -115
- package/dist/web/aware.js +1309 -110
- package/dist/web/chat.css +110 -4
- package/dist/web/chat.js +638 -46
- package/dist/web/commands-shell.js +482 -25
- package/dist/web/connections.js +24 -6
- package/dist/web/flo-avatar.js +191 -0
- package/dist/web/flo.js +156 -0
- package/dist/web/guide.js +1313 -0
- package/dist/web/index.html +120 -9
- package/dist/web/instructor.js +14 -3
- package/dist/web/local-discovery.js +35 -6
- package/dist/web/panels.js +2 -0
- package/dist/web/parser-setup-recovery.js +250 -0
- package/dist/web/tool-updates.js +373 -13
- package/dist/web/workspace-root-management.js +197 -0
- package/dist/web/workspaces.js +452 -79
- package/package.json +2 -2
- package/dist/skills/floless-app-onboarding/references/floless-app-tour.md +0 -158
package/dist/web/chat.js
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
historyToggle: el('chat-history-toggle'), newChat: el('chat-new'), refresh: el('chat-refresh'), history: el('chat-history'),
|
|
20
20
|
title: el('chat-title'), rename: el('chat-rename'), scope: el('chat-scope'), settingsToggle: el('chat-settings-toggle'),
|
|
21
21
|
settings: el('chat-settings'), provider: el('chat-provider'), switchAccount: el('chat-switch-account'), model: el('chat-model'),
|
|
22
|
-
effort: el('chat-effort'), permission: el('chat-permission'), integrations: el('chat-integrations'), ownConnectors: el('chat-own-connectors'),
|
|
22
|
+
effort: el('chat-effort'), permission: el('chat-permission'), guideAccess: el('chat-guide-access'), integrations: el('chat-integrations'), ownConnectors: el('chat-own-connectors'),
|
|
23
23
|
desktopValue: el('chat-desktop-value'), desktopReason: el('chat-desktop-reason'), picker: el('chat-picker'),
|
|
24
24
|
feed: el('chat-feed'), offscreenActivity: el('chat-offscreen-activity'), recovery: el('chat-recovery'),
|
|
25
25
|
approvalTray: el('chat-approval-tray'), recoveryCopy: el('chat-recovery-copy'),
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
instructorAnswers: [], historyLoading: false, historyRequestGeneration: 0, picker: null, loading: false,
|
|
55
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,
|
|
56
56
|
answerJump: null, answerJumpTimer: null, scopeInitialized: false, renaming: null, historyRename: null, pendingSubmissionId: null, recoveryMessage: null, recoveryCanEnd: false,
|
|
57
|
-
stream: null, liveStatusTurnId: null, decidingApprovalIds: new Set(), revokingApprovalTurns: new Set(), uploadingChatIds: new Set(),
|
|
57
|
+
stream: null, liveStatusTurnId: null, liveFlo: null, decidingApprovalIds: new Set(), revokingApprovalTurns: new Set(), uploadingChatIds: new Set(),
|
|
58
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.
|
|
59
59
|
teklaLinks: { ownerKey: '', state: 'idle', links: [], partial: false, inflight: false, again: false }, teklaHistoryUi: {}, teklaHistoryHost: null,
|
|
60
60
|
// Latched so the 5 s account poll logs an outage once instead of twelve times a minute; cleared
|
|
@@ -87,8 +87,9 @@
|
|
|
87
87
|
}).observe(tray);
|
|
88
88
|
}
|
|
89
89
|
keepApprovalTrayDecisionVisible(ui.approvalTray);
|
|
90
|
+
// #2037: safest to widest; Auto is the default for a project or workflow conversation.
|
|
90
91
|
const permissionLabels = {
|
|
91
|
-
'read-only': 'Read only', 'workspace-write': 'Working folder write', 'full-access': 'Full access',
|
|
92
|
+
'read-only': 'Read only', auto: 'Auto', 'workspace-write': 'Working folder write', 'full-access': 'Full access',
|
|
92
93
|
};
|
|
93
94
|
const providerLabels = { claude: 'Claude', codex: 'Codex' };
|
|
94
95
|
// The one sign-in refusal FloLess re-words. 'chat-turn-active' is the same code every other chat
|
|
@@ -102,7 +103,7 @@
|
|
|
102
103
|
// runtime problem happened and WHICH command to run by hand. errorMessage() would flatten it.
|
|
103
104
|
const SERVER_WORDED_SIGN_IN_CODES = new Set(['runtime-unavailable', 'launch-failed', 'launch-unsafe', 'sign-in-active', 'sign-out-failed']);
|
|
104
105
|
const requestTypeLabels = { 'drawing-intake': 'Initial drawing read', 'initial-drawing-read': 'Initial drawing read', 'tweak-contract': 'Workflow change', guide: 'Question' };
|
|
105
|
-
const requestStatusLabels = { pending: 'Queued', queued: 'Queued', running: 'Running', ready: 'Ready', completed: 'Complete', failed: 'Failed', stopped: 'Stopped' };
|
|
106
|
+
const requestStatusLabels = { pending: 'Queued', queued: 'Queued', running: 'Running', ready: 'Ready', completed: 'Complete', failed: 'Failed', stopped: 'Stopped', finished: 'Finished', 'left-queue': 'Left the queue' };
|
|
106
107
|
// Pictures and PDFs upload as the browser names them. Any other file is a DATA file (#1853): its
|
|
107
108
|
// bytes decide whether FloLess can read it (sniffDataFile), never its name or declared type.
|
|
108
109
|
const allowedTypes = new Set(['image/png', 'image/jpeg', 'image/webp', 'application/pdf']);
|
|
@@ -155,6 +156,8 @@
|
|
|
155
156
|
error.code = body?.code || null;
|
|
156
157
|
error.reason = body?.reason || null;
|
|
157
158
|
error.recovery = Array.isArray(body?.recovery) ? body.recovery : null;
|
|
159
|
+
// #2061: who holds a busy project, so the person can be asked: wait, stop it, or open it.
|
|
160
|
+
error.holder = body?.holder && typeof body.holder === 'object' ? body.holder : null;
|
|
158
161
|
error.status = response.status;
|
|
159
162
|
// #1890 PR 3b: the conversation moved — wherever this was asked from, the open tab follows it.
|
|
160
163
|
if (error.code === 'chat-moved' && body?.to?.chatId) {
|
|
@@ -234,6 +237,10 @@
|
|
|
234
237
|
'chat-followup-not-found': 'This message is no longer in this conversation. Refresh the conversation.',
|
|
235
238
|
'chat-attachment-scope': 'An attached file is no longer available to this message. Add the file again in a new message.',
|
|
236
239
|
'chat-initiator-unknown': 'FloLess could not identify what started this conversation. Reload the conversation and try again.',
|
|
240
|
+
// #2059: an Instructor answer uses no tools until the person confirms a wider Access.
|
|
241
|
+
'chat-instructor-answer-access': 'This chat is an Instructor answer, so the AI uses no tools. Confirm the Access change to turn it into an ordinary chat.',
|
|
242
|
+
'chat-instructor-answer-accounts': 'An Instructor answer uses no tools, so it cannot use a connected account. Start a new chat to use one.',
|
|
243
|
+
'chat-guide-read-only': 'The Guide only reads, so its Access stays Read only. To let the AI change things, use a regular conversation.',
|
|
237
244
|
// Damage the user can act on, unlike the refusals below it: the conversation history lists this
|
|
238
245
|
// same record as a row offering Discard, so the sentence sends them there (#1629). Without an
|
|
239
246
|
// entry here the code fell through to the generic "could not complete this chat action", which
|
|
@@ -259,6 +266,8 @@
|
|
|
259
266
|
'chat-provider-identity-changed': 'The connected AI account changed while this response was running. Refresh the conversation and try again.',
|
|
260
267
|
'chat-integration-unavailable': 'Connected accounts are unavailable right now. Open Integrations and try again.',
|
|
261
268
|
'chat-integration-input-invalid': 'The connected account request was not valid. Check Integrations and try again.',
|
|
269
|
+
// #2153: the same words the server gives the AI (AWARE's 2,048-byte limit on a text input).
|
|
270
|
+
'chat-integration-input-too-long': 'The search text is too long for this account read: it can be at most 2,048 bytes. Shorten it and try again.',
|
|
262
271
|
'chat-integration-limit-invalid': 'The connected account request was too large. Remove some items and try again.',
|
|
263
272
|
'chat-integration-stale': 'This connected account needs attention. Reconnect it in Integrations, then try again.',
|
|
264
273
|
'chat-integration-not-runnable': 'This connected account cannot be used right now. Check Integrations and try again.',
|
|
@@ -303,6 +312,12 @@
|
|
|
303
312
|
if (code === 'chat-owner-busy' || /project or workflow already has a modifying chat turn/i.test(raw)) {
|
|
304
313
|
return 'Another AI Chat is changing this project or workflow. Wait for it to finish or stop it before sending here.';
|
|
305
314
|
}
|
|
315
|
+
if (code === 'chat-project-run-busy') {
|
|
316
|
+
return 'A background request is changing this project. Wait for it to finish, or stop it, before sending here.';
|
|
317
|
+
}
|
|
318
|
+
if (code === 'chat-project-waiting') {
|
|
319
|
+
return 'A background request is already waiting to change this project. Let it go first, or send your message now.';
|
|
320
|
+
}
|
|
306
321
|
if (code === 'chat-host-busy' || /host application instance already has a modifying owner/i.test(raw)) {
|
|
307
322
|
return 'Another task is using the connected design application. Wait for it to finish or stop it before trying again.';
|
|
308
323
|
}
|
|
@@ -375,6 +390,8 @@
|
|
|
375
390
|
function capabilityMessage(provider, reason) {
|
|
376
391
|
const label = providerLabels[provider] || 'AI service';
|
|
377
392
|
const raw = String(reason || '');
|
|
393
|
+
// A check that timed out (this computer or FloLess was busy) says nothing about the AI: say that, not "not ready".
|
|
394
|
+
if (/timed out|took too long|computer was busy|\bis busy\b/i.test(raw)) return `FloLess couldn’t finish checking ${label} because this computer was busy. Try again in a moment.`;
|
|
378
395
|
if (signInNeeded(raw)) return `Sign in to ${label} first.`;
|
|
379
396
|
if (/EPERM|EACCES|ENOENT|ENOTDIR|operation not permitted|permission denied|watch ['"]/i.test(raw)) {
|
|
380
397
|
return 'FloLess cannot open this conversation’s project or workflow folder. Restore or reconnect that folder, then try again.';
|
|
@@ -2216,11 +2233,17 @@
|
|
|
2216
2233
|
/** A refusal FloLess wrote for the person (`plain`), shown as is: what happened, why, and what to do next. */
|
|
2217
2234
|
function renderPlainNotice(event) {
|
|
2218
2235
|
const item = document.createElement('div');
|
|
2219
|
-
|
|
2236
|
+
// #2037: a Codex auto-review decision is a receipt, not a failure: approved is information, held back is a notice.
|
|
2237
|
+
const review = event.payload?.tool === 'auto-review' ? event.payload.decision : null;
|
|
2238
|
+
// #2035: a step declined because nobody was watching a scheduled run is a notice the person reads later, not an error.
|
|
2239
|
+
const unattended = event.payload?.tool === 'unattended-decline';
|
|
2240
|
+
// #2058: an account command Codex ran without asking FloLess already ran; its line says the result is unchecked.
|
|
2241
|
+
const unchecked = event.payload?.tool === 'unchecked-command';
|
|
2242
|
+
item.className = review === 'approved' ? 'ai-chat-event auto-review' : review || unattended || unchecked ? 'ai-chat-event auto-review held' : 'ai-chat-event error';
|
|
2220
2243
|
item.dataset.eventSequence = String(event.sequence);
|
|
2221
2244
|
item.dataset.eventId = event.eventId;
|
|
2222
2245
|
const label = document.createElement('strong');
|
|
2223
|
-
label.textContent = 'Not done';
|
|
2246
|
+
label.textContent = review === 'approved' ? 'Auto-approved' : review ? 'Held back' : unattended ? 'Declined' : unchecked ? 'Not checked' : 'Not done';
|
|
2224
2247
|
item.append(label, document.createTextNode(` · ${event.payload.message}`));
|
|
2225
2248
|
return item;
|
|
2226
2249
|
}
|
|
@@ -2232,7 +2255,7 @@
|
|
|
2232
2255
|
item.dataset.eventSequence = String(event.sequence);
|
|
2233
2256
|
item.dataset.eventId = event.eventId;
|
|
2234
2257
|
const label = document.createElement('strong');
|
|
2235
|
-
label.textContent = 'Agent run';
|
|
2258
|
+
label.textContent = event.payload.tool === 'guide' || event.payload.tool === 'instructor' ? 'FloLess' : 'Agent run';
|
|
2236
2259
|
item.append(label, document.createTextNode(` · ${String(event.payload.message || '')}`));
|
|
2237
2260
|
return item;
|
|
2238
2261
|
}
|
|
@@ -2326,8 +2349,12 @@
|
|
|
2326
2349
|
const service = payload.targetKind === 'host' || !services ? null : services.find((row) => row.id === payload.target) || null;
|
|
2327
2350
|
const alias = payload.targetKind === 'host' ? null : service?.choice?.source === 'floless' ? (service.choice.alias ?? null) : undefined;
|
|
2328
2351
|
const receipt = payload.checkAgent && alias !== undefined ? connectionsApi()?.cachedReceipt(payload.checkAgent, alias) : null;
|
|
2352
|
+
// #2056: a card for a service used through the person's own connector follows this chat's switch, and its reply.
|
|
2353
|
+
const chat = state.chat;
|
|
2329
2354
|
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
|
|
2355
|
+
connectionLive.error, receipt?.probedAt || null, receipt?.state || null, entry.error, entry.busy,
|
|
2356
|
+
chat?.provider || null, chat?.settings?.useOwnConnectors === true, Boolean(chat?.activeTurn), chat?.integrationBindings?.length || 0,
|
|
2357
|
+
Boolean(chat?.archivedAt), state.ownConnectorsSaving === true]);
|
|
2331
2358
|
if (entry.node && entry.signature === signature) return entry.node;
|
|
2332
2359
|
// A check running, or its inline question open, lives in this node: keep it until it settles.
|
|
2333
2360
|
if (entry.node && entry.node.querySelector('[aria-busy="true"], [aria-expanded="true"]')) return entry.node;
|
|
@@ -2459,7 +2486,32 @@
|
|
|
2459
2486
|
} else if (!services.choicesUnreadable && service.choice?.source === 'native') {
|
|
2460
2487
|
// Their own Claude/Codex connection is the choice, whatever FloLess's own accounts look like (#1900 review): the
|
|
2461
2488
|
// way out is Change account, never Connect or Reconnect of an account FloLess was told not to use.
|
|
2462
|
-
|
|
2489
|
+
// #2056: and the choice leads somewhere: this conversation's own-connectors switch, offered in place.
|
|
2490
|
+
const chat = state.chat;
|
|
2491
|
+
const provider = providerLabels[chat?.provider] || 'Claude or Codex';
|
|
2492
|
+
const heldOff = Boolean(chat?.integrationBindings?.length);
|
|
2493
|
+
const on = !heldOff && chat?.settings?.useOwnConnectors === true;
|
|
2494
|
+
const chosen = `You chose your own Claude or Codex connection for ${name}, so FloLess won’t use one of its own accounts for it.`;
|
|
2495
|
+
// FloLess cannot see whether a connector for it exists (it never sees Claude's), so the card says "can use … if".
|
|
2496
|
+
title.textContent = heldOff ? `Your own connector for ${name} is off in this chat`
|
|
2497
|
+
: on ? `Your ${provider} connectors are on for ${name}` : `Use your own ${provider} connector for ${name}?`;
|
|
2498
|
+
stateLine.textContent = heldOff ? `${chosen} This chat uses a FloLess connected account, so your own connectors stay off here. To use your own, stop using that account in this chat’s Connected accounts (chat settings ⚙).`
|
|
2499
|
+
: on ? `${chosen} Your ${provider} connectors are on in this chat, so the AI can use yours for it if you have one. Every call asks you first.`
|
|
2500
|
+
: `${chosen} Your ${provider} connectors are off in this chat; turn them on so the AI can use yours for it if you have one. Every call still asks you first.`;
|
|
2501
|
+
if (!heldOff && !on) {
|
|
2502
|
+
const turnOn = connectionButton('Use my connectors in this chat', 'shell.chat-connection-own-connectors', target, name, 'ai-chat-filter-apply');
|
|
2503
|
+
// The accessible name starts with the visible words (WCAG 2.5.3), so a voice command that says them works.
|
|
2504
|
+
turnOn.setAttribute('aria-label', `Use my connectors in this chat, for ${name} (${provider})`);
|
|
2505
|
+
const blocked = !chat ? 'Open a conversation first.'
|
|
2506
|
+
: chat.archivedAt ? 'This conversation is archived, so its settings can’t change.'
|
|
2507
|
+
: chat.activeTurn ? 'Wait for the current AI reply to finish before changing this.'
|
|
2508
|
+
: state.ownConnectorsSaving === true ? 'Turning your connectors on…' : '';
|
|
2509
|
+
turnOn.disabled = Boolean(blocked);
|
|
2510
|
+
turnOn.dataset.tip = blocked || `Turns on the connectors you added to ${provider} for this conversation only. Each call still asks you first.`;
|
|
2511
|
+
if (blocked) turnOn.dataset.blockedReason = blocked;
|
|
2512
|
+
turnOn.addEventListener('click', () => { void turnOnOwnConnectorsFromCard(); });
|
|
2513
|
+
actions.append(turnOn);
|
|
2514
|
+
}
|
|
2463
2515
|
actions.append(integrations('Change account', 'shell.chat-connection-change-account', `Opens Integrations at ${name}, where you choose the account FloLess uses.`));
|
|
2464
2516
|
} else if (api.signInExpired(service)) {
|
|
2465
2517
|
stateLine.textContent = `The sign-in for ${name} expired. Reconnect it in Integrations, then check it works.`;
|
|
@@ -2621,6 +2673,8 @@
|
|
|
2621
2673
|
if (event.type === 'connection-proposal') return renderConnectionProposal(event);
|
|
2622
2674
|
if (event.type === 'connection-proposal-update') return null;
|
|
2623
2675
|
if (event.type === 'connection-check') return renderConnectionCheck(event);
|
|
2676
|
+
// #2046: a next move the Guide suggested; web/guide.js paints it and owns its button.
|
|
2677
|
+
if (event.type === 'next-move') return window.flolessGuide?.renderNextMove?.(event) || null;
|
|
2624
2678
|
if (event.type === 'approval-decided' && event.payload?.automatic === true && event.payload?.connectionCheck) return renderConnectionCheckAllowed(event);
|
|
2625
2679
|
if (event.type === 'assistant-message') return renderMessage(event, 'assistant', payloadText(event), Boolean(event.payload?.delta));
|
|
2626
2680
|
// #1907: a connector call that ran under "Allow for this chat" leaves a visible receipt; every other decision is audit only.
|
|
@@ -2630,7 +2684,7 @@
|
|
|
2630
2684
|
// #1890 PR 3a: a decided workflow create stays visible as one line, so a reload never shows it as pending.
|
|
2631
2685
|
if (event.type === 'approval-decided' && event.payload?.create) return renderCreateReceipt(event);
|
|
2632
2686
|
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
|
|
2687
|
+
if (event.type === 'tool' && ['agent', 'guide', 'instructor'].includes(event.payload?.tool) && typeof event.payload?.message === 'string') return renderAgentRunLine(event);
|
|
2634
2688
|
if (event.type === 'tekla-read') return renderTeklaReadEvent(event);
|
|
2635
2689
|
if (event.type === 'height-question') return renderHeightQuestion(event);
|
|
2636
2690
|
if (event.type === 'setup-question') return renderSetupQuestion(event);
|
|
@@ -4387,19 +4441,46 @@
|
|
|
4387
4441
|
return time;
|
|
4388
4442
|
}
|
|
4389
4443
|
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4444
|
+
// #2079: Flo shows what the AI is doing in this turn, from the events the feed already has. Working, with its hat
|
|
4445
|
+
// on, while a tool it started has not reported an end; Thinking otherwise. FloLess's own receipts (plain lines, an
|
|
4446
|
+
// agent run's or the Guide's opening line) are not the AI's tools. While the AI waits for the person to answer an
|
|
4447
|
+
// approval it is doing nothing: Flo idles, and the approval card's Flo asks. Claude never reports a tool's end, so
|
|
4448
|
+
// writing again ends it, and so does a declined approval (it never will run). Codex ends each tool by its own item
|
|
4449
|
+
// id (#2102), so one finishing does not end another running beside it.
|
|
4450
|
+
const TOOL_ENDED = new Set(['completed', 'failed', 'denied', 'declined', 'error']);
|
|
4451
|
+
function liveFloMood() {
|
|
4452
|
+
if (state.chat?.state === 'awaiting-approval' || state.chat?.pendingApproval) return 'idle';
|
|
4453
|
+
const turnId = state.chat?.activeTurn?.turnId;
|
|
4454
|
+
// Codex ends every tool itself, by its item id; Claude never does, so for Claude writing again or a declined
|
|
4455
|
+
// approval is what ends it.
|
|
4456
|
+
const endsItsOwnTools = state.chat?.provider === 'codex';
|
|
4457
|
+
const running = new Set();
|
|
4458
|
+
for (const event of state.events) {
|
|
4459
|
+
if (event.turnId !== turnId) continue;
|
|
4460
|
+
if (event.type === 'assistant-message') { if (!endsItsOwnTools) running.clear(); }
|
|
4461
|
+
else if (event.type === 'approval-decided') { if (event.payload?.decision !== 'allow' && !endsItsOwnTools) running.clear(); }
|
|
4462
|
+
else if (event.type === 'tool' && event.payload?.plain !== true && event.payload?.tool !== 'agent' && event.payload?.tool !== 'guide') {
|
|
4463
|
+
const key = event.providerItemId || event.eventId || event.payload?.tool;
|
|
4464
|
+
if (TOOL_ENDED.has(event.payload?.status)) running.delete(key); else running.add(key);
|
|
4465
|
+
}
|
|
4466
|
+
}
|
|
4467
|
+
return running.size ? 'working' : 'thinking';
|
|
4394
4468
|
}
|
|
4395
4469
|
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4470
|
+
// The feed is rebuilt on every event, so the live row is one kept node: Flo carries on instead of restarting
|
|
4471
|
+
// on every streamed word. The row is decoration; announceLiveResponseOnce speaks for it.
|
|
4472
|
+
function renderLiveStatus() {
|
|
4473
|
+
if (!state.liveFlo) {
|
|
4474
|
+
const item = document.createElement('div'); item.className = 'ai-chat-live-status';
|
|
4475
|
+
item.setAttribute('aria-hidden', 'true');
|
|
4476
|
+
const label = document.createElement('span'); label.className = 'ai-chat-live-label';
|
|
4477
|
+
item.append(label);
|
|
4478
|
+
state.liveFlo = { item, flo: typeof floAvatar === 'function' ? floAvatar(item, { size: 22, mood: 'thinking', hatRoom: true }) : null };
|
|
4479
|
+
}
|
|
4480
|
+
const mood = liveFloMood();
|
|
4481
|
+
state.liveFlo.item.dataset.mood = mood;
|
|
4482
|
+
state.liveFlo.flo?.setMood(mood, mood === 'working');
|
|
4483
|
+
return state.liveFlo.item;
|
|
4403
4484
|
}
|
|
4404
4485
|
|
|
4405
4486
|
function announceLiveResponseOnce() {
|
|
@@ -4454,7 +4535,7 @@
|
|
|
4454
4535
|
}
|
|
4455
4536
|
|
|
4456
4537
|
function updateOffscreenActivity() {
|
|
4457
|
-
const liveDots = ui.feed.querySelector('.ai-chat-live-status
|
|
4538
|
+
const liveDots = ui.feed.querySelector('.ai-chat-live-status');
|
|
4458
4539
|
// Showing the badge claims a row below the feed. Require enough room for that row before
|
|
4459
4540
|
// showing it, otherwise ResizeObserver could alternate between show and hide in a short pane.
|
|
4460
4541
|
const minimumFeedHeight = ui.offscreenActivity.hidden ? 88 : 48;
|
|
@@ -4516,7 +4597,7 @@
|
|
|
4516
4597
|
}
|
|
4517
4598
|
// Something FloLess itself refused during the answer (a file change it declined, a connector it turned away,
|
|
4518
4599
|
// #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
|
|
4600
|
+
if (event.type === 'tool' && event.payload?.plain === true && !['agent', 'guide', 'instructor'].includes(event.payload?.tool)
|
|
4520
4601
|
&& typeof event.payload?.message === 'string' && event.payload.message) {
|
|
4521
4602
|
links.push({ turnId: event.turnId, node: renderPlainNotice(event) });
|
|
4522
4603
|
continue;
|
|
@@ -4527,13 +4608,15 @@
|
|
|
4527
4608
|
// the suggestion and a check's result are receipts like the ones below, held under the answer they were written during.
|
|
4528
4609
|
// #2007: an agent run's first line (who started it, its scope) is a tool event too, but it is the conversation's
|
|
4529
4610
|
// opening line, not a tool: shown where it was written, before the instructions.
|
|
4530
|
-
if (event.type === 'tool' && event.payload?.tool
|
|
4611
|
+
if (event.type === 'tool' && ['agent', 'guide', 'instructor'].includes(event.payload?.tool) && typeof event.payload?.message === 'string') {
|
|
4531
4612
|
flushAssistant();
|
|
4532
4613
|
ui.feed.append(renderAgentRunLine(event));
|
|
4533
4614
|
continue;
|
|
4534
4615
|
}
|
|
4535
4616
|
if (event.type === 'connection-proposal-update') continue;
|
|
4536
4617
|
if (event.type === 'connection-proposal' || event.type === 'connection-check') { links.push({ turnId: event.turnId, node: renderEvent(event) }); continue; }
|
|
4618
|
+
// #2046: the Guide's next-move cards are held under the answer they were suggested in, like the cards above.
|
|
4619
|
+
if (event.type === 'next-move') { const node = renderEvent(event); if (node) links.push({ turnId: event.turnId, node }); continue; }
|
|
4537
4620
|
if (['tool', 'usage', 'knowledge-citation', 'attachment', 'compaction', 'state'].includes(event.type)) continue;
|
|
4538
4621
|
// FloLess's own receipts (object links #1653; evidence looks and suggestion cards #1859) are written mid-answer while a tool runs:
|
|
4539
4622
|
// held and shown under the answer, so they never cut one answer into fragments.
|
|
@@ -4672,6 +4755,12 @@
|
|
|
4672
4755
|
existing?.remove();
|
|
4673
4756
|
const card = document.createElement('section'); card.className = 'ai-chat-approval';
|
|
4674
4757
|
card.dataset.approvalId = approval.approvalId;
|
|
4758
|
+
// #2079: Flo, hat on, faces the person: the AI is asking, and the person decides. Still, and never beside Allow.
|
|
4759
|
+
if (typeof floAvatar === 'function') {
|
|
4760
|
+
const flo = document.createElement('span'); flo.className = 'ai-chat-approval-flo';
|
|
4761
|
+
card.classList.add('has-flo'); card.append(flo);
|
|
4762
|
+
floAvatar(flo, { size: 28, mood: 'yourcall', hat: true });
|
|
4763
|
+
}
|
|
4675
4764
|
if (teklaBinding || connector || change || connectionCheck) card.dataset.allowanceRevision = allowanceRevision;
|
|
4676
4765
|
// #1890 PR 3a: the AI asking to create a workflow, with where it would go.
|
|
4677
4766
|
const create = approval.create && typeof approval.create === 'object' ? approval.create : null;
|
|
@@ -5540,9 +5629,18 @@
|
|
|
5540
5629
|
ui.model.querySelector('strong').textContent = chat?.settings.model ? (model?.label || chat.settings.model) : (model?.label || 'Choose model');
|
|
5541
5630
|
const medium = (model?.efforts || []).find((effort) => effort.toLowerCase() === 'medium');
|
|
5542
5631
|
ui.effort.querySelector('strong').textContent = effortLabel(chat?.settings.effort || medium || model?.efforts?.[0]) || 'Choose effort';
|
|
5543
|
-
|
|
5544
|
-
|
|
5545
|
-
|
|
5632
|
+
// #2059: an Instructor answer's AI has no tools. Its Access says so; choosing one asks first (confirmInstructorRelease).
|
|
5633
|
+
const instructorChat = isInstructorAnswer(chat);
|
|
5634
|
+
ui.permission.querySelector('strong').textContent = instructorChat ? 'No tools' : permissionLabel(chat?.settings.permissionProfile);
|
|
5635
|
+
ui.permission.dataset.tip = instructorChat
|
|
5636
|
+
? 'This chat answers an Instructor question, so the AI can’t read files, run commands, search the web or use your connectors. Choose an Access to turn it into an ordinary chat. FloLess asks first.'
|
|
5637
|
+
: permissionTip(chat?.settings.permissionProfile);
|
|
5638
|
+
// #2046: the Guide always reads only; its Access is said, not chosen, beside its Turn off and Delete.
|
|
5639
|
+
const guideChat = chat?.initiator?.kind === 'guide';
|
|
5640
|
+
ui.permission.hidden = guideChat;
|
|
5641
|
+
if (ui.guideAccess) ui.guideAccess.hidden = !guideChat;
|
|
5642
|
+
// #2053: the Guide's morning briefing lives here too; web/guide.js paints it (only when something changed).
|
|
5643
|
+
if (guideChat) window.flolessGuide?.paintBriefing?.();
|
|
5546
5644
|
paintWorkspaceUnits();
|
|
5547
5645
|
const bindings = chat?.integrationBindings || [];
|
|
5548
5646
|
ui.integrations.querySelector('strong').textContent = bindings.length
|
|
@@ -5550,8 +5648,10 @@
|
|
|
5550
5648
|
: 'Not using one';
|
|
5551
5649
|
const frozen = !chat || Boolean(chat.activeTurn) || !state.capability?.available;
|
|
5552
5650
|
ui.model.disabled = frozen; ui.effort.disabled = frozen; ui.permission.disabled = frozen;
|
|
5553
|
-
ui.integrations.disabled = frozen || Boolean(chat?.nativeSessionId);
|
|
5554
|
-
const integrationBlocked =
|
|
5651
|
+
ui.integrations.disabled = frozen || Boolean(chat?.nativeSessionId) || instructorChat;
|
|
5652
|
+
const integrationBlocked = instructorChat
|
|
5653
|
+
? 'An Instructor answer uses no tools, so it cannot use a connected account. Start a new chat to use one.'
|
|
5654
|
+
: chat?.nativeSessionId
|
|
5555
5655
|
? 'Connected accounts are fixed after the first message. Start a new chat to use another account.'
|
|
5556
5656
|
: !chat ? 'Open a conversation first.'
|
|
5557
5657
|
: chat.activeTurn ? 'Connected accounts cannot change during an active turn.'
|
|
@@ -5756,6 +5856,12 @@
|
|
|
5756
5856
|
// waiting for a follow-up fetch, which can leave a finished answer showing dots.
|
|
5757
5857
|
state.chat = { ...state.chat, state: 'completed', activeTurn: null };
|
|
5758
5858
|
paintConversation();
|
|
5859
|
+
// An answer just arrived, so the AI is reachable: a readiness check that failed earlier (it timed out while
|
|
5860
|
+
// this computer was busy) must not keep saying "not ready" under it. Read it again.
|
|
5861
|
+
if (!providerReady()) {
|
|
5862
|
+
const snapshot = captureChat();
|
|
5863
|
+
void loadCapability().then(() => { if (sameChat(snapshot)) { paintSettings(); updateSendState(); } });
|
|
5864
|
+
}
|
|
5759
5865
|
}
|
|
5760
5866
|
if (event.type === 'followup-status') {
|
|
5761
5867
|
const notices = {
|
|
@@ -6249,7 +6355,8 @@
|
|
|
6249
6355
|
const chat = await request('/api/chat/conversations', {
|
|
6250
6356
|
method: 'POST', body: JSON.stringify({
|
|
6251
6357
|
owner, provider, title: 'New chat',
|
|
6252
|
-
|
|
6358
|
+
// #2037: no access level — the server starts a project or workflow conversation in Auto, the workspace in Read only.
|
|
6359
|
+
settings: { model: null, effort: null },
|
|
6253
6360
|
initiator: { kind: 'user' },
|
|
6254
6361
|
...(displayUnitsSuggestion ? { displayUnitsSuggestion } : {}),
|
|
6255
6362
|
}),
|
|
@@ -6376,14 +6483,23 @@
|
|
|
6376
6483
|
}
|
|
6377
6484
|
|
|
6378
6485
|
function closePicker() {
|
|
6379
|
-
state.picker = null; ui.picker.hidden = true; ui.picker.replaceChildren();
|
|
6486
|
+
state.picker = null; state.pickerOpener = null; ui.picker.hidden = true; ui.picker.replaceChildren();
|
|
6487
|
+
ui.picker.removeAttribute('aria-describedby');
|
|
6380
6488
|
for (const control of [ui.model, ui.effort, ui.permission, ui.integrations]) control.setAttribute('aria-expanded', 'false');
|
|
6381
6489
|
}
|
|
6382
6490
|
|
|
6383
|
-
function
|
|
6491
|
+
function closePickerOnEscape(event) {
|
|
6492
|
+
if (event.key !== 'Escape' || ui.picker.hidden || !state.picker) return;
|
|
6493
|
+
if (!ui.picker.contains(event.target) && event.target !== state.pickerOpener) return;
|
|
6494
|
+
const opener = state.pickerOpener;
|
|
6495
|
+
event.preventDefault(); event.stopPropagation(); closePicker();
|
|
6496
|
+
if (opener?.isConnected && !opener.disabled) opener.focus();
|
|
6497
|
+
}
|
|
6498
|
+
|
|
6499
|
+
function openPicker(kind, anchor, choices, note) {
|
|
6384
6500
|
if (anchor.disabled) return;
|
|
6385
6501
|
if (state.picker === kind) { closePicker(); return; }
|
|
6386
|
-
toggleHistory(false); closePicker(); state.picker = kind;
|
|
6502
|
+
toggleHistory(false); closePicker(); state.picker = kind; state.pickerOpener = anchor;
|
|
6387
6503
|
ui.picker.replaceChildren();
|
|
6388
6504
|
for (const choice of choices) {
|
|
6389
6505
|
const row = button('', `shell.chat-choice#${commandInstance(choice.id)}`, 'ai-chat-choice');
|
|
@@ -6395,23 +6511,103 @@
|
|
|
6395
6511
|
row.addEventListener('click', async () => { closePicker(); await saveSettings(choice.patch); anchor.focus(); });
|
|
6396
6512
|
ui.picker.append(row);
|
|
6397
6513
|
}
|
|
6514
|
+
// A quiet line after the choices says why one is missing; it is not an option, so the list is described by it.
|
|
6515
|
+
if (note) {
|
|
6516
|
+
const line = document.createElement('div'); line.className = 'ai-chat-picker-note'; line.id = 'chat-picker-note'; line.textContent = note;
|
|
6517
|
+
ui.picker.append(line); ui.picker.setAttribute('aria-describedby', line.id);
|
|
6518
|
+
}
|
|
6398
6519
|
ui.picker.hidden = false; anchor.setAttribute('aria-expanded', 'true');
|
|
6399
6520
|
const selected = ui.picker.querySelector('[aria-selected="true"]') || ui.picker.querySelector('button');
|
|
6400
6521
|
selected?.focus();
|
|
6401
6522
|
}
|
|
6402
6523
|
|
|
6524
|
+
/** #2059: an Instructor-started conversation the person has not widened: its AI answers with no tools. */
|
|
6525
|
+
function isInstructorAnswer(chat) {
|
|
6526
|
+
// The server's rule (chatIsInstructorAnswer): durable facts only, never the stored settings.
|
|
6527
|
+
return chat?.initiator?.kind === 'instructor' && !chat.instructorReleasedAt;
|
|
6528
|
+
}
|
|
6529
|
+
|
|
6530
|
+
/** #2059: does this settings change give an Instructor answer's AI tools (any Access choice, or the person's connectors)? */
|
|
6531
|
+
function widensInstructorAnswer(patch) {
|
|
6532
|
+
return isInstructorAnswer(state.chat) && ('permissionProfile' in patch || patch.useOwnConnectors === true);
|
|
6533
|
+
}
|
|
6534
|
+
|
|
6535
|
+
/**
|
|
6536
|
+
* #2059: asks before an Instructor answer becomes an ordinary chat. Resolves true only on "Change…"; Escape, the
|
|
6537
|
+
* backdrop and "Keep as Instructor answer" all keep it as it is. Focus returns to whatever opened it.
|
|
6538
|
+
*/
|
|
6539
|
+
function confirmInstructorRelease(patch) {
|
|
6540
|
+
return new Promise((resolve) => {
|
|
6541
|
+
const modal = document.getElementById('chat-instructor-access-modal');
|
|
6542
|
+
const keep = document.getElementById('chat-instructor-access-keep');
|
|
6543
|
+
const go = document.getElementById('chat-instructor-access-confirm');
|
|
6544
|
+
const sub = document.getElementById('chat-instructor-access-sub');
|
|
6545
|
+
if (!modal || !keep || !go || !sub) { resolve(false); return; }
|
|
6546
|
+
const back = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
6547
|
+
const connectors = patch.useOwnConnectors === true && !('permissionProfile' in patch);
|
|
6548
|
+
const chosen = connectors ? '' : permissionLabel(patch.permissionProfile);
|
|
6549
|
+
const provider = providerLabels[state.chat?.provider] || 'Claude or Codex';
|
|
6550
|
+
sub.textContent = 'This chat is an Instructor answer, so the AI used no tools. '
|
|
6551
|
+
+ (connectors
|
|
6552
|
+
? `If you turn on your ${provider} connectors, it becomes an ordinary chat, and its next replies can use the tools its Access allows as well as your connectors (each call still asks you first).`
|
|
6553
|
+
: `If you change Access to ${chosen}, it becomes an ordinary chat, and its next replies can use the tools ${chosen} allows.`)
|
|
6554
|
+
+ ' Earlier answers stay as they were. You can’t switch it back to no tools: ask the Instructor again for that.';
|
|
6555
|
+
go.textContent = connectors ? 'Turn on connectors' : `Change to ${chosen}`;
|
|
6556
|
+
const done = (value) => {
|
|
6557
|
+
modal.classList.remove('show');
|
|
6558
|
+
modal.removeEventListener('keydown', onKey); modal.removeEventListener('click', onBackdrop);
|
|
6559
|
+
keep.removeEventListener('click', onKeep); go.removeEventListener('click', onGo);
|
|
6560
|
+
if (back?.isConnected) back.focus();
|
|
6561
|
+
resolve(value);
|
|
6562
|
+
};
|
|
6563
|
+
const onKey = (event) => {
|
|
6564
|
+
if (event.key === 'Escape') { event.preventDefault(); event.stopPropagation(); done(false); return; }
|
|
6565
|
+
if (event.key === 'Tab') {
|
|
6566
|
+
// Keep focus inside the two choices while the question is open.
|
|
6567
|
+
const order = [keep, go];
|
|
6568
|
+
const at = order.indexOf(document.activeElement);
|
|
6569
|
+
event.preventDefault();
|
|
6570
|
+
order[(at + (event.shiftKey ? order.length - 1 : 1)) % order.length].focus();
|
|
6571
|
+
}
|
|
6572
|
+
};
|
|
6573
|
+
const onBackdrop = (event) => { if (event.target === modal) done(false); };
|
|
6574
|
+
const onKeep = () => done(false);
|
|
6575
|
+
const onGo = () => done(true);
|
|
6576
|
+
modal.addEventListener('keydown', onKey); modal.addEventListener('click', onBackdrop);
|
|
6577
|
+
keep.addEventListener('click', onKeep); go.addEventListener('click', onGo);
|
|
6578
|
+
modal.classList.add('show');
|
|
6579
|
+
keep.focus();
|
|
6580
|
+
});
|
|
6581
|
+
}
|
|
6582
|
+
|
|
6403
6583
|
async function saveSettings(patch, options = {}) {
|
|
6404
|
-
|
|
6584
|
+
let snapshot = captureChat();
|
|
6405
6585
|
if (!snapshot) return;
|
|
6586
|
+
// #2059: giving an Instructor answer tools asks first; the server refuses it without this confirmation.
|
|
6587
|
+
let release = false;
|
|
6588
|
+
if (widensInstructorAnswer(patch)) {
|
|
6589
|
+
if (!await confirmInstructorRelease(patch)) return;
|
|
6590
|
+
if (!sameChat(snapshot)) return;
|
|
6591
|
+
// The settings may have moved on while the question was open: apply the choice to what is current now.
|
|
6592
|
+
snapshot = captureChat();
|
|
6593
|
+
if (!snapshot) return;
|
|
6594
|
+
release = true;
|
|
6595
|
+
}
|
|
6406
6596
|
const settings = { ...state.chat.settings, ...patch };
|
|
6407
6597
|
if ('model' in patch && !('effort' in patch)) settings.effort = null;
|
|
6408
6598
|
try {
|
|
6409
6599
|
const chat = await request(`/api/chat/conversations/${encodeURIComponent(snapshot.chatId)}/settings`, {
|
|
6410
|
-
method: 'PUT', body: JSON.stringify({ owner: snapshot.scope.owner, ...settings }),
|
|
6600
|
+
method: 'PUT', body: JSON.stringify({ owner: snapshot.scope.owner, ...settings, ...(release ? { releaseInstructorAnswer: true } : {}) }),
|
|
6411
6601
|
});
|
|
6412
6602
|
if (!sameChat(snapshot)) return;
|
|
6413
6603
|
state.chat = chat;
|
|
6414
|
-
paintConversation();
|
|
6604
|
+
paintConversation();
|
|
6605
|
+
if (release) {
|
|
6606
|
+
announce(patch.useOwnConnectors === true && !('permissionProfile' in patch)
|
|
6607
|
+
? 'Connectors on. This is now an ordinary chat.' : `Access changed to ${permissionLabel(chat.settings.permissionProfile)}. This is now an ordinary chat.`);
|
|
6608
|
+
// The transcript line the server wrote is shown now, not on the next poll.
|
|
6609
|
+
void refreshConversation(snapshot.chatId, false);
|
|
6610
|
+
} else if (options.announce !== false) announce('Chat settings updated.');
|
|
6415
6611
|
} catch (error) { if (sameChat(snapshot)) report(error, 'Could not update settings'); }
|
|
6416
6612
|
}
|
|
6417
6613
|
|
|
@@ -6435,20 +6631,67 @@
|
|
|
6435
6631
|
return permissionLabels[value] || 'Read only';
|
|
6436
6632
|
}
|
|
6437
6633
|
|
|
6634
|
+
/**
|
|
6635
|
+
* #2037: when Auto cannot do what it promises, the picker says so. Claude Haiku has no auto mode; Codex with the
|
|
6636
|
+
* person's own connectors on keeps asking, so each connector call still reaches its card (#1907).
|
|
6637
|
+
*/
|
|
6638
|
+
function autoUnavailable() {
|
|
6639
|
+
if (state.chat?.integrationBindings?.length) return 'accounts';
|
|
6640
|
+
if (state.chat?.provider === 'codex') return state.chat?.settings?.useOwnConnectors === true ? 'connectors' : null;
|
|
6641
|
+
return state.chat?.provider === 'claude' && selectedModel()?.autoMode === false ? 'model' : null;
|
|
6642
|
+
}
|
|
6643
|
+
|
|
6644
|
+
function permissionMeta(value, workspace) {
|
|
6645
|
+
if (value === 'read-only') return 'Looks and answers. Changes nothing.';
|
|
6646
|
+
if (value === 'auto') {
|
|
6647
|
+
const why = autoUnavailable();
|
|
6648
|
+
if (why === 'connectors') return 'With your Codex connectors on, Codex asks you before steps that need approval.';
|
|
6649
|
+
if (why === 'accounts') return 'With a FloLess account selected, the AI asks you before steps that need approval.';
|
|
6650
|
+
return why ? 'Not available with this model. It asks before changes.' : 'Does safe work by itself. Checks risky steps first.';
|
|
6651
|
+
}
|
|
6652
|
+
if (value === 'workspace-write') return workspace ? 'Asks before changing project files.' : 'Asks you whenever the AI needs approval.';
|
|
6653
|
+
return 'Can change any file on this computer.';
|
|
6654
|
+
}
|
|
6655
|
+
|
|
6656
|
+
function permissionTip(value) {
|
|
6657
|
+
if (state.scope?.owner?.kind === 'workspace') return `Access: ${permissionLabel(value)}. Full access and Auto are offered only inside a project or workflow.`;
|
|
6658
|
+
const why = value === 'auto' ? autoUnavailable() : null;
|
|
6659
|
+
const label = why === 'connectors' ? 'Auto (asking first while your connectors are on)'
|
|
6660
|
+
: why === 'accounts' ? 'Auto (asking first while a FloLess account is selected)'
|
|
6661
|
+
: why ? 'Auto (asking first with this model)' : permissionLabel(value);
|
|
6662
|
+
return `Access: ${label}. ${permissionMeta(value || 'read-only', false)}`;
|
|
6663
|
+
}
|
|
6664
|
+
|
|
6438
6665
|
function permissionChoices() {
|
|
6439
6666
|
// #1890 PR 2b: from the workspace, Full access is not offered — it would remove the approvals each change needs.
|
|
6667
|
+
// #2037: nor Auto — Codex's auto review would approve a change around the claim its card makes.
|
|
6440
6668
|
const workspace = state.scope?.owner?.kind === 'workspace';
|
|
6441
6669
|
const offered = workspace
|
|
6442
|
-
? Object.keys(permissionLabels).filter((value) => value !== 'full-access')
|
|
6670
|
+
? Object.keys(permissionLabels).filter((value) => value !== 'full-access' && value !== 'auto')
|
|
6443
6671
|
: Object.keys(permissionLabels);
|
|
6444
6672
|
return offered.map((value) => ({
|
|
6445
|
-
id: `permission:${value}`, label: permissionLabel(value),
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
selected: state.chat.settings.permissionProfile === value, patch: { permissionProfile: value },
|
|
6673
|
+
id: `permission:${value}`, label: permissionLabel(value), meta: permissionMeta(value, workspace),
|
|
6674
|
+
// #2059: an Instructor answer has none of these yet ("No tools" is a state, not a choice).
|
|
6675
|
+
selected: !isInstructorAnswer(state.chat) && state.chat.settings.permissionProfile === value, patch: { permissionProfile: value },
|
|
6449
6676
|
}));
|
|
6450
6677
|
}
|
|
6451
6678
|
|
|
6679
|
+
/** Why the workspace's Access list has no Auto or Full access; the same test permissionChoices uses to leave them out. */
|
|
6680
|
+
function permissionPickerNote() {
|
|
6681
|
+
return state.scope?.owner?.kind === 'workspace' ? 'Auto and Full access are offered inside a project or workflow.' : '';
|
|
6682
|
+
}
|
|
6683
|
+
|
|
6684
|
+
/** #2037: what Auto means in this conversation's Scope view; Codex's review may approve a change outside the folder. */
|
|
6685
|
+
function autoScopeNote() {
|
|
6686
|
+
const why = autoUnavailable();
|
|
6687
|
+
if (why === 'connectors') return 'Auto: while your Codex connectors are on, Codex asks you — instead of its own review — before any step that needs approval, so each connector call reaches its card. Turn the connectors off to let its review decide. Scope does not limit file reads.';
|
|
6688
|
+
if (why === 'accounts') return 'Auto: while a FloLess account is selected for this chat, the AI asks you — instead of its own review — before any step that needs approval, so that account stays its only way to reach the service. Scope does not limit file reads.';
|
|
6689
|
+
if (why) return 'Auto isn’t available with this model, so the AI asks before changes. File edits outside your home folder ask for approval. Scope does not limit file reads.';
|
|
6690
|
+
return state.chat?.provider === 'codex'
|
|
6691
|
+
? 'Auto: Codex’s built-in review checks each step. Safe changes go ahead; risky ones, like deleting, are held back. Its review may also approve a change outside your home folder on its own — each decision is noted in the conversation. Scope does not limit file reads.'
|
|
6692
|
+
: 'Auto: Claude checks each step itself. Safe changes in your home folder go ahead; it asks you before touching anything outside it, and holds back risky steps like deleting. Scope does not limit file reads.';
|
|
6693
|
+
}
|
|
6694
|
+
|
|
6452
6695
|
async function loadIntegrations() {
|
|
6453
6696
|
const snapshot = captureChat();
|
|
6454
6697
|
if (!snapshot) return null;
|
|
@@ -6468,7 +6711,21 @@
|
|
|
6468
6711
|
|| row.alias || 'Provider account';
|
|
6469
6712
|
}
|
|
6470
6713
|
|
|
6714
|
+
// #2154: AWARE's machine reason (AWARE >= 0.157) says exactly what is wrong with a connected account; each maps to the
|
|
6715
|
+
// one thing the person can do. Older AWAREs send none, and the word matching below stays the fallback.
|
|
6716
|
+
const INTEGRATION_REASON_COPY = Object.freeze({
|
|
6717
|
+
'auth-invalid': 'Sign in again to this connected account in Integrations.',
|
|
6718
|
+
'credential-expired': 'This account’s sign-in has expired. Sign in again in Integrations.',
|
|
6719
|
+
'credential-missing': 'This account has no saved sign-in on this computer. Connect it again in Integrations.',
|
|
6720
|
+
'scope-missing': 'This account was connected without permission to read these files. Connect it again in Integrations and allow file access.',
|
|
6721
|
+
'identity-unverified': 'FloLess could not confirm which account this is. Verify it in Integrations, then try again.',
|
|
6722
|
+
'generation-unavailable': 'FloLess could not check this account’s sign-in just now. Try again in a moment.',
|
|
6723
|
+
'command-planned': 'This service is not available in FloLess Chat yet.',
|
|
6724
|
+
});
|
|
6725
|
+
|
|
6471
6726
|
function integrationReason(row) {
|
|
6727
|
+
const code = typeof row?.reasonCode === 'string' ? row.reasonCode : '';
|
|
6728
|
+
if (Object.hasOwn(INTEGRATION_REASON_COPY, code)) return INTEGRATION_REASON_COPY[code];
|
|
6472
6729
|
const raw = String(row?.reason || '');
|
|
6473
6730
|
if (!raw) return 'This connected account is unavailable.';
|
|
6474
6731
|
if (/expired|sign in|auth|token/i.test(raw)) return 'Sign in again to this connected account in Integrations.';
|
|
@@ -6519,7 +6776,7 @@
|
|
|
6519
6776
|
if (!snapshot) return;
|
|
6520
6777
|
if (ui.integrations.disabled) return;
|
|
6521
6778
|
if (state.picker === 'integrations') { closePicker(); return; }
|
|
6522
|
-
toggleHistory(false); closePicker(); state.picker = 'integrations';
|
|
6779
|
+
toggleHistory(false); closePicker(); state.picker = 'integrations'; state.pickerOpener = ui.integrations;
|
|
6523
6780
|
ui.integrations.setAttribute('aria-expanded', 'true'); ui.picker.hidden = false;
|
|
6524
6781
|
const loading = document.createElement('div'); loading.className = 'ai-chat-integration-empty'; loading.textContent = 'Checking FloLess accounts…';
|
|
6525
6782
|
ui.picker.replaceChildren(loading);
|
|
@@ -6700,7 +6957,7 @@
|
|
|
6700
6957
|
// tell the two apart. Handing the text back then would send it twice; losing it from the
|
|
6701
6958
|
// composer, which is what a torn record has always done, only costs the retype.
|
|
6702
6959
|
|| ['chat-provider-unavailable', 'chat-turn-active', 'chat-turn-settling', 'chat-followup-queued', 'chat-followup-unconfirmed',
|
|
6703
|
-
'chat-owner-busy', 'chat-host-busy', 'chat-attachment-scope',
|
|
6960
|
+
'chat-owner-busy', 'chat-project-run-busy', 'chat-project-knowledge-busy', 'chat-project-waiting', 'chat-host-busy', 'chat-attachment-scope',
|
|
6704
6961
|
'chat-root-stale', 'chat-archived'].includes(String(error?.code || ''));
|
|
6705
6962
|
}
|
|
6706
6963
|
|
|
@@ -7135,7 +7392,9 @@
|
|
|
7135
7392
|
if (reason) state.filterNotShared.set(clientSubmissionId, reason);
|
|
7136
7393
|
}
|
|
7137
7394
|
|
|
7138
|
-
async function sendTurn() {
|
|
7395
|
+
async function sendTurn(options) {
|
|
7396
|
+
// #2061: `override` — the person chose to send now over a background request that was waiting first.
|
|
7397
|
+
const sendOverride = options?.override === true;
|
|
7139
7398
|
if (!state.chat || ui.send.disabled) return;
|
|
7140
7399
|
// ONE AI CHAT (#1859, owner ruling 2026-10-01/02): the open Drawing Filter never changes where a message goes.
|
|
7141
7400
|
// It is a turn, or a follow-up to a running reply (a drawing read included), exactly as anywhere else; the
|
|
@@ -7161,6 +7420,13 @@
|
|
|
7161
7420
|
const uiContext = currentFloLessContext();
|
|
7162
7421
|
const chatId = snapshot.chatId;
|
|
7163
7422
|
const attachmentIds = state.attachments.map((item) => item.attachmentId);
|
|
7423
|
+
// #2061: the message as it was asked about, should the project turn out to be busy (see askIfProjectBusy).
|
|
7424
|
+
const busyMessage = { chatId, text, attachmentIds, subjectsField, filterField: filterContext.field };
|
|
7425
|
+
const askedBusy = !sendOverride && await projectBusyBeforeSend(snapshot, busyMessage);
|
|
7426
|
+
if (askedBusy || !sameChat(snapshot)) return;
|
|
7427
|
+
// Edited while FloLess checked — or already sent by an earlier click, which empties the box — nothing is sent over
|
|
7428
|
+
// the box's text now; it stays for the next Send.
|
|
7429
|
+
if (ui.input.value.trim() !== text || JSON.stringify(state.attachments.map((item) => item.attachmentId)) !== JSON.stringify(attachmentIds)) return;
|
|
7164
7430
|
const clientSubmissionId = crypto.randomUUID();
|
|
7165
7431
|
const previousChat = state.chat;
|
|
7166
7432
|
const previousAttachments = state.attachments;
|
|
@@ -7187,8 +7453,11 @@
|
|
|
7187
7453
|
// durable transcript must remain exactly what the user typed.
|
|
7188
7454
|
owner: snapshot.scope.owner, clientSubmissionId, text, displayText: text, uiContext, attachmentIds,
|
|
7189
7455
|
modifying: previousChat.settings.permissionProfile !== 'read-only', ...subjectsField, ...filterContext.field,
|
|
7456
|
+
// #2061: the person chose "Send my message now" over a request that was waiting first.
|
|
7457
|
+
...(sendOverride ? { overrideWaiting: true } : {}),
|
|
7190
7458
|
}),
|
|
7191
7459
|
});
|
|
7460
|
+
if (sameChat(snapshot)) endProjectBusy();
|
|
7192
7461
|
if (!sameChat(snapshot)) {
|
|
7193
7462
|
noteFilterContext(clientSubmissionId, filterContext, result?.filterContext);
|
|
7194
7463
|
return void subjectLinksSaved(subjects);
|
|
@@ -7212,10 +7481,317 @@
|
|
|
7212
7481
|
state.chat = previousChat;
|
|
7213
7482
|
state.attachments = previousAttachments;
|
|
7214
7483
|
ui.input.value = text; autosize(); paintAttachments(); saveDraftSoon(); paintConversation();
|
|
7215
|
-
|
|
7484
|
+
// #2061: the project is busy — ask (wait / open it / stop it) instead of only saying it failed. Nothing was sent.
|
|
7485
|
+
if (!askIfProjectBusy(error, busyMessage)) report(error, 'Message was not sent');
|
|
7216
7486
|
} finally { if (sameChat(snapshot)) { setBusy(false); updateSendState(); } }
|
|
7217
7487
|
}
|
|
7218
7488
|
|
|
7489
|
+
// ── #2061: a project another piece of work is changing ─────────────────────────────────────────────────────────
|
|
7490
|
+
// Asked, never refused (owner ruling 2026-10-07): wait and send by itself when the project is free, open the other
|
|
7491
|
+
// work, or stop it. The wait lives in this tab only — the message stays in the composer, which is what is sent — and it
|
|
7492
|
+
// sends only the message that was asked about: a changed text, file, selection or sheet stops it, saying why.
|
|
7493
|
+
|
|
7494
|
+
const PROJECT_BUSY_CODES = new Set(['chat-owner-busy', 'chat-project-run-busy', 'chat-project-knowledge-busy', 'chat-project-waiting', 'chat-host-busy']);
|
|
7495
|
+
const PROJECT_WAIT_POLL_MS = 4000;
|
|
7496
|
+
const PROJECT_WAIT_FAILURE_LIMIT = 5;
|
|
7497
|
+
const PROJECT_WAIT_CAP_MS = 30 * 60 * 1000;
|
|
7498
|
+
// #2106: the same remedy every waiter gives once organizing has held the project for the whole wait (server copy:
|
|
7499
|
+
// knowledgeStuckRemedy in project-wait-clock.ts).
|
|
7500
|
+
const KNOWLEDGE_STUCK_REMEDY = 'If organizing has stopped, restart FloLess — that clears an organize that already finished. If it still shows as organizing after that, open a terminal outside FloLess (Claude Code or Codex) and ask it to check and recover the stuck knowledge organize for this project, then send again.';
|
|
7501
|
+
|
|
7502
|
+
/** What a message means beyond its words: the selected objects and the open Drawing Filter's context. */
|
|
7503
|
+
function projectWaitContext(subjectsField, filterField) {
|
|
7504
|
+
try { return JSON.stringify({ subjects: subjectsField?.subjects ?? null, filter: filterField ?? {} }); }
|
|
7505
|
+
catch { return ''; }
|
|
7506
|
+
}
|
|
7507
|
+
|
|
7508
|
+
function currentProjectWaitContext() {
|
|
7509
|
+
const subjects = subjectsPayload(composerSelection());
|
|
7510
|
+
return projectWaitContext(subjects ? { subjects } : {}, filterContextForSend().field);
|
|
7511
|
+
}
|
|
7512
|
+
|
|
7513
|
+
function holderTitle(holder) {
|
|
7514
|
+
if (holder?.kind === 'knowledge') return 'FloLess’s knowledge organizing';
|
|
7515
|
+
const title = String(holder?.title || (holder?.kind === 'chat' ? 'another AI Chat conversation' : 'another background request'));
|
|
7516
|
+
return holder?.kind === 'chat' ? `“${title}”` : title;
|
|
7517
|
+
}
|
|
7518
|
+
|
|
7519
|
+
/** A holder named at the start of a sentence ("the background request …" → "The background request …"). */
|
|
7520
|
+
function sentenceCase(text) {
|
|
7521
|
+
return text ? text.charAt(0).toUpperCase() + text.slice(1) : text;
|
|
7522
|
+
}
|
|
7523
|
+
|
|
7524
|
+
function endProjectBusy() {
|
|
7525
|
+
const busy = state.projectBusy;
|
|
7526
|
+
if (busy?.timer) clearInterval(busy.timer);
|
|
7527
|
+
state.projectBusy = null;
|
|
7528
|
+
shell.querySelector('.ai-chat-busy-ask')?.remove();
|
|
7529
|
+
}
|
|
7530
|
+
|
|
7531
|
+
/** The pending-message record the wait compares against before it sends by itself. */
|
|
7532
|
+
function busyMessageRecord(message) {
|
|
7533
|
+
return { chatId: message.chatId, text: message.text, attachmentIds: JSON.stringify(message.attachmentIds),
|
|
7534
|
+
context: projectWaitContext(message.subjectsField, message.filterField) };
|
|
7535
|
+
}
|
|
7536
|
+
|
|
7537
|
+
/**
|
|
7538
|
+
* A message that may change files first asks whether the project is free (a read; nothing is sent), so a busy
|
|
7539
|
+
* project is asked about at once instead of after a refused send. The send itself still re-checks. True when it
|
|
7540
|
+
* asked; the caller still checks the person is in the same conversation before sending.
|
|
7541
|
+
*/
|
|
7542
|
+
async function projectBusyBeforeSend(snapshot, message) {
|
|
7543
|
+
if (state.chat?.settings?.permissionProfile === 'read-only' || snapshot.scope?.owner?.kind === 'workspace') return false;
|
|
7544
|
+
let holder = null;
|
|
7545
|
+
try {
|
|
7546
|
+
holder = (await request(`/api/chat/conversations/${encodeURIComponent(message.chatId)}/project-holder?${ownerQuery(snapshot.scope.owner)}`))?.holder || null;
|
|
7547
|
+
} catch (error) { console.warn('[chat] could not check whether the project is free; sending anyway:', error); }
|
|
7548
|
+
if (!holder || !sameChat(snapshot)) return false;
|
|
7549
|
+
askProjectBusy(holder, busyMessageRecord(message));
|
|
7550
|
+
return true;
|
|
7551
|
+
}
|
|
7552
|
+
|
|
7553
|
+
/** A send refused because the project is busy is asked about; true when it was. Any other refusal ends a wait. */
|
|
7554
|
+
function askIfProjectBusy(error, message) {
|
|
7555
|
+
if (PROJECT_BUSY_CODES.has(String(error?.code || '')) && error?.holder) {
|
|
7556
|
+
askProjectBusy(error.holder, busyMessageRecord(message));
|
|
7557
|
+
return true;
|
|
7558
|
+
}
|
|
7559
|
+
endProjectBusy(); // a wait never retries a message refused for another reason
|
|
7560
|
+
return false;
|
|
7561
|
+
}
|
|
7562
|
+
|
|
7563
|
+
/** The project is busy: ask what to do. */
|
|
7564
|
+
function askProjectBusy(holder, message) {
|
|
7565
|
+
const waitingBefore = state.projectBusy?.mode === 'waiting' && state.projectBusy.message.chatId === message.chatId;
|
|
7566
|
+
if (waitingBefore) {
|
|
7567
|
+
// Still busy when the wait tried to send (another piece of work got there first): keep waiting, name the new holder.
|
|
7568
|
+
state.projectBusy.holder = holder;
|
|
7569
|
+
paintProjectBusy();
|
|
7570
|
+
return;
|
|
7571
|
+
}
|
|
7572
|
+
endProjectBusy();
|
|
7573
|
+
state.projectBusy = { mode: holder.waiting ? 'queued-request' : 'ask', holder, message, since: Date.now(), timer: null };
|
|
7574
|
+
paintProjectBusy({ focus: true });
|
|
7575
|
+
}
|
|
7576
|
+
|
|
7577
|
+
function startProjectWait() {
|
|
7578
|
+
const busy = state.projectBusy;
|
|
7579
|
+
if (!busy) return;
|
|
7580
|
+
busy.mode = 'waiting';
|
|
7581
|
+
busy.since = Date.now();
|
|
7582
|
+
if (busy.timer) clearInterval(busy.timer);
|
|
7583
|
+
busy.timer = setInterval(() => void checkProjectWait(), PROJECT_WAIT_POLL_MS);
|
|
7584
|
+
paintProjectBusy();
|
|
7585
|
+
ui.input.focus();
|
|
7586
|
+
void checkProjectWait();
|
|
7587
|
+
}
|
|
7588
|
+
|
|
7589
|
+
async function checkProjectWait() {
|
|
7590
|
+
const busy = state.projectBusy;
|
|
7591
|
+
if (!busy || busy.mode !== 'waiting' || busy.checking) return;
|
|
7592
|
+
// The wait belongs to the conversation it was asked in; leaving it ends the wait (the draft stays there).
|
|
7593
|
+
if (state.chat?.chatId !== busy.message.chatId) { endProjectBusy(); return; }
|
|
7594
|
+
if (Date.now() - busy.since >= PROJECT_WAIT_CAP_MS) {
|
|
7595
|
+
clearInterval(busy.timer); busy.timer = null; busy.mode = 'cap';
|
|
7596
|
+
paintProjectBusy({ focus: true });
|
|
7597
|
+
return;
|
|
7598
|
+
}
|
|
7599
|
+
busy.checking = true;
|
|
7600
|
+
try {
|
|
7601
|
+
const owner = state.scope?.owner;
|
|
7602
|
+
const found = await request(`/api/chat/conversations/${encodeURIComponent(busy.message.chatId)}/project-holder?${ownerQuery(owner)}${busy.override ? '&overrideWaiting=1' : ''}`);
|
|
7603
|
+
if (state.projectBusy !== busy || busy.mode !== 'waiting') return;
|
|
7604
|
+
busy.failures = 0;
|
|
7605
|
+
if (found?.holder) {
|
|
7606
|
+
busy.sendNotReady = false;
|
|
7607
|
+
if (found.holder.title !== busy.holder.title) { busy.holder = found.holder; paintProjectBusy(); }
|
|
7608
|
+
paintProjectBusyElapsed();
|
|
7609
|
+
return;
|
|
7610
|
+
}
|
|
7611
|
+
// Free. Send only the message that was asked about.
|
|
7612
|
+
const sameMessage = ui.input.value.trim() === busy.message.text
|
|
7613
|
+
&& JSON.stringify(state.attachments.map((item) => item.attachmentId)) === busy.message.attachmentIds
|
|
7614
|
+
&& currentProjectWaitContext() === busy.message.context;
|
|
7615
|
+
if (!sameMessage) {
|
|
7616
|
+
clearInterval(busy.timer); busy.timer = null; busy.mode = 'changed';
|
|
7617
|
+
paintProjectBusy({ focus: true });
|
|
7618
|
+
return;
|
|
7619
|
+
}
|
|
7620
|
+
// Free, but this conversation can't send yet (still answering, or not ready): try again on the next check.
|
|
7621
|
+
if (ui.send.disabled || turnIsVisiblyActive()) { busy.sendNotReady = true; return; }
|
|
7622
|
+
clearInterval(busy.timer); busy.timer = null;
|
|
7623
|
+
busy.sending = true;
|
|
7624
|
+
await sendTurn({ override: Boolean(busy.override) });
|
|
7625
|
+
} catch (error) {
|
|
7626
|
+
// A check that failed is tried again a few times; one the server refused outright (the conversation moved or was
|
|
7627
|
+
// archived), or several in a row, end the wait and say so — never later blamed on the other work.
|
|
7628
|
+
console.warn('[chat] could not check whether the project is free:', error);
|
|
7629
|
+
busy.failures = (busy.failures || 0) + 1;
|
|
7630
|
+
const refused = Number(error?.status) >= 400 && Number(error?.status) < 500;
|
|
7631
|
+
if (state.projectBusy === busy && (refused || busy.failures >= PROJECT_WAIT_FAILURE_LIMIT)) {
|
|
7632
|
+
clearInterval(busy.timer); busy.timer = null; busy.mode = 'check-failed';
|
|
7633
|
+
paintProjectBusy({ focus: true });
|
|
7634
|
+
}
|
|
7635
|
+
} finally {
|
|
7636
|
+
busy.checking = false;
|
|
7637
|
+
busy.sending = false;
|
|
7638
|
+
// A send refused again as busy resumed the wait (askProjectBusy); anything else ended it.
|
|
7639
|
+
if (state.projectBusy === busy && busy.mode === 'waiting' && !busy.timer) {
|
|
7640
|
+
busy.timer = setInterval(() => void checkProjectWait(), PROJECT_WAIT_POLL_MS);
|
|
7641
|
+
}
|
|
7642
|
+
}
|
|
7643
|
+
}
|
|
7644
|
+
|
|
7645
|
+
/**
|
|
7646
|
+
* #2104: the design program a holder is using, by the name a person knows it ("Revit"), or `fallback` when FloLess
|
|
7647
|
+
* cannot name it (SketchUp/AutoCAD/ArchiCAD share one claim, and older records carry no key).
|
|
7648
|
+
*/
|
|
7649
|
+
function hostProgramLabel(holder, fallback) {
|
|
7650
|
+
const kind = String(holder?.hostKey || '').split(':', 1)[0];
|
|
7651
|
+
return ({ tekla: 'Tekla', revit: 'Revit', rhino: 'Rhino' })[kind] || fallback;
|
|
7652
|
+
}
|
|
7653
|
+
|
|
7654
|
+
async function stopProjectHolder() {
|
|
7655
|
+
const busy = state.projectBusy;
|
|
7656
|
+
const holder = busy?.holder;
|
|
7657
|
+
// #2106: organizing carries a request id but is never a background run: there is nothing here to stop.
|
|
7658
|
+
if (!holder || holder.kind === 'knowledge') return;
|
|
7659
|
+
try {
|
|
7660
|
+
if (holder.kind === 'chat' && holder.chatId && holder.owner) {
|
|
7661
|
+
await request(`/api/chat/conversations/${encodeURIComponent(holder.chatId)}/stop`, { method: 'POST',
|
|
7662
|
+
body: JSON.stringify({ owner: holder.owner, expectTurnId: holder.turnId || undefined }) });
|
|
7663
|
+
} else if (holder.requestId) {
|
|
7664
|
+
await request(`/api/requests/${encodeURIComponent(holder.requestId)}/run/stop`, { method: 'POST',
|
|
7665
|
+
body: JSON.stringify(holder.leaseId ? { expectLeaseId: holder.leaseId } : {}) });
|
|
7666
|
+
}
|
|
7667
|
+
announce(`Stopped ${holderTitle(holder)}. Your message sends as soon as ${holder.reason === 'host' ? hostProgramLabel(holder, 'the design program') : 'the project'} is free.`);
|
|
7668
|
+
} catch (error) {
|
|
7669
|
+
// Already finished, or could not be stopped: say so, and still wait — the message goes once the project is free.
|
|
7670
|
+
announce(error?.code === 'stop-stale' ? 'That work had already finished, so nothing was stopped.' : `FloLess couldn’t stop ${holderTitle(holder)}. It keeps waiting instead.`);
|
|
7671
|
+
}
|
|
7672
|
+
if (state.projectBusy === busy) startProjectWait();
|
|
7673
|
+
}
|
|
7674
|
+
|
|
7675
|
+
/** Whether "Open it" has somewhere to go: a conversation, a request, or (#2106) the project's Knowledge step. */
|
|
7676
|
+
function canOpenHolder(holder) {
|
|
7677
|
+
if (holder?.kind === 'knowledge') return Boolean(holder.projectId);
|
|
7678
|
+
return Boolean(holder?.kind === 'chat' ? holder.owner : holder?.requestId);
|
|
7679
|
+
}
|
|
7680
|
+
|
|
7681
|
+
/** #2106: a project's Knowledge step. A missing Workspaces bridge is said, never a silent no-op. */
|
|
7682
|
+
async function openKnowledgeStepOf(projectId) {
|
|
7683
|
+
const open = window.flolessWorkspaces?.openKnowledgeStep;
|
|
7684
|
+
if (typeof open !== 'function') throw new Error('FloLess couldn’t open that project’s Knowledge step. Open it from Workspaces.');
|
|
7685
|
+
await open(projectId);
|
|
7686
|
+
}
|
|
7687
|
+
|
|
7688
|
+
async function openProjectHolder() {
|
|
7689
|
+
const holder = state.projectBusy?.holder;
|
|
7690
|
+
if (!holder) return;
|
|
7691
|
+
if (holder.kind === 'knowledge') {
|
|
7692
|
+
// The wait keeps going: opening the Knowledge step only shows the organizing this message waits for.
|
|
7693
|
+
try { await openKnowledgeStepOf(holder.projectId); }
|
|
7694
|
+
catch (error) { announce(error?.message || 'FloLess couldn’t open that project’s Knowledge step. Open it from Workspaces.'); }
|
|
7695
|
+
return;
|
|
7696
|
+
}
|
|
7697
|
+
if (holder.kind === 'chat' && holder.chatId && holder.owner) {
|
|
7698
|
+
endProjectBusy(); // the wait belongs to this conversation; opening the other one ends it (the draft is kept)
|
|
7699
|
+
const opened = await openConversationIn({ owner: holder.owner }, holder.chatId).catch(() => false);
|
|
7700
|
+
if (!opened) announce('FloLess couldn’t open that conversation. It may have finished or moved.');
|
|
7701
|
+
return;
|
|
7702
|
+
}
|
|
7703
|
+
if (holder.requestId && typeof window.flolessBridge?.openRequest === 'function') {
|
|
7704
|
+
await window.flolessBridge.openRequest(holder.requestId);
|
|
7705
|
+
}
|
|
7706
|
+
}
|
|
7707
|
+
|
|
7708
|
+
function paintProjectBusyElapsed() {
|
|
7709
|
+
const line = shell.querySelector('.ai-chat-busy-ask .ai-chat-busy-elapsed');
|
|
7710
|
+
const busy = state.projectBusy;
|
|
7711
|
+
if (!line || !busy) return;
|
|
7712
|
+
const minutes = Math.floor((Date.now() - busy.since) / 60000);
|
|
7713
|
+
line.textContent = minutes < 1 ? 'Waiting less than a minute' : `Waiting ${minutes} min`;
|
|
7714
|
+
}
|
|
7715
|
+
|
|
7716
|
+
function paintProjectBusy({ focus = false } = {}) {
|
|
7717
|
+
shell.querySelector('.ai-chat-busy-ask')?.remove();
|
|
7718
|
+
const busy = state.projectBusy;
|
|
7719
|
+
if (!busy) return;
|
|
7720
|
+
const who = holderTitle(busy.holder);
|
|
7721
|
+
const knowledge = busy.holder.kind === 'knowledge';
|
|
7722
|
+
const card = document.createElement('section');
|
|
7723
|
+
const neutral = busy.mode === 'waiting';
|
|
7724
|
+
// Its own class, never .ai-chat-runtime: the setup card's painter removes any element carrying that one.
|
|
7725
|
+
card.className = `ai-chat-busy-ask${neutral ? '' : ' is-asking'}`;
|
|
7726
|
+
card.setAttribute('role', neutral ? 'status' : 'alert');
|
|
7727
|
+
if (neutral) card.setAttribute('aria-live', 'polite');
|
|
7728
|
+
const heading = document.createElement('strong');
|
|
7729
|
+
const copy = document.createElement('p');
|
|
7730
|
+
const actions = document.createElement('div'); actions.className = 'ai-chat-approval-actions';
|
|
7731
|
+
const add = (label, commandId, onClick, cls = '') => {
|
|
7732
|
+
const control = button(label, commandId, cls);
|
|
7733
|
+
control.addEventListener('click', onClick);
|
|
7734
|
+
actions.append(control);
|
|
7735
|
+
return control;
|
|
7736
|
+
};
|
|
7737
|
+
let primary = null;
|
|
7738
|
+
if (busy.mode === 'ask') {
|
|
7739
|
+
heading.textContent = knowledge ? 'FloLess is organizing this project’s knowledge right now' : busy.holder.reason === 'host'
|
|
7740
|
+
? `${sentenceCase(who)} is using ${hostProgramLabel(busy.holder, 'the same design program')} on this computer right now`
|
|
7741
|
+
: `${sentenceCase(who)} is changing this project right now`;
|
|
7742
|
+
copy.textContent = 'Your message hasn’t been sent. It’s still in the box below.';
|
|
7743
|
+
primary = add('Wait and send when it’s free', 'shell.chat-busy-wait', () => startProjectWait(), 'allow');
|
|
7744
|
+
if (canOpenHolder(busy.holder)) add('Open it', 'shell.chat-busy-open', () => void openProjectHolder());
|
|
7745
|
+
// #2106: organizing is driven from outside FloLess (start/finish by the AI organizing it), so it is never stopped here.
|
|
7746
|
+
if (!knowledge && (busy.holder.kind === 'chat' ? busy.holder.owner : busy.holder.requestId)) add('Stop it', 'shell.chat-busy-stop', () => void stopProjectHolder(), 'ai-chat-busy-stop');
|
|
7747
|
+
} else if (busy.mode === 'queued-request') {
|
|
7748
|
+
heading.textContent = 'A background request is already waiting for this project';
|
|
7749
|
+
copy.textContent = 'It asked first. Let it go first and your message sends by itself after it finishes, or send your message now and the request waits.';
|
|
7750
|
+
primary = add('Let it go first', 'shell.chat-busy-let-first', () => startProjectWait(), 'allow');
|
|
7751
|
+
add('Send my message now', 'shell.chat-busy-send-now', () => { const current = state.projectBusy; if (current) current.override = true; void sendTurn({ override: true }); });
|
|
7752
|
+
if (busy.holder.requestId) add('Open it', 'shell.chat-busy-open', () => void openProjectHolder());
|
|
7753
|
+
} else if (busy.mode === 'waiting') {
|
|
7754
|
+
heading.textContent = knowledge ? 'Waiting for FloLess to finish organizing this project’s knowledge' : `Waiting for ${who} to finish`;
|
|
7755
|
+
const dots = document.createElement('span'); dots.className = 'ai-chat-live-dots'; dots.setAttribute('aria-hidden', 'true');
|
|
7756
|
+
dots.append(document.createElement('i'), document.createElement('i'), document.createElement('i'));
|
|
7757
|
+
heading.append(dots);
|
|
7758
|
+
copy.textContent = `Your message sends by itself when ${busy.holder.reason === 'host' ? hostProgramLabel(busy.holder, 'the design program') : 'this project'} is free. Keep this conversation open.`;
|
|
7759
|
+
const elapsed = document.createElement('p'); elapsed.className = 'ai-chat-busy-elapsed'; elapsed.setAttribute('aria-hidden', 'true');
|
|
7760
|
+
card.append(heading, copy, elapsed);
|
|
7761
|
+
if (canOpenHolder(busy.holder)) add('Open it', 'shell.chat-busy-open', () => void openProjectHolder());
|
|
7762
|
+
add('Cancel waiting', 'shell.chat-busy-cancel', () => { endProjectBusy(); announce('Stopped waiting. Your message is still in the box.'); ui.input.focus(); });
|
|
7763
|
+
} else if (busy.mode === 'cap') {
|
|
7764
|
+
heading.textContent = 'Still waiting after 30 minutes';
|
|
7765
|
+
copy.textContent = busy.sendNotReady
|
|
7766
|
+
? 'Your message hasn’t been sent. This conversation wasn’t ready to send it. Check it, then press Send.'
|
|
7767
|
+
: knowledge
|
|
7768
|
+
? `Your message hasn’t been sent. FloLess has been organizing this project’s knowledge for over 30 minutes. ${KNOWLEDGE_STUCK_REMEDY}`
|
|
7769
|
+
: `Your message hasn’t been sent. ${sentenceCase(who)} is still ${busy.holder.reason === 'host' ? `using ${hostProgramLabel(busy.holder, 'the same design program')}` : 'changing this project'}.`;
|
|
7770
|
+
primary = add('Keep waiting', 'shell.chat-busy-keep-waiting', () => startProjectWait(), 'allow');
|
|
7771
|
+
add('Cancel', 'shell.chat-busy-cancel', () => { endProjectBusy(); ui.input.focus(); });
|
|
7772
|
+
} else if (busy.mode === 'check-failed') {
|
|
7773
|
+
heading.textContent = `FloLess couldn’t check whether ${busy.holder.reason === 'host' ? hostProgramLabel(busy.holder, 'the design program') : 'the project'} is free`;
|
|
7774
|
+
copy.textContent = 'Your message hasn’t been sent. It’s still in the box below. Press Send to try again.';
|
|
7775
|
+
primary = add('OK', 'shell.chat-busy-dismiss', () => { endProjectBusy(); ui.input.focus(); }, 'allow');
|
|
7776
|
+
} else {
|
|
7777
|
+
heading.textContent = 'Your message wasn’t sent';
|
|
7778
|
+
copy.textContent = 'You changed the message or selection while waiting, so it wasn’t sent. Check it, then press Send.';
|
|
7779
|
+
primary = add('OK', 'shell.chat-busy-dismiss', () => { endProjectBusy(); ui.input.focus(); }, 'allow');
|
|
7780
|
+
}
|
|
7781
|
+
if (busy.mode !== 'waiting') card.append(heading, copy);
|
|
7782
|
+
if (busy.mode !== 'changed' && busy.mode !== 'waiting' && busy.mode !== 'check-failed') {
|
|
7783
|
+
const dismiss = button('×', 'shell.chat-busy-dismiss', 'ai-chat-busy-dismiss');
|
|
7784
|
+
dismiss.setAttribute('aria-label', 'Dismiss'); dismiss.dataset.tip = 'Dismiss — your message stays in the box';
|
|
7785
|
+
dismiss.addEventListener('click', () => { endProjectBusy(); ui.input.focus(); });
|
|
7786
|
+
card.prepend(dismiss);
|
|
7787
|
+
}
|
|
7788
|
+
card.append(actions);
|
|
7789
|
+
shell.insertBefore(card, ui.recovery);
|
|
7790
|
+
paintProjectBusyElapsed();
|
|
7791
|
+
if (busy.mode !== 'waiting') announce(`${heading.textContent}. ${copy.textContent}`);
|
|
7792
|
+
if (focus && primary) primary.focus();
|
|
7793
|
+
}
|
|
7794
|
+
|
|
7219
7795
|
/**
|
|
7220
7796
|
* A follow-up refused with `chat-turn-stale` was never saved (the route answers `chat-followup-unknown`
|
|
7221
7797
|
* for anything it did save), so sending the same text as a new turn cannot duplicate it. Send stays
|
|
@@ -8257,6 +8833,7 @@
|
|
|
8257
8833
|
const disclosure = chat.settings?.permissionProfile === 'read-only'
|
|
8258
8834
|
? 'Read only: the AI’s file tools cannot change files. Commands keep their own approvals and may authorize file changes.'
|
|
8259
8835
|
: chat.settings?.permissionProfile === 'full-access' ? 'Full access is on. The AI can change files without asking.'
|
|
8836
|
+
: chat.settings?.permissionProfile === 'auto' ? autoScopeNote()
|
|
8260
8837
|
: chat.changeAllowance?.allowedForChat ? 'File changes in scope, including folders you add later, are allowed for this chat.' : '';
|
|
8261
8838
|
if (ui.scopeDisclosure.textContent !== disclosure) ui.scopeDisclosure.textContent = disclosure;
|
|
8262
8839
|
// Poll/SSE can change permissions or pause a reply while Scope stays open. Refresh only when
|
|
@@ -8319,6 +8896,7 @@
|
|
|
8319
8896
|
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
8897
|
+ (globalAllowance ? ' Your saved file-change allowance does not override Read only.' : '')
|
|
8321
8898
|
: profile === 'full-access' ? 'Full access is on. The AI can change files without asking.'
|
|
8899
|
+
: profile === 'auto' ? autoScopeNote()
|
|
8322
8900
|
: 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
8901
|
: '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
8902
|
host.append(note);
|
|
@@ -8578,6 +9156,15 @@
|
|
|
8578
9156
|
}
|
|
8579
9157
|
}
|
|
8580
9158
|
|
|
9159
|
+
/** #2056: the card's "Use my connectors in this chat" — the same switch as chat settings, for this conversation only. */
|
|
9160
|
+
async function turnOnOwnConnectorsFromCard() {
|
|
9161
|
+
if (state.ownConnectorsSaving === true || !state.chat) return;
|
|
9162
|
+
state.ownConnectorsSaving = true;
|
|
9163
|
+
repaintConnectionCards(); paintConnectorAllowance();
|
|
9164
|
+
try { await setOwnConnectors(true, { focusInput: true }); }
|
|
9165
|
+
finally { state.ownConnectorsSaving = false; repaintConnectionCards(); paintConnectorAllowance(); }
|
|
9166
|
+
}
|
|
9167
|
+
|
|
8581
9168
|
async function turnOffOwnConnectors() {
|
|
8582
9169
|
state.ownConnectorsSaving = true;
|
|
8583
9170
|
paintConnectorAllowance();
|
|
@@ -8846,6 +9433,8 @@
|
|
|
8846
9433
|
if (event.key === 'Escape') { event.preventDefault(); toggleHistory(false, { focusToggle: true }); }
|
|
8847
9434
|
}
|
|
8848
9435
|
ui.history.addEventListener('keydown', closeHistoryOnEscape);
|
|
9436
|
+
ui.picker.addEventListener('keydown', closePickerOnEscape);
|
|
9437
|
+
ui.integrations.addEventListener('keydown', closePickerOnEscape);
|
|
8849
9438
|
ui.newChat.addEventListener('click', () => {
|
|
8850
9439
|
beginProviderChoice();
|
|
8851
9440
|
toggleHistory(false); setBusy(false); providerChooser(); clearReport();
|
|
@@ -8868,7 +9457,10 @@
|
|
|
8868
9457
|
ui.model.addEventListener('click', () => openPicker('model', ui.model, modelChoices()));
|
|
8869
9458
|
ui.switchAccount.addEventListener('click', () => { void switchAccount(); });
|
|
8870
9459
|
ui.effort.addEventListener('click', () => openPicker('effort', ui.effort, effortChoices()));
|
|
8871
|
-
ui.permission.addEventListener('click', () => openPicker('permission', ui.permission, permissionChoices()));
|
|
9460
|
+
ui.permission.addEventListener('click', () => openPicker('permission', ui.permission, permissionChoices(), permissionPickerNote()));
|
|
9461
|
+
// #2046: the Guide's own controls (web/guide.js does the work and says what happened).
|
|
9462
|
+
el('chat-guide-off')?.addEventListener('click', () => { void window.flolessGuide?.turnOff?.(); });
|
|
9463
|
+
el('chat-guide-delete')?.addEventListener('click', () => { void window.flolessGuide?.deleteHistory?.(); });
|
|
8872
9464
|
ui.ownConnectors?.addEventListener('click', () => {
|
|
8873
9465
|
if (ui.ownConnectors.disabled || !state.chat) return;
|
|
8874
9466
|
closePicker();
|