Skip to content

feat: Remote rendering 4.4a: Update server mode panels when scene changes - #194

Open
LKasianAnsys wants to merge 5 commits into
feat/4.5-record-camera-and-cross-section-dragsfrom
feat/4.4a-update-server-mode-panels-when-scene-changes
Open

LKasianAnsys wants to merge 5 commits into
feat/4.5-record-camera-and-cross-section-dragsfrom
feat/4.4a-update-server-mode-panels-when-scene-changes

Conversation

@LKasianAnsys

@LKasianAnsys LKasianAnsys commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Issue

Addresses #29

Context

Until now, in a loaded visor scene, server-side API calls such as add_dataset or load_state updated the server-mode canvas but not the UI panels, and picks on new parts did not resolve to anything. A refresh was needed to fetch the new, updated scene.

In this PR, the server now bumps a scene_version state key once per scene-changing API call, and the client rebuilds the frontend when it changes. The latest request wins, and each replaced frontend releases its listeners.

Like the current client mode, server mode now rebuilds the full frontend on each python-originated scene change. (The scope of Phase 4 of the remote rendering epic targets parity with the client mode; an optimization to allow for in-place updates for data-only changes is expected in Phase 6 of the epic.)

Manual check: Start a VISOR session in server mode, open the viewer, run add_dataset to add a second dataset, and see that the tree shows the new dataset without needing to refresh the page. Clicking a part of the new dataset selects it.

Copilot summary

This pull request introduces a robust mechanism for tracking and responding to scene changes in server-mode VTK visualization, ensuring that the frontend reliably rebuilds whenever the scene changes. The main changes include adding a versioning key that increments with every scene modification on the server, a new frontend rebuilder utility on the client to handle rebuild requests efficiently, and comprehensive test coverage for these new behaviors.

Server-side scene change tracking:

  • Added scene_version state key and logic in ServerStatePublisher to increment this value on every scene change, ensuring all modifications are serially tracked and communicated to clients. [1] [2]
  • Refactored VisorVTK and its subclasses to call a _post_scene_change_hook after every scene-changing operation, which bumps the scene_version in server mode or does nothing in client mode. This is enforced via a new @notifies_scene_change decorator applied to all relevant methods. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]

Frontend rebuild and state synchronization:

  • Introduced the FrontendRebuilder class, which ensures that multiple rebuild requests during an ongoing build collapse into a single additional build, preventing redundant work and handling errors gracefully.
  • Updated the useServerVtk hook to watch the scene_version key and trigger frontend rebuilds using FrontendRebuilder whenever the scene changes, ensuring the UI always matches the server state. [1] [2]

Testing improvements:

  • Added comprehensive Jest tests for FrontendRebuilder, verifying its correct batching and error-handling behavior.
  • Added tests to ensure ServerRenderer properly removes its frame listeners on disposal, preventing memory leaks or stale listeners.
  • Improved test mocks to simulate the new state-watching behavior.

Internal code refactoring:

  • Extracted shared scene-clearing logic into a private _clear_scene method, used by both clear and remove_dataset to avoid code duplication.
  • Improved comments and documentation throughout the affected files for better maintainability and clarity.

These changes together provide a robust, efficient, and well-tested mechanism for keeping the frontend in sync with all server-side scene changes in VTK server mode.

@github-actions github-actions Bot added test Work associated with testing added enhancement New feature or request labels Oct 27, 2026
@LKasianAnsys LKasianAnsys changed the title Feat/4.4a update server mode panels when scene changes feat: [Remote rendering 4.4a] Update server mode panels when scene changes Oct 27, 2026
@LKasianAnsys LKasianAnsys self-assigned this Oct 27, 2026
@LKasianAnsys
LKasianAnsys force-pushed the feat/4.4a-update-server-mode-panels-when-scene-changes branch from 3300896 to 2ca7f83 Compare October 28, 2026 14:11
@LKasianAnsys
LKasianAnsys force-pushed the feat/4.4a-update-server-mode-panels-when-scene-changes branch from 2ca7f83 to 32f9772 Compare October 28, 2026 16:17
@LKasianAnsys
LKasianAnsys force-pushed the feat/4.4a-update-server-mode-panels-when-scene-changes branch from 32f9772 to 4f17bad Compare October 28, 2026 16:31
@LKasianAnsys
LKasianAnsys added this pull request to stack #197 October 29, 2026 20:54
@LKasianAnsys
LKasianAnsys force-pushed the feat/4.4a-update-server-mode-panels-when-scene-changes branch from 4f17bad to 5574cb6 Compare October 29, 2026 21:57
@LKasianAnsys LKasianAnsys changed the title feat: [Remote rendering 4.4a] Update server mode panels when scene changes feat: Remote rendering 4.4a: Update server mode panels when scene changes Oct 29, 2026
@LKasianAnsys
LKasianAnsys force-pushed the feat/4.4a-update-server-mode-panels-when-scene-changes branch 2 times, most recently from c52afc1 to 11d3c3e Compare November 2, 2026 13:57
@LKasianAnsys
LKasianAnsys force-pushed the feat/4.4a-update-server-mode-panels-when-scene-changes branch from 11d3c3e to 5c61d70 Compare November 2, 2026 14:24

This branch has not been deployed

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

Labels

added enhancement New feature or request test Work associated with testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants