mirror of
https://github.com/vxcontrol/pentagi.git
synced 2026-08-22 19:16:29 +00:00
fix(frontend): always refetch knowledgeDocuments on provider remount
The Apollo client's global nextFetchPolicy is 'cache-first', so returning to /knowledges via SPA navigation would serve potentially stale cache. Subscriptions are now scoped to /knowledges* and detach on other pages, so changes from AI agents during flow runs would be missed until a full reload. Override nextFetchPolicy to keep cache-and-network for this query. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
258b677c01
commit
35e077fd8b
@@ -46,8 +46,13 @@ export const KnowledgesProvider = ({ children }: KnowledgesProviderProps) => {
|
||||
|
||||
const shouldFetch = Boolean(authInfo && authInfo.type !== 'guest' && isAuthenticated());
|
||||
|
||||
// Override the client's default `nextFetchPolicy: 'cache-first'`: since
|
||||
// subscriptions are scoped to this provider, the cache can drift while the
|
||||
// user is on other pages (AI agents write documents during flow runs).
|
||||
// Re-mounting the provider on return to /knowledges should refresh.
|
||||
const { data, loading: isLoading } = useKnowledgeDocumentsQuery({
|
||||
fetchPolicy: 'cache-and-network',
|
||||
nextFetchPolicy: 'cache-and-network',
|
||||
skip: !shouldFetch,
|
||||
variables: { withContent: true },
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user