tmux-ide 2.9.26 → 2.9.27

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 (47) hide show
  1. package/README.md +1 -1
  2. package/bin/cli.js +1252 -528
  3. package/package.json +2 -2
  4. package/packages/contracts/src/pane-stream.ts +9 -0
  5. package/packages/contracts/src/terminal-delivery.ts +114 -3
  6. package/packages/core/src/index.ts +1 -0
  7. package/packages/core/src/terminal-delivery-binary.ts +8 -7
  8. package/packages/core/src/terminal-delivery.ts +174 -3
  9. package/packages/core/src/terminal-partial-history.ts +152 -0
  10. package/packages/core/src/terminal-replica.ts +70 -1
  11. package/packages/daemon/dist/command-center/owner-keep-alive.js +30 -0
  12. package/packages/daemon/dist/command-center/server.js +3 -0
  13. package/packages/daemon/dist/command-center/tmux-server-attach.js +51 -0
  14. package/packages/daemon/dist/command-center/tmux-servers.js +78 -0
  15. package/packages/daemon/dist/doctor.js +4 -4
  16. package/packages/daemon/dist/lib/app-config.js +7 -0
  17. package/packages/daemon/dist/lib/node-requirement.js +20 -0
  18. package/packages/daemon/dist/lib/require-supported-node.js +8 -0
  19. package/packages/daemon/dist/lib/tmux-server-session-open.js +38 -12
  20. package/packages/daemon/dist/lib/workspace-promotion.js +4 -4
  21. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Info.plist +2 -2
  22. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/MacOS/tmux-ide-notifier +0 -0
  23. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Resources/Assets.car +0 -0
  24. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/_CodeSignature/CodeResources +2 -2
  25. package/packages/daemon/dist/server/pane-stream-upgrade.js +39 -1
  26. package/packages/daemon/dist/terminal/pane-stream/pane-stream-websocket.js +14 -0
  27. package/packages/daemon/dist/terminal/session-runtime/registry.js +1 -0
  28. package/packages/daemon/dist/terminal/session-runtime/terminal-delivery-hub.js +465 -42
  29. package/packages/daemon/dist/tui/mirror/open-tui-workspace-runtime-port.js +76 -2
  30. package/packages/daemon/dist/tui/mirror/theme.js +8 -1
  31. package/packages/daemon/src/command-center/attach-window-rule.cases.json +84 -0
  32. package/packages/daemon/src/command-center/owner-keep-alive.ts +38 -0
  33. package/packages/daemon/src/command-center/server.ts +3 -0
  34. package/packages/daemon/src/command-center/tmux-server-attach.ts +75 -0
  35. package/packages/daemon/src/command-center/tmux-servers.ts +84 -0
  36. package/packages/daemon/src/doctor.ts +4 -4
  37. package/packages/daemon/src/lib/app-config.ts +15 -0
  38. package/packages/daemon/src/lib/node-requirement.ts +22 -0
  39. package/packages/daemon/src/lib/require-supported-node.ts +9 -0
  40. package/packages/daemon/src/lib/tmux-server-session-open.ts +53 -15
  41. package/packages/daemon/src/lib/workspace-promotion.ts +4 -4
  42. package/packages/daemon/src/server/pane-stream-upgrade.ts +41 -1
  43. package/packages/daemon/src/terminal/pane-stream/pane-stream-websocket.ts +25 -0
  44. package/packages/daemon/src/terminal/session-runtime/registry.ts +1 -0
  45. package/packages/daemon/src/terminal/session-runtime/terminal-delivery-hub.ts +575 -39
  46. package/packages/daemon/src/tui/mirror/open-tui-workspace-runtime-port.ts +82 -2
  47. package/packages/daemon/src/tui/mirror/theme.ts +13 -1
@@ -1,4 +1,4 @@
1
- import { STOCK_CAPTURE_TAB_UNAVAILABLE } from "@tmux-ide/contracts";
1
+ import { STOCK_CAPTURE_TAB_UNAVAILABLE, TERMINAL_DELIVERY_MAX_PIPELINED, TERMINAL_DELIVERY_PIPELINING_CAPABILITY_VERSION, } from "@tmux-ide/contracts";
2
2
  import { randomUUID } from "node:crypto";
3
3
  import { TerminalDeliveryAssembler, decodeVerifiedCompactSemanticTerminalUpdate, decodeVerifiedCompactSemanticTerminalUpdateCooperatively, decodeVerifiedLegacySemanticTerminalUpdate, terminalDeliveryEncodingAccepted, } from "@tmux-ide/core";
4
4
  import { PaneStreamOperationError, } from "@tmux-ide/daemon-client/pane-stream-client";
@@ -244,6 +244,13 @@ class WireTerminalEndpoint {
244
244
  #pending = null;
245
245
  #rejectedTransactionId = null;
246
246
  #decodeToken = null;
247
+ /**
248
+ * Capability 124: patches the daemon pipelined behind the delivery that is
249
+ * still decoding or unsettled, each with its chunks, in arrival order. Each
250
+ * names the one before as its base; they are admitted once that one is ACKed.
251
+ */
252
+ #queued = [];
253
+ #draining = false;
247
254
  #closed = false;
248
255
  #ready;
249
256
  #resolveReady;
@@ -311,6 +318,7 @@ class WireTerminalEndpoint {
311
318
  return;
312
319
  }
313
320
  if (message.type === "terminal.delivery.fault") {
321
+ this.#queued.length = 0;
314
322
  if (message.deliveryNonce !== this.#negotiated.deliveryNonce) {
315
323
  this.#failConnection(new Error("Terminal fault nonce does not match negotiation"));
316
324
  return;
@@ -335,6 +343,15 @@ class WireTerminalEndpoint {
335
343
  }
336
344
  if (this.#unavailable)
337
345
  return;
346
+ if ((this.#queued.length > 0 || this.#busy()) && this.#mayQueue(message)) {
347
+ this.#queued.push(message);
348
+ return;
349
+ }
350
+ return this.#acceptNow(message);
351
+ }
352
+ #acceptNow(message) {
353
+ if (message.type === "terminal.delivery.fault")
354
+ return;
338
355
  if (message.type === "terminal.projection") {
339
356
  this.#failConnection(new Error("Unsolicited alternate-screen projection"));
340
357
  return;
@@ -345,10 +362,61 @@ class WireTerminalEndpoint {
345
362
  }
346
363
  return this.#acceptChunk(message);
347
364
  }
365
+ /** A flight is decoding or waiting for its subscriber: it has not been ACKed. */
366
+ #busy() {
367
+ return this.#decodeToken !== null || this.#pending !== null;
368
+ }
369
+ /**
370
+ * Capability 124: only a patch based on the newest flight (decoding,
371
+ * unsettled or queued), within TERMINAL_DELIVERY_MAX_PIPELINED, and the
372
+ * chunks of the newest queued patch. Anything else overlapping a flight is
373
+ * still a protocol violation and takes the ordinary path.
374
+ */
375
+ #mayQueue(message) {
376
+ let newest = this.#pending?.envelope ?? this.#envelope;
377
+ let envelopes = 1;
378
+ let chunks = 0;
379
+ for (const queued of this.#queued)
380
+ if (queued.type === "terminal.delivery") {
381
+ newest = queued;
382
+ envelopes += 1;
383
+ chunks = 0;
384
+ }
385
+ else if (queued.type === "terminal.delivery.chunk")
386
+ chunks += 1;
387
+ if (!newest)
388
+ return false;
389
+ if (message.type === "terminal.delivery.chunk")
390
+ return (envelopes > 1 &&
391
+ message.transactionId === newest.transactionId &&
392
+ chunks < newest.chunkCount);
393
+ return (message.type === "terminal.delivery" &&
394
+ message.frame === "patch" &&
395
+ message.baseRevision === newest.canonicalRevision &&
396
+ message.incarnation === newest.incarnation &&
397
+ envelopes < TERMINAL_DELIVERY_MAX_PIPELINED &&
398
+ (envelopes === 1 || chunks === newest.chunkCount));
399
+ }
400
+ /** Admit queued deliveries in order until one is decoding or unsettled again. */
401
+ #drain() {
402
+ if (this.#draining)
403
+ return;
404
+ this.#draining = true;
405
+ try {
406
+ while (this.#queued.length > 0 && !this.#busy() && !this.#closed) {
407
+ const message = this.#queued.shift();
408
+ this.#acceptNow(message);
409
+ }
410
+ }
411
+ finally {
412
+ this.#draining = false;
413
+ }
414
+ }
348
415
  close() {
349
416
  if (this.#closed)
350
417
  return;
351
418
  this.#closed = true;
419
+ this.#queued.length = 0;
352
420
  this.#assembler = null;
353
421
  this.#assemblyStorage = null;
354
422
  this.#envelope = null;
@@ -595,7 +663,9 @@ class WireTerminalEndpoint {
595
663
  }
596
664
  catch (error) {
597
665
  this.#failConnection(error instanceof Error ? error : new Error(String(error)));
666
+ return;
598
667
  }
668
+ this.#drain();
599
669
  }
600
670
  #reject(reason, envelope, transactionId = null) {
601
671
  const negotiated = this.#negotiated;
@@ -626,6 +696,9 @@ class WireTerminalEndpoint {
626
696
  this.#decodeToken = null;
627
697
  this.#rejectedTransactionId = attempted?.transactionId ?? transactionId;
628
698
  this.#reseedRequired = true;
699
+ // Patches queued behind the rejected flight are NACKed in turn ("gap");
700
+ // the daemon dropped them with the first NACK.
701
+ this.#drain();
629
702
  }
630
703
  }
631
704
  class WireTerminalSubscription {
@@ -942,7 +1015,8 @@ export async function connectOpenTuiWorkspaceRuntimePort(options) {
942
1015
  panes: [...panes],
943
1016
  viewerMode: "interactive",
944
1017
  terminalDelivery: {
945
- protocolVersions: [1],
1018
+ // 124: this endpoint holds patches pipelined behind a decoding one.
1019
+ protocolVersions: [1, TERMINAL_DELIVERY_PIPELINING_CAPABILITY_VERSION],
946
1020
  encodings: ["semantic-compact-v1", "semantic-v1"],
947
1021
  richPlacements: true,
948
1022
  },
@@ -597,10 +597,17 @@ export function createSemanticThemeSnapshot(config = undefined, rendererMode = n
597
597
  increasedContrast: config?.accessibility?.increasedContrast ?? DEFAULT_ACCESSIBILITY.increasedContrast,
598
598
  };
599
599
  const mode = resolvedMode(setting, rendererMode, hostDefaults);
600
+ // System mode with a chosen preset for each side (the Mac app's Match
601
+ // macOS writes theme.light / theme.dark): the side the host is on.
602
+ const side = setting === "system"
603
+ ? findVisualThemePreset(mode === "light" ? config?.light : config?.dark)
604
+ : undefined;
600
605
  const resolved = resolveVisualTheme({
601
606
  appearance: mode,
602
607
  hostDefaults: setting === "system" ? (hostDefaults ?? undefined) : undefined,
603
- userTheme: config?.userTheme ?? findVisualThemePreset(config?.preset),
608
+ userTheme: config?.userTheme ??
609
+ findVisualThemePreset(config?.preset) ??
610
+ (side?.appearance === mode ? side : undefined),
604
611
  projectTheme: config?.projectTheme,
605
612
  accessibility,
606
613
  });
@@ -0,0 +1,84 @@
1
+ [
2
+ {
3
+ "name": "a session that fits streams whole, preferred pane selected",
4
+ "windows": [
5
+ { "id": "window.a", "active": false, "panes": ["pane.1", "pane.2"] },
6
+ { "id": "window.b", "active": true, "panes": ["pane.3"] }
7
+ ],
8
+ "preferred": "pane.3",
9
+ "maxPanes": 3,
10
+ "expect": { "window": null, "panes": ["pane.1", "pane.2", "pane.3"], "selected": "pane.3" }
11
+ },
12
+ {
13
+ "name": "a whole session without a preferred pane selects the first",
14
+ "windows": [{ "id": "window.a", "active": true, "panes": ["pane.1", "pane.2"] }],
15
+ "preferred": null,
16
+ "maxPanes": 2,
17
+ "expect": { "window": null, "panes": ["pane.1", "pane.2"], "selected": "pane.1" }
18
+ },
19
+ {
20
+ "name": "a preferred pane that is gone selects the first",
21
+ "windows": [{ "id": "window.a", "active": true, "panes": ["pane.1"] }],
22
+ "preferred": "pane.9",
23
+ "maxPanes": 24,
24
+ "expect": { "window": null, "panes": ["pane.1"], "selected": "pane.1" }
25
+ },
26
+ {
27
+ "name": "too many panes: the window holding the preferred pane",
28
+ "windows": [
29
+ { "id": "window.a", "active": true, "panes": ["pane.1", "pane.2"] },
30
+ { "id": "window.b", "active": false, "panes": ["pane.3", "pane.4"] }
31
+ ],
32
+ "preferred": "pane.4",
33
+ "maxPanes": 3,
34
+ "expect": { "window": "window.b", "panes": ["pane.3", "pane.4"], "selected": "pane.4" }
35
+ },
36
+ {
37
+ "name": "too many panes and no preferred pane: the active window",
38
+ "windows": [
39
+ { "id": "window.a", "active": false, "panes": ["pane.1", "pane.2"] },
40
+ { "id": "window.b", "active": true, "panes": ["pane.3", "pane.4"] }
41
+ ],
42
+ "preferred": null,
43
+ "maxPanes": 3,
44
+ "expect": { "window": "window.b", "panes": ["pane.3", "pane.4"], "selected": "pane.3" }
45
+ },
46
+ {
47
+ "name": "the wanted window does not fit: the active one",
48
+ "windows": [
49
+ { "id": "window.a", "active": false, "panes": ["pane.1", "pane.2", "pane.5"] },
50
+ { "id": "window.b", "active": true, "panes": ["pane.3"] }
51
+ ],
52
+ "preferred": "pane.2",
53
+ "maxPanes": 2,
54
+ "expect": { "window": "window.b", "panes": ["pane.3"], "selected": "pane.3" }
55
+ },
56
+ {
57
+ "name": "neither wanted nor active fits: the first that fits",
58
+ "windows": [
59
+ { "id": "window.a", "active": true, "panes": ["pane.1", "pane.2", "pane.5"] },
60
+ { "id": "window.b", "active": false, "panes": ["pane.3", "pane.6", "pane.7"] },
61
+ { "id": "window.c", "active": false, "panes": ["pane.4"] }
62
+ ],
63
+ "preferred": null,
64
+ "maxPanes": 2,
65
+ "expect": { "window": "window.c", "panes": ["pane.4"], "selected": "pane.4" }
66
+ },
67
+ {
68
+ "name": "nothing fits: no selection",
69
+ "windows": [
70
+ { "id": "window.a", "active": true, "panes": ["pane.1", "pane.2"] },
71
+ { "id": "window.b", "active": false, "panes": ["pane.3", "pane.4"] }
72
+ ],
73
+ "preferred": null,
74
+ "maxPanes": 1,
75
+ "expect": null
76
+ },
77
+ {
78
+ "name": "no panes: no selection",
79
+ "windows": [],
80
+ "preferred": null,
81
+ "maxPanes": 24,
82
+ "expect": null
83
+ }
84
+ ]
@@ -0,0 +1,38 @@
1
+ import type { IncomingMessage, ServerResponse } from "node:http";
2
+ import type { MiddlewareHandler } from "hono";
3
+ import { ownerBearerMatches } from "./owner-authority.ts";
4
+
5
+ /**
6
+ * How long an owner-authenticated HTTP connection may sit idle before the
7
+ * daemon closes it. Node's default is 5 s, so a native app that paused for
8
+ * longer found its proven connection gone; over SSH every replacement costs
9
+ * a channel open and an identity proof (attach-rtt). The app keeps an idle
10
+ * connection for at most 60 s, below this.
11
+ */
12
+ export const OWNER_KEEP_ALIVE_MS = 65_000;
13
+
14
+ type NodeBindings = { incoming?: IncomingMessage; outgoing?: ServerResponse } | undefined;
15
+
16
+ /**
17
+ * After a response to the owner bearer, keep that connection open for
18
+ * `timeoutMs` while idle. Every other connection keeps Node's default.
19
+ * Node arms its own keep-alive timer when the response finishes; this runs
20
+ * after it and replaces the bound for this socket only. The next request on
21
+ * the socket clears the timer as usual.
22
+ */
23
+ export function ownerKeepAlive(
24
+ ownerToken: string | null,
25
+ timeoutMs: number = OWNER_KEEP_ALIVE_MS,
26
+ ): MiddlewareHandler {
27
+ return async (c, next) => {
28
+ const bindings = c.env as NodeBindings;
29
+ const outgoing = bindings?.outgoing;
30
+ const socket = bindings?.incoming?.socket;
31
+ if (outgoing && socket && ownerBearerMatches(c.req.header("Authorization"), ownerToken)) {
32
+ outgoing.once("finish", () => {
33
+ if (!socket.destroyed && outgoing.shouldKeepAlive) socket.setTimeout(timeoutMs);
34
+ });
35
+ }
36
+ await next();
37
+ };
38
+ }
@@ -161,6 +161,7 @@ import { mountWorkspaceResourceRoutes } from "./resources/workspace-resource-rou
161
161
  import { mountFleetResourceRoute } from "./resources/fleet-resource-route.ts";
162
162
  import { mountWorkspaceMissionsRoute } from "./resources/workspace-missions-route.ts";
163
163
  import { ownerAuthorityGate, requireOwnerAuthority } from "./owner-authority.ts";
164
+ import { ownerKeepAlive } from "./owner-keep-alive.ts";
164
165
  import { mountDiagnosticsRoute } from "./diagnostics.ts";
165
166
  import {
166
167
  mountStartupReadinessRoute,
@@ -569,6 +570,8 @@ export function createApp(options: CreateAppOptions = {}): Hono {
569
570
 
570
571
  // Allow cross-origin (Next.js dashboard, Tailscale, etc.)
571
572
  app.use("/*", cors());
573
+ // An owner connection stays open while idle for longer than Node's 5 s.
574
+ app.use("/*", ownerKeepAlive(options.remoteAccess?.ownerToken ?? null));
572
575
 
573
576
  if (options.tmuxServerOwners) {
574
577
  mountAutomationRoutes(app, {
@@ -0,0 +1,75 @@
1
+ import { z } from "zod";
2
+
3
+ /**
4
+ * One request that opens a session, reads its inventory and issues its stream
5
+ * (attach-rtt). Before it the app sent three: open, inventory, issue. The app
6
+ * still checks the answer: it applies its own window rule to the returned
7
+ * inventory and uses the issued stream only when the daemon chose the same.
8
+ *
9
+ * `issue` is the body of an ordinary pane-stream issue request without the
10
+ * workspace name, the panes and the window, which only the daemon knows here.
11
+ */
12
+ export const TmuxServerAttachRequestSchemaZ = z
13
+ .object({
14
+ version: z.literal(1),
15
+ preferredPane: z.string().min(1).max(128).nullable(),
16
+ maxPanes: z.number().int().min(1).max(256),
17
+ issue: z
18
+ .object({
19
+ expectedDaemonInstanceId: z.uuid(),
20
+ stream: z.record(z.string(), z.unknown()),
21
+ })
22
+ .catchall(z.unknown()),
23
+ })
24
+ .strict();
25
+ export type TmuxServerAttachRequest = z.infer<typeof TmuxServerAttachRequestSchemaZ>;
26
+
27
+ export interface AttachInventory {
28
+ readonly semanticPaneIds: readonly string[];
29
+ readonly windows: readonly {
30
+ readonly semanticWindowId: string;
31
+ readonly active: boolean;
32
+ readonly semanticPaneIds: readonly string[];
33
+ }[];
34
+ }
35
+
36
+ export interface AttachSelection {
37
+ /** The one window the stream carries, or null for the whole session. */
38
+ readonly semanticWindowId: string | null;
39
+ readonly panes: readonly string[];
40
+ readonly selectedPane: string;
41
+ }
42
+
43
+ /**
44
+ * The app's rule (browser_native_local_window.rs `scope`), here so the open
45
+ * and the issue can be one request: a session that fits streams whole;
46
+ * otherwise the window holding the preferred pane (else the active one) when
47
+ * it fits, else the active one, else the first in tmux order that fits. No
48
+ * selection when there is no pane or nothing fits: the app decides then.
49
+ */
50
+ export function chooseAttachSelection(
51
+ inventory: AttachInventory,
52
+ preferredPane: string | null,
53
+ maxPanes: number,
54
+ ): AttachSelection | null {
55
+ const panes = inventory.semanticPaneIds;
56
+ if (panes.length === 0) return null;
57
+ let semanticWindowId: string | null = null;
58
+ let chosen = panes;
59
+ if (panes.length > maxPanes) {
60
+ const fits = (window: AttachInventory["windows"][number] | undefined) =>
61
+ window !== undefined && window.semanticPaneIds.length <= maxPanes;
62
+ const active = inventory.windows.find((window) => window.active);
63
+ const wanted =
64
+ (preferredPane !== null
65
+ ? inventory.windows.find((window) => window.semanticPaneIds.includes(preferredPane))
66
+ : undefined) ?? active;
67
+ const window = [wanted, active].find(fits) ?? inventory.windows.find(fits);
68
+ if (!window) return null;
69
+ semanticWindowId = window.semanticWindowId;
70
+ chosen = window.semanticPaneIds;
71
+ }
72
+ const selectedPane =
73
+ preferredPane !== null && chosen.includes(preferredPane) ? preferredPane : chosen[0]!;
74
+ return { semanticWindowId, panes: chosen, selectedPane };
75
+ }
@@ -41,6 +41,7 @@ import { WorkspacePaneCreationError } from "../lib/workspace-pane-creation.ts";
41
41
  import { ownerBearerMatches } from "./owner-authority.ts";
42
42
  import { logger } from "../lib/log.ts";
43
43
  import { mountPaneStreamIssueRoute } from "./pane-stream-issue.ts";
44
+ import { chooseAttachSelection, TmuxServerAttachRequestSchemaZ } from "./tmux-server-attach.ts";
44
45
  import {
45
46
  projectTerminalRuntimeInventory,
46
47
  projectTerminalRuntimeInventoryV2,
@@ -295,6 +296,89 @@ export function mountTmuxServerRoutes(app: Hono, options: TmuxServerRoutesOption
295
296
  return c.json({ version: 1, server, ...result });
296
297
  }),
297
298
  );
299
+ // attach-rtt: open, inventory and issue in one round trip. The stream is
300
+ // issued through the ordinary issue route with this request's headers, so
301
+ // it is checked exactly as a separate issue request would be.
302
+ app.post(
303
+ `${scoped}/sessions/:liveSessionId/attach`,
304
+ route(async (c) => {
305
+ const server = scope(c);
306
+ const liveSessionId = workspaceSchema.parse(c.req.param("liveSessionId"));
307
+ const request = TmuxServerAttachRequestSchemaZ.parse(await boundedJson(c.req.raw));
308
+ // The issue below checks the same, but only after the open: refuse a
309
+ // request for another generation before it can promote anything.
310
+ if (
311
+ request.issue.expectedDaemonInstanceId !== server.generation ||
312
+ c.req.header("X-Tmux-Ide-Expected-Daemon-Instance-Id") !== server.generation
313
+ )
314
+ throw new TmuxServerScopeError("stale-generation");
315
+ const result = await options.owners.withOwner(server, async (owner) => {
316
+ const opened = await owner.openSession(liveSessionId);
317
+ const workspace = owner.workspaceRegistry.get(opened.workspaceName);
318
+ if (!workspace || opened.liveSessionId !== liveSessionId)
319
+ throw new TmuxServerScopeError("stale-generation");
320
+ const snapshot = await owner.terminalInventoryRuntime.discoverTerminalRuntimeSession(
321
+ workspace.sessionName,
322
+ c.req.raw.signal,
323
+ );
324
+ if (!snapshot) return null;
325
+ const inventory = projectTerminalRuntimeInventoryV2(snapshot, 0);
326
+ const selection = chooseAttachSelection(inventory, request.preferredPane, request.maxPanes);
327
+ if (!selection)
328
+ return { kind: "attached" as const, opened, inventory, selection, issue: null };
329
+ // The window is the daemon's to choose, never the client's.
330
+ const stream = { ...request.issue.stream };
331
+ delete stream.semanticWindowId;
332
+ const body = {
333
+ ...request.issue,
334
+ stream: {
335
+ ...stream,
336
+ workspaceName: opened.workspaceName,
337
+ panes: selection.panes,
338
+ ...(selection.semanticWindowId ? { semanticWindowId: selection.semanticWindowId } : {}),
339
+ },
340
+ };
341
+ const issueApp = new Hono();
342
+ mountPaneStreamIssueRoute(issueApp, {
343
+ daemonInstanceId: server.generation,
344
+ ownerToken: options.ownerToken,
345
+ workspaceRegistry: owner.workspaceRegistry,
346
+ backend: owner.paneStreamRuntime.coordinator,
347
+ });
348
+ const url = new URL(c.req.url);
349
+ url.pathname = PANE_STREAM_ISSUE_PATH;
350
+ url.search = "";
351
+ const headers = new Headers(c.req.raw.headers);
352
+ headers.delete("Content-Length");
353
+ headers.set("Content-Type", "application/json");
354
+ const issued = await issueApp.request(
355
+ new Request(url, { method: "POST", headers, body: JSON.stringify(body) }),
356
+ );
357
+ // The issue route answers a refused issue as 200 with an error
358
+ // envelope, which goes back in `issue` with the open and inventory
359
+ // (the app then issues again). A non-200 is an auth or body refusal.
360
+ if (issued.status !== 200) return { kind: "refused" as const, refused: issued };
361
+ return {
362
+ kind: "attached" as const,
363
+ opened,
364
+ inventory,
365
+ selection,
366
+ issue: (await issued.json()) as unknown,
367
+ };
368
+ });
369
+ if (!result) return c.json({ error: { code: "workspace-not-found" } }, 404);
370
+ if (result.kind === "refused") return result.refused;
371
+ return c.json({
372
+ version: 1,
373
+ server,
374
+ workspaceName: result.opened.workspaceName,
375
+ liveSessionId,
376
+ inventory: result.inventory,
377
+ selection: result.selection,
378
+ issue: result.issue,
379
+ });
380
+ }),
381
+ );
298
382
  app.get(
299
383
  `${scoped}/sessions`,
300
384
  route(async (c) => {
@@ -17,6 +17,7 @@ import { findCompiledTui, hasDevelopmentTuiSource, isBunAvailable } from "./tui/
17
17
  import { claudeSettingsPath } from "./tui/integrations/claude.ts";
18
18
  import { readNotificationPrefs, resolveNativeMacosNotifierPath } from "./tui/chrome/notify.ts";
19
19
  import { resolveConfig } from "./lib/resolved-config.ts";
20
+ import { MINIMUM_NODE_MAJOR, isSupportedNodeVersion } from "./lib/node-requirement.ts";
20
21
  import {
21
22
  collectDaemonProvenanceReport,
22
23
  type DaemonProvenanceReport,
@@ -436,12 +437,11 @@ export function tmuxServerSocketRow(environment: NodeJS.ProcessEnv, uid: number)
436
437
  }
437
438
 
438
439
  export function nodeVersionRow(version: string): CheckResult {
439
- const major = Number(version.split(".")[0]);
440
- const pass = Number.isInteger(major) && major >= 20;
440
+ const pass = isSupportedNodeVersion(version);
441
441
  return {
442
- label: "Node.js ≥ 20",
442
+ label: `Node.js ≥ ${MINIMUM_NODE_MAJOR}`,
443
443
  pass,
444
- detail: pass ? `v${version}` : `Node ${version} (need ≥ 20)`,
444
+ detail: pass ? `v${version}` : `Node ${version} (need ≥ ${MINIMUM_NODE_MAJOR})`,
445
445
  optional: false,
446
446
  };
447
447
  }
@@ -89,6 +89,13 @@ export interface AppTheme {
89
89
  /** Explicit palette mode or terminal-following mode. Defaults to following the terminal. */
90
90
  mode: ThemeModeSetting;
91
91
  preset?: string;
92
+ /**
93
+ * The presets `mode: "system"` uses when the terminal (or macOS, in the
94
+ * Mac app) is light or dark. Kept only when each names a preset of that
95
+ * appearance; unset, system mode follows the host palette as before.
96
+ */
97
+ light?: string;
98
+ dark?: string;
92
99
  /** Primary/brand accent (default `colour75`). */
93
100
  accent: string;
94
101
  /** Muted/secondary foreground for dim text (default `colour240`). */
@@ -368,6 +375,12 @@ function appThemeOverrideProvenance(
368
375
  * back to its default, so partial and garbage configs both resolve to a complete,
369
376
  * well-typed {@link AppConfig}. Never throws.
370
377
  */
378
+ /** `theme.light` / `theme.dark`, when the id names a preset of that appearance. */
379
+ function systemSide(value: unknown, appearance: "light" | "dark"): Partial<AppTheme> {
380
+ const preset = findVisualThemePreset(value);
381
+ return preset?.appearance === appearance ? { [appearance]: preset.id } : {};
382
+ }
383
+
371
384
  export function parseAppConfig(input: unknown): AppConfig {
372
385
  const D = DEFAULT_APP_CONFIG;
373
386
  const root = asObject(input);
@@ -405,6 +418,8 @@ export function parseAppConfig(input: unknown): AppConfig {
405
418
  findVisualThemePreset(theme.preset)?.appearance ?? D.theme.mode,
406
419
  ),
407
420
  ...(findVisualThemePreset(theme.preset) ? { preset: String(theme.preset) } : {}),
421
+ ...systemSide(theme.light, "light"),
422
+ ...systemSide(theme.dark, "dark"),
408
423
  accent: pickString(theme.accent, D.theme.accent),
409
424
  muted: pickString(theme.muted, D.theme.muted),
410
425
  fg: pickString(theme.fg, D.theme.fg),
@@ -0,0 +1,22 @@
1
+ /** The oldest Node.js major an npm install of tmux-ide supports (package.json `engines`). */
2
+ export const MINIMUM_NODE_MAJOR = 24;
3
+
4
+ /** True when `version` (as in `process.versions.node`) is new enough. */
5
+ export function isSupportedNodeVersion(version: string): boolean {
6
+ const major = Number(version.split(".")[0]);
7
+ return Number.isInteger(major) && major >= MINIMUM_NODE_MAJOR;
8
+ }
9
+
10
+ /**
11
+ * The message the CLI prints before exiting on an unsupported Node.js, or null
12
+ * when the runtime is supported. Bun (dev runs, compiled surfaces) is exempt.
13
+ */
14
+ export function unsupportedNodeMessage(versions: { node?: string; bun?: string }): string | null {
15
+ if (versions.bun !== undefined || versions.node === undefined) return null;
16
+ if (isSupportedNodeVersion(versions.node)) return null;
17
+ return (
18
+ `tmux-ide needs Node.js ${MINIMUM_NODE_MAJOR} or newer; this is Node.js ${versions.node}.\n` +
19
+ `Upgrade Node.js, or use the installer, which brings its own runtime:\n` +
20
+ ` curl -fsSL https://tmux-ide.com/install.sh | sh\n`
21
+ );
22
+ }
@@ -0,0 +1,9 @@
1
+ // Imported first by bin/cli.ts so an unsupported Node.js stops with a clear
2
+ // message before any command code runs.
3
+ import { unsupportedNodeMessage } from "./node-requirement.ts";
4
+
5
+ const message = unsupportedNodeMessage(process.versions);
6
+ if (message !== null) {
7
+ process.stderr.write(message);
8
+ process.exit(1);
9
+ }