@treeport/treeport 0.4.0 → 0.6.1

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.
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ import "../../../dist-Crk_Xr82.js";
2
3
  import { t as integrateShellLaunch } from "../../../shell-integration-Be_c91lw.js";
3
4
  import fs from "node:fs/promises";
4
5
  import path from "node:path";
@@ -13,6 +14,7 @@ const FORWARDED_SIGNALS = [
13
14
  ];
14
15
  const launchSpecSchema = z.object({
15
16
  argv: z.array(z.string()),
17
+ initialTitle: z.string().trim().min(1).max(120).optional(),
16
18
  fallbackArgv: z.array(z.string()).optional(),
17
19
  cwd: z.string(),
18
20
  env: z.record(z.string(), z.string()),
@@ -112,6 +114,7 @@ async function runLaunchSpec(spec, dependencies = {}) {
112
114
  const stdout = dependencies.stdout ?? process.stdout;
113
115
  const stderr = dependencies.stderr ?? process.stderr;
114
116
  const signalSource = dependencies.signalSource ?? process;
117
+ const tmuxPane = dependencies.tmuxPane === void 0 ? process.env.TMUX_PANE : dependencies.tmuxPane ?? void 0;
115
118
  if (spec.setupError) {
116
119
  stderr.write(`[Treeport setup] ${safeDiagnostic(spec.setupError) || "setup preparation failed"}\n`);
117
120
  return 1;
@@ -158,6 +161,24 @@ async function runLaunchSpec(spec, dependencies = {}) {
158
161
  ...spec.env
159
162
  };
160
163
  const command = integrateShellLaunch(spec.argv, commandEnvironment, spec.shellIntegrationDir, spec.tmuxExecutable);
164
+ const initialTitle = spec.initialTitle ? safeDiagnostic(spec.initialTitle) : "";
165
+ if (initialTitle && spec.tmuxExecutable && tmuxPane) {
166
+ if ((await runChild([
167
+ spec.tmuxExecutable,
168
+ "set-option",
169
+ "-p",
170
+ "-t",
171
+ tmuxPane,
172
+ "--",
173
+ "@treeport-command",
174
+ initialTitle
175
+ ], {
176
+ cwd: spec.cwd,
177
+ env: process.env,
178
+ spawnProcess,
179
+ signalSource
180
+ })).forwardedSignal) return 1;
181
+ }
161
182
  const result = await runChild(command.argv, {
162
183
  cwd: spec.cwd,
163
184
  env: command.env,
@@ -167,6 +188,30 @@ async function runLaunchSpec(spec, dependencies = {}) {
167
188
  if (result.spawnError) stderr.write(`Treeport launcher: ${safeDiagnostic(result.spawnError.message) || "spawn error"}\n`);
168
189
  if (result.forwardedSignal && (!spec.fallbackArgv || result.forwardedSignal !== "SIGINT")) return 1;
169
190
  if (spec.fallbackArgv) {
191
+ if (spec.tmuxExecutable && tmuxPane && spec.fallbackArgv[0]) {
192
+ if ((await runChild([
193
+ spec.tmuxExecutable,
194
+ "set-option",
195
+ "-p",
196
+ "-u",
197
+ "-t",
198
+ tmuxPane,
199
+ "@treeport-command",
200
+ ";",
201
+ "set-option",
202
+ "-p",
203
+ "-t",
204
+ tmuxPane,
205
+ "--",
206
+ "@treeport-fallback-shell",
207
+ Buffer.from(JSON.stringify(spec.fallbackArgv[0]), "utf8").toString("base64url")
208
+ ], {
209
+ cwd: spec.cwd,
210
+ env: process.env,
211
+ spawnProcess,
212
+ signalSource
213
+ })).forwardedSignal) return 1;
214
+ }
170
215
  const fallback = integrateShellLaunch(spec.fallbackArgv, commandEnvironment, spec.shellIntegrationDir, spec.tmuxExecutable);
171
216
  const fallbackResult = await runChild(fallback.argv, {
172
217
  cwd: spec.cwd,