Skip to content

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

Merged
juliusmarminge merged 4 commits into
pingdotgg:mainfrom
sync:fix/zsh-worktree-setup-paste-20261117
Nov 23, 2026
Merged

juliusmarminge merged 4 commits into
pingdotgg:mainfrom
sync:fix/zsh-worktree-setup-paste-20261117

Conversation

@sync

@sync sync commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

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 reports quiet when the shell is not busy after the quiet-period fallback. For a ready POSIX shell, it sends multiline commands with bracketed-paste markers and converts carriage returns to newlines. Tests cover shell-specific submissions and marker-free input handling.

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 the shell is not busy after the quiet-period fallback. For ready POSIX shells, it converts carriage returns to newlines and wraps multiline commands in bracketed-paste markers. Tests cover PowerShell and quiet-shell 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

Suggested reviewers: maria-rcks, kendjohnson

Merge Risk: Minimal · up to 9c99b

This change makes long multiline setup scripts run reliably in macOS zsh by sending them as a single bracketed paste once the shell is ready. Short scripts and the other shell paths behave as before. No concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: long multiline setup scripts now complete in macOS zsh. The raw summary shows the transport change that sends long POSIX wrappers as one bracketed paste after readines…
Description check Passed The description follows the template. It has Problem, Change, Scope, and Verification sections, and each section is filled with specific content. It links issue #37817, lists the review notes and thei…
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 current head is 9c99be4, a merge of origin/main into the f…
Out of Scope Changes check Passed The supplied change summary for the current head lists only apps/server/src/project/ProjectSetupScriptRunner.ts and its test file. The runner change is limited to the readiness-gated bracketed-paste b…
Full details: Title check

Explanation

The title names the main change: long multiline setup scripts now complete in macOS zsh. The raw summary shows the transport change that sends long POSIX wrappers as one bracketed paste after readiness, which targets that outcome. The title follows the conventional commit format, is specific, and is not misleading.

Full details: Description check

Explanation

The description follows the template. It has Problem, Change, Scope, and Verification sections, and each section is filled with specific content. It links issue #37817, lists the review notes and their disposition, and reports verification with commands, environments, and observed results. It also states limits, such as unverified Linux behavior and the failing Bash 3.2 syntax-error test. The template's agent-model line is present at the end. One gap: the description says the 'Scope' section should link the issue, and it does (Fixes #37817). The description is long, but it covers every required section with concrete information.

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 current head is 9c99be4, a merge of origin/main into the fix branch. The whole-PR diff against merge base d63b9c4 could not be read because changed blobs are missing from the checkout. The current-head conclusion therefore relies on the supplied change summary and the previous assessment. That summary states that runForThread sends a POSIX command containing carriage returns as \x1b[200~ + the command with CR replaced by LF + \x1b[201~ when the shell is ready. The final Enter is kept. watchShellReadiness returns "quiet" instead of "ready" for the quiet fallback, which keeps unbracketed input. The test changes assert the long-script envelope and the absence of the envelope for PowerShell, quiet-shell, and short-script paths. 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.

Full details: Out of Scope Changes check

Explanation

The supplied change summary for the current head lists only apps/server/src/project/ProjectSetupScriptRunner.ts and its test file. The runner change is limited to the readiness-gated bracketed-paste branch and the quiet-fallback return value. The test changes support those behaviors. The PR states that client, contract, Fish, Nushell, PowerShell submission, and unrelated shell-status code are unchanged. The merge with origin/main adds no file the summary attributes to this PR. Residual uncertainty: the whole-PR file list could not be verified from repository diff because changed blobs are missing from the checkout, and call sites of watchShellReadiness were not checked for dependence on the old "ready" value. No demonstrated out-of-scope change exists.

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 8f84442 and 9c99be4.

Files selected for processing: 2

  • apps/server/src/project/ProjectSetupScriptRunner.test.ts
  • 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; 9 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 takeover:in-progress A takeover lead is working on this PR and removed takeover:in-progress A takeover lead is working on this PR takeover:blocked Takeover blocked; reason in the PR body labels Nov 17, 2026
@juliusmarminge

Copy link
Copy Markdown
Member

Evidence

Proven on macOS with /bin/zsh: scenarios:prove exited 0. Both sides used identical fresh synthetic data, UI steps, light theme, and 1280×800 captures at 1x.

Steps: paste the literal 120-line printf script into a synchronous worktree-creation action; create a new worktree thread from main; submit the same Replay prompt; inspect the setup terminal.

Before After
d63b9c4c76 9c99be48d7
Before: corrupted assignments leave setup pending After: numbered output and completion sentinel with exit code 0
Before recording After recording

Head verified exactly 120 ordered output lines, once each, the :0 completion sentinel, and the waiting agent's reply. Pairing startup was removed from recordings; workspace paths were visibly redacted.

Scenario source · Proof summary · Supplemental manual head output scroll

@juliusmarminge juliusmarminge added takeover:ready Takeover done; auto-lands when gates pass and removed takeover:in-progress A takeover lead is working on this PR labels Nov 23, 2026
@juliusmarminge
juliusmarminge merged commit 3ab1ee2 into pingdotgg:main Nov 23, 2026
17 checks passed
@juliusmarminge juliusmarminge removed the takeover:ready Takeover done; auto-lands when gates pass label Nov 23, 2026
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). 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