fix(deploy-control): stabilize empty deployments selector - #33
Conversation
The `?? []` fallback in the `deployments` zustand selector allocated a fresh array every render when the active task had no deployments, making `Object.is` see a new snapshot each call and triggering "getSnapshot should be cached" + "Maximum update depth exceeded". Hoist a module-level `EMPTY_DEPLOYMENTS` constant and return it from the selector so the snapshot is reference-stable. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Heads-up: #37 is now open and also touches You and @wuwangzhang1216 may want to compare scope; the maintainer team will decide which path lands so neither effort gets wasted. |
|
Adding one more coordination note: PR #25 is also open against this same The maintainer team will choose which focused fix to land; noting the overlap so everyone has the full picture. |
|
Heads-up: PR #41 is now also open against this same You and @jidechao may want to compare approaches; the maintainer team will decide which one lands. Sharing this so neither effort gets wasted. |
|
Adding one more coordination note: PR #42 is now also open against this same The maintainer team will choose which focused fix lands; noting the overlap so everyone has the latest picture. |
joeylee12629-star
left a comment
There was a problem hiding this comment.
LGTM. Cleanest of the four duplicates — readonly type + module-scope constant fixes the getSnapshot infinite loop without touching the selectActiveTask helper.
Summary
DeployControlselector(s) => selectActiveTask(s)?.deployments ?? []allocated a fresh[]on every render when the active task had nodeployments, so zustand's defaultObject.issnapshot comparison saw a new value each time.getSnapshot should be cached to avoid an infinite loopandMaximum update depth exceeded, surfacing in the preview pane the moment<DeployControl />mounted for a task without prior deployments.EMPTY_DEPLOYMENTS: readonly DeploymentRecord[]constant and return it from the selector so the snapshot reference is stable.Test plan
<DeployControl />renders without the React error overlay.🤖 Generated with Claude Code