@clagentic/console 1.12.0-beta.1 → 1.12.0-beta.3
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/LICENSES/README.md +5 -0
- package/README.md +1 -0
- package/bin/cli.js +5 -2
- package/lib/agent-roster-ws.js +84 -0
- package/lib/agent-roster.js +312 -0
- package/lib/auth-required-notify.js +42 -0
- package/lib/build-changes.js +8 -2
- package/lib/build-sha.json +2 -2
- package/lib/build-update-notify.js +45 -0
- package/lib/build-update-offer.js +34 -11
- package/lib/build-update-standing.js +34 -14
- package/lib/claude-settings-env.js +142 -0
- package/lib/cli/duration.js +27 -0
- package/lib/cli/schedule-input-subcommands.js +1 -22
- package/lib/cli/session-subcommands.js +60 -11
- package/lib/client-address.js +44 -0
- package/lib/daemon.js +31 -10
- package/lib/idle-compaction-setting.js +203 -0
- package/lib/mcp-bridge-credential.js +41 -0
- package/lib/notification-prefs.js +18 -22
- package/lib/notify/core.js +210 -0
- package/lib/notify/index.js +31 -0
- package/lib/notify/live-prompts.js +36 -0
- package/lib/notify/payload.js +62 -0
- package/lib/notify/target.js +5 -0
- package/lib/notify/type-registry.js +81 -0
- package/lib/notify/types.js +57 -0
- package/lib/open-sockets.js +27 -0
- package/lib/outbound-access.js +85 -0
- package/lib/outbound-entry.js +116 -0
- package/lib/outbound-ledger.js +306 -0
- package/lib/outbound-query.js +153 -0
- package/lib/pending-prompts.js +31 -16
- package/lib/project-connection.js +48 -8
- package/lib/project-filesystem.js +43 -5
- package/lib/project-http.js +9 -1
- package/lib/project-loop.js +38 -26
- package/lib/project-notifications.js +122 -39
- package/lib/project-prompt-responses.js +1 -1
- package/lib/project-sessions.js +11 -1
- package/lib/project-user-mention.js +22 -34
- package/lib/project-user-message.js +208 -4
- package/lib/project-user-shell.js +298 -0
- package/lib/project.js +41 -5
- package/lib/prompt-answer.js +145 -0
- package/lib/prompt-expiry.js +50 -0
- package/lib/prompt-registry.js +98 -25
- package/lib/prompt-reminders.js +38 -33
- package/lib/prompt-source.js +59 -8
- package/lib/public/app.js +32 -2
- package/lib/public/css/agent-messages.css +96 -0
- package/lib/public/css/agent-roster.css +93 -0
- package/lib/public/css/diagnostics.css +29 -1
- package/lib/public/css/home-hub.css +12 -0
- package/lib/public/css/icon-strip.css +9 -0
- package/lib/public/css/input.css +20 -141
- package/lib/public/css/login-panel.css +73 -0
- package/lib/public/css/menus.css +2 -2
- package/lib/public/css/mobile-nav.css +11 -0
- package/lib/public/css/sidebar.css +18 -0
- package/lib/public/css/team-panel.css +1 -6
- package/lib/public/css/team-view.css +101 -0
- package/lib/public/css/title-bar.css +10 -0
- package/lib/public/css/user-shell.css +144 -0
- package/lib/public/index.html +44 -7
- package/lib/public/modules/activity-state.js +20 -4
- package/lib/public/modules/agent-avatar-picker.js +162 -0
- package/lib/public/modules/agent-avatar.js +153 -0
- package/lib/public/modules/agent-messages.js +285 -0
- package/lib/public/modules/agent-roster.js +157 -0
- package/lib/public/modules/app-connection.js +34 -5
- package/lib/public/modules/app-messages.js +55 -16
- package/lib/public/modules/app-notifications.js +104 -75
- package/lib/public/modules/app-panels.js +26 -3
- package/lib/public/modules/app-projects.js +3 -1
- package/lib/public/modules/app-rate-limit.js +8 -165
- package/lib/public/modules/app-rendering.js +32 -7
- package/lib/public/modules/build-update-sessions.js +81 -0
- package/lib/public/modules/collapsible-text.js +33 -18
- package/lib/public/modules/compaction-state.js +34 -0
- package/lib/public/modules/custom-icons.js +23 -5
- package/lib/public/modules/diagnostics.js +61 -57
- package/lib/public/modules/env-shadow-notice.js +34 -0
- package/lib/public/modules/injected-identity.js +24 -21
- package/lib/public/modules/input.js +176 -15
- package/lib/public/modules/login-panel.js +136 -0
- package/lib/public/modules/login-parser.js +73 -0
- package/lib/public/modules/login-tab.js +66 -0
- package/lib/public/modules/notifications.js +9 -1
- package/lib/public/modules/notify-client.js +246 -0
- package/lib/public/modules/pending-term-request.js +30 -0
- package/lib/public/modules/project-icon.js +22 -2
- package/lib/public/modules/project-settings.js +5 -0
- package/lib/public/modules/prompt-state.js +3 -3
- package/lib/public/modules/prompts.js +1 -1
- package/lib/public/modules/queued-button.js +11 -0
- package/lib/public/modules/scheduled-input-actions.js +12 -4
- package/lib/public/modules/scheduled-outbox.js +230 -0
- package/lib/public/modules/send-now.js +200 -0
- package/lib/public/modules/server-settings.js +50 -1
- package/lib/public/modules/shell-card.js +76 -0
- package/lib/public/modules/shell-line.js +49 -0
- package/lib/public/modules/shell-queue.js +253 -0
- package/lib/public/modules/shell-settings-controls.js +76 -0
- package/lib/public/modules/sidebar-mobile.js +3 -3
- package/lib/public/modules/sidebar-sessions.js +8 -0
- package/lib/public/modules/sidebar-users.js +5 -7
- package/lib/public/modules/team-panel.js +30 -88
- package/lib/public/modules/team-view.js +211 -0
- package/lib/public/modules/terminal-links.js +193 -0
- package/lib/public/modules/terminal.js +84 -107
- package/lib/public/modules/tools.js +19 -0
- package/lib/public/modules/user-shell.js +824 -0
- package/lib/public/notify-sw-logic.js +252 -0
- package/lib/public/notify-target.js +157 -0
- package/lib/public/style.css +5 -0
- package/lib/public/sw.js +20 -69
- package/lib/push.js +63 -19
- package/lib/queued-chat.js +392 -0
- package/lib/runtime-env.js +1 -0
- package/lib/scheduled-input/ws.js +67 -9
- package/lib/sdk-bridge.js +184 -73
- package/lib/sdk-message-processor.js +124 -76
- package/lib/server-auth.js +6 -4
- package/lib/server-dm.js +11 -20
- package/lib/server-settings.js +39 -1
- package/lib/server.js +112 -16
- package/lib/session-directory.js +39 -12
- package/lib/session-end.js +97 -0
- package/lib/session-input-ipc.js +37 -1
- package/lib/session-input.js +263 -21
- package/lib/session-liveness.js +53 -0
- package/lib/session-reclaim.js +37 -2
- package/lib/session-resume.js +1 -0
- package/lib/session-settings-file.js +53 -0
- package/lib/sessions.js +80 -9
- package/lib/team-traffic-ws.js +68 -0
- package/lib/team-traffic.js +318 -0
- package/lib/usage-store.js +36 -7
- package/lib/user-shell-settings.js +105 -0
- package/lib/vendor-auth.js +33 -2
- package/lib/ws-schema.js +33 -5
- package/lib/yoke/adapters/claude-capabilities.js +2 -0
- package/lib/yoke/adapters/claude-vendor.js +17 -1
- package/lib/yoke/adapters/claude-worker.js +39 -11
- package/lib/yoke/adapters/claude.js +225 -6
- package/lib/yoke/adapters/codex-capabilities.js +6 -1
- package/lib/yoke/adapters/codex-user-shell.js +265 -0
- package/lib/yoke/adapters/codex-vendor.js +7 -0
- package/lib/yoke/adapters/codex.js +186 -52
- package/lib/yoke/auth-checks.js +17 -2
- package/lib/yoke/codex-app-server.js +8 -2
- package/lib/yoke/index.js +21 -3
- package/lib/yoke/interface.js +54 -1
- package/lib/yoke/mcp-bridge-server.js +12 -8
- package/lib/yoke/provider-credentials.js +24 -0
- package/lib/yoke/registry.js +40 -1
- package/lib/yoke/user-shell.js +224 -0
- package/package.json +2 -2
- package/scripts/check-test-count.js +14 -0
- package/lib/public/modules/build-notice-gate.js +0 -73
|
@@ -36,6 +36,7 @@ import { handleAgentsList, handleAgentFavoriteToggled } from './agent-picker.js'
|
|
|
36
36
|
import { handleProjectAgentsList, requestProjectAgents } from './at-agents.js';
|
|
37
37
|
import { handleFindInSessionResults } from './session-search.js';
|
|
38
38
|
import { handleInputSync, autoResize, resetAutoResize, builtinCommands } from './input.js';
|
|
39
|
+
import { compactingFromSessionList } from './compaction-state.js';
|
|
39
40
|
import { startThinking, appendThinking, stopThinking, resetThinkingGroup, createToolItem, updateToolExecuting, updateToolResult, markAllToolsDone, closeToolGroup, removeToolFromGroup, resetToolState, getTools, getPlanContent, setPlanContent, renderPlanBanner, renderPlanCard, getTodoTools, handleTodoWrite, handleTaskCreate, handleTaskUpdate, applyDeadSessionTodoCompaction, isPlanFilePath, enableMainInput, addTurnMeta, updateSubagentActivity, addSubagentToolEntry, markSubagentDone, initSubagentStop, updateSubagentProgress, updateSubagentTaskStatus, applyPromptMessage, hasPendingPrompts } from './tools.js';
|
|
40
41
|
import { showDoneNotification, playDoneSound, isNotifAlertEnabled, isNotifSoundEnabled } from './notifications.js';
|
|
41
42
|
import { handleNotificationPrefs, isSurfaceWanted } from './notification-prefs.js';
|
|
@@ -44,8 +45,10 @@ import { isProjectSettingsOpen, refreshProjectSettingsModels, handleInstructions
|
|
|
44
45
|
import { updateSettingsModels, updateSettingsStats, updateDaemonConfig, handleSharedEnv, handleSharedEnvSaved, updateSsLiteVisibility } from './server-settings.js';
|
|
45
46
|
import { handleRenameCustomIconResult } from './custom-icons-settings.js';
|
|
46
47
|
import { handlePermissionSettings, handlePermissionModeApplied } from './permission-settings.js';
|
|
47
|
-
import {
|
|
48
|
-
import {
|
|
48
|
+
import { handleShellResult, handleUserShellSettings, handleSessionShown, handleHistoryReplayed, handleMessageDelivered, handleQueuedMessageCancelled, handleQueuedMessageTracked, handleQueuedMessageSendNow } from './user-shell.js';
|
|
49
|
+
import { handleTermList, handleTermCreated, sendTerminalCommand, markLoginTerminal, handleTermOutput, handleTermResized, handleTermExited, handleTermClosed } from './terminal.js';
|
|
50
|
+
import { consumePendingTerm } from './pending-term-request.js';
|
|
51
|
+
import { updateTerminalList,handleContextSourcesState } from './context-sources.js';
|
|
49
52
|
import { handleNotesList, handleNoteCreated, handleNoteUpdated, handleNoteDeleted } from './sticky-notes.js';
|
|
50
53
|
import { handleSkillInstalled, handleSkillUninstalled } from './skills.js';
|
|
51
54
|
import { applyVendorRegistry, defaultVendorId } from './vendor-registry.js';
|
|
@@ -65,15 +68,18 @@ import { updateProjectList, resetClientState, showUpdateAvailable, handleRemoveP
|
|
|
65
68
|
import { updateHistorySentinel, prependOlderHistory } from './app-header.js';
|
|
66
69
|
import { hideHomeHub, handleHubSchedules, handleHubRecentSessions } from './app-home-hub.js';
|
|
67
70
|
import { openDm, enterDmMode, exitDmMode, appendDmMessage, showDmTypingIndicator } from './app-dm.js';
|
|
71
|
+
import { failScheduledRequests, completeScheduledRequest } from './scheduled-outbox.js';
|
|
68
72
|
import { handleRateLimitEvent, updateRateLimitUsage, applyScheduledInputList, handleFastModeState, restoreRateLimitStateForSession, forgetSessionRateLimitState } from './app-rate-limit.js';
|
|
69
73
|
import { handleRemoteCursorMove, handleRemoteCursorLeave, handleRemoteSelection, clearRemoteCursors } from './app-cursors.js';
|
|
70
74
|
import { showLoopBanner, updateLoopBanner, updateLoopInputVisibility, updateLoopPendingBanner, showRalphApprovalBar, updateRalphApprovalStatus, openRalphPreviewModal, showExecModal, updateExecModalStatus } from './app-loop-ui.js';
|
|
71
75
|
import { handleSkillInstallWs } from './app-skills-install.js';
|
|
72
76
|
import { handleSessionGrants } from './session-grants.js';
|
|
73
|
-
import { handleNotificationsState, handleNotificationCreated, handleNotificationDismissed, handleNotificationDismissedAll
|
|
77
|
+
import { handleNotificationsState, handleNotificationCreated, handleNotificationDismissed, handleNotificationDismissedAll } from './app-notifications.js';
|
|
74
78
|
import { handleMentionStart, handleMentionActivity, handleMentionStream, handleMentionDone, handleMentionError, renderMentionUser, renderMentionResponse, renderUserMention } from './mention.js';
|
|
75
79
|
import { handleTeamState, handleTeamMemberUpdate, handleTeamTaskUpdate, handleTeamMessage as handleTeamMsg, handleTeamGone } from './team-panel.js';
|
|
76
|
-
import {
|
|
80
|
+
import { handleTeamTraffic, handleTeamTrafficChanged } from './agent-messages.js';
|
|
81
|
+
import { handleAgentRoster, handleAgentRosterChanged, handleAgentAvatarSetResult } from './agent-roster.js';
|
|
82
|
+
import { addDiagnostic, retractDiagnostics, settleBuildUpdateRequest } from './diagnostics.js';
|
|
77
83
|
import { handleHistoryMeta, handleHistoryDone } from './app-history-replay.js';
|
|
78
84
|
import { shouldApplyActivityEdge } from './activity-latch.js';
|
|
79
85
|
import { deriveSessionListProcessing } from './activity-state.js';
|
|
@@ -169,7 +175,10 @@ registerHandlers({
|
|
|
169
175
|
prependOlderHistory(msg.items, msg.meta);
|
|
170
176
|
},
|
|
171
177
|
|
|
172
|
-
history_done:
|
|
178
|
+
history_done: function (msg) {
|
|
179
|
+
handleHistoryDone(msg);
|
|
180
|
+
handleHistoryReplayed();
|
|
181
|
+
},
|
|
173
182
|
|
|
174
183
|
info: function (msg) {
|
|
175
184
|
if (msg.text && !msg.project && !msg.cwd) {
|
|
@@ -202,11 +211,11 @@ registerHandlers({
|
|
|
202
211
|
},
|
|
203
212
|
|
|
204
213
|
update_available: function (msg) {
|
|
205
|
-
//
|
|
214
|
+
// The settings button is for the admin who asked; the banner and the push
|
|
215
|
+
// reach admins through the notification core (update_available).
|
|
206
216
|
checkAdminAccess().then(function (isAdmin) {
|
|
207
217
|
if (!isAdmin) return;
|
|
208
218
|
showUpdateAvailable(msg);
|
|
209
|
-
showUpdateBanner(msg);
|
|
210
219
|
});
|
|
211
220
|
},
|
|
212
221
|
|
|
@@ -294,6 +303,12 @@ registerHandlers({
|
|
|
294
303
|
},
|
|
295
304
|
|
|
296
305
|
permission_settings: handlePermissionSettings,
|
|
306
|
+
shell_result: handleShellResult,
|
|
307
|
+
message_delivered: handleMessageDelivered,
|
|
308
|
+
queued_message_cancelled: handleQueuedMessageCancelled,
|
|
309
|
+
queued_message_tracked: handleQueuedMessageTracked,
|
|
310
|
+
queued_message_send_now: handleQueuedMessageSendNow,
|
|
311
|
+
user_shell_settings: handleUserShellSettings,
|
|
297
312
|
permission_mode_applied: handlePermissionModeApplied,
|
|
298
313
|
|
|
299
314
|
config_state: function (msg) {
|
|
@@ -439,6 +454,8 @@ registerHandlers({
|
|
|
439
454
|
// not importable under plain Node (see that function's own doc comment
|
|
440
455
|
// for why), so leaving this inline would leave only a hand-copied
|
|
441
456
|
// reimplementation testable, not the shipped code.
|
|
457
|
+
var _compaction = compactingFromSessionList(msg.sessions || [], store.get('activeSessionId'));
|
|
458
|
+
if (_compaction.found) store.set({ sessionCompacting: _compaction.compacting });
|
|
442
459
|
var _projection = deriveSessionListProcessing(msg.sessions || [], store.get('activeSessionId'));
|
|
443
460
|
if (_projection.found) {
|
|
444
461
|
store.set({ processing: _projection.active });
|
|
@@ -523,7 +540,7 @@ registerHandlers({
|
|
|
523
540
|
// session_switched now always carries msg.isProcessing
|
|
524
541
|
// (project-connection.js's hydration path previously omitted it —
|
|
525
542
|
// sessions.js's own switchSession() send already had it).
|
|
526
|
-
store.set({ activeSessionId: msg.id, cliSessionId: msg.cliSessionId || null, vendorCapabilities: msg.capabilities || {}, sessionIsProcessing: !!msg.isProcessing });
|
|
543
|
+
store.set({ sessionCompacting: !!msg.compacting, activeSessionId: msg.id, cliSessionId: msg.cliSessionId || null, vendorCapabilities: msg.capabilities || {}, sessionIsProcessing: !!msg.isProcessing });
|
|
527
544
|
// NOTE: the 'processing' projection itself is applied further down,
|
|
528
545
|
// AFTER resetClientState() (PEACHES finding 1, lr-5edd64 8th
|
|
529
546
|
// recurrence) — see the comment down there for why the ordering
|
|
@@ -611,6 +628,9 @@ registerHandlers({
|
|
|
611
628
|
// Restore draft for incoming session
|
|
612
629
|
var draft = store.get('sessionDrafts')[store.get('activeSessionId')] || "";
|
|
613
630
|
inputEl.value = draft;
|
|
631
|
+
// Queued chat of a session left behind, or of a page that was reloaded, comes
|
|
632
|
+
// back to the composer in front of the draft.
|
|
633
|
+
handleSessionShown(inputEl);
|
|
614
634
|
// Reset the autoResize line-count cache before the rAF so the skip-
|
|
615
635
|
// guard never freezes the textarea at the outgoing session's height.
|
|
616
636
|
resetAutoResize();
|
|
@@ -651,7 +671,7 @@ registerHandlers({
|
|
|
651
671
|
addUserMessage("Execute the following plan. Do NOT re-enter plan mode — just implement it step by step.", msg.images || null, msg.pastes || null, msg.from, msg.fromName);
|
|
652
672
|
} else {
|
|
653
673
|
// Injected input names its sender; it never takes the local user's place.
|
|
654
|
-
addUserMessage(msg.text, msg.images || null, msg.pastes || null, msg.from, msg.fromName, injectedFromMessage(msg));
|
|
674
|
+
addUserMessage(msg.text, msg.images || null, msg.pastes || null, msg.from, msg.fromName, injectedFromMessage(msg), !!msg.sentMidTurn);
|
|
655
675
|
}
|
|
656
676
|
},
|
|
657
677
|
|
|
@@ -759,7 +779,13 @@ registerHandlers({
|
|
|
759
779
|
// transition and pushes a fresh 'context_usage' message (see the 'status'
|
|
760
780
|
// handler in sdk-message-processor.js), which the context_usage handler
|
|
761
781
|
// below already applies to the meter.
|
|
762
|
-
compacting
|
|
782
|
+
// The sidebar follows the compacting flag on the session list entry; this
|
|
783
|
+
// drives the session view's own state for the span the server reports.
|
|
784
|
+
compacting: function (msg) {
|
|
785
|
+
// History replays recorded events; only the live span, or the session list
|
|
786
|
+
// entry, says whether compaction is running now.
|
|
787
|
+
if (!store.get('replayingHistory')) store.set({ sessionCompacting: !!msg.active });
|
|
788
|
+
},
|
|
763
789
|
|
|
764
790
|
thinking_start: function (msg) {
|
|
765
791
|
removePreThinking();
|
|
@@ -976,6 +1002,9 @@ registerHandlers({
|
|
|
976
1002
|
// collapses to ONE optimistic raise (input.js) with no manual clears.
|
|
977
1003
|
error: function (msg) {
|
|
978
1004
|
removePreThinking();
|
|
1005
|
+
// Only an error that names its request frees a row; any other error is not
|
|
1006
|
+
// about a scheduled request.
|
|
1007
|
+
failScheduledRequests(msg.text, msg.requestId);
|
|
979
1008
|
addSystemMessage(msg.text, true);
|
|
980
1009
|
},
|
|
981
1010
|
|
|
@@ -1020,6 +1049,12 @@ registerHandlers({
|
|
|
1020
1049
|
// names the session, which may not be the one on screen (lr-0827ba).
|
|
1021
1050
|
scheduled_input_list: applyScheduledInputList,
|
|
1022
1051
|
|
|
1052
|
+
// The answer to a Fire now or Cancel that carried a requestId: frees the row
|
|
1053
|
+
// that sent it, which a list push cannot do for a recurring schedule.
|
|
1054
|
+
scheduled_request_result: function (msg) {
|
|
1055
|
+
completeScheduledRequest(msg.requestId);
|
|
1056
|
+
},
|
|
1057
|
+
|
|
1023
1058
|
// The original scheduled-message names, still sent for a browser running an
|
|
1024
1059
|
// older client; this client takes its state from scheduled_input_list alone.
|
|
1025
1060
|
scheduled_message_queued: function () {},
|
|
@@ -1113,12 +1148,12 @@ registerHandlers({
|
|
|
1113
1148
|
|
|
1114
1149
|
term_created: function (msg) {
|
|
1115
1150
|
handleTermCreated(msg);
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1151
|
+
var pending = consumePendingTerm(store, msg);
|
|
1152
|
+
if (pending) {
|
|
1153
|
+
if (pending.vendor) markLoginTerminal(msg.id, pending.vendor);
|
|
1119
1154
|
// Small delay to let terminal initialize
|
|
1120
1155
|
setTimeout(function() {
|
|
1121
|
-
sendTerminalCommand(
|
|
1156
|
+
sendTerminalCommand(pending.command);
|
|
1122
1157
|
}, 300);
|
|
1123
1158
|
}
|
|
1124
1159
|
},
|
|
@@ -1287,13 +1322,17 @@ registerHandlers({
|
|
|
1287
1322
|
team_task_update: handleTeamTaskUpdate,
|
|
1288
1323
|
team_message: handleTeamMsg,
|
|
1289
1324
|
team_gone: handleTeamGone,
|
|
1325
|
+
team_traffic: handleTeamTraffic,
|
|
1326
|
+
team_traffic_changed: handleTeamTrafficChanged,
|
|
1327
|
+
agent_roster: handleAgentRoster,
|
|
1328
|
+
agent_roster_changed: handleAgentRosterChanged,
|
|
1329
|
+
agent_avatar_set_result: handleAgentAvatarSetResult,
|
|
1290
1330
|
|
|
1291
1331
|
diagnostic: function (msg) {
|
|
1292
1332
|
// Diagnostic events from CLI stderr (stage 4/5, lr-8294, epic lr-1a52).
|
|
1293
1333
|
// Future sources (e.g. settings preflight from stage 5/5 lr-1a26) will
|
|
1294
1334
|
// also arrive via this same type — the render path must not assume CLI origin.
|
|
1295
|
-
|
|
1296
|
-
else addDiagnostic(msg);
|
|
1335
|
+
addDiagnostic(msg);
|
|
1297
1336
|
},
|
|
1298
1337
|
|
|
1299
1338
|
diagnostic_retract: function (msg) {
|
|
@@ -9,28 +9,30 @@ import { store } from './store.js';
|
|
|
9
9
|
import { loginCommandFor, defaultVendorId } from './vendor-registry.js';
|
|
10
10
|
import { getWs } from './ws-ref.js';
|
|
11
11
|
import { getCachedProjects } from './app-projects.js';
|
|
12
|
-
import { switchProject } from './app-projects.js';
|
|
13
12
|
import { userAvatarUrl } from './avatar.js';
|
|
14
13
|
import { openTerminal } from './terminal.js';
|
|
14
|
+
import { newTermRequestId } from './pending-term-request.js';
|
|
15
15
|
import { askWording } from './prompt-kinds/index.js';
|
|
16
16
|
import { wirePromptBanner, restoreUnconfirmedBanners, bannerActions } from './prompt-banner.js';
|
|
17
17
|
import { promptLabelHtml } from './prompt-label.js';
|
|
18
18
|
import { isSurfaceWanted, shouldChimeForNotification } from './notification-prefs.js';
|
|
19
19
|
import { playDoneSound, isNotifSoundEnabled } from './notifications.js';
|
|
20
|
+
import { initNotifyClient, noteNotificationsState, routeTo, takePendingSession, takePendingPlace, registerPlace } from './notify-client.js';
|
|
21
|
+
import { applyBuildOffer, withdrawBuildOffer, openDiagnosticsPanel } from './diagnostics.js';
|
|
22
|
+
import '../notify-sw-logic.js';
|
|
20
23
|
|
|
21
24
|
// The server dismisses a prompt's banner once the prompt settles, however it
|
|
22
25
|
// was answered.
|
|
23
26
|
var notifications = [];
|
|
27
|
+
// The notification behind each banner on screen, by id.
|
|
28
|
+
var shownNotifs = Object.create(null);
|
|
24
29
|
var unreadCount = 0;
|
|
25
30
|
var bannerContainer = null;
|
|
26
31
|
var bellBtn = null;
|
|
27
32
|
var badgeEl = null;
|
|
28
33
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
// per-banner-instance and doesn't need to persist. The next server push
|
|
32
|
-
// (next hour) acts as a fresh ping.
|
|
33
|
-
var pendingUpdateMsg = null;
|
|
34
|
+
var BUILD_OFFER_TYPE = "build_update_offer";
|
|
35
|
+
|
|
34
36
|
var activeAuthRequiredMsg = null;
|
|
35
37
|
var authReminderVisible = false;
|
|
36
38
|
|
|
@@ -47,6 +49,11 @@ export function initAppNotifications() {
|
|
|
47
49
|
bannerContainer.className = "notif-banner-container";
|
|
48
50
|
document.body.appendChild(bannerContainer);
|
|
49
51
|
|
|
52
|
+
initNotifyClient();
|
|
53
|
+
// The build-update offer's action (the restart button) lives in the
|
|
54
|
+
// diagnostics panel; a tap on its banner or push opens it.
|
|
55
|
+
registerPlace(BUILD_OFFER_TYPE, openDiagnosticsPanel);
|
|
56
|
+
|
|
50
57
|
if (bellBtn) {
|
|
51
58
|
bellBtn.addEventListener("click", function (e) {
|
|
52
59
|
e.stopPropagation();
|
|
@@ -63,11 +70,8 @@ function showAllBanners() {
|
|
|
63
70
|
// Clear existing banners first
|
|
64
71
|
if (bannerContainer) bannerContainer.innerHTML = "";
|
|
65
72
|
|
|
66
|
-
// Re-add update banner if present (may be suppressed by recent dismiss)
|
|
67
|
-
if (pendingUpdateMsg) showUpdateBanner(pendingUpdateMsg);
|
|
68
|
-
|
|
69
73
|
for (var i = 0; i < notifications.length; i++) {
|
|
70
|
-
|
|
74
|
+
showNotificationBanner(notifications[i], false);
|
|
71
75
|
}
|
|
72
76
|
|
|
73
77
|
if (activeAuthRequiredMsg) showAuthRequiredBanner(activeAuthRequiredMsg);
|
|
@@ -90,12 +94,20 @@ function showAllBanners() {
|
|
|
90
94
|
// Banner
|
|
91
95
|
// ========================================================
|
|
92
96
|
|
|
97
|
+
// An update notice has its own banner (the "Update now" action); every other
|
|
98
|
+
// notification renders from the generic one.
|
|
99
|
+
function showNotificationBanner(notif, autoDismissMs) {
|
|
100
|
+
if (notif.type === "update_available") showUpdateBanner({ version: notif.meta && notif.meta.version }, notif.id);
|
|
101
|
+
else showBanner(notif, autoDismissMs);
|
|
102
|
+
}
|
|
103
|
+
|
|
93
104
|
function showBanner(notif, autoDismissMs) {
|
|
94
105
|
if (!bannerContainer) return;
|
|
95
106
|
|
|
96
107
|
var isEmpty = notif.id === "_empty";
|
|
97
108
|
var isPermission = notif.type === "permission_request" && notif.meta && notif.meta.requestId;
|
|
98
109
|
var isAuthRequired = notif.type === "auth_required";
|
|
110
|
+
var isBuildOffer = notif.type === BUILD_OFFER_TYPE;
|
|
99
111
|
var isUserMention = notif.type === "user_mention";
|
|
100
112
|
var isReminder = notif.type === "permission_reminder";
|
|
101
113
|
var projectIcon = isEmpty ? null : getProjectIcon(notif.slug);
|
|
@@ -106,6 +118,10 @@ function showBanner(notif, autoDismissMs) {
|
|
|
106
118
|
banner.className = "notif-banner" + (isAuthRequired ? " notif-banner-update notif-banner-auth" : isPermission ? " notif-banner-permission" : isUserMention ? " notif-banner-user-mention" : isReminder ? " notif-banner-reminder" : "");
|
|
107
119
|
if (!isEmpty) banner.setAttribute("data-notif-id", notif.id);
|
|
108
120
|
if (!isEmpty && notif.type) banner.setAttribute("data-notif-type", notif.type);
|
|
121
|
+
if (!isEmpty && notif.liveInState === true) {
|
|
122
|
+
banner.setAttribute("data-live-in-state", "true");
|
|
123
|
+
shownNotifs[notif.id] = notif;
|
|
124
|
+
}
|
|
109
125
|
if (isAuthRequired) banner.setAttribute("data-auth-banner", "true");
|
|
110
126
|
|
|
111
127
|
var iconHtmlStr = userMentionAvatarSrc
|
|
@@ -168,11 +184,13 @@ function showBanner(notif, autoDismissMs) {
|
|
|
168
184
|
|
|
169
185
|
if (!isEmpty) {
|
|
170
186
|
if (!isAuthRequired) {
|
|
171
|
-
// Click banner body -> navigate + dismiss
|
|
187
|
+
// Click banner body -> navigate + dismiss. An offer is not declined by
|
|
188
|
+
// looking at it: its tap opens the place the restart lives in, and only
|
|
189
|
+
// its close button declines it.
|
|
172
190
|
banner.addEventListener("click", function (e) {
|
|
173
191
|
if (e.target.closest(".notif-banner-close")) return;
|
|
174
192
|
removeBanner(banner);
|
|
175
|
-
dismissNotif(notif.id);
|
|
193
|
+
if (!isBuildOffer) dismissNotif(notif.id);
|
|
176
194
|
navigateToNotification(notif);
|
|
177
195
|
});
|
|
178
196
|
}
|
|
@@ -212,7 +230,8 @@ function showBanner(notif, autoDismissMs) {
|
|
|
212
230
|
activeAuthRequiredMsg = null;
|
|
213
231
|
removeBanner(banner);
|
|
214
232
|
dismissNotif(notif.id);
|
|
215
|
-
|
|
233
|
+
var login = authLoginFor(notif);
|
|
234
|
+
startLoginCommand(login.loginCommand, login.vendor);
|
|
216
235
|
showLoginReminderBanner();
|
|
217
236
|
});
|
|
218
237
|
}
|
|
@@ -227,12 +246,15 @@ function showBanner(notif, autoDismissMs) {
|
|
|
227
246
|
}
|
|
228
247
|
}
|
|
229
248
|
|
|
230
|
-
function startLoginCommand(loginCommand) {
|
|
249
|
+
function startLoginCommand(loginCommand, vendor) {
|
|
231
250
|
var ws = getWs();
|
|
232
251
|
if (!ws || ws.readyState !== 1 || !loginCommand) return;
|
|
233
252
|
var termCommand = loginCommand + "\n";
|
|
234
|
-
|
|
235
|
-
|
|
253
|
+
// The terminal that answers this request id is this login's: marking it
|
|
254
|
+
// makes its output, and only its output, feed the sign-in panel.
|
|
255
|
+
var requestId = newTermRequestId();
|
|
256
|
+
store.set({ pendingTermCommand: termCommand, pendingLoginVendor: vendor || "", pendingTermRequestId: requestId });
|
|
257
|
+
ws.send(JSON.stringify({ type: "term_create", cols: 80, rows: 24, requestId: requestId }));
|
|
236
258
|
openTerminal();
|
|
237
259
|
}
|
|
238
260
|
|
|
@@ -315,13 +337,12 @@ export function showAuthRequiredBanner(msg) {
|
|
|
315
337
|
loginCommand: loginCommand,
|
|
316
338
|
}),
|
|
317
339
|
});
|
|
318
|
-
var existing = bannerContainer.querySelector('[data-auth-banner="true"]');
|
|
319
|
-
if (existing) removeBanner(existing);
|
|
320
340
|
showBanner(activeAuthRequiredMsg, false);
|
|
321
341
|
}
|
|
322
342
|
|
|
323
343
|
function removeBanner(banner) {
|
|
324
344
|
if (!banner || !banner.parentNode) return;
|
|
345
|
+
delete shownNotifs[banner.getAttribute("data-notif-id")];
|
|
325
346
|
banner.classList.remove("show");
|
|
326
347
|
banner.classList.add("hide");
|
|
327
348
|
// Update the clear-all button right away so it disappears before the
|
|
@@ -408,42 +429,60 @@ export function handleNotificationsState(msg) {
|
|
|
408
429
|
notifications = msg.notifications || [];
|
|
409
430
|
unreadCount = msg.unreadCount || 0;
|
|
410
431
|
updateBadge();
|
|
411
|
-
dropBannersOfEndedPrompts();
|
|
432
|
+
dropBannersOfEndedPrompts(msg.livePrompts || null);
|
|
433
|
+
syncBuildOffer(notifications);
|
|
434
|
+
noteNotificationsState(notifications, msg.livePrompts);
|
|
412
435
|
|
|
413
|
-
//
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
436
|
+
// A route waiting on the connection (a project switch, a deep link) opens
|
|
437
|
+
// its session now that this project's socket is up.
|
|
438
|
+
var ws = getWs();
|
|
439
|
+
// A cold-start tap on a system notice names its type: open that place.
|
|
440
|
+
var pendingPlace = takePendingPlace();
|
|
441
|
+
if (pendingPlace) routeTo({ slug: null, sessionId: null }, pendingPlace);
|
|
442
|
+
if (ws && ws.readyState === 1) {
|
|
443
|
+
var pendingId = takePendingSession();
|
|
444
|
+
if (pendingId !== null) ws.send(JSON.stringify({ type: "switch_session", id: pendingId }));
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
// The offer's diagnostics entry follows the server's list, which every connect
|
|
449
|
+
// sends: the held offer is shown, and an entry whose offer is gone (closed while
|
|
450
|
+
// this page was away) is withdrawn, so a dead restart action cannot stay.
|
|
451
|
+
function syncBuildOffer(list) {
|
|
452
|
+
var offer = list.filter(function (n) { return n.type === BUILD_OFFER_TYPE; })[0];
|
|
453
|
+
if (offer) applyBuildOffer(offer);
|
|
454
|
+
else withdrawBuildOffer();
|
|
424
455
|
}
|
|
425
456
|
|
|
426
457
|
// A prompt banner and a reminder are tied to a live prompt. The server's list
|
|
427
|
-
// (sent on every connect)
|
|
428
|
-
// survives, and the dismissals were sent to a
|
|
429
|
-
//
|
|
430
|
-
|
|
458
|
+
// (sent on every connect) and its live-prompt record are the truth: after a
|
|
459
|
+
// daemon restart no prompt survives, and the dismissals were sent to a
|
|
460
|
+
// connection that was gone. The check is the one the push reconcile uses
|
|
461
|
+
// (NotifySw.isBannerLive), for every banner the registry marks liveInState.
|
|
462
|
+
function dropBannersOfEndedPrompts(livePrompts) {
|
|
431
463
|
if (!bannerContainer) return;
|
|
432
|
-
var
|
|
433
|
-
notifications.forEach(function (n) { live[n.id] = true; });
|
|
434
|
-
var banners = bannerContainer.querySelectorAll('.notif-banner[data-notif-type="permission_request"], .notif-banner[data-notif-type="permission_reminder"]');
|
|
464
|
+
var banners = bannerContainer.querySelectorAll('.notif-banner[data-live-in-state="true"]');
|
|
435
465
|
for (var i = 0; i < banners.length; i++) {
|
|
436
|
-
|
|
466
|
+
var notif = shownNotifs[banners[i].getAttribute("data-notif-id")];
|
|
467
|
+
if (notif && !globalThis.NotifySw.isBannerLive(notif, notifications, livePrompts)) removeBanner(banners[i]);
|
|
437
468
|
}
|
|
438
469
|
}
|
|
439
470
|
|
|
471
|
+
// Session local ids are unique only within a project, and the server sends a
|
|
472
|
+
// user's notifications to every project socket that user has open. A session
|
|
473
|
+
// id therefore names the viewed session only together with the project slug.
|
|
474
|
+
function isViewedProject(slug) {
|
|
475
|
+
return !!slug && slug === (store.get('currentSlug') || "");
|
|
476
|
+
}
|
|
477
|
+
|
|
440
478
|
export function handleNotificationCreated(msg) {
|
|
441
479
|
var notif = msg.notification;
|
|
442
480
|
|
|
443
481
|
// Auto-dismiss if it's for the session the user is currently viewing
|
|
444
482
|
var activeSession = store.get('activeSessionId') || null;
|
|
445
|
-
|
|
446
|
-
|
|
483
|
+
var sameProject = isViewedProject(notif.slug);
|
|
484
|
+
console.log("[notif] created:", notif.type, "slug=" + notif.slug, "sessionId=" + notif.sessionId + "(" + typeof notif.sessionId + ")", "active=" + activeSession + "(" + typeof activeSession + ")", "match=" + (sameProject && notif.sessionId == activeSession));
|
|
485
|
+
if (notif.type !== "auth_required" && notif.sessionId && sameProject && String(notif.sessionId) === String(activeSession)) {
|
|
447
486
|
dismissNotif(notif.id);
|
|
448
487
|
return;
|
|
449
488
|
}
|
|
@@ -451,28 +490,27 @@ export function handleNotificationCreated(msg) {
|
|
|
451
490
|
notifications.unshift(notif);
|
|
452
491
|
unreadCount = msg.unreadCount;
|
|
453
492
|
updateBadge();
|
|
493
|
+
if (notif.type === BUILD_OFFER_TYPE) applyBuildOffer(notif);
|
|
454
494
|
|
|
455
|
-
//
|
|
456
|
-
//
|
|
457
|
-
//
|
|
458
|
-
//
|
|
459
|
-
//
|
|
460
|
-
|
|
461
|
-
// 3. The user clicks the X close button.
|
|
462
|
-
// Permission and auth banners are also persistent for the same UX reason.
|
|
463
|
-
// A reminder stays until its prompt is answered, or the next one replaces it.
|
|
464
|
-
var _autoDismiss = (notif.type === "permission_request" || notif.type === "permission_reminder" || notif.type === "auth_required" || notif.type === "user_mention") ? false : true;
|
|
495
|
+
// A banner stays until acted on when the type registry says so (the
|
|
496
|
+
// notification's persistent flag; lib/notify/types.js), or when it carries
|
|
497
|
+
// its own persistent marker in meta. It goes away when the user clicks it
|
|
498
|
+
// (which routes to its session), views the session some other way (handled
|
|
499
|
+
// above), closes it, or when its prompt resolves and the server dismisses it.
|
|
500
|
+
var _autoDismiss = !(notif.persistent === true || (notif.meta && notif.meta.persistent === true));
|
|
465
501
|
|
|
466
502
|
// The user's per-type choices (lib/notification-prefs.js). A muted type has
|
|
467
503
|
// still been added to the list and counted above: only the alert and the
|
|
468
504
|
// sound are skipped. A sound plays only while the page is hidden, like the
|
|
469
505
|
// finished turn's own chime.
|
|
470
|
-
if (isSurfaceWanted("banner", notif.category))
|
|
506
|
+
if (isSurfaceWanted("banner", notif.category)) showNotificationBanner(notif, _autoDismiss);
|
|
471
507
|
if (shouldChimeForNotification(notif, isNotifSoundEnabled())) playDoneSound();
|
|
472
508
|
}
|
|
473
509
|
|
|
474
510
|
export function handleNotificationDismissed(msg) {
|
|
475
511
|
var ids = msg.ids || [];
|
|
512
|
+
var closedOffer = notifications.some(function (n) { return n.type === BUILD_OFFER_TYPE && ids.indexOf(n.id) !== -1; });
|
|
513
|
+
if (closedOffer) withdrawBuildOffer();
|
|
476
514
|
notifications = notifications.filter(function (n) { return ids.indexOf(n.id) === -1; });
|
|
477
515
|
unreadCount = msg.unreadCount;
|
|
478
516
|
updateBadge();
|
|
@@ -486,6 +524,7 @@ export function handleNotificationDismissed(msg) {
|
|
|
486
524
|
}
|
|
487
525
|
|
|
488
526
|
export function handleNotificationDismissedAll() {
|
|
527
|
+
withdrawBuildOffer();
|
|
489
528
|
notifications = [];
|
|
490
529
|
unreadCount = 0;
|
|
491
530
|
updateBadge();
|
|
@@ -510,22 +549,10 @@ function updateBadge() {
|
|
|
510
549
|
// Navigation
|
|
511
550
|
// ========================================================
|
|
512
551
|
|
|
552
|
+
// The one router (notify-client.js) opens the notification's project and
|
|
553
|
+
// session; the slug is part of the target, as session ids repeat across projects.
|
|
513
554
|
function navigateToNotification(notif) {
|
|
514
|
-
|
|
515
|
-
var needsProjectSwitch = notif.slug && notif.slug !== currentSlug;
|
|
516
|
-
|
|
517
|
-
if (needsProjectSwitch) {
|
|
518
|
-
// Store target session for after project switch
|
|
519
|
-
if (notif.sessionId) {
|
|
520
|
-
try { sessionStorage.setItem("pending-notif-session", notif.sessionId); } catch (e) {}
|
|
521
|
-
}
|
|
522
|
-
switchProject(notif.slug);
|
|
523
|
-
} else if (notif.sessionId) {
|
|
524
|
-
var ws = getWs();
|
|
525
|
-
if (ws && ws.readyState === 1) {
|
|
526
|
-
ws.send(JSON.stringify({ type: "switch_session", id: notif.sessionId }));
|
|
527
|
-
}
|
|
528
|
-
}
|
|
555
|
+
routeTo({ slug: notif.slug, sessionId: notif.sessionId, requestId: notif.meta && notif.meta.requestId, peerId: notif.peerId }, notif.type);
|
|
529
556
|
}
|
|
530
557
|
|
|
531
558
|
// Build the sender avatar URL for a user_mention notification banner.
|
|
@@ -556,21 +583,16 @@ function buildUserMentionAvatarSrc(notif) {
|
|
|
556
583
|
// Update available banner
|
|
557
584
|
// ========================================================
|
|
558
585
|
|
|
559
|
-
|
|
586
|
+
function showUpdateBanner(msg, notifId) {
|
|
560
587
|
if (!msg || !msg.version) return;
|
|
561
|
-
pendingUpdateMsg = msg;
|
|
562
588
|
if (!bannerContainer) return;
|
|
563
589
|
|
|
564
|
-
// Remove any existing update banner
|
|
565
|
-
var existing = bannerContainer.querySelector('[data-notif-id="_update"]');
|
|
566
|
-
if (existing) removeBanner(existing);
|
|
567
|
-
|
|
568
590
|
var isHeadless = store.get('isHeadlessMode');
|
|
569
591
|
var updTag = msg.version.indexOf("-beta") !== -1 ? "beta" : "latest";
|
|
570
592
|
|
|
571
593
|
var banner = document.createElement("div");
|
|
572
594
|
banner.className = "notif-banner notif-banner-update";
|
|
573
|
-
banner.setAttribute("data-notif-id", "_update");
|
|
595
|
+
banner.setAttribute("data-notif-id", notifId || "_update");
|
|
574
596
|
|
|
575
597
|
var actionsHtml = '';
|
|
576
598
|
if (!isHeadless) {
|
|
@@ -599,6 +621,12 @@ export function showUpdateBanner(msg) {
|
|
|
599
621
|
banner.classList.add("show");
|
|
600
622
|
});
|
|
601
623
|
|
|
624
|
+
// A tap on the notice opens the update UI, like a tap on its push.
|
|
625
|
+
banner.addEventListener("click", function (e) {
|
|
626
|
+
if (e.target.closest("button")) return;
|
|
627
|
+
routeTo({ slug: null, sessionId: null }, "update_available");
|
|
628
|
+
});
|
|
629
|
+
|
|
602
630
|
// "Update now" button
|
|
603
631
|
var updateBtn = banner.querySelector(".notif-banner-update-now");
|
|
604
632
|
if (updateBtn) {
|
|
@@ -613,12 +641,13 @@ export function showUpdateBanner(msg) {
|
|
|
613
641
|
});
|
|
614
642
|
}
|
|
615
643
|
|
|
616
|
-
// Close button -> dismiss. No local throttle; the
|
|
617
|
-
//
|
|
644
|
+
// Close button -> dismiss. No local throttle; the next hourly check raises
|
|
645
|
+
// a new update_available, which re-shows naturally.
|
|
618
646
|
var closeBtn = banner.querySelector(".notif-banner-close");
|
|
619
647
|
if (closeBtn) {
|
|
620
648
|
closeBtn.addEventListener("click", function (e) {
|
|
621
649
|
e.stopPropagation();
|
|
650
|
+
if (notifId) dismissNotif(notifId);
|
|
622
651
|
removeBanner(banner);
|
|
623
652
|
});
|
|
624
653
|
}
|
|
@@ -10,6 +10,7 @@ import { renderVendorPicker } from './vendor-picker.js';
|
|
|
10
10
|
import { splitModelsByTier } from './settings-defaults.js';
|
|
11
11
|
import { isSonnetModel } from './model-families.js';
|
|
12
12
|
import { modeOptions } from './mode-options.js';
|
|
13
|
+
import { isNearingCompaction } from './compaction-state.js';
|
|
13
14
|
|
|
14
15
|
// --- Module-owned state (not in store) ---
|
|
15
16
|
// sessionUsage.context = last-turn context fill (lastStreamInputTokens) — not cumulative,
|
|
@@ -489,7 +490,8 @@ export function initPanels() {
|
|
|
489
490
|
}
|
|
490
491
|
|
|
491
492
|
// --- Reactive UI sync ---
|
|
492
|
-
store.subscribe(['availableVendors', 'installedVendors', 'vendorRegistry', 'currentVendor', 'richContextUsage', 'ctxPopoverVisible', 'currentModel', 'currentModels', 'currentMode', 'currentEffort', 'currentBetas', 'currentThinking', 'vendorCapabilities'], function (state, prev) {
|
|
493
|
+
store.subscribe(['availableVendors', 'installedVendors', 'vendorRegistry', 'currentVendor', 'richContextUsage', 'ctxPopoverVisible', 'currentModel', 'currentModels', 'currentMode', 'currentEffort', 'currentBetas', 'currentThinking', 'vendorCapabilities', 'sessionCompacting'], function (state, prev) {
|
|
494
|
+
if (state.sessionCompacting !== prev.sessionCompacting) renderCompactingChip(state.sessionCompacting);
|
|
493
495
|
// Agent picker state
|
|
494
496
|
if (state.availableVendors !== prev.availableVendors ||
|
|
495
497
|
state.installedVendors !== prev.installedVendors ||
|
|
@@ -913,6 +915,24 @@ export function getEffectiveContextFill() {
|
|
|
913
915
|
return { used: contextData.input, win: resolveContextWindow(contextData.contextWindow) };
|
|
914
916
|
}
|
|
915
917
|
|
|
918
|
+
// The session view's compacting state: a chip in the header status area for
|
|
919
|
+
// exactly the span the server reports (compacting active true to false).
|
|
920
|
+
function renderCompactingChip(active) {
|
|
921
|
+
var statusArea = document.querySelector(".title-bar-content .status");
|
|
922
|
+
if (!statusArea) return;
|
|
923
|
+
var chip = statusArea.querySelector(".header-compacting");
|
|
924
|
+
if (!active) {
|
|
925
|
+
if (chip) chip.remove();
|
|
926
|
+
return;
|
|
927
|
+
}
|
|
928
|
+
if (chip) return;
|
|
929
|
+
chip = document.createElement("span");
|
|
930
|
+
chip.className = "header-compacting";
|
|
931
|
+
chip.setAttribute("role", "status");
|
|
932
|
+
chip.textContent = "Compacting context...";
|
|
933
|
+
statusArea.insertBefore(chip, statusArea.firstChild);
|
|
934
|
+
}
|
|
935
|
+
|
|
916
936
|
export function updateContextPanel() {
|
|
917
937
|
if (!contextUsedEl) return;
|
|
918
938
|
var fill = getEffectiveContextFill();
|
|
@@ -941,7 +961,7 @@ export function updateContextPanel() {
|
|
|
941
961
|
if (statusArea && !hCtxEl) {
|
|
942
962
|
hCtxEl = document.createElement("div");
|
|
943
963
|
hCtxEl.className = "header-context";
|
|
944
|
-
hCtxEl.innerHTML = '<div class="header-context-bar"><div class="header-context-fill"></div></div><span class="header-context-label"></span>';
|
|
964
|
+
hCtxEl.innerHTML = '<div class="header-context-bar"><div class="header-context-fill"></div></div><span class="header-context-label"></span><span class="header-context-nearing hidden">Nearing auto-compaction</span>';
|
|
945
965
|
statusArea.insertBefore(hCtxEl, statusArea.firstChild);
|
|
946
966
|
hCtxEl.addEventListener("mouseenter", function() {
|
|
947
967
|
if (store.get('richContextUsage')) {
|
|
@@ -959,6 +979,9 @@ export function updateContextPanel() {
|
|
|
959
979
|
hFill.style.width = pct.toFixed(1) + "%";
|
|
960
980
|
hFill.className = "header-context-fill" + cls;
|
|
961
981
|
hLabel.textContent = pct.toFixed(0) + "%";
|
|
982
|
+
var nearing = isNearingCompaction(store.get('richContextUsage'));
|
|
983
|
+
hCtxEl.classList.toggle("nearing", nearing);
|
|
984
|
+
hCtxEl.querySelector(".header-context-nearing").classList.toggle("hidden", !nearing);
|
|
962
985
|
// Use data-tip as fallback when rich data is not yet loaded
|
|
963
986
|
if (store.get('richContextUsage')) {
|
|
964
987
|
hCtxEl.removeAttribute("data-tip");
|
|
@@ -1226,7 +1249,7 @@ export function renderCtxPopover() {
|
|
|
1226
1249
|
|
|
1227
1250
|
// Auto-compact note
|
|
1228
1251
|
if (d.isAutoCompactEnabled && d.autoCompactThreshold) {
|
|
1229
|
-
html += '<div class="ctx-pop-note">' + em("\u267b\ufe0f") + ' Auto-compact at ' + formatTokens(d.autoCompactThreshold) + '</div>';
|
|
1252
|
+
html += '<div class="ctx-pop-note">' + em("\u267b\ufe0f") + ' Auto-compact at ' + formatTokens(d.autoCompactThreshold) + (isNearingCompaction(d) ? ' (nearing)' : '') + '</div>';
|
|
1230
1253
|
}
|
|
1231
1254
|
|
|
1232
1255
|
ctxPopoverEl.innerHTML = html;
|
|
@@ -22,7 +22,7 @@ import { resetFileBrowser } from './filebrowser.js';
|
|
|
22
22
|
import { closeArchive } from './sticky-notes.js';
|
|
23
23
|
import { isSchedulerOpen, closeScheduler, resetScheduler } from './scheduler.js';
|
|
24
24
|
import { connect, cancelReconnect, setStatus } from './app-connection.js';
|
|
25
|
-
import { setTurnCounter, setPrependAnchor, setActivityEl, setIsUserScrolledUp, hideSuggestionChips, resetCurrentFullText } from './app-rendering.js';
|
|
25
|
+
import { setTurnCounter, setPrependAnchor, setActivityEl, setIsUserScrolledUp, hideSuggestionChips, resetCurrentFullText, resetStreamState } from './app-rendering.js';
|
|
26
26
|
import { resetToolState, enableMainInput, resetTurnMetaCost, clearPromptStates } from './tools.js';
|
|
27
27
|
import { clearPendingImages } from './input.js';
|
|
28
28
|
import { clearAllMentionActive } from './sidebar-users.js';
|
|
@@ -404,6 +404,7 @@ export function resetClientState() {
|
|
|
404
404
|
store.set({ currentMsgEl: null });
|
|
405
405
|
store.set({ currentFullText: "" });
|
|
406
406
|
resetCurrentFullText("");
|
|
407
|
+
resetStreamState();
|
|
407
408
|
resetToolState();
|
|
408
409
|
clearPromptStates();
|
|
409
410
|
clearPendingImages();
|
|
@@ -506,6 +507,7 @@ export function switchProject(slug) {
|
|
|
506
507
|
// session switch) where the session list must stay intact.
|
|
507
508
|
if (typeof _onResetClientState === "function") _onResetClientState();
|
|
508
509
|
resetClientState();
|
|
510
|
+
cancelReconnect();
|
|
509
511
|
connect();
|
|
510
512
|
}
|
|
511
513
|
|