Repository navigation
Refactor: shared broadcast/listen, watchDir, task lookup - #229
Merged
Merged
Conversation
broadcast(channel, ...args) in src/main/utils/broadcast.ts sends to every live window, skips destroyed ones and logs instead of throwing. It replaces the private copies in servicesIpc and ScaffoldService and the hand-rolled getAllWindows loops in 11 other places. Targeted sends to one window stay. preload's listen<T>(channel) builds the onX(callback) => unsubscribe pairs; 28 of them now use it. The exposed API is unchanged. Claude goes brr.. via Dash
watchDir(dir, { filter, debounceMs, onChange }) in src/main/utils/watchDir.ts
watches a folder non-recursively, debounces matching events, swallows watch
errors and returns close(). FileWatcherService and PortsConfigWatcher now use
it; their filters, debounce timings and arm-time error handling are unchanged
(watchDir throws if the folder can't be watched, and each caller keeps its
own handling of that).
Claude goes brr.. via Dash
Two selectors next to selectActiveTask in projectsStore find a task across every project (archived included) and return the stored object, so a hook can use them without useShallow. Ten hand-rolled lookups over Object.values(tasksByProject), in eight files, now use them, and so does selectActiveTask. Claude goes brr.. via Dash
Claude goes brr.. via Dash
This was referenced Nov 8, 2026
Merged
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.
Three behaviour-preserving consolidations from the cross-PR design review. This merges before #227 and #228, which get rebased onto it and switched to the new helpers.
1. Broadcast and listen
broadcast(channel, ...args)insrc/main/utils/broadcast.tssends to every live window. It skips destroyed windows and logs a failed send instead of throwing.servicesIpc.tsandScaffoldService.tsand 12 hand-rolledgetAllWindows()loops in 11 files.setSenderservices, and TokenStatsService's sender path.listen<T>(channel)builds theonX(callback) => unsubscribepairs. 28 of them now use it. The exposed API is unchanged.onOrchestratorAccessRequeststays hand-written: it listens on two channels and reshapes the payload.2. watchDir
watchDir(dir, { filter, debounceMs, onChange }) => closeinsrc/main/utils/watchDir.ts. It watches the folder non-recursively, debounces matching events, swallows watch errors and returnsclose().FileWatcherServiceandPortsConfigWatchernow use it. Filters and timings (500 ms, 2 s) are unchanged.watchDirthrows when the folder can't be watched, so each caller keeps its own handling of that.3. Task lookup
selectTaskById(state, id)andselectTaskByPath(state, path)inprojectsStore.ts. Both return the stored task by reference, so they're safe as hook selectors withoutuseShallow.selectActiveTask.One normalisation: the broadcasts that didn't catch send errors before now catch them and log. Nothing else changes.
Tests: broadcast (4), preload listen with a stub ipcRenderer (3), watchDir with a fake
fs.watchand fake timers (5), task lookup (1). Bumps to 0.23.0.🤖 Generated with Claude Code