⚡ Bolt: Optimize polling and DB writes for terminal sessions - #81
Conversation
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: 00f5b7c2ec
ℹ️ 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".
| if (s.status !== "completed" && s.status !== "failed") { | ||
| await patchSession(s.id, { status: live.status, last_polled: lastUpdate }); | ||
| } |
There was a problem hiding this comment.
Skip vendor polling for terminal list rows
When a stored session is completed or failed, this condition runs only after getStatus, so every /api/sessions refresh still calls the external vendor API. The dashboard consumers in session-table.tsx and telemetry-strip.tsx refresh this endpoint every three seconds and do not use the returned summary, meaning terminal sessions continue consuming API quota and latency indefinitely; guard the vendor call itself while retaining the first write that records a newly observed terminal status.
Useful? React with 👍 / 👎.
💡 What:
src/commands/status.ts: Avoided the external API polling entirely for sessions that are already in a terminal state (completedorfailed).web/app/api/sessions/route.ts: Avoided saving to the database (patchSession) if the session was already in a terminal state.web/components/session-drawer.tsx: Fixed a React warning about setting state synchronously within an effect by deriving the state during the render cycle.🎯 Why:
Polling the external API for sessions that have finished is unnecessary when the summary is not required. Updating the DB with the exact same terminal state over and over burns database cycles and costs. Deriving the state during render prevents an unnecessary extra React render pass that can cause flashing UI states and uses CPU cycles.
📊 Impact:
🔬 Measurement:
pnpm test) to ensure functionality behaves as expected.cd web && pnpm dev) and use the Network tab to confirmPATCHqueries are not being unnecessarily spawned when dealing with finished sessions, and observe fewer React dev-tools component commits.PR created automatically by Jules for task 744900050290090210 started by @parvezk