Skip to content

⚡ Bolt: Skip external polling for terminal sessions#50

Open
parvezk wants to merge 1 commit into
mainfrom
bolt-optimization-terminal-sessions-2055244534014742034
Open

⚡ Bolt: Skip external polling for terminal sessions#50
parvezk wants to merge 1 commit into
mainfrom
bolt-optimization-terminal-sessions-2055244534014742034

Conversation

@parvezk

@parvezk parvezk commented Jul 22, 2026

Copy link
Copy Markdown
Owner

💡 What

  • Prevents external API polling for sessions that are already completed or failed in both GET /api/sessions and GET /api/sessions/[id].
  • Adds a Supabase migration to store the summary field so it is not lost when skipping the external fetch.
  • Refactors session-drawer.tsx to reset optimistic state during the render phase instead of using useEffect.

🎯 Why

  • Polling terminal sessions created an O(N) bottleneck on the dashboard list view, leading to excessive external network calls and database writes for data that never changes.
  • Using useEffect to reset local state when a prop changes causes cascading re-renders and violates React best practices for performance.

📊 Impact

  • Network/DB: Reduces external API requests to 0 for all terminal sessions. Eliminates unnecessary database patches for terminal sessions.
  • Frontend: Prevents 1 unnecessary re-render cycle every time the user selects a different session from the dashboard table.

🔬 Measurement

  • Observe the Network tab when viewing a dashboard filled with completed/failed sessions; no external requests will be fired by the Next.js server.
  • Review React DevTools Profiler to verify that clicking a session row no longer causes a cascading second render pass in SessionDrawer.

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

…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>
@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 22, 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 22, 2026 8:46am

@cursor

cursor Bot commented Jul 22, 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: 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".

Comment on lines +23 to +24
// Bolt optimization: Skip external polling for completed/failed sessions to avoid unnecessary network/DB 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 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 👍 / 👎.

Comment thread web/lib/sessions-store.ts
first_message: s.firstMessage ?? null,
dispatched_at: s.dispatchedAt,
last_polled: s.lastPolled ?? null,
summary: null,

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

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