Skip to content

Fix/307 bug color scheme wahl funktioniert nicht#337

Merged
FBumann merged 6 commits into
mainfrom
fix/307-bug-color-scheme-wahl-funktioniert-nicht
Sep 21, 2025
Merged

Fix/307 bug color scheme wahl funktioniert nicht#337
FBumann merged 6 commits into
mainfrom
fix/307-bug-color-scheme-wahl-funktioniert-nicht

Conversation

@FBumann
Copy link
Copy Markdown
Member

@FBumann FBumann commented Sep 17, 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

    • Added a control that syncs color pickers with the selected color scheme; color pickers are now the single source of truth for node colors.
  • Changes

    • Visualization now derives all node colors strictly from the color pickers; color-scheme selection updates pickers (not visuals).
    • Reset behavior updated to restore scheme, edge color, sizes, and layout; pickers are reset via the sync flow.
  • Bug Fixes

    • Fixed unreliable color-picker updates when a scheme is chosen; reset consistently restores edge color and layout.
  • Documentation

    • Changelog wording, structure, and Unreleased section corrected and clarified.

@FBumann FBumann linked an issue Sep 17, 2025 that may be closed by this pull request
2 tasks
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Sep 17, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Adds a Dash callback to sync five color pickers with a selected color scheme, makes color pickers the single source of truth for node colors (visualization now reads picker values only), adjusts reset control outputs to exclude pickers, and updates CHANGELOG editorial content.

Changes

Cohort / File(s) Summary
Color picker sync & visualization
flixopt/network_app.py
Added update_color_pickers(color_scheme, reset_clicks) to populate Bus/Source/Sink/Storage/Converter pickers from VisualizationConfig.COLOR_PRESETS (fallback DEFAULT_COLORS). Updated update_visualization(...) signature to remove color_scheme and to derive node colors exclusively from picker inputs with defaults as fallbacks.
Reset controls outputs
flixopt/network_app.py
Modified reset callback outputs to exclude direct color-picker outputs; reset now returns color-scheme-dropdown, edge-color-picker, node-size-slider, font-size-slider, and layout-dropdown. Picker values are updated via update_color_pickers when scheme or reset changes.
Docs & docstrings
flixopt/network_app.py
Updated docstrings/comments to describe the new synchronization flow and simplified visualization logic; clarified which callbacks manage picker values.
Changelog edits
CHANGELOG.md
Fixed headings/terminology, normalized Unreleased sections with standard subsections, and added a Fixed entry noting that color pickers now update when a scheme is selected.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor User
    participant SchemeDropdown as Color Scheme Dropdown
    participant ColorPickers as Color Pickers (Bus/Source/Sink/Storage/Converter)
    participant Viz as update_visualization

    rect rgb(240,248,255)
    Note over SchemeDropdown,ColorPickers: Scheme selection updates pickers
    User->>SchemeDropdown: select color scheme
    SchemeDropdown-->>ColorPickers: update_color_pickers(color_scheme, reset_clicks)
    ColorPickers-->>User: pickers show scheme colors
    end

    rect rgb(248,250,240)
    Note over ColorPickers,Viz: Rendering reads pickers only
    User->>Viz: trigger visualization update (edge_color, sizes, layout)
    ColorPickers-->>Viz: bus_color, source_color, sink_color, storage_color, converter_color
    Viz-->>User: render graph with picker-driven colors
    end
Loading
sequenceDiagram
    autonumber
    actor User
    participant ResetBtn as Reset Controls
    participant SchemeDropdown as Color Scheme Dropdown
    participant OtherControls as Edge/Size/Font/Layout
    participant ColorPickers as Color Pickers
    participant updateCP as update_color_pickers

    rect rgb(255,248,240)
    Note over ResetBtn,OtherControls: Reset emits non-picker defaults
    User->>ResetBtn: click reset
    ResetBtn-->>SchemeDropdown: set value to 'Default'
    ResetBtn-->>OtherControls: set edge_color, node_size, font_size, layout
    end

    rect rgb(240,248,255)
    Note over SchemeDropdown,ColorPickers: Scheme change triggers picker sync
    SchemeDropdown-->>updateCP: color_scheme change / reset_clicks
    updateCP-->>ColorPickers: set Bus/Source/Sink/Storage/Converter colors
    ColorPickers-->>User: pickers reflect defaults
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I hopped through palettes, small and bright,
Pickers now guide every node's light.
Schemes whisper, then step aside,
Pickers hold the colors with pride.
A cheerful thump — the graph’s just right! 🐇🎨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The PR description currently contains only the template placeholder text and does not summarize the actual code changes; "Description" remains "Brief description of the changes in this PR.", "Related Issues" is a placeholder, and the Testing section is unchecked and lacks verification steps. Because the repository's template expects a concrete description, issue linkage, and testing information, the current description is incomplete and prevents reviewers from quickly understanding the rationale and verification for the change. This omission is significant given the public API/callback signature changes described in the raw summary. Please replace the placeholder with a concise summary of the changes (mention the new update_color_pickers callback, removal of color_scheme from update_visualization, and reset callback output changes), add the related issue number in "Related Issues" or remove that line if none exists, and update the Testing section with how you verified the fix (manual steps and/or automated tests) and check the corresponding boxes. Also note any reviewer-relevant compatibility impacts (changed callback signatures/exports) so reviewers can focus on those areas.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title clearly references the color-scheme selection bug addressed by the changes and therefore describes the primary intent of the changeset; it signals a bug fix and includes the issue reference "307" in the prefix. The wording mixes German and a branch/issue prefix which may reduce readability for some reviewers. Consider using a concise, consistently formatted English title without branch notation to improve clarity in changelogs and history.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b8db1de and ee74b8c.

📒 Files selected for processing (1)
  • CHANGELOG.md (2 hunks)

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

@FBumann FBumann requested a review from PStange September 17, 2025 13:59
Copy link
Copy Markdown
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: 0

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

538-560: Good addition: picker–scheme sync is clear and non-cyclic.

Callback wiring looks correct and avoids feedback loops. Consider optionally syncing the edge color with the selected scheme as well (even if all schemes use the same gray), so “scheme” fully captures graph styling and “reset” isn’t the only way edges change.

Apply this localized change to include the edge picker in the same callback:

 @app.callback(
-        [
+        [
             Output('bus-color-picker', 'value'),
             Output('source-color-picker', 'value'),
             Output('sink-color-picker', 'value'),
             Output('storage-color-picker', 'value'),
             Output('converter-color-picker', 'value'),
+            Output('edge-color-picker', 'value'),
         ],
         [Input('color-scheme-dropdown', 'value')],
     )
 def update_color_pickers(color_scheme):
@@
-        return (
+        return (
             {'hex': colors['Bus']},
             {'hex': colors['Source']},
             {'hex': colors['Sink']},
             {'hex': colors['Storage']},
             {'hex': colors['Converter']},
+            {'hex': '#808080'},  # keep edge consistent per scheme
         )

587-601: Harden color extraction against shape drift from DAQ ColorPicker.

If dash_daq ever returns a string (e.g., “#RRGGBB”) instead of a dict, .get('hex') will raise. Add a tiny helper to normalize values.

Apply this diff:

 def update_visualization(
@@
-    """Update visualization based on current color picker values"""
+    """Update visualization based on current color picker values"""
+    def _hex(val, default):
+        if not val:
+            return default
+        if isinstance(val, str):
+            return val
+        return val.get('hex', default)
@@
-    default_colors = VisualizationConfig.DEFAULT_COLORS
-    colors = {
-        'Bus': bus_color.get('hex') if bus_color else default_colors['Bus'],
-        'Source': source_color.get('hex') if source_color else default_colors['Source'],
-        'Sink': sink_color.get('hex') if sink_color else default_colors['Sink'],
-        'Storage': storage_color.get('hex') if storage_color else default_colors['Storage'],
-        'Converter': converter_color.get('hex') if converter_color else default_colors['Converter'],
-        'Other': default_colors['Other'],
-    }
+    default_colors = VisualizationConfig.DEFAULT_COLORS
+    colors = {
+        'Bus': _hex(bus_color, default_colors['Bus']),
+        'Source': _hex(source_color, default_colors['Source']),
+        'Sink': _hex(sink_color, default_colors['Sink']),
+        'Storage': _hex(storage_color, default_colors['Storage']),
+        'Converter': _hex(converter_color, default_colors['Converter']),
+        'Other': default_colors['Other'],
+    }

703-723: Reset UX: make reset atomic by also emitting picker values.

Current reset relies on the scheme change to cascade picker updates; this can cause a brief visual mismatch on slow clients. Emitting picker values directly makes the reset one-shot and deterministic.

Apply this diff:

 @app.callback(
-        [
+        [
             Output('color-scheme-dropdown', 'value'),
             Output('node-size-slider', 'value'),
             Output('font-size-slider', 'value'),
             Output('layout-dropdown', 'value'),
             Output('edge-color-picker', 'value'),
+            Output('bus-color-picker', 'value'),
+            Output('source-color-picker', 'value'),
+            Output('sink-color-picker', 'value'),
+            Output('storage-color-picker', 'value'),
+            Output('converter-color-picker', 'value'),
         ],
         [Input('reset-btn', 'n_clicks')],
     )
 def reset_controls(n_clicks):
@@
-        if n_clicks and n_clicks > 0:
-            return (
-                'Default',  # color scheme (will trigger color picker updates)
-                90,  # node size
-                10,  # font size
-                'klay',  # layout
-                {'hex': '#808080'},  # edge color
-            )
+        if n_clicks and n_clicks > 0:
+            defaults = VisualizationConfig.DEFAULT_COLORS
+            return (
+                'Default',                 # color scheme
+                90,                        # node size
+                10,                        # font size
+                'klay',                    # layout
+                {'hex': '#808080'},        # edge color
+                {'hex': defaults['Bus']},
+                {'hex': defaults['Source']},
+                {'hex': defaults['Sink']},
+                {'hex': defaults['Storage']},
+                {'hex': defaults['Converter']},
+            )

To verify no flicker remains, click “Reset to Defaults” repeatedly and observe that nodes/edges/colors change in a single render tick without intermediate states.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8af7af1 and 18415c1.

📒 Files selected for processing (1)
  • flixopt/network_app.py (3 hunks)

@FBumann
Copy link
Copy Markdown
Member Author

FBumann commented Sep 20, 2025

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Sep 20, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
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: 0

🧹 Nitpick comments (4)
CHANGELOG.md (4)

9-13: Fix typos and tighten wording in the guidance (HTML comment).

Keeps the CI token “Whats Changed” intact while correcting pluralization and tone.

Apply this diff:

- Take Care: The CI will automatically append a "Whats Changed" section to the changelog.
- This contains all Commits, PR's and Contributers.
+ Note: The CI will automatically append a "Whats Changed" section to the changelog.
+ This contains all commits, PRs, and contributors.
@@
- Please remove all not relevant sections before releasing.
+ Please remove all irrelevant sections before releasing.

Please confirm “Whats Changed” is the exact string your CI expects; if yes, keep it as-is.


30-30: Use standard Keep a Changelog header for Unreleased (drop date placeholder).

Unreleased usually has no date.

Apply this diff:

-## [Unreleased] - ????-??-??
+## [Unreleased]

32-37: Trim empty sections before release; consider canonical section order.

Remove empty headings at release time (as your note already says). Optional: order as Added, Changed, Deprecated, Removed, Fixed, Security for consistency with Keep a Changelog.

Also applies to: 41-44


38-39: Make the Fixed entry concise and reference the PR.

Use imperative voice and add the PR number for traceability.

Apply this diff:

-- Fixed bug in the network_app that caused the color schemes to not work. Further, color pickers are now updated when selecting a color scheme.
+- Fix color scheme selection in network_app; color pickers now update when a scheme is selected. (#337)
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a598a0e and 4dcc039.

📒 Files selected for processing (1)
  • CHANGELOG.md (2 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.12)
  • GitHub Check: test (3.13)
  • GitHub Check: test (3.11)
  • GitHub Check: test (3.10)

@FBumann FBumann added the Bugfix PR's related to a Bug Fix label Sep 21, 2025
Copy link
Copy Markdown
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: 0

🧹 Nitpick comments (6)
CHANGELOG.md (6)

30-44: Tighten Unreleased section; avoid empty subsections and align with style.

  • Drop empty subsections before release (Added/Changed/Deprecated/Known issues).
  • Prefer plain "### Development" over italicized for consistency with other headings.

Apply:

-### *Development*
+### Development

39-39: Make the Fixed entry precise and reference the PR for traceability.

Name the module, note all five pickers, and link the PR/author to match prior entries.

Apply:

-- Fix color scheme selection in network_app; color pickers now update when a scheme is selected.
+- Fix color scheme selection in `flixopt/network_app.py`: selecting a scheme now updates all five color pickers (single source of truth). [[#337](https://github.com/flixOpt/flixopt/pull/337) by [@FBumann](https://github.com/FBumann)]

45-49: Resolve wording inconsistency about “no changes or new features.”

You have an “Added” entry below; rephrase to “no user-facing features.”

Apply:

-This update is a maintenance release to improve Code Quality, CI and update the dependencies.
-There are no changes or new features.
+Maintenance release focused on code quality, CI, and dependency updates.
+No user-facing features were added in this version.

54-60: Normalize capitalization and wording in Development bullets.

Use sentence case and consistent verbs.

Apply:

-- ruff format the whole Codebase
-- Added renovate config
-- Added pre-commit
-- lint and format in CI
-- improved CI
-- Updated Dependencies
-- Updated Issue Templates
+- Format the whole codebase with ruff
+- Add Renovate configuration
+- Add pre-commit hooks
+- Lint and format in CI
+- Improve CI
+- Update dependencies
+- Update issue templates

26-26: Style consistency: avoid italics in headings (even inside comments).

Match visible sections’ style for easier copy/paste later.

Apply:

-### *Development*
+### Development

30-44: Optional: add guidance to Unreleased on release hygiene.

Since CI appends “What’s Changed,” add a short reminder to remove any empty sections before tagging.

Would you like me to push a follow-up commit that removes empty Unreleased subsections as part of the release workflow?

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4dcc039 and b8db1de.

📒 Files selected for processing (1)
  • CHANGELOG.md (2 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)

@FBumann FBumann merged commit 64a7528 into main Sep 21, 2025
6 of 7 checks passed
@FBumann FBumann deleted the fix/307-bug-color-scheme-wahl-funktioniert-nicht branch September 21, 2025 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bugfix PR's related to a Bug Fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Color Scheme Wahl funktioniert nicht

1 participant