Skip to content

fix(realtime): deliver realtime updates for analysis & project node lists#1684

Open
tada5hi wants to merge 1 commit into
masterfrom
fix/node-list-realtime-updates
Open

fix(realtime): deliver realtime updates for analysis & project node lists#1684
tada5hi wants to merge 1 commit into
masterfrom
fix/node-list-realtime-updates

Conversation

@tada5hi

@tada5hi tada5hi commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Problem

Analysis- and project-node lists — including the node-execution list on the analysis view — never updated in realtime. New execution_status/approval changes only showed up after a manual reload.

Root cause

In a realm namespace the client subscribed to and filtered on the directional socket rooms (analysisNodeOut/In, projectNodeOut/In), but the TypeORM subscriber only ever publishes to the base entity room (analysisNode / projectNode). Every realtime event was therefore delivered to a room nobody was listening in, and dropped.

The contradiction was actually twofold: the list's custom isSameSocketRoom check demanded the directional room while createEntitySocket's built-in room check demanded the base room — so the realm+direction path could never match, regardless of what the server emitted.

Approach

Realm isolation is already provided by the socket namespace (/resources/<realmId> — the analysis realm and node realm are distinct namespaces). The in/out split therefore only needs to gate permissions, not separate rooms. So all directional subscriptions now join the base entity room (the one the subscriber emits to), and the directional event names are kept solely for their permission checks (ANALYSIS_APPROVE/ANALYSIS_UPDATE, PROJECT_APPROVE/PROJECT_UPDATE).

Changes

Server (server-core)

  • Directional analysis-/project-node subscribe handlers now join the base room instead of …Out/…In.
  • Fixed the analysis-node base handler whose unsubscribe listener was registered on the SUBSCRIBE event name (base subscribe joined then immediately left).

Client (client-vue)

  • Lists (FAnalysisNodes, FProjectNodes): dropped the contradictory isSameSocketRoom check; processEvent now only confirms the event belongs to the viewed source.
  • Per-item managers (FAnalysisNode, FProjectNode): buildChannelName now targets the base room.
  • createEntitySocket passes the effective realmId into buildSubscribe/UnsubscribeEventName, so master-realm sockets (root namespace) emit the base subscribe and join the base room, while realm sockets emit the directional subscribe — the subscribe event now always matches the namespace the socket actually connects to.
  • Fixed a FProjectNode.processEvent realm-field swap (PROJECT/NODE were comparing the wrong *_realm_id).

Behavior after

  • Non-master user in their realm (the reported case): node-execution list updates live.
  • Master user on the root namespace: emits the base subscribe → joins the base room → receives the all-realm broadcast, narrowed client-side by isSocketEventForSource.

Verification

  • eslint clean on all touched files.
  • server-core (tsc) and client-vue (vue-tsc) build/type-check.
  • No tests reference the changed room names or builders.
  • Manual: open an analysis's node-execution list as a realm user and trigger a node execution_status change — badge/progress update without reload.

Follow-ups (not in this PR)

  • Root-namespace firehose: master sockets decode every realm's node events and filter client-side. Correct, but could be narrowed server-side on busy instances.
  • Per-item managers' sockets are redundant with the list socket when rendered inside a list (idempotent, but an optional opt-out prop could avoid N+1 subscriptions).

Summary by CodeRabbit

  • Bug Fixes
    • Fixed realm-level socket event handling for analysis nodes to properly distinguish between subscription and unsubscription events.
    • Corrected socket event routing for project and analysis nodes to ensure reliable real-time synchronization within scoped realm environments.
    • Improved event subscription consistency by refining how directional event types are handled across different realm scopes.

…ists

Analysis- and project-node lists (incl. the node-execution list) never
updated in realtime. In a realm namespace the client subscribed to and
filtered on the directional rooms (analysisNodeOut/In, projectNodeOut/In),
but the subscriber only ever publishes to the base entity room, so every
event was dropped. The client's built-in room check also demanded the base
room, contradicting the directional filter, so the path could never match.

Realm isolation is already provided by the socket namespace
(/resources/<realmId>); the in/out split only needs to gate permissions.
Unify all directional subscriptions onto the base entity room (the room the
subscriber emits to) and keep the directional event names solely for their
permission checks.

- server: directional analysis-/project-node subscribe handlers join the
  base room; fix the analysis-node base handler whose unsubscribe listener
  was registered on the SUBSCRIBE event name
- client: drop the contradictory isSameSocketRoom check; lists' and
  managers' room checks use the base entity room
- pass the effective realmId into buildSubscribe/UnsubscribeEventName so
  master-realm sockets (root namespace) emit the base subscribe and join
  the base room, while realm sockets emit the directional subscribe
- fix FProjectNode realm-field swap in processEvent (PROJECT/NODE were
  comparing the wrong *_realm_id field)
Copilot AI review requested due to automatic review settings June 15, 2026 20:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1c278ec0-fad3-4deb-9952-2e5890f6d35b

📥 Commits

Reviewing files that changed from the base of the PR and between ac2012f and a3d340c.

📒 Files selected for processing (8)
  • apps/server-core/src/adapters/socket/controllers/analysis-node/handlers.ts
  • apps/server-core/src/adapters/socket/controllers/project-node/handlers.ts
  • packages/client-vue/src/components/analysis-node/FAnalysisNode.ts
  • packages/client-vue/src/components/analysis-node/FAnalysisNodes.ts
  • packages/client-vue/src/components/project-node/FProjectNode.ts
  • packages/client-vue/src/components/project-node/FProjectNodes.ts
  • packages/client-vue/src/core/entity-socket/module.ts
  • packages/client-vue/src/core/entity-socket/type.ts

📝 Walkthrough

Walkthrough

Socket room subscription routing is corrected for analysis-node and project-node domains. Server handlers now join the base DomainType room for both IN and OUT directional events instead of directional subtypes. The EntitySocketContext callbacks gain an optional realmId parameter, which createEntitySocket now passes through, enabling client components to generate direction-aware event names only when realm-scoped.

Changes

Socket Room Routing and Realm-Aware Event Naming

Layer / File(s) Summary
EntitySocketContext callback contract
packages/client-vue/src/core/entity-socket/type.ts
buildSubscribeEventName and buildUnsubscribeEventName signatures updated to accept realmId?: string, keeping the return type unchanged.
createEntitySocket passes realmId
packages/client-vue/src/core/entity-socket/module.ts
createEntitySocket forwards realmId.value when invoking both event-name builder callbacks instead of calling them with no arguments.
Server-side directional room routing fix
apps/server-core/src/adapters/socket/controllers/analysis-node/handlers.ts, apps/server-core/src/adapters/socket/controllers/project-node/handlers.ts
Fixes the analysis-node UNSUBSCRIBE handler registration (was duplicating SUBSCRIBE). Routes both IN and OUT directional subscriptions to the base DomainType.ANALYSIS_NODE / DomainType.PROJECT_NODE room instead of their DomainSubType variants. Adds inline comments explaining that realm namespace isolation handles the directional distinction.
Client analysis-node event naming
packages/client-vue/src/components/analysis-node/FAnalysisNode.ts, packages/client-vue/src/components/analysis-node/FAnalysisNodes.ts
FAnalysisNode always uses DomainType.ANALYSIS_NODE for buildChannelName and introduces buildSubscribeEventName/buildUnsubscribeEventName that select direction-specific subtypes only when a realmId is present. FAnalysisNodes removes the isSameSocketRoom roomName-matching helper and drops buildDomainChannelName, relying on createEntitySocket's resolved realmId instead.
Client project-node event naming and realm fix
packages/client-vue/src/components/project-node/FProjectNode.ts, packages/client-vue/src/components/project-node/FProjectNodes.ts
FProjectNode corrects Target.NODE realm filtering to use event.data.node_realm_id, switches buildChannelName to DomainType.PROJECT_NODE, and adds realmId-aware event-name builders. FProjectNodes removes isSameSocketRoom and roomName-based filtering, accepting an effective realmId parameter in both event-name builders.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐇 Hoppity-hop through the socket maze,
Rooms were misnamed in a directional daze!
Now IN and OUT join the same base hall,
realmId travels to the event call.
No more isSameSocketRoom checking astray —
The bunny fixed routing and hopped away! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main fix: delivering realtime updates for analysis & project node lists, which directly addresses the root cause and solution outlined in the PR objectives.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/node-list-realtime-updates

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants