Fix MinifyUI state desync on cross-model view switch#3196
Conversation
Refactor MinifyUI script to handle icon updates based on active state.
|
Unable to trigger custom agent "Code Reviewer". You have run out of credits 😔 |
There was a problem hiding this comment.
Pull request overview
Fixes MinifyUI getting out of sync with actual Revit ribbon/tab visibility when switching between views across different open models by re-applying the configured hidden-tab state on view activation.
Changes:
- Initializes the MinifyUI smartbutton icon/state on load based on
MINIFYUIACTIVE, and (if active) re-applies the hidden tabs immediately. - Adds a guarded
ViewActivatedevent subscription to re-runupdate_ui()(plus a deferred re-hide) after view switches. - Cleans up minor module metadata (encoding headers) and a docstring typo.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
extensions/pyRevitTools.extension/pyRevit.tab/Toggles.panel/toggles1.stack/MinifyUI.smartbutton/script.py |
On smartbutton init, syncs icon + (if active) ensures event subscription and re-applies MinifyUI state. |
extensions/pyRevitTools.extension/pyRevit.tab/Toggles.panel/toggles1.stack/MinifyUI.smartbutton/minifyui.py |
Implements guarded ViewActivated subscription and deferred UI update to keep hidden tabs enforced across cross-model view switches. |
...vitTools.extension/pyRevit.tab/Toggles.panel/toggles1.stack/MinifyUI.smartbutton/minifyui.py
Outdated
Show resolved
Hide resolved
...vitTools.extension/pyRevit.tab/Toggles.panel/toggles1.stack/MinifyUI.smartbutton/minifyui.py
Outdated
Show resolved
Hide resolved
...vitTools.extension/pyRevit.tab/Toggles.panel/toggles1.stack/MinifyUI.smartbutton/minifyui.py
Outdated
Show resolved
Hide resolved
…ggles1.stack/MinifyUI.smartbutton/minifyui.py Adding Debug Exception Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ggles1.stack/MinifyUI.smartbutton/minifyui.py Addubg debug message on exception Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Thanks Tay, |
|
I have had 1 crash and a slowdown at some point while testing, I could not assert it was due to the MinifyUI code though, |
sanzoghenzo
left a comment
There was a problem hiding this comment.
Not really the right person, unfortunately I haven't used MinifyUI and I'm not that great at events and dispatchers...
Regardless, I went pedantic as always 😅
...vitTools.extension/pyRevit.tab/Toggles.panel/toggles1.stack/MinifyUI.smartbutton/minifyui.py
Outdated
Show resolved
Hide resolved
...vitTools.extension/pyRevit.tab/Toggles.panel/toggles1.stack/MinifyUI.smartbutton/minifyui.py
Outdated
Show resolved
Hide resolved
...vitTools.extension/pyRevit.tab/Toggles.panel/toggles1.stack/MinifyUI.smartbutton/minifyui.py
Outdated
Show resolved
Hide resolved
@jmcouffin , before deciding. let me explore updating pyrevit-runtime.dll give me a couple of days to look at it, since I understand C# I am bad at writing C#. |
|
@jmcouffin @sanzoghenzo The fix now uses a C# runtime approach that intercepts Revit's internal tab visibility changes at the data model level. When Revit tries to restore a hidden tab during a view switch, the change is caught and overridden synchronously — before the UI ever renders. This eliminates the flash entirely. No timers, no polling, no deferred callbacks. The compiled runtime DLLs for Revit 2021–2026 are included in the commits below: Tested on Version 2023, 2024 , 2025 and 2026 (I will compile it for 2027 in a week or two) Revit 2023 Revit 2024 Revit 2025 Revit 2026 |
Completely changed direction, The PR now propose architectural change at the runtime level not the script level.
...RevitTools.extension/pyRevit.tab/Toggles.panel/toggles1.stack/MinifyUI.smartbutton/script.py
Outdated
Show resolved
Hide resolved
...RevitTools.extension/pyRevit.tab/Toggles.panel/toggles1.stack/MinifyUI.smartbutton/script.py
Outdated
Show resolved
Hide resolved
...RevitTools.extension/pyRevit.tab/Toggles.panel/toggles1.stack/MinifyUI.smartbutton/script.py
Outdated
Show resolved
Hide resolved
...vitTools.extension/pyRevit.tab/Toggles.panel/toggles1.stack/MinifyUI.smartbutton/minifyui.py
Outdated
Show resolved
Hide resolved
...vitTools.extension/pyRevit.tab/Toggles.panel/toggles1.stack/MinifyUI.smartbutton/minifyui.py
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@jmcouffin I resolved conflict with the latest commits, |
|
📦 New work-in-progress (wip) builds are available for 6.1.0.26089+1231-wip |
|
📦 New work-in-progress (wip) builds are available for 6.1.0.26090+0549-wip |
|
📦 New work-in-progress (wip) builds are available for 6.1.0.26090+1533-wip |
|
📦 New work-in-progress (wip) builds are available for 6.1.0.26090+1536-wip |
|
📦 New work-in-progress (wip) builds are available for 6.1.0.26090+1540-wip |
|
📦 New work-in-progress (wip) builds are available for 6.1.0.26090+1540-wip |
|
📦 New work-in-progress (wip) builds are available for 6.1.0.26090+1556-wip |
|
📦 New public release are available for 6.2.0.26090+1754 |




Fix MinifyUI state desync on cross-model view switch
Description
Minify Revit UI desynchronizes from actual ribbon visibility when switching between views in different open models. The button stays active (orange), MINIFYUIACTIVE remains True, but contextual tabs like Steel, Precast, and Massing & Site reappear — because Revit's ribbon manager restores them during view activation with no mechanism to re-enforce the hidden state.
This has been reported four times since 2022 (#1570, #1716, #1744, #3106).
Checklist
Before submitting your pull request, ensure the following requirements are met:
pipenv run black {source_file_or_directory}Related Issues
Closes #3106
Closes #1716
Closes #1570
Related: #1744
Additional Notes
Guard event subscription with a single env var flag (MINIFYUI_SUBSCRIBED) — subscribe once, skip if already subscribed, same pattern as selfinit function detection
Cleared experimental / debugging code