Skip to content

fix(server): long setup scripts complete in macOS zsh - #37836

Open
sync wants to merge 3 commits into
pingdotgg:mainfrom
sync:fix/zsh-worktree-setup-paste-20261117
Open

sync wants to merge 3 commits into
pingdotgg:mainfrom
sync:fix/zsh-worktree-setup-paste-20261117

Conversation

@sync

@sync sync commented Nov 17, 2026 •

Copy link
Copy Markdown

Problem

New-worktree setup can hang in macOS zsh when the setup command is long. Instead of finishing and starting the agent, the terminal repeats corrupted __t3_command assignments.

Reproduce with the self-contained 120-line Unicode/quoting/backslash script and PTY helper in #37817. The helper waits for the shell's bracketed-paste readiness signal before sending the command; the original delivery still hangs with /bin/zsh -f, without user shell configuration.

Change

Submit long, multiline POSIX wrappers as one bracketed paste after the shell actually signals readiness, converting internal carriage returns to newlines and retaining the final Enter. Keep the quiet fallback distinct from that readiness signal so shells without an active line editor receive the existing input format.

Extend the existing long-script and quiet-shell tests. Short scripts and Fish, Nushell, and PowerShell submission paths are unchanged.

Scope

Fixes #37817.

One completion-tracked setup-input transport bug in the shared server runner, which also handles settle scripts. No client, contract, or unrelated shell-status changes.

Review notes and their disposition:

Review note Disposition
Transport guards needed direct test coverage. Extended existing cases to reject paste markers for PowerShell, quiet fallback, and short scripts, and to require the long-script envelope and LF-only interior.
Interactive Bash needed real readline verification. Verified Bash 5.3.20 after live readiness: all 120 expected lines and completion exit code 0.
Unobserved scripts and quiet fallback are not fully covered by this fix. Raw LF scripts and shells reaching the quiet fallback retain their pre-existing limitations. Raw CRLF scripts can also take the paste path. This PR does not claim to fix all unobserved scripts.
Shell redraw can leave wrapper fragments in the setup output tail. Known cosmetic limitation. Output filtering is outside this transport fix.
The syntax-error test fails on macOS system Bash 3.2. Confirmed on the unchanged upstream wrapper too: status 1 instead of the test's expected 2. No unrelated shell-status change included.
Runtime evidence has limits. Native macOS PTY and isolated real-server setup verified. Browser inspection covers the after-fix terminal result, not a UI-created before/after scenario. Linux remains unverified.

Verification

  • The extended long-script test fails on upstream base b79d277cddaf65858418f29d73b87fcc3d1a19c5 for the missing paste envelope, then passes with this fix.
  • Native macOS zsh 5.9 PTY reproduction: original delivery sends the command but produces 0/120 expected output lines and no completion sentinel before the diagnostic's five-second watchdog. Bracketed delivery verifies all 120 lines byte-for-byte and completion exit code 0.
  • Interactive Homebrew Bash 5.3.20, with no profile or rc file: after live readline readiness, the same bracketed input verifies all 120 output lines and completion exit code 0. Terminal escape sequences are removed before comparing output lines.
  • Actual isolated development-server worktree setup: terminal history verifies all 120 Unicode/quoting/backslash lines, the final marker, and completion exit code 0; workspace preparation and the replay-provider turn complete. Opened that thread in the built-in Browser panel and inspected the terminal drawer showing the final output lines and exit-0 sentinel. No installed app or live user state is used.
  • vp test run apps/server/src/project/ProjectSetupScriptRunner.test.ts: 14 passed, 1 failed. The sole failure is the existing syntax-error test expecting status 2; macOS system Bash 3.2 returns 1. Independently extracting and executing the unchanged upstream wrapper produces the same status 1.
  • vp run check:changed 4b758f49ec52ab58a0bd9647e28c9e2911945c88: format, lint, knip, GraphQL validation, and all three affected-package typechecks pass. Adjacent tests: 16 passed, 1 failed, the same baseline Bash discrepancy.
  • Browser pairing initially failed to produce screenshot frames; it recovered after pairing and direct thread navigation. The thread was created through the real server CLI, not through the new-thread UI. No before/after scenarios:prove run or other-OS shell verification is claimed. Native PTY and actual server terminal transcripts provide the before/after and runtime proof.

Independent council reviews from GPT-6.1 Sol, Claude Opus 5.5, and Claude Fable 5.2 approved this scoped change. Non-blocking notes and verification limits are documented above.

Created with GPT-6.1+ Sol in the Codex harness.

@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Nov 17, 2026
@macroscopeapp

macroscopeapp Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 640b5f7

Macroscope's review found this PR approvable — The change sends multiline POSIX setup commands as bracketed paste when the shell reports line-editor readiness, allowing long scripts to complete in macOS zsh. Script selection and execution permissions remain unchanged, with the existing input path retained for quiet-shell fallback.

You can add or adjust custom eligibility rules. Learn more.

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Nov 17, 2026
@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The runner now reports quiet when shell activity remains unchanged and no subprocess is busy. For a ready POSIX shell, it sends multiline commands with bracketed-paste markers and converts carriage returns to newlines. Tests cover these submission formats and marker-free shell input.

Changes: POSIX setup input delivery

Layer / File(s) Summary
Readiness-aware command delivery
apps/server/src/project/ProjectSetupScriptRunner.ts, apps/server/src/project/ProjectSetupScriptRunner.test.ts
The runner reports quiet when activity remains unchanged and the shell is not busy. For ready POSIX shells, it converts carriage returns to newlines and wraps multiline commands in bracketed-paste markers. Tests check quiet-shell and PowerShell submissions, marker-free shell input, and long-script formatting.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related PRs

Suggested labels: bugfix

Suggested reviewers: t3dotgg, maria-rcks

Merge Risk: Minimal · up to 8f844

This change submits long multiline POSIX setup scripts as a single bracketed paste once the shell is ready, which targets the macOS zsh hang. No concrete regression remains after review, so the merge risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: long setup scripts now complete in macOS zsh. It matches the linked issue #37817 and the PR objectives, which describe readiness-gated bracketed-paste delivery for lon…
Description check Passed The description follows the repository template. It has Problem, Change, Scope, and Verification sections with substantive content. The Problem section gives reproduction steps and the environment (ma…
Linked Issues check Passed [#37817] The requirement is that long, multiline POSIX setup wrappers run once in macOS zsh, report exit status, and let the agent start. The whole-PR diff against merge base d6a28f4 shows the transpo…
Out of Scope Changes check Passed The whole-PR diff touches only ProjectSetupScriptRunner.ts and its test file. The runner change is limited to the readiness-gated bracketed-paste branch and the return value of watchShellReadiness. Th…
Full details: Title check

Explanation

The title names the main change: long setup scripts now complete in macOS zsh. It matches the linked issue #37817 and the PR objectives, which describe readiness-gated bracketed-paste delivery for long multiline POSIX wrappers. It uses the conventional commit format with a fix(server) scope and stays within the 53-character length. It does not name the bracketed-paste mechanism, but it does not need to cover every detail.

Full details: Description check

Explanation

The description follows the repository template. It has Problem, Change, Scope, and Verification sections with substantive content. The Problem section gives reproduction steps and the environment (macOS zsh, /bin/zsh -f, PTY helper in #37817). The Change section explains the bracketed-paste fix and the quiet fallback. The Scope section links issue #37817 and explains why the change stays limited to the shared server runner. The Verification section lists focused test results, native macOS PTY and Bash checks, and an isolated server setup run. It also states the known limits: the one failing syntax-error test on Bash 3.2, unverified Linux and other-OS shells, and the lack of a UI-created before/after scenario. The template's optional agent-model line is present at the end. Some details are dense, but the required information is present.

Full details: Linked Issues check

Explanation

[#37817] The requirement is that long, multiline POSIX setup wrappers run once in macOS zsh, report exit status, and let the agent start. The whole-PR diff against merge base d6a28f4 shows the transport change in apps/server/src/project/ProjectSetupScriptRunner.ts. When the shell is ready, the completion shell is POSIX, and the command contains "\r", runForThread sends \x1b[200~ + commandLine with "\r" replaced by "\n" + \x1b[201~. The final Enter is kept. The quiet fallback now returns "quiet" instead of "ready", so it keeps the unbracketed input. The test diff asserts the bracketed envelope for long scripts, asserts no envelope for PowerShell, quiet-shell, and short-script paths, and checks line lengths on the unwrapped shell input. The current head matches the previous assessment's conclusion for the code. I did not run the tests. The zsh PTY, Bash, and development-server results are author-reported and were not re-run here. Manual UI steps in the issue are non-coding and out of scope.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff touches only ProjectSetupScriptRunner.ts and its test file. The runner change is limited to the readiness-gated bracketed-paste branch and the return value of watchShellReadiness. The "quiet" return value separates the quiet fallback from the readiness signal, which the bracketed-paste condition requires. The test changes support those behaviors: envelope assertions, the shell-input unwrapping used when Bash runs the submitted script, and the quiet-shell and PowerShell guards. The PR states that client, contract, Fish, Nushell, PowerShell submission, and unrelated shell-status code are unchanged, and the diff shows no such edits. Residual uncertainty remains: I did not check other call sites of watchShellReadiness that might depend on the old "ready" value for quiet shells. This is not a demonstrated out-of-scope change.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 640b5f7 and 8f84442.

Files selected for processing: 1

  • apps/server/src/project/ProjectSetupScriptRunner.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@juliusmarminge

Copy link
Copy Markdown
Member

The automated pipeline stopped on this pull request and will not merge it:

the fix is written and reviewed, but proving it needs something no worker has:

  • Permanent blocker: a macOS host running the T3 Code server with /bin/zsh is required. This worker is Linux, and the brief prohibits reaching another machine. Base corruption, head completion with exit code 0, content preservation, single execution, and waiting-agent startup remain unverified.

It stays open for a person to finish or close.

@juliusmarminge juliusmarminge added takeover:blocked Takeover blocked; reason in the PR body and removed takeover:in-progress A takeover lead is working on this PR labels Nov 17, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS 0-9 changed lines (additions + deletions). takeover:blocked Takeover blocked; reason in the PR body vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Long worktree setup scripts hang in macOS zsh

2 participants