feat: viewport-aware debugger polling with ST/IL inline badge support#689
feat: viewport-aware debugger polling with ST/IL inline badge support#689thiagoralves wants to merge 6 commits into
Conversation
Add an ST/IL section to the debugger polling tick that scans the POU source text for variable references and adds them to debugVariableKeys. This follows the same pattern as the LD/FBD sections — only variables that actually appear in the code are polled, not every declared variable. Also polls FB instance sub-variables (e.g., TON0.ET, TON0.Q) when the instance name appears in the source text. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… mixing When multiple ST/IL function blocks are open in tabs, switching between them causes the debugVarPositions memo to run with the new POU name but the old Monaco model (since @monaco-editor/react reuses the component with keepCurrentModel). This resets editorMounted to false on name change so the memo returns null until handleEditorDidMount fires with the correct model. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The previous fix (resetting editorMounted on name change) didn't work
because @monaco-editor/react's onMount only fires once on initial mount,
not on subsequent path/model switches with keepCurrentModel={true}.
New approach:
- Listen to editor.onDidChangeModel to detect when the library switches
models (tab change), then bump a modelVersion counter to trigger the
debugVarPositions memo recomputation.
- Add a URI guard inside the memo that verifies the current model matches
the expected POU path, preventing position scanning against a stale
model during the render before the model switch completes.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
Disabled knowledge base sources:
WalkthroughThis PR enhances debugger variable polling and Monaco editor safety. Changes track model switches in the Monaco editor to prevent race conditions when recomputing debug variable positions, and significantly refactor workspace variable polling to support hierarchical nested variables, function-block instances with context-aware keys, and ST/IL source-based variable detection at arbitrary nesting depths. Changes
Sequence Diagram(s)sequenceDiagram
actor Editor as Editor (User)
participant POU as POU/Source
participant Poller as Variable Polling Logic
participant Debugger as Debugger Backend
participant VarTree as Variable Hierarchy
Editor->>POU: Switch/Edit POU (FB, ST, IL)
POU->>Poller: Trigger polling for variables
Poller->>VarTree: Extract variable path (dot/bracket notation)
VarTree-->>Poller: Hierarchical path + deepest ancestor
Poller->>VarTree: Check ancestor expansion status
alt Ancestor not expanded
VarTree-->>Poller: Expand path
end
Poller->>Poller: Generate composite key (context-aware)
Note over Poller: FB instances, outputs, nested depth
Poller->>Debugger: Poll variable with composite key
Debugger-->>Poller: Variable value + position
Poller->>Editor: Update debug display (inline positions)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
onDidChangeModellistener + URI guard to ensure thedebugVarPositionsmemo always scans the correct Monaco modelKey changes
workspace-screen.tsx:shouldPollNestedVariablefor watched/expanded variable keysmonaco/index.tsx:modelVersionstate +onDidChangeModellistener to detect model switchesdebugVarPositionsmemo to prevent scanning stale models during tab transitionsTest plan
🤖 Generated with Claude Code
Summary by CodeRabbit