fix(server): preserve shell paths containing spaces and dashes #37069
main fromrefs/pull/37069/head·merged by juliusmarminge View on GitHubA valid unquoted $SHELL path such as /.../Jane -Doe/bash was truncated before PTY launch. A real terminal then exited with execvp(3) failed instead of starting the configured shell.
Resolve the longest existing file path before applying the historical flag stripping. This also handles directory components containing spaces or =, while preserving quoted paths, shell flags and Windows behavior. The filesystem lookup stays inside the server terminal manager shared by all clients.
Proof#
The terminal-shell-launch bughunt found this on main 015eba4083974f8ed86694a8770a4311d8a4714b; an independent Claude Opus 5.5 verifier confirmed it. Reproduced again before fixing.
- The focused public
TerminalManager.openregression fails against main and passes on this branch forJane -Doe,Jane -Doe=Smith, andJane -Doe Smith. - A real Manager plus native PTY, with executable symlinks to
/bin/bashin an isolated home, fails on base and prints the intact shell path on head for all three forms. Plain-space control launches on both. - Full Manager tests and
pnpm exec vp run check:changedpass. Existing quoted-path, flag, macOS bash and Windows tests remain covered. Native proof is Linux only.
Runtime transcript (fixture prefix shortened):
base: SHELL=/<fixture>/Jane -Doe/bash
open: status=running pid=true
outcome: exited 1
execvp(3) failed.: No such file or directory
head: SHELL=/<fixture>/Jane -Doe/bash
outcome: marker
SHELL_OK:/<fixture>/Jane -Doe/bash
Medium fast-lane fix: private startup resolution becomes effectful; no public interface, storage or UI change. The longest existing file wins an inherently ambiguous unquoted string. Invalid command strings such as /usr/bin/env bash are outside the supported shell-path contract.
Council review#
| Reviewer | Round 1 | Round 2 |
|---|---|---|
| Claude Opus 5.5 | 9/10 | 9/10 |
| GPT 6.1 Sol | 8/10 | 8/10 |
Round 1 directory siblings were fixed. Round 2 Sol's remaining concern was Windows portability of the POSIX test fixture; afterward the fixture was mapped through the test filesystem to the host's temporary directory and its red/green proof and fast checks rerun. Opus's original missing-file assertion was restored. The final fixture adjustment has not received another council round. Local cubic found no issues in both rounds; fork-specific repository context was unavailable. No separate proof-audit run in the fast lane.
Closes #37068
Created with GPT 6.1 Sol and Claude Opus 5.5 in T3 Code using the Codex and Claude harnesses.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
Approvability#
Verdict: Approved at
7fd5d11Macroscope's review found this PR approvable — Preserves configured POSIX shell paths containing spaces and dashes by checking existing files before stripping flags. Default shells, Windows behavior and launch fallbacks remain unchanged, keeping the impact narrowly scoped.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).juliusmarminge added labelstakeover:in-progress
No actionable comments were generated in the recent review.
Walkthrough
-
Shell command normalization now checks filesystem paths to identify unquoted absolute shell paths that contain whitespace. Candidate resolution and session startup use the Effect workflow. Tests cover existing and missing paths with spaces, punctuation, and shell options.
Changes: Shell path normalization
Layer / File(s) Summary Normalize and resolve shell candidates
apps/server/src/terminal/Manager.ts,apps/server/src/terminal/Manager.test.tsNormalization checks an unquoted absolute command and progressively shorter whitespace-delimited prefixes against the filesystem. The resolver and session startup use the Effect workflow. Tests cover existing and missing paths with spaces and punctuation, plus quoted paths with shell options. Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Low
Suggested reviewers:
marcodotio,juliusmarminge,saphid
Merge Risk:
Minimal · up to2063e-
This change lets terminal startup launch unquoted shell paths that contain spaces, dashes, or equals signs, instead of truncating them. The changed behavior is confined to server shell resolution and is covered by focused tests. No merge-blocking risk is identified.
Pre-merge checks:
4-
Check name Status Explanation Title check The title names the main change: preserving unquoted shell paths that contain spaces and dashes in the server terminal shell startup. The raw summary, objectives, and description all describe the same… Description check The description follows the template's main sections: Problem (truncated unquoted $SHELL path before PTY launch, with execvp(3) failure), Change (resolve longest existing file path before flag strippi… Linked Issues check Issue #37068requiresTerminalManager.opento launch the full configured shell path when an unquoted absolute$SHELLcontains a whitespace-followed dash directory (Jane -Doe,Jane -Doe=Smith, …Out of Scope Changes check All changed hunks in Manager.ts and Manager.test.ts relate to unquoted shell-path resolution. The Effect conversion of normalizeShellCommandandresolveShellCandidatesis needed for the filesystem…Full details: Title check
-
Explanation
The title names the main change: preserving unquoted shell paths that contain spaces and dashes in the server terminal shell startup. The raw summary, objectives, and description all describe the same change, so the title matches the changeset and states the fix type.
Full details: Description check
-
Explanation
The description follows the template's main sections: Problem (truncated unquoted $SHELL path before PTY launch, with execvp(3) failure), Change (resolve longest existing file path before flag stripping), Scope (references issue
#37068and explains the fix is a bug fix), and Verification (focused regression tests, native PTY proof, Manager tests, and check:changed run, with a transcript). It also notes untested areas (native proof is Linux only) and includes the agent/model attribution line. The Scope section does not clearly state a maintainer request, which the template treats as optional. The description is thorough and complete enough to pass.
Full details: Linked Issues check
-
Explanation
Issue
#37068requiresTerminalManager.opento launch the full configured shell path when an unquoted absolute$SHELLcontains a whitespace-followed dash directory (Jane -Doe,Jane -Doe=Smith,Jane -Doe Smith). In apps/server/src/terminal/Manager.ts,normalizeShellCommandnow handles unquoted absolute paths containing whitespace. It stats the full string, then each prefix ending at a whitespace boundary, longest first. It returns the first candidate that stats as aFile. APlatformErrorcounts as a non-match. Quoted input returns early as before. The old flag-stripping logic runs only when no candidate exists.resolveShellCandidatesyields the normalized values, and the call site provides theFileSystemservice. In Manager.test.ts, the$SHELLtest uses a real temp fixture with aJane -Doe Smithdirectory and a trailing-lflag. It asserts the spawn shell is the full path. A missing unquoted path and quoted paths with spaces and dashes are also asserted. The=andJane -Doeforms are not separately tested in the diff I read. The PR reports the focused regression fails on base and passes on head, and that a native Linux PTY run launches the intact path. I did not re-run the tests. The issue requirement is implemented in code.
Full details: Out of Scope Changes check
-
Explanation
All changed hunks in Manager.ts and Manager.test.ts relate to unquoted shell-path resolution. The Effect conversion of
normalizeShellCommandandresolveShellCandidatesis needed for the filesystem existence check. TheFileSystemservice is provided at the single call site. The test changes cover the reported shell-path forms, a missing path, and quoted paths. The POSIX-to-temp-directory mapping in the test fixture is test-only support for Windows portability and supports the same behavior. The diff shows no changes to exported declarations, storage, or UI. ThefileSystemidentifier used at the call site is not declared in the hunks I read. I assume it is in scope inmakeWithOptions, and this does not affect the verdict. The PR notes that the final fixture adjustment did not get a second council round. This is a process gap, not an 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-
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: main
- File: .coderabbit.config.ts
- Commit: 2386789
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Advanced
- Run ID:
1fef7cce-56c4-445f-b67e-470ef9b0fb53
Commits-
Reviewing files that changed from the base of the PR and between 7fd5d11701be3c52e1935526701d0ed6bd45cbef and 2063eaf06f662c5e538f6b8c4bfd97cf81ea7efa.
Files selected for processing: 1-
apps/server/src/terminal/Manager.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
-
-
Evidence#
Linux, Chromium, 1280×800, light theme; fresh isolated databases and synthetic replay-seeded threads on both commits.
Create executable symlinks to
/bin/bashinside absolute directories namedJane -Doe,Jane -Doe=Smith, andJane -Doe Smith. For each variant, launch the server withSHELLset to the complete path without literal quote characters, open a thread, and open a new terminal. Print the bash version and$0, and verify that bash executes a command using the complete invocation path.All three comparisons failed on base and passed on head. Base visibly reports
execvp(3) failed: No such file or directoryfollowed by[terminal] Process exited. Head remains interactive and prints the complete path. Before stills are unaltered recording frames captured before the failed drawer closes.Shell directory Before After Commit 238678951a 2063eaf06f Jane -Doe

Jane -Doe=Smith

Jane -Doe Smith

Shell directory Before interaction After interaction Jane -DoeBefore recording After recording Jane -Doe=SmithBefore recording After recording Jane -Doe SmithBefore recording After recording Scenario · Fixture setup and reproduction driver · Recording frame extraction · Sanitized runner logs
Not shown:
- The web client displayed process exit but not the numeric native PTY exit code.
juliusmarminge added labelstakeover:ready
juliusmarminge removed labelstakeover:in-progress
juliusmarminge merged this0720280
juliusmarminge closed this
juliusmarminge removed labelstakeover:ready
StiensWout(GitHub profile, opens in a new tab) linked this to fix #37068
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes