Skip to content

Conversation

@Nightbr
Copy link
Owner

@Nightbr Nightbr commented Jan 13, 2026

Summary

Optimizes the family data polling to only occur during agent conversation, eliminating continuous background polling when idle.

Changes

apps/web/src/hooks/use-family-data.ts

  • Added an isPolling option parameter that controls when polling is active
  • When isPolling is true, polls every 1 second (fast enough to catch updates during conversation)
  • When isPolling is false (default), polling is completely disabled

apps/web/src/hooks/use-chat.ts

  • Added isPolling state that tracks whether polling should be active
  • Added triggerPolling() callback that:
    • Enables polling immediately
    • Resets a 5-second timer on each call
    • Automatically disables polling after 5 seconds of no new messages
  • Calls triggerPolling() every time a text chunk is received from the agent
  • Exposes isPolling in the return value

apps/web/src/components/family/family-panel.tsx

  • Accepts new isPolling prop
  • Passes it to useFamilyData hook

apps/web/src/App.tsx

  • Gets isPolling from useChat()
  • Passes it to <FamilyPanel isPolling={isPolling} />

Behavior

  • Before: Continuously polled every 5 seconds, even when idle
  • After: Only polls for 5 seconds after receiving an agent message, then stops. Timer resets on each new chunk received, ensuring data stays fresh during conversation while not wasting resources when idle.

Pull Request opened by Augment Code with guidance from the PR author

@Nightbr Nightbr merged commit 9d2ebae into main Jan 13, 2026
1 check passed
@Nightbr Nightbr deleted the opti-polling branch January 13, 2026 16:03
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