Skip to content

fix(contracts): preserve trailing spaces in task folder repository paths - #47733

Merged
juliusmarminge merged 3 commits into
pingdotgg:mainfrom
saphid:hunter/c-a41d65c114
Dec 2, 2026
Merged

juliusmarminge merged 3 commits into
pingdotgg:mainfrom
saphid:hunter/c-a41d65c114

Conversation

@saphid

@saphid saphid commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Problem

Adding a tracked Git repository whose directory ends in a space to an existing task folder fails because the add request trims the path before matching it against the project. Reading task-folder repository records also trims the repository and checkout paths.

Deterministic repro on origin/main (9c846a85f35c0467c5a418e67727611363a1efb2): On POSIX with dependencies installed, download reproduce.mjs from the evidence gist to your current directory, then run from the checkout root:

fixture_script="$(realpath reproduce.mjs)"
(cd apps/server && EXPECT=base node --input-type=module < "$fixture_script")

The fixture creates an isolated project with two tracked Git repositories, api and repo , then launches a worktree thread with only api selected. The web/desktop and mobile repository pickers use workspace.listFolders and addableTaskFolderRepositories to pass the exact second path to workspace.addTaskFolderRepository. The fixture follows that same RPC path: TaskFolders.addRepository compares resolved paths, creates the Git checkout, and writes it through TaskFolderStore; workspace.taskFolder reads that record back for the repository rows.

  • Observed: The live RPC returns "/tmp/fixture/repo" is not a tracked folder of the project. and creates no checkout. A stored repository entry with "/tmp/workspace/repo " and "/tmp/task/repo " also decodes without the spaces.
  • Expected: The add RPC creates the checkout on the thread's branch and returns both literal paths, including the trailing spaces. workspace.taskFolder returns those same paths from storage.

Change

Use NonBlankString for the add request's repository path and the stored and returned repository and checkout paths, matching the tracked-folder schemas. The RPC, SQLite codec, and shared client already use these contracts, so web, desktop, and mobile need no separate changes to the add flow.

Scope

Small fix for an obvious bug; no issue needed under CONTRIBUTING.md.

Verification

  • The original decode assertions failed on base because they lost trailing spaces. The existing wire-whitespace test now round-trips both the add request and the repository JSON codec used by TaskFolderStore, covering encode and decode. The targeted test file passed all 8 tests.
  • The before/after live WebSocket transcript and fixture show the base rejection and the fixed checkout on branch proof, with both literal paths intact in the response and SQLite-backed read-back. Run the same fixture on the fixed commit with EXPECT=fixed.
  • vp run check:changed exited 0: format, lint, Knip, typecheck across 39 packages, and 10 tests in 2 files.
  • Not shown: Interactive web, desktop, or mobile; relay or tunnel connections; macOS or Windows. Explicitly selecting a whitespace-ended repository at initial thread launch and subsequent VCS status/actions use separate path schemas and are outside this fix.

Authored by GPT-6.2 Sol (Codex); reviewed by Gemini 4 Neon (Antigravity).

@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Dec 2, 2026
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Dec 2, 2026
@macroscopeapp

macroscopeapp Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 59e78d6

Macroscope's review found this PR approvable — The contracts now preserve edge whitespace in task-folder repository paths and VCS status working directories while still rejecting blank values. This is a narrow path-handling correction with no product-default changes or obvious material operational risk.

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

@coderabbitai

coderabbitai Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Task-folder repository and VCS status path schemas now use NonBlankString. Contract tests check whitespace preservation, and an end-to-end scenario adds a repository with a trailing space to an open task.

Changes: Task-folder path handling

Layer / File(s) Summary
Path schemas and round-trip validation
packages/contracts/src/workspaceFolders.ts, packages/contracts/src/git.ts, packages/contracts/src/project.test.ts
Task-folder repository paths and VCS status working-directory paths now use NonBlankString. Contract tests check that paths containing whitespace remain unchanged through schema encoding and decoding.
Trailing-space repository scenario
scripts/scenarios/task-folder-adds-repository-with-trailing-space.e2e.ts
The end-to-end scenario adds a repository with a trailing space to an open task and checks that its repository group and t3/ path appear.

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

Change: Bug fix

Merge Risk: Minimal · up to 59e78

This change keeps trailing spaces in task-folder repository and VCS status paths, so repositories with such directory names can be added and recognized. The tests cover the behavior and no merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: trailing spaces are preserved in task folder repository paths, which matches the raw summary and objectives (NonBlankString replacing TrimmedNonEmptyString in the add …
Description check Passed The description follows the template sections (Problem, Change, Scope, Verification). It explains the bug, the repro on origin/main, the fix using NonBlankString, why no issue is needed, and detailed …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: trailing spaces are preserved in task folder repository paths, which matches the raw summary and objectives (NonBlankString replacing TrimmedNonEmptyString in the add request and stored repository paths). The title uses a conventional commit format and is specific. It does not mention the follow-up VCS status change, which is a secondary part of the PR.

Full details: Description check

Explanation

The description follows the template sections (Problem, Change, Scope, Verification). It explains the bug, the repro on origin/main, the fix using NonBlankString, why no issue is needed, and detailed verification with results. It also states what was not checked. The template's conventional-commit title guidance is met by the PR title. The description does not cover the follow-up VCS status change that the objectives mention, and the 'Authored by' and model-attribution line is extra. These gaps are minor, so the description is mostly complete.

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 8f2ba57 and 59e78d6.

Files selected for processing: 3

  • packages/contracts/src/git.ts
  • packages/contracts/src/project.test.ts
  • scripts/scenarios/task-folder-adds-repository-with-trailing-space.e2e.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.

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Dec 2, 2026
Adding a repository whose folder name ends in a space now worked, but its
row in thread details read "Not a Git repository": the status request
trimmed the worktree path to a folder that does not exist.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@macroscopeapp
macroscopeapp Bot dismissed their stale review December 2, 2026 22:36

Dismissing prior approval to re-evaluate 59e78d6

@github-actions github-actions Bot added size:M 30-99 changed lines (additions + deletions). and removed size:XS 0-9 changed lines (additions + deletions). labels Dec 2, 2026
@juliusmarminge

Copy link
Copy Markdown
Member

Evidence

On each fresh database, create real main-branch Git repositories space-repro, api, and 'repo ' (one trailing space), register api and 'repo ' as tracked folders, open the project, use New worktree with only api selected, and send 'hello' with Replay (dev) Showcase. After the turn finishes, open Other repositories... and select repo. Capture the settled result. On head, also inspect Git status, verify the stored repositoryPath and worktreePath retain the trailing space, check the checkout's real Git branch, and reload the thread.

Environment for all captures: real Linux web app in Chromium, 1280×800, light theme, isolated fresh server state on each commit.

Scenario: Adding a tracked repository preserves its trailing space and Git status

Proven: the scenario fails on base f3e735b5cf and passes on head 59e78d6239.

Before f3e735b5cf After 59e78d6239
Result ❌ failed
ASSERTION_FAILED: expect.toBeVisible failed
locator: getByRole("group", name: "Repository repo")
expected: visible
observed: no node (match count 0)
✅ passed
add trailing space repository Base f3e735b5cf: add trailing space repository Head 59e78d6239: add trailing space repository
failure Base f3e735b5cf: failure
repository git status Head 59e78d6239: repository git status
repository after reload Head 59e78d6239: repository after reload

Scenario source · Before recording · After recording

Head's repo row shows the same task branch as api and Publish repository; it remains correct after reload. The orange branch-title warning is present on both commits because the scenario runner disables real text generation; it is independent of the repository-path behavior.

Not shown:

  • Leading-whitespace path inputs were not exercised; this reproduction covers a directory ending in a space.
  • Records created by an older server were not migrated into head. Newly stored task-folder repository paths were checked exactly and read back through a real app reload.

@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 Dec 2, 2026
@juliusmarminge
juliusmarminge merged commit b94204d into pingdotgg:main Dec 2, 2026
48 checks passed
@juliusmarminge juliusmarminge removed the takeover:ready Takeover done; auto-lands when gates pass label Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants