Skip to content

Conversation

@FBumann
Copy link
Member

@FBumann FBumann commented Sep 3, 2025

Description

Brief description of the changes in this PR.

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Code refactoring

Related Issues

Closes #(issue number)

Testing

  • I have tested my changes
  • Existing tests still pass

Checklist

  • My code follows the project style
  • I have updated documentation if needed
  • I have added tests for new functionality (if applicable)

Summary by CodeRabbit

  • New Features

    • Enhanced info panel with richer, structured details for nodes and edges, including labels and parameters.
    • Consistent styling and clear sections improve readability.
    • Supports displaying parameters provided as text, key-value data, or other types.
    • Tap interactions remain unchanged; details are now presented more clearly.
  • Refactor

    • Improved modularization of info rendering to enhance maintainability and readability.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 13, 2025

Walkthrough

Renamed the info-panel callback function to display_element_data and introduced two inner helpers (display_node_info, display_edge_info) to render structured HTML for node/edge details. The callback’s trigger behavior for taps is unchanged; rendering now delegates to the helpers for consistent formatting across parameter types.

Changes

Cohort / File(s) Change Summary
Info-panel callback refactor
flixopt/network_app.py
Renamed callback display_element_info(node_data, edge_data)display_element_data(node_data, edge_data); added inner helpers display_node_info and display_edge_info to build structured HTML for node/edge data (labels, parameters, various types). Preserved trigger logic; modularized rendering implementation.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as User
  participant NG as Network Graph
  participant CB as display_element_data()
  participant NI as display_node_info()
  participant EI as display_edge_info()
  participant IP as Info Panel

  U->>NG: Tap node or edge
  NG->>CB: Callback with node_data / edge_data

  alt Node tapped
    CB->>NI: Build node details HTML
    NI-->>CB: Node HTML
    CB-->>IP: Render node info
  else Edge tapped
    CB->>EI: Build edge details HTML
    EI-->>CB: Edge HTML
    CB-->>IP: Render edge info
  else No selection
    CB-->>IP: Placeholder/empty output
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

A hop, a tap—what do I see?
Nodes and edges sipping HTML tea.
New helpers stitch the data tight,
Labels gleam in tidy light.
I twitch my ears, approve the spread—
Modular burrows, neatly led. 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The description section remains the template placeholder without a real summary of what was changed and the Related Issues field still shows a placeholder rather than closing a specific issue, so reviewers lack the context they need. Please fill in the Description with a brief overview of the function renaming and new display helpers, specify the actual issue number in Related Issues, and confirm any manual testing under the Testing section.
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title Check ✅ Passed The title “Improve network data display” succinctly captures the core enhancement of richer node and edge information rendering in the network app, aligning with the main change of refactoring the callback and introducing detailed display helpers.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/network

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@FBumann
Copy link
Member Author

FBumann commented Oct 13, 2025

Not sure what this does atm

@FBumann FBumann added the Not in Focus This seems reasonable, but we are not working on it at the moment. label Oct 13, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
flixopt/network_app.py (1)

736-783: Extract shared parameter rendering logic.

The parameter rendering code (lines 736-783 and 831-878) is nearly identical between display_node_info and display_edge_info, differing only in the accent color. Extract this into a shared helper to reduce duplication and improve maintainability.

Add a new helper function within the callback:

def render_parameters(parameters, accent_color):
    """Render parameters section with consistent formatting"""
    if not parameters:
        return []
    
    components = [
        html.Div([
            html.Strong(
                'Parameters:',
                style={'color': accent_color, 'display': 'block', 'margin-bottom': '5px'}
            )
        ])
    ]
    
    if isinstance(parameters, str):
        lines = parameters.split('\n')
        for line in lines:
            if line.strip():
                components.append(
                    html.Div(
                        line,
                        style={
                            'color': '#BDC3C7',
                            'margin': '3px 0',
                            'font-family': 'monospace',
                            'font-size': '12px',
                            'line-height': '1.3',
                            'white-space': 'pre-wrap',
                            'padding-left': '10px',
                        },
                    )
                )
            else:
                components.append(html.Div(style={'height': '8px'}))
    elif isinstance(parameters, dict):
        for k, v in parameters.items():
            components.append(
                html.Div(
                    f'{k}: {v}',
                    style={
                        'color': '#BDC3C7',
                        'margin': '3px 0',
                        'font-family': 'monospace',
                        'font-size': '12px',
                        'line-height': '1.3',
                        'padding-left': '10px',
                    },
                )
            )
    else:
        components.append(
            html.Div(
                str(parameters),
                style={
                    'color': '#BDC3C7',
                    'font-family': 'monospace',
                    'font-size': '12px',
                    'white-space': 'pre-wrap',
                    'padding-left': '10px',
                },
            )
        )
    
    return components

Then update both helpers to use it:

 def display_node_info(data):
     # ... existing code for header and label ...
     
-    # Add parameters section
-    if parameters:
-        components.append(...)  # old parameter rendering code
+    # Add parameters section
+    components.extend(render_parameters(parameters, '#3498DB'))
     
     return components

 def display_edge_info(data):
     # ... existing code for header and label ...
     
-    # Add parameters section
-    if parameters:
-        components.append(...)  # old parameter rendering code
+    # Add parameters section
+    components.extend(render_parameters(parameters, '#E67E22'))
     
     return components

Also applies to: 831-878

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6d2b56e and f4d3cb1.

📒 Files selected for processing (1)
  • flixopt/network_app.py (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: test (3.10)
  • GitHub Check: test (3.11)
  • GitHub Check: test (3.13)
  • GitHub Check: test (3.12)
🔇 Additional comments (1)
flixopt/network_app.py (1)

690-692: Function rename looks good.

The rename from display_element_info to display_element_data is clear and the signature remains compatible with the callback inputs.

Comment on lines +693 to +785
def display_node_info(data):
"""Display node information"""
node_id = data['id']
label = data.get('label', node_id) # Use label if available
parameters = data.get('parameters', '')

components = [
html.H4(
f'Node: {node_id}',
style={
'color': 'white',
'margin-bottom': '10px',
'margin-top': '5px',
'border-bottom': '1px solid #3498DB',
'padding-bottom': '5px',
},
)
]

# Add label if it's different from the ID
if label and label != node_id:
components.append(
html.Div(
[
html.Strong('Label: ', style={'color': '#3498DB'}),
html.Span(label, style={'color': '#BDC3C7'}),
],
style={'margin': '8px 0', 'line-height': '1.4'},
)
)

# Add parameters section
if parameters:
components.append(
html.Div(
[
html.Strong(
'Parameters:', style={'color': '#3498DB', 'display': 'block', 'margin-bottom': '5px'}
)
]
)
)

if isinstance(parameters, str):
lines = parameters.split('\n')
for line in lines:
if line.strip():
components.append(
html.Div(
line,
style={
'color': '#BDC3C7',
'margin': '3px 0',
'font-family': 'monospace',
'font-size': '12px',
'line-height': '1.3',
'white-space': 'pre-wrap',
'padding-left': '10px',
},
)
)
else:
components.append(html.Div(style={'height': '8px'}))
elif isinstance(parameters, dict):
for k, v in parameters.items():
components.append(
html.Div(
f'{k}: {v}',
style={
'color': '#BDC3C7',
'margin': '3px 0',
'font-family': 'monospace',
'font-size': '12px',
'line-height': '1.3',
'padding-left': '10px',
},
)
)
else:
components.append(
html.Div(
str(parameters),
style={
'color': '#BDC3C7',
'font-family': 'monospace',
'font-size': '12px',
'white-space': 'pre-wrap',
'padding-left': '10px',
},
)
)

return components
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Critical: Helper function defined but never called.

The display_node_info helper is defined but never invoked. The callback at lines 889-899 still uses the old simple rendering logic instead of calling this new helper. This means the structured HTML rendering introduced by this PR is not actually active.

To activate the new helper, replace lines 889-899 with:

         if ctx.triggered[0]['prop_id'] == 'cytoscape.tapNodeData' and node_data:
-            return [
-                html.H5(
-                    f'Node: {node_data.get("label", "Unknown")}', style={'color': 'white', 'margin-bottom': '10px'}
-                ),
-                html.P(f'Type: {node_data.get("element_type", "Unknown")}', style={'color': '#BDC3C7'}),
-                html.Pre(
-                    node_data.get('parameters', 'No parameters'),
-                    style={'color': '#BDC3C7', 'font-size': '11px', 'white-space': 'pre-wrap'},
-                ),
-            ]
+            return display_node_info(node_data)
🤖 Prompt for AI Agents
In flixopt/network_app.py around lines 693-785 the display_node_info(data)
helper is defined but never used; replace the old simple rendering logic in the
callback at lines 889-899 with a call to this helper so the structured HTML is
actually returned—specifically, call display_node_info(data) where the callback
currently creates the simple list/divs, and ensure you wrap or assign its
returned list as the callback output (e.g., set the component children to the
list returned by display_node_info or return
html.Div(children=display_node_info(data))) so the new formatted node info is
rendered.

Comment on lines +787 to +880
def display_edge_info(data):
"""Display edge information"""
source = data.get('source', '')
target = data.get('target', '')
label = data.get('label', '')
parameters = data.get('parameters', '')

components = [
html.H4(
f'Edge: {source}{target}',
style={
'color': 'white',
'margin-bottom': '10px',
'margin-top': '5px',
'border-bottom': '1px solid #E67E22',
'padding-bottom': '5px',
},
)
]

# Add label section (same formatting as nodes)
if label:
components.append(
html.Div(
[
html.Strong('Label: ', style={'color': '#E67E22'}),
html.Span(label, style={'color': '#BDC3C7'}),
],
style={'margin': '8px 0', 'line-height': '1.4'},
)
)

# Add parameters section (same formatting as nodes)
if parameters:
components.append(
html.Div(
[
html.Strong(
'Parameters:', style={'color': '#E67E22', 'display': 'block', 'margin-bottom': '5px'}
)
]
)
)

if isinstance(parameters, str):
lines = parameters.split('\n')
for line in lines:
if line.strip():
components.append(
html.Div(
line,
style={
'color': '#BDC3C7',
'margin': '3px 0',
'font-family': 'monospace',
'font-size': '12px',
'line-height': '1.3',
'white-space': 'pre-wrap',
'padding-left': '10px',
},
)
)
else:
components.append(html.Div(style={'height': '8px'}))
elif isinstance(parameters, dict):
for k, v in parameters.items():
components.append(
html.Div(
f'{k}: {v}',
style={
'color': '#BDC3C7',
'margin': '3px 0',
'font-family': 'monospace',
'font-size': '12px',
'line-height': '1.3',
'padding-left': '10px',
},
)
)
else:
components.append(
html.Div(
str(parameters),
style={
'color': '#BDC3C7',
'font-family': 'monospace',
'font-size': '12px',
'white-space': 'pre-wrap',
'padding-left': '10px',
},
)
)

return components
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Critical: Helper function defined but never called.

Like display_node_info, this helper is defined but never invoked. The callback at lines 900-910 still uses the old simple rendering instead of calling this helper.

To activate the new helper, replace lines 900-910 with:

         elif ctx.triggered[0]['prop_id'] == 'cytoscape.tapEdgeData' and edge_data:
-            return [
-                html.H5(
-                    f'Edge: {edge_data.get("label", "Unknown")}', style={'color': 'white', 'margin-bottom': '10px'}
-                ),
-                html.P(f'{edge_data.get("source", "")} → {edge_data.get("target", "")}', style={'color': '#E67E22'}),
-                html.Pre(
-                    edge_data.get('parameters', 'No parameters'),
-                    style={'color': '#BDC3C7', 'font-size': '11px', 'white-space': 'pre-wrap'},
-                ),
-            ]
+            return display_edge_info(edge_data)
🤖 Prompt for AI Agents
In flixopt/network_app.py around lines 787-880 a new helper function
display_edge_info is defined but never used; update the callback that renders
edge details (currently at lines ~900-910) to call display_edge_info(data)
instead of the old simple rendering so the detailed edge UI is used;
specifically replace the current rendering lines with a call to
display_edge_info(edge_data) (or the existing variable name for the edge's data)
and return its components (or wrap them in the same container the callback
expects) so the helper's output is displayed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Not in Focus This seems reasonable, but we are not working on it at the moment.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants