kaizen-agent 1.84.0 → 1.85.1

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/web/term.ts CHANGED
@@ -10,14 +10,42 @@ import { SearchAddon } from "@xterm/addon-search";
10
10
  import { Unicode11Addon } from "@xterm/addon-unicode11";
11
11
  import { fontRead, fontSet, fontStep } from "./term-font.ts";
12
12
 
13
+ // Orca's defaults (its "Ghostty Default Style Dark" and "Builtin Tango Light"): a terminal's ANSI
14
+ // palette is content, not board chrome, so these hex values are the one exception to design.md's
15
+ // tokens-only rule.
16
+ const ORCA_DARK = {
17
+ background: "#282c34", foreground: "#ffffff", cursor: "#ffffff", cursorAccent: "#282c34",
18
+ selectionBackground: "#5a7898", selectionForeground: "#ffffff",
19
+ black: "#1d1f21", red: "#cc6666", green: "#b5bd68", yellow: "#f0c674", blue: "#81a2be", magenta: "#b294bb", cyan: "#8abeb7", white: "#c5c8c6",
20
+ brightBlack: "#666666", brightRed: "#d54e53", brightGreen: "#b9ca4a", brightYellow: "#e7c547", brightBlue: "#7aa6da", brightMagenta: "#c397d8", brightCyan: "#70c0b1", brightWhite: "#eaeaea",
21
+ };
22
+ const ORCA_LIGHT = {
23
+ background: "#ffffff", foreground: "#2e3434", cursor: "#2e3434", cursorAccent: "#ffffff",
24
+ selectionBackground: "#accef7", selectionForeground: "#2e3434",
25
+ black: "#2e3436", red: "#cc0000", green: "#4e9a06", yellow: "#8e7700", blue: "#3465a4", magenta: "#75507b", cyan: "#05727e", white: "#6a6a6a",
26
+ brightBlack: "#555753", brightRed: "#ef2929", brightGreen: "#1b7a1b", brightYellow: "#6d5a00", brightBlue: "#204a87", brightMagenta: "#ad7fa8", brightCyan: "#034b50", brightWhite: "#3d3d3d",
27
+ };
28
+
13
29
  function mountTerm(el: HTMLElement, key: string, onEnd?: () => void): () => void {
14
30
  const css = getComputedStyle(el);
15
31
  const tok = (n: string) => css.getPropertyValue(n).trim() || undefined;
16
- const theme = () => ({ background: tok("--bg"), foreground: tok("--ink-hi"), cursor: tok("--accent"), // --line on --bg was near invisible in the dark theme (#2e2e2e on #121212), so a drag
17
- // looked like it selected nothing; --dim at 35% shows in both themes.
18
- selectionBackground: (tok("--dim") ?? "#808080") + "59" });
32
+ const os = matchMedia("(prefers-color-scheme: dark)");
33
+ // The board's theme toggle, else the system's scheme.
34
+ const dark = () => { const t = document.documentElement.dataset.theme; return t ? t === "dark" : os.matches; };
35
+ // Orca's default palettes, so a terminal looks like a terminal app rather than a box on the board:
36
+ // the pane behind it takes the same background (--term-bg), edge to edge.
37
+ const theme = () => {
38
+ const t = dark() ? ORCA_DARK : ORCA_LIGHT;
39
+ document.documentElement.style.setProperty("--term-bg", t.background);
40
+ return t;
41
+ };
19
42
  const term = new Terminal({
20
43
  cursorBlink: true,
44
+ cursorStyle: "block",
45
+ // Orca's weights and line height: 500 reads as a native terminal's regular, 700 for bold.
46
+ fontWeight: "500",
47
+ fontWeightBold: "700",
48
+ lineHeight: 1,
21
49
  // Nerd Font first: shell prompts print private-use glyphs that plain monospace fonts lack.
22
50
  fontFamily: `"JetBrainsMono Nerd Font",${tok("--mono")}`,
23
51
  fontSize: fontRead(),
@@ -33,7 +61,6 @@ function mountTerm(el: HTMLElement, key: string, onEnd?: () => void): () => void
33
61
  term.options.theme = theme();
34
62
  reportScheme();
35
63
  });
36
- const os = matchMedia("(prefers-color-scheme: dark)");
37
64
  addEventListener("kz-theme", retheme);
38
65
  os.addEventListener("change", retheme);
39
66
  const fit = new FitAddon();
@@ -90,10 +117,29 @@ function mountTerm(el: HTMLElement, key: string, onEnd?: () => void): () => void
90
117
  // Each message makes the agent repaint its whole screen, so a size already sent on this
91
118
  // socket (a few pixels of drag that move no cell) is not sent again.
92
119
  let sentOn: WebSocket | null = null, sentC = 0, sentR = 0;
120
+ // FitAddon's fit with two fixes Orca makes: the cell is measured in device pixels over the
121
+ // pixel ratio (the CSS cell is rounded, so the column count wobbled between N and N+1 on a
122
+ // scaled screen), and the container's own padding is taken off (box-sizing is border-box here,
123
+ // so its computed width includes it and the last column was cut off).
124
+ const fitTerm = () => {
125
+ const d = (term as any)._core?._renderService?.dimensions, dpr = devicePixelRatio || 1;
126
+ const cw = d?.device?.cell?.width / dpr, ch = d?.device?.cell?.height / dpr;
127
+ const p = term.element?.parentElement;
128
+ if (!(cw > 0 && ch > 0) || !p) return fit.fit();
129
+ const px = (st: CSSStyleDeclaration, k: string) => parseFloat(st.getPropertyValue(k)) || 0;
130
+ const ps = getComputedStyle(p), es = getComputedStyle(term.element!);
131
+ const bar = term.options.scrollback === 0 ? 0 : term.options.overviewRuler?.width || 14;
132
+ const w = px(ps, "width") - px(ps, "padding-left") - px(ps, "padding-right") - px(es, "padding-left") - px(es, "padding-right") - bar;
133
+ const h = px(ps, "height") - px(ps, "padding-top") - px(ps, "padding-bottom") - px(es, "padding-top") - px(es, "padding-bottom");
134
+ const cols = Math.max(2, Math.floor(w / cw)), rows = Math.max(1, Math.floor(h / ch));
135
+ if (cols === term.cols && rows === term.rows) return;
136
+ (term as any)._core?._renderService?.clear();
137
+ term.resize(cols, rows);
138
+ };
93
139
  const size = (nudge = false) => {
94
140
  if (!el.offsetWidth) return;
95
141
  if (!ws) return connect(); // its onopen comes back here to fit and nudge
96
- fit.fit();
142
+ fitTerm();
97
143
  if (!nudge && sentOn === ws && sentC === term.cols && sentR === term.rows) return;
98
144
  sentOn = ws; sentC = term.cols; sentR = term.rows;
99
145
  // The replay was drawn at whatever size the agent had before; a resize to the same size
@@ -512,16 +558,19 @@ function mountTerm(el: HTMLElement, key: string, onEnd?: () => void): () => void
512
558
  size();
513
559
  };
514
560
  addEventListener("kz-term-font", refont);
515
- // Fit and tell the agent in the same tick. If xterm narrows first, the agent keeps drawing
516
- // at the old width until the message lands, its long lines wrap, and the frame ends up
517
- // shifted with junk rows above it. Each resize still makes the agent redraw its screen, so
518
- // a drag is throttled (first one at once, then one trailing) rather than sent per frame.
519
- let resizing: Timer | undefined, last = 0;
561
+ // Fit and tell the agent in the same tick: if xterm narrowed first, the agent kept drawing at
562
+ // the old width until the message landed, its long lines wrapped, and the frame ended up shifted
563
+ // with junk rows. As Orca does, nothing refits while a divider or the window is still moving: the
564
+ // pane clips or shows its background (the same colour), and one fit + one resize goes out 150 ms
565
+ // after the size settles, on the next frame. A pane that just appeared (no size before) fits at once.
566
+ let resizing: Timer | undefined, frame = 0, wasW = 0;
567
+ const settle = () => { frame = 0; size(); };
520
568
  const ro = new ResizeObserver(() => {
521
569
  clearTimeout(resizing);
522
- const wait = 60 - (Date.now() - last);
523
- if (wait <= 0) { last = Date.now(); size(); }
524
- else resizing = setTimeout(() => { last = Date.now(); size(); }, wait);
570
+ const appeared = !wasW && el.offsetWidth > 0;
571
+ wasW = el.offsetWidth;
572
+ if (appeared) return size();
573
+ resizing = setTimeout(() => { cancelAnimationFrame(frame); frame = requestAnimationFrame(settle); }, 150);
525
574
  });
526
575
  ro.observe(el);
527
576
  term.focus();
@@ -529,6 +578,7 @@ function mountTerm(el: HTMLElement, key: string, onEnd?: () => void): () => void
529
578
  return () => {
530
579
  ro.disconnect();
531
580
  clearTimeout(resizing);
581
+ cancelAnimationFrame(frame);
532
582
  el.removeEventListener("touchstart", touchStart);
533
583
  el.removeEventListener("touchmove", touchMove);
534
584
  typed.dispose();
package/web/video.html CHANGED
@@ -138,6 +138,8 @@ body .rail a.upd::after{left:calc(50% + 6px);top:4px}body .toast{left:16px;botto
138
138
  /* phones: Runs, Search, Home, Chat, Terminal (Settings and the Icebox are Search results). The board and Tasks are set up on a computer (web/board/phone.ts) */
139
139
  @media(min-width:641px){.rail .rbot .lbl{display:none}.rail .rbot a.it{flex:none;width:var(--btn-xs);height:var(--btn-xs);padding:0;justify-content:center;margin-right:auto}[data-rail=min] .rail .rbot a.it{width:var(--btn-s);height:var(--btn-s);margin-right:0}}
140
140
  .rail a.it.ponly,#phome{display:none}
141
+ /* the Home chat item reads Chat on a computer (Home is the floating workspace there) and Home on a phone */
142
+ .rail .phl{display:none}@media(max-width:640px){.rail .dkl{display:none}.rail .phl{display:inline}.rail svg.phl{display:block}}
141
143
  @media(max-width:640px){
142
144
  .rail a.it:is([data-view=board],[data-view=tasks],[data-view=sources]),#foot,#ctx-open,body .rail .rbot .ib.xs{display:none!important}
143
145
  .rail a.it.ponly{display:flex}
@@ -412,7 +414,7 @@ select.sel,button.sel{cursor:pointer;appearance:none;padding-right:30px;max-widt
412
414
  <symbol id="r-term" viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="16" rx="2"/><path d="m7 9 3 3-3 3M13 15h4"/></symbol>
413
415
  </defs></svg>
414
416
  <a class="it gs-it" href="#" id="gsearch" title="Search everything"><svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="7" fill="none" stroke="currentColor" stroke-width="2"/><path d="M20 20l-4-4" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg><span class="lbl">Search</span></a>
415
- <a class="it" href="/" data-view="home" title="Home: chat with the project's agent"><svg><use href="#i-home"/></svg><span class="lbl">Home</span></a>
417
+ <a class="it" href="/" data-view="home" title="Chat with the project's agent"><svg class="dkl"><use href="#r-chat"/></svg><svg class="phl"><use href="#i-home"/></svg><span class="lbl"><span class="dkl">Chat</span><span class="phl">Home</span></span></a>
416
418
  <a class="it ponly" href="/?view=chat" data-view="chat" title="Chat with kaizen's agent"><svg><use href="#r-chat"/></svg><span class="lbl">Chat</span></a>
417
419
  <a class="it ponly" href="/?view=device" data-view="device" title="This computer's runs"><svg><use href="#r-runs"/></svg><span class="lbl">Runs</span></a>
418
420
  <a class="it ponly" href="/?view=terminal" data-view="terminal" title="Open terminals across all projects"><svg><use href="#r-term"/></svg><span class="lbl">Terminal</span></a>