fix #490 (part 2): plugin panels adopt an authored size change instead of keeping a stale saved size forever
MountPlugins registered every plugin window with authoredGeometryRevision hard-coded to 0 (RetailUiRuntime.cs), so RetailWindowLayoutPersistence's MigrateAuthoredGeometry -- gated on "saved revision >= authored revision" -- never migrated a plugin window's saved size: 0 >= 0 forever. MossTank's panel went 856x236 -> 984x271 and every user with a stored layout stayed stuck at 856x236 with no way to see the new default. Two changes: 1. MountPlugins now passes RetailWindowManager.ComputeAuthoredGeometryRevision (added previous commit) as the plugin window's authoredGeometryRevision, derived from the panel's own authored width/height/minw/minh/resizable. 2. MigrateAuthoredGeometry now compares revisions for INEQUALITY (saved.Revision == authored.Revision) instead of ordering (saved.Revision >= authored.Revision). A hash is not an incrementing counter -- two different authored sizes can hash in either order -- so "the authored size changed" has to mean "the value differs", not "the value went up". Built-in windows' hand-picked incrementing literals (chat: authoredGeometryRevision = 1) are unaffected: no existing saved revision is ever equal to a later, different literal either way. Mutation shown to fail first: the two new PluginMarkupPanel_AuthoredSizeChanged_* tests in RetailWindowLayoutPersistenceTests.cs reproduce the exact bug with concrete literals (856x236/400/150/true -> 984x271/... and 200x100/100/80/true -> 220x110/...) chosen so ComputeAuthoredGeometryRevision's OLD hash is >= the NEW hash for each pair -- confirmed via a throwaway probe before writing the assertions, so the pre-fix run fails deterministically rather than by chance of hash ordering. Both failed before this commit (size stayed at the old authored extent) and pass after (PluginMarkupPanel_AuthoredSizeUnchanged_KeepsUserResizedSize, unaffected either way, is a regression-safety companion). Full RetailWindow/Markup/ PluginSidePanel filter: 249 passed (was 246), 0 failed, 0 skipped. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
b2e68c2343
commit
05f22d46ff
3 changed files with 188 additions and 2 deletions
|
|
@ -4767,11 +4767,20 @@ public sealed class RetailUiRuntime : IDisposable
|
|||
// later registration/sidepanel failure then rolls the mounted
|
||||
// subtree back through FailMount instead of leaking it.
|
||||
_bindings.Plugins.CompleteMount(panel, Host.Root, element);
|
||||
// #490 part 2: derive the authored-geometry revision from
|
||||
// the panel's own authored extent instead of a hard-coded 0
|
||||
// — see RetailWindowLayoutPersistence's class doc and
|
||||
// RetailWindowManager.ComputeAuthoredGeometryRevision's own
|
||||
// doc for why a plugin window can't use the built-in
|
||||
// windows' manual-literal scheme.
|
||||
int authoredGeometryRevision = RetailWindowManager.ComputeAuthoredGeometryRevision(
|
||||
element.Width, element.Height, element.MinWidth, element.MinHeight, element.Resizable);
|
||||
RetailWindowHandle handle = Host.WindowManager.Register(
|
||||
panel.WindowName,
|
||||
element,
|
||||
element,
|
||||
visibility);
|
||||
visibility,
|
||||
authoredGeometryRevision: authoredGeometryRevision);
|
||||
_bindings.Plugins.CompleteWindowMount(
|
||||
panel,
|
||||
() => Host.WindowManager.Unregister(panel.WindowName));
|
||||
|
|
|
|||
|
|
@ -9,6 +9,31 @@ namespace AcDream.App.UI;
|
|||
/// per-resolution settings. It deliberately ignores the temporary pre-login
|
||||
/// <c>default</c> character key so startup layout cannot overwrite a real
|
||||
/// character's state.
|
||||
///
|
||||
/// <para>
|
||||
/// <b>Authored-geometry revision (#490 part 2).</b> Every registered window
|
||||
/// carries an <c>authoredGeometryRevision</c> (see
|
||||
/// <see cref="RetailWindowHandle.AuthoredGeometryRevision"/>); a restore
|
||||
/// whose saved revision differs from the handle's current one replaces only
|
||||
/// the saved WIDTH/HEIGHT with the current authored size
|
||||
/// (<see cref="MigrateAuthoredGeometry"/>) — position, visibility, and
|
||||
/// collapsed/maximized state are untouched, and the clamp in
|
||||
/// <see cref="Apply"/> still re-fits the kept position to the live screen.
|
||||
/// Built-in retail-imported windows hand-pick that revision as a small
|
||||
/// incrementing literal at their <c>Register</c> call site (chat windows:
|
||||
/// <c>authoredGeometryRevision = 1</c>) — a deliberate author decision each
|
||||
/// time their authored size changes. Plugin windows have no such call site
|
||||
/// an author remembers to touch, so <c>MountPlugins</c> instead derives the
|
||||
/// revision automatically from the authored geometry tuple itself via
|
||||
/// <see cref="RetailWindowManager.ComputeAuthoredGeometryRevision"/>
|
||||
/// (width, height, min width, min height, resizable): unchanged authored
|
||||
/// geometry hashes to the same revision (a user's own resize survives
|
||||
/// restore), and ANY authored geometry change hashes to a different one
|
||||
/// (the stored size resets to the new default exactly once). Because a hash
|
||||
/// is not an ordered counter, the comparison is for INEQUALITY — see
|
||||
/// <see cref="MigrateAuthoredGeometry"/>'s own doc for why the original
|
||||
/// "newer revision only" read was wrong for this case.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public sealed class RetailWindowLayoutPersistence : IDisposable
|
||||
{
|
||||
|
|
@ -295,11 +320,26 @@ public sealed class RetailWindowLayoutPersistence : IDisposable
|
|||
handle.AuthoredGeometryRevision);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// #490 part 2: compares revisions for INEQUALITY, not ordering. Built-in
|
||||
/// retail-imported windows hand-pick a small incrementing literal
|
||||
/// (0, 1, 2…) that only ever grows, so the original "migrate only if
|
||||
/// saved < authored" read fine for them. Plugin windows instead derive
|
||||
/// their revision from a hash of the authored geometry itself
|
||||
/// (<see cref="RetailWindowManager.ComputeAuthoredGeometryRevision"/>) so
|
||||
/// their author never has to remember to bump a literal — but a hash is
|
||||
/// not a counter, and two different authored sizes can hash in either
|
||||
/// order. "The authored size changed" therefore means "the value
|
||||
/// differs", not "the value went up"; treating it as ordered silently
|
||||
/// dropped every size-decreasing (by hash value, not by pixels) plugin
|
||||
/// update, which is exactly how MossTank's 856x236 -> 984x271 bump got
|
||||
/// stuck at the old size for every user with a stored layout.
|
||||
/// </summary>
|
||||
private static UiWindowLayout MigrateAuthoredGeometry(
|
||||
UiWindowLayout saved,
|
||||
UiWindowLayout authored)
|
||||
{
|
||||
if (saved.AuthoredGeometryRevision >= authored.AuthoredGeometryRevision)
|
||||
if (saved.AuthoredGeometryRevision == authored.AuthoredGeometryRevision)
|
||||
return saved;
|
||||
|
||||
return saved with
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue