psinetron-opencode-visualizer 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "psinetron-opencode-visualizer",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "main": "index.ts",
5
5
  "description": "OpenCode session visualizer — real-time pixel-art office scene with animated agents",
6
6
  "files": [
@@ -753,11 +753,21 @@ function connect() {
753
753
 
754
754
  switch (data.type) {
755
755
  case "state.sync":
756
- agents.length = 0
757
- agentIdCounter = 0
758
- reservedCoffeeSpots.clear()
759
- for (const inst of data.instances || []) {
760
- createAgent(inst.instanceId, inst.cwd, inst.skin)
756
+ {
757
+ const syncIds = new Set((data.instances || []).map(inst => inst.instanceId))
758
+ if (syncIds.size > 0) {
759
+ for (const a of [...agents]) {
760
+ if (!syncIds.has(a.instanceId)) {
761
+ removeAgent(a.instanceId)
762
+ }
763
+ }
764
+ for (const inst of data.instances || []) {
765
+ const existing = agents.find(a => a.instanceId === inst.instanceId)
766
+ if (!existing) {
767
+ createAgent(inst.instanceId, inst.cwd, inst.skin)
768
+ }
769
+ }
770
+ }
761
771
  }
762
772
  break
763
773
  case "instance.added":