clay-server 5.2.0-beta.5 → 5.2.0-beta.7
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/lib/claude-hook-installer.js +1 -267
- package/lib/claude-jsonl-watcher.js +1 -204
- package/lib/clay-control-presentation-binding.js +96 -0
- package/lib/clay-control-presentation.js +128 -0
- package/lib/clay-control-target-projection.js +26 -0
- package/lib/clay-mate-chat.js +1 -0
- package/lib/clay-mate-knowledge.js +1 -1
- package/lib/clay-product-control-tools.js +1 -1
- package/lib/clay-product-control.js +22 -12
- package/lib/clay-project-records.js +2 -1
- package/lib/clay-scheduling.js +1 -1
- package/lib/clay-screen-controls.js +13 -5
- package/lib/clay-skill-install.js +1 -33
- package/lib/clay-workspace-controls.js +2 -1
- package/lib/cli-sessions.js +1 -300
- package/lib/codex-defaults.js +1 -28
- package/lib/context-usage.js +3 -2
- package/lib/contextual-screen-snapshot.js +38 -0
- package/lib/daemon.js +5 -55
- package/lib/default-ai-runtime.js +4 -8
- package/lib/email-mcp-server.js +1 -1
- package/lib/kiro-defaults.js +1 -22
- package/lib/mate-context-service.js +138 -0
- package/lib/mate-context-tools.js +21 -0
- package/lib/mcp-proxy.js +2 -32
- package/lib/mcp-query-bridge.js +1 -1
- package/lib/mcp-source-adapters.js +1 -91
- package/lib/mcp-source-context.js +1 -42
- package/lib/mcp-source-discovery.js +1 -169
- package/lib/mcp-source-plugins.js +1 -68
- package/lib/mcp-source-restrictions.js +1 -47
- package/lib/mcp-tool-policy.js +1 -26
- package/lib/os-user-diagnostics.js +2 -4
- package/lib/os-users.js +4 -65
- package/lib/project-connection.js +14 -10
- package/lib/project-control-git-view.js +12 -0
- package/lib/project-filesystem.js +5 -1
- package/lib/project-http.js +7 -4
- package/lib/project-mcp.js +2 -2
- package/lib/project-notifications.js +5 -4
- package/lib/project-pair-result-delivery.js +2 -2
- package/lib/project-pair-usage.js +12 -13
- package/lib/project-pending-message-queue.js +3 -1
- package/lib/project-product-control.js +3 -1
- package/lib/project-scheduled-messages.js +4 -4
- package/lib/project-scheduled-task-control.js +1 -1
- package/lib/project-session-document.js +20 -5
- package/lib/project-session-history-actions.js +5 -3
- package/lib/project-session-pair.js +1 -1
- package/lib/project-session-runtime-actions.js +2 -1
- package/lib/project-session-spawn.js +2 -3
- package/lib/project-session-vendor.js +2 -1
- package/lib/project-sessions.js +18 -26
- package/lib/project-shared-browser.js +22 -5
- package/lib/project-studio-presentation.js +58 -0
- package/lib/project-user-message.js +37 -0
- package/lib/project-vendor-login.js +6 -36
- package/lib/project-workspace-query.js +11 -1
- package/lib/project.js +24 -7
- package/lib/public/app.js +25 -0
- package/lib/public/appearance-bootstrap.js +2 -0
- package/lib/public/css/contextual-clay.css +240 -0
- package/lib/public/css/messages.css +6 -2
- package/lib/public/modules/app-favicon.js +18 -9
- package/lib/public/modules/app-header.js +4 -2
- package/lib/public/modules/app-loop-ui.js +2 -0
- package/lib/public/modules/app-message-router.js +5 -1
- package/lib/public/modules/app-messages.js +50 -6
- package/lib/public/modules/app-notifications.js +11 -5
- package/lib/public/modules/app-panels.js +61 -123
- package/lib/public/modules/app-projects.js +3 -0
- package/lib/public/modules/app-rate-limit.js +7 -27
- package/lib/public/modules/chat-render-runtime.js +3 -0
- package/lib/public/modules/clay-control-activity.js +214 -0
- package/lib/public/modules/clay-control-copy.js +36 -0
- package/lib/public/modules/clay-control-detail-targets.js +44 -0
- package/lib/public/modules/clay-control-object-targets.js +52 -0
- package/lib/public/modules/clay-control-target-visibility.js +12 -0
- package/lib/public/modules/clay-control-targets.js +44 -0
- package/lib/public/modules/clay-navigation-render.js +52 -0
- package/lib/public/modules/clay-owner-navigation.js +11 -2
- package/lib/public/modules/clay-session-links.js +31 -0
- package/lib/public/modules/clay-studio-bridge.js +20 -0
- package/lib/public/modules/clay-studio-document.js +67 -0
- package/lib/public/modules/clay-studio-render.js +144 -0
- package/lib/public/modules/clay-tool-presentation.js +4 -0
- package/lib/public/modules/command-palette.js +26 -31
- package/lib/public/modules/contextual-ask-session.js +26 -0
- package/lib/public/modules/contextual-clay-geometry.js +155 -0
- package/lib/public/modules/contextual-clay-session.js +130 -0
- package/lib/public/modules/contextual-clay-workspace.js +157 -0
- package/lib/public/modules/contextual-clay.js +237 -0
- package/lib/public/modules/contextual-composer.js +91 -0
- package/lib/public/modules/contextual-mate-context.js +115 -0
- package/lib/public/modules/contextual-mate-hint.js +40 -0
- package/lib/public/modules/contextual-mate-identity.js +23 -0
- package/lib/public/modules/contextual-mate-sessions.js +134 -0
- package/lib/public/modules/contextual-search.js +137 -0
- package/lib/public/modules/contextual-session-citations.js +58 -0
- package/lib/public/modules/filebrowser.js +20 -1
- package/lib/public/modules/generation-stop.js +8 -5
- package/lib/public/modules/git-panel.js +3 -1
- package/lib/public/modules/icon-strip-tooltip.js +2 -1
- package/lib/public/modules/input.js +35 -1
- package/lib/public/modules/issues-render.js +3 -2
- package/lib/public/modules/knowledge-db-workbench.js +4 -4
- package/lib/public/modules/markdown.js +2 -34
- package/lib/public/modules/mate-knowledge-workbench.js +1 -1
- package/lib/public/modules/mcp-connection-view.js +1 -1
- package/lib/public/modules/message-delivery.js +10 -0
- package/lib/public/modules/pane-bridge.js +2 -2
- package/lib/public/modules/pending-message-queue.js +1 -0
- package/lib/public/modules/permission-control.js +5 -4
- package/lib/public/modules/product-review.js +26 -0
- package/lib/public/modules/project-chat-identity.js +13 -4
- package/lib/public/modules/project-logs-render.js +3 -0
- package/lib/public/modules/project-mate-navigation.js +58 -21
- package/lib/public/modules/scheduled-tasks.js +2 -0
- package/lib/public/modules/scheduler.js +2 -0
- package/lib/public/modules/search-clay-chat.js +5 -454
- package/lib/public/modules/session-create-form.js +10 -10
- package/lib/public/modules/settings-defaults.js +27 -28
- package/lib/public/modules/shared-browser.js +2 -0
- package/lib/public/modules/sidebar-mobile.js +4 -3
- package/lib/public/modules/sidebar-projects.js +1 -0
- package/lib/public/modules/sidebar-sessions.js +1 -0
- package/lib/public/modules/split-view.js +7 -16
- package/lib/public/modules/terminal.js +9 -0
- package/lib/public/modules/tools.js +6 -2
- package/lib/public/modules/tui-grab.js +1 -2
- package/lib/public/modules/vendor-login-browser.js +5 -3
- package/lib/public/modules/vendor-login.js +2 -2
- package/lib/public/modules/vendor-priority.js +15 -1
- package/lib/public/modules/wireframe-workbench.js +5 -2
- package/lib/public/muse-avatar.svg +4 -0
- package/lib/public/style.css +2 -0
- package/lib/safe-bash-commands.js +3 -45
- package/lib/sdk-bridge.js +131 -395
- package/lib/sdk-foreground-admission.js +16 -0
- package/lib/sdk-mcp-descriptors.js +2 -37
- package/lib/sdk-message-processor.js +50 -17
- package/lib/sdk-quota-snapshot.js +1 -1
- package/lib/sdk-response-recovery.js +1 -155
- package/lib/sdk-worker.js +2 -677
- package/lib/server-contextual-clay-settings.js +40 -0
- package/lib/server-contextual-mate-sessions.js +70 -0
- package/lib/server-home-chat.js +7 -1
- package/lib/server-home-clay-entry.js +23 -4
- package/lib/server-home-clay-session-links.js +12 -0
- package/lib/server-owner-ui.js +49 -8
- package/lib/server-settings.js +2 -0
- package/lib/server.js +18 -1
- package/lib/session-fork-history.js +21 -0
- package/lib/session-hygiene.js +3 -35
- package/lib/session-permission-mode.js +4 -3
- package/lib/session-skill-scope.js +11 -0
- package/lib/sessions.js +24 -89
- package/lib/terminal-manager.js +18 -11
- package/lib/tool-llm.js +1 -1
- package/lib/tui-transcript-index.js +1 -132
- package/lib/users-contextual-clay-preferences.js +31 -0
- package/lib/users.js +3 -0
- package/lib/vendor-login-browser.js +1 -11
- package/lib/workspace-assignment-service.js +25 -0
- package/lib/workspace-query-mcp-server.js +1 -1
- package/lib/ws-request.js +1 -0
- package/lib/ws-schema.js +10 -0
- package/lib/yoke/acp-agent-profiles.js +5 -3
- package/lib/yoke/adapters/antigravity.js +3 -14
- package/lib/yoke/adapters/claude-query-contract.js +9 -0
- package/lib/yoke/adapters/claude.js +7 -42
- package/lib/yoke/adapters/codex-query-contract.js +24 -0
- package/lib/yoke/adapters/codex.js +1 -0
- package/lib/yoke/adapters/kiro.js +3 -1
- package/lib/yoke/adapters/muse-query-contract.js +7 -0
- package/lib/yoke/adapters/muse.js +122 -0
- package/lib/yoke/auth-events.js +17 -0
- package/lib/yoke/claude-hook-installer.js +271 -0
- package/lib/yoke/claude-jsonl-watcher.js +204 -0
- package/lib/yoke/claude-maintenance.js +55 -0
- package/lib/yoke/claude-permission-patterns.js +53 -0
- package/lib/yoke/claude-response-recovery.js +155 -0
- package/lib/yoke/claude-transcript-hygiene.js +34 -0
- package/lib/yoke/clay-skill-install.js +33 -0
- package/lib/yoke/cli-sessions.js +300 -0
- package/lib/yoke/codex-app-server.js +7 -12
- package/lib/yoke/configuration.js +13 -0
- package/lib/yoke/discovery.js +70 -0
- package/lib/yoke/errors.js +8 -0
- package/lib/yoke/host-environment.js +7 -0
- package/lib/yoke/index.js +9 -51
- package/lib/yoke/interface.js +116 -0
- package/lib/yoke/kiro-acp-server.js +5 -5
- package/lib/yoke/legacy-sessions.js +89 -0
- package/lib/yoke/login-protocol.js +25 -0
- package/lib/yoke/maintenance.js +12 -0
- package/lib/yoke/mcp-proxy.js +32 -0
- package/lib/yoke/mcp-source-adapters.js +91 -0
- package/lib/yoke/mcp-source-context.js +42 -0
- package/lib/yoke/mcp-source-discovery.js +169 -0
- package/lib/yoke/mcp-source-plugins.js +68 -0
- package/lib/yoke/mcp-source-restrictions.js +47 -0
- package/lib/yoke/mcp-tool-policy-normalize.js +28 -0
- package/lib/yoke/model-preferences.js +6 -0
- package/lib/yoke/muse-artifacts.js +36 -0
- package/lib/yoke/muse-controls.js +50 -0
- package/lib/yoke/muse-input.js +64 -0
- package/lib/yoke/muse-items.js +157 -0
- package/lib/yoke/muse-policy.js +52 -0
- package/lib/yoke/muse-query.js +428 -0
- package/lib/yoke/muse-runtime.js +211 -0
- package/lib/yoke/muse-services.js +79 -0
- package/lib/yoke/muse-skills.js +79 -0
- package/lib/yoke/muse-turns.js +71 -0
- package/lib/yoke/options/acp.js +2 -0
- package/lib/yoke/options/antigravity.js +2 -0
- package/lib/yoke/options/claude.js +21 -0
- package/lib/yoke/options/codex-defaults.js +29 -0
- package/lib/yoke/options/codex-settings.js +21 -0
- package/lib/yoke/options/codex.js +6 -0
- package/lib/yoke/options/kiro-defaults.js +22 -0
- package/lib/yoke/options/kiro.js +5 -0
- package/lib/yoke/options/muse.js +5 -0
- package/lib/yoke/provider-contract.js +5 -0
- package/lib/yoke/providers/antigravity-executable.js +8 -0
- package/lib/yoke/providers/claude-executable.js +40 -0
- package/lib/yoke/providers/claude-model-descriptions.js +14 -0
- package/lib/yoke/providers/claude-process.js +97 -0
- package/lib/yoke/providers/claude-provision.js +75 -0
- package/lib/yoke/providers/codex-errors.js +8 -0
- package/lib/yoke/providers/muse-executable.js +17 -0
- package/lib/yoke/provisioning.js +6 -0
- package/lib/yoke/query-options.js +10 -0
- package/lib/yoke/response-recovery.js +41 -0
- package/lib/yoke/sdk-mcp-descriptors.js +37 -0
- package/lib/yoke/sdk-server-factory.js +7 -0
- package/lib/yoke/session-history.js +8 -0
- package/lib/yoke/session-tool-transport.js +31 -13
- package/lib/yoke/settings.js +23 -0
- package/lib/yoke/source-locations.js +4 -0
- package/lib/yoke/title-query.js +18 -7
- package/lib/yoke/tui-transcript-index.js +132 -0
- package/lib/yoke/usage.js +48 -0
- package/lib/yoke/user-input.js +13 -0
- package/lib/yoke/vendor-registry.js +81 -1
- package/package.json +3 -2
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { handleStudioDocumentMessage } from './clay-studio-document.js';
|
|
2
|
+
import { handleClayControlActivity } from './clay-control-activity.js';
|
|
3
|
+
import { handleContextualWorkspaceMessage } from './contextual-clay-workspace.js';
|
|
4
|
+
import { handleContextualSessionMessage } from './contextual-clay-session.js';
|
|
1
5
|
import { handleOwnerNavigation } from './clay-owner-navigation.js';
|
|
2
6
|
import { leaveRevokedProject } from './project-access-recovery.js';
|
|
3
7
|
import { handlePersonalSettingsMessage } from './user-settings-preferences.js';
|
|
@@ -62,7 +66,7 @@ import { handleProjectOwnerChanged } from './project-settings.js';
|
|
|
62
66
|
import { handleProjectEnv, handleProjectEnvSaved } from './project-settings-environment.js';
|
|
63
67
|
import { handleProjectSessionVisibilityDefault, refreshProjectSessionVisibilitySettings } from './project-session-visibility-settings.js';
|
|
64
68
|
import { updateSettingsStats, updateDaemonConfig, handleSetPinResult, handleKeepAwakeChanged, handleAutoContinueChanged, handleRestartResult, handleShutdownResult, handleSharedEnv, handleSharedEnvSaved, handleServerSettingResult } from './server-settings.js';
|
|
65
|
-
import { handleTermList, handleTermCreated, sendTerminalCommand, handleTermOutput, handleTermResized, handleTermExited, handleTermClosed } from './terminal.js';
|
|
69
|
+
import { handleTerminalProjection, handleTermList, handleTermCreated, sendTerminalCommand, handleTermOutput, handleTermResized, handleTermExited, handleTermClosed } from './terminal.js';
|
|
66
70
|
import { attachTuiView, detachTuiView, setTuiSuspendedView, tuiHandleTermOutput, tuiHandleTermResized, tuiHandleTermExited, tuiHandleTermClosed } from './session-tui-view.js';
|
|
67
71
|
import { handleTuiTranscriptState } from './tui-grab.js';
|
|
68
72
|
import { tuiModalHandleTermOutput, tuiModalHandleTermResized, tuiModalHandleTermExited, tuiModalHandleTermClosed } from './tui-attention.js';
|
|
@@ -121,6 +125,8 @@ var connectOverlay = document.getElementById("connect-overlay");
|
|
|
121
125
|
initMessageDeliveryUi();
|
|
122
126
|
|
|
123
127
|
export function processMessage(msg) {
|
|
128
|
+
if (handleStudioDocumentMessage(msg)) return;
|
|
129
|
+
if (handleClayControlActivity(msg)) return;
|
|
124
130
|
if (handleOwnerNavigation(msg)) return;
|
|
125
131
|
if (["update_available", "up_to_date", "update_started", "update_check_failed"].indexOf(msg.type) !== -1) handleServerUpdate(msg);
|
|
126
132
|
if (/^(set_pin|set_keep_awake|set_inherit_groups|set_image_retention|set_update_channel|restart_server|shutdown_server)_result$/.test(msg.type)) handleServerSettingResult(msg);
|
|
@@ -230,6 +236,8 @@ export function processMessage(msg) {
|
|
|
230
236
|
|
|
231
237
|
store.set({ currentHistoryIndex: Number.isSafeInteger(msg._historyIndex) && msg._historyIndex >= 0 ? msg._historyIndex : null,
|
|
232
238
|
currentHistoryIndexes: Array.isArray(msg._historyIndexes) ? msg._historyIndexes : null });
|
|
239
|
+
if (handleContextualSessionMessage(msg)) return;
|
|
240
|
+
handleContextualWorkspaceMessage(msg);
|
|
233
241
|
switch (msg.type) {
|
|
234
242
|
case "message_ack":
|
|
235
243
|
var acknowledgedEntry = acknowledgeMessage(msg.clientMessageId);
|
|
@@ -260,6 +268,7 @@ export function processMessage(msg) {
|
|
|
260
268
|
break;
|
|
261
269
|
|
|
262
270
|
case "history_done":
|
|
271
|
+
if (messagesEl && msg.sessionId === store.get("activeSessionId") && msg.sessionOriginId === store.get("sessionOriginId")) { messagesEl.dataset.controlSessionId = String(msg.sessionId); messagesEl.dataset.controlSessionOrigin = msg.sessionOriginId; messagesEl.dataset.controlHistoryRevision = msg.controlHistoryRevision || ""; }
|
|
263
272
|
store.set({ replayingHistory: false });
|
|
264
273
|
resumeThinkingAfterReplay(store.get('sessionIsProcessing'));
|
|
265
274
|
// Batched syntax highlight + mermaid pass for the entire replayed
|
|
@@ -282,7 +291,7 @@ export function processMessage(msg) {
|
|
|
282
291
|
|
|
283
292
|
// Restore accurate context data from the last result in full history
|
|
284
293
|
if (msg.lastUsage || msg.lastModelUsage) {
|
|
285
|
-
accumulateContext(msg.lastCost, msg.lastUsage, msg.lastModelUsage, msg.lastStreamInputTokens);
|
|
294
|
+
accumulateContext(msg.lastCost, msg.lastUsage, msg.lastModelUsage, msg.lastStreamInputTokens, msg.context);
|
|
286
295
|
}
|
|
287
296
|
updateContextPanel();
|
|
288
297
|
updateUsagePanel();
|
|
@@ -290,6 +299,7 @@ export function processMessage(msg) {
|
|
|
290
299
|
// the restored turn instead of starting a second answer bubble.
|
|
291
300
|
if (store.get('sessionIsProcessing')) {
|
|
292
301
|
flushStreamBuffer();
|
|
302
|
+
if (store.get('turnActivity')) setActivity(store.get('turnActivity').phase);
|
|
293
303
|
} else {
|
|
294
304
|
markAllToolsDone();
|
|
295
305
|
finalizeAssistantBlock();
|
|
@@ -376,6 +386,7 @@ export function processMessage(msg) {
|
|
|
376
386
|
break;
|
|
377
387
|
|
|
378
388
|
case "info":
|
|
389
|
+
store.set({ controlRuntimeId: msg.controlRuntimeId || null });
|
|
379
390
|
if (msg.text && !msg.project && !msg.cwd) {
|
|
380
391
|
addSystemMessage(msg.text, false);
|
|
381
392
|
break;
|
|
@@ -912,7 +923,7 @@ export function processMessage(msg) {
|
|
|
912
923
|
? msg.runtimeTerminalId
|
|
913
924
|
: (typeof msg.terminalId === "number" ? msg.terminalId : null);
|
|
914
925
|
var _sessionRole = msg.sessionRole === "worker" ? "worker" : "driver";
|
|
915
|
-
store.set({ activeSessionId: msg.id, sessionOriginId: msg.sessionOriginId || null, cliSessionId: msg.cliSessionId || null, currentModel: msg.model || "", currentEffort: msg.effort || store.get('currentEffort'), vendorCapabilities: msg.capabilities || {}, sessionIsProcessing: !!msg.isProcessing, activeSessionMode: _effectiveMode, activeTerminalId: _effectiveTerminalId, sessionHasHistory: !!msg.hasHistory, sessionVendorBound: !!msg.vendor || !!msg.hasHistory, sessionFullAccess: msg.permissionMode === "bypassPermissions", currentMode: msg.permissionMode || store.get('currentMode'), effectivePermissionMode: msg.effectivePermissionMode || null, permissionCapabilities: msg.permissionCapabilities || { auto: false, mcpOverride: false }, mcpPermissionModeOverrides: msg.mcpPermissionModeOverrides || {}, activeSessionMateId: _sessionRole === "worker" ? null : (store.get('activeProjectMateId') || null), activeSessionMateName: _sessionRole === "worker" ? "" : (store.get('activeProjectMateName') || "") });
|
|
926
|
+
store.set({ activeSessionId: msg.id, sessionOriginId: msg.sessionOriginId || null, cliSessionId: msg.cliSessionId || null, currentModel: msg.model || "", currentEffort: msg.effort || store.get('currentEffort'), vendorCapabilities: msg.capabilities || {}, sessionIsProcessing: !!msg.isProcessing, turnActivity: null, activeSessionMode: _effectiveMode, activeTerminalId: _effectiveTerminalId, sessionHasHistory: !!msg.hasHistory, sessionVendorBound: !!msg.vendor || !!msg.hasHistory, sessionFullAccess: msg.permissionMode === "bypassPermissions", currentMode: msg.permissionMode || store.get('currentMode'), effectivePermissionMode: msg.effectivePermissionMode || null, permissionCapabilities: msg.permissionCapabilities || { auto: false, mcpOverride: false }, mcpPermissionModeOverrides: msg.mcpPermissionModeOverrides || {}, activeSessionMateId: _sessionRole === "worker" ? null : (store.get('activeProjectMateId') || null), activeSessionMateName: _sessionRole === "worker" ? "" : (store.get('activeProjectMateName') || "") });
|
|
916
927
|
handleScheduledTaskSessionSwitched(msg);
|
|
917
928
|
requestLoopInterviewState();
|
|
918
929
|
activateDeliverySession(msg.id, msg.cliSessionId || null, msg.sessionOriginId || null);
|
|
@@ -1039,7 +1050,11 @@ export function processMessage(msg) {
|
|
|
1039
1050
|
// running session, where history_done keeps current tools active.
|
|
1040
1051
|
// Question answers, plan feedback and Driver delegations are injected
|
|
1041
1052
|
// mid-turn, so tools before them may still be running.
|
|
1042
|
-
else if (!msg.askUserAnswer && !msg.planFeedback && !msg.delegated)
|
|
1053
|
+
else if (!msg.askUserAnswer && !msg.planFeedback && !msg.delegated) {
|
|
1054
|
+
markAllToolsDone();
|
|
1055
|
+
// Older histories predate explicit foreground presentation boundaries.
|
|
1056
|
+
finalizeAssistantBlock();
|
|
1057
|
+
}
|
|
1043
1058
|
resetThinkingGroup();
|
|
1044
1059
|
if (msg.planContent) {
|
|
1045
1060
|
setPlanContent(msg.planContent);
|
|
@@ -1136,7 +1151,7 @@ export function processMessage(msg) {
|
|
|
1136
1151
|
// events make it through.
|
|
1137
1152
|
removeMatePreThinking();
|
|
1138
1153
|
if (!(store.get('dmMode') && store.get('dmTargetUser') && store.get('dmTargetUser').isMate) && !store.get('matePreThinkingEl')) {
|
|
1139
|
-
setActivity("thinking");
|
|
1154
|
+
setActivity((store.get("turnActivity") || {}).phase || "thinking");
|
|
1140
1155
|
}
|
|
1141
1156
|
}
|
|
1142
1157
|
break;
|
|
@@ -1172,8 +1187,24 @@ export function processMessage(msg) {
|
|
|
1172
1187
|
}
|
|
1173
1188
|
break;
|
|
1174
1189
|
|
|
1190
|
+
case "turn_activity":
|
|
1191
|
+
if (["waiting", "running", "background"].indexOf(msg.phase) === -1) break;
|
|
1192
|
+
store.set({ turnActivity: { phase: msg.phase, turnId: msg.turnId || null, disposition: msg.disposition || null } });
|
|
1193
|
+
if (!store.get('replayingHistory') && store.get('sessionIsProcessing')) {
|
|
1194
|
+
removeMatePreThinking();
|
|
1195
|
+
setActivity(msg.phase);
|
|
1196
|
+
}
|
|
1197
|
+
break;
|
|
1198
|
+
|
|
1199
|
+
case "assistant_boundary":
|
|
1200
|
+
// Foreground presentation ended; background work still owns its real
|
|
1201
|
+
// terminal. Flush pending animation text without finishing tools/Stop.
|
|
1202
|
+
finalizeAssistantBlock();
|
|
1203
|
+
break;
|
|
1204
|
+
|
|
1175
1205
|
case "delta":
|
|
1176
1206
|
if (typeof msg.text !== "string") break;
|
|
1207
|
+
store.set({ turnActivity: null });
|
|
1177
1208
|
removeMatePreThinking();
|
|
1178
1209
|
stopThinking();
|
|
1179
1210
|
setActivity(null);
|
|
@@ -1221,6 +1252,8 @@ export function processMessage(msg) {
|
|
|
1221
1252
|
renderMcpDebateProposal(msg.id, msg.input);
|
|
1222
1253
|
startUrgentBlink();
|
|
1223
1254
|
} else if (msg.name === "AskUserQuestion" && msg.input && msg.input.questions) {
|
|
1255
|
+
store.set({ turnActivity: null });
|
|
1256
|
+
setActivity(null);
|
|
1224
1257
|
var askTool = getTools()[msg.id];
|
|
1225
1258
|
if (askTool) {
|
|
1226
1259
|
if (askTool.el) askTool.el.style.display = "none";
|
|
@@ -1301,6 +1334,7 @@ export function processMessage(msg) {
|
|
|
1301
1334
|
break;
|
|
1302
1335
|
|
|
1303
1336
|
case "permission_request":
|
|
1337
|
+
store.set({ turnActivity: null });
|
|
1304
1338
|
setActivity(null);
|
|
1305
1339
|
renderPermissionRequest(msg.requestId, msg.toolName, msg.toolInput, msg.decisionReason, msg.mateId, msg.vendor, msg);
|
|
1306
1340
|
startUrgentBlink();
|
|
@@ -1317,12 +1351,15 @@ export function processMessage(msg) {
|
|
|
1317
1351
|
break;
|
|
1318
1352
|
|
|
1319
1353
|
case "permission_request_pending":
|
|
1354
|
+
store.set({ turnActivity: null });
|
|
1320
1355
|
setActivity(null);
|
|
1321
1356
|
renderPermissionRequest(msg.requestId, msg.toolName, msg.toolInput, msg.decisionReason, msg.mateId, msg.vendor, msg);
|
|
1322
1357
|
startUrgentBlink();
|
|
1323
1358
|
break;
|
|
1324
1359
|
|
|
1325
1360
|
case "elicitation_request":
|
|
1361
|
+
store.set({ turnActivity: null });
|
|
1362
|
+
setActivity(null);
|
|
1326
1363
|
renderElicitationRequest(msg);
|
|
1327
1364
|
startUrgentBlink();
|
|
1328
1365
|
break;
|
|
@@ -1337,6 +1374,8 @@ export function processMessage(msg) {
|
|
|
1337
1374
|
break;
|
|
1338
1375
|
|
|
1339
1376
|
case "user_dialog_request":
|
|
1377
|
+
store.set({ turnActivity: null });
|
|
1378
|
+
setActivity(null);
|
|
1340
1379
|
renderUserDialogRequest(msg);
|
|
1341
1380
|
startUrgentBlink();
|
|
1342
1381
|
break;
|
|
@@ -1402,7 +1441,7 @@ export function processMessage(msg) {
|
|
|
1402
1441
|
finalizeAssistantBlock();
|
|
1403
1442
|
addTurnMeta(msg.cost, msg.duration);
|
|
1404
1443
|
accumulateUsage(msg.cost, msg.usage);
|
|
1405
|
-
accumulateContext(msg.cost, msg.usage, msg.modelUsage, msg.lastStreamInputTokens);
|
|
1444
|
+
accumulateContext(msg.cost, msg.usage, msg.modelUsage, msg.lastStreamInputTokens, msg.context);
|
|
1406
1445
|
break;
|
|
1407
1446
|
|
|
1408
1447
|
case "context_usage":
|
|
@@ -1415,6 +1454,7 @@ export function processMessage(msg) {
|
|
|
1415
1454
|
break;
|
|
1416
1455
|
|
|
1417
1456
|
case "done":
|
|
1457
|
+
store.set({ turnActivity: null });
|
|
1418
1458
|
removeMatePreThinking();
|
|
1419
1459
|
setActivity(null);
|
|
1420
1460
|
finishThinkingTurn();
|
|
@@ -1438,6 +1478,7 @@ export function processMessage(msg) {
|
|
|
1438
1478
|
break;
|
|
1439
1479
|
|
|
1440
1480
|
case "error":
|
|
1481
|
+
store.set({ turnActivity: null });
|
|
1441
1482
|
removeMatePreThinking();
|
|
1442
1483
|
setActivity(null);
|
|
1443
1484
|
finishThinkingTurn();
|
|
@@ -1662,6 +1703,9 @@ export function processMessage(msg) {
|
|
|
1662
1703
|
handleFileAt(msg);
|
|
1663
1704
|
break;
|
|
1664
1705
|
|
|
1706
|
+
case "term_control_projection":
|
|
1707
|
+
handleTerminalProjection(msg);
|
|
1708
|
+
break;
|
|
1665
1709
|
case "term_list":
|
|
1666
1710
|
handleTermList(msg);
|
|
1667
1711
|
updateTerminalList(msg.terminals);
|
|
@@ -26,8 +26,7 @@ function getVendorLoginCommand(vendor) {
|
|
|
26
26
|
var vendors = store.get('vendorInfo') || {};
|
|
27
27
|
var info = vendors[vendor];
|
|
28
28
|
if (info && info.loginCommand) return info.loginCommand;
|
|
29
|
-
|
|
30
|
-
return fallbacks[vendor] || fallbacks.claude;
|
|
29
|
+
return "";
|
|
31
30
|
}
|
|
32
31
|
|
|
33
32
|
// --- Pending TUI attention tracking ---
|
|
@@ -135,7 +134,7 @@ function showBanner(notif, autoDismissMs) {
|
|
|
135
134
|
|
|
136
135
|
var banner = document.createElement("div");
|
|
137
136
|
banner.className = "notif-banner" + (isAuthRequired ? " notif-banner-update notif-banner-auth" : isPermission ? " notif-banner-permission" : isUserMention ? " notif-banner-user-mention" : "");
|
|
138
|
-
if (!isEmpty) banner.setAttribute("data-notif-id", notif.id);
|
|
137
|
+
if (!isEmpty) { banner.setAttribute("data-notif-id", notif.id); banner.dataset.controlRevision = notif.controlRevision || ""; }
|
|
139
138
|
if (isAuthRequired) banner.setAttribute("data-auth-banner", "true");
|
|
140
139
|
|
|
141
140
|
var iconHtmlStr = userMentionAvatarSrc
|
|
@@ -470,7 +469,12 @@ export function getPendingTuiAttention(slug) {
|
|
|
470
469
|
}
|
|
471
470
|
|
|
472
471
|
export function handleNotificationsState(msg) {
|
|
473
|
-
notifications = msg.notifications || [];
|
|
472
|
+
notifications = msg.notifications || []; store.set({ clayControlNotifications: notifications });
|
|
473
|
+
// Authoritative snapshots also withdraw banners removed by reviewed canonical actions.
|
|
474
|
+
if (bannerContainer) Array.from(bannerContainer.querySelectorAll('[data-notif-id]')).forEach(function (banner) {
|
|
475
|
+
var id = banner.dataset.notifId;
|
|
476
|
+
if (id.charAt(0) !== '_' && !notifications.some(function (item) { return item.id === id; })) removeBanner(banner);
|
|
477
|
+
});
|
|
474
478
|
unreadCount = msg.unreadCount || 0;
|
|
475
479
|
updateBadge();
|
|
476
480
|
|
|
@@ -501,6 +505,7 @@ export function handleNotificationsState(msg) {
|
|
|
501
505
|
|
|
502
506
|
export function handleNotificationCreated(msg) {
|
|
503
507
|
var notif = msg.notification;
|
|
508
|
+
store.set({ clayControlNotifications: [notif].concat((store.get("clayControlNotifications") || []).filter(function (item) { return item.id !== notif.id; })) });
|
|
504
509
|
|
|
505
510
|
// Auto-dismiss if it's for the session the user is currently viewing
|
|
506
511
|
var activeSession = store.get('activeSessionId') || null;
|
|
@@ -511,6 +516,7 @@ export function handleNotificationCreated(msg) {
|
|
|
511
516
|
}
|
|
512
517
|
|
|
513
518
|
notifications.unshift(notif);
|
|
519
|
+
store.set({ clayControlNotifications: notifications });
|
|
514
520
|
unreadCount = msg.unreadCount;
|
|
515
521
|
updateBadge();
|
|
516
522
|
|
|
@@ -568,7 +574,7 @@ export function handleNotificationDismissed(msg) {
|
|
|
568
574
|
}
|
|
569
575
|
|
|
570
576
|
export function handleNotificationDismissedAll() {
|
|
571
|
-
notifications = [];
|
|
577
|
+
notifications = []; store.set({ clayControlNotifications: [] });
|
|
572
578
|
unreadCount = 0;
|
|
573
579
|
updateBadge();
|
|
574
580
|
if (bannerContainer) bannerContainer.innerHTML = "";
|
|
@@ -93,42 +93,6 @@ var MODE_OPTIONS = [
|
|
|
93
93
|
var MODE_FULL_AUTO = { value: "auto", label: "Auto" };
|
|
94
94
|
var MODE_SKIP = { value: "bypassPermissions", label: "Skip permissions" };
|
|
95
95
|
var EFFORT_LEVELS = ["low", "medium", "high", "xhigh", "max"];
|
|
96
|
-
var EFFORT_LEVELS_BY_VENDOR = {
|
|
97
|
-
claude: ["low", "medium", "high", "xhigh", "max"],
|
|
98
|
-
codex: ["low", "medium", "high", "xhigh", "max"],
|
|
99
|
-
antigravity: [],
|
|
100
|
-
opencode: [],
|
|
101
|
-
kiro: ["low", "medium", "high", "xhigh", "max"],
|
|
102
|
-
};
|
|
103
|
-
var THINKING_OPTIONS = ["disabled", "adaptive", "budget"];
|
|
104
|
-
var CODEX_APPROVAL_OPTIONS = [
|
|
105
|
-
{ value: "never", label: "Auto" },
|
|
106
|
-
{ value: "untrusted", label: "Untrusted" },
|
|
107
|
-
{ value: "on-request", label: "Ask" },
|
|
108
|
-
];
|
|
109
|
-
var CODEX_SANDBOX_OPTIONS = [
|
|
110
|
-
{ value: "read-only", label: "Read Only" },
|
|
111
|
-
{ value: "workspace-write", label: "Workspace" },
|
|
112
|
-
{ value: "danger-full-access", label: "Full Access" },
|
|
113
|
-
];
|
|
114
|
-
var CODEX_WEBSEARCH_OPTIONS = [
|
|
115
|
-
{ value: "disabled", label: "Off" },
|
|
116
|
-
{ value: "cached", label: "Cached" },
|
|
117
|
-
{ value: "live", label: "Live" },
|
|
118
|
-
];
|
|
119
|
-
var KNOWN_CONTEXT_WINDOWS = {
|
|
120
|
-
"opus-4-6": 1000000,
|
|
121
|
-
"claude-sonnet-4": 1000000,
|
|
122
|
-
"gpt-6-astra": 1050000,
|
|
123
|
-
"gpt-5.6": 1050000,
|
|
124
|
-
"gpt-5.5": 1048576,
|
|
125
|
-
"gpt-5.4": 1048576,
|
|
126
|
-
"gpt-5.3": 1048576,
|
|
127
|
-
"gpt-5.2": 1048576,
|
|
128
|
-
"gpt-4.1": 1047576,
|
|
129
|
-
"o3": 200000,
|
|
130
|
-
"o4-mini": 200000,
|
|
131
|
-
};
|
|
132
96
|
// Categories to hide from the legend (noise, not actionable)
|
|
133
97
|
var CTX_HIDDEN_CATS = { "Free space": 1, "Autocompact buffer": 1 };
|
|
134
98
|
|
|
@@ -160,12 +124,12 @@ export function effortDisplayName(value) {
|
|
|
160
124
|
// uses this for sessions other than the active one). Falls back from the
|
|
161
125
|
// model's own supportedEffortLevels to the vendor table.
|
|
162
126
|
export function effortLevelsFor(vendor, models, modelValue) {
|
|
163
|
-
var defaults =
|
|
127
|
+
var defaults = ((store.get("vendorInfo") || {})[vendor] || {}).effortLevels || [];
|
|
164
128
|
var list = models || [];
|
|
165
129
|
for (var i = 0; i < list.length; i++) {
|
|
166
130
|
var value = typeof list[i] === "string" ? list[i] : (list[i] && (list[i].value || list[i].id)) || "";
|
|
167
131
|
if (value === modelValue) {
|
|
168
|
-
if (
|
|
132
|
+
if (Array.isArray(list[i].supportedEffortLevels)) {
|
|
169
133
|
return list[i].supportedEffortLevels;
|
|
170
134
|
}
|
|
171
135
|
return defaults;
|
|
@@ -182,9 +146,8 @@ function thinkingDisplayName(value) {
|
|
|
182
146
|
}
|
|
183
147
|
|
|
184
148
|
function isSonnetModel(model) {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
return lower.indexOf("sonnet") !== -1;
|
|
149
|
+
var models = store.get("currentModels") || [];
|
|
150
|
+
return models.some(function(entry) { return entry && entry.value === model && entry.supportsBetaContext === true; });
|
|
188
151
|
}
|
|
189
152
|
|
|
190
153
|
function hasBeta(name) {
|
|
@@ -198,7 +161,7 @@ function hasBeta(name) {
|
|
|
198
161
|
function rebuildModeList() {
|
|
199
162
|
if (!configModeList) return;
|
|
200
163
|
configModeList.innerHTML = "";
|
|
201
|
-
var options =
|
|
164
|
+
var options = (providerConfiguration().permissionModes || []).slice();
|
|
202
165
|
options.push(MODE_FULL_AUTO);
|
|
203
166
|
options.push(MODE_SKIP);
|
|
204
167
|
var autoSupported = store.get('permissionCapabilities').auto === true;
|
|
@@ -212,8 +175,8 @@ function rebuildModeList() {
|
|
|
212
175
|
btn.textContent = opt.label;
|
|
213
176
|
if (opt.value === "auto" && !autoSupported) {
|
|
214
177
|
btn.disabled = true;
|
|
215
|
-
btn.title = "Auto permissions
|
|
216
|
-
btn.setAttribute("aria-description", "
|
|
178
|
+
btn.title = "Auto permissions are unavailable for this session.";
|
|
179
|
+
btn.setAttribute("aria-description", "The current runtime does not support Auto permissions.");
|
|
217
180
|
}
|
|
218
181
|
if (globallyForced) {
|
|
219
182
|
btn.disabled = true;
|
|
@@ -232,13 +195,13 @@ function rebuildModeList() {
|
|
|
232
195
|
function rebuildEffortBar() {
|
|
233
196
|
if (!configEffortBar || !configEffortSection) return;
|
|
234
197
|
var supportsEffort = getModelSupportsEffort();
|
|
235
|
-
|
|
198
|
+
var levels = getModelEffortLevels();
|
|
199
|
+
if (!supportsEffort || !levels.length) {
|
|
236
200
|
configEffortSection.style.display = "none";
|
|
237
201
|
return;
|
|
238
202
|
}
|
|
239
203
|
configEffortSection.style.display = "";
|
|
240
204
|
configEffortBar.innerHTML = "";
|
|
241
|
-
var levels = getModelEffortLevels();
|
|
242
205
|
for (var i = 0; i < levels.length; i++) {
|
|
243
206
|
var level = levels[i];
|
|
244
207
|
var btn = document.createElement("button");
|
|
@@ -277,8 +240,9 @@ function rebuildThinkingSection() {
|
|
|
277
240
|
configThinkingSection.style.display = "";
|
|
278
241
|
configThinkingBar.innerHTML = "";
|
|
279
242
|
var s = store.snap();
|
|
280
|
-
|
|
281
|
-
|
|
243
|
+
var thinkingOptions = (providerConfiguration().thinking || {}).options || [];
|
|
244
|
+
for (var i = 0; i < thinkingOptions.length; i++) {
|
|
245
|
+
var opt = thinkingOptions[i];
|
|
282
246
|
var btn = document.createElement("button");
|
|
283
247
|
btn.className = "config-segment-btn";
|
|
284
248
|
if (opt === s.currentThinking) btn.classList.add("active");
|
|
@@ -329,22 +293,21 @@ function buildSegmentedBar(barEl, options, currentValue, msgType, msgKey) {
|
|
|
329
293
|
}
|
|
330
294
|
}
|
|
331
295
|
|
|
332
|
-
function
|
|
333
|
-
var
|
|
334
|
-
|
|
296
|
+
function providerConfiguration() {
|
|
297
|
+
var state = store.snap();
|
|
298
|
+
return ((state.vendorInfo || {})[state.currentVendor] || {}).configuration || {};
|
|
299
|
+
}
|
|
335
300
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
if (isCodex) buildSegmentedBar(configSandboxBar, CODEX_SANDBOX_OPTIONS, s.codexSandbox, "set_codex_sandbox", "sandbox");
|
|
343
|
-
}
|
|
344
|
-
if (configWebsearchSection) {
|
|
345
|
-
configWebsearchSection.style.display = isCodex ? "" : "none";
|
|
346
|
-
if (isCodex) buildSegmentedBar(configWebsearchBar, CODEX_WEBSEARCH_OPTIONS, s.codexWebSearch, "set_codex_websearch", "webSearch");
|
|
301
|
+
function rebuildProviderSections() {
|
|
302
|
+
var state = store.snap(), config = providerConfiguration();
|
|
303
|
+
function section(element, bar, description) {
|
|
304
|
+
if (!element) return;
|
|
305
|
+
element.style.display = description ? "" : "none";
|
|
306
|
+
if (description) buildSegmentedBar(bar, description.options || [], state[description.state], description.message, description.key);
|
|
347
307
|
}
|
|
308
|
+
section(configApprovalSection, configApprovalBar, config.approval);
|
|
309
|
+
section(configSandboxSection, configSandboxBar, config.sandbox);
|
|
310
|
+
section(configWebsearchSection, configWebsearchBar, config.webSearch);
|
|
348
311
|
}
|
|
349
312
|
|
|
350
313
|
function escHtml(s) {
|
|
@@ -584,25 +547,17 @@ export function updateConfigChip() {
|
|
|
584
547
|
if (!configChipWrap || !configChip) return;
|
|
585
548
|
configChipWrap.classList.remove("hidden");
|
|
586
549
|
var s = store.snap();
|
|
587
|
-
var vendor = s.currentVendor || "claude";
|
|
588
550
|
configChipLabel.textContent = modelDisplayName(s.currentModel, s.currentModels);
|
|
589
551
|
renderModelPicker();
|
|
590
552
|
rebuildModeList();
|
|
591
553
|
rebuildEffortBar();
|
|
592
554
|
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
if (configModeList && configModeList.parentElement) configModeList.parentElement.style.display = isClaude ? "" : "none";
|
|
555
|
+
var configuration = providerConfiguration();
|
|
556
|
+
if (configModeList && configModeList.parentElement) configModeList.parentElement.style.display = configuration.permissionModes ? "" : "none";
|
|
596
557
|
rebuildThinkingSection();
|
|
597
|
-
|
|
598
|
-
// vendor), NOT "accepts thinking config". The adaptive/extended toggle and
|
|
599
|
-
// budget only feed Claude queries (sm.currentThinking), so the section
|
|
600
|
-
// stays Claude-only until a dedicated thinkingConfig capability exists.
|
|
601
|
-
if (configThinkingSection) configThinkingSection.style.display = isClaude ? "" : "none";
|
|
602
|
-
// BETA section deprecated (1M context is now standard)
|
|
558
|
+
if (configThinkingSection) configThinkingSection.style.display = configuration.thinking ? "" : "none";
|
|
603
559
|
if (configBetaSection) configBetaSection.style.display = "none";
|
|
604
|
-
|
|
605
|
-
rebuildCodexSections();
|
|
560
|
+
rebuildProviderSections();
|
|
606
561
|
}
|
|
607
562
|
|
|
608
563
|
export function getModelSupportsEffort() {
|
|
@@ -645,10 +600,10 @@ export function accumulateUsage(cost, usage) {
|
|
|
645
600
|
// Assign directly instead of summing to avoid overcounting.
|
|
646
601
|
if (cost != null) sessionUsage.cost = cost;
|
|
647
602
|
if (usage) {
|
|
648
|
-
sessionUsage.input += usage.
|
|
649
|
-
sessionUsage.output += usage.
|
|
650
|
-
sessionUsage.cacheRead += usage.
|
|
651
|
-
sessionUsage.cacheWrite += usage.
|
|
603
|
+
sessionUsage.input += usage.inputTokens || 0;
|
|
604
|
+
sessionUsage.output += usage.outputTokens || 0;
|
|
605
|
+
sessionUsage.cacheRead += usage.cacheReadInputTokens || 0;
|
|
606
|
+
sessionUsage.cacheWrite += usage.cacheCreationInputTokens || 0;
|
|
652
607
|
}
|
|
653
608
|
sessionUsage.turns++;
|
|
654
609
|
if (!store.get('replayingHistory')) updateUsagePanel();
|
|
@@ -724,14 +679,8 @@ export function toggleStatusPanel() {
|
|
|
724
679
|
|
|
725
680
|
// --- Context panel ---
|
|
726
681
|
|
|
727
|
-
export function resolveContextWindow(model,
|
|
728
|
-
|
|
729
|
-
if (lc.includes("[1m]")) return 1000000;
|
|
730
|
-
if (sdkValue) return sdkValue;
|
|
731
|
-
for (var key in KNOWN_CONTEXT_WINDOWS) {
|
|
732
|
-
if (lc.includes(key)) return KNOWN_CONTEXT_WINDOWS[key];
|
|
733
|
-
}
|
|
734
|
-
return 200000;
|
|
682
|
+
export function resolveContextWindow(model, reported) {
|
|
683
|
+
return typeof reported === "number" && reported > 0 ? reported : 0;
|
|
735
684
|
}
|
|
736
685
|
|
|
737
686
|
export function contextPctClass(pct) {
|
|
@@ -744,21 +693,21 @@ export function updateContextPanel() {
|
|
|
744
693
|
// only supplies currentInput from a verified last-turn snapshot; rich
|
|
745
694
|
// context usage is more authoritative when available.
|
|
746
695
|
var rich = store.get('richContextUsage');
|
|
747
|
-
var
|
|
748
|
-
|
|
749
|
-
(typeof rich.input_tokens === "number" && typeof rich.contextWindow === "number" && rich.contextWindow > 0)
|
|
750
|
-
);
|
|
696
|
+
var richContext = rich && rich.context;
|
|
697
|
+
var hasRich = richContext && typeof richContext.usedTokens === "number" && typeof richContext.windowTokens === "number" && richContext.windowTokens > 0;
|
|
751
698
|
var hasCurrent = typeof contextData.currentInput === "number";
|
|
752
699
|
var hasContext = !!(hasRich || hasCurrent);
|
|
753
|
-
var used = hasRich ?
|
|
754
|
-
var win = hasRich ?
|
|
700
|
+
var used = hasRich ? richContext.usedTokens : (hasCurrent ? contextData.currentInput : 0);
|
|
701
|
+
var win = hasRich ? richContext.windowTokens : (hasCurrent ? contextData.contextWindow : 0);
|
|
702
|
+
hasContext = hasContext && win > 0;
|
|
703
|
+
var measurement = hasRich ? richContext.measurement : store.get("contextMeasurement");
|
|
755
704
|
var pct = win > 0 ? Math.min(100, (used / win) * 100) : 0;
|
|
756
705
|
var cls = contextPctClass(pct);
|
|
757
706
|
reportPaneContext({ pct: pct, used: used, win: win, cls: cls, model: contextData.model, cost: contextData.cost });
|
|
758
707
|
// Panel bar
|
|
759
708
|
contextBarFill.style.width = pct.toFixed(1) + "%";
|
|
760
709
|
contextBarFill.className = "context-bar-fill" + cls;
|
|
761
|
-
contextBarPct.textContent = pct.toFixed(0) + "%";
|
|
710
|
+
contextBarPct.textContent = hasContext ? pct.toFixed(0) + "%" : "-";
|
|
762
711
|
// Mini bar
|
|
763
712
|
if (contextMiniFill) {
|
|
764
713
|
contextMiniFill.style.width = pct.toFixed(1) + "%";
|
|
@@ -807,7 +756,8 @@ export function updateContextPanel() {
|
|
|
807
756
|
}
|
|
808
757
|
}
|
|
809
758
|
}
|
|
810
|
-
contextUsedEl.textContent = formatTokens(used);
|
|
759
|
+
contextUsedEl.textContent = hasRich || hasCurrent ? (measurement === "estimated" ? "~" : "") + formatTokens(used) : "-";
|
|
760
|
+
contextUsedEl.title = hasRich || hasCurrent ? (measurement === "estimated" ? "Estimated current context" : "Observed current context") : "Current context unavailable";
|
|
811
761
|
contextWindowEl.textContent = win > 0 ? formatTokens(win) : "-";
|
|
812
762
|
contextMaxOutputEl.textContent = contextData.maxOutputTokens > 0 ? formatTokens(contextData.maxOutputTokens) : "-";
|
|
813
763
|
contextInputEl.textContent = formatTokens(contextData.input);
|
|
@@ -829,7 +779,13 @@ export function updateContextPanel() {
|
|
|
829
779
|
contextTurnsEl.textContent = String(contextData.turns);
|
|
830
780
|
}
|
|
831
781
|
|
|
832
|
-
export function accumulateContext(cost, usage, modelUsage, lastStreamInputTokens) {
|
|
782
|
+
export function accumulateContext(cost, usage, modelUsage, lastStreamInputTokens, context) {
|
|
783
|
+
if (context) {
|
|
784
|
+
if (context.source === "last_turn") store.set({ richContextUsage: null });
|
|
785
|
+
store.set({ contextMeasurement: context.measurement || "unavailable" });
|
|
786
|
+
contextData.currentInput = typeof context.usedTokens === "number" ? context.usedTokens : null;
|
|
787
|
+
if (typeof context.windowTokens === "number") contextData.contextWindow = context.windowTokens;
|
|
788
|
+
}
|
|
833
789
|
// cost is the SDK's total_cost_usd -- a cumulative running total, not a delta.
|
|
834
790
|
if (cost != null) contextData.cost = cost;
|
|
835
791
|
// Use latest turn values (not cumulative) since each turn's input_tokens
|
|
@@ -842,17 +798,14 @@ export function accumulateContext(cost, usage, modelUsage, lastStreamInputTokens
|
|
|
842
798
|
if (typeof lastStreamInputTokens === "number") {
|
|
843
799
|
contextData.input = lastStreamInputTokens;
|
|
844
800
|
} else {
|
|
845
|
-
contextData.input = (usage.
|
|
846
|
-
+ (usage.
|
|
847
|
-
}
|
|
848
|
-
contextData.output = usage.output_tokens || usage.outputTokens || 0;
|
|
849
|
-
contextData.cacheRead = usage.cache_read_input_tokens || usage.cacheReadInputTokens || 0;
|
|
850
|
-
contextData.cacheWrite = usage.cache_creation_input_tokens || usage.cacheCreationInputTokens || 0;
|
|
851
|
-
if (store.get('currentVendor') === "codex") {
|
|
852
|
-
contextData.currentInput = typeof lastStreamInputTokens === "number" ? lastStreamInputTokens : null;
|
|
853
|
-
} else {
|
|
854
|
-
contextData.currentInput = typeof lastStreamInputTokens === "number" ? lastStreamInputTokens : contextData.input;
|
|
801
|
+
contextData.input = (usage.inputTokens || 0)
|
|
802
|
+
+ (usage.cacheReadInputTokens || 0);
|
|
855
803
|
}
|
|
804
|
+
contextData.output = usage.outputTokens || 0;
|
|
805
|
+
contextData.cacheRead = usage.cacheReadInputTokens || 0;
|
|
806
|
+
contextData.cacheWrite = usage.cacheCreationInputTokens || 0;
|
|
807
|
+
contextData.currentInput = context && typeof context.usedTokens === "number" ? context.usedTokens : null;
|
|
808
|
+
if (context && typeof context.windowTokens === "number") contextData.contextWindow = context.windowTokens;
|
|
856
809
|
}
|
|
857
810
|
contextData.turns++;
|
|
858
811
|
if (modelUsage) {
|
|
@@ -864,23 +817,8 @@ export function accumulateContext(cost, usage, modelUsage, lastStreamInputTokens
|
|
|
864
817
|
// (e.g. CLI reports "claude-sonnet-4-6" even when running as opus[1m])
|
|
865
818
|
var displayModel = store.get('currentModel') || m;
|
|
866
819
|
contextData.model = displayModel;
|
|
867
|
-
contextData.contextWindow = resolveContextWindow(displayModel, mu.contextWindow);
|
|
820
|
+
contextData.contextWindow = context && typeof context.windowTokens === "number" ? context.windowTokens : resolveContextWindow(displayModel, mu.contextWindow);
|
|
868
821
|
if (mu.maxOutputTokens) contextData.maxOutputTokens = mu.maxOutputTokens;
|
|
869
|
-
if (store.get('currentVendor') === "codex") {
|
|
870
|
-
var snapshot = mu.contextSnapshot;
|
|
871
|
-
if (snapshot) store.set({ richContextUsage: null });
|
|
872
|
-
if (snapshot && snapshot.valid === true
|
|
873
|
-
&& typeof snapshot.inputTokens === "number"
|
|
874
|
-
&& typeof snapshot.contextWindow === "number"
|
|
875
|
-
&& snapshot.contextWindow > 0) {
|
|
876
|
-
contextData.currentInput = snapshot.inputTokens;
|
|
877
|
-
contextData.contextWindow = snapshot.contextWindow;
|
|
878
|
-
} else {
|
|
879
|
-
// An explicit invalid marker is authoritative: do not retain an
|
|
880
|
-
// occupancy value from the previous live turn or history replay.
|
|
881
|
-
contextData.currentInput = null;
|
|
882
|
-
}
|
|
883
|
-
}
|
|
884
822
|
|
|
885
823
|
// thinkingTokens and costBasis are per-model and optional: absent on
|
|
886
824
|
// older CLI builds and, for a resumed session, on the turns that ran
|
|
@@ -1009,8 +947,8 @@ export function renderCtxPopover() {
|
|
|
1009
947
|
if (!ctxPopoverEl || !richContextUsage) return;
|
|
1010
948
|
var d = richContextUsage;
|
|
1011
949
|
var cats = d.categories || [];
|
|
1012
|
-
var total = d.
|
|
1013
|
-
var max = d.
|
|
950
|
+
var total = d.context && d.context.usedTokens || 0;
|
|
951
|
+
var max = d.context && d.context.windowTokens || 0;
|
|
1014
952
|
var pct = d.percentage != null ? d.percentage : (max > 0 ? (total / max) * 100 : 0);
|
|
1015
953
|
|
|
1016
954
|
var html = "";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { prepareContextualWorkspaceDeparture } from './contextual-clay-workspace.js';
|
|
1
2
|
// app-projects.js - Project list, switching, add/remove project modals
|
|
2
3
|
// Extracted from app.js (PR-29)
|
|
3
4
|
|
|
@@ -311,6 +312,7 @@ export function renderProjectList() {
|
|
|
311
312
|
}).map(function (p) {
|
|
312
313
|
return {
|
|
313
314
|
slug: p.slug,
|
|
315
|
+
controlRuntimeId: p.controlRuntimeId || null,
|
|
314
316
|
name: p.title || p.project,
|
|
315
317
|
icon: p.icon || null,
|
|
316
318
|
isProcessing: p.isProcessing,
|
|
@@ -389,6 +391,7 @@ export function resetClientState() {
|
|
|
389
391
|
|
|
390
392
|
export function switchProject(slug) {
|
|
391
393
|
if (!slug) return;
|
|
394
|
+
if (prepareContextualWorkspaceDeparture(slug) === false) return;
|
|
392
395
|
var target = cachedProjects.find(function (project) { return project.slug === slug; });
|
|
393
396
|
if (target && target.contentAccess === false && target.administrativeAccess === true) {
|
|
394
397
|
window.location.assign("/p/" + encodeURIComponent(slug) + "/");
|