Skip to content

feat: multi-repo workspace support#1478

Draft
richardsolomou wants to merge 5 commits intomainfrom
feat/multi-repo-workspaces
Draft

feat: multi-repo workspace support#1478
richardsolomou wants to merge 5 commits intomainfrom
feat/multi-repo-workspaces

Conversation

@richardsolomou
Copy link
Copy Markdown
Member

@richardsolomou richardsolomou commented Apr 3, 2026

Problem

At PostHog we work across multiple repos (posthog, posthog.com, posthog-js, posthog-python) that often depend on each other. Currently, tasks only support a single repository, making cross-repo work cumbersome.

Changes

Data model (Stage 1):

  • Add multi-repo workspace support — each task can now have multiple workspace associations (one per repo), each with its own mode (local/worktree), branch, and folder

Session & agent integration (Stage 2):

  • Wire additional repo paths through session connect params and into the agent as additionalDirectories
  • Agent gets access to all repo worktrees/directories in the conversation

Task creation UI (Stage 3):

  • Add "Add repository" button to task creation — each additional repo gets its own folder picker, mode selector, and branch selector
  • Tighter spacing between repo rows via nested Flex container

Sidebar badge (Stage 4):

  • Show +N badge on sidebar task items for multi-repo tasks with tooltip listing additional repos
  • Badge stays visible on hover (doesn't hide when action buttons appear)
  • Derive additional repos from local workspace data as fallback when API doesn't return repositories array yet

File picker (Stage 5):

  • @ file mention picker searches across all workspace repos, not just the primary
  • When multiple repos exist, file descriptions include the repo name prefix for disambiguation

API integration (Stage 6):

Dev experience:

  • Skip invite code access check for dev region (local PostHog doesn't have the endpoint)

How did you test this?

  • Manually tested multi-repo task creation with two local repos
  • Verified sidebar badge appears with correct tooltip
  • Verified @ file picker shows files from both repos
  • Typecheck passes cleanly

Created with PostHog Code

Allow a task to have multiple workspaces, one per repository. This enables
cross-repo work (e.g., posthog + posthog-js + posthog.com) in a single
conversation.

Changes:
- DB migration: drop UNIQUE on workspaces.taskId, add label column, add index
- WorkspaceRepository: add findAllByTaskId for multi-workspace queries
- WorkspaceService: createWorkspace accepts additionalRepos, returns array
- Workspace schemas: add label field, RepoWorkspaceConfig, array outputs
- Task type: add repositories[] alongside deprecated repository field
- Sidebar: add additionalRepositories to TaskData for multi-repo badge
- useWorkspace hook: backward-compatible single-workspace access + new
  useTaskWorkspaces/useAllWorkspaces for multi-repo consumers
- Archive/suspension services: handle multi-workspace per task
- Fix downstream consumers (code editor, DraggableTab) for array workspace API

Generated-By: PostHog Code
Task-Id: 230ec8e6-6781-43b4-ae30-ea24faa410dc
Pass additional repository paths from multi-repo workspaces through to the
agent session:

- ConnectParams: add additionalRepoPaths field
- SessionService.createNewLocalSession: forward additionalDirectories to
  agent.start mutation
- TaskCreationSaga: resolve additional workspace paths from workspace.getInfo
  and pass them as additionalRepoPaths
- workspaceEnv: add buildMultiRepoWorkspaceEnv with indexed per-repo env vars
  (POSTHOG_CODE_REPO_0_NAME, POSTHOG_CODE_REPO_0_PATH, etc.)

Generated-By: PostHog Code
Task-Id: 230ec8e6-6781-43b4-ae30-ea24faa410dc
- TaskInput: "Add repository" button appears when a primary repo is
  selected. Each additional repo gets its own folder picker, mode selector,
  and branch selector. Repos can be removed individually.
- AdditionalRepoRow: new component for per-repo configuration rows
- TaskItem: renders "+N" badge with tooltip listing additional repos
  when a task has multiple repositories
- useTaskCreation: passes additionalRepos through to TaskCreationSaga
- TaskCreationSaga: resolves folders for additional repos and passes
  them as additionalRepos to workspace.create mutation

Generated-By: PostHog Code
Task-Id: 230ec8e6-6781-43b4-ae30-ea24faa410dc
Wire the client to send the new `repositories` array format when creating
multi-repo tasks. Single-repo tasks still use the legacy `repository` string
for backward compat.

- posthogClient.createTask: accepts `repositories` field
- TaskCreationSaga.createTask: detects additional repos, sends repositories
  array when multiple repos are present
- duplicateTask: preserves repositories array

Generated-By: PostHog Code
Task-Id: 230ec8e6-6781-43b4-ae30-ea24faa410dc
@richardsolomou richardsolomou force-pushed the feat/multi-repo-workspaces branch from 73db754 to 1f13450 Compare April 3, 2026 10:14
- Derive additional repos from local workspace data for sidebar badge
  (works even before API returns repositories array)
- Keep multi-repo badge visible on hover instead of hiding it
- Search files across all workspace repos in @ file picker
- Tighten spacing between repo rows and add-repo button
- Skip invite code check for dev region

Generated-By: PostHog Code
Task-Id: 230ec8e6-6781-43b4-ae30-ea24faa410dc
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