Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): preserve shell paths containing spaces and dashes #37069

MergedStiensWout(GitHub profile, opens in a new tab)merged 0 commits intomain fromrefs/pull/37069/headmerged by juliusmarminge View on GitHub

A 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.open regression fails against main and passes on this branch for Jane -Doe, Jane -Doe=Smith, and Jane -Doe Smith.
  • A real Manager plus native PTY, with executable symlinks to /bin/bash in 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:changed pass. 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

ReviewerRound 1Round 2
Claude Opus 5.59/109/10
GPT 6.1 Sol8/108/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

    2. Approvability

      Verdict: Approved at 7fd5d11

      Macroscope'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).
    3. juliusmarminge added labelstakeover:in-progress

    4. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Explain Change →

      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.ts
      Normalization 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 to 2063e

      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: Passed 4

      Check nameStatusExplanation
      Title checkPassedThe 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 checkPassedThe 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 checkPassedIssue #37068 requires TerminalManager.open to launch the full configured shell path when an unquoted absolute $SHELL contains a whitespace-followed dash directory (Jane -Doe, Jane -Doe=Smith, …
      Out of Scope Changes checkPassedAll changed hunks in Manager.ts and Manager.test.ts relate to unquoted shell-path resolution. The Effect conversion of normalizeShellCommand and resolveShellCandidates is 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 #37068 and 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 #37068 requires TerminalManager.open to launch the full configured shell path when an unquoted absolute $SHELL contains a whitespace-followed dash directory (Jane -Doe, Jane -Doe=Smith, Jane -Doe Smith). In apps/server/src/terminal/Manager.ts, normalizeShellCommand now 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 a File. A PlatformError counts as a non-match. Quoted input returns early as before. The old flag-stripping logic runs only when no candidate exists. resolveShellCandidates yields the normalized values, and the call site provides the FileSystem service. In Manager.test.ts, the $SHELL test uses a real temp fixture with a Jane -Doe Smith directory and a trailing -l flag. It asserts the spawn shell is the full path. A missing unquoted path and quoted paths with spaces and dashes are also asserted. The = and Jane -Doe forms 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 normalizeShellCommand and resolveShellCandidates is needed for the filesystem existence check. The FileSystem service 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. The fileSystem identifier used at the call site is not declared in the hunks I read. I assume it is in scope in makeWithOptions, 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

      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.

    5. Evidence

      Linux, Chromium, 1280×800, light theme; fresh isolated databases and synthetic replay-seeded threads on both commits.

      Create executable symlinks to /bin/bash inside absolute directories named Jane -Doe, Jane -Doe=Smith, and Jane -Doe Smith. For each variant, launch the server with SHELL set 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 directory followed 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 directoryBeforeAfter
      Commit238678951a2063eaf06f
      Jane -DoeBefore: Jane -Doe, execvp failureAfter: Jane -Doe, interactive bash
      Jane -Doe=SmithBefore: Jane -Doe=Smith, execvp failureAfter: Jane -Doe=Smith, interactive bash
      Jane -Doe SmithBefore: Jane -Doe Smith, execvp failureAfter: Jane -Doe Smith, interactive bash
      Shell directoryBefore interactionAfter interaction
      Jane -DoeBefore recordingAfter recording
      Jane -Doe=SmithBefore recordingAfter recording
      Jane -Doe SmithBefore recordingAfter 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.
    6. juliusmarminge added labelstakeover:ready

    7. juliusmarminge removed labelstakeover:in-progress

    8. juliusmarminge merged this0720280

    9. juliusmarminge closed this

    10. juliusmarminge removed labelstakeover:ready

Sign in to join this conversation.