-
Notifications
You must be signed in to change notification settings - Fork 370
JavaScript Programming tab: Add true/false indicators to aid debugging #2539
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sensei-hacker
wants to merge
13
commits into
iNavFlight:maintenance-9.x
Choose a base branch
from
sensei-hacker:feature/js-programming-lc-highlighting
base: maintenance-9.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
JavaScript Programming tab: Add true/false indicators to aid debugging #2539
sensei-hacker
wants to merge
13
commits into
iNavFlight:maintenance-9.x
from
sensei-hacker:feature/js-programming-lc-highlighting
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Augment decompiler to track which Logic Conditions map to which lines in generated JavaScript code. This enables real-time highlighting of active conditions in the JavaScript Programming tab. Key features: - 3-pass mapping algorithm handles simple, compound, and nested conditions - Compound conditions (a && b) correctly map all sub-LCs to same line - Activator chains propagate line numbers to child LCs - Hoisted variables and sticky/timer patterns tracked - Returns lcToLineMapping in decompile() result Part of Feature 1: Active LC Highlighting (Phase 1/5)
Implement real-time status polling and gutter decoration updates in the JavaScript Programming tab to show which Logic Conditions are currently active/true. Key features: - Status polling every 100ms using MSPChainer - updateActiveHighlighting() filters true LCs and applies gutter markers - clearActiveHighlighting() when code is dirty (unsaved changes) - Proper cleanup on tab switch/disconnect - isDirty check prevents highlighting stale code Part of Feature 1: Active LC Highlighting (Phase 2/5)
Implement CSS and Monaco editor configuration for green checkmark gutter markers that indicate active/true Logic Conditions. Key changes: - Add .lc-active-true CSS class with SVG green checkmark icon - Add Monaco gutter margin background styling - Enable glyphMargin: true in Monaco editor options - Set up proper cursor and sizing for gutter decorations Part of Feature 1: Active LC Highlighting (Phase 3/5)
Fix 'Cannot read properties of null' error in updateActiveHighlighting() by adding proper null checks for FC.LOGIC_CONDITIONS_STATUS and FC.LOGIC_CONDITIONS before accessing .get(). This prevents errors during tab initialization when FC data is still loading.
The onChange handler was firing after setValue() during load, causing isDirty to be set to true even after we cleared it. This prevented the highlighting from ever appearing because updateActiveHighlighting() returns early when isDirty is true. Fixed by using setTimeout() to clear isDirty after the setValue() change event has been processed.
Previous approach tried to find LCs by parsing the generated code for /* LC X */ comments, but normal if-statements don't have these comments. New approach: - Track LC index and line content during code generation - After adding boilerplate, search for the tracked lines in final code - Map LC index to actual line numbers in final output This ensures all if-statements and their associated LCs get mapped correctly for the active highlighting feature.
Track what's being searched for and what's being found to diagnose why the LC-to-line mapping is empty.
This will help us diagnose why the green checkmarks aren't appearing by logging: - When the function is called - If isDirty is blocking it - What the LC-to-line mapping is - If FC data is available - Which LCs are TRUE - What lines should be highlighted - If decorations are created
FC.LOGIC_CONDITIONS_STATUS.get() requires a condition index parameter and returns a single value. We need getAll() to get the entire status array. This was causing 'FC data is null' errors and preventing any highlighting from appearing.
This completes the active LC highlighting feature with two major improvements: 1. FALSE condition indicators: Gray hollow circles (○) display when conditions evaluate to FALSE, complementing the existing green checkmarks for TRUE conditions. Mixed states (TRUE and FALSE on same line) show green checkmark. 2. Transpiler-side line tracking: LC-to-line mappings are now generated during transpilation, providing immediate visual feedback after "Transpile" or "Save to FC" without requiring "Load from FC" roundtrip. Correctly adjusts for auto-added import statement offset. Technical changes: - Add lineOffset tracking in codegen to account for prepended import lines - Store currentSourceLine context during statement generation - Return lcToLineMapping in transpiler result - Update tab to use transpiler mapping immediately after transpile/save - Change polling interval from 100ms to 500ms to reduce MSP load (2Hz vs 10Hz) - Reorder checks: verify FC data availability before isDirty state - Clean up excessive debug logging for production readiness Testing: - Verified circles appear on correct lines after transpile - Tested TRUE/FALSE/MIXED states display properly - Confirmed decompiler mapping replaces transpiler mapping on load - Reviewed with inav-code-review agent - all critical issues resolved
Contributor
ⓘ Your approaching your monthly quota for Qodo. Upgrade your plan PR Compliance Guide 🔍All compliance sections have been disabled in the configurations. |
Fixes all 6 medium-priority issues identified by qodo-merge bot: 1. Clear stale decorations when loading code from FC 2. Clear mapping/decorations when loading default code 3. Add in-flight guard to prevent overlapping MSP polling requests 4. Remove duplicate intervals before adding new one 5. Improve type safety with Array.isArray() checks for MSP data Code organization improvements: - Extract highlighting logic to new module js/transpiler/lc_highlighting.js - Reduce tab file from 928 to 893 lines (-35 lines) - Create 5 testable, pure functions: categorizeLCsByStatus(), mapLCsToLines(), createMonacoDecorations(), applyDecorations(), clearDecorations() - Better separation of concerns (tab orchestrates, module implements) - Improved code maintainability and testability
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
User description
Summary
Adds visual indicators in the Monaco editor gutter to show which Logic Conditions are currently active and true. Green checkmarks (✓) display for TRUE conditions, gray hollow circles (○) for FALSE conditions, providing real-time feedback during development and debugging.
Changes
Testing
Files Changed
tabs/javascript_programming.js- UI logic for highlighting, polling, state managementtabs/javascript_programming.html- CSS for TRUE/FALSE visual indicatorsjs/transpiler/transpiler/codegen.js- Line tracking during transpilation with offset handlingjs/transpiler/transpiler/index.js- Return lcToLineMapping in transpiler resultPR Type
Enhancement
Description
This description is generated by an AI tool. It may have inaccuracies
Implement real-time active Logic Condition highlighting in Monaco editor
Add 500ms status polling with MSP chainer for responsive LC state updates
Implement line offset correction for auto-added import statements
Add comprehensive LC-to-line mapping algorithm with five-pass resolution
Diagram Walkthrough
File Walkthrough
monaco_loader.js
Enable Monaco gutter margin for LC highlightingjs/transpiler/editor/monaco_loader.js
glyphMargin: truein Monaco editor options to support gutterdecorations
decorations
codegen.js
Track LC-to-line mappings during code generationjs/transpiler/transpiler/codegen.js
lcToLineMappingobject to track LC index to source line mappingscurrentSourceLineandlineOffsetproperties for line trackingduring code generation
lineOffsetfrom Acorn line numbers to match Monaco editorline numbers
pushLogicCommand()when pushing logiccommands
line context
decompiler.js
Implement comprehensive LC-to-line mapping algorithmjs/transpiler/transpiler/decompiler.js
lcToLineMappingand_tempLcLinesproperties to track LC linemappings
lcToLineMappingin decompile result alongside code and warningsfinalizeLcLineMapping()with five-pass algorithm to resolveLC line numbers
resolution
activator relationships, and compound condition operands
&& b)"
index.js
Return LC-to-line mapping from transpilerjs/transpiler/transpiler/index.js
lineOffsetfrom transpiler to codegen for accurate line numberadjustment
lcToLineMappingfrom transpile result alongside commands andwarnings
javascript_programming.js
Add active LC highlighting with status pollingtabs/javascript_programming.js
lcToLineMapping,activeDecorations, andstatusChainerpropertiesfor highlighting state management
intervalmodule for managing polling intervalssetupActiveHighlighting()to create MSP chainer and start500ms polling interval
updateActiveHighlighting()to poll LC status and applyMonaco gutter decorations
clearActiveHighlighting()to remove all active decorationsisDirtyrace condition by usingsetTimeout()to defer flagclearing after
setValue()and conditions
markers
javascript_programming.html
Add CSS styling for LC gutter markerstabs/javascript_programming.html
.lc-active-trueCSS class with green checkmark SVG icon for TRUEconditions
.lc-active-falseCSS class with gray hollow circle SVG icon forFALSE conditions