Skip to content

fix parser commands to persist configuration#536

Merged
nschimme merged 1 commit into
MUME:masterfrom
nschimme:persist-config-on-parser-commands-12696502202478030067
Jun 4, 2026
Merged

fix parser commands to persist configuration#536
nschimme merged 1 commit into
MUME:masterfrom
nschimme:persist-config-on-parser-commands-12696502202478030067

Conversation

@nschimme

@nschimme nschimme commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

This ensures that changes made by the CLI are persisted immediately since they could be undone if the user canceled the Preferences dialog.

Summary by Sourcery

Ensure configuration changes made via hotkeys, parser commands, and UI actions are written to disk immediately.

Bug Fixes:

  • Persist hotkey add/remove/reset/clear operations immediately to avoid losing changes.
  • Persist numeric and boolean configuration updates issued via parser commands as soon as they are applied.
  • Persist map mode selection changes directly when updated from the main window.
  • Persist group color updates for the current user when changed through group parser commands.
  • Persist parser command prefix changes immediately after they are set.

This ensures that changes made by the CLI are persisted immediately since they
could be undone if the user canceled the Preferences dialog.
@sourcery-ai

sourcery-ai Bot commented Jun 4, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR ensures configuration changes triggered via CLI parser commands, hotkey updates, and certain UI actions are immediately persisted by writing the config after each mutation, preventing loss of changes if the preferences dialog is canceled.

Sequence diagram for immediate config persistence on mutations

sequenceDiagram
    actor User
    participant AbstractParser
    participant HotkeyManager
    participant MainWindow
    participant Config

    alt CLI_config_change
        User ->> AbstractParser: doConfig
        AbstractParser ->> Config: getConfig
        AbstractParser ->> Config: write
    end

    alt Set_command_prefix
        User ->> AbstractParser: setCommandPrefix
        AbstractParser ->> Config: getConfig
        AbstractParser ->> Config: write
    end

    alt Hotkey_update
        User ->> HotkeyManager: setHotkey
        HotkeyManager ->> Config: getConfig
        HotkeyManager ->> Config: write
    end

    alt Hotkey_remove
        User ->> HotkeyManager: removeHotkey
        HotkeyManager ->> Config: getConfig
        HotkeyManager ->> Config: write
    end

    alt Reset_or_clear_hotkeys
        User ->> HotkeyManager: resetToDefaults
        HotkeyManager ->> Config: getConfig
        HotkeyManager ->> Config: write
        User ->> HotkeyManager: clear
        HotkeyManager ->> Config: getConfig
        HotkeyManager ->> Config: write
    end

    alt Change_group_color
        User ->> AbstractParser: parseGroup
        AbstractParser ->> Config: getConfig
        AbstractParser ->> Config: write
    end

    alt Change_map_mode
        User ->> MainWindow: createActions
        MainWindow ->> MainWindow: setConfigMapMode
        MainWindow ->> Config: getConfig
        MainWindow ->> Config: write
    end
Loading

File-Level Changes

Change Details Files
Ensure hotkey configuration changes are immediately persisted after any modification.
  • After setting a hotkey, write the configuration to disk.
  • After removing a hotkey, write the configuration to disk.
  • After resetting hotkeys to defaults, write the configuration to disk.
  • After clearing all hotkeys, write the configuration to disk.
src/client/HotkeyManager.cpp
Persist parser-driven configuration changes right after they are applied.
  • After changing a float configuration value via the parser, immediately write the configuration to disk.
  • After changing a boolean configuration value via the parser, immediately write the configuration to disk.
src/parser/AbstractParser-Config.cpp
Persist UI-triggered configuration changes for map mode selection.
  • After updating the general map mode setting from the main window, write the configuration to disk.
src/mainwindow/mainwindow.cpp
Persist configuration changes when updating group-related settings from parser commands.
  • When updating the group manager color because the current player’s color changed, write the configuration to disk.
src/parser/AbstractParser-Group.cpp
Persist configuration changes when updating the parser command prefix.
  • After setting the parser prefix character, write the configuration to disk.
src/parser/abstractparser.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • Repeated calls to getConfig().write() scattered across different code paths could be consolidated into a helper (e.g., persistConfig() or similar) to reduce duplication and make future changes to persistence behavior easier to manage.
  • For hotkey and parser operations that may be triggered in rapid succession, consider whether immediate synchronous write() on every change could cause performance issues and if a debounced or buffered persistence mechanism would be more appropriate.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Repeated calls to `getConfig().write()` scattered across different code paths could be consolidated into a helper (e.g., `persistConfig()` or similar) to reduce duplication and make future changes to persistence behavior easier to manage.
- For hotkey and parser operations that may be triggered in rapid succession, consider whether immediate synchronous `write()` on every change could cause performance issues and if a debounced or buffered persistence mechanism would be more appropriate.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@codecov

codecov Bot commented Jun 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 44.44444% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 25.69%. Comparing base (21d2fb5) to head (2dcf728).

Files with missing lines Patch % Lines
src/parser/AbstractParser-Config.cpp 0.00% 2 Missing ⚠️
src/mainwindow/mainwindow.cpp 0.00% 1 Missing ⚠️
src/parser/AbstractParser-Group.cpp 0.00% 1 Missing ⚠️
src/parser/abstractparser.cpp 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #536      +/-   ##
==========================================
+ Coverage   25.38%   25.69%   +0.30%     
==========================================
  Files         521      521              
  Lines       43183    43192       +9     
  Branches     4709     4709              
==========================================
+ Hits        10963    11099     +136     
+ Misses      32220    32093     -127     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@nschimme nschimme merged commit 3adf38b into MUME:master Jun 4, 2026
22 checks passed
@nschimme nschimme deleted the persist-config-on-parser-commands-12696502202478030067 branch June 4, 2026 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant