@clagentic/console 1.9.0-beta.1 → 1.9.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.
Files changed (50) hide show
  1. package/bin/cli.js +12 -1
  2. package/lib/agents.js +13 -3
  3. package/lib/build-sha.json +2 -2
  4. package/lib/cli/ipc-subcommands.js +40 -4
  5. package/lib/daemon.js +25 -1
  6. package/lib/project-connection.js +15 -2
  7. package/lib/project-loop.js +46 -2
  8. package/lib/project-sessions.js +31 -3
  9. package/lib/project-user-message.js +70 -3
  10. package/lib/project.js +7 -1
  11. package/lib/public/app.js +14 -4
  12. package/lib/public/css/base.css +14 -0
  13. package/lib/public/css/home-hub.css +28 -8
  14. package/lib/public/css/icon-strip.css +17 -0
  15. package/lib/public/css/messages.css +11 -0
  16. package/lib/public/css/mobile-nav.css +22 -0
  17. package/lib/public/css/sidebar.css +15 -0
  18. package/lib/public/css/title-bar.css +10 -1
  19. package/lib/public/index.html +1 -0
  20. package/lib/public/modules/activity-latch.js +159 -0
  21. package/lib/public/modules/activity-state.js +157 -0
  22. package/lib/public/modules/app-connection.js +10 -4
  23. package/lib/public/modules/app-favicon.js +88 -1
  24. package/lib/public/modules/app-home-hub.js +14 -11
  25. package/lib/public/modules/app-loop-ui.js +86 -2
  26. package/lib/public/modules/app-messages.js +118 -54
  27. package/lib/public/modules/app-panels.js +91 -32
  28. package/lib/public/modules/app-projects.js +28 -8
  29. package/lib/public/modules/app-rate-limit.js +13 -1
  30. package/lib/public/modules/sidebar-mobile.js +32 -22
  31. package/lib/public/modules/sidebar-projects.js +42 -14
  32. package/lib/public/modules/sidebar-sessions.js +168 -48
  33. package/lib/public/modules/tools.js +11 -39
  34. package/lib/sdk-bridge.js +301 -22
  35. package/lib/sdk-message-processor.js +98 -15
  36. package/lib/sdk-skill-discovery.js +46 -6
  37. package/lib/sdk-slash-enrichment.js +5 -2
  38. package/lib/server-hub-sessions.js +70 -0
  39. package/lib/server.js +24 -22
  40. package/lib/session-activity.js +8 -1
  41. package/lib/sessions.js +47 -1
  42. package/lib/smtp.js +10 -1
  43. package/lib/ws-schema.js +16 -0
  44. package/lib/yoke/adapters/claude.js +7 -1
  45. package/lib/yoke/adapters/codex.js +219 -31
  46. package/package.json +2 -2
  47. package/scripts/check-test-count.js +397 -0
  48. package/scripts/test-file-completion-reporter.js +43 -0
  49. package/lib/model-context-windows.js +0 -74
  50. package/lib/public/modules/model-context-windows.js +0 -71
@@ -237,6 +237,23 @@
237
237
  background: var(--success);
238
238
  }
239
239
 
240
+ /* Multi-user tone (lr-66c118): ring shape (transparent center, colored
241
+ border) instead of a filled disc, plus a distinct violet hue — hue alone
242
+ is not sufficient to distinguish "another user active" from "I'm active"
243
+ at 10px under a red/green color-vision deficiency. */
244
+ .icon-strip-status.other {
245
+ opacity: 1;
246
+ background: transparent;
247
+ border-width: 2px;
248
+ border-color: var(--activity-other, #B77BF3);
249
+ }
250
+
251
+ /* Alert tone (lr-66c118): unread activity wins over processing green. */
252
+ .icon-strip-status.alert {
253
+ opacity: 1;
254
+ background: var(--danger, #e74c3c);
255
+ }
256
+
240
257
  /* IO blink = HDD LED flash */
241
258
  .icon-strip-status.io {
242
259
  opacity: 1;
@@ -632,6 +632,17 @@ pre.mermaid-error {
632
632
 
633
633
  .thinking-item.done .thinking-spinner { display: none; }
634
634
 
635
+ /* lr-6e20f7: bubble layout (body:not(.wide-view)) has its own
636
+ bottom-of-transcript presence indicator (.activity-inline, driven by
637
+ activity-state.js via app-favicon.js's initActivityFooter). The thinking
638
+ block owns DETAIL (the expandable content), not presence — showing this
639
+ spinner too duplicated the footer dots (this task's SYMPTOM B: one
640
+ indicator here, one at the bottom, simultaneously). Channel layout has no
641
+ such duplicate (its footer, .channel-pre-thinking, is always removed by
642
+ removePreThinking() before a real thinking block ever renders), so this
643
+ is scoped to bubble layout only. */
644
+ body:not(.wide-view) .thinking-spinner { display: none; }
645
+
635
646
  .thinking-content {
636
647
  display: none;
637
648
  padding: 8px 14px;
@@ -217,6 +217,17 @@
217
217
  flex-shrink: 0;
218
218
  }
219
219
 
220
+ /* Multi-user tone (lr-66c118): ring shape, distinct violet hue. */
221
+ .mobile-project-processing.other {
222
+ background: transparent;
223
+ border: 1.5px solid var(--activity-other, #B77BF3);
224
+ box-sizing: border-box;
225
+ }
226
+ /* Alert tone (lr-66c118): unread wins over processing green. */
227
+ .mobile-project-processing.alert {
228
+ background: var(--danger, #e74c3c);
229
+ }
230
+
220
231
  .mobile-project-unread {
221
232
  min-width: 18px;
222
233
  height: 18px;
@@ -865,6 +876,17 @@
865
876
  box-shadow: 0 0 4px var(--success);
866
877
  }
867
878
 
879
+ /* Multi-user tone (lr-66c118): ring shape, distinct violet hue. */
880
+ .mobile-session-processing.other {
881
+ background: transparent;
882
+ border: 1.5px solid var(--activity-other, #B77BF3);
883
+ box-sizing: border-box;
884
+ }
885
+ /* Alert tone (lr-66c118): unread wins over processing green. */
886
+ .mobile-session-processing.alert {
887
+ background: var(--danger, #e74c3c);
888
+ }
889
+
868
890
  /* Date group header inside sheet */
869
891
  .mobile-sheet-group {
870
892
  padding: 14px 12px 6px;
@@ -892,6 +892,21 @@
892
892
  box-shadow: 0 0 4px var(--success);
893
893
  }
894
894
 
895
+ /* Multi-user tone (lr-66c118): another user's activity — ring shape (not a
896
+ filled disc) plus a distinct violet hue, so hue alone never carries the
897
+ distinction at 6px. */
898
+ .session-item .session-processing.other,
899
+ .mate-session-item .session-processing.other {
900
+ background: transparent;
901
+ border: 1.5px solid var(--activity-other, #B77BF3);
902
+ box-sizing: border-box;
903
+ }
904
+ /* Alert tone (lr-66c118): unread activity wins over processing green. */
905
+ .session-item .session-processing.alert,
906
+ .mate-session-item .session-processing.alert {
907
+ background: var(--danger, #e74c3c);
908
+ }
909
+
895
910
  /* Session unread badge */
896
911
  .session-unread-badge {
897
912
  position: absolute;
@@ -580,6 +580,14 @@
580
580
  line-height: 1;
581
581
  }
582
582
 
583
+ /* lr-872f94: vendor-reported rate-limit usedPercent, shown in the pill
584
+ itself alongside the label (previously only in the transient popover). */
585
+ .header-pill-pct {
586
+ line-height: 1;
587
+ font-weight: 700;
588
+ opacity: 0.75;
589
+ }
590
+
583
591
  /* Rate limit wrapper for popover positioning */
584
592
  .header-rate-limit-wrap {
585
593
  position: relative;
@@ -666,7 +674,8 @@
666
674
 
667
675
  /* Hide pills on very narrow screens */
668
676
  @media (max-width: 400px) {
669
- .header-pill-text { display: none; }
677
+ .header-pill-text,
678
+ .header-pill-pct { display: none; }
670
679
  .header-rate-limit,
671
680
  .header-fast-mode { padding: 3px; }
672
681
  .rate-limit-popover { font-size: 11px; padding: 6px 10px; }
@@ -373,6 +373,7 @@
373
373
  <div class="usage-row"><span class="usage-label">Used</span><span id="context-used" class="usage-value">-</span></div>
374
374
  <div class="usage-row"><span class="usage-label">Window</span><span id="context-window" class="usage-value">-</span></div>
375
375
  <div class="usage-row"><span class="usage-label">Max output</span><span id="context-max-output" class="usage-value">-</span></div>
376
+ <div class="usage-row hidden"><span class="usage-label">Reasoning</span><span id="context-reasoning" class="usage-value">-</span></div>
376
377
  <div class="usage-divider"></div>
377
378
  <div class="usage-section-label">Model</div>
378
379
  <div class="usage-row"><span class="usage-label">Name</span><span id="context-model" class="usage-value">-</span></div>
@@ -0,0 +1,159 @@
1
+ // activity-latch.js - Pure decision logic for the client-local 'processing'
2
+ // activity-indicator latch.
3
+ //
4
+ // 'processing' (the field app-favicon.js's initActivityFooter subscribes
5
+ // to) is a client-local edge latch with no server reconciliation —
6
+ // app-messages.js's status/done/auth_required handlers wrote it
7
+ // unconditionally, with no knowledge of which session a message actually
8
+ // belongs to. A background session's status:"processing" could raise the
9
+ // FOCUSED session's latch with no done ever routed back to clear it
10
+ // (stuck-ON) — the inverse of the historical stuck-OFF symptom this
11
+ // codebase has previously fixed for the transcript footer.
12
+ //
13
+ // This module extracts the two DECISION functions those handlers need —
14
+ // "should this session-scoped edge apply to the currently-focused session?"
15
+ // and "when should the staleness backstop timer arm/fire/clear?" — as pure,
16
+ // DOM-free logic. app-messages.js and app-favicon.js are both DOM-heavy
17
+ // (app-favicon.js's import graph reaches theme.js <-> markdown.js, which
18
+ // has a circular-import ordering hazard around mermaid theme init that
19
+ // makes them unimportable in a plain Node test process without a much
20
+ // heavier harness than this repo carries — see the test file for this
21
+ // module's header comment). Carving the pure decision logic out here —
22
+ // mirroring how activity-state.js was carved out of the sidebar/hub render
23
+ // sites for the same reason — is what makes this fix's core logic
24
+ // behaviorally testable at all, rather than only provable by source-text
25
+ // inspection.
26
+
27
+ /**
28
+ * Should a session-scoped activity-latch edge (status:"processing",
29
+ * done, auth_required) be applied to the client's current local state?
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
+ }
46
+
47
+ // ---------------------------------------------------------------------------
48
+ // lr-58c813: accept/reject ledger — instrumentation only, no decision logic.
49
+ //
50
+ // MILLER (lr-96e7da) hypothesized cross-session crosstalk on this latch at
51
+ // 0.5 confidence and flagged it never instrumented to proof; the symptom
52
+ // recurred (lr-5edd64) in code that already has this guard. This ledger
53
+ // records what shouldApplyActivityEdge actually decided at runtime, at the
54
+ // three call sites in app-messages.js (status/done/auth_required), WITHOUT
55
+ // changing which branch any of them take — recordActivityEdgeDecision is
56
+ // called for its side effect (counting) only, after the real decision has
57
+ // already been made by shouldApplyActivityEdge, never in place of it.
58
+ //
59
+ // The fail-open branch (msgLocalId == null) is counted SEPARATELY per the
60
+ // task spec: it is a deliberate back-compat path, but a live send site that
61
+ // still fails to stamp localId would silently re-enable the pre-fix
62
+ // unguarded write through this exact branch, and no existing test would
63
+ // notice. A nonzero count here in production is the actionable signal.
64
+ //
65
+ // Bounded: this is a plain in-memory counter object, reset on page
66
+ // load/reload (no persistence, no growth — four integers total, no per-
67
+ // event array). It does not log to the console on every message (that would
68
+ // flood devtools on a chatty session); callers read the totals on demand via
69
+ // getActivityEdgeLedger(), e.g. from devtools or a future diagnostics-panel
70
+ // hook — never a per-event stream.
71
+
72
+ var _activityEdgeLedger = {
73
+ accepted: 0,
74
+ rejected: 0,
75
+ acceptedFailOpen: 0, // subset of `accepted`: msgLocalId == null specifically
76
+ };
77
+
78
+ /**
79
+ * Record the outcome of a shouldApplyActivityEdge call for the ledger.
80
+ * Pure bookkeeping — does not itself decide anything and must be called
81
+ * with the SAME inputs the real decision already used, after the fact.
82
+ *
83
+ * @param {string} msgType - "status" | "done" | "auth_required"
84
+ * @param {number|string|null|undefined} msgLocalId
85
+ * @param {number|string|null|undefined} activeSessionId
86
+ * @param {boolean} accepted - the shouldApplyActivityEdge result already computed by the caller
87
+ */
88
+ export function recordActivityEdgeDecision(msgType, msgLocalId, activeSessionId, accepted) {
89
+ if (accepted) {
90
+ _activityEdgeLedger.accepted++;
91
+ if (msgLocalId == null) _activityEdgeLedger.acceptedFailOpen++;
92
+ } else {
93
+ _activityEdgeLedger.rejected++;
94
+ }
95
+ }
96
+
97
+ /** Read-only snapshot of the ledger totals (does not reset). */
98
+ export function getActivityEdgeLedger() {
99
+ return {
100
+ accepted: _activityEdgeLedger.accepted,
101
+ rejected: _activityEdgeLedger.rejected,
102
+ acceptedFailOpen: _activityEdgeLedger.acceptedFailOpen,
103
+ };
104
+ }
105
+
106
+ /** Test-only reset so ledger tests don't leak counts across cases. */
107
+ export function _resetActivityEdgeLedgerForTest() {
108
+ _activityEdgeLedger = { accepted: 0, rejected: 0, acceptedFailOpen: 0 };
109
+ }
110
+
111
+ /**
112
+ * Staleness-backstop timer state machine. A single timer is
113
+ * armed on a genuine 0->1 'processing' transition and disarmed on every
114
+ * 1->0 transition — never a recurring poll, never more than one in-flight
115
+ * timer regardless of how many turns/sessions run. Kept here as pure state
116
+ * transitions (arm/clear/shouldFire) so the bound (one timer, one-shot,
117
+ * re-armed only by a fresh transition) is asserted directly rather than
118
+ * only described in a comment.
119
+ */
120
+ export function createActivityStaleBackstop(opts) {
121
+ var delayMs = (opts && opts.delayMs) || 5 * 60 * 1000; // mirrors sdk-bridge.js ACTIVITY_STALE_MS
122
+ var setTimeoutFn = (opts && opts.setTimeout) || setTimeout;
123
+ var clearTimeoutFn = (opts && opts.clearTimeout) || clearTimeout;
124
+ var onFire = (opts && opts.onFire) || function () {};
125
+ var timer = null;
126
+ var armCount = 0; // exposed for the "never polls / never stacks" test assertion
127
+
128
+ function clear() {
129
+ if (timer) {
130
+ clearTimeoutFn(timer);
131
+ timer = null;
132
+ }
133
+ }
134
+
135
+ function arm() {
136
+ clear(); // at most one in-flight timer, ever — re-arming replaces, never stacks
137
+ armCount++;
138
+ timer = setTimeoutFn(function () {
139
+ timer = null;
140
+ onFire();
141
+ }, delayMs);
142
+ }
143
+
144
+ /** Called on every store 'processing' transition (state !== prev only). */
145
+ function onTransition(nowProcessing) {
146
+ if (nowProcessing) {
147
+ arm();
148
+ } else {
149
+ clear();
150
+ }
151
+ }
152
+
153
+ return {
154
+ onTransition: onTransition,
155
+ isArmed: function () { return timer !== null; },
156
+ armCount: function () { return armCount; },
157
+ _clearForTest: clear,
158
+ };
159
+ }
@@ -0,0 +1,157 @@
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] - project-level dots (icon strip,
65
+ * mobile project rows, folder headers, home-hub project summary) have
66
+ * their OWN separate unread badge affordance and have never shown alert
67
+ * red on the dot itself — set true there so passing the raw project
68
+ * object (which does carry .unread, for the badge) doesn't also flip the
69
+ * dot to alert tone. Session-level dots never set this.
70
+ * @returns {ActivityState}
71
+ */
72
+ export function sessionActivity(sess, currentUserId, opts) {
73
+ if (!sess) {
74
+ return { active: false, alert: false, tone: "idle", label: "Idle" };
75
+ }
76
+
77
+ var alert = !(opts && opts.ignoreUnread) && (sess.unread || 0) > 0;
78
+ var active = !!sess.isProcessing;
79
+
80
+ if (alert) {
81
+ return { active: true, alert: true, tone: "alert", label: "Unread activity" };
82
+ }
83
+
84
+ if (!active) {
85
+ return { active: false, alert: false, tone: "idle", label: "Idle" };
86
+ }
87
+
88
+ var isOther = !!(sess.ownerId != null && currentUserId != null && sess.ownerId !== currentUserId);
89
+ return isOther
90
+ ? { active: true, alert: false, tone: "other", label: "Active (another user)" }
91
+ : { active: true, alert: false, tone: "self", label: "Active" };
92
+ }
93
+
94
+ // Precedence used by both sessionActivity's tone choice above and
95
+ // rollupActivity's OR-reduce below. Higher wins. 'self' outranks 'other'
96
+ // per the locked rollup rule; 'alert' outranks everything.
97
+ var TONE_RANK = { idle: 0, other: 1, self: 2, alert: 3 };
98
+
99
+ /**
100
+ * Roll up a list of already-derived (or raw session/project) items into a
101
+ * single ActivityState, replacing the 8 open-coded `anyProcessing` OR-loops
102
+ * this module supersedes.
103
+ *
104
+ * Accepts either raw session/project objects (in which case sessionActivity
105
+ * is applied per-item using the given currentUserId) or an array of
106
+ * ActivityState objects already produced by sessionActivity — the latter is
107
+ * useful when a caller has already computed per-item tone for other reasons
108
+ * and wants to fold the results without re-deriving.
109
+ *
110
+ * @param {Array<object|ActivityState>} list
111
+ * @param {string|number|null} [currentUserId]
112
+ * @param {object} [opts] - forwarded to sessionActivity() for each raw item;
113
+ * see its ignoreUnread doc. Ignored for items that are already derived
114
+ * ActivityState objects.
115
+ * @returns {ActivityState}
116
+ */
117
+ export function rollupActivity(list, currentUserId, opts) {
118
+ if (!list || list.length === 0) {
119
+ return { active: false, alert: false, tone: "idle", label: "Idle" };
120
+ }
121
+
122
+ var best = { active: false, alert: false, tone: "idle", label: "Idle" };
123
+ for (var i = 0; i < list.length; i++) {
124
+ var item = list[i];
125
+ var state = (item && typeof item.tone === "string" && typeof item.active === "boolean")
126
+ ? item
127
+ : sessionActivity(item, currentUserId, opts);
128
+ if (TONE_RANK[state.tone] > TONE_RANK[best.tone]) {
129
+ best = state;
130
+ }
131
+ }
132
+ return best;
133
+ }
134
+
135
+ // The 5 CSS class families this reconciles all key their "on" state off a
136
+ // bare ".processing" (or ".alert" for the home-hub dot) suffix appended to a
137
+ // per-surface base class. indicatorClass() returns ONLY that suffix (or ""
138
+ // for idle) — callers still own their own base class name, since the base
139
+ // classes themselves are not being unified (that would be a DOM/CSS
140
+ // restructure, out of scope for a derivation module) — only the STATE ->
141
+ // CLASS decision is centralized.
142
+ /**
143
+ * The one place a CSS class suffix is chosen from an ActivityState.
144
+ * @param {ActivityState} state
145
+ * @returns {string} "" | "processing" | "alert" | "other"
146
+ */
147
+ export function indicatorClass(state) {
148
+ if (!state || !state.active) return "";
149
+ if (state.tone === "alert") return "alert";
150
+ if (state.tone === "other") return "other";
151
+ // tone === "self": the reconciled state. home-hub.css's stale comment
152
+ // claimed 4 states (alert/processing/live/idle) but only ever shipped 3
153
+ // classes (.alert, .processing, bare/idle) — there is no separate "live"
154
+ // class anywhere in the codebase. "self" activity renders as ".processing"
155
+ // everywhere, matching what every surface already shipped.
156
+ return "processing";
157
+ }
@@ -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, setActivity } from './app-favicon.js';
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,18 @@ 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
+ // state.processing is this client's own live turn-in-flight signal —
80
+ // always tone 'self' — routed through the same derivation every other
81
+ // dot uses rather than writing '.processing' independently.
78
82
  if (state.connected !== prev.connected || state.processing !== prev.processing) {
79
83
  var dot = getStatusDot();
80
84
  if (dot) {
81
85
  dot.className = "icon-strip-status";
82
86
  if (state.connected) {
83
87
  dot.classList.add("connected");
84
- if (state.processing) dot.classList.add("processing");
88
+ var connActivityCls = indicatorClass(sessionActivity({ isProcessing: state.processing }));
89
+ if (connActivityCls) dot.classList.add(connActivityCls);
85
90
  }
86
91
  }
87
92
  }
@@ -331,7 +336,8 @@ function openSocket(ticket) {
331
336
  if (connectTimeoutId) { clearTimeout(connectTimeoutId); connectTimeoutId = null; }
332
337
  closeDmUserPicker();
333
338
  setStatus("disconnected");
334
- setActivity(null);
339
+ // lr-66c118: the setActivity(null) clear formerly here is gone —
340
+ // setActivity collapsed to one optimistic raise (input.js), no manual clears.
335
341
  // lr-0446: Discard any pending cross-project session switch. If the WS
336
342
  // closed before the target project's session_list fired, the key is now
337
343
  // stale — leaving it would cause the *next* successful session_list (on
@@ -4,8 +4,10 @@
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
+ import { getWs } from './ws-ref.js';
10
+ import { createActivityStaleBackstop } from './activity-latch.js';
9
11
 
10
12
  // --- Module-owned state ---
11
13
  var faviconLink, faviconOrigHref, faviconCanvas, faviconCtx, faviconImg, faviconImgReady;
@@ -230,3 +232,88 @@ export function setActivity(text) {
230
232
  }
231
233
  }
232
234
 
235
+ // lr-6e20f7: the reactive clear setActivity's own removal branch (above) was
236
+ // designed for but never wired up — lr-66c118 deleted all 15 manual clear
237
+ // call sites (including every clear of this widget) on the assumption that
238
+ // "the widget's own reactive clear" would replace them, but no such
239
+ // subscriber was ever added. The widget was raised once at input.js's
240
+ // optimistic call and then never cleared again short of a full DOM wipe
241
+ // (resetClientState / prependOlderHistory), so it visibly stranded on-screen
242
+ // and was indistinguishable from the .thinking-item's own presence spinner —
243
+ // two indicators live at once (this task's SYMPTOM B).
244
+ //
245
+ // This subscriber makes the footer a DERIVED render of the same boolean the
246
+ // bottom bar/icon-strip status dot already uses (store.processing —
247
+ // app-connection.js's setStatus(), flipped true by the server's
248
+ // {type:"status", status:"processing"} at turn-start and false at
249
+ // done/auth_required/disconnect). That boolean already covers "literally
250
+ // anything" for THIS client's own turn: Claude has turn-wide isProcessing
251
+ // coverage for ordinary tools (sdk-message-processor.js module header), and
252
+ // status:"processing" is sent once at turn-start and stays true for the
253
+ // whole turn including any backgrounded Task/subagent activity — it only
254
+ // flips false at genuine turn-end (done) or auth_required/disconnect, all of
255
+ // which are real "nothing is happening" states. Subscribing here — rather
256
+ // than re-deriving from scratch — reuses the exact boolean already proven
257
+ // correct for the icon-strip dot instead of inventing a second one that
258
+ // could disagree with it.
259
+ //
260
+ // Gated to bubble layout only (mirrors input.js's optimistic-raise gate and
261
+ // showClaudePreThinking's channel-only gate in app-rendering.js) — the two
262
+ // footer renderers are mutually exclusive by design (wide-view <=> channel,
263
+ // theme.js getChatLayout/setChatLayout), so this must not fight
264
+ // .channel-pre-thinking for the same bottom-of-transcript slot in channel
265
+ // layout.
266
+ // Client-side staleness backstop, mirroring sdk-bridge.js's server-side
267
+ // ACTIVITY_STALE_MS (5 min) sweep for the registry. That server sweep can
268
+ // never repair THIS client-local latch — it sweeps the (already-correct)
269
+ // server registry, not any client state. Session-scoping the status/done/
270
+ // auth_required writers and reconciling on every session_switched snapshot
271
+ // (both elsewhere in this fix) close the known trigger paths; this is the
272
+ // backstop for an edge this fix's authors did not anticipate — a single
273
+ // timer, armed only on the 0->1 transition and disarmed on every 1->0
274
+ // transition, so it never polls per-tick and never accumulates more than
275
+ // one in-flight timer regardless of how many turns a session runs. On
276
+ // fire, it re-sends the EXISTING switch_session request for the
277
+ // currently-focused session (same message every sidebar click already
278
+ // sends) rather than inventing a new wire message — the server always
279
+ // answers with a fresh session_switched carrying the authoritative
280
+ // isProcessing (lib/sessions.js switchSession), which the reconciliation in
281
+ // app-messages.js's session_switched handler then applies. Bound: at most
282
+ // one re-request per ACTIVITY_STALE_BACKSTOP_MS per session-focus-duration,
283
+ // never a recurring poll — the timer is one-shot and only re-arms on a
284
+ // fresh 0->1 transition (a genuinely new turn), not on a fixed interval.
285
+ // Decision logic (arm/clear/one-shot-never-stacks) lives in the pure,
286
+ // directly-unit-tested activity-latch.js module — see its header comment
287
+ // for why (app-favicon.js's own import graph is not importable in a plain
288
+ // Node test process, so the behavioral proof lives against the pure
289
+ // module instead of this DOM-driving glue).
290
+ var _activityStaleBackstop = createActivityStaleBackstop({
291
+ onFire: function () {
292
+ // Only re-request if the latch is STILL true when the timer fires —
293
+ // a legitimate long-running turn re-arms nothing extra here (the
294
+ // request is one-shot, not a recurring poll); if the turn already
295
+ // ended, the 1->0 transition already cleared this timer, so reaching
296
+ // this callback at all means 'processing' has been true, unbroken,
297
+ // for the full backstop window.
298
+ if (!store.get('processing')) return;
299
+ var sid = store.get('activeSessionId');
300
+ var ws = getWs();
301
+ if (sid == null || !ws || ws.readyState !== 1) return;
302
+ ws.send(JSON.stringify({ type: "switch_session", id: sid }));
303
+ },
304
+ });
305
+
306
+ export function initActivityFooter() {
307
+ store.subscribe(['processing'], function (state, prev) {
308
+ if (state.processing === prev.processing) return;
309
+ _activityStaleBackstop.onTransition(state.processing);
310
+ if (getChatLayout() !== "channel") {
311
+ if (state.processing) {
312
+ setActivity("thinking");
313
+ } else {
314
+ setActivity(null);
315
+ }
316
+ }
317
+ });
318
+ }
319
+
@@ -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
- dot.className = "hub-project-dot" + (proj.isProcessing ? " processing" : "");
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
- // alert(red) > processing(green, pulsing) > live(green) > idle(grey).
474
- // Alert wins over an active/processing session so the notification is
475
- // always visible. Previously alert rendered as a SEPARATE right-side dot
476
- // (.hub-recent-alert-dot); that's removed — alert is now just another
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 hasAlert = (sess.unread || 0) > 0;
487
- var dotClass = "hub-recent-dot" +
488
- (hasAlert ? " alert" : (sess.isProcessing ? " processing" : ""));
489
- var dotTitle = hasAlert ? "Unread activity" : (sess.isProcessing ? "Active" : "Idle");
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 +