Skip to content

⚡ Bolt: Skip live polling for terminal sessions#39

Open
parvezk wants to merge 1 commit into
mainfrom
bolt/skip-terminal-polling-3318047496366640461
Open

⚡ Bolt: Skip live polling for terminal sessions#39
parvezk wants to merge 1 commit into
mainfrom
bolt/skip-terminal-polling-3318047496366640461

Conversation

@parvezk

@parvezk parvezk commented Jul 20, 2026

Copy link
Copy Markdown
Owner

💡 What:

  • Modified web/app/api/sessions/route.ts and src/commands/status.ts to skip live vendor polling for sessions that have reached a terminal state (completed or failed).
  • Optimized web/components/session-drawer.tsx by replacing a useEffect hook with a state update during render to reset optimistic messages when switching sessions.

🎯 Why:

  • The application was previously querying third-party APIs (Claude, Jules) and issuing database upserts for every session during the polling interval, even those that had permanently concluded. This created unnecessary compute overhead, network latency, and increased the risk of hitting third-party API rate limits as the user's session history grew.
  • The session-drawer.tsx change removes an unnecessary useEffect that was causing cascading renders, improving UI performance and fixing an ESLint warning.

📊 Impact:

  • Drastically reduces the number of outgoing HTTP requests and database writes during live polling.
  • The number of external requests per poll interval is now proportional to the number of active sessions, rather than all historical sessions.
  • Prevents an unnecessary browser paint and cascading render when switching between sessions in the UI.

🔬 Measurement:

  • Verify by running the application (pnpm dev) with multiple completed/failed sessions in the history. Use the browser's Network tab (or logging) to observe that calls to buildAdapter(vendor).getStatus() are only made for non-terminal sessions during the 3-second polling interval.
  • Run pnpm test and cd web && pnpm lint to verify tests pass and no lint warnings exist.

PR created automatically by Jules for task 3318047496366640461 started by @parvezk

- Updated `web/app/api/sessions/route.ts` and `src/commands/status.ts` to check if a session is in a terminal state (`completed` or `failed`) before polling the vendor API.
- Replaced a `useEffect` with a conditional state update during render in `web/components/session-drawer.tsx` to fix a React warning and improve render performance.
- Added a journal entry detailing the learning about terminal state polling.

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 20, 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, Comment Jul 20, 2026 8:41am

@cursor

cursor Bot commented Jul 20, 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: 6b224aeabb

ℹ️ 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 +23 to +24
// Skip live polling for terminal statuses to prevent unnecessary API calls
if (status !== "completed" && status !== "failed") {

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 Preserve summaries when skipping terminal sessions

For any session already stored as completed or failed, this branch is skipped after summary was initialized to undefined, so every subsequent /api/sessions response loses the final summary previously returned by the adapter. Because DbSession has no persisted summary field, the value cannot be recovered from storage; persist the summary when the session becomes terminal or otherwise retain it before bypassing the poll.

Useful? React with 👍 / 👎.

Comment thread src/commands/status.ts
Comment on lines +22 to +23
// Skip live polling for terminal statuses to prevent unnecessary API calls
if (status !== "completed" && status !== "failed") {

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 Resume polling after a terminal-session follow-up

When a vendor accepts a follow-up that reactivates a completed or failed session, followupCommand reports success but does not reset the stored status. This condition then prevents polyagent status --watch from ever querying the vendor again, so it continues displaying the old terminal state while the follow-up runs, despite directing the user to track it with that command.

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