fix(server): setup scripts complete with shell line editors#25472

open1
main
maria/takeover-pr-17817
opened2d agobyMmaria
View on GitHubTwo-way sync enabledPR last imported 1d ago

Problem

Bash line editors can treat carriage-return-separated setup wrappers as unfinished multiline input. Worktree setup then never reports completion and the waiting agent cannot start.

Change

Submit complete POSIX commands with encoded script text, preserve trailing newlines, and evaluate in a subshell before reporting exit status. Long scripts use bounded, independently complete assignments. Preserve Fish, PowerShell, and main's startup-readiness handling. Reuse the existing test harness instead of adding another mock runner.

Scope and approval

This is an obvious, focused bug fix under the small-fix contribution exception. It only repairs POSIX completion-observed setup and settle delivery, preserving the original intent and all other shell paths. Maintainer takeover was already recorded on #17817, and Maria explicitly requested this replacement after the archived fork rejected pushes.

Verification

  • vp run check:changed passed through Blacksmith: format, lint, both knip passes, GraphQL generation, affected typechecks, and all 12 adjacent tests. The six shell cases include literals/heredocs, long input, stdin, trailing backslash-newline, explicit exit, and syntax error. Two fail against current main before the fix.
  • Real dev client with Bash 5.2 and ble.sh: main remains in MULTILINE with setup waiting; this branch completes the same setup and the Codex agent replies setup verified.
  • Additional real node-pty checks pass with plain Bash and ble.sh: multiline/heredoc, trailing backslash-newline, explicit exit 7, syntax error 2, and 120-line Unicode script.
  • Two independent GPT-6.1-Sol static reviews found no blockers. The replacement's file contents are identical to the reviewed merge candidate.
  • Unverified: native zsh, Fish, PowerShell, macOS/Windows, mobile/Electron, relay/tunnel. Long-input byte limits are tested; the long case was not repeated through the browser. Existing cosmetic limit: line-editor redraws can show internal assignments for long scripts.

main waits in ble.sh multiline input

replacement completes setup and starts the agent

worktree setup completes and starts the agent

Takeover

Replaces #17817, with thanks to @sgaabdu4 for the original implementation.

The contributor fork is archived and rejects maintainer pushes. Compared with the original PR's current diff, this retains its production wrapper and all six shell regression cases, replaces the duplicate test harness with main's harness, and preserves main's startup-readiness tests. No behavior was dropped. The commit credits Abid A Gafoor.

Built with GPT-6.1-Sol in the Codex harness on T3 Code.

Checks

21 successful · 7 skipped · 1 neutral
All checks passed
301c1a1

Added 1 commit

  • fix(server): setup scripts complete with shell line editors301c1a1
Synced from GitHub

Approvability

Verdict: Needs Human Approval

Macroscope's review found this PR requires human approval — The fix changes the production POSIX setup-script execution wrapper for all completion-observed scripts, adding shell encoding, eval-based execution, and terminal-size chunking. The scope is focused and well tested, but the runtime logic is sufficiently intricate to warrant human review.

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

Synced from GitHub

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

ProviderMetricMain baselineThis PRImpactPR ceiling
CodexTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
CodexLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
CodexLive turn WebSocket decoded20.9 KiB20.9 KiB0 B (0.0%)29.3 KiB✅
CodexLive turn messages220 (0.0%)8✅
ClaudeTotal thread wire5.0 KiB5.0 KiB+24 B (+0.5%)6.8 KiB✅
ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
ClaudeLive turn WebSocket wire1.2 KiB1.2 KiB+24 B (+2.0%)2.0 KiB✅
ClaudeLive turn WebSocket decoded21.2 KiB21.2 KiB+41 B (+0.2%)29.3 KiB✅
ClaudeLive turn messages12+1 (+100.0%)8✅

Baseline: 0712398 · PR result: 301c1a1 · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

Synced from GitHub

Review in Change Stack →

No actionable comments were generated in the recent review.

External image Recent review info
External image Run configuration
External image Commits

Reviewing files that changed from the base of the PR and between 071239804e375078dd3fae3b14704b4def57e048 and 301c1a1a30b00a7ef3bae145ef3c6c310a0f8ff7.

External image 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; 0 remain after this review.

Walkthrough

The POSIX completion wrapper now encodes and evaluates setup commands in a subshell, splits long commands into bounded terminal lines, and reports their exit status. Tests cover multiline syntax, literal text, long scripts, stdin, trailing backslash-newline behavior, and nonzero exit codes.

Changes: POSIX setup command delivery

Layer / File(s)Summary
POSIX wrapper and execution validation
apps/server/src/project/ProjectSetupScriptRunner.ts, apps/server/src/project/ProjectSetupScriptRunner.test.ts
The POSIX wrapper encodes and evaluates commands in a subshell, splits commands that exceed the 1,023-byte terminal line limit, and emits the command status. Tests submit commands to Bash and verify multiline syntax, long scripts, stdin, trailing backslash-newline behavior, and exit codes.

Priority: External image Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Possibly related PRs

  • pingdotgg/t3code#24775: Both PRs change setup command delivery through ProjectSetupScriptRunner; this PR changes the POSIX wrapper submitted after shell readiness.
  • pingdotgg/t3code#23576: Both PRs modify shell-specific completion behavior in ProjectSetupScriptRunner.
  • pingdotgg/t3code#24428: Both PRs change setup-script completion wrappers and exit-status reporting.

Suggested labels: bugfix, size:M

Suggested reviewers: t3dotgg, juliusmarminge

Merge Risk: External image Minimal · up to 301c1

No actionable merge-blocking issue is identified; the setup-command change is ready for normal merge checks.

Pre-merge checks: Passed 4
Check nameStatusExplanation
Title checkPassedThe title clearly and concisely describes the main change: fixing setup script completion with shell line editors.
Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
Description checkPassedThe pull request description includes all required sections: Problem, Change, Scope and approval, and Verification. It explains the bug, implementation, approval basis, focused test results, observed …
Full details: Description check

Explanation

The pull request description includes all required sections: Problem, Change, Scope and approval, and Verification. It explains the bug, implementation, approval basis, focused test results, observed behavior, unverified environments, screenshots, and the agent model and harness used.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

Note

Written by gpt-6.1-sol on behalf of Maria

Verified in a real dev environment

verified unchanged head 301c1a1a30b00a7ef3bae145ef3c6c310a0f8ff7 on this linux boat vm. git.cafe and github both use #25472. the pr is open; its sole commit has no authors from the excluded maintainer accounts.

  • installed dependencies with vp i in a separate github/main worktree (4914cdd98f) and on the exact pr head. ran both dev environments in the background with separate state. used repository playwright and /usr/bin/google-chrome.
  • created a project pointing at a real git repository through the client. configured a synchronous worktree setup action through the action editor. used bash 5.2.21 with ble.sh cb9c2c3.
  • on main, the multiline script with an apostrophe, quoted heredoc, unicode, and a trailing comment stays in ble.sh's MULTILINE state. setup waits and the provider does not start.
  • on this head, the same script completes, creates setup-proof.txt, and starts a real codex gpt-6.1-sol turn through the local proxy. codex runs cat setup-proof.txt and returns setup verified.
  • neighboring behavior: a 120-line unicode/quoted/backslash script completes through the same worktree flow, then codex reads its proof file. exit 7 reports exactly that status in the client and prevents the agent from starting.
  • blacksmith vp run check:changed 071239804e375078dd3fae3b14704b4def57e048 passed format, lint, both knip passes, graphql generation, affected typechecks, and all 12 adjacent tests. an explicit pr base was needed because the worker has shallow history. the pr currently has 29 successful checks, none failing or pending.

short runtime transcript:

text
1$ git rev-parse HEAD
2301c1a1a30b00a7ef3bae145ef3c6c310a0f8ff7
3$ cat .t3/worktrees/setup-verification/t3-795aa242/setup-proof.txt
4setup verified
5$ cat .t3/worktrees/setup-verification/t3-d20de44d/setup-proof.txt
6setup verified
7client, exit-7 scenario: Setup script exited with 7.
8blacksmith adjacent tests: 12 passed

main: ble.sh multiline setup blocks agent startup

pr: codex reads the file created by the same setup

pr: setup completes and the real codex turn reads its proof file

pr: exit 7 is reported and agent startup is blocked

Not verified

native ios/android and electron clients, macos/windows, zsh/fish/powershell, relay/tunnel connections, other providers, and the settle-trigger path were not exercised on this linux web-client pass. interactive stdin and trailing backslash-newline have passing adjacent automated coverage, but were not repeated through the browser. no performance claim is made; ble.sh redraws expose internal assignments during long scripts.