⚡ Bolt: Skip external polling for terminal sessions#50
Conversation
…ion drawer re-renders This commit introduces two targeted performance optimizations: 1. Skips expensive external API polling for sessions in terminal states (`completed` or `failed`), saving N+1 network requests during list fetches. The `summary` is now persisted to the database to ensure no data loss. 2. Updates `session-drawer.tsx` to derive state during the render phase rather than via `useEffect`, avoiding unnecessary React commit cycles and cascading re-renders when switching sessions. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5a83c2e408
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // Bolt optimization: Skip external polling for completed/failed sessions to avoid unnecessary network/DB calls. | ||
| if (status !== "completed" && status !== "failed") { |
There was a problem hiding this comment.
Hydrate summaries before skipping legacy terminal rows
When this migration is applied to an existing installation, every already-completed or failed row receives summary = NULL. This condition then prevents those rows from ever making the status request that previously supplied their summaries, so GET /api/sessions permanently stops returning summary data for all historical terminal sessions. Poll terminal rows once when their persisted summary is missing, or otherwise backfill/mark migrated rows before enabling the skip.
Useful? React with 👍 / 👎.
| first_message: s.firstMessage ?? null, | ||
| dispatched_at: s.dispatchedAt, | ||
| last_polled: s.lastPolled ?? null, | ||
| summary: null, |
There was a problem hiding this comment.
Preserve stored summaries during CLI re-imports
When a user re-imports a CLI session whose ID already exists, upsertSessions() updates the existing row with this explicit summary: null, erasing any summary that the new polling logic previously persisted. If the imported copy is already completed or failed, the terminal-state optimization will never fetch that summary again, making the loss permanent. The import path should omit this field on conflict or preserve the existing value.
Useful? React with 👍 / 👎.
💡 What
completedorfailedin bothGET /api/sessionsandGET /api/sessions/[id].summaryfield so it is not lost when skipping the external fetch.session-drawer.tsxto reset optimistic state during the render phase instead of usinguseEffect.🎯 Why
useEffectto reset local state when a prop changes causes cascading re-renders and violates React best practices for performance.📊 Impact
🔬 Measurement
SessionDrawer.PR created automatically by Jules for task 2055244534014742034 started by @parvezk