Skip to content

fix(server): keep normalized workspace paths unique - #7354

Closed
ralphsmith80 wants to merge 3 commits into
pingdotgg:mainfrom
ralphsmith80:fix/workspace-path-deduplication
Closed

ralphsmith80 wants to merge 3 commits into
pingdotgg:mainfrom
ralphsmith80:fix/workspace-path-deduplication

Conversation

@ralphsmith80

@ralphsmith80 ralphsmith80 commented Aug 18, 2026 •

Copy link
Copy Markdown

What this does

Workspace file listings no longer send duplicate paths after wire normalization. A legal Linux or macOS filename with trailing whitespace can no longer make the entire Files panel fail with a duplicate-path error.

Fixes #5501.

Verification

  • pnpm exec vp test run apps/server/src/workspace/WorkspaceSearchIndex.test.ts (10 tests passed)
  • pnpm --filter t3 typecheck
  • Targeted Vite+ lint and formatting checks for both changed files

Intentional decisions

The existing project-entry contract trims surrounding whitespace. This change preserves that contract and drops normalized collisions before they reach the client instead of expanding this fix into a wire-format migration.

Generated with GPT-5.6 in the Codex harness through T3 Code.


Note

Low Risk
Scoped to workspace search index mapping and response shaping; no auth or persistence changes, with behavior limited to collapsing paths that only differed after normalization.

Overview
Fixes workspace list/search responses that could emit duplicate ProjectEntry.path values after wire normalization (e.g. trailing whitespace or newline on an otherwise valid filename), which broke the Files UI with a duplicate-path error (#5501).

WorkspaceSearchIndex now centralizes path shaping in normalizeProjectEntryPath (POSIX, trim then drop trailing /) and runs all file/directory/mixed mappers through uniqueProjectEntries, which keeps one row per normalized path and prefers directory over file when both collide. truncated for mixed/file results can reflect deduped counts, not only raw index hits.

New unit tests cover wire-normalized dedup and the file→directory upgrade when a trailing-space file path collides with a real folder.

Reviewed by Cursor Bugbot for commit 378f54f. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Deduplicate normalized workspace paths in WorkspaceSearchIndex

  • Introduces normalizeProjectEntryPath in WorkspaceSearchIndex.ts to trim wire-level whitespace before removing trailing directory separators, centralizing path normalization.
  • Adds uniqueProjectEntries to collapse duplicate paths across file, directory, and mixed search results, with directory entries taking precedence over file entries on collision.
  • Behavioral Change: mixed and file search results may now return fewer entries than before deduplication, and truncated can be true even when the raw item count is under the limit.

Macroscope summarized 378f54f.

@coderabbitai

coderabbitai Bot commented Aug 18, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e6d833ac-39eb-4d60-afb2-1caa7445a4cd

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Aug 18, 2026
Comment thread apps/server/src/workspace/WorkspaceSearchIndex.ts Outdated
Comment thread apps/server/src/workspace/WorkspaceSearchIndex.ts Outdated
@macroscopeapp

macroscopeapp Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 378f54f

Macroscope's review found this PR approvable — This is a localized workspace-search bug fix that normalizes and deduplicates server results before they reach the file UI, with focused regression coverage. It introduces no schema, security, deployment, product-default, or static-analysis-policy changes.

Notes:

  • Diff unchanged. Approvability was decided on eligibility alone.

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

@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 Aug 18, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 696eb7c. Configure here.

Comment thread apps/server/src/workspace/WorkspaceSearchIndex.ts
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Aug 18, 2026
@shivamhwp

Copy link
Copy Markdown
Collaborator

Note: GPT-6 on behalf of shivam (@shivamhwp).

withDirectoryAncestors can reintroduce duplicates after the new normalization. A real workspace containing pkg/notes.txt, pkg/notes.txt\n, and pkg /other.txt produces both pkg and pkg directory entries. ProjectEntry then encodes both as pkg, leaving the Files panel exposed to the same duplicate-path failure.

Normalize and deduplicate the entries after adding directory ancestors, retaining directory precedence. Add the trailing-space directory case alongside the existing filename collision cases.

@juliusmarminge juliusmarminge added the macroscope-review Opt PRs made by unvouched contributors in for Macroscope review. Vouched contributors auto-reviews label Sep 30, 2026 — with ChatGPT Codex Connector
@macroscopeapp
macroscopeapp Bot dismissed their stale review September 30, 2026 23:04

Dismissing prior approval to re-evaluate 378f54f

@maria-rcks

Copy link
Copy Markdown
Collaborator

Note

Written by claude-opus-5-5 on behalf of Maria

Hi! We are cleaning up open PRs, and this one appears to have been created with an older model (gpt-5.6). If this change is really important, we recommend rebuilding the PR with a newer model if possible.

@maria-rcks maria-rcks closed this Oct 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

macroscope-review Opt PRs made by unvouched contributors in for Macroscope review. Vouched contributors auto-reviews size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Files panel throws "Duplicate path" and renders nothing when a workspace has two filenames differing only by trailing whitespace

4 participants