shadok-ai 0.19.55 → 0.19.56

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 CHANGED
@@ -248,7 +248,12 @@ Enter to skip; you can add it later from the web UI).
248
248
  actually produced its **last message** (`set → actual`), read from the
249
249
  transcript. That last-message model is the only place the real model is
250
250
  observable: the *setting* is empty for "Claude Code's own default", so an agent
251
- on the default shows which model it resolved to only here. The
251
+ on the default shows which model it resolved to only this way. For a glance
252
+ without opening Stats, the agent's **⋯ menu header** shows the same
253
+ `set → actual (last message)` on its 🧠 line, together with the
254
+ **context-window gauge** (`📊 Context NN%` + a bar) — the gauge used to sit as a
255
+ thin line on the channel row and now lives in the menu, where there is room for
256
+ a number beside it. The
252
257
  figures are the **real** per-message counts the API reported (only the *cost* is
253
258
  notional), and they include the agent's **subagents** — the Task-tool children
254
259
  write their own transcripts, so a delegating agent's true total is mostly there;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shadok-ai",
3
- "version": "0.19.55",
3
+ "version": "0.19.56",
4
4
  "main": "dist/session.js",
5
5
  "scripts": {
6
6
  "test": "node --import tsx --test --test-timeout=120000 test/*.ts context/*/test/*.test.mjs",
package/public/index.html CHANGED
@@ -358,6 +358,17 @@
358
358
  display: block; margin-top: 3px; opacity: 0.8;
359
359
  white-space: normal; line-height: 1.45;
360
360
  }
361
+ /* The context-window gauge, moved off the tab into this header: a tiny inline
362
+ track after the "📊 Context NN%" label. Same colour thresholds as the old
363
+ tab bar (green → amber → red) so the meaning is unchanged. */
364
+ #tabMenu .tm-ctxbar {
365
+ display: inline-block; vertical-align: middle; margin-left: 4px;
366
+ width: 92px; height: 4px; border-radius: 2px; overflow: hidden;
367
+ background: var(--line);
368
+ }
369
+ #tabMenu .tm-ctxfill { display: block; height: 100%; width: 0%; background: var(--ok); }
370
+ #tabMenu .tm-ctxfill.warn { background: var(--amber); }
371
+ #tabMenu .tm-ctxfill.crit { background: var(--err); }
361
372
  /* Top banners sit ABOVE the header, not over it: they are flow items at the
362
373
  very top of the fixed flex chassis (inserted as body's first child), so they
363
374
  push the header and everything below down instead of overlapping it. A
@@ -585,25 +596,6 @@
585
596
  tab in JS (ageOpacity) — bright when fresh, nearly gone when old. The
586
597
  transition makes the 30s refresh a fade rather than a step. */
587
598
  .tab .lastat { font-size: 9px; color: var(--text); flex: none; line-height: 1.1; font-variant-numeric: tabular-nums; transition: opacity 0.6s ease; }
588
- .tab .ctxbar {
589
- position: absolute;
590
- left: 10px;
591
- right: 10px;
592
- bottom: 3px;
593
- height: 2px;
594
- background: transparent;
595
- border-radius: 1px;
596
- overflow: hidden;
597
- }
598
- .tab .ctxfill {
599
- display: block;
600
- height: 100%;
601
- width: 0%;
602
- background: var(--ok);
603
- transition: width 0.4s ease;
604
- }
605
- .tab .ctxfill.warn { background: var(--amber); }
606
- .tab .ctxfill.crit { background: var(--err); }
607
599
  .tab:hover { color: var(--text); background: var(--bg-inset); }
608
600
  /* Active (selected) tab. Deliberately WITHOUT a background: the background is
609
601
  reserved for the session's state (.working/.needs-answer/.unread), or a
@@ -626,12 +618,12 @@
626
618
  /* Boot: each row's "xxx ago" + % + bar ease in one after the other as the
627
619
  glance lands (paintGlance) — a quick cascade top to bottom instead of one
628
620
  late burst. --gi is the row's rank, capped so the tail never drags. */
629
- .tab.glance-in .tab-row2, .tab.glance-in .ctxbar {
621
+ .tab.glance-in .tab-row2 {
630
622
  animation: glance-in 0.28s ease-out both;
631
623
  animation-delay: calc(var(--gi, 0) * 35ms);
632
624
  }
633
625
  @keyframes glance-in { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: none; } }
634
- @media (prefers-reduced-motion: reduce) { .tab.glance-in .tab-row2, .tab.glance-in .ctxbar { animation: none; } }
626
+ @media (prefers-reduced-motion: reduce) { .tab.glance-in .tab-row2 { animation: none; } }
635
627
  .tab .name {
636
628
  flex: 1;
637
629
  min-width: 0;
@@ -3003,7 +2995,6 @@
3003
2995
  }
3004
2996
  .tab > .tav { grid-row: 1 / 3; }
3005
2997
  .tab-row1, .tab-row2 { grid-column: 2; min-width: 0; }
3006
- .tab .ctxbar { left: 50px; right: 8px; }
3007
2998
  .tab .lastat, .tab .ctxnum { font-size: 11px; color: var(--text-dim); }
3008
2999
  .tab.active { border-left: 0; border-radius: 6px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); background: var(--bg-raised); font-weight: 600; }
3009
3000
  :root:not([data-mode="light"]) .tab.active { background: var(--bg-inset); box-shadow: inset 0 0 0 1px var(--line); }
@@ -3355,7 +3346,7 @@
3355
3346
  .tab.room .tav > span:first-child, body.room-active #chanAvatar { font-size: 0; }
3356
3347
  .tab.room .tav::before, body.room-active #chanAvatar::before { content: "💬"; font-size: 15px; line-height: 1; }
3357
3348
  body.room-active #chanAvatar::before { font-size: 18px; }
3358
- .tab.room .tav .led, .tab.room .ctxbar, .tab.room .timer { display: none; }
3349
+ .tab.room .tav .led, .tab.room .timer { display: none; }
3359
3350
  .tab.room .name { font-style: italic; }
3360
3351
  .tab.room .kind { color: var(--text-dim); font-size: 11px; }
3361
3352
  /* A room's chat has none of an agent's machinery. */
@@ -5385,13 +5376,8 @@
5385
5376
  row2.className = "tab-row2";
5386
5377
  row2.append(lastAt, ctxNum);
5387
5378
  btn.append(avatar, row1, row2);
5388
- // Context-window usage: a thin progress bar at the bottom of the tab.
5389
- const ctxBar = document.createElement("div");
5390
- ctxBar.className = "ctxbar";
5391
- const ctxFill = document.createElement("span");
5392
- ctxFill.className = "ctxfill";
5393
- ctxBar.appendChild(ctxFill);
5394
- btn.appendChild(ctxBar);
5379
+ // Context-window usage no longer paints on the tab — it lives in the agent
5380
+ // menu now (tm-ctxbar), kept as `tab.contextPct` and read when the menu opens.
5395
5381
  const group = groupId != null && groups.find((g) => String(g.id) === String(groupId));
5396
5382
  (group ? group.bodyEl : ungroupedEl).appendChild(btn);
5397
5383
 
@@ -5417,7 +5403,7 @@
5417
5403
  updateState: null, // Claude Code update: "restart" (reload to apply) | "failed" (install then reload) | null
5418
5404
  staleReasons: [], // server-side "reload to apply" reasons: prompt/guardrails/skills/secrets changed, auth token expired, claude binary updated
5419
5405
  btnEl: btn, ledEl: led, nameEl: name, timerEl: timer,
5420
- ctxNumEl: ctxNum, ctxFillEl: ctxFill, muteEl: mute, cronEl: cron, tgEl: tg, shellsEl: shells, monitorsEl: monitors, updateEl: update, linkEl: link,
5406
+ ctxNumEl: ctxNum, muteEl: mute, cronEl: cron, tgEl: tg, shellsEl: shells, monitorsEl: monitors, updateEl: update, linkEl: link,
5421
5407
  mirror: false, // mirrored into Telegram? (the ✈️ on the tab)
5422
5408
  lastAtEl: lastAt,
5423
5409
  };
@@ -6018,6 +6004,20 @@
6018
6004
  tabMenuOpenedAt = Date.now();
6019
6005
  }
6020
6006
 
6007
+ // The resolved model of this agent's LAST message, as a display label — read
6008
+ // from the same /channels/stats the Stats panel uses (the resolved name only
6009
+ // lives in the transcript). "" when nothing has been answered yet or on any
6010
+ // error, so the caller just keeps the setting-only line.
6011
+ async function lastRunModel(tab) {
6012
+ if (!tab.sessionId) return "";
6013
+ try {
6014
+ const r = await fetch("/channels/stats?id=" + encodeURIComponent(tab.sessionId));
6015
+ if (!r.ok) return "";
6016
+ const data = await r.json();
6017
+ return resolvedModelLabel(data.lastModel);
6018
+ } catch { return ""; }
6019
+ }
6020
+
6021
6021
  function openTabMenu(tab, x, y) {
6022
6022
  tabMenu.replaceChildren();
6023
6023
  if (tab.roomId) return openRoomMenu(tab, x, y);
@@ -6038,11 +6038,36 @@
6038
6038
  head.appendChild(pend);
6039
6039
  }
6040
6040
  // The model this agent runs on — the thing the user asked to be able to see.
6041
+ // The SETTING is known synchronously (the --model arg, "profile default"
6042
+ // when unset); the model that actually produced the LAST message — the only
6043
+ // observable "real" model — needs the transcript, so we fetch it and upgrade
6044
+ // the line to "set → actual (last message)" in place (the same datum the
6045
+ // Stats panel shows, surfaced here so it is one click closer).
6041
6046
  if (tab.sessionId) {
6042
6047
  const ms = document.createElement("span");
6043
6048
  ms.className = "tm-sub";
6044
- ms.textContent = "🧠 " + modelLabel(tab.model);
6049
+ const setLabel = modelLabel(tab.model);
6050
+ ms.textContent = "🧠 " + setLabel;
6045
6051
  head.appendChild(ms);
6052
+ lastRunModel(tab).then((ran) => {
6053
+ // Bail if the menu was torn down (replaceChildren) before the answer.
6054
+ if (ran && ms.isConnected) ms.textContent = "🧠 " + setLabel + " → " + ran + " (last message)";
6055
+ });
6056
+ }
6057
+ // The context-window gauge, moved here off the tab: "📊 Context NN%" + a tiny
6058
+ // track. Snapshot of `tab.contextPct` at open (the menu is short-lived).
6059
+ if (tab.sessionId && tab.contextPct != null) {
6060
+ const p = tab.contextPct;
6061
+ const cx = document.createElement("span");
6062
+ cx.className = "tm-sub";
6063
+ const bar = document.createElement("span");
6064
+ bar.className = "tm-ctxbar";
6065
+ const fill = document.createElement("span");
6066
+ fill.className = "tm-ctxfill" + (p >= 85 ? " crit" : p >= 60 ? " warn" : "");
6067
+ fill.style.width = Math.min(100, p) + "%";
6068
+ bar.appendChild(fill);
6069
+ cx.append("📊 Context " + p + "%", bar);
6070
+ head.appendChild(cx);
6046
6071
  }
6047
6072
  if (tab.crons && tab.crons.length) {
6048
6073
  const sub = document.createElement("span");
@@ -8487,20 +8512,6 @@
8487
8512
  screenEl.textContent = t.screenText;
8488
8513
  }
8489
8514
 
8490
- /** Paints a channel's context-window usage bar + tiny number in its tab. */
8491
- function renderContext(tab) {
8492
- const p = tab.contextPct;
8493
- if (p == null) {
8494
- tab.ctxNumEl.textContent = "";
8495
- tab.ctxFillEl.style.width = "0%";
8496
- return;
8497
- }
8498
- tab.ctxNumEl.textContent = p + "%";
8499
- tab.ctxFillEl.style.width = Math.min(100, p) + "%";
8500
- tab.ctxFillEl.classList.toggle("warn", p >= 60 && p < 85);
8501
- tab.ctxFillEl.classList.toggle("crit", p >= 85);
8502
- }
8503
-
8504
8515
  // Re-pins the view to the bottom ONLY when the user is already there (a flag
8505
8516
  // driven by their own scrolls). Otherwise we leave their position alone — no
8506
8517
  // more scroll flying around while the live text fills in.
@@ -8645,7 +8656,6 @@
8645
8656
  }
8646
8657
  if (t.contextPct == null && Number.isFinite(g.contextPct)) {
8647
8658
  t.contextPct = g.contextPct;
8648
- renderContext(t);
8649
8659
  painted = true;
8650
8660
  }
8651
8661
  // Only rows on screen take a rank: a hidden group's rows must not push
@@ -11067,7 +11077,6 @@
11067
11077
  break;
11068
11078
  case "context":
11069
11079
  t.contextPct = msg.pct;
11070
- renderContext(t);
11071
11080
  break;
11072
11081
  case "prompt-id":
11073
11082
  // The transcript now holds a prompt this tab showed early: give the