Skip to content

fix(daemon): refresh workspace repos on checkout miss#1085

Merged
Bohan-J merged 2 commits intomultica-ai:mainfrom
blackhu0804:fix/daemon-repo-resync
Apr 15, 2026
Merged

fix(daemon): refresh workspace repos on checkout miss#1085
Bohan-J merged 2 commits intomultica-ai:mainfrom
blackhu0804:fix/daemon-repo-resync

Conversation

@blackhu0804
Copy link
Copy Markdown
Contributor

@blackhu0804 blackhu0804 commented Apr 15, 2026

What does this PR do?

This PR adds on-demand repository refresh for daemon checkout so newly added repositories can be checked out without restarting the daemon.

Today, multica repo checkout <url> can fail with repo not found in cache if a repository was added to Settings > Repositories after the daemon started. The daemon only syncs repository cache during workspace registration, so newly added repos are not available until a restart.

This change keeps the existing fast path for already-known repositories, but refreshes workspace repository state on checkout miss. If the target repo is now configured for the workspace, the daemon performs a one-time cache sync and retries checkout. It also improves error reporting by distinguishing between:

  • a repo that is not configured for the workspace
  • a repo that is configured but failed to sync

It also updates UI copy to refer to Git repositories rather than GitHub-only repositories.

Related Issue

Closes #1027

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Refactor / code improvement (no behavior change)
  • Documentation update
  • Tests (adding or improving test coverage)
  • CI / infrastructure

Changes Made

  • added a daemon workspace repo-state endpoint that returns:
    • workspace_id
    • repos
    • repos_version
  • computed repos_version from the normalized repository URL set so URL order and description-only changes do not trigger unnecessary refreshes
  • extended daemon register response to include repository version metadata for local initialization
  • added daemon local workspace repo state:
    • reposVersion
    • allowedRepoURLs
    • lastRepoSyncErr
    • repoRefreshMu
  • added ensureRepoReady() before checkout to:
    • use the local fast path when repo allowlist and cache already match
    • refresh repo state on miss
    • run a one-time repoCache.Sync(...) when needed
  • improved checkout error messages to distinguish:
    • repo is not configured for this workspace
    • repo is configured but not synced: ...
  • updated repository-related UI copy from GitHub-specific wording to generic Git repository wording in:
    • packages/views/settings/components/repositories-tab.tsx
    • packages/views/onboarding/step-complete.tsx

How to Test

  1. Run cd server && go test ./...
  2. Start the daemon and make sure a workspace is already being watched
  3. Add a new repository in Settings > Repositories
  4. Without restarting the daemon, run multica repo checkout <repo-url>
  5. Confirm the first checkout succeeds after refreshing repo state
  6. Run the same checkout again and confirm it succeeds without needing another refresh in the normal cached path

Checklist

  • I have included a thinking path that traces from project context to this change
  • I have run tests locally and they pass
  • I have added or updated tests where applicable
  • If this change affects the UI, I have included before/after screenshots
  • I have updated relevant documentation to reflect my changes
  • I have considered and documented any risks above
  • I will address all reviewer comments before requesting merge

AI Disclosure

AI tool used: Codex

Prompt / approach:
I used Codex to inspect the daemon register / checkout flow, trace why newly added repositories were not available without restarting the daemon, and help outline a minimal on-demand refresh design. I also used it to identify the relevant files for the daemon, handler, and UI copy updates, and to suggest test scenarios for the new repo-state and checkout behavior. Final code changes, scope decisions, and local verification were reviewed and validated manually.

Screenshots (optional)

image image

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated (UTC)
multica-web Ignored Ignored Apr 15, 2026 10:06am
multica-web-production Ignored Ignored Apr 15, 2026 10:06am

Request Review

@Bohan-J
Copy link
Copy Markdown
Collaborator

Bohan-J commented Apr 15, 2026

Great work on this PR! The on-demand refresh design is clean — double-checked locking with per-workspace mutex is the right call, and the test coverage is thorough. Merging now, I'll follow up with a small PR for the two nits (URL trim + reposVersion comment). Thanks! 🎉

@Bohan-J Bohan-J merged commit 0427fd8 into multica-ai:main Apr 15, 2026
5 checks passed
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.

[Feature]: GitLab support for repository integration

2 participants