Skip to content

Conversation

@ammar-agent
Copy link
Collaborator

Problem

Git fetch was only running once per project per polling cycle. This optimization worked for local workspaces that share a git repository, but broke for SSH workspaces where each workspace has its own independent git repository.

Solution

Changed the fetch key logic to distinguish between local and SSH workspaces:

  • Local workspaces: Use projectName as fetch key → one fetch serves all workspaces (efficient)
  • SSH workspaces: Use workspaceId as fetch key → each workspace gets its own fetch (correct)

Changes

  • Add getFetchKey() to determine fetch key based on runtime type
  • Rename tryFetchNextProjecttryFetchWorkspaces
  • Rename fetchProjectfetchWorkspace
  • Remove groupWorkspacesByProject (no longer needed)

Impact

Before (Bug)

Polling Cycle 1:
  SSH Workspace A (project-x) ───┐
  SSH Workspace B (project-x) ───┼─→ Fetch key: "project-x"
  SSH Workspace C (project-x) ───┘   ❌ Only ONE fetch runs

After (Fixed)

Polling Cycle 1: SSH Workspace A (id: abc123) ──→ Fetch key: "abc123" ✓
Polling Cycle 2: SSH Workspace B (id: def456) ──→ Fetch key: "def456" ✓
Polling Cycle 3: SSH Workspace C (id: ghi789) ──→ Fetch key: "ghi789" ✓

This ensures SSH workspaces get fresh git status updates while maintaining efficient fetch behavior for local workspaces.

Testing

The existing tests in GitStatusStore.test.ts continue to pass. The changes only affect internal fetch scheduling logic and maintain backward compatibility for local workspaces.

Previously, git fetch only ran once per project per cycle, which worked
for local workspaces that share a git repository. However, SSH workspaces
each have their own independent git repository and need separate fetches.

Changes:
- Add getFetchKey() to determine fetch key based on runtime type
  - Local workspaces: use projectName (shared repo)
  - SSH workspaces: use workspaceId (independent repos)
- Rename tryFetchNextProject -> tryFetchWorkspaces
- Rename fetchProject -> fetchWorkspace
- Remove groupWorkspacesByProject (no longer needed)

This ensures SSH workspaces get fresh git status updates while maintaining
efficient fetch behavior for local workspaces.
@ammario ammario merged commit 86ef049 into main Oct 26, 2025
13 checks passed
@ammario ammario deleted the rt-git-fetch-fix branch October 26, 2025 19:01
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