Skip to content

fix(project): use directory root for non-git projects#33668

Open
lin-hongkuan wants to merge 1 commit into
anomalyco:devfrom
lin-hongkuan:nongit-project-root
Open

fix(project): use directory root for non-git projects#33668
lin-hongkuan wants to merge 1 commit into
anomalyco:devfrom
lin-hongkuan:nongit-project-root

Conversation

@lin-hongkuan

Copy link
Copy Markdown

Issue for this PR

Closes #24694

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

When ProjectV2.resolve() returns no VCS, Project.fromDirectory() was using / as the global project worktree/sandbox. That makes tool permission paths relative to the filesystem root, so a project file such as src/secret.ts can be checked as a long root-relative path fragment instead of the project-relative rule users configured.

This keeps git behavior unchanged, but normalizes the opened directory once and uses it as the non-git worktree/sandbox. containsPath() keeps its / guard for legacy persisted rows so old data cannot make the filesystem root count as in-project.

Regression coverage now checks that:

  • Project.fromDirectory() returns the opened directory for non-git worktree/sandbox.
  • InstanceStore.load() exposes the opened directory as the non-git instance worktree.
  • Read permission requests in non-git projects use project-relative paths like src/secret.ts.

How did you verify your code works?

  • bun test test/project/project.test.ts
  • bun test test/project/instance.test.ts
  • bun test test/tool/read.test.ts
  • bun run typecheck
  • git diff --check

Screenshots / recordings

Not applicable, no UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

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.

Non-git projects use "/" as worktree, breaking permission path resolution

1 participant