Skip to content

Conversation

@Shironex
Copy link
Collaborator

@Shironex Shironex commented Jan 21, 2026

  • Introduced a new useEventRecency hook to track the recency of WebSocket events, allowing for conditional polling based on event activity.
  • Updated AgentInfoPanel to utilize the new hook, adjusting polling intervals based on WebSocket activity.
  • Implemented debounced invalidation for auto mode events to optimize query updates during rapid event streams.
  • Added utility functions for managing event recency checks in various query hooks, improving overall responsiveness and reducing unnecessary polling.
  • Introduced debounce and throttle utilities for better control over function execution rates.

This enhancement improves the application's performance by reducing polling when real-time updates are available, ensuring a more efficient use of resources.

Summary by CodeRabbit

  • New Features

    • Added intelligent polling optimization that detects real-time WebSocket activity to reduce unnecessary background requests.
    • Introduced debounced query updates for more efficient data synchronization.
  • Improvements

    • Enhanced real-time status tracking to provide more responsive activity detection.
    • Optimized query refresh intervals based on incoming real-time events.

✏️ Tip: You can customize this high-level summary in your review settings.

- Introduced a new `useEventRecency` hook to track the recency of WebSocket events, allowing for conditional polling based on event activity.
- Updated `AgentInfoPanel` to utilize the new hook, adjusting polling intervals based on WebSocket activity.
- Implemented debounced invalidation for auto mode events to optimize query updates during rapid event streams.
- Added utility functions for managing event recency checks in various query hooks, improving overall responsiveness and reducing unnecessary polling.
- Introduced debounce and throttle utilities for better control over function execution rates.

This enhancement improves the application's performance by reducing polling when real-time updates are available, ensuring a more efficient use of resources.
@Shironex Shironex self-assigned this Jan 21, 2026
@Shironex Shironex added Testers-Requested Request for others to test an enhancement or bug fix/etc. Performance A feature or bug is impacting performance and this needs to be looked at, Do Not Merge Use this label if something should not be merged. labels Jan 21, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @Shironex, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances application performance and resource efficiency by intelligently managing API polling. Instead of constant polling, the system now prioritizes real-time WebSocket updates. When WebSocket activity is detected, polling is either reduced or disabled, and rapid event-driven query invalidations are debounced to prevent UI thrashing. This ensures a smoother user experience and reduces server load by fetching data only when necessary or when real-time streams are inactive.

Highlights

  • Dynamic API Polling: Introduced a new useEventRecency hook and associated utilities to track the recency of WebSocket events. This allows the application to dynamically adjust API polling intervals, reducing unnecessary polling when real-time WebSocket updates are active and healthy.
  • Optimized Query Invalidation: Implemented debounced invalidation for auto_mode_progress events within useAutoModeQueryInvalidation. This batches rapid query invalidations during continuous event streams, preventing excessive re-renders and improving UI responsiveness.
  • Centralized Event Recency Tracking: A new Zustand store (useEventRecencyStore) was created to centralize the tracking of global and query-specific WebSocket event timestamps, making it easier for various parts of the application to react to real-time event flow.
  • New Utility Functions: Added general-purpose debounce and throttle utility functions to libs/utils, providing robust tools for rate-limiting function calls across the codebase.
  • Integration with Existing Query Hooks: Existing query hooks like useFeature, useAgentOutput, and useSpecRegenerationStatus have been updated to leverage the new event recency logic, disabling their polling mechanisms when WebSocket events are recent.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request significantly improves the application's performance by introducing a new useEventRecency hook and debounced invalidation for query updates. The changes effectively reduce unnecessary API polling when real-time WebSocket events are active, leading to a more efficient use of resources. The new debounce and throttle utilities are well-implemented and thoroughly tested, providing robust rate-limiting capabilities. Overall, the changes are well-structured and address the stated objective of fixing excessive API polling.

Shironex and others added 2 commits January 21, 2026 16:10
Address PR review feedback:
- Use WS_ACTIVITY_THRESHOLD constant instead of hardcoded 10000 in agent-info-panel.tsx
- Extract AGENT_OUTPUT_POLLING_INTERVAL constant for 5000ms value in use-features.ts

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…tments

- Bumped version from 0.12.0rc to 0.13.0 across the project.
- Updated package-lock.json to reflect changes in dependencies, including marking certain dependencies as `devOptional`.
- Adjusted import paths in the UI for better module organization.

This update ensures consistency in versioning and improves the structure of utility imports.
@coderabbitai
Copy link

coderabbitai bot commented Jan 21, 2026

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

📝 Walkthrough

Walkthrough

The PR introduces WebSocket activity tracking and smart polling mechanisms. A new event recency module with Zustand store tracks WebSocket event timestamps globally and per-query-key. Query hooks are modified to disable polling when recent WebSocket events are detected. A debounce utility is added to manage frequent invalidation updates, reducing unnecessary API calls during rapid WebSocket activity.

Changes

Cohort / File(s) Change Summary
WebSocket Activity Tracking
apps/ui/src/hooks/use-event-recency.ts
New module introducing Zustand-based event recency store with 5-second threshold, supporting per-key and global event timestamp tracking; exports useEventRecorder, useEventRecency hooks and getGlobalEventsRecent/getEventsRecent helpers for polling integration.
Kanban Component Integration
apps/ui/src/components/views/board-view/components/kanban-card/agent-info-panel.tsx
Added WebSocket activity tracking state (lastWsEventTimestamp, isReceivingWsEvents) with 10-second inactivity timeout; reworked polling logic to compute pollingInterval dynamically based on auto-task status, feature state, and active WebSocket reception.
Hooks & Query Integration
apps/ui/src/hooks/index.ts, apps/ui/src/hooks/queries/use-features.ts, apps/ui/src/hooks/queries/use-spec.ts
Added re-exports from use-event-recency module; integrated global recent-events checking to conditionally disable polling in useFeature, useAgentOutput, and useSpecRegenerationStatus hooks; introduced AGENT_OUTPUT_POLLING_INTERVAL constant (5000ms).
Query Invalidation Enhancement
apps/ui/src/hooks/use-query-invalidation.ts
Introduced per-feature debounced invalidation for agentOutput queries (150ms wait, 2000ms maxWait); added WebSocket event recording via recordGlobalEvent() across multiple hooks; implemented cleanup for debounced functions on feature completion or unmount.
Debounce Utility
libs/utils/src/debounce.ts
New utility module providing debounce and throttle functions with leading/trailing options, maxWait enforcement, and cancel/flush/pending control methods; includes full type definitions and comprehensive JSDoc documentation.
Utility Exports & Configuration
libs/utils/src/index.ts, libs/utils/package.json
Added re-exports for debounce, throttle functions and DebounceOptions, ThrottleOptions, DebouncedFunction types; updated package.json exports map to include "./debounce" entry.
Debounce Test Suite
libs/utils/tests/debounce.test.ts
New comprehensive test coverage for debounce (delayed execution, arguments, options, utility methods) and throttle (immediate invocation, periodic behavior, option interactions) using fake timers.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

Suggested labels

scope: ui, performance

Poem

🐰 WebSocket whispers flow through the ether,
Smart polls now heed when events gather,
Debounce catches the rapid-fire chatter,
Real-time feels snappier, no more wasted lather!

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Title check ⚠️ Warning The title 'fix: excessive api pooling' contains a typo ('pooling' instead of 'polling') and while related to the changeset, the substantive issue described in the PR is excessive API polling that needs fixing. Correct the typo to 'fix: excessive api polling' → 'fix: excessive API polling' to accurately reflect the issue being addressed.
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Shironex Shironex merged commit c3cecc1 into v0.14.0rc Jan 21, 2026
5 of 6 checks passed
@Shironex Shironex deleted the fix/excessive-api-polling branch January 21, 2026 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Do Not Merge Use this label if something should not be merged. Performance A feature or bug is impacting performance and this needs to be looked at, Testers-Requested Request for others to test an enhancement or bug fix/etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants