Skip to content

Feature/react viewer#14972

Merged
remibettan merged 57 commits into
realsenseai:developmentfrom
remibettan:feature/react-viewer
May 11, 2026
Merged

Feature/react viewer#14972
remibettan merged 57 commits into
realsenseai:developmentfrom
remibettan:feature/react-viewer

Conversation

@remibettan

Copy link
Copy Markdown
Contributor

Tracked by: RSDEV-6224

Copilot AI review requested due to automatic review settings April 26, 2026 11:22
Comment thread wrappers/rest-api/tools/react-viewer/scripts/bundle-for-prod.js
Comment thread wrappers/rest-api/tools/react-viewer/scripts/bundle-for-prod.js
Comment thread wrappers/rest-api/tools/react-viewer/src-tauri/src/main.rs
Comment thread wrappers/rest-api/app/services/rs_manager.py
Comment thread wrappers/rest-api/tools/react-viewer/src-tauri/Cargo.lock
Comment thread wrappers/rest-api/app/services/rs_manager.py Outdated
Comment thread wrappers/rest-api/tools/react-viewer/src/components/DevicePanel.tsx Outdated
Comment thread wrappers/rest-api/tools/react-viewer/src/components/DevicePanel.tsx Outdated
Comment thread wrappers/rest-api/app/api/endpoints/sensor_streaming.py Outdated
Comment thread wrappers/rest-api/app/services/rs_manager.py
Comment thread wrappers/rest-api/tools/react-viewer/src/components/IMUViewer.tsx
Comment thread wrappers/rest-api/tools/react-viewer/src/store/index.ts
Comment thread wrappers/rest-api/tools/react-viewer/src/components/DevicePanel.tsx
Comment thread wrappers/rest-api/tools/react-viewer/src/api/socket.ts Outdated
Comment thread wrappers/rest-api/tools/react-viewer/src/api/socket.ts Outdated
Comment thread wrappers/rest-api/app/models/stream.py Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a new React-based “react-viewer” tool (with unit/integration + E2E testing and Tauri desktop packaging) and updates the REST API backend to support additional viewer capabilities (firmware endpoints, per-sensor streaming, depth helpers, improved streaming/timing responses).

Changes:

  • Introduces a full Vite/React frontend (UI components, Zustand store integration, Tailwind styling) plus Vitest + MSW unit tests and Playwright E2E tests.
  • Adds Tauri desktop packaging scaffolding and Windows build/diagnostics scripts for bundling the frontend + a PyInstaller-built FastAPI executable.
  • Extends the FastAPI backend with /api/v1 routing, health + firmware endpoints, per-sensor streaming endpoints/models, and enhanced stream start responses (timings, cache reuse, depth helpers).

Reviewed changes

Copilot reviewed 86 out of 99 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
wrappers/rest-api/tools/react-viewer/vitest.config.ts Adds Vitest configuration (globals/jsdom/setup/coverage).
wrappers/rest-api/tools/react-viewer/vite.config.ts Adds Vite dev/build configuration (aliases, proxy, chunking).
wrappers/rest-api/tools/react-viewer/tests/utils/test-utils.tsx Adds RTL helpers + Zustand store reset + mock factories.
wrappers/rest-api/tools/react-viewer/tests/unit/components/Toast.test.tsx Adds unit tests for Toast + ToastContainer.
wrappers/rest-api/tools/react-viewer/tests/unit/components/StreamViewer.test.tsx Adds StreamViewer rendering/empty-state tests.
wrappers/rest-api/tools/react-viewer/tests/unit/components/Header.test.tsx Adds Header tests (logo, view toggle, tooltip).
wrappers/rest-api/tools/react-viewer/tests/unit/components/DevicePanel.test.tsx Adds DevicePanel tests (empty/loading/list/error/refresh).
wrappers/rest-api/tools/react-viewer/tests/unit/api/client.test.ts Adds API client tests using MSW fixtures/handlers.
wrappers/rest-api/tools/react-viewer/tests/setup/test-setup.ts Adds global test setup (jest-dom, MSW, WebRTC + Socket mocks).
wrappers/rest-api/tools/react-viewer/tests/mocks/server.ts Adds MSW node server with Vitest lifecycle hooks.
wrappers/rest-api/tools/react-viewer/tests/mocks/fixtures/sensors.ts Adds sensor/option fixtures (including PP options).
wrappers/rest-api/tools/react-viewer/tests/mocks/fixtures/index.ts Re-exports fixtures for convenience.
wrappers/rest-api/tools/react-viewer/tests/mocks/fixtures/devices.ts Adds device/device-state fixtures for tests.
wrappers/rest-api/tools/react-viewer/tests/mocks/api-handlers.ts Adds MSW request handlers for the viewer API surface.
wrappers/rest-api/tools/react-viewer/tests/e2e/smoke.spec.ts Adds Playwright smoke tests for basic app load/visibility.
wrappers/rest-api/tools/react-viewer/tests/e2e/real-device.spec.ts Adds Playwright real-hardware tests gated by REAL_DEVICE.
wrappers/rest-api/tools/react-viewer/tests/e2e/fixtures.ts Adds Playwright fixtures/helpers for mock vs real device mode.
wrappers/rest-api/tools/react-viewer/tests/README.md Documents test structure, running commands, and troubleshooting.
wrappers/rest-api/tools/react-viewer/tests/LATEST_FIX.md Documents a specific historical test fix and rationale.
wrappers/rest-api/tools/react-viewer/tests/INSTALLATION.md Documents how to install and verify the testing stack.
wrappers/rest-api/tools/react-viewer/tests/FIXES.md Summarizes fixes made to get tests passing.
wrappers/rest-api/tools/react-viewer/tailwind.config.js Adds Tailwind theme/content configuration.
wrappers/rest-api/tools/react-viewer/src/vite-env.d.ts Adds Vite client type references.
wrappers/rest-api/tools/react-viewer/src/main.tsx Adds React entry point.
wrappers/rest-api/tools/react-viewer/src/index.css Adds Tailwind directives + global styles.
wrappers/rest-api/tools/react-viewer/src/components/index.ts Adds barrel exports for components.
wrappers/rest-api/tools/react-viewer/src/components/WhatsNew.tsx Adds “What’s New” modal + version tracking.
wrappers/rest-api/tools/react-viewer/src/components/Toast.tsx Adds Toast UI components.
wrappers/rest-api/tools/react-viewer/src/components/PointCloudViewer.tsx Adds Three.js point cloud rendering + PLY export.
wrappers/rest-api/tools/react-viewer/src/components/LoadingSplash.tsx Adds loading overlay UI.
wrappers/rest-api/tools/react-viewer/src/components/IMUViewer.tsx Adds IMU charts + CSV export.
wrappers/rest-api/tools/react-viewer/src/components/Header.tsx Adds app header with view toggle + About modal.
wrappers/rest-api/tools/react-viewer/src/components/FirmwareProgressModal.tsx Adds firmware update progress modal wiring to client events.
wrappers/rest-api/tools/react-viewer/src/components/DepthLegend.tsx Adds interactive depth legend widget.
wrappers/rest-api/tools/react-viewer/src/components/ChatBot/index.ts Adds ChatBot barrel exports.
wrappers/rest-api/tools/react-viewer/src/components/ChatBot/SettingsPreview.tsx Adds settings proposal preview/apply UI.
wrappers/rest-api/tools/react-viewer/src/components/ChatBot/CodeExport.tsx Adds code snippet export UI (Python/C++).
wrappers/rest-api/tools/react-viewer/src/components/ChatBot/ChatPanel.tsx Adds chat panel UI + input + message list.
wrappers/rest-api/tools/react-viewer/src/components/ChatBot/ChatMessage.tsx Adds message bubble rendering + inline formatting + code export.
wrappers/rest-api/tools/react-viewer/src/components/ChatBot/ChatButton.tsx Adds floating chat toggle + availability handling.
wrappers/rest-api/tools/react-viewer/src/components/ApiDiagnostics.tsx Adds desktop-only backend diagnostics panel via Tauri invoke.
wrappers/rest-api/tools/react-viewer/src/api/webrtc.ts Adds WebRTC handler logic for viewer streams.
wrappers/rest-api/tools/react-viewer/src/api/types.ts Adds frontend TypeScript types for API + UI state.
wrappers/rest-api/tools/react-viewer/src/api/socket.ts Adds Socket.IO client wrapper for metadata updates.
wrappers/rest-api/tools/react-viewer/src/api/index.ts Adds API barrel exports.
wrappers/rest-api/tools/react-viewer/src/api/chat.ts Adds client-side LLM chat API integration (Groq/OpenAI/custom).
wrappers/rest-api/tools/react-viewer/src/App.tsx Adds overall app layout + Socket connect + overlays + chat.
wrappers/rest-api/tools/react-viewer/src-tauri/resources/.gitkeep Adds placeholder for bundled backend resources.
wrappers/rest-api/tools/react-viewer/src-tauri/icons/icon.png Adds Tauri icon asset.
wrappers/rest-api/tools/react-viewer/src-tauri/icons/icon.icns Adds macOS icon asset.
wrappers/rest-api/tools/react-viewer/src-tauri/icons/512x512.png Adds icon size asset.
wrappers/rest-api/tools/react-viewer/src-tauri/icons/32x32.png Adds icon size asset.
wrappers/rest-api/tools/react-viewer/src-tauri/icons/256x256.png Adds icon size asset.
wrappers/rest-api/tools/react-viewer/src-tauri/icons/128x128.png Adds icon size asset.
wrappers/rest-api/tools/react-viewer/src-tauri/build.rs Adds Tauri build script.
wrappers/rest-api/tools/react-viewer/src-tauri/Cargo.toml Adds Tauri Rust crate manifest.
wrappers/rest-api/tools/react-viewer/src-tauri/.cargo/config.toml Customizes Cargo target dir for repo build output.
wrappers/rest-api/tools/react-viewer/scripts/bundle-for-prod.js Adds script to copy Vite dist into FastAPI static folder.
wrappers/rest-api/tools/react-viewer/public/realsense.svg Adds SVG asset.
wrappers/rest-api/tools/react-viewer/public/favicon.png Adds favicon asset.
wrappers/rest-api/tools/react-viewer/postcss.config.js Adds PostCSS plugins config for Tailwind.
wrappers/rest-api/tools/react-viewer/playwright.config.ts Adds Playwright configuration (mock/real device modes).
wrappers/rest-api/tools/react-viewer/index.html Adds Vite HTML entrypoint.
wrappers/rest-api/tools/react-viewer/diagnose-backend.ps1 Adds Windows backend diagnostic script.
wrappers/rest-api/tools/react-viewer/build-all.ps1 Adds Windows build pipeline script (backend + UI + Tauri).
wrappers/rest-api/tools/react-viewer/README.md Adds top-level viewer documentation + scripts overview.
wrappers/rest-api/tools/react-viewer/QUICK_START.md Adds Windows-oriented build/install quick start instructions.
wrappers/rest-api/tools/react-viewer/LICENSE-THIRD-PARTY.md Adds third-party license summary for packaged app.
wrappers/rest-api/tools/react-viewer/DESKTOP_BUILD.md Adds Tauri architecture/build documentation.
wrappers/rest-api/tools/react-viewer/.gitignore Adds tool-local ignore rules.
wrappers/rest-api/tools/react-viewer/.eslintrc.cjs Adds ESLint configuration.
wrappers/rest-api/tools/react-viewer/.env.example Adds example environment variables for chat providers.
wrappers/rest-api/realsense_api.spec Adds PyInstaller spec for building backend executable.
wrappers/rest-api/main.py Updates backend startup behavior (event loop capture, PyInstaller mode, reload).
wrappers/rest-api/config.py Changes API base prefix to /api/v1.
wrappers/rest-api/app/services/webrtc_manager.py Improves frame normalization/conversion + error logging in WebRTC track.
wrappers/rest-api/app/models/stream.py Extends stream models (reuse_cache, stopping, timing response model).
wrappers/rest-api/app/models/sensor_streaming.py Adds models for per-sensor streaming control.
wrappers/rest-api/app/models/option.py Extends option info (category/filter/value descriptions).
wrappers/rest-api/app/models/device.py Extends device models with firmware-related fields.
wrappers/rest-api/app/api/router.py Adds health endpoint + firmware + per-sensor streaming routing.
wrappers/rest-api/app/api/endpoints/streams.py Returns timing info on start + adds depth helpers endpoints.
wrappers/rest-api/app/api/endpoints/sensor_streaming.py Adds per-sensor + batch streaming endpoints.
wrappers/rest-api/app/api/endpoints/options.py Preserves RealSenseError status codes + upgrades unexpected errors to 500.
wrappers/rest-api/app/api/endpoints/firmware.py Adds firmware status/update endpoints (threadpool for blocking update).
wrappers/rest-api/app/api/endpoints/devices.py Adds force_refresh and a refresh endpoint.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread wrappers/rest-api/tools/react-viewer/tests/utils/test-utils.tsx
Comment thread wrappers/rest-api/tools/react-viewer/tests/utils/test-utils.tsx
Comment thread wrappers/rest-api/main.py Outdated
Comment thread wrappers/rest-api/tools/react-viewer/README.md Outdated
Comment thread wrappers/rest-api/tools/react-viewer/tests/INSTALLATION.md
Comment thread wrappers/rest-api/tools/react-viewer/src/components/Toast.tsx
Comment thread wrappers/rest-api/tools/react-viewer/vitest.config.ts
Comment thread wrappers/rest-api/tools/react-viewer/tests/utils/test-utils.tsx Outdated
@remibettan

Copy link
Copy Markdown
Contributor Author

Response to Automated Review Comments

Addressing all Aikido and Copilot bot findings from this PR. Below is the status of each category.


✅ Security Fixes (implemented)

SSRF — rs_manager.py _download_firmware

Added a strict regex guard re.match(r'^\d+\.\d+\.\d+\.\d+$', version) before URL construction. Any version string that does not match the X.Y.Z.W dotted-numeric format is rejected with a logged error and return False. The path that derives version from device.get_info() was not protected by the existing header-file regex, so this closes the gap.

Weak hash (SHA-1 → SHA-256) — rs_manager.py

Replaced hashlib.sha1() with hashlib.sha256() in the firmware download integrity check.

print() in production — rs_manager.py

All three print() calls replaced with logging.debug().


✅ Correctness / Reliability Fixes (implemented)

Timer leak in FirmwareProgressModal.tsx

Added useRef to track the 2-second auto-close setTimeout. The ref is cleared in the useEffect cleanup function, preventing the callback from firing on an unmounted component.

alert() calls in DevicePanel.tsx

Both alert(...) calls (calibration placeholders) replaced with onShowToast('info', '...') using the existing toast system. onShowToast prop added to DeviceCardProps.

StreamStartTiming duplicate fields — models/stream.py

StreamStartTiming now inherits from StreamStatus via class StreamStartTiming(StreamStatus) instead of BaseModel, eliminating six duplicated field declarations.

console.log in production — socket.ts

connect, disconnect, and welcome console logs wrapped with if (import.meta.env.DEV) so they are stripped from production builds.

Missing aria-label on close button — Toast.tsx

Added aria-label="Close" to the × button for screen reader compatibility.


✅ Code Quality Refactors (implemented)

sensor_streaming.py — shared exception handler

Extracted _handle_rs_exception(e, default_status=400) helper. All 6 endpoint except blocks replaced with a single call. get_sensor_status and get_batch_status pass default_status=404.

rs_manager.py_collect_sensor_frames length

Extracted _process_sensor_frame(frame, frame_stream_name, device_id, colorizer) method that returns (processed_frame, metadata). The 50-line dispatch block in _collect_sensor_frames is now a single call.

IMUViewer.tsx — duplicated chart JSX

Extracted IMUChart({ data, title, titleColor }) component. The two identical LineChart blocks (accel / gyro) are replaced with <IMUChart data={accelData} title="Accelerometer History" titleColor="text-orange-400" /> and the gyro equivalent.

store/index.ts fetchSensors — inline logic

Extracted buildStreamConfigs(sensors) and buildSensorConfigs(sensors) as module-level helper functions. fetchSensors body reduced from ~100 lines to ~15 lines of setup + two helper calls.

DevicePanel.tsx — component decomposition

Extracted:

  • FirmwareBanner — owns all firmware-update-notification state (dismiss logic, localStorage, update/missing banners, progress line). Props: device, firmware, isStreaming, onUpdateFirmware.
  • SensorStreamControls — renders per-sensor streaming controls (start/stop buttons, resolution/FPS selectors, stream checkboxes). Props: sensors, streamsBySensor, streamingMode, sensorStreamingStatus, sensorConfigs, and the four update/start/stop callbacks.

⚠️ Deferred — Cargo CVEs (src-tauri/)

The cargo audit findings (6 high, 3 medium, 2 low) require a Rust toolchain and are tracked separately. Most are in indirect deps (instant, time, atty, etc.) that require bumping tauri 1.x itself — those will be addressed in a dedicated Tauri upgrade PR to avoid scope creep here.


Not Actionable (false positives)

Finding Reason
Path traversal in bundle-for-prod.js __dirname + static string array — no user input reaches path.join
Command injection in main.rs Tauri sidecar with hardcoded args array — no shell interpolation
reload_enabled flag inversion Fixed in a prior commit (simplified to not is_bundled)

@remibettan remibettan force-pushed the feature/react-viewer branch from 8d24b45 to 160ad90 Compare April 27, 2026 08:38
Comment thread wrappers/rest-api/tools/react-viewer/src/api/webrtc.ts
Comment thread wrappers/rest-api/tools/react-viewer/src-tauri/src/main.rs
Comment thread wrappers/rest-api/tools/react-viewer/src-tauri/src/main.rs
Comment thread wrappers/rest-api/app/api/endpoints/sensor_streaming.py
Comment thread wrappers/rest-api/tools/react-viewer/src-tauri/src/main.rs
Comment thread wrappers/rest-api/tools/react-viewer/src/api/client.ts Outdated
Comment thread wrappers/rest-api/tools/react-viewer/src/store/index.ts
@remibettan remibettan force-pushed the feature/react-viewer branch from db39076 to 53ba625 Compare May 10, 2026 10:53
Comment thread wrappers/rest-api/tools/react-viewer/src-tauri/src/main.rs
Comment thread wrappers/rest-api/tools/react-viewer/src-tauri/src/main.rs
Comment thread wrappers/rest-api/tools/react-viewer/src-tauri/src/main.rs
Comment thread wrappers/rest-api/tools/react-viewer/src/utils/chatPrompt.ts
Comment thread wrappers/rest-api/tools/react-viewer/src/api/chat.ts
Comment thread wrappers/rest-api/app/models/device.py
Comment thread wrappers/rest-api/tools/react-viewer/src/store/index.ts
Comment thread wrappers/rest-api/tools/react-viewer/src/components/DepthLegend.tsx
Comment thread wrappers/rest-api/tools/react-viewer/src/components/Header.tsx
Comment thread wrappers/rest-api/app/api/endpoints/devices.py Outdated
export const APP_VERSION = '0.5.0'

// What's New content for each version
const WHATS_NEW: Record<string, { title: string; features: string[] }> = {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's either drop or use the SDK version with a first time welcome message
Let's try to get to a generic text that we don't need to maintaine

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done- designed to be similar at the popup in realsense-viewer when running new SDK version

@@ -0,0 +1,248 @@
# RealSense React Viewer

A modern React-based web UI for Intel RealSense cameras, leveraging the REST API backend.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Drop Intel

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread wrappers/rest-api/tools/react-viewer/src/components/Header.tsx Outdated
{/* Footer */}
<div className="px-6 py-4 bg-gray-800/50 flex justify-between items-center">
<a
href="https://github.com/IntelRealSense/librealsense"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

IntelRealsense --> realsenseai

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

@Nir-Az

Nir-Az commented May 10, 2026

Copy link
Copy Markdown
Collaborator

@remibettan how do we update FW from file?

@Nir-Az Nir-Az left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@Nir-Az Nir-Az self-requested a review May 11, 2026 08:20
@Nir-Az

Nir-Az commented May 11, 2026

Copy link
Copy Markdown
Collaborator

Lets verify the added files license and add to notice.md

@remibettan

Copy link
Copy Markdown
Contributor Author

Lets verify the added files license and add to notice.md

Done - file wrappers/rest-api/tools/react-viewer/LICENSE-THIRD-PARTY.md updated
redirection done to this file from file NOTICE.md

@remibettan remibettan merged commit 0bb662e into realsenseai:development May 11, 2026
30 checks passed
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.

4 participants