Skip to content

Fix MinifyUI state desync on cross-model view switch#3196

Merged
jmcouffin merged 9 commits intodevelopfrom
tay0thman-patch-6
Mar 30, 2026
Merged

Fix MinifyUI state desync on cross-model view switch#3196
jmcouffin merged 9 commits intodevelopfrom
tay0thman-patch-6

Conversation

@tay0thman
Copy link
Copy Markdown
Contributor

@tay0thman tay0thman commented Mar 26, 2026

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:

  • Code follows the PEP 8 style guide.
  • Code has been formatted with Black using the command:
    pipenv run black {source_file_or_directory}
  • Changes are tested and verified to work as expected.

Quick_Elevations V2


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

@devloai
Copy link
Copy Markdown
Contributor

devloai bot commented Mar 26, 2026

Unable to trigger custom agent "Code Reviewer". You have run out of credits 😔
Please upgrade your plan or buy additional credits from the subscription page.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 ViewActivated event subscription to re-run update_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.

tay0thman and others added 2 commits March 27, 2026 01:10
…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>
@jmcouffin
Copy link
Copy Markdown
Contributor

Thanks Tay,
Kind of work. switching between 2 projects... you get the tabs to come up again then disappear again.
Not sure this is the right fix.
I'll add reviewer to get second opinion as I cannot deep dive into this one @tay0thman

@jmcouffin jmcouffin added the Enhancement Enhancement request [class->Improved #{number}: {title}] label Mar 29, 2026
@jmcouffin
Copy link
Copy Markdown
Contributor

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,

Copy link
Copy Markdown
Contributor

@sanzoghenzo sanzoghenzo left a comment

Choose a reason for hiding this comment

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

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 😅

@tay0thman
Copy link
Copy Markdown
Contributor Author

Not sure this is the right fix.
I'll add reviewer to get second opinion as I cannot deep dive into this one @tay0thman

@jmcouffin , before deciding. let me explore updating pyrevit-runtime.dll
The nature of this bug being tied to a monolithic nature of wpf.
If i can fix it on a runtime level, we dont need to have an event handler afterall.

give me a couple of days to look at it, since I understand C# I am bad at writing C#.

@tay0thman
Copy link
Copy Markdown
Contributor Author

@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:
318d1a5
14030bf

Tested on Version 2023, 2024 , 2025 and 2026 (I will compile it for 2027 in a week or two)

Revit 2023

Revit2023

Revit 2024

Revit2024

Revit 2025

Revit2025

Revit 2026

Revit2026

@tay0thman tay0thman requested a review from sanzoghenzo March 30, 2026 08:58
@tay0thman tay0thman dismissed sanzoghenzo’s stale review March 30, 2026 08:59

Completely changed direction, The PR now propose architectural change at the runtime level not the script level.

@jmcouffin jmcouffin requested a review from Copilot March 30, 2026 09:27
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 9 changed files in this pull request and generated 6 comments.

@tay0thman
Copy link
Copy Markdown
Contributor Author

tay0thman commented Mar 30, 2026

@jmcouffin I resolved conflict with the latest commits,

@jmcouffin jmcouffin merged commit c72c0f5 into develop Mar 30, 2026
@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 6.1.0.26089+1231-wip

@tay0thman tay0thman deleted the tay0thman-patch-6 branch March 30, 2026 16:33
@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 6.1.0.26090+0549-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 6.1.0.26090+1533-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 6.1.0.26090+1536-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 6.1.0.26090+1540-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 6.1.0.26090+1540-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New work-in-progress (wip) builds are available for 6.1.0.26090+1556-wip

@github-actions
Copy link
Copy Markdown
Contributor

📦 New public release are available for 6.2.0.26090+1754

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

Labels

Enhancement Enhancement request [class->Improved #{number}: {title}]

Projects

None yet

5 participants