Skip to content

feat: discover local repos and reconnect OpenCode sessions#158

Open
itz4blitz wants to merge 3 commits intochriswritescode-dev:mainfrom
itz4blitz:feat/repo-session-discovery
Open

feat: discover local repos and reconnect OpenCode sessions#158
itz4blitz wants to merge 3 commits intochriswritescode-dev:mainfrom
itz4blitz:feat/repo-session-discovery

Conversation

@itz4blitz
Copy link

Summary

  • add folder-based repository discovery so users can point OpenCode Manager at a parent directory and import nested git repositories and worktrees in one step
  • link existing local repositories in place with a persisted sourcePath, allowing imported repos to reconnect to existing OpenCode chats instead of recloning or copying them
  • import standalone OpenCode config/state on first startup and document the onboarding flow for both local installs and Docker setups that need path matching

Why

OpenCode Manager already works well once repositories are manually mapped, but first-time setup is still too manual for people who already live in OpenCode.

If someone already has a repo folder like ~/Development and already has OpenCode chats for those projects, onboarding should feel automatic: add one folder, discover repos, and immediately see the existing sessions for matching paths.

Walkthrough

1. Add one folder instead of one repo at a time

The add-repository dialog now includes Folder Discovery, which scans a parent folder for nested git repositories and registers them in one step.

Folder discovery dialog

2. Existing local repos are linked in place

Discovered repositories keep their original source path and are linked into the workspace instead of being copied, so OpenCode Manager can work against the real repo location.

Discovered repositories

3. Existing OpenCode chats reconnect on first install

When OpenCode state already exists, a fresh install can import that state and show prior chats as soon as the discovered repo path matches the original OpenCode path.

Imported OpenCode sessions

What Is Included

  • folder discovery API and UI for nested git repositories
  • support for linking existing local repos in place with persisted sourcePath
  • session matching for imported repos using the real source directory
  • first-run import of existing OpenCode config/state
  • Docker docs for preserving host absolute paths so imported standalone sessions still match
  • quickstart/docs updates for the new onboarding flow

Validation

  • pnpm test
  • pnpm lint
  • pnpm build
  • manual verification in a fresh Dockerized install:
    • Manager repo database started empty
    • existing standalone OpenCode state was imported
    • adding /Users/blitz/Development discovered repos
    • existing chats appeared for matching repositories

Notes

  • imported sessions depend on path matching; Docker setups need to preserve the same absolute repo paths that standalone OpenCode originally stored
  • local-only validation compose files were intentionally kept out of this PR

Type Of Change

  • New feature
  • Documentation

Checklist

  • Code follows project style
  • Types updated
  • Tests added/updated
  • pnpm test passes
  • pnpm lint passes
  • pnpm build passes

Replace one-by-one local repo setup with parent-folder discovery and path-aware repo linking so first-time installs can recover existing OpenCode chats. Add first-run import support and onboarding docs for standalone OpenCode users, including Docker path-matching guidance.
Copilot AI review requested due to automatic review settings March 9, 2026 01:47
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves onboarding by adding folder-based Git repository discovery, linking existing local repos in place via a persisted sourcePath, and importing standalone OpenCode config/state on first startup so existing sessions reconnect when paths match.

Changes:

  • Add backend discovery + linking flow (symlink-based workspace aliases) and persist sourcePath in the repo model/DB.
  • Update frontend repo naming/UI and add “Folder Discovery” to the add-repo dialog.
  • Document the new onboarding flow (including Docker path-matching and host state import).

Reviewed changes

Copilot reviewed 26 out of 29 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
shared/src/types/index.ts Exposes new discover request/response types.
shared/src/schemas/repo.ts Adds sourcePath to repo schema + discover request/response schemas.
frontend/src/pages/SessionDetail.tsx Displays repo names using sourcePath when available.
frontend/src/pages/RepoDetail.tsx Uses updated display-name helper including sourcePath.
frontend/src/pages/Memories.tsx Uses updated display-name helper including sourcePath.
frontend/src/lib/utils.ts Extends repo display-name helper to prefer sourcePath.
frontend/src/components/repo/RepoList.tsx Dedup/search now considers sourcePath.
frontend/src/components/repo/RepoCard.tsx Card label now prefers sourcePath when no URL.
frontend/src/components/repo/AddRepoDialog.tsx Adds “Folder Discovery” mode and toasts for discovery results.
frontend/src/api/types.ts Updates frontend repo shape for optional repoUrl/sourcePath.
frontend/src/api/repos.ts Adds discoverRepos API call.
docs/index.md Updates feature bullets to mention discovery/reconnect.
docs/images/session-discovery/03-imported-opencode-sessions.png Adds screenshot for imported-session discovery.
docs/getting-started/quickstart.md Updates onboarding steps (clone vs folder discovery).
docs/features/git.md Documents folder discovery feature.
docs/configuration/docker.md Documents Docker bind-mount path matching + state import env vars.
backend/test/services/repo.test.ts Adds tests for symlink-based local linking + discovery.
backend/test/db/queries.test.ts Updates tests for source_path + is_local insert behavior.
backend/src/types/repo.ts Extends create input with optional sourcePath.
backend/src/services/repo.ts Implements local repo linking (sourcePath), discovery walk, and uses fullPath for git ops.
backend/src/services/notification.ts Resolves repo by sourcePath when directory is outside workspace.
backend/src/routes/repos.ts Adds /repos/discover endpoint.
backend/src/index.ts Adds first-run import of OpenCode config/state (incl. DB snapshot).
backend/src/db/queries.ts Persists source_path and computes fullPath accordingly.
backend/src/db/migrations/index.ts Registers new migration for repo source_path.
backend/src/db/migrations/009-repo-source-path.ts Adds source_path column + index.
.env.example Documents optional OpenCode import env vars and Docker mount helpers.

You can also share your feedback on Copilot code review. Take the survey.

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.

2 participants