fix(ui): re-root sanitized paths so the project dir reads as /#57
Merged
Conversation
The path sanitizer only stripped a known /var/zero or /data marker before /projects/<id>, so the production root /app/data/projects/<id> (PI_PROJECTS_ROOT in server/.ocd-deploy.json) left the /app segment dangling and rendered as /app./.pi. Rewrite it to anchor on /projects/<id> and consume the whole absolute prefix regardless of root, presenting the project dir as the filesystem root (/.pi, /foo/bar.ts, / for the root itself). Also collapse the container deploy root /app to ~ at a path boundary, so non-project internals (the zero-sdk symlink target, node_modules) no longer leak /app/ — without touching an app/ directory that lives inside a project. Add tests/sanitize-path.test.ts covering all roots, the /app collapse, the in-project app/ collision case, and recursive sanitizeValue.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The chat UI rendered project paths like
/app./.piinstead of a clean project-relative path. Root cause:web/src/lib/sanitize-path.tsonly stripped a known/var/zeroor/datamarker before/projects/<id>. The production projects root is/app/data/projects/<id>(PI_PROJECTS_ROOTinserver/.ocd-deploy.json, set in #10 so workspaces live on the persistent volume). The regex matched only the/data/projects/<id>/portion and left the leading/appdangling →/app+./+.pi=/app./.pi.This was display-only — the filesystem layer resolves real paths correctly — but every path under
/apprendered wrong, and/app./.piisn't a valid path if copied into a shell.Fix
Rewrite the sanitizer to present the project dir as the filesystem root:
/app/data/projects/<id>/.pi/.pi/app/data/projects/<id>/foo/bar.ts/foo/bar.ts/app/data/projects/<id>//app/zero/src/sdk(sdk symlink)~/zero/src/sdk/app~/Users/<name>/...(dev)~/...One combined pass, two alternatives:
/projects/<id>and consume the whole absolute prefix regardless of root →/(root-agnostic; survives futurePI_PROJECTS_ROOTchanges)./app→~, but only at a path boundary so anapp/directory inside a project (e.g. re-rooted/app/main.ts) is left intact.Tests
New
tests/sanitize-path.test.ts— all roots, the/appcollapse, the in-projectapp/collision case, mixed strings, and recursivesanitizeValue. 12/12 pass.