@clagentic/console 1.12.0-beta.1 → 1.12.0-beta.2
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/README.md +1 -0
- package/bin/cli.js +2 -1
- package/lib/build-changes.js +8 -2
- package/lib/build-sha.json +2 -2
- package/lib/build-update-offer.js +31 -7
- 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 +38 -7
- package/lib/daemon.js +6 -0
- package/lib/notification-prefs.js +2 -0
- package/lib/notify/core.js +175 -0
- package/lib/notify/index.js +31 -0
- package/lib/notify/live-prompts.js +36 -0
- package/lib/notify/payload.js +63 -0
- package/lib/notify/target.js +5 -0
- package/lib/notify/type-registry.js +64 -0
- package/lib/notify/types.js +20 -0
- package/lib/open-sockets.js +27 -0
- package/lib/outbound-access.js +74 -0
- package/lib/outbound-entry.js +109 -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 +40 -1
- package/lib/project-filesystem.js +20 -5
- package/lib/project-http.js +9 -1
- package/lib/project-loop.js +22 -7
- package/lib/project-notifications.js +54 -32
- package/lib/project-prompt-responses.js +1 -1
- package/lib/project-sessions.js +2 -1
- package/lib/project.js +15 -1
- package/lib/prompt-registry.js +74 -24
- package/lib/prompt-reminders.js +38 -33
- package/lib/prompt-source.js +43 -8
- package/lib/public/app.js +1 -0
- package/lib/public/css/diagnostics.css +28 -0
- package/lib/public/css/home-hub.css +12 -0
- package/lib/public/css/icon-strip.css +9 -0
- package/lib/public/css/mobile-nav.css +11 -0
- package/lib/public/css/sidebar.css +7 -0
- package/lib/public/index.html +3 -0
- package/lib/public/modules/activity-state.js +20 -4
- package/lib/public/modules/app-connection.js +22 -5
- package/lib/public/modules/app-notifications.js +47 -48
- package/lib/public/modules/app-projects.js +3 -1
- package/lib/public/modules/app-rendering.js +10 -0
- package/lib/public/modules/build-update-sessions.js +81 -0
- package/lib/public/modules/diagnostics.js +9 -2
- package/lib/public/modules/env-shadow-notice.js +34 -0
- package/lib/public/modules/notify-client.js +153 -0
- 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/server-settings.js +3 -0
- package/lib/public/modules/terminal-links.js +175 -0
- package/lib/public/modules/terminal.js +19 -103
- package/lib/public/notify-sw-logic.js +300 -0
- package/lib/public/notify-target.js +97 -0
- package/lib/public/sw.js +15 -68
- package/lib/push.js +63 -19
- package/lib/runtime-env.js +1 -0
- package/lib/sdk-bridge.js +62 -30
- package/lib/sdk-message-processor.js +78 -37
- package/lib/server.js +34 -2
- package/lib/session-directory.js +6 -4
- package/lib/session-input-ipc.js +11 -1
- package/lib/session-input.js +89 -14
- package/lib/session-liveness.js +53 -0
- package/lib/session-reclaim.js +37 -2
- package/lib/sessions.js +31 -4
- package/lib/usage-store.js +29 -7
- package/lib/vendor-auth.js +33 -2
- package/lib/ws-schema.js +6 -1
- package/lib/yoke/adapters/claude-vendor.js +11 -1
- package/lib/yoke/adapters/claude.js +7 -0
- package/lib/yoke/auth-checks.js +17 -2
- package/lib/yoke/index.js +21 -3
- package/lib/yoke/provider-credentials.js +24 -0
- package/lib/yoke/registry.js +8 -1
- package/package.json +2 -2
- package/scripts/check-test-count.js +14 -0
package/lib/prompt-reminders.js
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
// from a config file is a value that can be set to nothing. A `tickSeconds` key
|
|
31
31
|
// left in daemon.json is ignored.
|
|
32
32
|
|
|
33
|
-
var {
|
|
33
|
+
var { notifyFor } = require("./notify");
|
|
34
34
|
|
|
35
35
|
var DEFAULT_SCHEDULE_MINUTES = [5, 15, 30];
|
|
36
36
|
var DEFAULT_REPEAT_MINUTES = 60;
|
|
@@ -143,8 +143,8 @@ function describe(s) {
|
|
|
143
143
|
* @param {object} deps
|
|
144
144
|
* @param {function(): Array<{slug: string, project: string, session: object, prompts: object}>} deps.listSessions
|
|
145
145
|
* every session of every project with its prompt registry.
|
|
146
|
-
* @param {object} deps.notifications the
|
|
147
|
-
*
|
|
146
|
+
* @param {object} deps.notifications the in-app banner store (show, dismissKeys,
|
|
147
|
+
* setReminderReconciler).
|
|
148
148
|
* @param {?object} [deps.push] the push module.
|
|
149
149
|
* @param {function(): ?object} [deps.getConfig] daemon.json `promptReminders`.
|
|
150
150
|
* @param {function(): boolean} [deps.isMultiUser] true when the daemon has
|
|
@@ -174,46 +174,47 @@ function createPromptReminders(deps) {
|
|
|
174
174
|
return slug + ":" + session.localId;
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
-
function
|
|
178
|
-
|
|
179
|
-
var payload = {
|
|
180
|
-
type: "permission_reminder",
|
|
181
|
-
slug: entry.slug,
|
|
182
|
-
requestId: entry.requestId,
|
|
183
|
-
title: text.title,
|
|
184
|
-
body: text.body,
|
|
185
|
-
tag: "prompt-reminder-" + key,
|
|
186
|
-
};
|
|
187
|
-
pushForSession(push, entry.session.ownerId, payload, isMultiUser, listAdmins);
|
|
177
|
+
function audienceOf(session) {
|
|
178
|
+
return { ownerId: session.ownerId, isMultiUser: isMultiUser, listAdmins: listAdmins };
|
|
188
179
|
}
|
|
189
180
|
|
|
181
|
+
function core() {
|
|
182
|
+
return notifyFor(push, notifications);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// One notify() delivers the banner and, when due, the push, and the core
|
|
186
|
+
// collapses a repeat under the session's key: no reminder is replaced here.
|
|
190
187
|
function raise(entry, infos, ageMs, key, withPush) {
|
|
191
188
|
states[key].sig = signature(infos);
|
|
189
|
+
var target = { slug: entry.slug, sessionId: entry.session.localId };
|
|
190
|
+
var audience = audienceOf(entry.session);
|
|
191
|
+
states[key].scope = { target: target, audience: audience };
|
|
192
192
|
var text = describe({ project: entry.project, session: entry.session.title, infos: infos, ageMs: ageMs });
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
193
|
+
core().notify("permission_reminder", Object.assign({ requestId: infos[0].requestId }, target),
|
|
194
|
+
{
|
|
195
|
+
push: withPush ? { title: text.title, body: text.body } : null,
|
|
196
|
+
banner: {
|
|
197
|
+
title: text.title,
|
|
198
|
+
body: text.body,
|
|
199
|
+
requestIds: infos.map(function (i) { return i.requestId; }),
|
|
200
|
+
count: infos.length,
|
|
201
|
+
ageMs: ageMs,
|
|
202
|
+
agents: text.agents,
|
|
203
|
+
tools: text.tools,
|
|
204
|
+
},
|
|
205
|
+
}, audience);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// Closes the session's reminder, banner and push alike, if one was raised.
|
|
209
|
+
function close(key) {
|
|
210
|
+
var scope = states[key] && states[key].scope;
|
|
211
|
+
if (scope) core().resolve(scope.target, scope.audience);
|
|
211
212
|
}
|
|
212
213
|
|
|
213
214
|
function clear(key) {
|
|
214
215
|
if (states[key]) {
|
|
216
|
+
close(key);
|
|
215
217
|
delete states[key];
|
|
216
|
-
notifications.dismissReminder(key);
|
|
217
218
|
}
|
|
218
219
|
}
|
|
219
220
|
|
|
@@ -260,7 +261,11 @@ function createPromptReminders(deps) {
|
|
|
260
261
|
if (timer.unref) timer.unref();
|
|
261
262
|
}
|
|
262
263
|
|
|
264
|
+
// The daemon is going away: a reminder still shown would outlive the prompt
|
|
265
|
+
// it nags about, and the reconciler below is detached before the prompts
|
|
266
|
+
// settle, so the reminder pushes are closed here.
|
|
263
267
|
function stop() {
|
|
268
|
+
Object.keys(states).forEach(close);
|
|
264
269
|
if (timer) { clearInterval(timer); timer = null; }
|
|
265
270
|
notifications.setReminderReconciler(null);
|
|
266
271
|
}
|
package/lib/prompt-source.js
CHANGED
|
@@ -7,8 +7,22 @@
|
|
|
7
7
|
//
|
|
8
8
|
// { kind: "ws", clientId, user } an answer from a browser connection
|
|
9
9
|
// { kind: "push", action, user } an answer from a push notification
|
|
10
|
-
//
|
|
11
|
-
//
|
|
10
|
+
//
|
|
11
|
+
// A prompt that ends without an answer carries a cancel source instead: one
|
|
12
|
+
// string from a stable vocabulary, recorded on the prompt_cancel event, in the
|
|
13
|
+
// journal line and in the replayed promptState.
|
|
14
|
+
//
|
|
15
|
+
// user the operator ended it (a rewind, a context clear)
|
|
16
|
+
// timeout the prompt's own timer ran out
|
|
17
|
+
// session_end the scope that owned it ended (turn, query, session abort
|
|
18
|
+
// or close, session deletion)
|
|
19
|
+
// daemon_restart the daemon is going away
|
|
20
|
+
// worker the worker or app-server process stopped waiting for it
|
|
21
|
+
// caller:<name> an outside caller ended it; <name> is the caller's own
|
|
22
|
+
// string (1-64 of A-Z a-z 0-9 . _ @ / + -), never interpreted
|
|
23
|
+
// unspecified the fallback for a cancel that named no valid source (it is
|
|
24
|
+
// logged as a warning); also what a replay reports for an
|
|
25
|
+
// ending recorded before cancels carried a source
|
|
12
26
|
//
|
|
13
27
|
// clientId is a per-connection label made here, not a credential; user is the
|
|
14
28
|
// authenticated user's id, or null in single-user mode. Prompt content never
|
|
@@ -36,18 +50,38 @@ function fromPush(req, action) {
|
|
|
36
50
|
return { kind: "push", action: action, user: userIdOf(req && req._clagenticUser) };
|
|
37
51
|
}
|
|
38
52
|
|
|
39
|
-
|
|
40
|
-
|
|
53
|
+
var CANCEL = Object.freeze({
|
|
54
|
+
USER: "user",
|
|
55
|
+
TIMEOUT: "timeout",
|
|
56
|
+
SESSION_END: "session_end",
|
|
57
|
+
DAEMON_RESTART: "daemon_restart",
|
|
58
|
+
WORKER: "worker",
|
|
59
|
+
UNSPECIFIED: "unspecified",
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
var FIXED_CANCEL_SOURCES = Object.keys(CANCEL).map(function (k) { return CANCEL[k]; });
|
|
63
|
+
var CALLER_SOURCE = /^caller:[A-Za-z0-9._@\/+-]{1,64}$/;
|
|
64
|
+
|
|
65
|
+
function isCancelSource(value) {
|
|
66
|
+
return typeof value === "string" && (FIXED_CANCEL_SOURCES.indexOf(value) !== -1 || CALLER_SOURCE.test(value));
|
|
41
67
|
}
|
|
42
68
|
|
|
43
|
-
|
|
44
|
-
|
|
69
|
+
// The one rule for a cancel's source: a value from the vocabulary is kept; a
|
|
70
|
+
// missing or unknown one becomes "unspecified" and is warned about, so a
|
|
71
|
+
// settle always carries a source and never an undefined one.
|
|
72
|
+
function cancelSource(value, reason) {
|
|
73
|
+
if (isCancelSource(value)) return value;
|
|
74
|
+
console.warn("[prompt-source] cancel (reason=" + logField(reason) + ") named "
|
|
75
|
+
+ (value === undefined || value === null ? "no source" : "an unknown source " + logField(value))
|
|
76
|
+
+ "; recorded as " + CANCEL.UNSPECIFIED);
|
|
77
|
+
return CANCEL.UNSPECIFIED;
|
|
45
78
|
}
|
|
46
79
|
|
|
47
80
|
// The source as log fields, "source=ws client=c-1a2b user=u1". A cancel's
|
|
48
81
|
// reason is its own field on the settle line, not repeated here.
|
|
49
82
|
function describe(source) {
|
|
50
83
|
if (!source) return "source=unspecified";
|
|
84
|
+
if (typeof source === "string") return "source=" + logField(source);
|
|
51
85
|
var out = "source=" + logField(source.kind);
|
|
52
86
|
if (source.clientId) out += " client=" + logField(source.clientId);
|
|
53
87
|
if (source.action) out += " action=" + logField(source.action);
|
|
@@ -58,8 +92,9 @@ function describe(source) {
|
|
|
58
92
|
module.exports = {
|
|
59
93
|
fromWs: fromWs,
|
|
60
94
|
fromPush: fromPush,
|
|
61
|
-
|
|
62
|
-
|
|
95
|
+
CANCEL: CANCEL,
|
|
96
|
+
isCancelSource: isCancelSource,
|
|
97
|
+
cancelSource: cancelSource,
|
|
63
98
|
describe: describe,
|
|
64
99
|
clientIdOf: clientIdOf,
|
|
65
100
|
};
|
package/lib/public/app.js
CHANGED
|
@@ -259,6 +259,31 @@
|
|
|
259
259
|
margin-left: 6px;
|
|
260
260
|
}
|
|
261
261
|
|
|
262
|
+
/* The sessions a restart would end: a count line and an expand control above the
|
|
263
|
+
card's actions. Collapsed by default; expanded, the list scrolls in a bounded
|
|
264
|
+
region, so the card's height does not depend on the session count. */
|
|
265
|
+
.build-update-sessions {
|
|
266
|
+
display: flex;
|
|
267
|
+
flex-direction: column;
|
|
268
|
+
gap: 2px;
|
|
269
|
+
margin-top: 4px;
|
|
270
|
+
font-size: 11px;
|
|
271
|
+
color: var(--text-secondary);
|
|
272
|
+
}
|
|
273
|
+
.build-update-sessions-head {
|
|
274
|
+
display: flex;
|
|
275
|
+
align-items: center;
|
|
276
|
+
gap: 8px;
|
|
277
|
+
}
|
|
278
|
+
.build-update-sessions.is-collapsed .build-update-session-list { display: none; }
|
|
279
|
+
.build-update-session-list {
|
|
280
|
+
margin: 0;
|
|
281
|
+
padding-left: 16px;
|
|
282
|
+
max-height: 160px;
|
|
283
|
+
overflow-y: auto;
|
|
284
|
+
overflow-wrap: anywhere;
|
|
285
|
+
}
|
|
286
|
+
|
|
262
287
|
/* Shown beside a restart button whose click could not be sent. */
|
|
263
288
|
.build-update-send-failed {
|
|
264
289
|
margin-top: 4px;
|
|
@@ -480,6 +505,9 @@
|
|
|
480
505
|
.toast-diagnostic.visible {
|
|
481
506
|
transform: translateY(0);
|
|
482
507
|
}
|
|
508
|
+
.build-update-session-list {
|
|
509
|
+
max-height: 25vh;
|
|
510
|
+
}
|
|
483
511
|
.toast-diagnostic-msg {
|
|
484
512
|
/* Long unbreakable identifiers (e.g. "PostToolUse", absolute paths)
|
|
485
513
|
must wrap instead of forcing the flex child's intrinsic width
|
|
@@ -303,6 +303,13 @@
|
|
|
303
303
|
border: 1.5px solid var(--activity-other, #B77BF3);
|
|
304
304
|
box-shadow: 0 0 4px rgba(183, 123, 243, 0.4);
|
|
305
305
|
}
|
|
306
|
+
/* Waiting on a prompt: dashed ring in the warning hue, so it is
|
|
307
|
+
told from running (filled) and another user's activity (solid ring) by
|
|
308
|
+
shape as well as color. */
|
|
309
|
+
.hub-project-dot.waiting {
|
|
310
|
+
background: transparent;
|
|
311
|
+
border: 1.5px dashed var(--warning);
|
|
312
|
+
}
|
|
306
313
|
.hub-project-icon {
|
|
307
314
|
font-size: 14px;
|
|
308
315
|
width: 20px;
|
|
@@ -523,6 +530,11 @@
|
|
|
523
530
|
border: 1.5px solid var(--activity-other, #B77BF3);
|
|
524
531
|
box-shadow: 0 0 4px rgba(183, 123, 243, 0.4);
|
|
525
532
|
}
|
|
533
|
+
.hub-recent-dot.waiting {
|
|
534
|
+
background: transparent;
|
|
535
|
+
opacity: 1;
|
|
536
|
+
border: 1.5px dashed var(--warning);
|
|
537
|
+
}
|
|
526
538
|
.hub-recent-project-icon {
|
|
527
539
|
font-size: 14px;
|
|
528
540
|
width: 20px;
|
|
@@ -248,6 +248,15 @@
|
|
|
248
248
|
border-color: var(--activity-other, #B77BF3);
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
+
/* Waiting on a prompt: dashed ring, warning hue. */
|
|
252
|
+
.icon-strip-status.waiting {
|
|
253
|
+
opacity: 1;
|
|
254
|
+
background: transparent;
|
|
255
|
+
border-width: 2px;
|
|
256
|
+
border-style: dashed;
|
|
257
|
+
border-color: var(--warning);
|
|
258
|
+
}
|
|
259
|
+
|
|
251
260
|
/* Alert tone (lr-66c118): unread activity wins over processing green. */
|
|
252
261
|
.icon-strip-status.alert {
|
|
253
262
|
opacity: 1;
|
|
@@ -223,6 +223,12 @@
|
|
|
223
223
|
border: 1.5px solid var(--activity-other, #B77BF3);
|
|
224
224
|
box-sizing: border-box;
|
|
225
225
|
}
|
|
226
|
+
/* Waiting on a prompt: dashed ring, warning hue. */
|
|
227
|
+
.mobile-project-processing.waiting {
|
|
228
|
+
background: transparent;
|
|
229
|
+
border: 1.5px dashed var(--warning);
|
|
230
|
+
box-sizing: border-box;
|
|
231
|
+
}
|
|
226
232
|
/* Alert tone (lr-66c118): unread wins over processing green. */
|
|
227
233
|
.mobile-project-processing.alert {
|
|
228
234
|
background: var(--danger, #e74c3c);
|
|
@@ -882,6 +888,11 @@
|
|
|
882
888
|
border: 1.5px solid var(--activity-other, #B77BF3);
|
|
883
889
|
box-sizing: border-box;
|
|
884
890
|
}
|
|
891
|
+
.mobile-session-processing.waiting {
|
|
892
|
+
background: transparent;
|
|
893
|
+
border: 1.5px dashed var(--warning);
|
|
894
|
+
box-sizing: border-box;
|
|
895
|
+
}
|
|
885
896
|
/* Alert tone (lr-66c118): unread wins over processing green. */
|
|
886
897
|
.mobile-session-processing.alert {
|
|
887
898
|
background: var(--danger, #e74c3c);
|
|
@@ -901,6 +901,13 @@
|
|
|
901
901
|
border: 1.5px solid var(--activity-other, #B77BF3);
|
|
902
902
|
box-sizing: border-box;
|
|
903
903
|
}
|
|
904
|
+
/* Waiting on a prompt: dashed ring, warning hue. */
|
|
905
|
+
.session-item .session-processing.waiting,
|
|
906
|
+
.mate-session-item .session-processing.waiting {
|
|
907
|
+
background: transparent;
|
|
908
|
+
border: 1.5px dashed var(--warning);
|
|
909
|
+
box-sizing: border-box;
|
|
910
|
+
}
|
|
904
911
|
/* Alert tone (lr-66c118): unread activity wins over processing green. */
|
|
905
912
|
.session-item .session-processing.alert,
|
|
906
913
|
.mate-session-item .session-processing.alert {
|
package/lib/public/index.html
CHANGED
|
@@ -744,6 +744,7 @@
|
|
|
744
744
|
</div>
|
|
745
745
|
<div class="ps-env-tab-content active" data-tab="project">
|
|
746
746
|
<p class="settings-hint" id="ps-env-scope-hint" style="margin-bottom: 12px;"></p>
|
|
747
|
+
<div class="settings-hint ps-env-notice hidden" id="ps-env-shadow-notice"></div>
|
|
747
748
|
<div class="ps-env-header">
|
|
748
749
|
<button class="settings-btn-sm" id="ps-env-add-btn"><i data-lucide="plus"></i> Add Variable</button>
|
|
749
750
|
<span class="ps-save-status" id="ps-env-save-status"></span>
|
|
@@ -754,6 +755,7 @@
|
|
|
754
755
|
</div>
|
|
755
756
|
<div class="ps-env-tab-content" data-tab="shared">
|
|
756
757
|
<p class="settings-hint" style="margin-bottom: 12px;">Shared variables apply to every session in every project. Only administrators can change them. Project-level variables take precedence where they apply. Applies to sessions started after saving.</p>
|
|
758
|
+
<div class="settings-hint ps-env-notice hidden" id="ps-shared-env-shadow-notice"></div>
|
|
757
759
|
<div class="ps-env-header">
|
|
758
760
|
<button class="settings-btn-sm" id="ps-shared-env-add-btn"><i data-lucide="plus"></i> Add Variable</button>
|
|
759
761
|
<span class="ps-save-status" id="ps-shared-env-save-status"></span>
|
|
@@ -1325,6 +1327,7 @@
|
|
|
1325
1327
|
<div class="server-settings-section" data-section="environment">
|
|
1326
1328
|
<h2>Environment</h2>
|
|
1327
1329
|
<p class="settings-hint" style="margin-bottom: 16px;">Define environment variables shared across all projects. Project-level variables take precedence over shared ones. Applies to sessions started after saving.</p>
|
|
1330
|
+
<div class="settings-hint ps-env-notice hidden" id="ss-env-shadow-notice"></div>
|
|
1328
1331
|
<div class="ps-env-header">
|
|
1329
1332
|
<button class="settings-btn-sm" id="ss-env-add-btn"><i data-lucide="plus"></i> Add Variable</button>
|
|
1330
1333
|
<span class="ps-save-status" id="ss-env-save-status"></span>
|
|
@@ -13,6 +13,14 @@
|
|
|
13
13
|
//
|
|
14
14
|
// Design notes:
|
|
15
15
|
//
|
|
16
|
+
// - Waiting: a session the daemon reports as blocked on an
|
|
17
|
+
// operator prompt (the `waiting` wire field, derived once in
|
|
18
|
+
// lib/session-liveness.js from the same pending-prompt data list-sessions
|
|
19
|
+
// serves) is its own tone, "waiting", and outranks alert: a blocked
|
|
20
|
+
// session is the one the operator must act on, and an unread badge on it
|
|
21
|
+
// must not hide that. It has its own class, "waiting", distinct from
|
|
22
|
+
// running and idle.
|
|
23
|
+
//
|
|
16
24
|
// - Precedence (LOCKED, operator ruling lr-0aa7b6, promoted here from its
|
|
17
25
|
// former home-hub-only special case): alert > processing > live > idle.
|
|
18
26
|
// "live" and "processing" collapse to the same visual state today (no
|
|
@@ -38,7 +46,7 @@
|
|
|
38
46
|
* @typedef {Object} ActivityState
|
|
39
47
|
* @property {boolean} active - true if there is any live activity to show a dot for.
|
|
40
48
|
* @property {boolean} alert - true if this represents unread/alert state (wins over active).
|
|
41
|
-
* @property {"alert"|"self"|"other"|"idle"} tone - which color family to render.
|
|
49
|
+
* @property {"waiting"|"alert"|"self"|"other"|"idle"} tone - which color family to render.
|
|
42
50
|
* @property {string} label - short human label for a title/tooltip attribute.
|
|
43
51
|
*/
|
|
44
52
|
|
|
@@ -61,6 +69,9 @@
|
|
|
61
69
|
* self-vs-other tone. Omit (or pass null/undefined) in single-user mode —
|
|
62
70
|
* every session then renders as 'self'.
|
|
63
71
|
* @param {object} [opts]
|
|
72
|
+
* @param {boolean} [opts.ignoreWaiting] - read only the turn flag, for the
|
|
73
|
+
* transcript footer, which says whether a turn is running and must not be
|
|
74
|
+
* pinned on by a session that is merely waiting on a prompt.
|
|
64
75
|
* @param {boolean} [opts.ignoreUnread] - suppress alert/unread from flipping
|
|
65
76
|
* `.active`/tone, for a consumer that has no unread-alert affordance of
|
|
66
77
|
* its own. Project-level dots (icon strip, mobile project rows, folder
|
|
@@ -81,6 +92,10 @@ export function sessionActivity(sess, currentUserId, opts) {
|
|
|
81
92
|
return { active: false, alert: false, tone: "idle", label: "Idle" };
|
|
82
93
|
}
|
|
83
94
|
|
|
95
|
+
if (sess.waiting && !(opts && opts.ignoreWaiting)) {
|
|
96
|
+
return { active: true, alert: false, tone: "waiting", label: "Waiting on a prompt" };
|
|
97
|
+
}
|
|
98
|
+
|
|
84
99
|
var alert = !(opts && opts.ignoreUnread) && (sess.unread || 0) > 0;
|
|
85
100
|
var active = !!sess.isProcessing;
|
|
86
101
|
|
|
@@ -123,7 +138,7 @@ export function deriveSessionListProcessing(sessions, activeSessionId) {
|
|
|
123
138
|
if (activeSessionId == null || !sessions) return { found: false, active: false };
|
|
124
139
|
for (var i = 0; i < sessions.length; i++) {
|
|
125
140
|
if (sessions[i].id === activeSessionId) {
|
|
126
|
-
return { found: true, active: sessionActivity(sessions[i], null, { ignoreUnread: true }).active };
|
|
141
|
+
return { found: true, active: sessionActivity(sessions[i], null, { ignoreUnread: true, ignoreWaiting: true }).active };
|
|
127
142
|
}
|
|
128
143
|
}
|
|
129
144
|
return { found: false, active: false };
|
|
@@ -132,7 +147,7 @@ export function deriveSessionListProcessing(sessions, activeSessionId) {
|
|
|
132
147
|
// Precedence used by both sessionActivity's tone choice above and
|
|
133
148
|
// rollupActivity's OR-reduce below. Higher wins. 'self' outranks 'other'
|
|
134
149
|
// per the locked rollup rule; 'alert' outranks everything.
|
|
135
|
-
var TONE_RANK = { idle: 0, other: 1, self: 2, alert: 3 };
|
|
150
|
+
var TONE_RANK = { idle: 0, other: 1, self: 2, alert: 3, waiting: 4 };
|
|
136
151
|
|
|
137
152
|
/**
|
|
138
153
|
* Roll up a list of already-derived (or raw session/project) items into a
|
|
@@ -180,10 +195,11 @@ export function rollupActivity(list, currentUserId, opts) {
|
|
|
180
195
|
/**
|
|
181
196
|
* The one place a CSS class suffix is chosen from an ActivityState.
|
|
182
197
|
* @param {ActivityState} state
|
|
183
|
-
* @returns {string} "" | "processing" | "alert" | "other"
|
|
198
|
+
* @returns {string} "" | "processing" | "alert" | "other" | "waiting"
|
|
184
199
|
*/
|
|
185
200
|
export function indicatorClass(state) {
|
|
186
201
|
if (!state || !state.active) return "";
|
|
202
|
+
if (state.tone === "waiting") return "waiting";
|
|
187
203
|
if (state.tone === "alert") return "alert";
|
|
188
204
|
if (state.tone === "other") return "other";
|
|
189
205
|
// tone === "self": the reconciled state. home-hub.css's stale comment
|
|
@@ -277,6 +277,10 @@ function fetchWsTicket() {
|
|
|
277
277
|
.catch(function () { return { ticket: null }; });
|
|
278
278
|
}
|
|
279
279
|
|
|
280
|
+
// Bumped by every connect() call; an attempt whose generation is no longer
|
|
281
|
+
// current is superseded and must not touch the socket or the UI.
|
|
282
|
+
var connectGeneration = 0;
|
|
283
|
+
|
|
280
284
|
// Milliseconds to wait before re-verifying a single ws-ticket 401 (lr-e5c1fe).
|
|
281
285
|
var UNAUTH_RETRY_BACKOFF_MS = 400;
|
|
282
286
|
|
|
@@ -291,21 +295,27 @@ var UNAUTH_RETRY_BACKOFF_MS = 400;
|
|
|
291
295
|
// re-run) then proved was still good. Re-verify once, after a short backoff,
|
|
292
296
|
// before declaring the session gone — only two consecutive 401s (auth
|
|
293
297
|
// actually confirmed absent) route to handleUnauthenticated().
|
|
298
|
+
//
|
|
299
|
+
// Single-flight: each call takes a new generation. An earlier attempt still
|
|
300
|
+
// awaiting its ticket sees the bump and neither opens nor registers a socket,
|
|
301
|
+
// so no orphan socket can keep feeding processMessage.
|
|
294
302
|
export function connect() {
|
|
303
|
+
var gen = ++connectGeneration;
|
|
304
|
+
cancelReconnect();
|
|
295
305
|
var ws = getWs();
|
|
296
306
|
if (ws) { ws.onclose = null; ws.onmessage = null; ws.onerror = null; ws.close(); }
|
|
297
307
|
if (connectTimeoutId) { clearTimeout(connectTimeoutId); connectTimeoutId = null; }
|
|
298
308
|
|
|
299
309
|
fetchWsTicket().then(function (result) {
|
|
310
|
+
if (gen !== connectGeneration) return;
|
|
300
311
|
if (result.unauthenticated) {
|
|
301
312
|
setTimeout(function () {
|
|
313
|
+
if (gen !== connectGeneration) return;
|
|
302
314
|
fetchWsTicket().then(function (retryResult) {
|
|
315
|
+
if (gen !== connectGeneration) return;
|
|
303
316
|
if (retryResult.unauthenticated) {
|
|
304
317
|
// Two consecutive 401s: auth is confirmed gone, not a transient
|
|
305
|
-
// wake-from-background cookie
|
|
306
|
-
// instead of opening a socket that would only 401 on the
|
|
307
|
-
// upgrade too — ties into the Surface-1 unauth-vs-unreachable
|
|
308
|
-
// split below.
|
|
318
|
+
// wake-from-background cookie gap. Route to sign-in.
|
|
309
319
|
handleUnauthenticated();
|
|
310
320
|
return;
|
|
311
321
|
}
|
|
@@ -333,9 +343,13 @@ function openSocket(ticket) {
|
|
|
333
343
|
var newWs = ticket ? new WebSocket(url, ["clagentic.auth." + ticket]) : new WebSocket(url);
|
|
334
344
|
setWs(newWs);
|
|
335
345
|
|
|
346
|
+
// Handlers fire only while this socket is still the tracked one; a socket
|
|
347
|
+
// that was replaced must not mutate connection state or feed messages.
|
|
348
|
+
function isCurrent() { return getWs() === newWs; }
|
|
349
|
+
|
|
336
350
|
// If not connected within 3s, force retry
|
|
337
351
|
connectTimeoutId = setTimeout(function () {
|
|
338
|
-
if (!store.get('connected')) {
|
|
352
|
+
if (isCurrent() && !store.get('connected')) {
|
|
339
353
|
newWs.onclose = null;
|
|
340
354
|
newWs.onerror = null;
|
|
341
355
|
newWs.onmessage = null;
|
|
@@ -353,6 +367,7 @@ function openSocket(ticket) {
|
|
|
353
367
|
var everOpened = false;
|
|
354
368
|
|
|
355
369
|
newWs.onopen = function () {
|
|
370
|
+
if (!isCurrent()) return;
|
|
356
371
|
everOpened = true;
|
|
357
372
|
if (connectTimeoutId) { clearTimeout(connectTimeoutId); connectTimeoutId = null; }
|
|
358
373
|
setStatus("connected");
|
|
@@ -373,6 +388,7 @@ function openSocket(ticket) {
|
|
|
373
388
|
};
|
|
374
389
|
|
|
375
390
|
newWs.onclose = function (e) {
|
|
391
|
+
if (!isCurrent()) return;
|
|
376
392
|
if (connectTimeoutId) { clearTimeout(connectTimeoutId); connectTimeoutId = null; }
|
|
377
393
|
closeDmUserPicker();
|
|
378
394
|
setStatus("disconnected");
|
|
@@ -399,6 +415,7 @@ function openSocket(ticket) {
|
|
|
399
415
|
newWs.onerror = function () {};
|
|
400
416
|
|
|
401
417
|
newWs.onmessage = function (event) {
|
|
418
|
+
if (!isCurrent()) return;
|
|
402
419
|
// Backup: if we're receiving messages, we're connected
|
|
403
420
|
if (!store.get('connected')) {
|
|
404
421
|
setStatus("connected");
|