Skip to content

fix(sessions): strip remote workspace prefix from file paths in chat#2205

Draft
timgl wants to merge 2 commits into
mainfrom
posthog-code/strip-workspace-prefix-from-file-paths
Draft

fix(sessions): strip remote workspace prefix from file paths in chat#2205
timgl wants to merge 2 commits into
mainfrom
posthog-code/strip-workspace-prefix-from-file-paths

Conversation

@timgl
Copy link
Copy Markdown

@timgl timgl commented May 18, 2026

Summary

When viewing a cloud task, file chips in the chat rendered the full sandbox path (e.g. /tmp/workspace/repos/posthog/posthog.com/src/c). For cloud tasks the local workspace cwd is empty (folderPath: "", worktreePath: null), so useCwd() returned undefined and FileMentionChip's toRelativePath had nothing to strip.

This adds a small useDisplayRepoPath(taskId) hook that prefers the local cwd, and falls back to the conventional sandbox root /tmp/workspace/repos/<owner>/<repo> derived from task.repository when there isn't one. FileMentionChip uses it instead of useCwd so the chip shows just the repo-relative directory on cloud tasks.

  • Read/Edit views are unchanged structurally — they already use FileMentionChip; the chip just gets a correct prefix to strip now.
  • Local tasks keep the existing behavior (cwd takes precedence).
  • The ToolCallView fallback (Glob/Grep/etc. via compactHomePath(title)) is unchanged — out of scope for this fix.

Test plan

  • pnpm vitest run src/renderer/features/sessions — 161 tests pass, including 7 new tests for useDisplayRepoPath covering local cwd, derived remote path, missing/malformed repository, and missing task.
  • pnpm exec tsc -p tsconfig.web.json --noEmit — clean.
  • biome check — clean (auto-formatted on commit via lint-staged).
  • Manually: open a cloud task that has performed a Read, verify the chip shows src/... rather than /tmp/workspace/repos/<owner>/<repo>/src/....
  • Manually: open a local task and verify nothing regresses.

Created with PostHog Code

For cloud tasks the local workspace cwd is empty, so FileMentionChip
fell back to rendering the full sandbox path
(/tmp/workspace/repos/<owner>/<repo>/...). Derive the conventional
remote root from `task.repository` when there is no local cwd, so the
chip shows just the repo-relative directory.

Generated-By: PostHog Code
Task-Id: 1b29c9c1-769d-4c98-a3c1-04c703482115
@timgl timgl requested a review from jonathanlab May 18, 2026 23:15

const REMOTE_WORKSPACE_PREFIX = "/tmp/workspace/repos";

export function useDisplayRepoPath(
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I think we could use a comment here to explain what/why (brief!)

Generated-By: PostHog Code
Task-Id: 1b29c9c1-769d-4c98-a3c1-04c703482115
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