Skip to content

feat: add worktree:scan CLI command and dashboard button#200

Draft
ropi-bc wants to merge 1 commit intogeodro:mainfrom
ropi-bc:feat/manual-worktree-scan
Draft

feat: add worktree:scan CLI command and dashboard button#200
ropi-bc wants to merge 1 commit intogeodro:mainfrom
ropi-bc:feat/manual-worktree-scan

Conversation

@ropi-bc
Copy link
Copy Markdown

@ropi-bc ropi-bc commented Apr 16, 2026

Summary

  • Adds a lerd worktree:scan CLI command that manually triggers a full worktree rescan across all registered sites — detects worktrees, ensures dependencies (vendor/, node_modules/, .env), mounts paths in podman, generates nginx vhosts, and reloads nginx
  • Adds a POST /api/worktrees/scan API endpoint in the UI server
  • Adds a "Scan Worktrees" button to the Watcher panel in the dashboard, styled with the existing git-worktree violet color scheme
  • Extracts the shared cli.ScanWorktrees() function from the private scanWorktrees() in the watch daemon, eliminating duplication
  • Refactors worktree vhost generation to accept config.Site instead of individual strings, enabling proper proxy and public dir detection for worktrees via a new worktreeVhostData() helper

Why

The file watcher detects new git worktrees automatically via fsnotify + 30s polling, but there was no way to manually trigger a full rescan. This is needed when:

  • Worktrees were created while the watcher was not running
  • Nginx vhosts need to be refreshed after configuration changes
  • Debugging worktree setup issues

CLI usage

lerd worktree:scan
# Worktree vhost: feature-branch -> feature-branch.myapp.test
# Generated 3 worktree vhost(s) and reloaded nginx.

Test plan

  • Run lerd worktree:scan with existing worktrees — verify vhosts are generated and nginx reloads
  • Run lerd worktree:scan with no worktrees — verify "No worktree vhosts to generate." message
  • Open the dashboard → System → Watcher panel → click "Scan Worktrees" button — verify it shows spinner, completes, and the sites list refreshes
  • Verify the watcher daemon startup still works (the delegated scanWorktrees() path)
  • Verify worktree vhosts now correctly detect proxy config and public dir from the parent site

🤖 Generated with Claude Code

… worktree rescan

The file watcher detects new git worktrees automatically, but there was no
way to manually trigger a full rescan — useful when worktrees were created
while the watcher was down, or when vhosts need to be refreshed after config
changes.

- Extract shared `cli.ScanWorktrees()` from the private `scanWorktrees()` in
  the watch daemon so it can be reused by the new CLI command and UI handler
- Add `lerd worktree:scan` CLI command that scans all registered sites,
  ensures worktree dependencies (vendor/, node_modules/, .env), mounts paths
  in podman, generates nginx vhosts, and reloads nginx
- Add `POST /api/worktrees/scan` API endpoint with site event publishing
- Add "Scan Worktrees" button to the Watcher panel in the dashboard UI
- Refactor worktree vhost generation to accept `config.Site` instead of
  individual strings, enabling proxy and public dir detection for worktrees
- Add `worktreeVhostData()` helper to reduce duplication between HTTP and
  SSL vhost generators

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ropi-bc ropi-bc marked this pull request as draft April 16, 2026 15:39
@ropi-bc
Copy link
Copy Markdown
Author

ropi-bc commented Apr 16, 2026

sorry, I was too eager to open the PR, and I see some issues with it. converted to draft and will reopen soon

@geodro
Copy link
Copy Markdown
Owner

geodro commented Apr 16, 2026

Hey, thanks for taking your time! Can you update your commit message and PR and remove "Generated with Claude Code" ?

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.

3 participants