Skip to content

refactor(frontend): merge Watch class into useResourceWatch composable#3081

Merged
talos-bot merged 11 commits into
siderolabs:mainfrom
Slessi:watch-refactoring
Jul 2, 2026
Merged

refactor(frontend): merge Watch class into useResourceWatch composable#3081
talos-bot merged 11 commits into
siderolabs:mainfrom
Slessi:watch-refactoring

Conversation

@Slessi

@Slessi Slessi commented Jul 2, 2026

Copy link
Copy Markdown
Member

Merge the Watch class into the useResourceWatch composable. Comes with a lot of code simplifications, and is the first step in having watch singletons so that a given resource is never watched more than once across multiple components.

Basic design:

  • useResourceWatch entry-point, determines if its a single item or list watch
    • useWatchSingle if single, goes here. Doesn't do much other than set/remove the watched item.
    • useWatchMulti if a list, goes here. All list logic encapsulated here (sorting, bootstrapping, total)
  • useWatchStream both single/multi will call this final composable, which handles opening and closing the stream, setting request options, loading/error state, forwarding the stream messages, parsing JSON.

Closes #1471

Comment thread frontend/src/components/OngoingTasks/OngoingTasks.vue
@github-project-automation github-project-automation Bot moved this from In Review to Approved in Planning Jul 2, 2026
Slessi added 11 commits July 2, 2026 21:27
Merge WatchFunc and Watch classes together, as there is no longer a requirement for them to be separated

Signed-off-by: Edward Sammut Alessi <edward.sammutalessi@siderolabs.com>
Migrate Watch.setup() into useResourceWatch as part of the slow removal of the Watch class

Signed-off-by: Edward Sammut Alessi <edward.sammutalessi@siderolabs.com>
Migrate the tests for Watch to the useResourceWatch tests

Signed-off-by: Edward Sammut Alessi <edward.sammutalessi@siderolabs.com>
Remove unnecessary setDescending func from WatchItems. The information can be passed in from the watch event.

Signed-off-by: Edward Sammut Alessi <edward.sammutalessi@siderolabs.com>
Inline most of the callbacks in the Watch class to ease refactoring.

Signed-off-by: Edward Sammut Alessi <edward.sammutalessi@siderolabs.com>
Lift item handlers up from Watch class to useResourceWatch composable

Signed-off-by: Edward Sammut Alessi <edward.sammutalessi@siderolabs.com>
Lift the remaining parts of the Watch class (start & stop) to the useResourceWatch composable. Do some code simplification on the composable side.

Signed-off-by: Edward Sammut Alessi <edward.sammutalessi@siderolabs.com>
Merge WatchItems into useResourceWatch composable

Signed-off-by: Edward Sammut Alessi <edward.sammutalessi@siderolabs.com>
Lift typescript interfaces from watch to useResourceWatch

Signed-off-by: Edward Sammut Alessi <edward.sammutalessi@siderolabs.com>
Remove unnecessary usages of the itemID helper as it does not offer any benefit over using item.metadata.id. Keep it for useResourceWatch incase of k8s resources that may span multiple namespaces.

Signed-off-by: Edward Sammut Alessi <edward.sammutalessi@siderolabs.com>
When a stream closes due to a connection drop, store the current state of the list in an intermediary value until the new list is fully bootstrapped.

Signed-off-by: Edward Sammut Alessi <edward.sammutalessi@siderolabs.com>
@Slessi

Slessi commented Jul 2, 2026

Copy link
Copy Markdown
Member Author

/m

@talos-bot talos-bot merged commit 2d56102 into siderolabs:main Jul 2, 2026
78 of 80 checks passed
@github-project-automation github-project-automation Bot moved this from Approved to Done in Planning Jul 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Watch/useWatch refactoring

3 participants