fix(ui): OP5 review fixes — thumb sync, batched opacity writes, cull register row, tests

Fixes the OP5 (Chat tab) dual-lens review findings against e71e5a96:

- M1 (MUST-FIX): each opacity row's own apply closure now pushes its OWN
  slider's thumb from the post-link truth (bindings.Current*Opacity()),
  mirroring the OP4 binding pattern. Before this, a single-slider drag
  followed by Reset reverted the live value/link but left that slider's
  own thumb stuck at the dragged position.

- S1 (SHOULD-FIX): the Chat tab's two opacity sliders no longer round-trip
  the whole settings.json on every drag MouseMove tick. UiScrollbar gains
  IsDragging + a DragCompleted callback (fires once, at the MouseUp that
  ends an actual thumb drag); the opacity apply closures flush immediately
  when not mid-drag (Reset/Defaults/discrete edits, same as before) and
  defer to DragCompleted otherwise, collapsing dozens of per-tick writes
  into exactly one per drag gesture. Live opacity still applies every tick.

- S2 (SHOULD-FIX): filed register row AP-201 and issue #371 for the
  UiScrollablePanel whole-row-cull-vs-clip divergence the review found
  (predates OP5, made user-visible by OP5's 240-260px filter blocks). Not
  fixed in this round (a renderer-level scissor stack is out of scope
  here) — corrected the OP5 connected-gate script instead so a straddling
  block's disappear-then-reappear-whole is no longer reported as a
  self-sizing regression.

- S3 (SHOULD-FIX): the chatWindowMainFilter round-trip test already
  existed in e71e5a96 (the review missed it scrolling past line 330);
  added the genuinely missing coverage instead — a composed test pinning
  RetailUiRuntime.MountChat's window-0 SettingsStore -> ChatWindowState
  seed (MountChat itself needs live DAT access and isn't unit-testable
  directly).

- N11: ScrollbarLinkage_ModelPointsAtTheChatListBoxScroll now asserts
  through the scoped page-slot lookup (UiElement.FindDescendant) instead
  of the flat layout.FindElement, which passed for the wrong reason given
  the shared scrollbar id 0x10000201 — matches OP6's own scrollbar-linkage
  test pattern.

Also updated ConfigOptionsPageControllerTests' local ChatOptionsPageController
Bindings fake for the new FlushOpacity parameter.

Full Release suite: 13,117 passed / 4 skipped / 0 failed (baseline 13,107/4/0
post-OP6 — 10 tests added, zero skips added, zero failures).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Erik 2026-08-11 07:36:54 +02:00
parent e318e8628d
commit 6d0b0f9285
10 changed files with 501 additions and 20 deletions

View file

@ -155,12 +155,24 @@ public static class ChatOptionsPageController
/// live per-window fade); filters route to the shared <see cref="ChatWindowState"/>
/// CH6 already consumes. The two DAT-extracted defaults are resolved ONCE by the
/// caller (<c>RetailUiRuntime</c>) — <see cref="ChatOptionsDatDefaults"/> — since
/// they never change within a session.</summary>
/// they never change within a session.
/// <para>
/// OP5 review fix S1 (2026-08-11): <see cref="SetDefaultOpacity"/>/
/// <see cref="SetActiveOpacity"/> apply the value LIVE only — they must never
/// perform the settings.json round trip themselves, or a slider drag (dozens of
/// <c>MouseMove</c> ticks) becomes dozens of whole-file load+rewrite cycles on the
/// UI thread. <see cref="FlushOpacity"/> is the separate settle seam this
/// controller calls exactly once per discrete edit (a Reset/Defaults click, or a
/// drag's own <c>MouseUp</c> via <see cref="UiScrollbar.DragCompleted"/>) — never
/// once per tick — matching retail's own dirty-timer batching (structure doc
/// §3.5) for this blob.
/// </para></summary>
public sealed record Bindings(
Func<float> CurrentDefaultOpacity,
Func<float> CurrentActiveOpacity,
Action<float> SetDefaultOpacity,
Action<float> SetActiveOpacity,
Action FlushOpacity,
float DefaultOpacityDatDefault,
float ActiveOpacityDatDefault,
Func<int, ulong> CurrentFilter,
@ -287,6 +299,24 @@ public static class ChatOptionsPageController
/// <c>ChatOpacityLink</c> and re-applies live), then pushes whatever the OTHER
/// value became onto its own row/slider — raising one drags the other, never
/// clamps.
/// <para>
/// OP5 review fix M1 (2026-08-11): each row's own <c>apply</c> closure pushes its
/// OWN slider's thumb from the post-link truth (<c>bindings.Current*Opacity()</c>,
/// not the raw dragged value — the link may have clamped it), mirroring the OP4
/// binding pattern (a sibling widget's own edit pushes its own widget first). Without
/// this, <see cref="FloatOptionRow.RestoreSavedValue"/>/<c>RestoreDefaultValue</c>
/// (Reset/Defaults on ONLY this row) call <c>apply</c> but never
/// <c>refresh</c>, leaving the thumb visually stuck at the pre-revert position.
/// </para>
/// <para>
/// OP5 review fix S1 (2026-08-11): each row's own <c>apply</c> closure flushes the
/// batched settings write (<see cref="Bindings.FlushOpacity"/>) immediately UNLESS
/// its own slider is mid-drag (<see cref="UiScrollbar.IsDragging"/>) — a Reset/
/// Defaults click is never mid-drag, so those keep writing immediately (single
/// discrete edit, same as before); a drag tick IS mid-drag, so the write defers to
/// the matching <see cref="UiScrollbar.DragCompleted"/> callback wired below,
/// collapsing dozens of <c>MouseMove</c>-tick writes into exactly one per gesture.
/// </para>
/// </summary>
private static void BuildOpacitySliders(
UiTemplateListBox listBox,
@ -331,7 +361,9 @@ public static class ChatOptionsPageController
apply: value =>
{
bindings.SetDefaultOpacity(value);
slider1.SetScalarPosition(bindings.CurrentDefaultOpacity()); // M1: own slider first
activeRow!.RefreshFromLink(bindings.CurrentActiveOpacity());
if (!slider1.IsDragging) bindings.FlushOpacity(); // S1: settle now unless mid-drag
},
read: bindings.CurrentDefaultOpacity,
refresh: value => slider1.SetScalarPosition(value));
@ -342,7 +374,9 @@ public static class ChatOptionsPageController
apply: value =>
{
bindings.SetActiveOpacity(value);
slider2.SetScalarPosition(bindings.CurrentActiveOpacity()); // M1: own slider first
defaultRow!.RefreshFromLink(bindings.CurrentDefaultOpacity());
if (!slider2.IsDragging) bindings.FlushOpacity(); // S1: settle now unless mid-drag
},
read: bindings.CurrentActiveOpacity,
refresh: value => slider2.SetScalarPosition(value));
@ -350,6 +384,10 @@ public static class ChatOptionsPageController
slider1.ScalarChanged = value => defaultRow.SetCurrentValue(value);
slider2.ScalarChanged = value => activeRow.SetCurrentValue(value);
// S1: the drag-end seam — flushes whatever the tick loop above deferred.
slider1.DragCompleted = bindings.FlushOpacity;
slider2.DragCompleted = bindings.FlushOpacity;
page.Register(defaultRow);
page.Register(activeRow);
}

View file

@ -701,9 +701,18 @@ public sealed class RetailUiRuntime : IDisposable
/// Campaign OP slice OP5: persists the Chat tab's two opacity-slider values —
/// the "worth tightening to auto-save-on-change" gap
/// <see cref="SaveChatWindowFilters"/>'s own doc flagged before a live options UI
/// existed to edit them. Called from the Chat tab's slider apply closures, so
/// every drag tick is captured (matching the filter blocks' own auto-save-on-
/// change wiring below, not the old "only on /saveautoui" schedule).
/// existed to edit them.
/// <para>
/// OP5 review fix S1 (2026-08-11): this is now the BATCHED settle point, not a
/// per-tick write. <see cref="Layout.ChatOptionsPageController.Bindings.SetDefaultOpacity"/>/
/// <c>SetActiveOpacity</c> below apply the value LIVE only; this method is wired as
/// <c>FlushOpacity</c> and is called by the controller exactly once per discrete
/// edit — a Reset/Defaults click, or a drag's own <c>MouseUp</c> — never once per
/// <c>MouseMove</c> tick. Previously this ran a full <c>settings.json</c> load +
/// rewrite on every drag tick (dozens-to-hundreds of synchronous whole-file round
/// trips on the UI thread for one drag); retail's own structure batches the
/// equivalent blob behind a dirty timer (research doc §3.5).
/// </para>
/// </summary>
private void SaveChatOpacity()
{
@ -2120,16 +2129,11 @@ public sealed class RetailUiRuntime : IDisposable
new Layout.ChatOptionsPageController.Bindings(
CurrentDefaultOpacity: () => WindowOpacity.DefaultOpacity,
CurrentActiveOpacity: () => WindowOpacity.ActiveOpacity,
SetDefaultOpacity: value =>
{
WindowOpacity.SetDefaultOpacity(value);
SaveChatOpacity();
},
SetActiveOpacity: value =>
{
WindowOpacity.SetActiveOpacity(value);
SaveChatOpacity();
},
// S1 fix: live apply ONLY — no disk write per call. The controller
// calls FlushOpacity (below) once per discrete edit, not once per tick.
SetDefaultOpacity: WindowOpacity.SetDefaultOpacity,
SetActiveOpacity: WindowOpacity.SetActiveOpacity,
FlushOpacity: SaveChatOpacity,
DefaultOpacityDatDefault: datDefaultOpacity,
ActiveOpacityDatDefault: datActiveOpacity,
CurrentFilter: windowId => _bindings.Chat.Windows.GetFilter(windowId),

View file

@ -35,6 +35,26 @@ public sealed class UiScrollbar : UiElement
public Action<float>? ScalarChanged { get; set; }
public bool Horizontal { get; set; }
/// <summary>True while a thumb drag is in progress (between a thumb-hit
/// <c>MouseDown</c>/drag-start and the matching <c>MouseUp</c>). OP5 review
/// fix S1, 2026-08-11: lets a consumer distinguish a per-tick drag edit
/// (defer any expensive settle work) from a single discrete edit (settle
/// immediately) without threading extra state through the scalar-value
/// callback.</summary>
public bool IsDragging => _draggingThumb;
/// <summary>
/// Fires once, at the <c>MouseUp</c> that ends a thumb drag — never on a
/// <c>MouseUp</c> that was not preceded by an actual drag (a bare click that
/// only page-scrolled or jumped, or a stray <c>MouseUp</c> with no prior
/// <c>MouseDown</c>). OP5 review fix S1: the drag-end seam neither
/// <see cref="ScalarChanged"/> (fires on every tick) nor <see cref="Model"/>
/// scrolling provided — the Chat tab's opacity sliders use this to flush a
/// batched settings write exactly once per drag gesture instead of once per
/// <c>MouseMove</c>.
/// </summary>
public Action? DragCompleted { get; set; }
/// <summary>
/// Optional fill rendered beneath the scalar thumb. Retail's combat power
/// control is a horizontal scrollbar containing a meter child; the importer
@ -421,9 +441,13 @@ public sealed class UiScrollbar : UiElement
}
case UiEventType.MouseUp:
{
bool wasDragging = _draggingThumb;
_draggingThumb = false;
_pressedButton = EndButton.None;
if (wasDragging) DragCompleted?.Invoke();
return true;
}
}
return false;
@ -474,9 +498,13 @@ public sealed class UiScrollbar : UiElement
}
case UiEventType.MouseUp:
{
bool wasDragging = _draggingThumb;
_draggingThumb = false;
_pressedButton = EndButton.None;
if (wasDragging) DragCompleted?.Invoke();
return true;
}
}
return false;
}
@ -513,9 +541,13 @@ public sealed class UiScrollbar : UiElement
}
case UiEventType.MouseUp:
{
bool wasDragging = _draggingThumb;
_draggingThumb = false;
_pressedButton = EndButton.None;
if (wasDragging) DragCompleted?.Invoke();
return true;
}
}
return false;