@sma1lboy/kobe 0.7.21 → 0.7.22

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.
@@ -5,8 +5,8 @@
5
5
  <meta charset="UTF-8" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>kobe-web</title>
8
- <script type="module" crossorigin src="/assets/index-DHNbtmKS.js"></script>
9
- <link rel="stylesheet" crossorigin href="/assets/index-Bz2DJrhb.css">
8
+ <script type="module" crossorigin src="/assets/index-B_AO4Tl6.js"></script>
9
+ <link rel="stylesheet" crossorigin href="/assets/index-ClDlEZ7A.css">
10
10
  </head>
11
11
  <body>
12
12
  <div id="app"></div>
@@ -15,6 +15,7 @@
15
15
  import { createServer } from "node:http"
16
16
  import { spawn } from "node-pty"
17
17
  import { WebSocketServer } from "ws"
18
+ import { createScrollback } from "./pty-scrollback.mjs"
18
19
 
19
20
  const PORT = Number.parseInt(process.env.KOBE_PTY_PORT ?? "5175", 10)
20
21
  const BRIDGE_PORT = Number.parseInt(process.env.KOBE_BRIDGE_PORT ?? "5174", 10)
@@ -52,9 +53,13 @@ function spawnTab(tabId, spec, cols, rows) {
52
53
  cwd: spec.cwd,
53
54
  env: ptyEnv(),
54
55
  })
55
- const entry = { pty, buffer: "", sockets: new Set() }
56
+ // Scrollback is a bounded ring of chunks, not a single growing string: the
57
+ // old `(buffer + data).slice(-CAP)` re-flattened ~256KB on EVERY chunk once
58
+ // the cap was reached (quadratic during heavy streaming). `push` is O(chunk);
59
+ // the string is materialized only on (re)attach replay.
60
+ const entry = { pty, scrollback: createScrollback(SCROLLBACK_CAP), sockets: new Set() }
56
61
  pty.onData((data) => {
57
- entry.buffer = (entry.buffer + data).slice(-SCROLLBACK_CAP)
62
+ entry.scrollback.push(data)
58
63
  for (const ws of entry.sockets) if (ws.readyState === ws.OPEN) ws.send(data)
59
64
  })
60
65
  pty.onExit(() => {
@@ -150,7 +155,7 @@ wss.on("connection", (ws, req) => {
150
155
 
151
156
  entry.sockets.add(ws)
152
157
  // Replay recent output so a (re)attach shows current screen state.
153
- if (entry.buffer && ws.readyState === ws.OPEN) ws.send(entry.buffer)
158
+ if (entry.scrollback.length() > 0 && ws.readyState === ws.OPEN) ws.send(entry.scrollback.replay())
154
159
  entry.pty.resize(cols, rows)
155
160
 
156
161
  ws.on("message", (raw) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@sma1lboy/kobe",
4
- "version": "0.7.21",
4
+ "version": "0.7.22",
5
5
  "description": "TUI orchestrator for Claude Code (codename)",
6
6
  "type": "module",
7
7
  "packageManager": "bun@1.3.13",