Skip to content

fix(ui): re-root sanitized paths so the project dir reads as /#57

Merged
Anton-Horn merged 1 commit into
mainfrom
fix/sanitize-path-project-root
Jun 9, 2026
Merged

fix(ui): re-root sanitized paths so the project dir reads as /#57
Anton-Horn merged 1 commit into
mainfrom
fix/sanitize-path-project-root

Conversation

@Anton-Horn

Copy link
Copy Markdown
Contributor

Problem

The chat UI rendered project paths like /app./.pi instead of a clean project-relative path. Root cause: web/src/lib/sanitize-path.ts only stripped a known /var/zero or /data marker before /projects/<id>. The production projects root is /app/data/projects/<id> (PI_PROJECTS_ROOT in server/.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 /app dangling → /app + ./ + .pi = /app./.pi.

This was display-only — the filesystem layer resolves real paths correctly — but every path under /app rendered wrong, and /app./.pi isn't a valid path if copied into a shell.

Fix

Rewrite the sanitizer to present the project dir as the filesystem root:

Real path Shown as
/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:

  1. Anchor on /projects/<id> and consume the whole absolute prefix regardless of root → / (root-agnostic; survives future PI_PROJECTS_ROOT changes).
  2. Collapse the container deploy root /app~, but only at a path boundary so an app/ directory inside a project (e.g. re-rooted /app/main.ts) is left intact.

Tests

New tests/sanitize-path.test.ts — all roots, the /app collapse, the in-project app/ collision case, mixed strings, and recursive sanitizeValue. 12/12 pass.

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.
@Anton-Horn Anton-Horn merged commit a795f06 into main Jun 9, 2026
1 check passed
@Anton-Horn Anton-Horn deleted the fix/sanitize-path-project-root branch June 9, 2026 13:20
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.

1 participant