Skip to content

fix: cache issue on provider disconnect/reconnect#1992

Open
janburzinski wants to merge 2 commits into
generalaction:mainfrom
janburzinski:emdash/linear-org-stuck-after-change-mo05n
Open

fix: cache issue on provider disconnect/reconnect#1992
janburzinski wants to merge 2 commits into
generalaction:mainfrom
janburzinski:emdash/linear-org-stuck-after-change-mo05n

Conversation

@janburzinski
Copy link
Copy Markdown
Collaborator

summary

issue cache per provider clear on disconnect so that account switch works flawlessly

@janburzinski janburzinski marked this pull request as ready for review May 12, 2026 13:51
@janburzinski janburzinski changed the title fix(pull-requests): refresh task PR badges after creation fix: cache issue on provider disconnect/reconnect May 12, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 12, 2026

Greptile Summary

This PR clears provider-scoped issue query caches (issues:initial and issues:search) when a provider is connected or disconnected, in addition to the existing connection-status invalidation. The goal is to prevent stale issue data from appearing after an account switch.

  • invalidateStatuses is replaced by invalidateProvider(provider), which calls queryClient.removeQueries for both issue query key prefixes before invalidating the connection-status query.
  • The partial-key removal (['issues:initial', provider]) correctly covers all variations of those queries (different project IDs, search terms, limits) because TanStack Query uses prefix matching by default.
  • removeQueries fires via onSettled on both success and failure of connect/disconnect mutations, meaning a failed connect attempt will also evict cached issues for that provider — likely harmless in practice since no issues would be cached for an unconnected provider.

Confidence Score: 4/5

Safe to merge — the cache-clearing logic is well-scoped and the partial-key removal correctly targets all related queries for a provider.

The change is focused and correct. The only open item is that the per-provider invalidate wrappers are non-memoized inline arrows, which is a minor style concern rather than a functional defect.

src/renderer/features/integrations/integrations-provider.tsx — the new inline arrow functions for each provider's invalidate prop could be stabilized with useCallback.

Important Files Changed

Filename Overview
src/renderer/features/integrations/integrations-provider.tsx Replaces the shared invalidateStatuses callback with a per-provider invalidateProvider that additionally removes issues:initial and issues:search cache entries for the disconnected/connected provider, preventing stale issue data after an account switch.

Sequence Diagram

sequenceDiagram
    participant User
    participant ProviderConnection as useProviderConnection
    participant InvalidateProvider as invalidateProvider
    participant QueryClient

    User->>ProviderConnection: connect/disconnect
    ProviderConnection->>ProviderConnection: mutation.mutateAsync()
    Note over ProviderConnection: onSettled fires (success OR failure)
    ProviderConnection->>InvalidateProvider: invalidate()
    InvalidateProvider->>QueryClient: removeQueries(['issues:initial', provider])
    InvalidateProvider->>QueryClient: removeQueries(['issues:search', provider])
    InvalidateProvider->>QueryClient: invalidateQueries(ISSUE_CONNECTION_STATUS_QUERY_KEY)
    QueryClient-->>InvalidateProvider: cache cleared for provider
    QueryClient-->>ProviderConnection: connection status refetched
Loading
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
src/renderer/features/integrations/integrations-provider.tsx:159-182
The inline arrow functions passed as `invalidate` are recreated on every render since they aren't memoized. While `useProviderConnection` uses `useMutation` internally (which doesn't re-subscribe on every render cycle), binding each provider string directly in `invalidateProvider` and passing it as a stable callback would be cleaner and avoid any future surprise if the hook's internals change.

```suggestion
  const invalidateLinear = useCallback(() => invalidateProvider('linear'), [invalidateProvider]);
  const invalidateJira = useCallback(() => invalidateProvider('jira'), [invalidateProvider]);
  const invalidateGitlab = useCallback(() => invalidateProvider('gitlab'), [invalidateProvider]);
  const invalidatePlain = useCallback(() => invalidateProvider('plain'), [invalidateProvider]);
  const invalidateForgejo = useCallback(() => invalidateProvider('forgejo'), [invalidateProvider]);
  const invalidateFeaturebase = useCallback(() => invalidateProvider('featurebase'), [invalidateProvider]);

  const linearConnection = useProviderConnection({
    ...PROVIDER_CONNECTION_CONFIG.linear,
    invalidate: invalidateLinear,
  });
  const jiraConnection = useProviderConnection({
    ...PROVIDER_CONNECTION_CONFIG.jira,
    invalidate: invalidateJira,
  });
  const gitlabConnection = useProviderConnection({
    ...PROVIDER_CONNECTION_CONFIG.gitlab,
    invalidate: invalidateGitlab,
  });
  const plainConnection = useProviderConnection({
    ...PROVIDER_CONNECTION_CONFIG.plain,
    invalidate: invalidatePlain,
  });
  const forgejoConnection = useProviderConnection({
    ...PROVIDER_CONNECTION_CONFIG.forgejo,
    invalidate: invalidateForgejo,
  });
  const featurebaseConnection = useProviderConnection({
    ...PROVIDER_CONNECTION_CONFIG.featurebase,
    invalidate: invalidateFeaturebase,
  });
```

Reviews (1): Last reviewed commit: "Fix issue cache after integration reconn..." | Re-trigger Greptile

Comment thread src/renderer/features/integrations/integrations-provider.tsx
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.

1 participant