plans/2026-01-22-Fix Auto-Sync Workspace Registration Issue-v2.md
Issue: #2288
Problem: The zsh plugin automatically syncs workspaces in the background on every directory change, causing unintended parent directories to be registered as workspaces. When users run forge workspace list, ancestor directories appear as "Current" instead of the actual working directory.
Root Cause: _forge_start_background_sync() in shell-plugin/lib/helpers.zsh:114-131 unconditionally runs forge workspace sync without checking if the workspace or its ancestors are already registered.
Prevent auto-sync from creating unintended workspace registrations while maintaining the convenience of automatic syncing for already-indexed workspaces.
--porcelain flag to workspace info command in crates/forge_main/src/cli.rs:262-266on_workspace_info() in crates/forge_main/src/ui.rs:3328-3389 to handle porcelain modeget_workspace_info() call which already checks for workspace or ancestor_forge_start_background_sync() in shell-plugin/lib/helpers.zsh:114-131$_FORGE_BIN workspace info "$workspace_path" --porcelain 2>/dev/nullFORGE_DEBUG=true) to indicate when sync is skippedforge workspace sync still works for first-time registrationforge workspace syncon_list_workspaces() in crates/forge_main/src/ui.rs:3266-3311 to distinguish between exact match and ancestor match[Current via ancestor] or similarcd /Users/username (parent directory)forge workspace sync oncecd /Users/username/Documents/Projects/forge (subdirectory)forge workspace list/Users/username/Documents/Projects/forge is incorrectly registered as a workspacecd /Users/username/Documents/Projects/forgeforge workspace list/Users/username appears (no auto-sync of subdirectory)forge workspace sync in subdirectoryforge workspace info with --porcelain flag returns correct exit codesFORGE_SYNC_ENABLED=false (should still respect flag)Mitigation: Users who rely on automatic workspace creation will need to run forge workspace sync once per workspace. This is a one-time migration cost for better UX long-term.
Mitigation: The workspace info --porcelain check reuses existing get_workspace_info() which is already fast. Negligible overhead.
Mitigation: The check and sync are not atomic, but this is acceptable - worst case, a sync happens when it shouldn't have. No data corruption risk.
is-indexed SubcommandCreate a dedicated forge workspace is-indexed command instead of extending info.
Pros: Clearer intent, dedicated purpose
Cons: More API surface, duplicates existing functionality
Just improve the workspace list display to show [Current via ancestor] without changing auto-sync behavior.
Pros: Simpler implementation, no behavior changes
Cons: Doesn't solve the root problem of unintended workspace registrations
Only auto-sync directories within N levels of an existing workspace.
Pros: Prevents deep directory pollution
Cons: Arbitrary limit, still creates unintended workspaces
get_workspace_info() method which already handles ancestor matching$_FORGE_BIN for CLI callsworkspace info --porcelain exit codesshell-plugin/README.md to explain auto-sync behaviorworkspace sync requirement for new workspacesFORGE_SYNC_ENABLED environment variable--porcelain flag