Repository navigation
Description
Before submitting
- Searched issues for
zsh setupandsetup hangs, and open PRs forzsh setup,bracketed paste, andsetup line editoron November 17, 2026. No matching fix found in those searches. - Included a harmless setup script and an isolated PTY reproduction.
Area
apps/server
Steps to reproduce
-
Use macOS with
/bin/zshas the terminal shell and a T3 Code build containing the current POSIX setup wrapper. The affected runner is unchanged between upstream maine8e7fb7e9aandb79d277cddaf65858418f29d73b87fcc3d1a19c5. -
Generate a long, harmless setup script in Terminal:
node -e 'console.log(Array.from({length:120}, (_, index) => `printf "line-${index}\\n"`).join("\n"))' -
Set a disposable project's worktree-creation setup script to the generated 120 lines. Paste the generated output, not the Node generator itself, so T3 submits a long script.
-
Create a new thread in a new worktree with setup enabled.
-
Observe the Setup stage and open its terminal. The setup can remain pending with repeated or corrupted
__t3_commandassignments. The agent does not start. Cancel the disposable setup when finished.
The original report occurred in the desktop app with a longer project setup script. The short script above exercises the same long-wrapper delivery path. These exact simplified UI steps still need a fresh real-client run; the isolated PTY steps below have been run.
Isolated reproduction without starting T3
Use an installed T3 Code checkout on macOS. Save the companion reproduce.cjs outside the checkout. From the checkout root run:
node /path/to/reproduce.cjs
node /path/to/reproduce.cjs --bracketedThe helper reads the checkout's existing wrapPosixCommand implementation, starts only its own /bin/zsh -f PTY, waits for zsh's bracketed-paste-ready signal, then writes the entire wrapped command once. It prints 120 numbered lines with quoting, Unicode, and a backslash. It kills only that child after completion or a five-second diagnostic deadline.
- Default mode uses main's current carriage-return-separated delivery. It reproduces corrupted input and no completion sentinel within the diagnostic deadline.
--bracketedsends the same commands as a single bracketed paste. It verifies all 120 output lines and completion status 0.
This does not run the user's project script, access live T3 state, or start an agent. The diagnostic deadline establishes missing completion during the probe, not proof that the shell could never complete.
Expected behavior
The setup script executes once, reports its exit status, and allows the waiting agent to start.
Actual behavior
Long POSIX scripts become several complete __t3_command assignments separated by carriage returns. Writing all of them at once to native zsh can corrupt queued input as the line editor enters and leaves command execution. Setup does not receive its completion sentinel and remains pending.
Representative terminal output:
__t3_command="$ __t3_command="$ __t3_command="$ ...
Impact
Blocks work completely for new worktrees using an affected long setup script. The original setup was stopped manually.
Version or commit
Custom macOS arm64 build, based on upstream main e8e7fb7e9a. The relevant runner and test files are identical on upstream main b79d277cddaf65858418f29d73b87fcc3d1a19c5, fetched November 17, 2026. No claim that the latest released binary was independently tested.
Environment
macOS 26.7.3, build 25G342; Apple Silicon; zsh 5.9, arm64-apple-darwin25.0; Node v22.22.3. The PTY reproduction uses /bin/zsh -f, without normal user startup configuration. No provider behavior is required to reproduce it.
Related changes and reports
- fix(server): setup scripts complete with shell line editors #25472 introduced bounded long-script assignments. Its verification explicitly did not cover native zsh or macOS.
- fix(server): worktree setup no longer hangs when the shell is Nushell #29461 addressed Nushell completion and is not the same shell path.
- fix(terminal): run project actions after shell startup #36352 concerns project actions submitted before shell startup. This reproduction waits for zsh readiness and then fails during long-input delivery.
- [Bug]: Worktree setup hangs forever when the setup command fails to parse in fish, and imported t3.json actions silently go stale #32556 concerns Fish parsing. This reproduction uses valid POSIX statements in zsh.
Workaround and candidate fix
Cancel the stuck setup. Reducing the submitted setup command to a short invocation of a checked-in script should avoid the long-wrapper path, but that workaround has not been verified in the real client.
A local candidate uses bracketed paste for multiline POSIX wrapper delivery only after the shell has advertised bracketed-paste readiness. The quiet fallback remains unbracketed. The candidate completes the isolated 120-line zsh probe. It has not been installed into the live desktop app.
Verification notes for the candidate
- The existing long-script regression test fails before the delivery change and passes after it.
- Focused runner tests pass 14 of 15 cases on this Mac. The remaining syntax-error case expects Bash exit 2, but this Mac's system Bash returns 1. The unmodified HEAD wrapper also returns 1 for the same input.
vp run check:changed HEADpasses format, lint, dependency checks, GraphQL checks, and affected typechecks. Adjacent tests report the same pre-existing Bash expectation failure, not an all-green run.- Real client verification and independent review remain to be completed in the dedicated fix thread.
PTY reproduction helper
Save this as reproduce.cjs outside the checkout, then run the two commands above from an installed T3 Code checkout root. The default mode deliberately reproduces the original delivery; --bracketed demonstrates the alternative transport, not automatic detection of whether a build is fixed.
reproduce.cjs
const fs = require('node:fs');
const path = require('node:path');
const assert = require('node:assert/strict');
const { createRequire } = require('node:module');
const root = process.cwd();
const requireServer = createRequire(path.join(root, 'apps/server/package.json'));
const pty = requireServer('node-pty');
const source = fs.readFileSync(path.join(root, 'apps/server/src/project/ProjectSetupScriptRunner.ts'), 'utf8');
const start = source.indexOf('const utf8 =');
const end = source.indexOf('function wrapCommandForCompletion');
assert(start >= 0 && end > start, 'Run from a T3 Code checkout with the POSIX wrapper.');
const wrapperSource = source.slice(start, end).replaceAll(': string[]', '').replaceAll(': string', '');
const wrap = new Function(wrapperSource + '\nreturn wrapPosixCommand;')();
const command = Array.from({ length: 120 }, (_, index) => `printf '%s\\n' "line-${index}: café 雪 'quoted' \\\\path"`).join('\n');
const commandLine = wrap(command, '__T3_PROBE_DONE__:');
const bracketed = process.argv.includes('--bracketed');
const input = bracketed ? `\x1b[200~${commandLine.replaceAll('\r', '\n')}\x1b[201~` : commandLine;
const submitted = ' ' + input + '\r';
const child = pty.spawn('/bin/zsh', ['-f'], {
cwd: '/private/tmp', cols: 120, rows: 30,
env: { PATH: process.env.PATH, TERM: 'xterm-256color', PS1: 'probe> ', HOME: process.env.HOME, LANG: 'en_US.UTF-8' },
});
let output = '';
let sent = false;
let completed = false;
const watchdog = setTimeout(() => child.kill(), 5000);
child.onData(data => {
output += data;
if (!sent && output.includes('\x1b[?2004h')) {
sent = true;
child.write(submitted);
}
if (!completed && /(?:^|\r?\n)__T3_PROBE_DONE__:0\r?\n/.test(output)) {
completed = true;
child.kill();
}
});
child.onExit(() => {
clearTimeout(watchdog);
const lines = output.split('\r\n').filter(line => /^line-\d+:/.test(line));
console.log(JSON.stringify({ mode: bracketed ? 'bracketed' : 'current-main', sent, completed, verifiedLines: lines.length, inputBytes: Buffer.byteLength(submitted), outputTail: output.slice(-700) }, null, 2));
if (completed) {
assert.deepEqual(lines, Array.from({ length: 120 }, (_, index) => `line-${index}: café 雪 'quoted' \\path`));
}
process.exitCode = completed ? 0 : 1;
});
Activity