Skip to content

Configurator as Web APP (PWA)#2448

Draft
Scavanger wants to merge 92 commits intoiNavFlight:masterfrom
Scavanger:PWA
Draft

Configurator as Web APP (PWA)#2448
Scavanger wants to merge 92 commits intoiNavFlight:masterfrom
Scavanger:PWA

Conversation

@Scavanger
Copy link
Contributor

@Scavanger Scavanger commented Dec 1, 2025

*** Work in Progess ***

Preview, only partially working now: https://inav-configurator.pages.dev/
Now fully functional (only Bugfixing now) inkl. Demo mode and SITL

Working:

  • In principle, runs on the web (HTML/CSS/assets/...)
  • Flashing via DFU
  • MSP connection via WebSerial
  • Some tabs are working

To do:
- Add more bridge code to replace elctron api calls (Dialgos, load/save file, ...)
- Remove update

-Not- working, :
SITL, inkl Simulator imterface. But needs a local Websocket-to-Socket Proxy, because Applications in the browser are only allowed to comunicate via Websockets.

Things to consider:

  • The CORS policy is causing problems with the firmware flasher. I have now solved this by using a proxy on a Cloudflare worker, which allows the app to download the assets.
    Any other suggestions?
  • Where should all this be hosted later? Just on GitHub pages? => Deploy pipeline?
    Github pages will not work, because SITL webassembly needs a special HTTP-Header, wich is impossible to set here. Cloudflare pages as alternative?

@github-actions
Copy link

github-actions bot commented Dec 1, 2025

Branch Targeting Suggestion

You've targeted the master branch with this PR. Please consider if a version branch might be more appropriate:

  • maintenance-9.x - If your change is backward-compatible and won't create compatibility issues between INAV firmware and Configurator 9.x versions. This will allow your PR to be included in the next 9.x release.

  • maintenance-10.x - If your change introduces compatibility requirements between firmware and configurator that would break 9.x compatibility. This is for PRs which will be included in INAV 10.x

If master is the correct target for this change, no action is needed.


This is an automated suggestion to help route contributions to the appropriate branch.

@sensei-hacker
Copy link
Member

sensei-hacker commented Dec 2, 2025

The CORS policy is causing problems with the firmware flasher. I have now solved this by using a proxy on a Cloudflare worker, which allows the app to download the assets. Any other suggestions?

$ curl -I https://github.com/iNavFlight/inav/releases/download/9.1.0/inav_9.1.0_MATEKF405.hex | grep -i Access
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     9    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  
$ curl -I https://raw.githubusercontent.com/iNavFlight/inav/master/README.md 2>&1 | grep -i Access
*access-control-allow-origin: **

Scavanger#3

@sensei-hacker
Copy link
Member

sensei-hacker commented Dec 2, 2025

TCP would be possible via WebSockets, but somehow it doesn't connect properly with SITL.

I think websockets wrap it in HTTP requests. They aren't raw sockets, as I understand it.

Both Electron and PWA support web sockets, though. So one solution would be something along these lines, roughly:
sensei-hacker/inav_unofficial_targets#42

BUUUUT I have another idea in mind I'm going to try.

@sensei-hacker
Copy link
Member

sensei-hacker commented Dec 3, 2025

@Scavanger I don't know if you've seen my other comments, but ...

I now have SITL mostly running in the browser, compiled with webassembly. It runs in-browser can responds to MSP communication. So no platform-specific SITL needed for Configurator.

…ividual objects

- Updated all tabs to replace the global TABS object with individual tab objects (e.g., loggingTab, magnetometerTab, etc.).
- Changed the way active tabs are set by comparing against the tab object instead of string literals.
- Exported each tab object for better modularity and maintainability.
- Ensured all tab initialization and cleanup functions are correctly referenced to their respective objects.

This should help to optimise the tabs and prevent some of the tabs from loading incorrectly in PWA.
sensei-hacker and others added 23 commits January 5, 2026 21:21
This commit fixes three issues in the JavaScript Programming tab:

1. **Fix silent code dropping for invalid function calls**
   - Previously, code like `inav.override.flightAxis(180);` was silently
     discarded without any error message
   - Now generates clear error: "Cannot call 'X' as a function"
   - Added extractCalleeNameForError() helper to show full call path
   - Location: js/transpiler/transpiler/parser.js

2. **Add comprehensive intermediate object detection**
   - Detects when users try to use objects as if they were properties
   - Catches: assignments, function calls, expressions, comparisons
   - Examples caught:
     * `inav.override.flightAxis.yaw = 180` (missing .angle)
     * `gvar[0] = inav.flight + 1` (flight is an object)
     * `inav.override.vtx(3)` (vtx is object, not function)
   - Provides helpful suggestions showing available properties
   - Locations:
     * js/transpiler/transpiler/property_access_checker.js
     * js/transpiler/transpiler/analyzer.js

3. **Fix missing i18n text in JavaScript Programming tab header**
   - Added i18n.localize() calls in tab initialization
   - Added CSS to fix paragraph spacing (margin-bottom: 10px)
   - Locations:
     * tabs/javascript_programming.js (lines 84, 91)
     * tabs/javascript_programming.html (line 217-219)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Changed addError to addWarning with type 'error' in parser
- Made transpile() fail when parser errors are present
- Prevents silent code dropping from succeeding compilation
This commit completes the transpiler validation improvements by:

1. Enhanced intermediate object detection (property_access_checker.js):
   - Now uses raw API definitions instead of processed structure
   - Simplified logic per user suggestion: just check typeof === 'object'
   - Catches 2-level objects (e.g., inav.override.vtx)
   - Catches 3-level objects (e.g., inav.override.flightAxis.yaw)
   - Catches category-only access (e.g., inav.flight)

2. Improved error messages (analyzer.js):
   - Shows available properties for intermediate objects
   - Differentiates simple vs deeply nested objects
   - Provides actionable suggestions

3. Comprehensive test coverage:
   - test_examples.mjs: All 22 examples still compile (no regressions)
   - test_validation_fixes.mjs: 8/8 validation tests pass

All invalid code now generates helpful error messages instead of:
- Being silently dropped
- Failing later in codegen with cryptic messages
- Passing through to generate invalid logic conditions

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Address Qodo code review feedback: check result.warnings.errors
instead of result.errors for semantic/validation errors.
Set tpa_rate = 80 for airplane presets ("Airplane with a Tail" and
"Airplane without a Tail"). This addresses feedback from PR #11222
that fixed-wing aircraft benefit from higher TPA values.

Multicopter presets retain their existing tpa_rate = 20 setting.
…y key

Prevents generating error suggestions containing 'undefined' when
nested.properties is an empty object.

Addresses qodo-merge-pro bot suggestion on PR iNavFlight#2514.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
The plotElevation() function was commented out in commit 8d5870b
due to ESM module compatibility issues. This fix:
- Adds Chart.js v4.4.1 with full ESM support to package.json
- Imports Chart.js properly as ES module
- Uncomments the plotElevation() function

This restores the terrain elevation profile chart feature for
mission planning safety checks.
The plotElevation() function calls `new Chart()` which expects Chart
to be available in the global scope. While we correctly imported
Chart.js as an ES module, it was only available within the module
scope. This change exposes Chart on the window object so the
elevation plotting function can access it.
The plotElevation() function had Chart.js code only for empty missions
(dummy data). When missions had waypoints, it prepared elevation data
but only had a commented-out Plotly.newPlot() call, so no chart
rendered.

Changes:
- Add Chart.js rendering after elevation data preparation (line 4352+)
- Convert Plotly trace data to Chart.js datasets format
- Display WGS84 terrain elevation (orange, filled area)
- Display mission altitude (blue line with waypoint markers)
- Properly destroy existing chart before creating new one
- Store chart instance globally for cleanup on subsequent calls

Both empty and non-empty mission cases now create Chart.js charts.
Code review identified several issues that needed addressing:

CRITICAL fixes:
- Replace hardcoded test data in empty mission case with proper empty chart
- Add canvas element validation before Chart instantiation
- Remove all unused Plotly code structures (trace objects, layout vars)
- Fix chart title to not depend on removed Plotly code

IMPROVEMENTS:
- Add try-catch error handling for async elevation data fetch
- Add safe array checks for Math.min/max to prevent empty array errors
- Change var to const for immutable values (modern JavaScript)
- Clear chart instance reference (set to null) after destruction
- Add console error messages for debugging

The plotElevation() function is now a clean Chart.js-only implementation
without any Plotly remnants, proper error handling, and validation.
…ctivity

When waypoints are dragged, the elevation chart should update smoothly.
The previous approach of destroying and recreating the chart on every
update was causing the chart to not refresh when waypoints were moved.

Chart.js update() method is designed for this use case:
- Preserves the chart instance
- Updates data and options
- Triggers smooth re-render with animations
- More efficient than destroy/recreate

This fixes the issue where dragging a waypoint didn't update the
elevation profile.
…cted

Previously, plotElevation() was only called if the dragged waypoint
matched selectedMarker. This meant dragging an unselected waypoint
wouldn't update the chart.

Now plotElevation() is called for all waypoint drags:
- If waypoint is selected: updates elevation + runs full async logic
- If waypoint is not selected: updates elevation chart only

This ensures the elevation profile always reflects the current mission
geometry after any waypoint is moved.
Per code review feedback, adds two important improvements:

1. Race condition protection:
   - Track elevation update sequence number
   - Ignore stale data from late-returning API calls
   - Prevents chart showing outdated elevation when waypoints dragged rapidly

2. Disable chart animations during updates:
   - Use chart.update('none') instead of chart.update()
   - Improves performance during drag operations
   - Prevents animation queueing and visual lag

These fixes ensure the chart always shows current data and responds
smoothly even with rapid waypoint dragging or slow network connections.
…indows-binaries

Fix postPackage hook to remove non-native SITL binaries from macOS builds
…validation

Fix transpiler validation and improve error messages
…ic-tpa-defaults

Add TPA rate defaults to fixed-wing presets
…vation-chart-esm

Fix: Re-enable terrain elevation chart with Chart.js ESM support
removed old pre 9.0 values I missed
@Scavanger
Copy link
Contributor Author

Feature complete!
Works inkl. Demo mode, (full*) SITL support and some Goodies:

  • Update dialog
  • Nice message boxes
  • File manager for EEprom files
  • = Network support (Sim interface, TCP Uarts) need a local Websocket-to-Socket proxy.

https://inav-configurator.pages.dev/

@Phil-MC
Copy link

Phil-MC commented Feb 8, 2026 via email

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.

6 participants