Skip to content

feat: [Remote rendering 3.2d] report settled camera gestures to the server - #125

Merged
margalva merged 29 commits into
mainfrom
feat/3.2d-report-camera-to-server
Sep 22, 2026
Merged

margalva merged 29 commits into
mainfrom
feat/3.2d-report-camera-to-server

Conversation

@LKasianAnsys

@LKasianAnsys LKasianAnsys commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

Issue

Resolves #20

Context

This is the last of 4 PRs for user story 3.2 (#20) of the phased implementation plan (ADR here) for adding remote rendering in VISOR.

PR 3.2a (#110) added the server-side camera record and populated it on load, PR 3.2b (#111) updated save_state to read from it, and PR 3.2c (#124) tags each client-side camera change as gesture or programmatic. Gestures still do not reach the server-side record. This PR adds the client-to-server report, so the record is updated after every completed gesture and save_state writes the current camera.

  • Client-side changes
    • CameraSyncReporter subscribes to teh settle from PR 3.2c, reads the camera once at settle time, and sends it with its origin as a new sync_camera trigger.
    • VisorFrontend holds the subscription and releases it when the frontend is replaced on rebuild, so one settle produces one report.
  • Server-side changes
    • sync_camera trigger handler on LocalApp; payloads not tagged gesture are dropped before the coordinator (logged, so an echo is visible in visor.log)
    • VisorSceneBase.sync_camera: under _vtk_lock, writes the record, applies it to the pipeline, and re-serializes.

Two pre-existing bugs, found while testing this PR, are fixed here:

  • The z/r handler had no modifier check, so Ctrl+R reached it as a plain r and reset the camera.
    • When the canvas had focus (next bullet) the reload itself was cancelled, so all Ctrl+R did was reset the camera, and since a reset lands on the default framing it looked like a reload had happened.
    • Once resets are written to the server's record, that is no longer harmless: a Ctrl+R after a camera update in the browser replaces the recorded camera with the reset one.
    • In this PR, both VtkScene and CameraGestureTrackerhave been updated tokeydownand ignoreCtrl, Meta, Alt` and auto-repeat.
  • vtk-wasm creates its canvas with tabindex="0", so after any click the canvas held focus and Ctrl+R, Ctrl+F and F5 were cancelled until focus moved.
    • RemoteVtkScene now removes the attribute; all VISOR key listeners are on window, so nothing depends on focus canvas.

Testing

To test this change, which is the full 3.2 user story work, run the VISOR server, and open the logs/visor.log file.

  • Check that you see one gesture arrival per input path: left drag, middle drag, right drag, wheel, z, r
  • Check that you see no gesture arrival on a load_state
  • Check that after changing the camera in the browser, when you refresh, you get the same camera back.
  • Add a second dataset. Move the camera around; check that only one gesture arrived (ie not one per dataset).
  • Test that after moving the camera around in the browser and saving the state, the saved state has the browser's current camera.

Copilot summary

This pull request implements server-side tracking of user camera gestures. It introduces a new sync_camera trigger, allowing the frontend to report settled camera gestures to the backend, where they are validated, logged, and applied to the server-side camera state. The implementation ensures that only genuine user gestures are recorded, avoids redundant updates, and maintains clear separation of concerns for testability and maintainability.

The most important changes are:

Backend: Camera Gesture Reporting and Handling

  • Added a new sync_camera trigger to the backend, including the SyncCameraPayload model and validation logic, to accept and process camera gesture reports from the frontend. Only gestures with origin: "gesture" are recorded; others are logged and dropped. (src/ansys/visor/viewer/app/trame/local_app.py, src/ansys/visor/viewer/models/runtime/requests/sync_camera_payload.py) [1] [2]
  • Implemented the sync_camera method on the scene coordinator to update the backend camera state and re-serialize it, without triggering client notifications or causing update loops. (src/ansys/visor/viewer/vtk/scene/base.py)

Frontend: Camera Gesture Detection and Reporting

  • Introduced a new CameraSyncReporter module that subscribes to settled camera gestures, builds a precise payload, and sends it to the server using the provided trigger sender. The subscription is managed to avoid duplicate reports on frontend rebuilds. (src/ansys/visor/visor-client/src/CameraSyncReporter.ts, src/ansys/visor/visor-client/src/VisorFrontend.tsx, src/ansys/visor/visor-client/src/App.tsx) [1] [2] [3]
  • Updated the frontend wiring to ensure that the camera gesture reporter is properly attached and released when the frontend is replaced, preventing multiple subscriptions and redundant reports. (src/ansys/visor/visor-client/src/VisorFrontend.tsx, src/ansys/visor/visor-client/src/App.tsx) [1] [2]

Testing and Maintenance

  • Improved testability by splitting out the camera sync reporter logic into its own module and updating camera gesture tests for accuracy (e.g., using keydown instead of keyup for gesture detection). (src/ansys/visor/visor-client/src/jest-tests/CameraGestureTracker.test.js) [1] [2] [3]

@github-actions github-actions Bot added test Work associated with testing added enhancement New feature or request labels Sep 16, 2026
@LKasianAnsys
LKasianAnsys force-pushed the feat/3.2d-report-camera-to-server branch from b1d5fff to 8f07192 Compare September 16, 2026 21:29
@LKasianAnsys
LKasianAnsys changed the base branch from main to feat/3.2c-add-camera-gesture-tracker September 16, 2026 21:48
@LKasianAnsys LKasianAnsys changed the title feat: [Remote rendering 3.2d] report camera to server feat: [Remote rendering 3.2d] report settled camera gestures to the server Sep 16, 2026
@LKasianAnsys
LKasianAnsys force-pushed the feat/3.2d-report-camera-to-server branch from bd5df63 to 551ddc2 Compare September 16, 2026 22:40
@LKasianAnsys
LKasianAnsys force-pushed the feat/3.2c-add-camera-gesture-tracker branch from 5da4a63 to b149c50 Compare September 21, 2026 20:09
@LKasianAnsys
LKasianAnsys force-pushed the feat/3.2d-report-camera-to-server branch from aa2a5e4 to 07de410 Compare September 21, 2026 20:09
Base automatically changed from feat/3.2c-add-camera-gesture-tracker to main September 22, 2026 16:20
@margalva
margalva merged commit 4fba50e into main Sep 22, 2026
15 checks passed
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.

[Remote rendering 3.2] Camera state persistence and sync-back

3 participants