@dfosco/storyboard-core 4.2.0-alpha.7 → 4.2.0-alpha.9
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.
- package/package.json +1 -1
- package/src/canvas/terminal-server.js +31 -15
package/package.json
CHANGED
|
@@ -161,6 +161,12 @@ export function setupTerminalServer(httpServer, base = '/', branch = 'unknown')
|
|
|
161
161
|
if (addr && addr.port) actualServerPort = addr.port
|
|
162
162
|
} catch {}
|
|
163
163
|
|
|
164
|
+
// Ensure node-pty spawn-helper has execute permission (npm install can strip it)
|
|
165
|
+
try {
|
|
166
|
+
const nodePtyDir = resolve(process.cwd(), 'node_modules/node-pty/prebuilds')
|
|
167
|
+
execSync(`chmod +x "${nodePtyDir}"/darwin-*/spawn-helper 2>/dev/null || true`, { stdio: 'ignore' })
|
|
168
|
+
} catch {}
|
|
169
|
+
|
|
164
170
|
// Initialize registry and terminal config
|
|
165
171
|
const root = process.cwd()
|
|
166
172
|
const termCfg = readTerminalConfig()
|
|
@@ -206,6 +212,21 @@ function handleConnection(ws, widgetId, canvasId, prettyName) {
|
|
|
206
212
|
// Register in registry, check for conflicts
|
|
207
213
|
const { entry, conflict } = registerSession({ branch, canvasId, widgetId, prettyName })
|
|
208
214
|
|
|
215
|
+
// Resolve server URL deterministically:
|
|
216
|
+
// 1. Use the actual port from httpServer (set at setup time)
|
|
217
|
+
// 2. Fall back to server registry (tracks running dev servers)
|
|
218
|
+
// 3. Last resort: default port 1234
|
|
219
|
+
let serverPort = actualServerPort
|
|
220
|
+
if (!serverPort) {
|
|
221
|
+
try {
|
|
222
|
+
const name = detectWorktreeName()
|
|
223
|
+
const servers = findByWorktree(name)
|
|
224
|
+
if (servers.length > 0) serverPort = servers[0].port
|
|
225
|
+
} catch {}
|
|
226
|
+
}
|
|
227
|
+
if (!serverPort) serverPort = 1234
|
|
228
|
+
const serverUrl = `http://localhost:${serverPort}`
|
|
229
|
+
|
|
209
230
|
// Write terminal config for agent context
|
|
210
231
|
writeTermConfig({ branch, canvasId, widgetId, serverUrl })
|
|
211
232
|
|
|
@@ -236,21 +257,6 @@ function handleConnection(ws, widgetId, canvasId, prettyName) {
|
|
|
236
257
|
writeFileSync(join(zdotdir, '.zshrc'), `export PS1='${prompt.replace(/'/g, "'\\''")}'\nunset RPS1\n`)
|
|
237
258
|
} catch { /* best effort */ }
|
|
238
259
|
|
|
239
|
-
// Resolve server URL deterministically:
|
|
240
|
-
// 1. Use the actual port from httpServer (set at setup time)
|
|
241
|
-
// 2. Fall back to server registry (tracks running dev servers)
|
|
242
|
-
// 3. Last resort: default port 1234
|
|
243
|
-
let serverPort = actualServerPort
|
|
244
|
-
if (!serverPort) {
|
|
245
|
-
try {
|
|
246
|
-
const name = detectWorktreeName()
|
|
247
|
-
const servers = findByWorktree(name)
|
|
248
|
-
if (servers.length > 0) serverPort = servers[0].port
|
|
249
|
-
} catch {}
|
|
250
|
-
}
|
|
251
|
-
if (!serverPort) serverPort = 1234
|
|
252
|
-
const serverUrl = `http://localhost:${serverPort}`
|
|
253
|
-
|
|
254
260
|
const env = {
|
|
255
261
|
...process.env,
|
|
256
262
|
TERM: 'xterm-256color',
|
|
@@ -270,6 +276,7 @@ function handleConnection(ws, widgetId, canvasId, prettyName) {
|
|
|
270
276
|
let ptyProcess
|
|
271
277
|
let isNewSession = false
|
|
272
278
|
|
|
279
|
+
try {
|
|
273
280
|
if (hasTmux) {
|
|
274
281
|
const reattach = tmuxSessionExists(tmuxName)
|
|
275
282
|
|
|
@@ -353,6 +360,15 @@ function handleConnection(ws, widgetId, canvasId, prettyName) {
|
|
|
353
360
|
env,
|
|
354
361
|
})
|
|
355
362
|
}
|
|
363
|
+
} catch (spawnErr) {
|
|
364
|
+
console.error(`[storyboard] terminal spawn failed: ${spawnErr.message}`)
|
|
365
|
+
if (ws.readyState === ws.OPEN) {
|
|
366
|
+
ws.send(`\r\n\x1b[31m✖ Terminal failed to start: ${spawnErr.message}\x1b[0m\r\n`)
|
|
367
|
+
ws.send(`\x1b[2mTry: chmod +x node_modules/node-pty/prebuilds/darwin-*/spawn-helper\x1b[0m\r\n`)
|
|
368
|
+
ws.close()
|
|
369
|
+
}
|
|
370
|
+
return
|
|
371
|
+
}
|
|
356
372
|
|
|
357
373
|
const generation = entry.generation
|
|
358
374
|
ptyProcesses.set(tmuxName, ptyProcess)
|