Conversation
Camillebzd
commented
Apr 1, 2026
- reduce block state tracker max amount of data to 5k instead of 15k
- remove useless events 25k array from useEvent and event context
Greptile SummaryThis PR makes two focused memory-reduction optimisations in the frontend event pipeline: it removes the 25 000-item Key changes:
No issues found. The removal of the in-memory 25 k array is a meaningful win because it eliminates an O(n) state copy on every WebSocket message, and the subscriber pattern already covers all real consumers. Confidence Score: 5/5This PR is safe to merge — changes are well-scoped, all consumers updated, and no remaining references to the removed API. All three files have straightforward, self-consistent changes. A grep across the frontend confirms zero remaining consumers of the removed No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant WS as WebSocket
participant EP as EventsProvider
participant UE as useEvents
participant BST as useBlockStateTracker
Note over EP: Before: stored up to 25k events in state
Note over EP: After: pure pub/sub via subscribersRef
WS->>EP: onmessage (Events[])
EP->>EP: iterate newEvents
EP->>UE: subscribersRef callback(evt)
UE->>BST: onEventRef.current(evt) → queueEvent(evt)
BST->>BST: applyEventToBlocks() (ring-buffer capped at 5k, was 15k)
Reviews (1): Last reviewed commit: "reduce block state tracker max amount of..." | Re-trigger Greptile |
There was a problem hiding this comment.
Pull request overview
This PR reduces frontend memory and re-render overhead by (1) lowering the retained block history size in the block state tracker and (2) removing the large in-memory events array from the events context/hook API.
Changes:
- Reduce
useBlockStateTrackerretained block history from 15,000 to 5,000 blocks. - Remove
eventsstorage (25k array) fromEventsProviderand stop exposing it viauseEvents.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
frontend/hooks/use-events.ts |
Updates the public hook return shape and examples to no longer expose events. |
frontend/hooks/use-block-state-tracker.ts |
Lowers MAX_BLOCKS to reduce retained block history size. |
frontend/contexts/events-context.tsx |
Removes the events state and related retention logic from the context to avoid large in-memory arrays and unnecessary context updates. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.