Skip to content

fix(models): cancel model-route-targets watch on inactive tab#1280

Merged
hibig merged 1 commit into
mainfrom
dev
Jul 14, 2026
Merged

fix(models): cancel model-route-targets watch on inactive tab#1280
hibig merged 1 commit into
mainfrom
dev

Conversation

@hibig

@hibig hibig commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings July 14, 2026 12:26
@hibig
hibig merged commit 3c00317 into main Jul 14, 2026
2 checks passed

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

Copy link
Copy Markdown
Contributor

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 refactors the watch list mechanism for model route targets in the LLM models deployments page. The useWatchList hook is lifted from the TableList component to the parent Deployments component, allowing the watch connection to be paused and resumed when the page becomes inactive or active. However, a potential issue was identified in use-watch-list.ts where calling cancelWatch cancels the requests but does not clear the cached data or state. This can lead to stale or deleted items lingering in the UI when the watch is resumed, so it is recommended to clear the cache and state upon cancellation.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +43 to +46
const cancelWatch = useMemoizedFn(() => {
chunkRequestRef.current?.current?.cancel?.();
listRequestTokenRef.current?.cancel?.();
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

When cancelWatch is called (e.g., when the tab becomes inactive), the watch connection is cancelled, but the cached data in cacheWatchDataListRef.current and watchDataList is not cleared. If any targets are deleted while the tab is inactive, they will not be sent as CREATE or UPDATE events when the watch is restarted upon the tab becoming active again. This will cause those deleted targets to linger in the UI indefinitely. Clearing the cache and state on cancel ensures data consistency when the watch is resumed.

  const cancelWatch = useMemoizedFn(() => {
    chunkRequestRef.current?.current?.cancel?.();
    listRequestTokenRef.current?.cancel?.();
    cacheWatchDataListRef.current = [];
    setWatchDataList([]);
  });

Copilot AI 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.

Pull request overview

This PR moves the MODEL_ROUTE_TARGETS watch lifecycle out of the TableList component and into the deployments page so it can be explicitly started/stopped when the deployments tab becomes active/inactive.

Changes:

  • Add startWatch / cancelWatch controls to useWatchList and use them for cleanup.
  • Start/stop the model-route-targets watcher from src/pages/llmodels/deployments.tsx as part of the existing “inactive/active” request lifecycle.
  • Pass the watched targetList down into the table component via props (and remove the table’s internal watcher).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/pages/llmodels/deployments.tsx Owns the model-route-targets watch lifecycle and passes targetList into the table.
src/pages/llmodels/components/table-list.tsx Removes internal useWatchList usage; consumes targetList via props.
src/hooks/use-watch-list.ts Adds cancelWatch and exposes startWatch/cancelWatch in the hook API; uses cancelWatch in unmount cleanup.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

2 participants