feat: real-time non-BOOL value display on FBD and LD diagrams#636
Conversation
Show live debug values (INT, REAL, STRING, etc.) in green badges next to variable nodes during debugging, similar to CODESYS. BOOL variables are excluded since they already have dedicated color indicators. - Add shared DebugValueBadge component for both FBD and LD editors - Integrate badge into FBD variable nodes (right/left/below positioning) - Integrate badge into LD variable nodes (right/left positioning) - Poll all variables of the active POU (not just BOOLs) so non-BOOL values are available for display; tab switching naturally updates the polling set Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review infoConfiguration used: Repository UI Review profile: CHILL Plan: Pro Disabled knowledge base sources:
📒 Files selected for processing (1)
WalkthroughAdds DebugValueBadge and BlockOutputDebugBadges UI components, integrates them into FBD and Ladder variable/block renders, and extends workspace-screen debugger polling from BOOL-only to include non-BOOL base-type variables using composite keys for real-time debug values. Changes
Sequence DiagramsequenceDiagram
participant WS as rgba(52,152,219,0.5) workspace-screen
participant Store as rgba(46,204,113,0.5) GlobalStore
participant UI as rgba(155,89,182,0.5) Block/Variable components
participant Badge as rgba(241,196,15,0.5) DebugValueBadge
WS->>WS: Build composite keys for active POU variables (include non-BOOL)
WS->>Store: Poll values for composite keys
Store-->>Store: Update debugVariableValues map
UI->>Store: Read debugger visibility & compositeKey helper
alt Debugger visible & compositeKey exists
UI->>Badge: Instantiate with compositeKey, variableType, position
Badge->>Store: Lookup debugVariableValues[compositeKey]
Store-->>Badge: Return value (if present)
Badge-->>UI: Render positioned badge with value
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/renderer/screens/workspace-screen.tsx`:
- Around line 1392-1408: The FB POU branch incorrectly compares
currentPou.data.name (FB type) to varInfo.pouName (the program where the FB is
instantiated), so FB variables are always skipped; change the FB handling in the
loop to follow the working pattern used elsewhere: obtain the FB instance
context from currentPou (e.g., fbInstanceCtx), match varInfo.pouName against
fbInstanceCtx.programName, and for matching program entries only add variables
whose names start with the FB instance path (the instance prefix), then convert
those to the appropriate composite key (using makeCompositeKeyForCurrentPou or
the same composite-key logic used at lines 1154-1168) before adding to
debugVariableKeys; keep the non-FB branch as-is.
ℹ️ Review info
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (4)
src/renderer/components/_atoms/graphical-editor/debug-value-badge.tsxsrc/renderer/components/_atoms/graphical-editor/fbd/variable.tsxsrc/renderer/components/_atoms/graphical-editor/ladder/variable.tsxsrc/renderer/screens/workspace-screen.tsx
…l base types - Register all base-type function outputs (not just BOOL) so non-BOOL _TMP_ variables like ADD's INT output get polled during debugging - Create shared BlockOutputDebugBadges component used by both FBD and LD block nodes to show real-time values next to output connectors - Skip badge rendering for outputs connected to variable nodes to avoid duplicate badges (LD uses connectedVariables, FBD uses edge analysis) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
♻️ Duplicate comments (1)
src/renderer/screens/workspace-screen.tsx (1)
1432-1448:⚠️ Potential issue | 🟠 MajorFB active-POU polling still filters with the wrong POU identity.
At Line 1436,
varInfo.pouNameis compared tocurrentPou.data.name. For FB tabs,currentPou.data.nameis the FB type, whilevarInfo.pouNameis the hosting program (instance context). This causes FB variables to be skipped, so non-BOOL badges in FB POU context won’t get polled.🐛 Suggested fix
- if (currentPou) { - const activePouName = currentPou.data.name - Array.from(variableInfoMapRef.current.entries()).forEach(([_, varInfos]) => { - for (const varInfo of varInfos) { - if (varInfo.pouName !== activePouName) continue - // For FB POUs, only add variables that match the selected instance context - if (currentPou.type === 'function-block') { - const compositeKey = makeCompositeKeyForCurrentPou(varInfo.variable.name) - if (compositeKey) { - debugVariableKeys.add(compositeKey) - } - } else { - debugVariableKeys.add(`${varInfo.pouName}:${varInfo.variable.name}`) - } - } - }) - } + if (currentPou) { + if (currentPou.type === 'function-block') { + const fbTypeKey = currentPou.data.name.toUpperCase() + const selectedKey = fbSelectedInstance.get(fbTypeKey) + const selectedInstance = (fbDebugInstances.get(fbTypeKey) || []).find((inst) => inst.key === selectedKey) + if (selectedInstance) { + Array.from(variableInfoMapRef.current.entries()).forEach(([_, varInfos]) => { + for (const varInfo of varInfos) { + if (varInfo.pouName !== selectedInstance.programName) continue + if (!varInfo.variable.name.startsWith(`${selectedInstance.fbVariableName}.`)) continue + debugVariableKeys.add(`${varInfo.pouName}:${varInfo.variable.name}`) + } + }) + } + } else { + const activePouName = currentPou.data.name + Array.from(variableInfoMapRef.current.entries()).forEach(([_, varInfos]) => { + for (const varInfo of varInfos) { + if (varInfo.pouName !== activePouName) continue + debugVariableKeys.add(`${varInfo.pouName}:${varInfo.variable.name}`) + } + }) + } + }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/renderer/screens/workspace-screen.tsx` around lines 1432 - 1448, The loop filters out FB variables because it compares varInfo.pouName to currentPou.data.name (which is the FB type) instead of the hosting program/instance identity; change how activePouName is derived: compute activePouName differently when currentPou.type === 'function-block' by using the FB's hosting program/instance identity from currentPou.data (the instance/host field) rather than data.name, and keep the existing branch that calls makeCompositeKeyForCurrentPou(varInfo.variable.name) and adds compositeKey — for non-FB POUs keep comparing varInfo.pouName to currentPou.data.name and adding `${varInfo.pouName}:${varInfo.variable.name}` as before.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@src/renderer/screens/workspace-screen.tsx`:
- Around line 1432-1448: The loop filters out FB variables because it compares
varInfo.pouName to currentPou.data.name (which is the FB type) instead of the
hosting program/instance identity; change how activePouName is derived: compute
activePouName differently when currentPou.type === 'function-block' by using the
FB's hosting program/instance identity from currentPou.data (the instance/host
field) rather than data.name, and keep the existing branch that calls
makeCompositeKeyForCurrentPou(varInfo.variable.name) and adds compositeKey — for
non-FB POUs keep comparing varInfo.pouName to currentPou.data.name and adding
`${varInfo.pouName}:${varInfo.variable.name}` as before.
ℹ️ Review info
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (4)
src/renderer/components/_atoms/graphical-editor/block-output-debug-badges.tsxsrc/renderer/components/_atoms/graphical-editor/fbd/block.tsxsrc/renderer/components/_atoms/graphical-editor/ladder/block.tsxsrc/renderer/screens/workspace-screen.tsx
…line union casts Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…and instance path The non-BOOL polling loop compared varInfo.pouName (the hosting program, e.g. "main") against currentPou.data.name (the FB type name, e.g. "IRRIGATION_CONTROLLER"), so all FB variables were silently skipped. It also passed the already-qualified variable name into makeCompositeKeyForCurrentPou, which would double-prefix the instance path. Fix follows the proven BOOL polling pattern: resolve the selected FB instance context, then filter by programName + instance path prefix. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
Implementation
debug-value-badge.tsx— New shared component used by both FBD and LD editors. Reads fromdebugVariableValuesstore, renders only for non-BOOL types, supportsright/left/belowpositioningvariable.tsx— Badge positioned to the right of input variables, left of output variables, below inout variablesvariable.tsx— Badge positioned to the right of input variables, left of output variablesworkspace-screen.tsx— Polls all variables of the active POU (not just BOOLs), enabling non-BOOL values to be available for display. FB POU instance context is respectedArchitecture notes
DebugValueBadgecomponentTest plan
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Chores