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