diff --git a/vibn-frontend/app/[workspace]/project/[projectId]/(home)/plan/page.tsx b/vibn-frontend/app/[workspace]/project/[projectId]/(home)/plan/page.tsx index fe04242..6212c90 100644 --- a/vibn-frontend/app/[workspace]/project/[projectId]/(home)/plan/page.tsx +++ b/vibn-frontend/app/[workspace]/project/[projectId]/(home)/plan/page.tsx @@ -42,7 +42,7 @@ export default function PlanPageV2() { const { data: plan, error, mutate: mutatePlan } = useSWR( projectId ? `/api/projects/${projectId}/plan` : null, fetcher, - { refreshInterval: 15000, dedupingInterval: 5000 } + { revalidateOnFocus: false, revalidateIfStale: false } ); // Wrapper for child components to update SWR cache optimally diff --git a/vibn-frontend/fix_plan_swr_loop.js b/vibn-frontend/fix_plan_swr_loop.js new file mode 100644 index 0000000..8bbacef --- /dev/null +++ b/vibn-frontend/fix_plan_swr_loop.js @@ -0,0 +1,21 @@ +const fs = require('fs'); + +const file = 'app/[workspace]/project/[projectId]/(home)/plan/page.tsx'; +let code = fs.readFileSync(file, 'utf8'); + +// I injected SWR into the file earlier to stop the custom setInterval loop. +// However, the `fetcher` I injected doesn't use useCallback, and SWR's fallback/refresh +// logic might be triggering too aggressively because of how the subcomponents remount +// or because `refreshInterval` is fighting with `mutatePlan(newPlan, false)`. + +// Let's remove the 15-second auto-polling. If the user edits something, we trigger a revalidation. +// If the AI edits something from the chat, we already have an SSE 'plan' event that +// streams the update directly to the UI! So we don't need SWR to poll AT ALL. + +code = code.replace( + '{ refreshInterval: 15000, dedupingInterval: 5000 }', + '{ revalidateOnFocus: false, revalidateIfStale: false }' +); + +fs.writeFileSync(file, code); +console.log("Disabled SWR polling on the Plan page");