Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
4618245
Add GitHub Action to suggest maintenance branches for PRs targeting m…
sensei-hacker Nov 30, 2025
5209d96
Fix import of HTML in JS Programming tab
Lemontree-Softworks Dec 1, 2025
01cdcbd
search.js: Update fetch to ESM import syntax
sensei-hacker Dec 1, 2025
a536572
search: Add error handling
sensei-hacker Dec 1, 2025
2ab4cae
magnetometer.js error logging
sensei-hacker Dec 1, 2025
ef74611
magnetometer.js error logging
sensei-hacker Dec 1, 2025
1ea34bf
Fix transpiler API definitions to match firmware implementation
sensei-hacker Dec 2, 2025
ef4b1c4
Fix page loading in packed app
Lemontree-Softworks Dec 2, 2025
447769e
Address PR review feedback: update test documentation
sensei-hacker Dec 3, 2025
e3924bd
Merge pull request #2450 from sensei-hacker/transpiler-api-fixes
sensei-hacker Dec 3, 2025
7bb72e0
Merge pull request #2446 from sensei-hacker/search_update_fetch_to_esm
sensei-hacker Dec 3, 2025
689378c
Merge pull request #2447 from sensei-hacker/mag_not_load_win64
sensei-hacker Dec 3, 2025
2ed9320
Remove unused API definition files
sensei-hacker Dec 2, 2025
dca306d
Fix build error: Remove missing override.js import
sensei-hacker Dec 3, 2025
1745979
Merge pull request #2445 from Scavanger/Fix-JS-Programming-Tab
sensei-hacker Dec 3, 2025
2a72ab8
Merge pull request #2451 from sensei-hacker/remove-unused-api-definit…
sensei-hacker Dec 3, 2025
8dfa61a
Fix JavaScript Programming: Clear unused logic conditions on save
sensei-hacker Dec 3, 2025
3c36172
Fix three bugs breaking JavaScript Programming examples
sensei-hacker Dec 3, 2025
5b8bc76
Fix bug: Ensure logic conditions are sent to correct FC slots
sensei-hacker Dec 4, 2025
d983fbd
Fix duplicate condition bug in transpiler >= synthesis
sensei-hacker Dec 4, 2025
47a0fd7
Fix missing override reference and editorWorker import
sensei-hacker Dec 4, 2025
0c7c067
Merge pull request #2452 from sensei-hacker/fix-javascript-clear-unus…
sensei-hacker Dec 4, 2025
7a9bf65
Merge pull request #2455 from sensei-hacker/fix-transpiler-examples-bugs
sensei-hacker Dec 4, 2025
c23ffd1
Merge pull request #2456 from sensei-hacker/fix-transpiler-not-operat…
sensei-hacker Dec 4, 2025
6681f4e
Fix JavaScript Programming tab issues (#2453)
sensei-hacker Dec 6, 2025
f0b47a3
Merge pull request #2460 from sensei-hacker/fix-javascript-programmin…
sensei-hacker Dec 6, 2025
4326ea1
Add flight axis override support to JavaScript Programming
sensei-hacker Dec 6, 2025
0e4fdb3
Merge branch 'maintenance-9.x' into flight-axis-override-implementation
sensei-hacker Dec 6, 2025
eb00d67
ests/test_flight_axis_override.js stray whitespace
sensei-hacker Dec 6, 2025
3909f8e
Remove CHANGELOG_FLIGHT_AXIS.md from PR
sensei-hacker Dec 6, 2025
52e3389
Move internal docs to project directory
sensei-hacker Dec 6, 2025
9dbd346
Merge pull request #2461 from sensei-hacker/flight-axis-override-impl…
sensei-hacker Dec 6, 2025
9bcf765
Update SITL binaries for 9.0.0-RC3
sensei-hacker Dec 7, 2025
c288607
Merge pull request #2464 from sensei-hacker/sitl-update-9.0.0-RC3
sensei-hacker Dec 7, 2025
400fb45
change for ipf trig
xznhj8129 Dec 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/pr-branch-suggestion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: PR Branch Suggestion

on:
pull_request_target:
types: [opened]
branches:
- master

jobs:
suggest-branch:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Suggest maintenance branch
uses: actions/github-script@v7
with:
script: |
const comment = `### 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.*`;

github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
});
15 changes: 15 additions & 0 deletions js/configurator_main.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,21 @@ $(function() {
return;
}

// Check for unsaved changes in current tab before switching
if (GUI.active_tab === 'javascript_programming' &&
TABS.javascript_programming &&
TABS.javascript_programming.isDirty) {
console.log('[Tab Switch] Checking for unsaved changes in JavaScript Programming tab');
const confirmMsg = i18n.getMessage('unsavedChanges') ||
'You have unsaved changes. Leave anyway?';

if (!confirm(confirmMsg)) {
console.log('[Tab Switch] User cancelled tab switch');
return; // Cancel tab switch
}
console.log('[Tab Switch] User confirmed tab switch');
}

GUI.tab_switch_in_progress = true;

GUI.tab_switch_cleanup(function () {
Expand Down
20 changes: 19 additions & 1 deletion js/logicConditionOperators.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,24 @@ const LOGIC_OPERATORS = {
hasOperand: [true, false],
output: "boolean"
},
57: {
name: "Trigonometry: ACos",
operandType: "Maths",
hasOperand: [true, true],
output: "raw"
},
58: {
name: "Trigonometry: ASin",
operandType: "Maths",
hasOperand: [true, true],
output: "raw"
},
Comment on lines +264 to +275
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: Update the hasOperand property for ACOS and ASIN in js/logicConditionOperators.js from [true, true] to [true, false] to correctly reflect that they are single-argument functions. [general, importance: 6]

Suggested change
57: {
name: "Trigonometry: ACos",
operandType: "Maths",
hasOperand: [true, true],
output: "raw"
},
58: {
name: "Trigonometry: ASin",
operandType: "Maths",
hasOperand: [true, true],
output: "raw"
},
57: {
name: "Trigonometry: ACos",
operandType: "Maths",
hasOperand: [true, false],
output: "raw"
},
58: {
name: "Trigonometry: ASin",
operandType: "Maths",
hasOperand: [true, false],
output: "raw"
},

59: {
name: "Trigonometry: ATan2",
operandType: "Maths",
hasOperand: [true, true],
output: "raw"
},
42: {
name: "Set Control Profile",
operandType: "Set Flight Parameter",
Expand Down Expand Up @@ -347,4 +365,4 @@ const LOGIC_OPERATORS = {
},
};

export { LOGIC_OPERATORS };
export { LOGIC_OPERATORS };
19 changes: 18 additions & 1 deletion js/serial_backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,28 @@ var SerialBackend = (function () {
CONFIGURATOR.connection.connect(selected_port, {bitrate: selected_baud}, privateScope.onOpen);
}
} else {
// Check for unsaved changes in JavaScript Programming tab
if (GUI.active_tab === 'javascript_programming' &&
TABS.javascript_programming &&
TABS.javascript_programming.isDirty) {
console.log('[Disconnect] Checking for unsaved changes in JavaScript Programming tab');
const confirmMsg = i18n.getMessage('unsavedChanges') ||
'You have unsaved changes. Leave anyway?';

if (!confirm(confirmMsg)) {
console.log('[Disconnect] User cancelled disconnect due to unsaved changes');
return; // Cancel disconnect
}
console.log('[Disconnect] User confirmed, proceeding with disconnect');
// Clear isDirty flag so tab switch during disconnect doesn't show warning again
TABS.javascript_programming.isDirty = false;
}

if (this.isDemoRunning) {
SITLProcess.stop();
this.isDemoRunning = false;
}

var wasConnected = CONFIGURATOR.connectionValid;

timeout.killAll();
Expand Down
187 changes: 187 additions & 0 deletions js/transpiler/API_BUGS_FOUND.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
# Transpiler API Definition Bugs Found

**Date:** 2025-12-02
**Investigator:** Developer
**Context:** Systematic verification of transpiler API definitions against INAV firmware

---

## Summary

Found **3 critical bugs** in the transpiler API definitions where the configurator did not match the actual firmware implementation.

---

## Bug #1: waypoint.js - CRITICAL - Wrong Type and Fabricated Properties

**File:** `js/transpiler/api/definitions/waypoint.js`

### Issues Found:

1. **Wrong Operand Type**
- **Bug:** Used `type: 5` (GVAR type)
- **Correct:** Should be `type: 7` (WAYPOINTS type)
- **Impact:** Waypoint properties would read global variables instead of waypoint data!

2. **Fabricated Properties - Data Not Exposed by Firmware**
- The following properties were **completely fabricated** and do NOT exist in the firmware's logic condition operand system:
- ❌ `latitude` (claimed value: 2) - **DOES NOT EXIST**
- ❌ `longitude` (claimed value: 3) - **DOES NOT EXIST**
- ❌ `altitude` (claimed value: 4) - **DOES NOT EXIST**
- ❌ `bearing` (claimed value: 6) - **DOES NOT EXIST**
- ❌ `missionReached` (claimed value: 7) - **DOES NOT EXIST**
- ❌ `missionValid` (claimed value: 8) - **DOES NOT EXIST**

3. **Missing Actual Properties**
- The file was missing these REAL properties that ARE exposed:
- Missing: `isWaypointMission` (value: 0)
- Missing: `nextAction` (value: 3)
- Missing: `distanceFromPrevious` (value: 5)
- Missing: ALL user action flags (values: 6-13)

### Root Cause:
- Incorrect source documentation cited: `navigation_pos_estimator.c`
- **Actual source:** `src/main/programming/logic_condition.h` (logicWaypointOperands_e)
- **Actual implementation:** `src/main/programming/logic_condition.c` (lines 575-669)

### Firmware Reality:
Waypoints have lat/lon/alt/bearing **internally**, but these are **NOT exposed** through the logic condition operand system (for security/simplicity).

### Status: ✅ **FIXED**
- Updated waypoint.js with correct type (7) and actual properties (0-13)
- Added proper source documentation
- Added comment explaining why lat/lon/alt/bearing aren't available

---

## Bug #2: codegen.js - RC Channel .value Syntax Not Supported

**File:** `js/transpiler/transpiler/codegen.js` (line 614)

### Issue:
- **Bug:** Regex `/^rc\[(\d+)\]$/` only matched `rc[N]`, not `rc[N].value`
- **Impact:** Users couldn't use `rc[N].value` syntax (explicit form)
- **Note:** rc.js defines `.value` property, but transpiler rejected it

### Status: ✅ **FIXED**
- Updated regex to `/^rc\[(\d+)\](?:\.value)?$/`
- Both `rc[N]` and `rc[N].value` now work as equivalent
- Error message updated to reflect both syntaxes

### Verification:
Created comprehensive test (`test_rc_channels.js`) that confirms:
- ✅ RC reads use operand type 1 (RC_CHANNEL) - Correct!
- ✅ RC writes use operation 38 (RC_CHANNEL_OVERRIDE) - Correct!
- ✅ Both `rc[N]` and `rc[N].value` syntax work

---

## Bug #3: inav_constants.js - Missing Flight Parameters 46-49

**File:** `js/transpiler/transpiler/inav_constants.js`

### Issue:
- **Bug:** FLIGHT_PARAM stops at index 45 (CRSF_RSSI_DBM)
- **Missing:** Firmware has parameters 46-49

### Missing Parameters:
From `inav/src/main/programming/logic_condition.h` (lines 151-154):

```c
LOGIC_CONDITION_OPERAND_FLIGHT_MIN_GROUND_SPEED, // 46 - m/s
LOGIC_CONDITION_OPERAND_FLIGHT_HORIZONTAL_WIND_SPEED, // 47 - cm/s
LOGIC_CONDITION_OPERAND_FLIGHT_WIND_DIRECTION, // 48 - deg
LOGIC_CONDITION_OPERAND_FLIGHT_RELATIVE_WIND_OFFSET, // 49 - deg
```

### Impact:
- Wind-related flight parameters cannot be accessed in transpiler
- flight.js may also be missing these properties

### Status: ⚠️ **NEEDS FIX**
- Requires updating inav_constants.js FLIGHT_PARAM
- Requires updating flight.js with wind properties
- Requires re-running generate-constants.js script

---

## Additional Findings

###rc.js - Type 4 Bug (FALSE ALARM)

**File:** `js/transpiler/api/definitions/rc.js`

**Initial concern:** Uses `type: 4` instead of `type: 1` (RC_CHANNEL)

**Resolution:** ✅ **NO FIX NEEDED**
- codegen.js handles RC channels **directly** and hardcodes correct type
- Line 625 in codegen.js: `return { type: OPERAND_TYPE.RC_CHANNEL, value: index }`
- rc.js definitions are not actually used for operand type mapping
- Test confirms RC channels use correct type 1

---

## Files Modified

1. ✅ `js/transpiler/api/definitions/waypoint.js` - Complete rewrite
2. ✅ `js/transpiler/transpiler/codegen.js` - Regex fix for rc[N].value
3. ✅ `js/transpiler/transpiler/tests/test_rc_channels.js` - New comprehensive test

## Files Still Need Review

4. ⚠️ `js/transpiler/transpiler/inav_constants.js` - Add FLIGHT_PARAM 46-49
5. ⚠️ `js/transpiler/api/definitions/flight.js` - Add wind parameters
6. ⏳ `js/transpiler/api/definitions/gvar.js` - Verify against firmware
7. ⏳ `js/transpiler/api/definitions/pid.js` - Verify against firmware
8. ⏳ `js/transpiler/api/definitions/override.js` - Verify operations

---

## Testing Performed

### RC Channel Test (`test_rc_channels.js`)
- Tests both reading (`rc[N]`, `rc[N].value`) and writing (`rc[N] = value`)
- Verifies correct operand type (1) for reads
- Verifies correct operation (38) for writes
- Tests `low`, `mid`, `high` boolean properties
- ✅ All tests pass (after fixes)

### Waypoint Verification
- Cross-referenced firmware source (`logic_condition.h`, `logic_condition.c`)
- Confirmed actual exposed operands (0-13)
- Documented why lat/lon/alt/bearing are not available

---

## Recommendations

1. **Immediate:** Fix inav_constants.js and flight.js to add wind parameters 46-49
2. **Process:** Re-run `generate-constants.js` script to ensure sync with firmware
3. **Testing:** Add tests for waypoint operations to prevent regression
4. **Documentation:** Update transpiler docs to clarify RC channel syntax options
5. **Audit:** Complete verification of remaining API definition files (gvar, pid, override)

---

## Impact Assessment

### Critical (Bug #1 - waypoint.js):
- **Severity:** HIGH - Complete functional breakage
- **User Impact:** Any code using waypoint.latitude/longitude/bearing would fail or return wrong data
- **Likelihood:** MEDIUM - Users writing waypoint-based logic would encounter this

### Moderate (Bug #2 - rc syntax):
- **Severity:** MEDIUM - Syntax limitation
- **User Impact:** Users forced to use shorthand, couldn't use explicit .value
- **Likelihood:** LOW - Shorthand works, so users might not notice

### Low (Bug #3 - missing wind params):
- **Severity:** LOW - Missing features
- **User Impact:** Wind-related conditions unavailable
- **Likelihood:** LOW - Advanced feature, specific use case

---

**Total Issues:** 3 bugs found, 2 fixed, 1 pending
**New Tests:** 1 comprehensive RC channel test added
**Lines Changed:** ~150 lines across 3 files
Loading