Repository navigation
Move refresh coordination, snapshots and folder watches out of WidgetRuntime - #298
Merged
Merged
Conversation
…gistry The fs.directory sources with watch: true kept their watchers in a dictionary on WidgetRuntime. WorkflowWatchRegistry owns them now: one watch per widget, replaced by the next listing. It asks the runtime two things through WorkflowWatchRegistryHost: whether a change refreshes the widget now (its card is on the open shelf), and the refresh. No behavior change. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ng the outcome finishRefresh did two things in one body: decide whether the result of a native refresh still counts (the gate, the task table, the in-flight set), and apply it (snapshot, scheduler, ledger, cache). They are two functions now, called in the same order. No behavior change. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Which refresh is running for each widget, and whether its result still counts when it ends, was spread over four properties of WidgetRuntime: the in-flight set, the manual requests waiting for a running refresh, the native refresh gate and the task table. NativeRefreshCoordinator owns all four now. The runtime keeps starting refreshes and applying their outcome; it asks the coordinator whether a request joins a running refresh, takes its token from it, and hears back through NativeRefreshCoordinatorHost when an outdated refresh has to run again or a waiting manual request is due. The script path shares the in-flight set through the runtime's endInFlight, as before. No behavior change. A rescan now updates the gate before it cancels the run actions instead of after; neither reads the other. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The renders, the card models the popup observes and the single write path between them lived on WidgetRuntime. SnapshotStore owns them now, in the manner of CardOverlayStore: it refuses a write while the host does (a staged preview), suppresses an unchanged snapshot, publishes on the affected widget's card model only, and reports each change once through SnapshotStoreHost. What a change sets off stays the runtime's, in the same order: the attention, the reading history, the menu bar promoter. So do the disk cache and the desktop mirror, which the runtime writes from many other places. No behavior change: WidgetCardModel publishes at the same moments, and nothing that was published on the runtime moved. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…h their widget A workflow folder watch stayed open until the widget's next listing replaced it, which never came for a widget that was turned off or removed. It is now cancelled when the widget stops, goes away, or its code changes. A manual refresh that waited for a script load cancelled by a rescan stayed behind and fired after a later, unrelated refresh. It now runs when the load is released, or is dropped with a widget that is gone. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The rest of the refresh path out of
WidgetRuntime, one commit per piece, each a behavior-preserving move — then one commit fixing two defects the move made visible.WorkflowWatchRegistry(host: 2): the per-widget folder watches.finishRefreshsplit into "does this result still count" and "apply it".NativeRefreshCoordinator(host: 7): in-flight set, waiting manual requests, the gate and the task table. Applying an outcome stays in the runtime.SnapshotStore(host: 2):snapshots, the card models and the single write path. No@Publishedproperty moved; a runtime test pins "one model publish, no runtime publish".Fixes (last commit, each with tests that fail without it):
Two statement reorders in
loadWidgets/removeWidgetState(gate reload beforerunActions.cancel; card-model cleanup beforeforgetCards); neither reads the other's state.Wiring is covered by runtime-level tests that fail under 13 mutations (host unset, stale result applied, rerun/coalescing removed, cancel on stop removed, fan-out removed…). Full suite: Core 941 / App 1005 / CLI 86, 0 failures.
🤖 Generated with Claude Code