Only refresh tasks on RTC invalidation if a view is open.#11264
Only refresh tasks on RTC invalidation if a view is open.#11264liliwilson wants to merge 4 commits into
Conversation
74e141b to
c2ba08f
Compare
|
/oz-review |
|
I'm re-reviewing this pull request in response to a review request. You can view the conversation on Warp. I completed the review and no human review was requested for this pull request. Comment Powered by Oz |
There was a problem hiding this comment.
Overview
This PR carries ambient task IDs through RTC update events, gates task-list refreshes on active list consumers, and adds a deferred catch-up refresh when a list view opens.
Concerns
- Force-refreshing an open task clears existing fetch state, which can spawn overlapping single-task requests for repeated RTC events and allow an older response to overwrite newer task data.
- Deferred updates while no view is open are collapsed to one timestamp and flushed through one capped list fetch, so high-volume updates can be missed when the view reopens.
- The PR description does not include manual testing details or screenshots/recording. Because this changes user-visible freshness for agent task details/list views, please attach evidence demonstrating the flow end to end.
- The checked-in tech spec links to a contributor-local
/Users/...file that reviewers and future readers cannot access.
Verdict
Found: 0 critical, 3 important, 1 suggestions
Request changes
Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).
Powered by Oz
|
|
||
| // Flush dirty tasks accumulated while no view was open. | ||
| if let Some(dirty_since) = self.dirty_since.take() { | ||
| self.fetch_tasks_updated_after(dirty_since, ctx); |
There was a problem hiding this comment.
fetch_tasks_updated_after requests only INITIAL_TASK_AMOUNT tasks, so if more than 100 tasks changed while no view was open, reopening a list view drops the rest while RTC polling remains disabled. Track dirty task IDs or page until all updates are loaded before clearing dirty_since.
There was a problem hiding this comment.
I think this is fine, since the management views already behave this way—we fetch more things when you apply a filter, but some tasks are genuinely inaccessible via this view because they are too old
There was a problem hiding this comment.
Right, the view should always be showing the most recent 100 tasks that match the filters - we're not trying to show all tasks
6820a1e to
dd4ef6d
Compare
dd4ef6d to
a01931c
Compare
|
I'm starting a first review of this pull request. You can view the conversation on Warp. I completed the review and no human review was requested for this pull request. Comment Powered by Oz |
There was a problem hiding this comment.
Overview
This PR threads RTC task IDs through UpdateManager and changes AgentConversationsModel to avoid broad task-list refreshes unless a list surface is open, with dirty-state flushing when a list view reopens.
Concerns
- The throttled list refresh timer can still fire after all list consumers close, so pending RTC events recorded while a list view was open can still trigger a broad list fetch with no view open.
Verdict
Found: 0 critical, 1 important, 0 suggestions
Request changes
Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).
Powered by Oz
| match std::mem::take(&mut self.rtc_task_refresh_throttle_state) { | ||
| RtcTaskRefreshThrottleState::Idle => { | ||
| self.fetch_tasks_updated_after(timestamp, ctx); | ||
| self.start_rtc_task_refresh_throttle_timer(ctx); |
There was a problem hiding this comment.
start_rtc_task_refresh_throttle_timer will still run fetch_tasks_updated_after, causing the broad refresh this PR is trying to avoid. Abort the RTC throttle when the last list consumer closes or re-check has_list_consumers before flushing the pending timestamp.
There was a problem hiding this comment.
This seems fine? A few unnecessary refreshes if someone happens to toggle the management view shouldn't add that much traffic
| match std::mem::take(&mut self.rtc_task_refresh_throttle_state) { | ||
| RtcTaskRefreshThrottleState::Idle => { | ||
| self.fetch_tasks_updated_after(timestamp, ctx); | ||
| self.start_rtc_task_refresh_throttle_timer(ctx); |
There was a problem hiding this comment.
This seems fine? A few unnecessary refreshes if someone happens to toggle the management view shouldn't add that much traffic
|
|
||
| // Flush dirty tasks accumulated while no view was open. | ||
| if let Some(dirty_since) = self.dirty_since.take() { | ||
| self.fetch_tasks_updated_after(dirty_since, ctx); |
There was a problem hiding this comment.
Right, the view should always be showing the most recent 100 tasks that match the filters - we're not trying to show all tasks
| self.abort_rtc_task_refresh_throttle(); | ||
| self.active_data_consumers_per_window.clear(); | ||
| self.task_fetch_state.clear(); | ||
| self.dirty_since = None; |
There was a problem hiding this comment.
Should fetch_tasks_updated_after also clear dirty_since? Once we do a list refresh, either:
- The updated but unfetched task(s) will be included in the list response
- They'll be old enough to fall out of the view
| ) { | ||
| ctx.emit(UpdateManagerEvent::AmbientTaskUpdated { timestamp }); | ||
| let Ok(task_id) = task_id.parse::<AmbientAgentTaskId>() else { | ||
| log::warn!("Ignoring AmbientTaskUpdated with unparseable task_id: {task_id}"); |
There was a problem hiding this comment.
Probably worth using log::error or report_error! - if the server is sending back task IDs that the client can't parse, we'd need to fix it
Description
This PR updates the client-side RTC logic to only refetch data for a task on an RTC invalidation if:
task_idfrom the RTC notification)Right now, whenever we get any RTC invalidation, we discard the task ID and do a refetch. The throttling introduced in #11236 limits this fetch to once per every 5s, but we really shouldn't be refetching on every RTC invalidation if we don't need to.
Testing
./script/runTested locally, loom: https://www.loom.com/share/c4b23aaab2c4447c8839631941bbcce2
Agent Mode