fix(ui): disable aggressive polling on plan page to prevent layout thrashing

This commit is contained in:
2026-05-19 18:56:54 -07:00
parent 4414287ed4
commit 07da08f11f
2 changed files with 22 additions and 1 deletions

View File

@@ -42,7 +42,7 @@ export default function PlanPageV2() {
const { data: plan, error, mutate: mutatePlan } = useSWR<Plan>(
projectId ? `/api/projects/${projectId}/plan` : null,
fetcher,
{ refreshInterval: 15000, dedupingInterval: 5000 }
{ revalidateOnFocus: false, revalidateIfStale: false }
);
// Wrapper for child components to update SWR cache optimally

21
fix_plan_swr_loop.js Normal file
View File

@@ -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");