Skip to content

⚡ Bolt: Optimize polling and DB writes for terminal sessions - #81

Open
parvezk wants to merge 1 commit into
mainfrom
bolt-optimize-polling-terminal-sessions-744900050290090210
Open

⚡ Bolt: Optimize polling and DB writes for terminal sessions#81
parvezk wants to merge 1 commit into
mainfrom
bolt-optimize-polling-terminal-sessions-744900050290090210

Conversation

@parvezk

@parvezk parvezk commented Jul 30, 2026

Copy link
Copy Markdown
Owner

💡 What:

  • In src/commands/status.ts: Avoided the external API polling entirely for sessions that are already in a terminal state (completed or failed).
  • In web/app/api/sessions/route.ts: Avoided saving to the database (patchSession) if the session was already in a terminal state.
  • In 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:

  • Eliminates 100% of external API polling for terminal sessions in the CLI tool.
  • Eliminates 100% of redundant database update queries for terminal sessions in the Next.js API route.
  • Saves 1 unnecessary render pass in the session drawer UI every time a session is opened.

🔬 Measurement:

  • Run the unit tests (pnpm test) to ensure functionality behaves as expected.
  • Start Next.js (cd web && pnpm dev) and use the Network tab to confirm PATCH queries 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

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@vercel

vercel Bot commented Jul 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
polyagent Ready Ready Preview Jul 30, 2026 8:34am

@cursor

cursor Bot commented Jul 30, 2026

Copy link
Copy Markdown

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +27 to +29
if (s.status !== "completed" && s.status !== "failed") {
await patchSession(s.id, { status: live.status, last_polled: lastUpdate });
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant