Description
The app currently verifies active PR context on token/repository sync and page reload. If a user closes or merges the active PR directly on GitHub, the app does not update in real time until a reload or another verification trigger occurs.
This issue proposes lightweight browser-side polling for active PR context so the UI can automatically switch back to Open PR mode when the tracked PR is no longer open.
Why this matters
- Reduces stale “Push Commit” state after PR is closed/merged outside the app.
- Improves trust that app state matches GitHub state.
- Avoids requiring manual reload for common workflows.
Current behavior
- User has active PR context in app.
- User closes/merges PR in GitHub UI (outside app).
- App remains in Push mode until reload or another verification trigger.
- On verification, context is deactivated and Open PR mode is restored.
Expected behavior
- While active PR context exists, app periodically checks GitHub PR status.
- If PR is closed or merged, app deactivates local active context and updates UI immediately.
- If PR remains open, no visible disruption.
Scope
- Add polling only when
isActivePr context is present.
- Reuse existing context verification path (no duplicate deactivation logic).
- Pause polling when drawer/token/repo state makes verification impossible.
- Keep behavior browser-only (no webhook/backend work in this issue).
Suggested implementation
- Add poll controller in PR drawer module:
- Start poll on active context enter.
- Stop poll on active context clear, token loss, repo change, or dispose.
- Default interval:
- 30s (configurable constant).
- Trigger strategy:
- Run immediate verify on window
focus + visibilitychange (to reduce stale state quickly).
- Backoff/error handling:
- On transient failures, keep current context and retry next cycle.
- Optionally increase interval after repeated failures.
- Guardrails:
- Skip polling when no token, no selected repo, or no active context.
- Ensure only one in-flight verify call at a time.
Acceptance criteria
- With active PR context, app checks PR state periodically without reload.
- If PR is closed/merged externally, app automatically switches to Open PR mode.
- Local storage context is updated (
isActivePr: false) via existing flow.
- No polling occurs when no active context exists.
- Polling stops on logout/token removal and controller dispose.
- Existing tests continue passing; add targeted tests for polling-driven deactivation.
Testing suggestions
- Poll starts/stops based on active context transitions.
- Closed PR response deactivates context.
- Network/API errors do not falsely clear active context.
- Seed active context, mock PR state transition open -> closed during session, assert UI mode flips without reload.
Non-goals
- Webhook-based real-time sync.
- Backend event relay (SSE/WebSocket).
- Commit flow changes unrelated to context verification.
Notes
- Consider a future setting to disable polling or change interval if users prefer fewer API calls.
Description
The app currently verifies active PR context on token/repository sync and page reload. If a user closes or merges the active PR directly on GitHub, the app does not update in real time until a reload or another verification trigger occurs.
This issue proposes lightweight browser-side polling for active PR context so the UI can automatically switch back to Open PR mode when the tracked PR is no longer open.
Why this matters
Current behavior
Expected behavior
Scope
isActivePrcontext is present.Suggested implementation
focus+visibilitychange(to reduce stale state quickly).Acceptance criteria
isActivePr: false) via existing flow.Testing suggestions
Non-goals
Notes