tmux-ide 2.9.24 → 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 (77) hide show
  1. package/bin/cli.js +1689 -393
  2. package/package.json +5 -2
  3. package/packages/contracts/src/pane-stream.ts +72 -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/discovery.js +24 -5
  8. package/packages/daemon/dist/command-center/resources/terminal-runtime-inventory.js +42 -2
  9. package/packages/daemon/dist/command-center/server.js +81 -75
  10. package/packages/daemon/dist/command-center/tmux-servers.js +17 -7
  11. package/packages/daemon/dist/doctor.js +46 -10
  12. package/packages/daemon/dist/lib/canonical-daemon-bootstrap.js +20 -2
  13. package/packages/daemon/dist/lib/daemon-crash-snapshot.js +118 -0
  14. package/packages/daemon/dist/lib/daemon-embed.js +6 -0
  15. package/packages/daemon/dist/lib/headless-daemon.js +63 -6
  16. package/packages/daemon/dist/lib/invocation-directory.js +20 -0
  17. package/packages/daemon/dist/lib/runtime-namespace.js +22 -6
  18. package/packages/daemon/dist/lib/tmux-client-execution.js +12 -3
  19. package/packages/daemon/dist/lib/tmux-server-owner.js +4 -2
  20. package/packages/daemon/dist/lib/update-check.js +18 -0
  21. package/packages/daemon/dist/lib/update-daemon-outcome.js +31 -0
  22. package/packages/daemon/dist/lib/update.js +39 -14
  23. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Info.plist +2 -2
  24. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/MacOS/tmux-ide-notifier +0 -0
  25. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Resources/Assets.car +0 -0
  26. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/_CodeSignature/CodeResources +2 -2
  27. package/packages/daemon/dist/terminal/graphics/kitty-graphics.js +16 -4
  28. package/packages/daemon/dist/terminal/mirror/mirror-service.js +26 -0
  29. package/packages/daemon/dist/terminal/mirror/session-channel.js +31 -2
  30. package/packages/daemon/dist/terminal/pane-stream/lease-manager.js +1 -0
  31. package/packages/daemon/dist/terminal/pane-stream/pane-stream-websocket.js +831 -222
  32. package/packages/daemon/dist/terminal/protocol/browser-icon.js +1 -1
  33. package/packages/daemon/dist/terminal/protocol/session-descriptor-discovery.js +26 -3
  34. package/packages/daemon/dist/terminal/session-runtime/registry.js +25 -2
  35. package/packages/daemon/dist/terminal/session-runtime/terminal-delivery-hub.js +121 -6
  36. package/packages/daemon/dist/terminal/session-runtime/terminal-replica-interpreter.js +79 -2
  37. package/packages/daemon/dist/terminal/session-runtime/terminal-replica-owner.js +24 -2
  38. package/packages/daemon/dist/terminal/session-runtime/transport-binding.js +38 -0
  39. package/packages/daemon/dist/terminal/session-runtime/xterm-terminal-interpreter-backend.js +51 -4
  40. package/packages/daemon/dist/tui/chrome/snapshot.js +36 -1
  41. package/packages/daemon/dist/tui/chrome/statusline.js +8 -5
  42. package/packages/daemon/dist/tui/chrome/updater.js +2 -0
  43. package/packages/daemon/src/command-center/discovery.ts +24 -4
  44. package/packages/daemon/src/command-center/resources/terminal-runtime-inventory.ts +48 -1
  45. package/packages/daemon/src/command-center/server.ts +67 -67
  46. package/packages/daemon/src/command-center/tmux-servers.ts +19 -6
  47. package/packages/daemon/src/doctor.ts +50 -9
  48. package/packages/daemon/src/lib/canonical-daemon-bootstrap.ts +31 -5
  49. package/packages/daemon/src/lib/daemon-crash-snapshot.ts +175 -0
  50. package/packages/daemon/src/lib/daemon-embed.ts +22 -0
  51. package/packages/daemon/src/lib/headless-daemon.ts +88 -7
  52. package/packages/daemon/src/lib/invocation-directory.ts +21 -0
  53. package/packages/daemon/src/lib/runtime-namespace.ts +25 -7
  54. package/packages/daemon/src/lib/tmux-client-execution.ts +14 -5
  55. package/packages/daemon/src/lib/tmux-server-owner.ts +6 -3
  56. package/packages/daemon/src/lib/update-check.ts +34 -0
  57. package/packages/daemon/src/lib/update-daemon-outcome.ts +42 -0
  58. package/packages/daemon/src/lib/update.ts +58 -16
  59. package/packages/daemon/src/terminal/graphics/kitty-graphics.ts +22 -6
  60. package/packages/daemon/src/terminal/mirror/events.ts +2 -0
  61. package/packages/daemon/src/terminal/mirror/mirror-service.ts +27 -0
  62. package/packages/daemon/src/terminal/mirror/session-channel.ts +38 -2
  63. package/packages/daemon/src/terminal/pane-stream/lease-manager.ts +3 -0
  64. package/packages/daemon/src/terminal/pane-stream/pane-stream-websocket.ts +915 -236
  65. package/packages/daemon/src/terminal/protocol/browser-icon.ts +1 -1
  66. package/packages/daemon/src/terminal/protocol/session-descriptor-discovery.ts +32 -2
  67. package/packages/daemon/src/terminal/session-runtime/registry.ts +36 -2
  68. package/packages/daemon/src/terminal/session-runtime/terminal-delivery-hub.ts +136 -6
  69. package/packages/daemon/src/terminal/session-runtime/terminal-interpreter-backend.ts +6 -0
  70. package/packages/daemon/src/terminal/session-runtime/terminal-replica-interpreter.ts +76 -2
  71. package/packages/daemon/src/terminal/session-runtime/terminal-replica-owner.ts +21 -1
  72. package/packages/daemon/src/terminal/session-runtime/transport-binding.ts +42 -2
  73. package/packages/daemon/src/terminal/session-runtime/xterm-terminal-interpreter-backend.ts +67 -3
  74. package/packages/daemon/src/tui/chrome/snapshot.ts +47 -1
  75. package/packages/daemon/src/tui/chrome/statusline.ts +7 -4
  76. package/packages/daemon/src/tui/chrome/updater.ts +3 -0
  77. package/packages/daemon-client/src/pane-stream-client.ts +47 -5
@@ -108,6 +108,8 @@ function discoveredWorkspaceName(registry: WorkspaceRegistry, sessionName: strin
108
108
  export interface NativeLiveSessionSummary extends LiveSessionSummary {
109
109
  /** Distinct tmux windows of the session (at least one). */
110
110
  readonly windowCount: number;
111
+ /** Panes of the session's largest window (#806: streams open window by window). */
112
+ readonly largestWindowPaneCount: number;
111
113
  /** tmux `#{session_activity}` in epoch seconds, or null when tmux reports none. */
112
114
  readonly lastActivity: number | null;
113
115
  /** tmux `#{session_path}`, the session's working directory. */
@@ -159,7 +161,7 @@ export function createNativeTmuxServerCatalog(
159
161
  {
160
162
  summary: LiveSessionSummary;
161
163
  panes: Set<string>;
162
- windows: Set<string>;
164
+ windows: Map<string, number>;
163
165
  dir: string;
164
166
  activity: number | null;
165
167
  }
@@ -192,12 +194,12 @@ export function createNativeTmuxServerCatalog(
192
194
  const row = rows.get(liveSessionId) ?? {
193
195
  summary: { liveSessionId, sessionName: name, paneCount: 0 },
194
196
  panes: new Set<string>(),
195
- windows: new Set<string>(),
197
+ windows: new Map<string, number>(),
196
198
  dir,
197
199
  activity: activity && /^\d+$/.test(activity) ? Number(activity) : null,
198
200
  };
201
+ if (!row.panes.has(pane)) row.windows.set(window, (row.windows.get(window) ?? 0) + 1);
199
202
  row.panes.add(pane);
200
- row.windows.add(window);
201
203
  rows.set(liveSessionId, row);
202
204
  }
203
205
  const names = new Set([...rows.values()].map(({ summary }) => summary.sessionName));
@@ -218,6 +220,7 @@ export function createNativeTmuxServerCatalog(
218
220
  ...summary,
219
221
  paneCount: panes.size,
220
222
  windowCount: windows.size,
223
+ largestWindowPaneCount: Math.max(...windows.values()),
221
224
  lastActivity: activity,
222
225
  sessionPath: dir,
223
226
  }));
@@ -237,6 +237,40 @@ export function getUpdateStatus({
237
237
  return deriveStatus(cache?.latest ?? null, currentVersion);
238
238
  }
239
239
 
240
+ /** Where a status came from: the registry just now, or the last answer on disk. */
241
+ export type UpdateStatusSource = "registry" | "cache";
242
+
243
+ /**
244
+ * io — the answer for a user who asked (`tmux-ide update`): fetch the registry
245
+ * now, with a short timeout, and store what it said. The cache alone can be
246
+ * weeks old on a machine that rarely runs the updater tick. Falls back to the
247
+ * cache when the registry cannot be reached, and says so in `source`.
248
+ */
249
+ export async function refreshUpdateStatus({
250
+ currentVersion = getCurrentVersion(),
251
+ now = Date.now(),
252
+ timeoutMs = 3000,
253
+ fetchLatest = fetchLatestVersion,
254
+ }: UpdateScope & {
255
+ now?: number;
256
+ timeoutMs?: number;
257
+ fetchLatest?: typeof fetchLatestVersion;
258
+ } = {}): Promise<UpdateStatus & { source: UpdateStatusSource }> {
259
+ const fetched = await fetchLatest(timeoutMs, updateChannel(currentVersion));
260
+ const cache = readUpdateCache({ currentVersion });
261
+ if (fetched === null)
262
+ return { ...deriveStatus(cache?.latest ?? null, currentVersion), source: "cache" };
263
+ writeUpdateCache(
264
+ {
265
+ lastCheckedAt: now,
266
+ latest: fetched,
267
+ ...(cache?.notified ? { notified: cache.notified } : {}),
268
+ },
269
+ { currentVersion },
270
+ );
271
+ return { ...deriveStatus(fetched, currentVersion), source: "registry" };
272
+ }
273
+
240
274
  /**
241
275
  * io — the throttled network refresh (called fire-and-forget from the updater
242
276
  * tick). Does nothing if the last check was inside {@link CHECK_INTERVAL_MS};
@@ -0,0 +1,42 @@
1
+ import { compareProductVersions } from "./semver.ts";
2
+
3
+ /**
4
+ * What `tmux-ide update --daemon` tells the user once a daemon is running.
5
+ *
6
+ * A CLI never replaces a NEWER daemon (canonical-daemon-bootstrap's
7
+ * needsReplacement): clients of the newer version may depend on it. That is
8
+ * by design. But after a rollback (a newer daemon, an older CLI) the command
9
+ * used to report "Daemon ready" for the newer daemon and nothing else, so it
10
+ * looked as if it had done nothing. It now says the daemon was left running
11
+ * and how to run this version's daemon instead.
12
+ */
13
+ export function daemonUpdateOutcome(
14
+ running: {
15
+ readonly productVersion: string;
16
+ readonly pid: number;
17
+ readonly supervised: boolean;
18
+ /** The daemon runs inside another tmux-ide process (an app or TUI), not on its own. */
19
+ readonly embedded?: boolean;
20
+ },
21
+ cliVersion: string,
22
+ ): { status: "ready" | "kept-newer"; message: string } {
23
+ if (compareProductVersions(running.productVersion, cliVersion) !== 1)
24
+ return { status: "ready", message: `Daemon ready: ${running.productVersion}` };
25
+ // A service restart runs the launcher the service was set up with, which need
26
+ // not be this CLI's installation: say what it does, not which version it loads.
27
+ const how = running.supervised
28
+ ? "restart its service with tmux-ide daemon service restart; the service starts " +
29
+ `the installation it was set up with, so if that is not v${cliVersion}, set the ` +
30
+ "service up from this installation first"
31
+ : running.embedded
32
+ ? `quit what it runs in: it runs inside another tmux-ide process (pid ${running.pid}), ` +
33
+ "such as an open app, then run tmux-ide update --daemon again"
34
+ : `stop it (pid ${running.pid}), then run tmux-ide update --daemon again`;
35
+ return {
36
+ status: "kept-newer",
37
+ message:
38
+ `The running daemon is v${running.productVersion}, newer than this CLI (v${cliVersion}). ` +
39
+ `It was left running: a CLI never replaces a newer daemon. ` +
40
+ `To run v${cliVersion}'s daemon instead, ${how}.`,
41
+ };
42
+ }
@@ -11,11 +11,15 @@ import { dirname, join } from "node:path";
11
11
  import { execFileSync } from "node:child_process";
12
12
  import {
13
13
  getCurrentVersion,
14
- getUpdateStatus,
14
+ refreshUpdateStatus,
15
15
  deriveStatus,
16
16
  updateChannel,
17
+ type fetchLatestVersion,
17
18
  type UpdateChannel,
19
+ type UpdateStatus,
20
+ type UpdateStatusSource,
18
21
  } from "./update-check.ts";
22
+ import { IdeError } from "./errors.ts";
19
23
  import {
20
24
  installOrigin,
21
25
  detectPackageManager,
@@ -99,14 +103,22 @@ export function planUpdate(input: {
99
103
  }
100
104
  export function renderPlan(
101
105
  plan: UpdatePlan,
102
- { current, latest, dryRun }: { current: string; latest: string | null; dryRun: boolean },
106
+ {
107
+ current,
108
+ latest,
109
+ dryRun,
110
+ source = "registry",
111
+ }: { current: string; latest: string | null; dryRun: boolean; source?: UpdateStatusSource },
103
112
  ): string {
113
+ // "Up to date" is the registry's word only; a cached answer can be weeks old.
104
114
  const status =
105
115
  latest && deriveStatus(latest, current).updateAvailable
106
116
  ? `tmux-ide v${current} → v${latest} available`
107
- : latest
108
- ? `tmux-ide v${current} is up to date (registry: v${latest})`
109
- : `tmux-ide v${current} (latest version unknown)`;
117
+ : source === "cache"
118
+ ? `tmux-ide v${current}: could not reach the npm registry (last known release: ${latest ? `v${latest}` : "unknown"})`
119
+ : latest
120
+ ? `tmux-ide v${current} is up to date (registry: v${latest})`
121
+ : `tmux-ide v${current} (latest version unknown)`;
110
122
  return [
111
123
  status,
112
124
  "",
@@ -118,21 +130,43 @@ export function renderPlan(
118
130
  "After updating, relaunch the app. Use tmux-ide update --daemon to replace a running daemon with installed code.",
119
131
  ].join("\n");
120
132
  }
133
+ /** The update command prints its own failure; ours is one line, never a stack trace. */
134
+ function updateFailure(what: string, error: unknown): IdeError {
135
+ const { status, signal, message } = error as { status?: unknown; signal?: unknown } & Error;
136
+ const how =
137
+ typeof status === "number"
138
+ ? `exited with status ${status}`
139
+ : typeof signal === "string"
140
+ ? `was stopped by ${signal}`
141
+ : `could not run (${String(message).split("\n")[0]})`;
142
+ return new IdeError(
143
+ `The update did not finish: ${what} ${how}. Its own message is above. Retry with: tmux-ide update`,
144
+ { code: "UPDATE_FAILED", cause: error instanceof Error ? error : undefined },
145
+ );
146
+ }
121
147
  /** Does not refresh skills: the installed package's postinstall owns that step. */
122
- export function runUpdate(
148
+ export async function runUpdate(
123
149
  { cliDir, dryRun, json = false }: { cliDir: string; dryRun: boolean; json?: boolean },
124
150
  dependencies: {
125
151
  execute?: typeof execFileSync;
126
152
  query?: (executable: string, args: string[]) => string;
127
153
  currentVersion?: () => string;
128
- status?: typeof getUpdateStatus;
154
+ status?: (scope: {
155
+ currentVersion: string;
156
+ }) =>
157
+ | (UpdateStatus & { source?: UpdateStatusSource })
158
+ | Promise<UpdateStatus & { source?: UpdateStatusSource }>;
159
+ fetchLatest?: typeof fetchLatestVersion;
129
160
  output?: (line: string) => void;
130
161
  } = {},
131
- ): UpdatePlan {
162
+ ): Promise<UpdatePlan> {
132
163
  if (resolveRuntimeNamespace().development)
133
164
  throw new Error("Development instances rebuild exact artifacts; package updates are disabled");
134
165
  const current = (dependencies.currentVersion ?? getCurrentVersion)();
135
- const { latest } = (dependencies.status ?? getUpdateStatus)({ currentVersion: current });
166
+ const { latest, source: latestSource = "registry" } = await (
167
+ dependencies.status ??
168
+ ((scope) => refreshUpdateStatus({ ...scope, fetchLatest: dependencies.fetchLatest }))
169
+ )({ currentVersion: current });
136
170
  const source = installOrigin(cliDir);
137
171
  let plan: UpdatePlan =
138
172
  source.origin === "unknown"
@@ -178,19 +212,27 @@ export function runUpdate(
178
212
  }
179
213
  }
180
214
  const output = dependencies.output ?? console.log;
181
- if (!json) output(renderPlan(plan, { current, latest, dryRun }));
215
+ if (!json) output(renderPlan(plan, { current, latest, dryRun, source: latestSource }));
182
216
  let executed = false;
183
217
  if (!dryRun && plan.executable && plan.args) {
184
- // argv only: paths and version metadata never become shell source.
185
- (dependencies.execute ?? execFileSync)(plan.executable, plan.args, {
186
- stdio: json ? ["ignore", 2, 2] : "inherit",
187
- });
218
+ try {
219
+ // argv only: paths and version metadata never become shell source.
220
+ (dependencies.execute ?? execFileSync)(plan.executable, plan.args, {
221
+ stdio: json ? ["ignore", 2, 2] : "inherit",
222
+ });
223
+ } catch (error) {
224
+ throw updateFailure([plan.executable, ...plan.args].join(" "), error);
225
+ }
188
226
  executed = true;
189
227
  }
190
228
  if (!dryRun && plan.installerPrefix && plan.channel) {
191
- runManagedInstallerUpdate(plan.installerPrefix, plan.channel, json, dependencies.execute);
229
+ try {
230
+ runManagedInstallerUpdate(plan.installerPrefix, plan.channel, json, dependencies.execute);
231
+ } catch (error) {
232
+ throw updateFailure("the installer", error);
233
+ }
192
234
  executed = true;
193
235
  }
194
- if (json) output(JSON.stringify({ ...plan, current, latest, dryRun, executed }));
236
+ if (json) output(JSON.stringify({ ...plan, current, latest, latestSource, dryRun, executed }));
195
237
  return plan;
196
238
  }
@@ -367,18 +367,30 @@ export class KittyImageStore {
367
367
  null;
368
368
  #nextAnonymous = 0x7f000000;
369
369
  #bytes = 0;
370
- readonly #cellWidth: number;
371
- readonly #cellHeight: number;
370
+ /** Cell size in thousandths of a device pixel. */
371
+ #cellWidth: number;
372
+ #cellHeight: number;
372
373
  readonly #budget: KittyImageBudget;
373
374
  #revision = 0;
374
375
 
375
376
  constructor(options: KittyImageStoreOptions = {}) {
376
- this.#cellWidth = options.cellWidthPx ?? 10;
377
- this.#cellHeight = options.cellHeightPx ?? 20;
377
+ this.#cellWidth = (options.cellWidthPx ?? 10) * 1000;
378
+ this.#cellHeight = (options.cellHeightPx ?? 20) * 1000;
378
379
  this.#budget = options.budget ?? DEFAULT_KITTY_IMAGE_BUDGET;
379
380
  this.#budget.register(this);
380
381
  }
381
382
 
383
+ /**
384
+ * The renderer's cell size in device pixels, with thousandths when it reports
385
+ * them (capability 103/104). Placements made from now on that give no `c`/`r`
386
+ * cover the image at this size; earlier ones keep their grid.
387
+ */
388
+ setCellPixels(width: number, height: number, precise?: { width: number; height: number }): void {
389
+ if (!(width > 0 && height > 0)) return;
390
+ this.#cellWidth = precise && precise.width > 0 ? precise.width : width * 1000;
391
+ this.#cellHeight = precise && precise.height > 0 ? precise.height : height * 1000;
392
+ }
393
+
382
394
  /** Bumps whenever images or placements change. */
383
395
  get revision(): number {
384
396
  return this.#revision;
@@ -511,8 +523,12 @@ export class KittyImageStore {
511
523
  const image = this.#images.get(imageId);
512
524
  if (!image) return;
513
525
  this.#used.set(imageId, this.#budget.nextTick());
514
- const columns = clampCells(int(control, "c") || Math.ceil(image.width / this.#cellWidth));
515
- const rows = clampCells(int(control, "r") || Math.ceil(image.height / this.#cellHeight));
526
+ const columns = clampCells(
527
+ int(control, "c") || Math.ceil((image.width * 1000) / this.#cellWidth),
528
+ );
529
+ const rows = clampCells(
530
+ int(control, "r") || Math.ceil((image.height * 1000) / this.#cellHeight),
531
+ );
516
532
  const placementId = int(control, "p");
517
533
  if (control.get("U") === "1") {
518
534
  const placements = this.#virtual.get(imageId) ?? new Map();
@@ -92,6 +92,8 @@ export type MirrorPaneEvent =
92
92
  /** One visible pane rectangle inside a layout event, in window cells. */
93
93
  export interface MirrorLayoutPane {
94
94
  browserIcon?: string | null;
95
+ /** #718: a terminal browser with native controls, a plain one, or null. */
96
+ browserKind?: "native" | "plain" | null;
95
97
  /** A live Markdown reader pane; the path is daemon-only and never framed. */
96
98
  reader?: { name: string; path: string } | null;
97
99
  /** Null while the pane's semantic identity join is still unverified. */
@@ -214,6 +214,28 @@ export class MirrorService {
214
214
  wasPending: this.registeredWindows?.pending() ?? null,
215
215
  });
216
216
  this.registeredWindows?.invalidate();
217
+ this.scheduleOwnershipVerify();
218
+ }
219
+
220
+ /**
221
+ * Until a read proves ownership again, every retained session refuses input
222
+ * and geometry. A workspace added or removed (another session created or
223
+ * killed) invalidates without any channel resyncing, and nothing else read
224
+ * again until the next stream was issued: the next keystroke closed the
225
+ * stream. Read again at once (coalesced) while a channel is retained; a
226
+ * failed read takes the #764 retry path.
227
+ */
228
+ private ownershipVerifyScheduled = false;
229
+ private scheduleOwnershipVerify(): void {
230
+ if (this.ownershipVerifyScheduled || this.disposed) return;
231
+ this.ownershipVerifyScheduled = true;
232
+ const timer = setTimeout(() => {
233
+ this.ownershipVerifyScheduled = false;
234
+ if (this.disposed || this.channelSessions.size === 0 || !this.registeredWindows?.pending())
235
+ return;
236
+ void this.verifyRegisteredWindows().catch(() => {});
237
+ }, 0);
238
+ timer.unref?.();
217
239
  }
218
240
 
219
241
  /**
@@ -633,6 +655,11 @@ export class MirrorService {
633
655
  if (message) throw new Error(message);
634
656
  }
635
657
 
658
+ /** Registered-window ownership is being read again; input waits for it. */
659
+ windowOwnershipPending(): boolean {
660
+ return this.registeredWindows?.pending() ?? false;
661
+ }
662
+
636
663
  windowOwnershipMessage(session: string): string | null {
637
664
  if (this.registeredWindows?.pending())
638
665
  return "Window ownership is being verified. Retry after session discovery completes.";
@@ -755,6 +755,10 @@ export class SessionChannel {
755
755
  await this.captureAttachedSessionIdentity();
756
756
  this.io.send("refresh-client -B 'tmux-ide-browser-icon:%*:#{@tmux_ide_browser_icon}'");
757
757
  this.io.send("refresh-client -B 'tmux-ide-reader:%*:#{@tmux_ide_reader}'");
758
+ // #718: a browser's controls appear, or a plain terminal browser starts or exits.
759
+ this.io.send(
760
+ "refresh-client -B 'tmux-ide-browser-kind:%*:#{@tmux_ide_browser_control}#{m:terminal-browse*,#{pane_current_command}}'",
761
+ );
758
762
  // Changing border placement can resize PTYs without changing the layout
759
763
  // string, so tmux emits no layout-change. Subscribe to this window option.
760
764
  this.io.send("refresh-client -B 'tmux-ide-pane-borders:@*:#{pane-border-status}'");
@@ -1352,11 +1356,40 @@ export class SessionChannel {
1352
1356
  }
1353
1357
  this.input.flush();
1354
1358
  this.clearWindowViewports();
1355
- this.restoreWindowSizing(this.attachedIdentity?.runtimeSessionId ?? `=${this.opts.session}`);
1359
+ const target = this.attachedIdentity?.runtimeSessionId ?? `=${this.opts.session}`;
1360
+ this.restoreWindowSizing(target);
1356
1361
  this.io.send(`refresh-client -C ${cols}x${rows}${this.cellPixelSuffix()}`);
1362
+ this.reclaimWindowSize(target);
1357
1363
  this.clientViewport = { cols, rows };
1358
1364
  }
1359
1365
 
1366
+ /**
1367
+ * Under `window-size latest` a second tmux client on the session (a terminal
1368
+ * the user also attached) takes the window, and nothing this control client
1369
+ * sends makes it tmux's latest client again: input and refresh-client are not
1370
+ * client activity. Output then prints at the other client's width and tmux
1371
+ * re-wraps it mid-word when that width goes away (#695). A fit is the app
1372
+ * being used (it fits on focus and on a change of its canvas), so after one,
1373
+ * when the window is not this client's size, switch to the same session:
1374
+ * that makes this client the latest one. Only here, never on a timer or a
1375
+ * notification, so two clients never fight; whichever the user used last
1376
+ * wins, as between two terminals. Other window-size policies are the user's.
1377
+ */
1378
+ private reclaimWindowSize(target: string): void {
1379
+ if (!this.geometryParticipating) return;
1380
+ const quoted = tmuxSingleQuote(target);
1381
+ // Two FIFO slots whichever branch runs, as in restoreWindowSizing.
1382
+ this.io.commandListInline(
1383
+ `if-shell -F -t ${quoted} '#{&&:#{==:#{window-size},latest},#{||:#{!=:#{window_width},#{client_width}},#{!=:#{window_height},#{client_height}}}}' ` +
1384
+ tmuxSingleQuote(`switch-client -t ${quoted}`) +
1385
+ " " +
1386
+ tmuxSingleQuote(`display-message -p -t ${quoted} ''`),
1387
+ 2,
1388
+ 1,
1389
+ () => {},
1390
+ );
1391
+ }
1392
+
1360
1393
  private clientViewport: { cols: number; rows: number } | null = null;
1361
1394
  private cellPixels: {
1362
1395
  width: number;
@@ -2908,7 +2941,9 @@ export class SessionChannel {
2908
2941
  this.opts.onWindowTopologyChanged?.();
2909
2942
  if (
2910
2943
  name === "subscription-changed" &&
2911
- (rest.startsWith("tmux-ide-browser-icon ") || rest.startsWith("tmux-ide-reader "))
2944
+ (rest.startsWith("tmux-ide-browser-icon ") ||
2945
+ rest.startsWith("tmux-ide-reader ") ||
2946
+ rest.startsWith("tmux-ide-browser-kind "))
2912
2947
  ) {
2913
2948
  this.scheduleSync();
2914
2949
  return;
@@ -3326,6 +3361,7 @@ export class SessionChannel {
3326
3361
  displayName: display?.name ?? null,
3327
3362
  displayNameSource: display?.source ?? null,
3328
3363
  browserIcon: pane?.descriptor?.browserIcon ?? null,
3364
+ browserKind: pane?.descriptor?.browserKind ?? null,
3329
3365
  reader: pane?.descriptor?.reader ?? null,
3330
3366
  left: leaf.left,
3331
3367
  top: leaf.top,
@@ -65,6 +65,8 @@ export interface PaneStreamLeaseDescriptor {
65
65
  readonly sessionName: string;
66
66
  readonly runtimeSessionId: string | null;
67
67
  readonly panes: readonly string[];
68
+ /** #806: the one window this stream was issued for, or null for a pane set of the session. */
69
+ readonly semanticWindowId: string | null;
68
70
  readonly viewerMode: PaneStreamViewerMode;
69
71
  readonly terminalDelivery: TerminalDeliveryOffer | null;
70
72
  readonly status: PaneStreamLeaseStatus;
@@ -365,6 +367,7 @@ export class PaneStreamLeaseManager {
365
367
  sessionName: state.sessionName,
366
368
  runtimeSessionId: state.runtimeSessionId,
367
369
  panes: [...state.request.panes],
370
+ semanticWindowId: state.request.semanticWindowId ?? null,
368
371
  viewerMode: state.request.viewerMode,
369
372
  terminalDelivery: state.request.terminalDelivery ?? null,
370
373
  status: state.status,