tmux-ide 2.9.25 → 2.9.26

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 (36) hide show
  1. package/bin/cli.js +344 -50
  2. package/package.json +2 -1
  3. package/packages/contracts/src/pane-stream.ts +19 -0
  4. package/packages/contracts/src/terminal-delivery.ts +8 -2
  5. package/packages/contracts/src/terminal-runtime-inventory.ts +61 -1
  6. package/packages/contracts/src/tmux-server-scope.ts +18 -0
  7. package/packages/daemon/dist/command-center/resources/terminal-runtime-inventory.js +42 -2
  8. package/packages/daemon/dist/command-center/tmux-servers.js +17 -7
  9. package/packages/daemon/dist/lib/tmux-server-owner.js +4 -2
  10. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Info.plist +2 -2
  11. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/MacOS/tmux-ide-notifier +0 -0
  12. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Resources/Assets.car +0 -0
  13. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/_CodeSignature/CodeResources +2 -2
  14. package/packages/daemon/dist/terminal/mirror/session-channel.js +6 -1
  15. package/packages/daemon/dist/terminal/pane-stream/lease-manager.js +1 -0
  16. package/packages/daemon/dist/terminal/pane-stream/pane-stream-websocket.js +98 -22
  17. package/packages/daemon/dist/terminal/protocol/browser-icon.js +1 -1
  18. package/packages/daemon/dist/terminal/protocol/session-descriptor-discovery.js +26 -3
  19. package/packages/daemon/dist/terminal/session-runtime/registry.js +1 -0
  20. package/packages/daemon/dist/terminal/session-runtime/terminal-delivery-hub.js +121 -6
  21. package/packages/daemon/dist/terminal/session-runtime/terminal-replica-interpreter.js +2 -0
  22. package/packages/daemon/dist/terminal/session-runtime/xterm-terminal-interpreter-backend.js +51 -4
  23. package/packages/daemon/src/command-center/resources/terminal-runtime-inventory.ts +48 -1
  24. package/packages/daemon/src/command-center/tmux-servers.ts +19 -6
  25. package/packages/daemon/src/lib/tmux-server-owner.ts +6 -3
  26. package/packages/daemon/src/terminal/mirror/events.ts +2 -0
  27. package/packages/daemon/src/terminal/mirror/session-channel.ts +8 -1
  28. package/packages/daemon/src/terminal/pane-stream/lease-manager.ts +3 -0
  29. package/packages/daemon/src/terminal/pane-stream/pane-stream-websocket.ts +111 -20
  30. package/packages/daemon/src/terminal/protocol/browser-icon.ts +1 -1
  31. package/packages/daemon/src/terminal/protocol/session-descriptor-discovery.ts +32 -2
  32. package/packages/daemon/src/terminal/session-runtime/registry.ts +1 -0
  33. package/packages/daemon/src/terminal/session-runtime/terminal-delivery-hub.ts +136 -6
  34. package/packages/daemon/src/terminal/session-runtime/terminal-interpreter-backend.ts +6 -0
  35. package/packages/daemon/src/terminal/session-runtime/terminal-replica-interpreter.ts +2 -0
  36. package/packages/daemon/src/terminal/session-runtime/xterm-terminal-interpreter-backend.ts +67 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tmux-ide",
3
- "version": "2.9.25",
3
+ "version": "2.9.26",
4
4
  "description": "The open-source workspace for coding agents: run Claude Code, Codex and other agents in tmux with live status",
5
5
  "type": "module",
6
6
  "bin": {
@@ -39,6 +39,7 @@
39
39
  "test:tmux-boundary": "node scripts/test-tmux-boundary.mjs",
40
40
  "build": "pnpm build:cli",
41
41
  "build:cli": "node scripts/build-cli.mjs",
42
+ "check:cli-bundle": "node scripts/check-cli-bundle.mjs",
42
43
  "build:macos-notifier": "node scripts/build-macos-notifier.mjs",
43
44
  "build:tui": "bun scripts/build-tui.mjs",
44
45
  "prepack": "pnpm build:cli",
@@ -136,6 +136,14 @@ export const PaneStreamLeaseRequestSchemaZ = z
136
136
  viewerMode: PaneStreamViewerModeSchemaZ,
137
137
  /** Explicit semantic-v2 content/authority mode. Omission retains raw v1. */
138
138
  terminalDelivery: TerminalDeliveryOfferSchemaZ.optional(),
139
+ /**
140
+ * #806: a stream for one window. `panes` must be exactly that window's
141
+ * panes (at most PANE_STREAM_MAX_PANES), so a session with more panes in
142
+ * all can be viewed window by window. Under capability 119/120 the stream
143
+ * follows that window's pane set in place; other windows never enter.
144
+ * Released daemons refuse the field: send it only to a daemon that has it.
145
+ */
146
+ semanticWindowId: TerminalAttachmentSemanticWindowIdSchemaZ.optional(),
139
147
  })
140
148
  .strict();
141
149
  export type PaneStreamLeaseRequest = z.infer<typeof PaneStreamLeaseRequestSchemaZ>;
@@ -257,6 +265,12 @@ export const PANE_STREAM_BROWSER_ICON_CAPABILITY_VERSION = 117;
257
265
  * Offered in place of 117 because the offer array has nine slots.
258
266
  */
259
267
  export const PANE_STREAM_READER_CAPABILITY_VERSION = 118;
268
+ /**
269
+ * #718: layout panes carry `browserKind` ("native" | "plain" | null), so a
270
+ * client can say why a plain terminal browser has no tmux-ide controls.
271
+ * Sent only to a client offering 123; older clients refuse the field.
272
+ */
273
+ export const PANE_STREAM_BROWSER_KIND_CAPABILITY_VERSION = 123;
260
274
  /**
261
275
  * The client keeps its stream when the session gains or loses a pane (#723):
262
276
  * the daemon sends a `topology` frame where it would otherwise close the
@@ -588,6 +602,11 @@ export const PaneStreamLayoutFrameSchemaZ = z
588
602
  .regex(/^(?:[0-9a-f]{2048})?$/u)
589
603
  .nullable()
590
604
  .optional(),
605
+ /**
606
+ * Only with capability 123: a terminal browser with tmux-ide's
607
+ * native controls, a plain one without them, or null.
608
+ */
609
+ browserKind: z.enum(["native", "plain"]).nullable().optional(),
591
610
  /** Only with capability 118: the Markdown reader's file name, never its path. */
592
611
  reader: z
593
612
  .object({
@@ -20,6 +20,8 @@ export const TERMINAL_DELIVERY_BINARY_CAPABILITY_VERSION = 109;
20
20
  export const TERMINAL_DELIVERY_BINARY_LOCAL_CAPABILITY_VERSION = 110;
21
21
 
22
22
  export const TERMINAL_DELIVERY_PROTOCOL_VERSION = 1 as const;
23
+ /** Capability numbers one offer may carry (nine before 2.9.26). */
24
+ export const TERMINAL_DELIVERY_MAX_OFFERED_VERSIONS = 16;
23
25
  export const TERMINAL_DELIVERY_CHUNK_BYTES = 256 * 1024;
24
26
  export const TERMINAL_DELIVERY_PATCH_TO_SEED_BYTES = 512 * 1024;
25
27
  export const TERMINAL_DELIVERY_MAX_REPRESENTATION_BYTES = 16 * 1024 * 1024;
@@ -35,8 +37,12 @@ export type TerminalDeliveryEncoding = z.infer<typeof TerminalDeliveryEncodingSc
35
37
 
36
38
  export const TerminalDeliveryOfferSchemaZ = z
37
39
  .object({
38
- // Interactive binary/graphics offers use eight slots; native surfaces add one.
39
- protocolVersions: z.array(z.number().int().positive()).min(1).max(9),
40
+ // Released daemons before 2.9.26 refuse more than nine numbers, so a client
41
+ // offers a tenth only to a daemon whose productVersion is 2.9.26 or later.
42
+ protocolVersions: z
43
+ .array(z.number().int().positive())
44
+ .min(1)
45
+ .max(TERMINAL_DELIVERY_MAX_OFFERED_VERSIONS),
40
46
  encodings: z.array(TerminalDeliveryEncodingSchemaZ).min(1).max(4),
41
47
  richPlacements: z.boolean(),
42
48
  })
@@ -2,7 +2,10 @@ import { z } from "zod";
2
2
 
3
3
  import { DaemonInstanceIdentitySchemaZ } from "./daemon-wire.ts";
4
4
  import { DesktopWorkspaceNameSchemaZ } from "./desktop-workspace-name.ts";
5
- import { TerminalAttachmentSemanticPaneIdSchemaZ } from "./terminal-attachments.ts";
5
+ import {
6
+ TerminalAttachmentSemanticPaneIdSchemaZ,
7
+ TerminalAttachmentSemanticWindowIdSchemaZ,
8
+ } from "./terminal-attachments.ts";
6
9
  import { FleetSessionIdSchemaZ } from "./fleet-catalog.ts";
7
10
  import { SemanticProductIdSchemaZ } from "./pane-appearance.ts";
8
11
 
@@ -30,6 +33,63 @@ export type TerminalRuntimeInventoryProjectionV1 = z.infer<
30
33
  typeof TerminalRuntimeInventoryProjectionV1SchemaZ
31
34
  >;
32
35
 
36
+ /**
37
+ * #806: version 2 also names each window with its panes, so a client can issue
38
+ * a pane stream for one window (`semanticWindowId` plus exactly these panes).
39
+ * A window is listed only when every pane in it is available; a client that
40
+ * asks for version 2 of an older daemon gets version 1 and has no windows.
41
+ */
42
+ export const TerminalRuntimeInventoryWindowSchemaZ = z
43
+ .object({
44
+ semanticWindowId: TerminalAttachmentSemanticWindowIdSchemaZ,
45
+ /** tmux's current window of the session. */
46
+ active: z.boolean(),
47
+ semanticPaneIds: z
48
+ .array(TerminalAttachmentSemanticPaneIdSchemaZ)
49
+ .min(1)
50
+ .max(256)
51
+ .refine((values) => new Set(values).size === values.length, "pane ids must be unique"),
52
+ })
53
+ .strict();
54
+ export type TerminalRuntimeInventoryWindow = z.infer<typeof TerminalRuntimeInventoryWindowSchemaZ>;
55
+
56
+ export const TerminalRuntimeInventoryProjectionV2SchemaZ =
57
+ TerminalRuntimeInventoryProjectionV1SchemaZ.extend({
58
+ /** In tmux window order. */
59
+ windows: z.array(TerminalRuntimeInventoryWindowSchemaZ).max(256),
60
+ })
61
+ .strict()
62
+ .superRefine((value, ctx) => {
63
+ const listed = new Set(value.semanticPaneIds);
64
+ const seen = new Set<string>();
65
+ const windows = new Set<string>();
66
+ let active = 0;
67
+ for (const window of value.windows) {
68
+ if (windows.has(window.semanticWindowId))
69
+ ctx.addIssue({ code: "custom", message: "a window is listed twice", path: ["windows"] });
70
+ windows.add(window.semanticWindowId);
71
+ if (window.active) active += 1;
72
+ for (const pane of window.semanticPaneIds) {
73
+ if (!listed.has(pane) || seen.has(pane))
74
+ ctx.addIssue({
75
+ code: "custom",
76
+ message: "a window pane must be listed once and in the inventory",
77
+ path: ["windows"],
78
+ });
79
+ seen.add(pane);
80
+ }
81
+ }
82
+ if (active > 1)
83
+ ctx.addIssue({
84
+ code: "custom",
85
+ message: "at most one window is active",
86
+ path: ["windows"],
87
+ });
88
+ });
89
+ export type TerminalRuntimeInventoryProjectionV2 = z.infer<
90
+ typeof TerminalRuntimeInventoryProjectionV2SchemaZ
91
+ >;
92
+
33
93
  export const TerminalRuntimeInventoryResourceV1SchemaZ = z
34
94
  .object({
35
95
  version: z.literal(TERMINAL_RUNTIME_INVENTORY_RESOURCE_VERSION),
@@ -205,6 +205,24 @@ export const TmuxServerSessionsResourceV2SchemaZ = z
205
205
  .strict();
206
206
  export type TmuxServerSessionsResourceV2 = z.infer<typeof TmuxServerSessionsResourceV2SchemaZ>;
207
207
 
208
+ /**
209
+ * #806: version 3 adds the pane count of the session's largest window, so Home
210
+ * can tell whether a session opens window by window (at most 24 panes per
211
+ * window) before opening it. Versions 1 and 2 stay as they were.
212
+ */
213
+ export const TmuxServerSessionsResourceV3SchemaZ = z
214
+ .object({
215
+ version: z.literal(3),
216
+ server: TmuxServerScopeSchemaZ,
217
+ sessions: z.array(
218
+ TmuxServerSessionsResourceV2SchemaZ.shape.sessions.element
219
+ .extend({ largestWindowPaneCount: z.number().int().min(1) })
220
+ .strict(),
221
+ ),
222
+ })
223
+ .strict();
224
+ export type TmuxServerSessionsResourceV3 = z.infer<typeof TmuxServerSessionsResourceV3SchemaZ>;
225
+
208
226
  /** Selector intent is interpreted only by the daemon on its own host. */
209
227
  export const TmuxServerRegistrationRequestSchemaZ = z
210
228
  .object({
@@ -1,5 +1,5 @@
1
- import { TERMINAL_RUNTIME_INVENTORY_RESOURCE_VERSION, TerminalRuntimeInventoryProjectionV1SchemaZ, } from "@tmux-ide/contracts";
2
- import { projectApplicationShellResource } from "./application-shell.js";
1
+ import { TERMINAL_RUNTIME_INVENTORY_RESOURCE_VERSION, TerminalRuntimeInventoryProjectionV1SchemaZ, TerminalRuntimeInventoryProjectionV2SchemaZ, } from "@tmux-ide/contracts";
2
+ import { paneIdentities, projectApplicationShellResource } from "./application-shell.js";
3
3
  /** Pure, wire-safe agent-free topology projection. */
4
4
  export function projectTerminalRuntimeInventory(session, resourceRevision) {
5
5
  const shell = projectApplicationShellResource(session);
@@ -15,6 +15,46 @@ export function projectTerminalRuntimeInventory(session, resourceRevision) {
15
15
  ].sort(),
16
16
  });
17
17
  }
18
+ /**
19
+ * #806: version 1 plus each window and its panes, in tmux order. A window is
20
+ * named only when it has a verified window stamp and every pane in it is
21
+ * available, so its pane set is one a window-scoped issue can accept.
22
+ */
23
+ export function projectTerminalRuntimeInventoryV2(session, resourceRevision) {
24
+ const identities = paneIdentities(session);
25
+ const windows = new Map();
26
+ session.panes.forEach((pane, index) => {
27
+ if (pane.windowId === undefined)
28
+ return;
29
+ const stamp = pane.windowStamp ?? null;
30
+ const entry = windows.get(pane.windowId) ?? {
31
+ semanticWindowId: stamp,
32
+ active: false,
33
+ panes: [],
34
+ complete: true,
35
+ };
36
+ windows.set(pane.windowId, entry);
37
+ const attachability = identities[index].attachability;
38
+ if (attachability.status === "available")
39
+ entry.panes.push(attachability.semanticPaneId);
40
+ else
41
+ entry.complete = false;
42
+ if (pane.active)
43
+ entry.active = true;
44
+ });
45
+ return TerminalRuntimeInventoryProjectionV2SchemaZ.parse({
46
+ ...projectTerminalRuntimeInventory(session, resourceRevision),
47
+ windows: [...windows.values()].flatMap((window) => window.complete && window.semanticWindowId !== null && window.panes.length > 0
48
+ ? [
49
+ {
50
+ semanticWindowId: window.semanticWindowId,
51
+ active: window.active,
52
+ semanticPaneIds: [...window.panes].sort(),
53
+ },
54
+ ]
55
+ : []),
56
+ });
57
+ }
18
58
  export function terminalRuntimeInventoryEnvelope(daemon, session, resourceRevision) {
19
59
  return {
20
60
  version: TERMINAL_RUNTIME_INVENTORY_RESOURCE_VERSION,
@@ -11,7 +11,7 @@ import { streamSSE } from "hono/streaming";
11
11
  import { projectApplicationShellResource } from "./resources/application-shell.js";
12
12
  import { fleetSessionIdForName } from "./resources/fleet-catalog.js";
13
13
  import { z } from "zod";
14
- import { TmuxAgentOpenRequestSchemaZ, TmuxAgentOpenResponseSchemaZ, WorkspaceCatalogLiveSessionIdSchemaZ, WindowLinkTargetSchemaZ, WindowSplitLayoutResourceSchemaZ, TMUX_SERVERS_API_PATH, PANE_STREAM_ISSUE_PATH, TmuxServerIdSchemaZ, TmuxServerScopeSchemaZ, TmuxServersResourceSchemaZ, TmuxServerSessionsResourceSchemaZ, TmuxServerSessionsResourceV2SchemaZ, WorkspaceMultiplexerMutationRequestSchemaZ, WorkspacePaneCreateMutationRequestSchemaZ, WorkspaceSessionCreateArgumentsSchemaZ, } from "@tmux-ide/contracts";
14
+ import { TmuxAgentOpenRequestSchemaZ, TmuxAgentOpenResponseSchemaZ, WorkspaceCatalogLiveSessionIdSchemaZ, WindowLinkTargetSchemaZ, WindowSplitLayoutResourceSchemaZ, TMUX_SERVERS_API_PATH, PANE_STREAM_ISSUE_PATH, TmuxServerIdSchemaZ, TmuxServerScopeSchemaZ, TmuxServersResourceSchemaZ, TmuxServerSessionsResourceSchemaZ, TmuxServerSessionsResourceV2SchemaZ, TmuxServerSessionsResourceV3SchemaZ, WorkspaceMultiplexerMutationRequestSchemaZ, WorkspacePaneCreateMutationRequestSchemaZ, WorkspaceSessionCreateArgumentsSchemaZ, } from "@tmux-ide/contracts";
15
15
  import { TmuxServerRegistrationSchemaZ, TmuxServerScopeError, } from "../lib/tmux-server-owners.js";
16
16
  import { createSessionFaviconResolver } from "../lib/session-favicon.js";
17
17
  import { WorkspaceMultiplexerError } from "../lib/workspace-multiplexer-verbs.js";
@@ -19,7 +19,7 @@ import { WorkspacePaneCreationError } from "../lib/workspace-pane-creation.js";
19
19
  import { ownerBearerMatches } from "./owner-authority.js";
20
20
  import { logger } from "../lib/log.js";
21
21
  import { mountPaneStreamIssueRoute } from "./pane-stream-issue.js";
22
- import { projectTerminalRuntimeInventory } from "./resources/terminal-runtime-inventory.js";
22
+ import { projectTerminalRuntimeInventory, projectTerminalRuntimeInventoryV2, } from "./resources/terminal-runtime-inventory.js";
23
23
  /** Total raw favicon bytes one version 2 sessions response may carry. */
24
24
  export const SESSIONS_RESOURCE_FAVICON_BUDGET_BYTES = 512 * 1024;
25
25
  const registrationSchema = TmuxServerRegistrationSchemaZ.omit({ serverId: true }).strict();
@@ -206,7 +206,9 @@ export function mountTmuxServerRoutes(app, options) {
206
206
  }));
207
207
  app.get(`${scoped}/sessions`, route(async (c) => {
208
208
  const server = scope(c);
209
- const v2 = c.req.query("version") === "2";
209
+ // #806: version 3 is version 2 plus the largest window's pane count.
210
+ const v3 = c.req.query("version") === "3";
211
+ const v2 = v3 || c.req.query("version") === "2";
210
212
  const { rows, favicons } = await options.owners.withOwner(server, async (owner) => {
211
213
  const sessions = await owner.catalog();
212
214
  const workspaces = owner.workspaceRegistry.list();
@@ -231,8 +233,9 @@ export function mountTmuxServerRoutes(app, options) {
231
233
  })),
232
234
  }));
233
235
  let budget = SESSIONS_RESOURCE_FAVICON_BUDGET_BYTES;
234
- return c.json(TmuxServerSessionsResourceV2SchemaZ.parse({
235
- version: 2,
236
+ const schema = v3 ? TmuxServerSessionsResourceV3SchemaZ : TmuxServerSessionsResourceV2SchemaZ;
237
+ return c.json(schema.parse({
238
+ version: v3 ? 3 : 2,
236
239
  server,
237
240
  sessions: rows.map(({ session, workspaceName }, index) => {
238
241
  const found = favicons[index] ?? null;
@@ -245,6 +248,7 @@ export function mountTmuxServerRoutes(app, options) {
245
248
  workspaceName,
246
249
  paneCount: session.paneCount,
247
250
  windowCount: session.windowCount,
251
+ ...(v3 ? { largestWindowPaneCount: session.largestWindowPaneCount } : {}),
248
252
  lastActivity: session.lastActivity,
249
253
  favicon: favicon ? { mime: favicon.mime, data: favicon.data } : null,
250
254
  };
@@ -262,6 +266,8 @@ export function mountTmuxServerRoutes(app, options) {
262
266
  app.get(`${scoped}/inventory/:workspaceName`, route(async (c) => {
263
267
  const server = scope(c);
264
268
  const workspaceName = workspaceSchema.parse(c.req.param("workspaceName"));
269
+ // #806: version 2 also names each window and its panes.
270
+ const v2 = c.req.query("version") === "2";
265
271
  const resource = await options.owners.withOwner(server, async (owner) => {
266
272
  const sessions = await owner.catalog();
267
273
  const workspace = owner.workspaceRegistry.get(workspaceName);
@@ -272,10 +278,14 @@ export function mountTmuxServerRoutes(app, options) {
272
278
  !sessions.some((row) => row.sessionName === workspace.sessionName && row.liveSessionId === expected))
273
279
  throw new TmuxServerScopeError("stale-generation");
274
280
  const snapshot = await owner.terminalInventoryRuntime.discoverTerminalRuntimeSession(workspace.sessionName, c.req.raw.signal);
275
- return snapshot ? projectTerminalRuntimeInventory(snapshot, 0) : null;
281
+ if (!snapshot)
282
+ return null;
283
+ return v2
284
+ ? projectTerminalRuntimeInventoryV2(snapshot, 0)
285
+ : projectTerminalRuntimeInventory(snapshot, 0);
276
286
  });
277
287
  return resource
278
- ? c.json({ version: 1, server, resource })
288
+ ? c.json({ version: v2 ? 2 : 1, server, resource })
279
289
  : c.json({ error: { code: "workspace-not-found" } }, 404);
280
290
  }));
281
291
  app.get(`${scoped}/catalog`, route(async (c) => {
@@ -121,12 +121,13 @@ onTrouble) {
121
121
  const row = rows.get(liveSessionId) ?? {
122
122
  summary: { liveSessionId, sessionName: name, paneCount: 0 },
123
123
  panes: new Set(),
124
- windows: new Set(),
124
+ windows: new Map(),
125
125
  dir,
126
126
  activity: activity && /^\d+$/.test(activity) ? Number(activity) : null,
127
127
  };
128
+ if (!row.panes.has(pane))
129
+ row.windows.set(window, (row.windows.get(window) ?? 0) + 1);
128
130
  row.panes.add(pane);
129
- row.windows.add(window);
130
131
  rows.set(liveSessionId, row);
131
132
  }
132
133
  const names = new Set([...rows.values()].map(({ summary }) => summary.sessionName));
@@ -145,6 +146,7 @@ onTrouble) {
145
146
  ...summary,
146
147
  paneCount: panes.size,
147
148
  windowCount: windows.size,
149
+ largestWindowPaneCount: Math.max(...windows.values()),
148
150
  lastActivity: activity,
149
151
  sessionPath: dir,
150
152
  }));
@@ -21,9 +21,9 @@
21
21
  <key>CFBundlePackageType</key>
22
22
  <string>APPL</string>
23
23
  <key>CFBundleShortVersionString</key>
24
- <string>2.9.25</string>
24
+ <string>2.9.26</string>
25
25
  <key>CFBundleVersion</key>
26
- <string>2.9.25</string>
26
+ <string>2.9.26</string>
27
27
  <key>LSMinimumSystemVersion</key>
28
28
  <string>11.0</string>
29
29
  <key>LSUIElement</key>
@@ -10,7 +10,7 @@
10
10
  </data>
11
11
  <key>Resources/Assets.car</key>
12
12
  <data>
13
- 7L0fXtCk10AeTcenMDtoPnTE9Qo=
13
+ vCGQEYGoc/hxKRik4536rZeOyzI=
14
14
  </data>
15
15
  </dict>
16
16
  <key>files2</key>
@@ -26,7 +26,7 @@
26
26
  <dict>
27
27
  <key>hash2</key>
28
28
  <data>
29
- DHqrNoKM8WzcXeuCicvLfyxe5ANT6B5xPmqAVvoF3zs=
29
+ YpwfBnJnj+KlpeQ27JX9G6+7YYKfAwTW97PEFohYyuE=
30
30
  </data>
31
31
  </dict>
32
32
  </dict>
@@ -366,6 +366,8 @@ export class SessionChannel {
366
366
  await this.captureAttachedSessionIdentity();
367
367
  this.io.send("refresh-client -B 'tmux-ide-browser-icon:%*:#{@tmux_ide_browser_icon}'");
368
368
  this.io.send("refresh-client -B 'tmux-ide-reader:%*:#{@tmux_ide_reader}'");
369
+ // #718: a browser's controls appear, or a plain terminal browser starts or exits.
370
+ this.io.send("refresh-client -B 'tmux-ide-browser-kind:%*:#{@tmux_ide_browser_control}#{m:terminal-browse*,#{pane_current_command}}'");
369
371
  // Changing border placement can resize PTYs without changing the layout
370
372
  // string, so tmux emits no layout-change. Subscribe to this window option.
371
373
  this.io.send("refresh-client -B 'tmux-ide-pane-borders:@*:#{pane-border-status}'");
@@ -2292,7 +2294,9 @@ export class SessionChannel {
2292
2294
  name === "sessions-changed")
2293
2295
  this.opts.onWindowTopologyChanged?.();
2294
2296
  if (name === "subscription-changed" &&
2295
- (rest.startsWith("tmux-ide-browser-icon ") || rest.startsWith("tmux-ide-reader "))) {
2297
+ (rest.startsWith("tmux-ide-browser-icon ") ||
2298
+ rest.startsWith("tmux-ide-reader ") ||
2299
+ rest.startsWith("tmux-ide-browser-kind "))) {
2296
2300
  this.scheduleSync();
2297
2301
  return;
2298
2302
  }
@@ -2696,6 +2700,7 @@ export class SessionChannel {
2696
2700
  displayName: display?.name ?? null,
2697
2701
  displayNameSource: display?.source ?? null,
2698
2702
  browserIcon: pane?.descriptor?.browserIcon ?? null,
2703
+ browserKind: pane?.descriptor?.browserKind ?? null,
2699
2704
  reader: pane?.descriptor?.reader ?? null,
2700
2705
  left: leaf.left,
2701
2706
  top: leaf.top,
@@ -235,6 +235,7 @@ export class PaneStreamLeaseManager {
235
235
  sessionName: state.sessionName,
236
236
  runtimeSessionId: state.runtimeSessionId,
237
237
  panes: [...state.request.panes],
238
+ semanticWindowId: state.request.semanticWindowId ?? null,
238
239
  viewerMode: state.request.viewerMode,
239
240
  terminalDelivery: state.request.terminalDelivery ?? null,
240
241
  status: state.status,
@@ -2,7 +2,7 @@ import { TERMINAL_SURFACE_MAX_CONTROL_BYTES, TERMINAL_SURFACE_CAPABILITY_VERSION
2
2
  import { NativeSurfaceViewer } from "../graphics/native-surface-viewer.js";
3
3
  import { compressGraphicsChunk } from "../graphics/compress-chunk.js";
4
4
  import { TERMINAL_GRAPHICS_COMPRESSED_CAPABILITY_VERSION, TERMINAL_GRAPHICS_COMPRESSED_LOCAL_CAPABILITY_VERSION, TERMINAL_PROJECTION_CAPABILITY_VERSION, TERMINAL_PROJECTION_LOCAL_CAPABILITY_VERSION, } from "@tmux-ide/contracts";
5
- import { PANE_STREAM_INPUT_LIFETIME_CAPABILITY_VERSION, PANE_STREAM_INPUT_BYTES_CAPABILITY_VERSION, PANE_STREAM_BROWSER_ICON_CAPABILITY_VERSION, PANE_STREAM_READER_CAPABILITY_VERSION, PANE_STREAM_READER_TOPOLOGY_BUNDLE_CAPABILITY_VERSION, PANE_STREAM_TOPOLOGY_IN_PLACE_CAPABILITY_VERSION, } from "@tmux-ide/contracts";
5
+ import { PANE_STREAM_INPUT_LIFETIME_CAPABILITY_VERSION, PANE_STREAM_INPUT_BYTES_CAPABILITY_VERSION, PANE_STREAM_BROWSER_ICON_CAPABILITY_VERSION, PANE_STREAM_READER_CAPABILITY_VERSION, PANE_STREAM_BROWSER_KIND_CAPABILITY_VERSION, PANE_STREAM_READER_TOPOLOGY_BUNDLE_CAPABILITY_VERSION, PANE_STREAM_TOPOLOGY_IN_PLACE_CAPABILITY_VERSION, } from "@tmux-ide/contracts";
6
6
  import { inflateSync } from "node:zlib";
7
7
  import { PaneStreamLayoutSnapshotFrameSchemaZ } from "@tmux-ide/contracts";
8
8
  import { z } from "zod";
@@ -259,6 +259,16 @@ export class PaneStreamAdmissionCoordinator {
259
259
  throw new PaneStreamAdmissionError("pane-not-found", `The pane ${pane} is not present in the workspace session.`);
260
260
  }
261
261
  }
262
+ // #806: a stream for one window is issued for exactly that window's
263
+ // panes, as the trusted inventory places them now.
264
+ if (request.semanticWindowId !== undefined) {
265
+ const windowPanes = new Set(described.panes
266
+ .filter((pane) => pane.semanticWindowId === request.semanticWindowId)
267
+ .map((pane) => pane.semanticPaneId));
268
+ if (windowPanes.size !== request.panes.length ||
269
+ request.panes.some((pane) => !windowPanes.has(pane)))
270
+ throw new PaneStreamAdmissionError("pane-not-found", "The panes are not exactly the panes of that window of the workspace session.");
271
+ }
262
272
  const issued = await this.#leaseManager.issue(request, {
263
273
  requestId,
264
274
  projectIdentity,
@@ -1063,7 +1073,7 @@ export class PaneStreamLiveConnection {
1063
1073
  * stream with 1011, and nothing was tried twice. A refusal of authority is a
1064
1074
  * decision, not a failure, and is never repeated. Each repeat is logged.
1065
1075
  */
1066
- async #retryOpenStep(step, run) {
1076
+ async #retryOpenStep(step, run, final = () => false) {
1067
1077
  for (let attempt = 0;; attempt += 1) {
1068
1078
  try {
1069
1079
  return await run();
@@ -1072,7 +1082,8 @@ export class PaneStreamLiveConnection {
1072
1082
  const delayMs = this.#openRetryDelaysMs[attempt];
1073
1083
  if (delayMs === undefined ||
1074
1084
  this.#closed ||
1075
- error instanceof SessionRuntimeControllerLeaseError)
1085
+ error instanceof SessionRuntimeControllerLeaseError ||
1086
+ final(error))
1076
1087
  throw error;
1077
1088
  logger.info("pane-stream", "stream open step failed; trying again", {
1078
1089
  session: this.#descriptor.sessionName,
@@ -1108,25 +1119,40 @@ export class PaneStreamLiveConnection {
1108
1119
  let stagedAuthority = null;
1109
1120
  let authorityMalformed = false;
1110
1121
  let layoutActivated = false;
1122
+ let layoutAttempt = 0;
1111
1123
  // Establish the single session layout observer first. MirrorService owns
1112
1124
  // this lifecycle and may share native control state with delivery setup;
1113
1125
  // only the independent pane delivery opens below are parallelized.
1114
1126
  try {
1115
- if (!this.#mirror.subscribeLayout)
1127
+ const subscribeLayout = this.#mirror.subscribeLayout?.bind(this.#mirror);
1128
+ if (!subscribeLayout)
1116
1129
  throw new Error("authoritative layout is unavailable");
1117
- const subscription = await this.#mirror.subscribeLayout(this.#descriptor.sessionName, () => undefined, {
1118
- expectedSemanticPaneIds: expectedPaneIds,
1119
- expectedRuntimeSessionId: this.#descriptor.runtimeSessionId,
1120
- onAuthority: (snapshot) => {
1121
- this.#recordDiagnosticLifecycle("pane-stream-layout-staged");
1122
- if (snapshot.layouts.length > PANE_STREAM_MAX_PANES)
1123
- authorityMalformed = true;
1124
- else if (!layoutActivated)
1125
- stagedAuthority = snapshot;
1126
- else
1127
- this.#onLayoutAuthority(snapshot);
1128
- },
1129
- });
1130
+ // The session's trusted inventory can be unsettled for a moment after a
1131
+ // pane change ("lacks verified identity"): a stream re-issued at once
1132
+ // closed 1011 while the next, 100 ms later, opened. Try again, as the
1133
+ // other opening steps do (#585). A changed pane set is a decision, not
1134
+ // a failure, and still closes 1012 at once. A try that failed is
1135
+ // disowned: its authority callback is ignored.
1136
+ const subscription = await this.#retryOpenStep("semantic-layout-subscribe", () => {
1137
+ const attempt = ++layoutAttempt;
1138
+ stagedAuthority = null;
1139
+ authorityMalformed = false;
1140
+ return subscribeLayout(this.#descriptor.sessionName, () => undefined, {
1141
+ expectedSemanticPaneIds: expectedPaneIds,
1142
+ expectedRuntimeSessionId: this.#descriptor.runtimeSessionId,
1143
+ onAuthority: (snapshot) => {
1144
+ if (attempt !== layoutAttempt)
1145
+ return;
1146
+ this.#recordDiagnosticLifecycle("pane-stream-layout-staged");
1147
+ if (snapshot.layouts.length > PANE_STREAM_MAX_PANES)
1148
+ authorityMalformed = true;
1149
+ else if (!layoutActivated)
1150
+ stagedAuthority = snapshot;
1151
+ else
1152
+ this.#onLayoutAuthority(snapshot);
1153
+ },
1154
+ });
1155
+ }, (error) => error instanceof Error && error.name === "MirrorTopologyChangedError");
1130
1156
  if (this.#closed) {
1131
1157
  await subscription.close().catch(() => undefined);
1132
1158
  return;
@@ -1920,13 +1946,17 @@ export class PaneStreamLiveConnection {
1920
1946
  return;
1921
1947
  }
1922
1948
  const frames = this.#validateInitialLayout(snapshot.layouts, this.#semanticExpectedPaneIds);
1923
- if (!frames && this.#topologyInPlace) {
1949
+ // #806: a pane can also move between windows while the session keeps its
1950
+ // panes; for a stream of one window that changes its pane set.
1951
+ const windowChanged = frames !== null && this.#windowPaneSetChanged(snapshot);
1952
+ if ((!frames || windowChanged) && this.#topologyInPlace) {
1924
1953
  // The layout does not fit the pane set this stream knows. With
1925
1954
  // capability 119 that is a change to follow, not a reason to close.
1926
1955
  void this.#reconcileTopology(snapshot);
1927
1956
  return;
1928
1957
  }
1929
1958
  if (!frames ||
1959
+ windowChanged ||
1930
1960
  !PaneStreamLayoutSnapshotFrameSchemaZ.safeParse({
1931
1961
  type: "layout-snapshot",
1932
1962
  topologyEpoch: snapshot.topologyEpoch,
@@ -1952,6 +1982,22 @@ export class PaneStreamLiveConnection {
1952
1982
  windowLinks: snapshot.windowLinks,
1953
1983
  });
1954
1984
  }
1985
+ /** #806: the layout no longer shows this stream's window with exactly its panes. */
1986
+ #windowPaneSetChanged(snapshot) {
1987
+ const window = this.#descriptor.semanticWindowId;
1988
+ if (window === null)
1989
+ return false;
1990
+ const live = [...this.#panes.values()]
1991
+ .filter((channel) => !channel.closed)
1992
+ .map((channel) => channel.semanticPaneId);
1993
+ const shown = snapshot.layouts.find((event) => event.semanticWindowId === window);
1994
+ if (!shown)
1995
+ return true;
1996
+ const panes = shown.panes.map((pane) => pane.semanticPaneId ?? "");
1997
+ if (shown.zoomed)
1998
+ return panes.length !== 1 || !live.includes(panes[0]);
1999
+ return panes.length !== live.length || panes.some((pane) => !live.includes(pane));
2000
+ }
1955
2001
  /** The same session and runtime, a newer epoch, a layout a stream can carry. */
1956
2002
  #layoutAuthorityAdmissible(snapshot) {
1957
2003
  return (snapshot.session === this.#descriptor.sessionName &&
@@ -2074,12 +2120,37 @@ export class PaneStreamLiveConnection {
2074
2120
  windowLinks: snapshot.windowLinks,
2075
2121
  }).success)
2076
2122
  return this.#topologyFailed("layout snapshot invalid");
2123
+ // #806: a stream issued for one window follows that window's panes, as the
2124
+ // trusted inventory places them, and the same layout must show that window
2125
+ // with exactly those panes (a zoomed window shows one of them).
2126
+ const window = this.#descriptor.semanticWindowId;
2127
+ let windowPanes = null;
2128
+ if (window !== null) {
2129
+ windowPanes = [
2130
+ ...new Set(described.panes
2131
+ .filter((pane) => pane.semanticWindowId === window)
2132
+ .map((pane) => pane.semanticPaneId)),
2133
+ ].sort();
2134
+ if (windowPanes.length === 0)
2135
+ return this.#topologyFailed("the stream's window is gone");
2136
+ const shown = snapshot.layouts.find((event) => event.semanticWindowId === window);
2137
+ const shownPanes = (shown?.panes ?? []).map((pane) => pane.semanticPaneId ?? "");
2138
+ if (!shown ||
2139
+ (shown.zoomed
2140
+ ? shownPanes.length !== 1 || !windowPanes.includes(shownPanes[0])
2141
+ : shownPanes.length !== windowPanes.length ||
2142
+ shownPanes.some((pane) => !windowPanes.includes(pane))))
2143
+ return "stale";
2144
+ }
2145
+ const followed = windowPanes ?? next;
2077
2146
  const live = [...this.#panes.values()].filter((channel) => !channel.closed);
2078
- const removed = live.filter((channel) => !next.includes(channel.semanticPaneId));
2079
- // A stream issued for the whole session follows it; one issued for some
2080
- // panes keeps exactly those.
2147
+ const removed = live.filter((channel) => !followed.includes(channel.semanticPaneId));
2148
+ // A stream issued for the whole session follows it, and one issued for a
2149
+ // window follows that window; one issued for some panes keeps exactly those.
2081
2150
  const liveIds = new Set(live.map((channel) => channel.semanticPaneId));
2082
- const added = this.#leasesWholeSession ? next.filter((pane) => !liveIds.has(pane)) : [];
2151
+ const added = windowPanes !== null || this.#leasesWholeSession
2152
+ ? followed.filter((pane) => !liveIds.has(pane))
2153
+ : [];
2083
2154
  if (added.length > 0 && !inventoryIsThisSession)
2084
2155
  return this.#topologyFailed("inventory cannot prove the runtime session");
2085
2156
  const remaining = live.length - removed.length + added.length;
@@ -2245,6 +2316,9 @@ export class PaneStreamLiveConnection {
2245
2316
  ...(this.#offers(PANE_STREAM_READER_CAPABILITY_VERSION)
2246
2317
  ? { reader: pane.reader ? { name: pane.reader.name } : null }
2247
2318
  : {}),
2319
+ ...(this.#offers(PANE_STREAM_BROWSER_KIND_CAPABILITY_VERSION)
2320
+ ? { browserKind: pane.browserKind ?? null }
2321
+ : {}),
2248
2322
  left: pane.left,
2249
2323
  top: pane.top,
2250
2324
  width: pane.width,
@@ -3097,6 +3171,8 @@ export class PaneStreamLiveConnection {
3097
3171
  channel.sub.sendKey(data);
3098
3172
  else
3099
3173
  throw new Error("Byte input requires semantic runtime");
3174
+ // Its echo goes ahead of the connection's other panes (remote links).
3175
+ channel.delivery?.prioritize?.();
3100
3176
  let ackStartedAtMicros = null;
3101
3177
  let ackStartedAtSharedMicros = null;
3102
3178
  if (trace) {
@@ -5,7 +5,7 @@ export function browserIcon(value, alive = processAlive) {
5
5
  return null;
6
6
  return match[2];
7
7
  }
8
- function processAlive(pid) {
8
+ export function processAlive(pid) {
9
9
  try {
10
10
  process.kill(pid, 0);
11
11
  return true;