shadok-ai 0.19.78 → 0.19.80

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
@@ -573,7 +573,8 @@ Enter to skip; you can add it later from the web UI).
573
573
  own bar and, when the keyboard opens, sits right above it (the instrument bar
574
574
  folds away while you type). Fields are 16px, which is what stops Safari from
575
575
  zooming in on focus. The agents column is replaced by a channel selector in
576
- the channel bar.
576
+ the channel bar. The composer keeps one row: **+** (attach a file, add a
577
+ skill) · the field · the mic · **↑** to send.
577
578
  - **Tweak Shadok-AI** — a card pinned at the bottom of the agents column, with the running version in grey beside its title (the code a tweak starts from). One
578
579
  click clones shadok-ai's own source into `~/.shadok-ai/self/shadok-ai` and
579
580
  starts an agent on it in its own worktree; that agent delivers its change as a
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shadok-ai",
3
- "version": "0.19.78",
3
+ "version": "0.19.80",
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",
@@ -0,0 +1,62 @@
1
+ // Pure core of the phone header overflow: when a bar row does not fit, its
2
+ // icons go to that bar's ⋯ menu, one at a time, in a fixed order, until it fits.
3
+ // The DOM glue (measuring, moving) lives in index.html; this file only decides,
4
+ // so it is tested without a browser.
5
+
6
+ /**
7
+ * Show every item, then hide them one by one, in `items` order, until `fits()`
8
+ * says the row fits (or nothing is left to hide). Returns how many were hidden.
9
+ * Starting from "all shown" every time is what makes it reversible: a wider
10
+ * screen, a shorter agent name or a badge going away brings the icons back.
11
+ */
12
+ export function shrinkToFit(items, { show, hide, fits }) {
13
+ for (const it of items) show(it);
14
+ let hidden = 0;
15
+ for (const it of items) {
16
+ if (fits()) break;
17
+ hide(it);
18
+ hidden++;
19
+ }
20
+ return hidden;
21
+ }
22
+
23
+ /**
24
+ * Does a name that may ellipsize still read? It does when it is not cut at all,
25
+ * or when it keeps at least `minPx` on screen (a long name cut after a dozen
26
+ * letters is fine; "ca…" is not).
27
+ */
28
+ export function nameReads({ clientWidth, scrollWidth }, minPx) {
29
+ return scrollWidth <= clientWidth || clientWidth >= minPx;
30
+ }
31
+
32
+ /**
33
+ * The agent bar's icons, in the order they leave the row: least used first,
34
+ * the chat/terminal switch last. Schedule and Webhooks are already items of the
35
+ * agent menu, so hiding them needs no extra entry (`menu: null`).
36
+ */
37
+ export const CHAN_OVERFLOW = [
38
+ { id: "chanWebhooks", menu: null },
39
+ { id: "chanGallery", menu: "🖼 Media gallery" },
40
+ { id: "chanCron", menu: null },
41
+ { id: "chanInfo", menu: "ℹ About this agent" },
42
+ { id: "chanTerm", menu: "⌨ Terminal", menuOn: "💬 Back to the chat" },
43
+ ];
44
+
45
+ /** The agent bar's overflowable icon ids, in the order they leave the row. */
46
+ export function chanOverflowIds() {
47
+ return CHAN_OVERFLOW.map((it) => it.id);
48
+ }
49
+
50
+ /**
51
+ * The entries the agent menu gains for the icons hidden from the bar, in the
52
+ * order they left it. `hidden` is the set of hidden ids, `on` the set of toggles currently
53
+ * pressed (the terminal view).
54
+ */
55
+ export function chanOverflowItems(hidden, on = new Set()) {
56
+ const out = [];
57
+ for (const it of CHAN_OVERFLOW) {
58
+ if (!it.menu || !hidden.has(it.id)) continue;
59
+ out.push({ id: it.id, label: on.has(it.id) && it.menuOn ? it.menuOn : it.menu });
60
+ }
61
+ return out;
62
+ }
package/public/index.html CHANGED
@@ -538,6 +538,16 @@
538
538
  Hidden entirely when nothing overflowed. */
539
539
  .mm-tools { display: flex; flex-wrap: wrap; gap: 4px; padding-bottom: 4px; margin-bottom: 2px; border-bottom: 1px solid var(--line); }
540
540
  .mm-tools:empty { display: none; }
541
+ /* An agent-bar icon with no room on a phone: it lives in the agent ⋯ menu
542
+ instead (reflowChanBar, bar-overflow.js). */
543
+ #chanBar .chan-actions .bar-ovf { display: none !important; }
544
+ /* A badge-carrying header icon (Security, Reports) pushed into ⋯ for lack of
545
+ room: its badge must still be seen, so ⋯ wears a dot. */
546
+ .more-wrap:has(#overflowTools .sec-badge:not([hidden])) #moreBtn { position: relative; }
547
+ .more-wrap:has(#overflowTools .sec-badge:not([hidden])) #moreBtn::after {
548
+ content: ""; position: absolute; top: 3px; right: 3px; width: 7px; height: 7px;
549
+ border-radius: 50%; background: var(--err);
550
+ }
541
551
  #moreMenu .mm-tools button { width: auto; } /* override #moreMenu button width:100% */
542
552
  #moreMenu .mm-sep { height: 1px; background: var(--line); margin: 4px 2px; }
543
553
  #moreMenu .mm-label { padding: 2px 4px; font-size: 12px; font-weight: 500; color: var(--text-dim); }
@@ -2072,6 +2082,10 @@
2072
2082
  #chanBar #dirGauge, #chanBar #branchGauge { display: none !important; }
2073
2083
  #chanBar .gauge .label { display: none; } /* values only, more compact */
2074
2084
  #chanBar { gap: 6px; padding: 6px 10px; }
2085
+ /* The status word ("idle", "working") never yields to the name: squeezed, it
2086
+ read as a bare "…". The agent's name is the elastic item, and when it gets
2087
+ too short reflowChanBar moves icons into the ⋯ menu instead. */
2088
+ #chanBar .gauge:has(#state) { flex-shrink: 0; }
2075
2089
  /* One header row: brand + dials + ⋯. reflowHeaderTools (JS) moves ALL tool
2076
2090
  icons into the ⋯ menu, and `nowrap` makes the brand — the one elastic item
2077
2091
  — ABSORB the squeeze instead of shoving a dial onto a second line. Before
@@ -3336,14 +3350,39 @@
3336
3350
  the rail, the agents column and the engine room, so a wide window can still
3337
3351
  hold a narrow composer. */
3338
3352
  #composer { container: composer / inline-size; }
3353
+ /* The "+" and its menu exist only for the narrow composer below. */
3354
+ #cmpPlus, .cmp-plus-menu { display: none; }
3355
+ #sendBtn .send-ico { display: none; }
3339
3356
  @container composer (max-width: 560px) {
3357
+ /* ONE row on a phone: + · field · mic · ↑. It used to be two (the field on
3358
+ its own row, five buttons beneath), which spent a whole extra row of a
3359
+ small screen on buttons. Folding the paperclip and the skill button behind
3360
+ "+" and reducing Send to an arrow leaves the field ~220px at 390px — the
3361
+ old one-row layout had ~110px, which is why it was split. */
3362
+ #composer { gap: 6px; align-items: flex-end; }
3340
3363
  #composer .cmp-mic-msg { order: -3; }
3341
3364
  #composer .cmp-atts { order: -2; }
3342
- #composer textarea { order: -1; flex-basis: 100%; }
3343
- #composer .cmp-mic { margin-left: auto; }
3344
- #composer .cmp-attach, #composer .cmp-mic, #composer #sendBtn { height: 38px; }
3345
- #composer .cmp-attach { width: 38px; }
3365
+ #composer #attachBtn, #composer #skillBtn { display: none; }
3366
+ #composer #cmpPlus { display: inline-flex; }
3367
+ #composer .cmp-plus-menu:not([hidden]) { display: flex; }
3368
+ #composer .cmp-attach, #composer .cmp-mic, #composer #sendBtn { height: 42px; }
3369
+ #composer .cmp-attach { width: 42px; }
3370
+ #composer .cmp-mic { border-radius: 21px; } /* round like + and ↑; a pill while the timer shows */
3371
+ #composer #sendBtn { width: 42px; min-width: 42px; padding: 0; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; align-self: flex-end; }
3372
+ #composer #sendBtn .send-txt { display: none; }
3373
+ #composer #sendBtn .send-ico { display: block; }
3374
+ }
3375
+ .cmp-plus-menu {
3376
+ position: absolute; left: 12px; bottom: 100%; z-index: 30; margin-bottom: 6px;
3377
+ flex-direction: column; gap: 2px; padding: 4px; min-width: 190px;
3378
+ background: var(--bg-raised); border-radius: 14px;
3379
+ box-shadow: 0 22px 50px -18px rgba(0, 0, 0, .6), 0 0 0 1px var(--line);
3346
3380
  }
3381
+ .cmp-plus-menu button { text-align: left; border: 0; background: transparent; color: var(--text); padding: 10px 12px; border-radius: 10px; font: inherit; font-size: 15px; }
3382
+ .cmp-plus-menu button:hover:not(:disabled) { background: var(--amber-soft); }
3383
+ .cmp-plus-menu button:disabled { opacity: 0.45; }
3384
+ /* A room has no skills: the skill button is hidden there, so is its twin. */
3385
+ body.room-active #cmpPlusSkill { display: none; }
3347
3386
 
3348
3387
  /* Floating menus: lifted, not outlined. */
3349
3388
  #moreMenu, #tabMenu, #verMenu, .slash-menu {
@@ -4554,6 +4593,16 @@
4554
4593
  <div id="composerAtts" class="cmp-atts" hidden></div>
4555
4594
  <!-- Transient status for the dictate button (permission, nothing heard…). -->
4556
4595
  <div id="micMsg" class="cmp-mic-msg" role="status" aria-live="polite" hidden></div>
4596
+ <!-- A narrow composer (a phone) keeps ONE row: the paperclip and the skill
4597
+ button fold behind this "+", which opens a two-item menu that clicks
4598
+ the real buttons (so their handlers and disabled state still apply). -->
4599
+ <button type="button" id="cmpPlus" class="cmp-attach" title="Attach a file or add a skill" aria-label="More" aria-haspopup="true" aria-expanded="false">
4600
+ <svg viewBox="0 0 24 24" width="18" height="18" aria-hidden="true"><path d="M12 5v14M5 12h14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>
4601
+ </button>
4602
+ <div id="cmpPlusMenu" class="cmp-plus-menu" role="menu" hidden>
4603
+ <button type="button" role="menuitem" data-for="attachBtn">📎 Attach a file</button>
4604
+ <button type="button" role="menuitem" data-for="skillBtn" id="cmpPlusSkill">✨ Add a skill</button>
4605
+ </div>
4557
4606
  <!-- Pick a file to send: the same path as a paste or a drop (attachFile). -->
4558
4607
  <button type="button" id="attachBtn" class="cmp-attach" title="Attach a file" aria-label="Attach a file">
4559
4608
  <svg viewBox="0 0 24 24" width="18" height="18" aria-hidden="true"><path d="M21 11.5l-8.6 8.6a5.5 5.5 0 0 1-7.8-7.8l8.6-8.6a3.7 3.7 0 0 1 5.2 5.2l-8.6 8.6a1.8 1.8 0 0 1-2.6-2.6l7.9-7.9" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg>
@@ -4574,7 +4623,7 @@
4574
4623
  <svg class="mic-rec" viewBox="0 0 24 24" width="15" height="15" aria-hidden="true"><rect x="6" y="6" width="12" height="12" rx="2" fill="currentColor"/></svg>
4575
4624
  <span class="mic-time" aria-hidden="true"></span>
4576
4625
  </button>
4577
- <button type="submit" class="primary" id="sendBtn">Send</button>
4626
+ <button type="submit" class="primary" id="sendBtn" aria-label="Send"><span class="send-txt">Send</span><svg class="send-ico" viewBox="0 0 24 24" width="18" height="18" aria-hidden="true"><path d="M12 19V5M6 11l6-6 6 6" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"/></svg></button>
4578
4627
  </form>
4579
4628
 
4580
4629
  <!-- Interactive terminal, per channel, filling the main area (toggled by ⌨️
@@ -4698,6 +4747,7 @@
4698
4747
  applyReadonlyPreset, isManagedProfile, profileSaveBody, secretUsers, secretDeleteConfirmText } from "/profile-card.js?v=__ASSET_V__";
4699
4748
  import { secretsPanelMode, secretSections, keyGroups, shareTargets, auditLine, panelGroupOptions, publicWriteTarget, secretChipPick, secretReceivers, plusReloadPlan } from "/secrets-panel.js?v=__ASSET_V__";
4700
4749
  import { notifyState, BLINK_MS } from "/notify.js?v=__ASSET_V__";
4750
+ import { shrinkToFit, nameReads, chanOverflowIds, chanOverflowItems } from "/bar-overflow.js?v=__ASSET_V__";
4701
4751
  import { echoAuthor, isOwnPrompt } from "/echo-author.js?v=__ASSET_V__";
4702
4752
  import { dialPos, dialColor, dialTitle } from "/gauge-dial.js?v=__ASSET_V__";
4703
4753
  import { TOUR_STEPS, bubblePlacement, unionRect, visibleSteps } from "/tour-steps.js?v=__ASSET_V__";
@@ -4800,6 +4850,12 @@
4800
4850
  window.defaultAgentName = defaultAgentName;
4801
4851
  window.secretUsers = secretUsers;
4802
4852
  window.secretDeleteConfirmText = secretDeleteConfirmText;
4853
+ window.shrinkToFit = shrinkToFit;
4854
+ window.nameReads = nameReads;
4855
+ window.chanOverflowIds = chanOverflowIds;
4856
+ window.chanOverflowItems = chanOverflowItems;
4857
+ // The module is deferred: the first reflow ran on the stubs, so run it again.
4858
+ window.scheduleBarReflow?.();
4803
4859
  window.secretsPanelMode = secretsPanelMode;
4804
4860
  window.secretSections = secretSections;
4805
4861
  window.panelGroupOptions = panelGroupOptions;
@@ -4960,6 +5016,11 @@
4960
5016
  profileSaveBody: (form) => ({ ...form }),
4961
5017
  secretUsers: () => [],
4962
5018
  secretDeleteConfirmText: (name) => "Remove the secret " + name + " from the vault?",
5019
+ // Before the module lands: hide nothing, report "fits" — the bars keep their icons.
5020
+ shrinkToFit: () => 0,
5021
+ nameReads: () => true,
5022
+ chanOverflowIds: () => [],
5023
+ chanOverflowItems: () => [],
4963
5024
  // Before the module lands: the flat list (today's look) and no groups.
4964
5025
  secretsPanelMode: () => "flat",
4965
5026
  secretSections: () => ({ own: [], sharedIn: [], inheritedMain: [] }),
@@ -6178,7 +6239,7 @@
6178
6239
  } catch { return ""; }
6179
6240
  }
6180
6241
 
6181
- function openTabMenu(tab, x, y) {
6242
+ function openTabMenu(tab, x, y, extra = []) {
6182
6243
  tabMenu.replaceChildren();
6183
6244
  if (tab.roomId) return openRoomMenu(tab, x, y);
6184
6245
  // Header: WHO this agent is. The profile is what qualifies it (role,
@@ -6237,6 +6298,7 @@
6237
6298
  }
6238
6299
  tabMenu.appendChild(head);
6239
6300
  const items = [
6301
+ ...extra,
6240
6302
  [tab.muted ? "🔔 Unmute notifications" : "🔕 Mute notifications",
6241
6303
  () => setMuted(tab, !tab.muted)],
6242
6304
  ["↻ Reload agent", () => reloadTab(tab)],
@@ -12749,6 +12811,27 @@
12749
12811
  composer.requestSubmit();
12750
12812
  }
12751
12813
  });
12814
+ // The phone "+": opens Attach / Add a skill, each clicking the real button.
12815
+ // Disabled mirrors the real button at open time (no agent, upload running…).
12816
+ {
12817
+ const plus = $("cmpPlus"), menu = $("cmpPlusMenu");
12818
+ const close = () => { menu.hidden = true; plus.setAttribute("aria-expanded", "false"); };
12819
+ plus.addEventListener("click", (e) => {
12820
+ e.stopPropagation();
12821
+ if (!menu.hidden) return close();
12822
+ for (const b of menu.querySelectorAll("button[data-for]")) b.disabled = !!$(b.dataset.for)?.disabled;
12823
+ menu.hidden = false;
12824
+ plus.setAttribute("aria-expanded", "true");
12825
+ });
12826
+ menu.addEventListener("click", (e) => {
12827
+ const b = e.target.closest("button[data-for]");
12828
+ if (!b || b.disabled) return;
12829
+ e.stopPropagation(); // the skill menu opens on this click: don't let the document close it
12830
+ close();
12831
+ $(b.dataset.for)?.click();
12832
+ });
12833
+ document.addEventListener("click", (e) => { if (!menu.hidden && !menu.contains(e.target)) close(); });
12834
+ }
12752
12835
  function autosizePrompt() {
12753
12836
  promptInput.style.height = "auto";
12754
12837
  promptInput.style.height = Math.min(promptInput.scrollHeight, 160) + "px";
@@ -12919,7 +13002,12 @@
12919
13002
  e.stopPropagation();
12920
13003
  if (!active) return;
12921
13004
  const r = e.currentTarget.getBoundingClientRect();
12922
- openTabMenu(active, r.right, r.bottom + 4);
13005
+ // The bar icons hidden for lack of room come back as menu entries, at the
13006
+ // top (bar-overflow.js): clicking one clicks the real button.
13007
+ const hidden = new Set(window.chanOverflowIds().filter((id) => $(id)?.classList.contains("bar-ovf")));
13008
+ const on = new Set(window.chanOverflowIds().filter((id) => $(id)?.classList.contains("on")));
13009
+ const extra = window.chanOverflowItems(hidden, on).map((it) => [it.label, () => $(it.id).click()]);
13010
+ openTabMenu(active, r.right, r.bottom + 4, extra);
12923
13011
  });
12924
13012
 
12925
13013
  // "⋯" overflow menu (rarely-used actions, e.g. Diff). stopPropagation on the
@@ -12964,15 +13052,74 @@
12964
13052
  if (el) overflow.appendChild(el);
12965
13053
  }
12966
13054
  }
13055
+ // Then, on a phone, the icons that stay on the row (Security, Reports, Users
13056
+ // — kept for their badge) still leave it when the row does not fit: the
13057
+ // instance name is the one elastic item, and it was squeezed to nothing.
13058
+ // Moved in this order; a badge on a moved one shows as a dot on ⋯ (CSS).
13059
+ const SQUEEZE_TOOLS = ["usersBtn", "reportsBtn", "securityBtn"];
13060
+ const NAME_MIN_PX = 64;
13061
+ // The agent's name is what tells two agents apart: it gets more room.
13062
+ const AGENT_NAME_MIN_PX = 120;
13063
+ function reflowHeaderSqueeze() {
13064
+ const hdrTools = document.querySelector(".hdr-tools");
13065
+ const moreWrap = document.querySelector(".more-wrap");
13066
+ const overflow = $("overflowTools");
13067
+ if (!hdrTools || !moreWrap || !overflow) return;
13068
+ const back = (id) => { const el = $(id); if (el) hdrTools.insertBefore(el, moreWrap); };
13069
+ if (!matchMedia("(max-width: 640px)").matches) {
13070
+ // Desktop: back in the header, in their original order.
13071
+ for (const id of [...SQUEEZE_TOOLS].reverse()) back(id);
13072
+ return;
13073
+ }
13074
+ const name = $("brandName");
13075
+ window.shrinkToFit([...SQUEEZE_TOOLS], {
13076
+ show: back,
13077
+ hide: (id) => { const el = $(id); if (el) overflow.prepend(el); },
13078
+ fits: () => !name || window.nameReads(name, NAME_MIN_PX),
13079
+ });
13080
+ }
13081
+ // The agent bar: same rule, the agent's name in the picker is what must stay
13082
+ // readable. Hidden icons get `.bar-ovf` (display: none) and reappear as items
13083
+ // of the agent ⋯ menu — they are not moved, so their own state (`.on`) stays.
13084
+ function reflowChanBar() {
13085
+ const items = window.chanOverflowIds();
13086
+ const name = $("pickerName");
13087
+ const mobile = matchMedia("(max-width: 640px)").matches;
13088
+ window.shrinkToFit(items, {
13089
+ show: (id) => $(id)?.classList.remove("bar-ovf"),
13090
+ hide: (id) => $(id)?.classList.add("bar-ovf"),
13091
+ fits: () => !mobile || !name || $("chanBar").hidden || window.nameReads(name, AGENT_NAME_MIN_PX),
13092
+ });
13093
+ }
12967
13094
  let reflowPending = false;
12968
13095
  function scheduleReflow() {
12969
13096
  if (reflowPending) return;
12970
13097
  reflowPending = true;
12971
- requestAnimationFrame(() => { reflowPending = false; reflowHeaderTools(); });
13098
+ requestAnimationFrame(() => {
13099
+ reflowPending = false;
13100
+ reflowHeaderTools();
13101
+ reflowHeaderSqueeze();
13102
+ reflowChanBar();
13103
+ });
12972
13104
  }
13105
+ window.scheduleBarReflow = scheduleReflow;
12973
13106
  window.addEventListener("resize", scheduleReflow);
12974
- document.addEventListener("DOMContentLoaded", reflowHeaderTools);
13107
+ document.addEventListener("DOMContentLoaded", scheduleReflow);
12975
13108
  reflowHeaderTools();
13109
+ // What changes the room without resizing the window: the agent switched or
13110
+ // renamed, the cockpit renamed, a badge-carrying icon shown or hidden, the bar
13111
+ // itself shown. Our own moves touch none of these, so this cannot loop.
13112
+ {
13113
+ const mo = new MutationObserver(scheduleReflow);
13114
+ for (const id of ["pickerName", "brandName", "verView", "state"]) {
13115
+ const el = $(id);
13116
+ if (el) mo.observe(el, { childList: true, characterData: true, subtree: true });
13117
+ }
13118
+ for (const id of [...SQUEEZE_TOOLS, "chanBar", "chanUpdate", "branchGauge"]) {
13119
+ const el = $(id);
13120
+ if (el) mo.observe(el, { attributes: true, attributeFilter: ["hidden"] });
13121
+ }
13122
+ }
12976
13123
 
12977
13124
  // ── Diff panel ──────────────────────────────────────────
12978
13125
  function colorDiff(text) {