tmux-ide 2.9.25 → 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 (67) hide show
  1. package/README.md +1 -1
  2. package/bin/cli.js +1577 -559
  3. package/package.json +3 -2
  4. package/packages/contracts/src/pane-stream.ts +28 -0
  5. package/packages/contracts/src/terminal-delivery.ts +122 -5
  6. package/packages/contracts/src/terminal-runtime-inventory.ts +61 -1
  7. package/packages/contracts/src/tmux-server-scope.ts +18 -0
  8. package/packages/core/src/index.ts +1 -0
  9. package/packages/core/src/terminal-delivery-binary.ts +8 -7
  10. package/packages/core/src/terminal-delivery.ts +174 -3
  11. package/packages/core/src/terminal-partial-history.ts +152 -0
  12. package/packages/core/src/terminal-replica.ts +70 -1
  13. package/packages/daemon/dist/command-center/owner-keep-alive.js +30 -0
  14. package/packages/daemon/dist/command-center/resources/terminal-runtime-inventory.js +42 -2
  15. package/packages/daemon/dist/command-center/server.js +3 -0
  16. package/packages/daemon/dist/command-center/tmux-server-attach.js +51 -0
  17. package/packages/daemon/dist/command-center/tmux-servers.js +95 -7
  18. package/packages/daemon/dist/doctor.js +4 -4
  19. package/packages/daemon/dist/lib/app-config.js +7 -0
  20. package/packages/daemon/dist/lib/node-requirement.js +20 -0
  21. package/packages/daemon/dist/lib/require-supported-node.js +8 -0
  22. package/packages/daemon/dist/lib/tmux-server-owner.js +4 -2
  23. package/packages/daemon/dist/lib/tmux-server-session-open.js +38 -12
  24. package/packages/daemon/dist/lib/workspace-promotion.js +4 -4
  25. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Info.plist +2 -2
  26. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/MacOS/tmux-ide-notifier +0 -0
  27. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Resources/Assets.car +0 -0
  28. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/_CodeSignature/CodeResources +2 -2
  29. package/packages/daemon/dist/server/pane-stream-upgrade.js +39 -1
  30. package/packages/daemon/dist/terminal/mirror/session-channel.js +6 -1
  31. package/packages/daemon/dist/terminal/pane-stream/lease-manager.js +1 -0
  32. package/packages/daemon/dist/terminal/pane-stream/pane-stream-websocket.js +112 -22
  33. package/packages/daemon/dist/terminal/protocol/browser-icon.js +1 -1
  34. package/packages/daemon/dist/terminal/protocol/session-descriptor-discovery.js +26 -3
  35. package/packages/daemon/dist/terminal/session-runtime/registry.js +2 -0
  36. package/packages/daemon/dist/terminal/session-runtime/terminal-delivery-hub.js +571 -33
  37. package/packages/daemon/dist/terminal/session-runtime/terminal-replica-interpreter.js +2 -0
  38. package/packages/daemon/dist/terminal/session-runtime/xterm-terminal-interpreter-backend.js +51 -4
  39. package/packages/daemon/dist/tui/mirror/open-tui-workspace-runtime-port.js +76 -2
  40. package/packages/daemon/dist/tui/mirror/theme.js +8 -1
  41. package/packages/daemon/src/command-center/attach-window-rule.cases.json +84 -0
  42. package/packages/daemon/src/command-center/owner-keep-alive.ts +38 -0
  43. package/packages/daemon/src/command-center/resources/terminal-runtime-inventory.ts +48 -1
  44. package/packages/daemon/src/command-center/server.ts +3 -0
  45. package/packages/daemon/src/command-center/tmux-server-attach.ts +75 -0
  46. package/packages/daemon/src/command-center/tmux-servers.ts +103 -6
  47. package/packages/daemon/src/doctor.ts +4 -4
  48. package/packages/daemon/src/lib/app-config.ts +15 -0
  49. package/packages/daemon/src/lib/node-requirement.ts +22 -0
  50. package/packages/daemon/src/lib/require-supported-node.ts +9 -0
  51. package/packages/daemon/src/lib/tmux-server-owner.ts +6 -3
  52. package/packages/daemon/src/lib/tmux-server-session-open.ts +53 -15
  53. package/packages/daemon/src/lib/workspace-promotion.ts +4 -4
  54. package/packages/daemon/src/server/pane-stream-upgrade.ts +41 -1
  55. package/packages/daemon/src/terminal/mirror/events.ts +2 -0
  56. package/packages/daemon/src/terminal/mirror/session-channel.ts +8 -1
  57. package/packages/daemon/src/terminal/pane-stream/lease-manager.ts +3 -0
  58. package/packages/daemon/src/terminal/pane-stream/pane-stream-websocket.ts +136 -20
  59. package/packages/daemon/src/terminal/protocol/browser-icon.ts +1 -1
  60. package/packages/daemon/src/terminal/protocol/session-descriptor-discovery.ts +32 -2
  61. package/packages/daemon/src/terminal/session-runtime/registry.ts +2 -0
  62. package/packages/daemon/src/terminal/session-runtime/terminal-delivery-hub.ts +696 -30
  63. package/packages/daemon/src/terminal/session-runtime/terminal-interpreter-backend.ts +6 -0
  64. package/packages/daemon/src/terminal/session-runtime/terminal-replica-interpreter.ts +2 -0
  65. package/packages/daemon/src/terminal/session-runtime/xterm-terminal-interpreter-backend.ts +67 -3
  66. package/packages/daemon/src/tui/mirror/open-tui-workspace-runtime-port.ts +82 -2
  67. package/packages/daemon/src/tui/mirror/theme.ts +13 -1
@@ -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,8 @@ 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 { chooseAttachSelection, TmuxServerAttachRequestSchemaZ } from "./tmux-server-attach.js";
23
+ import { projectTerminalRuntimeInventory, projectTerminalRuntimeInventoryV2, } from "./resources/terminal-runtime-inventory.js";
23
24
  /** Total raw favicon bytes one version 2 sessions response may carry. */
24
25
  export const SESSIONS_RESOURCE_FAVICON_BUDGET_BYTES = 512 * 1024;
25
26
  const registrationSchema = TmuxServerRegistrationSchemaZ.omit({ serverId: true }).strict();
@@ -204,9 +205,88 @@ export function mountTmuxServerRoutes(app, options) {
204
205
  const result = await options.owners.withOwner(server, (owner) => owner.openSession(workspaceSchema.parse(c.req.param("liveSessionId"))));
205
206
  return c.json({ version: 1, server, ...result });
206
207
  }));
208
+ // attach-rtt: open, inventory and issue in one round trip. The stream is
209
+ // issued through the ordinary issue route with this request's headers, so
210
+ // it is checked exactly as a separate issue request would be.
211
+ app.post(`${scoped}/sessions/:liveSessionId/attach`, route(async (c) => {
212
+ const server = scope(c);
213
+ const liveSessionId = workspaceSchema.parse(c.req.param("liveSessionId"));
214
+ const request = TmuxServerAttachRequestSchemaZ.parse(await boundedJson(c.req.raw));
215
+ // The issue below checks the same, but only after the open: refuse a
216
+ // request for another generation before it can promote anything.
217
+ if (request.issue.expectedDaemonInstanceId !== server.generation ||
218
+ c.req.header("X-Tmux-Ide-Expected-Daemon-Instance-Id") !== server.generation)
219
+ throw new TmuxServerScopeError("stale-generation");
220
+ const result = await options.owners.withOwner(server, async (owner) => {
221
+ const opened = await owner.openSession(liveSessionId);
222
+ const workspace = owner.workspaceRegistry.get(opened.workspaceName);
223
+ if (!workspace || opened.liveSessionId !== liveSessionId)
224
+ throw new TmuxServerScopeError("stale-generation");
225
+ const snapshot = await owner.terminalInventoryRuntime.discoverTerminalRuntimeSession(workspace.sessionName, c.req.raw.signal);
226
+ if (!snapshot)
227
+ return null;
228
+ const inventory = projectTerminalRuntimeInventoryV2(snapshot, 0);
229
+ const selection = chooseAttachSelection(inventory, request.preferredPane, request.maxPanes);
230
+ if (!selection)
231
+ return { kind: "attached", opened, inventory, selection, issue: null };
232
+ // The window is the daemon's to choose, never the client's.
233
+ const stream = { ...request.issue.stream };
234
+ delete stream.semanticWindowId;
235
+ const body = {
236
+ ...request.issue,
237
+ stream: {
238
+ ...stream,
239
+ workspaceName: opened.workspaceName,
240
+ panes: selection.panes,
241
+ ...(selection.semanticWindowId ? { semanticWindowId: selection.semanticWindowId } : {}),
242
+ },
243
+ };
244
+ const issueApp = new Hono();
245
+ mountPaneStreamIssueRoute(issueApp, {
246
+ daemonInstanceId: server.generation,
247
+ ownerToken: options.ownerToken,
248
+ workspaceRegistry: owner.workspaceRegistry,
249
+ backend: owner.paneStreamRuntime.coordinator,
250
+ });
251
+ const url = new URL(c.req.url);
252
+ url.pathname = PANE_STREAM_ISSUE_PATH;
253
+ url.search = "";
254
+ const headers = new Headers(c.req.raw.headers);
255
+ headers.delete("Content-Length");
256
+ headers.set("Content-Type", "application/json");
257
+ const issued = await issueApp.request(new Request(url, { method: "POST", headers, body: JSON.stringify(body) }));
258
+ // The issue route answers a refused issue as 200 with an error
259
+ // envelope, which goes back in `issue` with the open and inventory
260
+ // (the app then issues again). A non-200 is an auth or body refusal.
261
+ if (issued.status !== 200)
262
+ return { kind: "refused", refused: issued };
263
+ return {
264
+ kind: "attached",
265
+ opened,
266
+ inventory,
267
+ selection,
268
+ issue: (await issued.json()),
269
+ };
270
+ });
271
+ if (!result)
272
+ return c.json({ error: { code: "workspace-not-found" } }, 404);
273
+ if (result.kind === "refused")
274
+ return result.refused;
275
+ return c.json({
276
+ version: 1,
277
+ server,
278
+ workspaceName: result.opened.workspaceName,
279
+ liveSessionId,
280
+ inventory: result.inventory,
281
+ selection: result.selection,
282
+ issue: result.issue,
283
+ });
284
+ }));
207
285
  app.get(`${scoped}/sessions`, route(async (c) => {
208
286
  const server = scope(c);
209
- const v2 = c.req.query("version") === "2";
287
+ // #806: version 3 is version 2 plus the largest window's pane count.
288
+ const v3 = c.req.query("version") === "3";
289
+ const v2 = v3 || c.req.query("version") === "2";
210
290
  const { rows, favicons } = await options.owners.withOwner(server, async (owner) => {
211
291
  const sessions = await owner.catalog();
212
292
  const workspaces = owner.workspaceRegistry.list();
@@ -231,8 +311,9 @@ export function mountTmuxServerRoutes(app, options) {
231
311
  })),
232
312
  }));
233
313
  let budget = SESSIONS_RESOURCE_FAVICON_BUDGET_BYTES;
234
- return c.json(TmuxServerSessionsResourceV2SchemaZ.parse({
235
- version: 2,
314
+ const schema = v3 ? TmuxServerSessionsResourceV3SchemaZ : TmuxServerSessionsResourceV2SchemaZ;
315
+ return c.json(schema.parse({
316
+ version: v3 ? 3 : 2,
236
317
  server,
237
318
  sessions: rows.map(({ session, workspaceName }, index) => {
238
319
  const found = favicons[index] ?? null;
@@ -245,6 +326,7 @@ export function mountTmuxServerRoutes(app, options) {
245
326
  workspaceName,
246
327
  paneCount: session.paneCount,
247
328
  windowCount: session.windowCount,
329
+ ...(v3 ? { largestWindowPaneCount: session.largestWindowPaneCount } : {}),
248
330
  lastActivity: session.lastActivity,
249
331
  favicon: favicon ? { mime: favicon.mime, data: favicon.data } : null,
250
332
  };
@@ -262,6 +344,8 @@ export function mountTmuxServerRoutes(app, options) {
262
344
  app.get(`${scoped}/inventory/:workspaceName`, route(async (c) => {
263
345
  const server = scope(c);
264
346
  const workspaceName = workspaceSchema.parse(c.req.param("workspaceName"));
347
+ // #806: version 2 also names each window and its panes.
348
+ const v2 = c.req.query("version") === "2";
265
349
  const resource = await options.owners.withOwner(server, async (owner) => {
266
350
  const sessions = await owner.catalog();
267
351
  const workspace = owner.workspaceRegistry.get(workspaceName);
@@ -272,10 +356,14 @@ export function mountTmuxServerRoutes(app, options) {
272
356
  !sessions.some((row) => row.sessionName === workspace.sessionName && row.liveSessionId === expected))
273
357
  throw new TmuxServerScopeError("stale-generation");
274
358
  const snapshot = await owner.terminalInventoryRuntime.discoverTerminalRuntimeSession(workspace.sessionName, c.req.raw.signal);
275
- return snapshot ? projectTerminalRuntimeInventory(snapshot, 0) : null;
359
+ if (!snapshot)
360
+ return null;
361
+ return v2
362
+ ? projectTerminalRuntimeInventoryV2(snapshot, 0)
363
+ : projectTerminalRuntimeInventory(snapshot, 0);
276
364
  });
277
365
  return resource
278
- ? c.json({ version: 1, server, resource })
366
+ ? c.json({ version: v2 ? 2 : 1, server, resource })
279
367
  : c.json({ error: { code: "workspace-not-found" } }, 404);
280
368
  }));
281
369
  app.get(`${scoped}/catalog`, route(async (c) => {
@@ -17,6 +17,7 @@ import { findCompiledTui, hasDevelopmentTuiSource, isBunAvailable } from "./tui/
17
17
  import { claudeSettingsPath } from "./tui/integrations/claude.js";
18
18
  import { readNotificationPrefs, resolveNativeMacosNotifierPath } from "./tui/chrome/notify.js";
19
19
  import { resolveConfig } from "./lib/resolved-config.js";
20
+ import { MINIMUM_NODE_MAJOR, isSupportedNodeVersion } from "./lib/node-requirement.js";
20
21
  import { collectDaemonProvenanceReport, } from "./lib/daemon-provenance.js";
21
22
  /**
22
23
  * PURE — the "agent integrations" doctor rows, one per DISCOVERED agent (absent
@@ -387,12 +388,11 @@ export function tmuxServerSocketRow(environment, uid) {
387
388
  };
388
389
  }
389
390
  export function nodeVersionRow(version) {
390
- const major = Number(version.split(".")[0]);
391
- const pass = Number.isInteger(major) && major >= 20;
391
+ const pass = isSupportedNodeVersion(version);
392
392
  return {
393
- label: "Node.js ≥ 20",
393
+ label: `Node.js ≥ ${MINIMUM_NODE_MAJOR}`,
394
394
  pass,
395
- detail: pass ? `v${version}` : `Node ${version} (need ≥ 20)`,
395
+ detail: pass ? `v${version}` : `Node ${version} (need ≥ ${MINIMUM_NODE_MAJOR})`,
396
396
  optional: false,
397
397
  };
398
398
  }
@@ -131,6 +131,11 @@ function appThemeOverrideProvenance(theme, status, glyphs) {
131
131
  * back to its default, so partial and garbage configs both resolve to a complete,
132
132
  * well-typed {@link AppConfig}. Never throws.
133
133
  */
134
+ /** `theme.light` / `theme.dark`, when the id names a preset of that appearance. */
135
+ function systemSide(value, appearance) {
136
+ const preset = findVisualThemePreset(value);
137
+ return preset?.appearance === appearance ? { [appearance]: preset.id } : {};
138
+ }
134
139
  export function parseAppConfig(input) {
135
140
  const D = DEFAULT_APP_CONFIG;
136
141
  const root = asObject(input);
@@ -164,6 +169,8 @@ export function parseAppConfig(input) {
164
169
  automaticContrast: pickBool(theme.automaticContrast, D.theme.automaticContrast),
165
170
  mode: pickChoice(theme.mode, ["dark", "light", "system"], findVisualThemePreset(theme.preset)?.appearance ?? D.theme.mode),
166
171
  ...(findVisualThemePreset(theme.preset) ? { preset: String(theme.preset) } : {}),
172
+ ...systemSide(theme.light, "light"),
173
+ ...systemSide(theme.dark, "dark"),
167
174
  accent: pickString(theme.accent, D.theme.accent),
168
175
  muted: pickString(theme.muted, D.theme.muted),
169
176
  fg: pickString(theme.fg, D.theme.fg),
@@ -0,0 +1,20 @@
1
+ /** The oldest Node.js major an npm install of tmux-ide supports (package.json `engines`). */
2
+ export const MINIMUM_NODE_MAJOR = 24;
3
+ /** True when `version` (as in `process.versions.node`) is new enough. */
4
+ export function isSupportedNodeVersion(version) {
5
+ const major = Number(version.split(".")[0]);
6
+ return Number.isInteger(major) && major >= MINIMUM_NODE_MAJOR;
7
+ }
8
+ /**
9
+ * The message the CLI prints before exiting on an unsupported Node.js, or null
10
+ * when the runtime is supported. Bun (dev runs, compiled surfaces) is exempt.
11
+ */
12
+ export function unsupportedNodeMessage(versions) {
13
+ if (versions.bun !== undefined || versions.node === undefined)
14
+ return null;
15
+ if (isSupportedNodeVersion(versions.node))
16
+ return null;
17
+ return (`tmux-ide needs Node.js ${MINIMUM_NODE_MAJOR} or newer; this is Node.js ${versions.node}.\n` +
18
+ `Upgrade Node.js, or use the installer, which brings its own runtime:\n` +
19
+ ` curl -fsSL https://tmux-ide.com/install.sh | sh\n`);
20
+ }
@@ -0,0 +1,8 @@
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.js";
4
+ const message = unsupportedNodeMessage(process.versions);
5
+ if (message !== null) {
6
+ process.stderr.write(message);
7
+ process.exit(1);
8
+ }
@@ -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
  }));
@@ -4,7 +4,7 @@ import { WorkspaceCatalogLiveSessionIdSchemaZ } from "@tmux-ide/contracts";
4
4
  import { liveSessionIdForNativeIdentity } from "../terminal/protocol/live-session-identity.js";
5
5
  import { fleetSessionIdForName } from "../command-center/resources/fleet-catalog.js";
6
6
  import { isVisibleFleetSession } from "../command-center/discovery.js";
7
- import { WorkspacePromotionAuthority } from "./workspace-promotion.js";
7
+ import { ADOPTED_OPTION, hasValidPaneStamp, SEMANTIC_PANE_OPTION, SEMANTIC_WINDOW_OPTION, WorkspacePromotionAuthority, } from "./workspace-promotion.js";
8
8
  import { shellEscape } from "./shell.js";
9
9
  /** Owner-local bounded admission; all native IO must already fence the server generation. */
10
10
  export function createNativeTmuxSessionOpener(options) {
@@ -18,28 +18,54 @@ export function createNativeTmuxSessionOpener(options) {
18
18
  };
19
19
  const open = async (liveSessionId, observed) => {
20
20
  assertOpen();
21
+ // One row per pane: the session's identity, whether it is adopted, and
22
+ // each window's and pane's stamp. tmux rejects tabs in session names, so
23
+ // the name is the last field; a pane stamp with a tab is invalid anyway.
21
24
  const records = await options.run([
22
- "list-sessions",
25
+ "list-panes",
26
+ "-a",
23
27
  "-F",
24
- "#{pid}\t#{session_id}\t#{session_created}\t#{session_name}",
28
+ `#{pid}\t#{session_id}\t#{session_created}\t#{${ADOPTED_OPTION}}\t#{${SEMANTIC_WINDOW_OPTION}}\t#{${SEMANTIC_PANE_OPTION}}\t#{session_name}`,
25
29
  ]);
26
- // The final field is an exact session identity; spaces are valid name bytes.
27
- const matches = records
30
+ const rows = records
28
31
  .replace(/\n+$/u, "")
29
32
  .split("\n")
30
33
  .map((line) => line.split("\t"))
31
- .filter(([pid, id, created, name]) => pid &&
32
- /^\d+$/.test(pid) &&
33
- id &&
34
+ .filter((fields) => fields.length >= 7)
35
+ .map((fields) => ({
36
+ // A tab can only come from a window or pane stamp: such a row never
37
+ // takes the fast path below.
38
+ exact: fields.length === 7,
39
+ pid: fields[0],
40
+ id: fields[1],
41
+ created: fields[2],
42
+ adopted: fields[3],
43
+ window: fields.slice(4, -2).join("\t"),
44
+ pane: fields.at(-2),
45
+ name: fields.at(-1),
46
+ }))
47
+ .filter(({ pid, id, created, name }) => /^\d+$/.test(pid) &&
34
48
  /^\$\d+$/.test(id) &&
35
- created &&
36
49
  /^\d+$/.test(created) &&
37
50
  name &&
38
51
  isVisibleFleetSession(name) &&
39
52
  liveSessionIdForNativeIdentity(pid, id, created) === liveSessionId);
40
- if (matches.length !== 1)
53
+ if (new Set(rows.map((row) => row.id)).size !== 1)
41
54
  throw new Error("Selected live tmux session is no longer available");
42
- const [, nativeSessionId, created, name] = matches[0];
55
+ const { id: nativeSessionId, created, name } = rows[0];
56
+ // Re-opening a session that an earlier open already finished changes
57
+ // nothing: it is adopted, has exactly one durable alias, and every window
58
+ // and pane already carries a stamp. Promotion would only read it again
59
+ // (seven tmux commands), so skip it. Anything else promotes as before,
60
+ // which also stamps panes split since the last open.
61
+ const aliases = options.registry.list().filter((entry) => entry.sessionName === name);
62
+ if (!observed &&
63
+ aliases.length === 1 &&
64
+ !options.registry.isVolatile(aliases[0].name) &&
65
+ rows.every((row) => row.exact && row.adopted === "1" && row.window.length > 0 && hasValidPaneStamp(row.pane))) {
66
+ assertOpen();
67
+ return { workspaceName: aliases[0].name, liveSessionId };
68
+ }
43
69
  // Each command checks the exact native session on the server accepting it.
44
70
  // A name-only validation followed by stamping would cross a session replacement.
45
71
  const run = async (args) => {
@@ -62,7 +88,7 @@ export function createNativeTmuxSessionOpener(options) {
62
88
  return output;
63
89
  };
64
90
  const agent = observed
65
- ? await captureAgentAdmission(run, { id: nativeSessionId, name: name }, observed)
91
+ ? await captureAgentAdmission(run, { id: nativeSessionId, name }, observed)
66
92
  : null;
67
93
  await agent?.verify(false);
68
94
  const promotion = new WorkspacePromotionAuthority({
@@ -18,12 +18,12 @@ const MAX_TMUX_OUTPUT_BYTES = 128 * 1024;
18
18
  // is proven, immediately before registry admission. The promotion marker is
19
19
  // DELIBERATELY distinct from the m32 open marker so a promoted session is a
20
20
  // separate provenance.
21
- const ADOPTED_OPTION = "@tmux_ide_adopted";
21
+ export const ADOPTED_OPTION = "@tmux_ide_adopted";
22
22
  const SESSION_PROMOTED_MARKER_OPTION = "@tmux_ide_workspace_promoted_v1";
23
23
  const SESSION_WORKSPACE_OPTION = "@tmux_ide_workspace_name";
24
24
  const SESSION_OPERATION_OPTION = "@tmux_ide_workspace_promote_operation";
25
- const SEMANTIC_PANE_OPTION = "@tmux_ide_pane_id";
26
- const SEMANTIC_WINDOW_OPTION = "@tmux_ide_window_id";
25
+ export const SEMANTIC_PANE_OPTION = "@tmux_ide_pane_id";
26
+ export const SEMANTIC_WINDOW_OPTION = "@tmux_ide_window_id";
27
27
  // Distinctive multi-char field/line delimiters — collision-resistant against
28
28
  // arbitrary pane paths, window names and user-controlled `@agent_*` values,
29
29
  // matching the fleet-discovery idiom. A value carrying a newline splits into a
@@ -142,7 +142,7 @@ function isInternalSession(name) {
142
142
  }
143
143
  const VALID_SEMANTIC_PANE_ID = /^[A-Za-z0-9][A-Za-z0-9._-]*$/u;
144
144
  const RESERVED_DISCOVERED_PREFIX = "terminal.discovered.";
145
- function hasValidPaneStamp(value) {
145
+ export function hasValidPaneStamp(value) {
146
146
  return (value.length > 0 &&
147
147
  value.length <= 128 &&
148
148
  VALID_SEMANTIC_PANE_ID.test(value) &&
@@ -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.27</string>
25
25
  <key>CFBundleVersion</key>
26
- <string>2.9.25</string>
26
+ <string>2.9.27</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
+ 7/c5M7HIcG2L8zbGq7f5hfd3b+k=
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
+ lInayHTe0NipJWAju3yVQdmkOMR8qipP8gNMy+AgXt4=
30
30
  </data>
31
31
  </dict>
32
32
  </dict>
@@ -16,6 +16,30 @@ function rawHeaderValues(request, expectedName) {
16
16
  }
17
17
  return values;
18
18
  }
19
+ /**
20
+ * attach-rtt: the client may carry its redeem frame in the upgrade request
21
+ * (base64url of the frame's JSON text), so the daemon answers the 101 and the
22
+ * seed without waiting a round trip for the frame. The 101 says so with
23
+ * `X-Tmux-Ide-Redeem: accepted`; a client that sees no such header sends the
24
+ * frame as before. Absent, the upgrade is exactly as it was.
25
+ */
26
+ export const PANE_STREAM_REDEEM_HEADER = "x-tmux-ide-redeem";
27
+ /** The frame a redeem header carries, `null` for none, or "invalid". */
28
+ function upgradeRedeemFrame(request) {
29
+ const values = rawHeaderValues(request, PANE_STREAM_REDEEM_HEADER);
30
+ if (values.length === 0)
31
+ return null;
32
+ const value = values[0];
33
+ if (values.length > 1 ||
34
+ value.length === 0 ||
35
+ value.length > Math.ceil((PANE_STREAM_MAX_REDEMPTION_BYTES * 4) / 3) ||
36
+ !/^[A-Za-z0-9_-]+$/u.test(value))
37
+ return "invalid";
38
+ const frame = Buffer.from(value, "base64url");
39
+ return frame.byteLength === 0 || frame.byteLength > PANE_STREAM_MAX_REDEMPTION_BYTES
40
+ ? "invalid"
41
+ : frame;
42
+ }
19
43
  function rejectUpgrade(socket, status) {
20
44
  const phrase = status === 403
21
45
  ? "Forbidden"
@@ -53,7 +77,12 @@ export function attachPaneStreamWebSocket(server, coordinator, redemptionPath =
53
77
  },
54
78
  });
55
79
  // Old clients ignore the header and answer the pings by protocol.
56
- wss.on("headers", (headers) => heartbeat.advertise(headers));
80
+ const redeemed = new WeakSet();
81
+ wss.on("headers", (headers, request) => {
82
+ heartbeat.advertise(headers);
83
+ if (redeemed.has(request))
84
+ headers.push("X-Tmux-Ide-Redeem: accepted");
85
+ });
57
86
  const upgrade = (request, socket, head) => {
58
87
  const rawPath = request.url ?? "";
59
88
  const pathname = rawPath.split("?", 1)[0] ?? "";
@@ -91,6 +120,11 @@ export function attachPaneStreamWebSocket(server, coordinator, redemptionPath =
91
120
  rejectUpgrade(socket, 403);
92
121
  return;
93
122
  }
123
+ const redeemFrame = upgradeRedeemFrame(request);
124
+ if (redeemFrame === "invalid") {
125
+ rejectUpgrade(socket, 403);
126
+ return;
127
+ }
94
128
  if (!isCurrent()) {
95
129
  rejectUpgrade(socket, 410);
96
130
  return;
@@ -109,12 +143,16 @@ export function attachPaneStreamWebSocket(server, coordinator, redemptionPath =
109
143
  const cancelUnbound = () => decision.admission.cancelBeforeBind();
110
144
  socket.once("close", cancelUnbound);
111
145
  socket.once("error", cancelUnbound);
146
+ if (redeemFrame)
147
+ redeemed.add(request);
112
148
  try {
113
149
  wss.handleUpgrade(request, socket, head, (ws) => {
114
150
  socket.off("close", cancelUnbound);
115
151
  socket.off("error", cancelUnbound);
116
152
  heartbeat.watch(ws, `pane-stream ${redemptionPath}`);
117
153
  decision.admission.bind(ws);
154
+ if (redeemFrame)
155
+ decision.admission.redeemFromUpgrade(redeemFrame);
118
156
  });
119
157
  }
120
158
  catch {
@@ -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,