@clagentic/console 1.9.0-beta.1 → 1.9.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/bin/cli.js +23 -1
- package/lib/agents.js +13 -3
- package/lib/build-sha.json +2 -2
- package/lib/cli/ipc-subcommands.js +84 -4
- package/lib/daemon.js +111 -7
- package/lib/effective-protocol.js +82 -0
- package/lib/project-connection.js +21 -8
- package/lib/project-filesystem.js +4 -4
- package/lib/project-http.js +4 -4
- package/lib/project-loop.js +49 -5
- package/lib/project-sessions.js +166 -68
- package/lib/project-user-mention.js +7 -7
- package/lib/project-user-message.js +81 -14
- package/lib/project.js +28 -22
- package/lib/public/app.js +18 -4
- package/lib/public/css/base.css +14 -0
- package/lib/public/css/filebrowser.css +6 -0
- package/lib/public/css/home-hub.css +28 -8
- package/lib/public/css/icon-strip.css +17 -0
- package/lib/public/css/messages.css +11 -0
- package/lib/public/css/mobile-nav.css +22 -0
- package/lib/public/css/server-settings.css +9 -0
- package/lib/public/css/sidebar.css +15 -0
- package/lib/public/css/title-bar.css +10 -1
- package/lib/public/index.html +9 -2
- package/lib/public/modules/activity-latch.js +45 -0
- package/lib/public/modules/activity-state.js +195 -0
- package/lib/public/modules/app-connection.js +31 -6
- package/lib/public/modules/app-favicon.js +75 -1
- package/lib/public/modules/app-home-hub.js +14 -11
- package/lib/public/modules/app-loop-ui.js +86 -2
- package/lib/public/modules/app-messages.js +178 -54
- package/lib/public/modules/app-panels.js +91 -32
- package/lib/public/modules/app-projects.js +46 -9
- package/lib/public/modules/app-rate-limit.js +13 -1
- package/lib/public/modules/server-settings.js +256 -21
- package/lib/public/modules/sidebar-mobile.js +32 -22
- package/lib/public/modules/sidebar-projects.js +42 -14
- package/lib/public/modules/sidebar-sessions.js +168 -48
- package/lib/public/modules/theme.js +2 -2
- package/lib/public/modules/tools.js +11 -39
- package/lib/sdk-bridge.js +375 -33
- package/lib/sdk-message-processor.js +98 -15
- package/lib/sdk-skill-discovery.js +46 -6
- package/lib/sdk-slash-enrichment.js +5 -2
- package/lib/server-dm.js +5 -5
- package/lib/server-hub-sessions.js +70 -0
- package/lib/server.js +78 -43
- package/lib/session-activity.js +9 -2
- package/lib/sessions.js +64 -18
- package/lib/smtp.js +10 -1
- package/lib/terminal-manager.js +6 -6
- package/lib/ws-schema.js +16 -0
- package/lib/yoke/adapters/claude.js +7 -1
- package/lib/yoke/adapters/codex.js +219 -31
- package/package.json +2 -2
- package/scripts/check-test-count.js +397 -0
- package/scripts/test-file-completion-reporter.js +43 -0
- package/scripts/verify-installed-build.js +242 -15
- package/lib/model-context-windows.js +0 -74
- package/lib/public/modules/model-context-windows.js +0 -71
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// activity-latch.js - Pure decision logic for session-scoping a
|
|
2
|
+
// session-addressed WS edge to the client's currently-focused session.
|
|
3
|
+
//
|
|
4
|
+
// lr-5edd64: this module used to also own the client-local 'processing'
|
|
5
|
+
// activity-indicator latch's staleness backstop (createActivityStaleBackstop)
|
|
6
|
+
// and an accept/reject ledger built to observe that latch
|
|
7
|
+
// (recordActivityEdgeDecision/getActivityEdgeLedger, lr-58c813). Both are
|
|
8
|
+
// deleted here: 'processing' (the field app-favicon.js's initActivityFooter
|
|
9
|
+
// subscribes to) is no longer an independently-written client-local latch —
|
|
10
|
+
// it is a pure PROJECTION of server-authoritative per-session state
|
|
11
|
+
// (app-messages.js's session_list/session_switched handlers, deriving via
|
|
12
|
+
// activity-state.js's sessionActivity()). A staleness backstop and a ledger
|
|
13
|
+
// both existed solely to defend that latch against a missed edge; with
|
|
14
|
+
// nothing left to defend, keeping them would make them load-bearing again
|
|
15
|
+
// for no real behavior (MILLER lr-5edd64 comment #2, Q6).
|
|
16
|
+
//
|
|
17
|
+
// shouldApplyActivityEdge itself remains: app-messages.js's status handler
|
|
18
|
+
// still uses it to session-scope a DIFFERENT, non-render concern —
|
|
19
|
+
// sessionIsProcessing (dead-session-todo-compaction) and the pre-thinking-
|
|
20
|
+
// dots clear — both of which target whatever session this client is
|
|
21
|
+
// currently viewing, so a background session's status:"processing" must
|
|
22
|
+
// still not touch them. That guard was never specific to the 'processing'
|
|
23
|
+
// latch; it is a general "does this session-addressed edge belong to the
|
|
24
|
+
// session I'm currently looking at?" predicate, reused here for its second,
|
|
25
|
+
// still-live purpose.
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Should a session-scoped edge (e.g. status:"processing") be applied to
|
|
29
|
+
* state the client currently associates with its focused session?
|
|
30
|
+
*
|
|
31
|
+
* Mirrors the lr-0827ba pattern already used by scheduled_message_*
|
|
32
|
+
* handlers: a message with no localId (older server, or a message type
|
|
33
|
+
* that was never session-scoped) always applies, matching pre-fix
|
|
34
|
+
* behavior; a message WITH a localId only applies when it matches the
|
|
35
|
+
* session the client currently has focused.
|
|
36
|
+
*
|
|
37
|
+
* @param {number|string|null|undefined} msgLocalId - localId on the
|
|
38
|
+
* incoming message, or null/undefined if the server didn't stamp one.
|
|
39
|
+
* @param {number|string|null|undefined} activeSessionId - the client's
|
|
40
|
+
* currently-focused session id (store.get('activeSessionId')).
|
|
41
|
+
* @returns {boolean}
|
|
42
|
+
*/
|
|
43
|
+
export function shouldApplyActivityEdge(msgLocalId, activeSessionId) {
|
|
44
|
+
return msgLocalId == null || msgLocalId === activeSessionId;
|
|
45
|
+
}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
// activity-state.js - Single frontend derivation module for activity
|
|
2
|
+
// indicator state (dots) across every render surface.
|
|
3
|
+
//
|
|
4
|
+
// Replaces 21 previously-divergent render sites across sidebar-sessions.js,
|
|
5
|
+
// sidebar-projects.js, sidebar-mobile.js, app-home-hub.js, app-projects.js,
|
|
6
|
+
// and the 3 different state sources they used to read directly (the
|
|
7
|
+
// per-session processing flag, the client's own live connection processing
|
|
8
|
+
// flag, and setActivity) with ONE derivation:
|
|
9
|
+
//
|
|
10
|
+
// sessionActivity(sess, currentUserId, opts) -> { active, alert, tone, label }
|
|
11
|
+
// rollupActivity(list, currentUserId, opts) -> same shape, OR-reduced
|
|
12
|
+
// indicatorClass(state) -> the one place a CSS class is chosen
|
|
13
|
+
//
|
|
14
|
+
// Design notes:
|
|
15
|
+
//
|
|
16
|
+
// - Precedence (LOCKED, operator ruling lr-0aa7b6, promoted here from its
|
|
17
|
+
// former home-hub-only special case): alert > processing > live > idle.
|
|
18
|
+
// "live" and "processing" collapse to the same visual state today (no
|
|
19
|
+
// separate 'live' CSS class exists anywhere in the codebase — the
|
|
20
|
+
// home-hub.css comment claiming 4 states was aspirational, not real; see
|
|
21
|
+
// indicatorClass() below for the reconciliation). tone: 'alert' | 'self' |
|
|
22
|
+
// 'other' | 'idle'.
|
|
23
|
+
//
|
|
24
|
+
// - Multi-user tone (operator ruling, epic lr-a6a449): a session/project
|
|
25
|
+
// whose activity belongs to a DIFFERENT user renders in a third,
|
|
26
|
+
// non-red/non-green tone ('other'), never conflated with your own
|
|
27
|
+
// ('self'). Rollup rule: self wins over other when a folder/project
|
|
28
|
+
// contains both — your own work is the more actionable signal, same
|
|
29
|
+
// spirit as the locked alert-over-processing precedence.
|
|
30
|
+
//
|
|
31
|
+
// - This module is pure: no DOM, no store import, no WS. Callers own
|
|
32
|
+
// rendering (indicatorClass gives the CSS class; callers still build the
|
|
33
|
+
// element/title/etc.). This keeps activity-state.js testable as plain
|
|
34
|
+
// data transforms and reusable from any surface (sidebar, mobile sheet,
|
|
35
|
+
// home hub) without an import cycle back into store.js or a render module.
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @typedef {Object} ActivityState
|
|
39
|
+
* @property {boolean} active - true if there is any live activity to show a dot for.
|
|
40
|
+
* @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.
|
|
42
|
+
* @property {string} label - short human label for a title/tooltip attribute.
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Derive activity state for a single session-shaped object. Callers pass the
|
|
47
|
+
* RAW session/project object straight through — activity-state.js is the
|
|
48
|
+
* ONLY place in lib/public/modules/ allowed to read .isProcessing (CI
|
|
49
|
+
* assertion #2); render sites must never read it themselves, even to build
|
|
50
|
+
* a wrapper object for this function.
|
|
51
|
+
*
|
|
52
|
+
* Accepts any object carrying the fields already on the wire for a session
|
|
53
|
+
* list item (lib/sessions.js mapSessionForClient): isProcessing, unread,
|
|
54
|
+
* ownerId. Also accepts the project-shaped objects used by the icon strip /
|
|
55
|
+
* mobile sheets (isProcessing, unread) — ownerId is absent there, which
|
|
56
|
+
* correctly falls back to tone 'self' since a project has no single owner
|
|
57
|
+
* distinguishing "mine" from "someone else's" the way a session does.
|
|
58
|
+
*
|
|
59
|
+
* @param {object} sess - session or project object with isProcessing/unread/ownerId.
|
|
60
|
+
* @param {string|number|null} [currentUserId] - the viewing user's id, for
|
|
61
|
+
* self-vs-other tone. Omit (or pass null/undefined) in single-user mode —
|
|
62
|
+
* every session then renders as 'self'.
|
|
63
|
+
* @param {object} [opts]
|
|
64
|
+
* @param {boolean} [opts.ignoreUnread] - suppress alert/unread from flipping
|
|
65
|
+
* `.active`/tone, for a consumer that has no unread-alert affordance of
|
|
66
|
+
* its own. Project-level dots (icon strip, mobile project rows, folder
|
|
67
|
+
* headers, home-hub project summary) are the original case: they have
|
|
68
|
+
* their OWN separate unread badge and have never shown alert red on the
|
|
69
|
+
* dot itself, so passing the raw project object (which does carry
|
|
70
|
+
* .unread, for the badge) must not also flip the dot to alert tone.
|
|
71
|
+
* lr-5edd64: the transcript footer's "is a turn running" projection
|
|
72
|
+
* (app-messages.js's session_list handler) is a second, SESSION-level
|
|
73
|
+
* caller of this — it is a processing indicator, not a dot with its own
|
|
74
|
+
* alert affordance, so unread must not pin it on. Most other
|
|
75
|
+
* session-level dots (sidebar rows, hub recent-session rows) still want
|
|
76
|
+
* full alert precedence and must NOT set this.
|
|
77
|
+
* @returns {ActivityState}
|
|
78
|
+
*/
|
|
79
|
+
export function sessionActivity(sess, currentUserId, opts) {
|
|
80
|
+
if (!sess) {
|
|
81
|
+
return { active: false, alert: false, tone: "idle", label: "Idle" };
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
var alert = !(opts && opts.ignoreUnread) && (sess.unread || 0) > 0;
|
|
85
|
+
var active = !!sess.isProcessing;
|
|
86
|
+
|
|
87
|
+
if (alert) {
|
|
88
|
+
return { active: true, alert: true, tone: "alert", label: "Unread activity" };
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (!active) {
|
|
92
|
+
return { active: false, alert: false, tone: "idle", label: "Idle" };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
var isOther = !!(sess.ownerId != null && currentUserId != null && sess.ownerId !== currentUserId);
|
|
96
|
+
return isOther
|
|
97
|
+
? { active: true, alert: false, tone: "other", label: "Active (another user)" }
|
|
98
|
+
: { active: true, alert: false, tone: "self", label: "Active" };
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* lr-5edd64: the exact derivation app-messages.js's session_list handler
|
|
103
|
+
* performs to project the transcript footer's 'processing' field from a
|
|
104
|
+
* session_list broadcast — extracted here (a pure, DOM-free module) rather
|
|
105
|
+
* than left inline, specifically so a test can import and exercise the
|
|
106
|
+
* REAL production logic directly. app-messages.js is not importable under
|
|
107
|
+
* plain Node (its import graph reaches the theme.js<->markdown.js circular
|
|
108
|
+
* boot hazard — see activity-latch-lr-96e7da.test.js's header), so without
|
|
109
|
+
* this extraction a behavioral test of this projection would necessarily
|
|
110
|
+
* be testing a hand-copied reimplementation, not the code that actually
|
|
111
|
+
* ships. Bounded to the entry matching activeSessionId; { ignoreUnread:
|
|
112
|
+
* true } is REQUIRED here — see sessionActivity's ignoreUnread doc above
|
|
113
|
+
* for why (PEACHES finding 2, this task's 8th recurrence): the footer is a
|
|
114
|
+
* turn-running indicator, not an unread-alert surface.
|
|
115
|
+
*
|
|
116
|
+
* @param {Array<object>} sessions - msg.sessions from a session_list broadcast.
|
|
117
|
+
* @param {string|number|null} activeSessionId
|
|
118
|
+
* @returns {{found: boolean, active: boolean}} found=false means no entry
|
|
119
|
+
* matched activeSessionId (or activeSessionId is null) — caller must not
|
|
120
|
+
* apply a projection in that case.
|
|
121
|
+
*/
|
|
122
|
+
export function deriveSessionListProcessing(sessions, activeSessionId) {
|
|
123
|
+
if (activeSessionId == null || !sessions) return { found: false, active: false };
|
|
124
|
+
for (var i = 0; i < sessions.length; i++) {
|
|
125
|
+
if (sessions[i].id === activeSessionId) {
|
|
126
|
+
return { found: true, active: sessionActivity(sessions[i], null, { ignoreUnread: true }).active };
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return { found: false, active: false };
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Precedence used by both sessionActivity's tone choice above and
|
|
133
|
+
// rollupActivity's OR-reduce below. Higher wins. 'self' outranks 'other'
|
|
134
|
+
// per the locked rollup rule; 'alert' outranks everything.
|
|
135
|
+
var TONE_RANK = { idle: 0, other: 1, self: 2, alert: 3 };
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Roll up a list of already-derived (or raw session/project) items into a
|
|
139
|
+
* single ActivityState, replacing the 8 open-coded `anyProcessing` OR-loops
|
|
140
|
+
* this module supersedes.
|
|
141
|
+
*
|
|
142
|
+
* Accepts either raw session/project objects (in which case sessionActivity
|
|
143
|
+
* is applied per-item using the given currentUserId) or an array of
|
|
144
|
+
* ActivityState objects already produced by sessionActivity — the latter is
|
|
145
|
+
* useful when a caller has already computed per-item tone for other reasons
|
|
146
|
+
* and wants to fold the results without re-deriving.
|
|
147
|
+
*
|
|
148
|
+
* @param {Array<object|ActivityState>} list
|
|
149
|
+
* @param {string|number|null} [currentUserId]
|
|
150
|
+
* @param {object} [opts] - forwarded to sessionActivity() for each raw item;
|
|
151
|
+
* see its ignoreUnread doc. Ignored for items that are already derived
|
|
152
|
+
* ActivityState objects.
|
|
153
|
+
* @returns {ActivityState}
|
|
154
|
+
*/
|
|
155
|
+
export function rollupActivity(list, currentUserId, opts) {
|
|
156
|
+
if (!list || list.length === 0) {
|
|
157
|
+
return { active: false, alert: false, tone: "idle", label: "Idle" };
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
var best = { active: false, alert: false, tone: "idle", label: "Idle" };
|
|
161
|
+
for (var i = 0; i < list.length; i++) {
|
|
162
|
+
var item = list[i];
|
|
163
|
+
var state = (item && typeof item.tone === "string" && typeof item.active === "boolean")
|
|
164
|
+
? item
|
|
165
|
+
: sessionActivity(item, currentUserId, opts);
|
|
166
|
+
if (TONE_RANK[state.tone] > TONE_RANK[best.tone]) {
|
|
167
|
+
best = state;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return best;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// The 5 CSS class families this reconciles all key their "on" state off a
|
|
174
|
+
// bare ".processing" (or ".alert" for the home-hub dot) suffix appended to a
|
|
175
|
+
// per-surface base class. indicatorClass() returns ONLY that suffix (or ""
|
|
176
|
+
// for idle) — callers still own their own base class name, since the base
|
|
177
|
+
// classes themselves are not being unified (that would be a DOM/CSS
|
|
178
|
+
// restructure, out of scope for a derivation module) — only the STATE ->
|
|
179
|
+
// CLASS decision is centralized.
|
|
180
|
+
/**
|
|
181
|
+
* The one place a CSS class suffix is chosen from an ActivityState.
|
|
182
|
+
* @param {ActivityState} state
|
|
183
|
+
* @returns {string} "" | "processing" | "alert" | "other"
|
|
184
|
+
*/
|
|
185
|
+
export function indicatorClass(state) {
|
|
186
|
+
if (!state || !state.active) return "";
|
|
187
|
+
if (state.tone === "alert") return "alert";
|
|
188
|
+
if (state.tone === "other") return "other";
|
|
189
|
+
// tone === "self": the reconciled state. home-hub.css's stale comment
|
|
190
|
+
// claimed 4 states (alert/processing/live/idle) but only ever shipped 3
|
|
191
|
+
// classes (.alert, .processing, bare/idle) — there is no separate "live"
|
|
192
|
+
// class anywhere in the codebase. "self" activity renders as ".processing"
|
|
193
|
+
// everywhere, matching what every surface already shipped.
|
|
194
|
+
return "processing";
|
|
195
|
+
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { store } from './store.js';
|
|
5
5
|
import { getWs, setWs } from './ws-ref.js';
|
|
6
6
|
import { getStatusDot, getSendBtn } from './dom-refs.js';
|
|
7
|
-
import { setSendBtnMode, blinkIO
|
|
7
|
+
import { setSendBtnMode, blinkIO } from './app-favicon.js';
|
|
8
8
|
import { startLogoAnimation, stopLogoAnimation } from './console-logo.js';
|
|
9
9
|
import { hasSendableContent } from './input.js';
|
|
10
10
|
import { processMessage } from './app-messages.js';
|
|
@@ -14,6 +14,7 @@ import { resetTerminals } from './terminal.js';
|
|
|
14
14
|
import { closeDmUserPicker } from './sidebar-users.js';
|
|
15
15
|
import { openDm } from './app-dm.js';
|
|
16
16
|
import { getPaletteVersion } from './command-palette.js';
|
|
17
|
+
import { sessionActivity, indicatorClass } from './activity-state.js';
|
|
17
18
|
|
|
18
19
|
var reconnectTimer = null;
|
|
19
20
|
var reconnectDelay = 100;
|
|
@@ -74,14 +75,21 @@ export function initConnection() {
|
|
|
74
75
|
|
|
75
76
|
// --- Reactive UI sync for connected/processing state ---
|
|
76
77
|
store.subscribe(['connected', 'processing'], function (state, prev) {
|
|
77
|
-
// Status dot (depends on both connected and processing)
|
|
78
|
+
// Status dot (depends on both connected and processing). lr-66c118:
|
|
79
|
+
// routed through the same derivation every other dot uses rather than
|
|
80
|
+
// writing '.processing' independently. lr-5edd64: state.processing is
|
|
81
|
+
// now a projection of the focused session's server-authoritative
|
|
82
|
+
// isProcessing (app-messages.js's session_list/session_switched
|
|
83
|
+
// handlers) rather than a client-local edge latch — always tone 'self'
|
|
84
|
+
// here since this dot represents the viewing user's own connection.
|
|
78
85
|
if (state.connected !== prev.connected || state.processing !== prev.processing) {
|
|
79
86
|
var dot = getStatusDot();
|
|
80
87
|
if (dot) {
|
|
81
88
|
dot.className = "icon-strip-status";
|
|
82
89
|
if (state.connected) {
|
|
83
90
|
dot.classList.add("connected");
|
|
84
|
-
|
|
91
|
+
var connActivityCls = indicatorClass(sessionActivity({ isProcessing: state.processing }));
|
|
92
|
+
if (connActivityCls) dot.classList.add(connActivityCls);
|
|
85
93
|
}
|
|
86
94
|
}
|
|
87
95
|
}
|
|
@@ -140,10 +148,26 @@ export function initConnection() {
|
|
|
140
148
|
});
|
|
141
149
|
}
|
|
142
150
|
|
|
143
|
-
// setStatus:
|
|
151
|
+
// setStatus: connection lifecycle, plus the two remaining legitimate
|
|
152
|
+
// session-scoped PUSH raises of 'processing' (lr-5edd64). The status/done/
|
|
153
|
+
// auth_required handlers no longer call this with "processing"/"connected"
|
|
154
|
+
// to drive it — that was the client-local latch with no reconciliation
|
|
155
|
+
// MILLER's lr-5edd64 diagnosis identified. 'processing' is now primarily a
|
|
156
|
+
// PROJECTION: re-derived from the session_list entry for the active session
|
|
157
|
+
// and the session_switched snapshot (app-messages.js) on every broadcast,
|
|
158
|
+
// regardless of whether anything pushed it in between — so even if one of
|
|
159
|
+
// the two remaining pushes below is ever missed or mis-scoped, the next
|
|
160
|
+
// session_list/session_switched self-corrects it (comment #2 Q5's push+
|
|
161
|
+
// query requirement). scheduled_message_sent and auto_continue_fired keep
|
|
162
|
+
// calling setStatus("processing") here because they are genuine "a turn
|
|
163
|
+
// just started for the focused session" server pushes, same shape as the
|
|
164
|
+
// deleted status:"processing" push, just for two different message types —
|
|
165
|
+
// deleting the push entirely (rather than just the previously-redundant
|
|
166
|
+
// status/done/auth_required copies of it) would leave a real WS event with
|
|
167
|
+
// no immediate raise until the next session_list tick.
|
|
144
168
|
export function setStatus(status) {
|
|
145
169
|
if (status === "connected") {
|
|
146
|
-
store.set({ connected: true
|
|
170
|
+
store.set({ connected: true });
|
|
147
171
|
} else if (status === "processing") {
|
|
148
172
|
store.set({ processing: true });
|
|
149
173
|
} else {
|
|
@@ -331,7 +355,8 @@ function openSocket(ticket) {
|
|
|
331
355
|
if (connectTimeoutId) { clearTimeout(connectTimeoutId); connectTimeoutId = null; }
|
|
332
356
|
closeDmUserPicker();
|
|
333
357
|
setStatus("disconnected");
|
|
334
|
-
setActivity(null)
|
|
358
|
+
// lr-66c118: the setActivity(null) clear formerly here is gone —
|
|
359
|
+
// setActivity collapsed to one optimistic raise (input.js), no manual clears.
|
|
335
360
|
// lr-0446: Discard any pending cross-project session switch. If the WS
|
|
336
361
|
// closed before the target project's session_list fired, the key is now
|
|
337
362
|
// stale — leaving it would cause the *next* successful session_list (on
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { refreshIcons } from './icons.js';
|
|
5
5
|
import { store } from './store.js';
|
|
6
6
|
import { getSendBtn, getStatusDot } from './dom-refs.js';
|
|
7
|
-
import { onThemeChange } from './theme.js';
|
|
7
|
+
import { onThemeChange, getChatLayout } from './theme.js';
|
|
8
8
|
import { getActivityEl, setActivityEl, addToMessages, scrollToBottom } from './app-rendering.js';
|
|
9
9
|
|
|
10
10
|
// --- Module-owned state ---
|
|
@@ -230,3 +230,77 @@ export function setActivity(text) {
|
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
+
// lr-6e20f7: the reactive clear setActivity's own removal branch (above) was
|
|
234
|
+
// designed for but never wired up — lr-66c118 deleted all 15 manual clear
|
|
235
|
+
// call sites (including every clear of this widget) on the assumption that
|
|
236
|
+
// "the widget's own reactive clear" would replace them, but no such
|
|
237
|
+
// subscriber was ever added. The widget was raised once at input.js's
|
|
238
|
+
// optimistic call and then never cleared again short of a full DOM wipe
|
|
239
|
+
// (resetClientState / prependOlderHistory), so it visibly stranded on-screen
|
|
240
|
+
// and was indistinguishable from the .thinking-item's own presence spinner —
|
|
241
|
+
// two indicators live at once (this task's SYMPTOM B).
|
|
242
|
+
//
|
|
243
|
+
// This subscriber makes the footer a DERIVED render of store.processing —
|
|
244
|
+
// which lr-5edd64 turned into a pure PROJECTION of server-authoritative
|
|
245
|
+
// per-session state (app-messages.js's session_list/session_switched
|
|
246
|
+
// handlers derive it via activity-state.js's sessionActivity(), nothing
|
|
247
|
+
// writes it independently anymore). Previously this boolean was a
|
|
248
|
+
// client-local edge latch (app-connection.js's setStatus(), flipped by the
|
|
249
|
+
// server's {type:"status"}/done/auth_required sends) with no reconciliation
|
|
250
|
+
// path — MILLER's lr-5edd64 diagnosis: two independent state sources
|
|
251
|
+
// (this latch, and the server's per-session session.isProcessing) could
|
|
252
|
+
// disagree, and neither renderer that read one could self-correct from the
|
|
253
|
+
// other. There is now exactly one source; this subscriber and the
|
|
254
|
+
// project-icon dot (sidebar-projects.js) both derive from it.
|
|
255
|
+
//
|
|
256
|
+
// Gated to bubble layout only (mirrors input.js's optimistic-raise gate and
|
|
257
|
+
// showClaudePreThinking's channel-only gate in app-rendering.js) — the two
|
|
258
|
+
// footer renderers are mutually exclusive by design (wide-view <=> channel,
|
|
259
|
+
// theme.js getChatLayout/setChatLayout), so this must not fight
|
|
260
|
+
// .channel-pre-thinking for the same bottom-of-transcript slot in channel
|
|
261
|
+
// layout. (lr-5edd64 comment #3: in channel layout this subscriber's raise/
|
|
262
|
+
// clear is inert by this same gate — the channel footer's own presence
|
|
263
|
+
// widget, .channel-pre-thinking, is driven separately and unaffected by
|
|
264
|
+
// this change.)
|
|
265
|
+
export function initActivityFooter() {
|
|
266
|
+
store.subscribe(['processing'], function (state, prev) {
|
|
267
|
+
if (state.processing === prev.processing) return;
|
|
268
|
+
reconcileActivityFooter();
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// lr-5edd64 (9th recurrence, PEACHES BLOCKING on PR #410 + HOLDEN trace):
|
|
273
|
+
// the footer's DOM ref (app-rendering.js's activityEl, via getActivityEl/
|
|
274
|
+
// setActivityEl) must not depend on a store.processing VALUE TRANSITION to
|
|
275
|
+
// get repaired. resetClientState() (app-projects.js) nulls the ref
|
|
276
|
+
// independently of any value change — a session switch where the outgoing
|
|
277
|
+
// AND incoming session are both isProcessing=true never fires the
|
|
278
|
+
// ['processing'] subscriber above (store.js's changed-flag bounding: the
|
|
279
|
+
// value is true before and after), so the widget could never be
|
|
280
|
+
// re-raised, leaving the footer stuck OFF for that session and every
|
|
281
|
+
// later broadcast carrying the same unchanged true value (identical
|
|
282
|
+
// mechanism, inverse edge, to the finding-1 stuck-OFF this same task
|
|
283
|
+
// already fixed once for false->true).
|
|
284
|
+
//
|
|
285
|
+
// FIX SHAPE (not another ordering tweak — see this task's dispatch note):
|
|
286
|
+
// this is an explicit, unconditional "render the footer from current
|
|
287
|
+
// store.processing now" call. Callers invoke it directly, right after
|
|
288
|
+
// applying a 'processing' projection (app-messages.js's session_list and
|
|
289
|
+
// session_switched handlers) — not gated on whether that store.set()
|
|
290
|
+
// actually changed the value. This is safe to call redundantly (setActivity
|
|
291
|
+
// itself no-ops when the DOM already matches the requested state via its
|
|
292
|
+
// own getActivityEl() presence check), and it does not touch
|
|
293
|
+
// lr-9bcd7b's changed-flag bounding on store.set()/the subscriber above,
|
|
294
|
+
// which still exists to suppress spurious re-renders on unrelated store
|
|
295
|
+
// updates that happen to carry the same 'processing' value along for the
|
|
296
|
+
// ride.
|
|
297
|
+
export function reconcileActivityFooter() {
|
|
298
|
+
if (getChatLayout() !== "channel") {
|
|
299
|
+
if (store.get('processing')) {
|
|
300
|
+
setActivity("thinking");
|
|
301
|
+
} else {
|
|
302
|
+
setActivity(null);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
@@ -11,6 +11,7 @@ import { openSchedulerToTab } from './scheduler.js';
|
|
|
11
11
|
// playbook imports removed (Quick Start section removed from hub)
|
|
12
12
|
import { exitDmMode } from './app-dm.js';
|
|
13
13
|
import { openCommandPalette } from './command-palette.js';
|
|
14
|
+
import { sessionActivity, indicatorClass } from './activity-state.js';
|
|
14
15
|
|
|
15
16
|
function $hub(id) { return document.getElementById(id); }
|
|
16
17
|
|
|
@@ -342,7 +343,10 @@ export function renderHomeHub(projects) {
|
|
|
342
343
|
item.className = "hub-project-item";
|
|
343
344
|
|
|
344
345
|
var dot = document.createElement("span");
|
|
345
|
-
|
|
346
|
+
// lr-66c118: project-level dot — isProcessing-only, no alert tone
|
|
347
|
+
// (the Projects-list unread badge owns that affordance).
|
|
348
|
+
var projActivityCls = indicatorClass(sessionActivity(proj, null, { ignoreUnread: true }));
|
|
349
|
+
dot.className = "hub-project-dot" + (projActivityCls ? " " + projActivityCls : "");
|
|
346
350
|
item.appendChild(dot);
|
|
347
351
|
|
|
348
352
|
if (proj.icon) {
|
|
@@ -469,12 +473,11 @@ export function handleHubRecentSessions(msg) {
|
|
|
469
473
|
var agentBadge = sess.agentName
|
|
470
474
|
? '<span class="hub-recent-agent">' + escapeHtml(sess.agentName) + '</span>'
|
|
471
475
|
: '';
|
|
472
|
-
// Single left status dot — color precedence LOCKED (andy, lr-0aa7b6)
|
|
473
|
-
//
|
|
474
|
-
//
|
|
475
|
-
//
|
|
476
|
-
//
|
|
477
|
-
// color state of the one left dot.
|
|
476
|
+
// Single left status dot — color precedence LOCKED (andy, lr-0aa7b6),
|
|
477
|
+
// now the CANONICAL derivation for every render surface via
|
|
478
|
+
// activity-state.js's sessionActivity/indicatorClass (lr-66c118): this
|
|
479
|
+
// was the only surface with a real precedence chain before, so it is
|
|
480
|
+
// promoted here rather than left a local special case.
|
|
478
481
|
//
|
|
479
482
|
// Alert state is keyed on THIS session's own unread count (sess.unread,
|
|
480
483
|
// populated server-side per-session — see hub_recent_sessions_list in
|
|
@@ -483,10 +486,10 @@ export function handleHubRecentSessions(msg) {
|
|
|
483
486
|
// project's session list even when only one of them is actually
|
|
484
487
|
// notifying — that was the bug lr-0aa7b6 required fixing, not just
|
|
485
488
|
// documenting.
|
|
486
|
-
var
|
|
487
|
-
var
|
|
488
|
-
|
|
489
|
-
var dotTitle =
|
|
489
|
+
var recentActivityState = sessionActivity(sess, store.get('myUserId'));
|
|
490
|
+
var recentActivityCls = indicatorClass(recentActivityState);
|
|
491
|
+
var dotClass = "hub-recent-dot" + (recentActivityCls ? " " + recentActivityCls : "");
|
|
492
|
+
var dotTitle = recentActivityState.label;
|
|
490
493
|
item.innerHTML =
|
|
491
494
|
'<span class="' + dotClass + '" title="' + dotTitle + '"></span>' +
|
|
492
495
|
iconHtml +
|
|
@@ -16,6 +16,27 @@ var pendingIterations = 20;
|
|
|
16
16
|
// ========================================================
|
|
17
17
|
// Init
|
|
18
18
|
// ========================================================
|
|
19
|
+
|
|
20
|
+
// lr-fd38ac follow-up: re-check the queue-mode gate whenever the fields it
|
|
21
|
+
// depends on change, not only when a handler happens to remember to call
|
|
22
|
+
// updateLoopInputVisibility() itself. loop_iteration/loop_judging
|
|
23
|
+
// (app-messages.js) write loopCurrentSessionId without re-invoking the
|
|
24
|
+
// gate — that used to leave loopQueueMode stale-false for a client already
|
|
25
|
+
// viewing the loop's own session (queued messages silently dropped instead
|
|
26
|
+
// of queued, the inverse of the original lr-fd38ac bug). See
|
|
27
|
+
// recheckLoopQueueModeFromState() for why this branch does not need the
|
|
28
|
+
// raw per-session `loop` object that updateLoopInputVisibility()'s direct
|
|
29
|
+
// callers (session_switched et al.) pass in.
|
|
30
|
+
//
|
|
31
|
+
// Split out from initLoopUi() so it can be installed on its own — the rest
|
|
32
|
+
// of initLoopUi() renders DOM (banners, buttons) that a unit test covering
|
|
33
|
+
// only this reactive gate has no reason to depend on.
|
|
34
|
+
export function initLoopQueueModeSync() {
|
|
35
|
+
store.subscribe(['loopActive', 'loopCurrentSessionId', 'activeSessionId'], function () {
|
|
36
|
+
recheckLoopQueueModeFromState();
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
19
40
|
export function initLoopUi() {
|
|
20
41
|
|
|
21
42
|
// --- Reactive UI sync for loop state ---
|
|
@@ -34,6 +55,8 @@ export function initLoopUi() {
|
|
|
34
55
|
}
|
|
35
56
|
});
|
|
36
57
|
|
|
58
|
+
initLoopQueueModeSync();
|
|
59
|
+
|
|
37
60
|
// --- Preview modal listeners ---
|
|
38
61
|
// Backdrop click intentionally does NOT close the modal (no way to reopen it)
|
|
39
62
|
|
|
@@ -156,6 +179,32 @@ function sendLoopStart() {
|
|
|
156
179
|
// Loop UI (exported)
|
|
157
180
|
// ========================================================
|
|
158
181
|
|
|
182
|
+
// lr-6fe5fc: single derivation of "should THIS session's composer present
|
|
183
|
+
// queue-mode UI", used by both call sites below. Takes the three server-
|
|
184
|
+
// pushed inputs directly (never a per-session `loop` object) — see the
|
|
185
|
+
// invariant note on recheckLoopQueueModeFromState() for why the per-session
|
|
186
|
+
// `loop.active`/`loop.role` fields the pre-lr-6fe5fc code additionally
|
|
187
|
+
// checked here are provably redundant with this three-input check and are
|
|
188
|
+
// no longer consulted: project-loop.js only ever sets loopCurrentSessionId
|
|
189
|
+
// to a session whose own loop.active is true and role is coder/judge, and
|
|
190
|
+
// finishLoop() atomically nulls loopCurrentSessionId in the same pass that
|
|
191
|
+
// clears every affected session's loop.active. So loopCurrentSessionId ===
|
|
192
|
+
// activeSessionId already implies everything the per-session object could
|
|
193
|
+
// have told us; carrying it as a second, separately-checked condition is
|
|
194
|
+
// exactly the shape of the bug this task is fixing (two things that are
|
|
195
|
+
// supposed to always agree, checked independently, able to drift).
|
|
196
|
+
//
|
|
197
|
+
// This is a client-side UX gate only — which WS message type the composer
|
|
198
|
+
// sends (`loop_message` vs `message`). It is not a permission check: the
|
|
199
|
+
// server's handleLoopMessage() gate independently and authoritatively
|
|
200
|
+
// decides whether to accept a queued `loop_message` off loopState.active,
|
|
201
|
+
// which is a coarser, correctly-project-scoped question (see that
|
|
202
|
+
// function's comment for why the two predicates are intentionally not the
|
|
203
|
+
// same one).
|
|
204
|
+
export function isLoopQueueSession(loopActive, loopCurrentSessionId, activeSessionId) {
|
|
205
|
+
return !!(loopActive && loopCurrentSessionId != null && loopCurrentSessionId === activeSessionId);
|
|
206
|
+
}
|
|
207
|
+
|
|
159
208
|
// lr-e31b: An active (non-crafting) loop iteration session used to hide the
|
|
160
209
|
// composer outright, leaving no way for a human to get a message into a
|
|
161
210
|
// running loop. Loop iterations are single-turn SDK sessions whose input
|
|
@@ -164,12 +213,30 @@ function sendLoopStart() {
|
|
|
164
213
|
// into the in-flight turn — it is queued and delivered at the next
|
|
165
214
|
// iteration boundary instead. The composer stays visible and enabled;
|
|
166
215
|
// input.js routes the send through `loop_message` while loopQueueMode is set.
|
|
216
|
+
//
|
|
217
|
+
// lr-fd38ac / lr-6fe5fc: the per-session `loop.active` marker (persisted on
|
|
218
|
+
// the session itself, see sessions.js:109/711) is not a reliable input to
|
|
219
|
+
// this gate — see isLoopQueueSession()'s comment for why the three
|
|
220
|
+
// server-pushed store values are sufficient on their own. The `loop`
|
|
221
|
+
// parameter is accepted for backward compatibility with callers that pass
|
|
222
|
+
// the per-session object from a WS message (session_switched et al.) but is
|
|
223
|
+
// intentionally unused in the derivation itself.
|
|
167
224
|
export function updateLoopInputVisibility(loop) {
|
|
168
225
|
var inputArea = document.getElementById("input-area");
|
|
169
226
|
if (!inputArea) return;
|
|
170
227
|
inputArea.style.display = "";
|
|
171
|
-
var
|
|
172
|
-
|
|
228
|
+
var s = store.snap();
|
|
229
|
+
var queueMode = isLoopQueueSession(s.loopActive, s.loopCurrentSessionId, s.activeSessionId);
|
|
230
|
+
applyLoopQueueMode(queueMode);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// lr-fd38ac follow-up: shared by updateLoopInputVisibility() (per-session
|
|
234
|
+
// `loop` object supplied by the caller — session_switched, loop_available,
|
|
235
|
+
// loop_finished) and recheckLoopQueueModeFromState() (no `loop` object
|
|
236
|
+
// available; see that function's comment for why store state alone is
|
|
237
|
+
// sufficient there). Applies the derived boolean to the store and syncs
|
|
238
|
+
// the composer placeholder.
|
|
239
|
+
function applyLoopQueueMode(queueMode) {
|
|
173
240
|
var inputEl = document.getElementById("input");
|
|
174
241
|
if (inputEl) {
|
|
175
242
|
if (queueMode) {
|
|
@@ -178,6 +245,23 @@ export function updateLoopInputVisibility(loop) {
|
|
|
178
245
|
inputEl.placeholder = "Message Claude Code...";
|
|
179
246
|
}
|
|
180
247
|
}
|
|
248
|
+
store.set({ loopQueueMode: queueMode });
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// lr-fd38ac follow-up / lr-6fe5fc: re-derive queue mode from store state
|
|
252
|
+
// alone, for the reactive subscriber in initLoopUi() — it fires on
|
|
253
|
+
// loopActive/loopCurrentSessionId/activeSessionId changes, none of which
|
|
254
|
+
// carry a per-session `loop` object the way session_switched's msg.loop
|
|
255
|
+
// does. Uses the same isLoopQueueSession() predicate as
|
|
256
|
+
// updateLoopInputVisibility() — see that function's comment for the
|
|
257
|
+
// server-side invariant that makes the three store values sufficient on
|
|
258
|
+
// their own, without a per-session `loop` object.
|
|
259
|
+
function recheckLoopQueueModeFromState() {
|
|
260
|
+
var inputArea = document.getElementById("input-area");
|
|
261
|
+
if (!inputArea) return;
|
|
262
|
+
var s = store.snap();
|
|
263
|
+
var queueMode = isLoopQueueSession(s.loopActive, s.loopCurrentSessionId, s.activeSessionId);
|
|
264
|
+
applyLoopQueueMode(queueMode);
|
|
181
265
|
}
|
|
182
266
|
|
|
183
267
|
export function updateLoopButton() {
|