Skip to content

🐛 fix(device-control): keep nested Windows project files in their folders - #21755

Open
markjoin123 wants to merge 1 commit into
lobehub:canaryfrom
markjoin123:fix/windows-project-file-index-21699
Open

markjoin123 wants to merge 1 commit into
lobehub:canaryfrom
markjoin123:fix/windows-project-file-index-21699

Conversation

@markjoin123

Copy link
Copy Markdown

Summary

Contribution source: AI-assisted

On Windows, the conversation Files tree showed nested project files directly under the project root. The files were in the right repository, but their parent folders were missing.

collectProjectDirectories compared the Git root from git rev-parse --show-toplevel (D:/repo) with parents produced by path.resolve (D:\repo\src\nested). Those strings use different separators, so current.startsWith(`${root}${path.sep}`) never matched and no parent directory entries were emitted. The tree then attached each file to the project root.

The walk now normalizes the root and each candidate before the containment check, and it stops at the normalized root without emitting the root itself. POSIX behavior is unchanged.

Test

  • Tested locally

  • Added/updated tests

  • No tests needed

  • Acceptance: packages/device-control/src/__tests__/projectFileIndex.test.ts runs the collector with path.win32 and a Git-style root D:/repo plus src/nested/example.ts. Before normalization those cases returned no parents. After the fix they return src/ and src/nested/, the root is not an entry, shared parents are deduped, and a root-level file adds no directory. The same assertions with path.posix still return src/ and src/nested/ and do not emit /repo. Package suite: 14 files, 165 tests passed. bun run check --lint --test --type on the two touched files was lint clean, 19 tests passed, types clean. A Windows desktop UI pass was not run.

🔗 Related Issue

Fixes #21699

AI assistance

  • Harness: Cursor Cloud Agent
  • Division of work: AI confirmed the mixed-separator comparison, implemented the normalization, added the regression tests, and reviewed the diff against the reported repro. The change was tested in this session.
  • Implementation rationale: Git for Windows and Node's Windows path API do not use the same separator. Normalizing both sides with path.resolve makes the existing prefix walk match, and stopping at the normalized root keeps the project root itself out of the child list. Injecting the path API lets Linux CI run that walk with path.win32 without changing POSIX results.
  • Verification: See the Test section. A live Windows desktop Files-tree pass was not run.

…ders

Git for Windows reports the repo root with forward slashes, while path.resolve
uses backslashes. The directory walk compared those forms directly, so parent
folders were dropped and nested files flattened onto the project root.
Normalize both paths before the containment check, and stop at the root.
@vercel

vercel Bot commented Oct 28, 2026

Copy link
Copy Markdown

@markjoin123 is attempting to deploy a commit to the LobeHub OSS Team on Vercel.

A member of the Team first needs to authorize it.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-28T02:29:19.816006Z
We couldn’t complete this review. Comment @codex review to try again.
03f01ca PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Windows project file tree flattens nested files due to mixed path separators

1 participant