feat: Track profile modifications with *#26
feat: Track profile modifications with *#26Eclipse-Dominator wants to merge 5 commits intoToRvaLDz:mainfrom
Conversation
427ef2e to
54f7925
Compare
|
Thanks for this! The direction is solid. The 🔴 Blockers1. Type hints use lowercase Several signatures use def _on_save_clicked(self, btn, success_cb: callable[[Profile], None] | None = None, ...)
def _check_unsaved_changes(..., on_save: callable | None = None, ...)
from typing import Callable
success_cb: Callable[[Profile], None] | None = NoneWith 2. self._dirty = False
self._profile_mgr.save(profile) # if this raises...
self._toast(f"Profile '{name}' saved")
if success_cb:
success_cb(profile)If 🟡 Medium3. Stale comment in # Snapshot actual compositor state before applying (for revert)
self._ws_snapshot = self._ipc.get_workspaces()The monitor snapshot was removed (good), but the comment still advertises a full compositor-state snapshot. Worth trimming to "Snapshot workspaces (for revert)". 4. Revert UX regression when not dirty New self._toast("Reverted to last configuration")If a user clicks Apply, doesn't modify anything, then clicks Revert, the
🟢 Minor
Merge strategyAgreed on rebase-merge to preserve the 5 logical commits. Much better for |
f42df4c to
d8f7b15
Compare
When reverting configuration, only restore the monitor.conf file and reload the compositor. Keep current GUI values in the UI instead of restoring from pre-apply snapshots to preserve user edits.
- Add success_cb and cancel_cb parameters to `_on_save_clicked` - Pass callbacks through `_on_save_response` - Call callbacks at appropriate times after save completes - Add `_save_then_switch_saved_profile` that replaces the old `_on_saved_clicked` functionality
- Extract profile loading logic into _load_profile() - Update _select_matching_profile to use _load_profile - Add _save_then_switch_saved_profile using success callback - Update save button and Ctrl+S to use new method
- Add _check_unsaved_changes with callback parameters - Update _on_close_request to use callbacks - Remove old _on_close_dialog_response
- Add _current_modified_profile field - Update _refresh_profile_list to include modified profile when dirty - Update _mark_dirty to create modified profile with * suffix - Add _on_profile_selected to prompt save/discard/cancel using callbacks - Update _load_current_state to reset _current_profile_name
d8f7b15 to
0e804f3
Compare
|
overall diff from last change: https://github.com/ToRvaLDz/monique/compare/54f79259a5d4a402dca6f3714e0aaea634ad1b86..0e804f3a19accb2d76243df6d4cfc46ad13196c3 Hi, thanks for the review, I have made the relevant changes as requested to each of the 5 commits with exception of some of the suggestions in 4th point: For 4,
I updated the toast to Then for the case where nothing happens during apply, clicking on revert should not 'change' anything since that was the state before previously. |
Closes #25
Summary
Refactors profile management in Monique to better track unsaved modifications and improves the dialog system with callback-based flows.
Whenever the user modifies anything, if _dirty is not true, then Monique will now snapshot the current profile environment and named it as "XXX" + "*". e.g. ("Profile A" => "Profile A*") and append it to the relevant location in dropdown and switches to it. This also applies to "(Current)" => "(Current)*". (latest commit)
When the user reverts, the old monitor.conf is reapplied but now the settings will not switch to the current reported one by IPC but keeping whatever the user was working on before. (first commit)
When the user tries to switch to a different profile with unsaved changes, it now prompts the user to save/discard/cancel their current modified profile. Should they save or discard, the temporary snapshot will be discarded.
As this PR contains multiple commits which includes refactors that can be more generalized, I suggest rebasing the commits instead of merging all the commits together if it is approved
Changes and relevant bug fixes
1. fix: Keep modifications instead of overwriting from IPC during revert
pre_apply_monitorstracking2. refactor: Add callbacks to save dialog
success_cbandcancel_cbparameters to_on_save_clicked()_on_save_response()_save_then_switch_saved_profile()that uses success callback (this replaces the old_on_save_clicked()3. refactor: Extract
_load_profilemethod_load_profile(Profile)method4. refactor: Replace close dialog with callback-based unsaved changes check
_check_unsaved_changes(body_text, on_save, on_cancel, on_discard)function5. feat: Track modifications with * profile entry
_on_profile_selected()to handle dirty state with save/discard/cancel prompts using callbacks_load_current_state()to reset profile name when loading current stateOverview of workflow modifed by this PR
Summary of Modified Flows
_on_save_clicked(success_cb, cancel_cb)→_on_save_response()→ calls optional callbacks after save completes or fails_save_then_switch_saved_profile()that uses success_cb to select the saved profile (this imitates the old_on_saved_clickedbehavior and is used to replace GUI save and ctrl+SRefactored general check unsaved change dialog function
Using the above, these 2 additional functions are created one to handle when user closes Monique
and the other to handle when user switches profile when they have unsaved changes
Refactored to reduce code duplication and maintain consistency
Called by:
_select_matching_profile(), this fixes the issue where named profile is not properly loaded on first launch of moniqueswitch_to_selected()in_on_profile_selected()