Skip to content

fix(preview): stabilize scrolling and reduce preview resource usage - #1752

Merged
l0gicgate merged 9 commits into
mainfrom
fix/1749-investigate-preview-scroll
Oct 20, 2026
Merged

l0gicgate merged 9 commits into
mainfrom
fix/1749-investigate-preview-scroll

Conversation

@JoeJoeflyn

@JoeJoeflyn JoeJoeflyn commented Oct 18, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Fix scrollbar jumps during thumb drags and touchpad/content scrolling while retaining GTK's native input handling and virtualization. The indicator follows document positions rather than changing pixel-height estimates. Cancel stale momentum when GTK changes either the estimated range or the pixel origin, then synchronize GTK's next input origin. A flick may end early when newly measured rows invalidate its trajectory.

Defer intermediate/prefetched rendered-row construction and qualify Settings tab-label CSS to avoid unrelated preview style invalidation. Keep Source binding eager for thumb seeking. Retain the earlier shared hit-testing, source-memory, and event-driven table improvements. Browser and picker document previews share the component; file/folder-list scrolling is unchanged.

Ignore GTK's integer quantization when detecting pixel-origin corrections so valid native momentum remains active. The owner confirmed that the real-touchpad candidate no longer jumped before the latest main merge; the merged result has not been manually retested. Initial-loading speed and actual battery-life improvements remain unverified.

Visual evidence

N/A. The thumb no longer jumps to stale positions during touchpad momentum. No intentional content-layout change.

How to test

  1. Open the long mixed Markdown fixture from fix(preview): rendered Markdown jumps between two positions while holding the scrollbar #1749. Scroll over content with a touchpad in both directions, pause, and release fast flicks into momentum without grabbing the scrollbar.
  2. Repeat in Source and with a large plain-text file. Momentum may stop when GTK re-anchors newly measured rows, but the indicator must not jump backward during forward input.
  3. Drag/hold the thumb at interior positions and both ends, release outside it, then continue with wheel/keyboard input. Try find, copy, wrapping, view switches, and close/reopen.
  4. Repeat from Open/Save picker previews. Check table sorting, selection/copy, resizing, and live theme colors, plus Settings action-editor tabs.

Expected result: Content and scrollbar follow input direction without stale-momentum jumps; thumb dragging and existing preview actions remain usable.

Related issue

Refs #1749.

Keep the held scrollbar range separate from GTK's changing median row-height estimates, then resynchronize on release without moving the document. Cover rendered and virtual-source input routing and drag lifecycle regressions for #1749.
@JoeJoeflyn

Copy link
Copy Markdown
Collaborator Author

Local validation and handoff

Scope: virtual rendered/source previews, their shared selection/find/keyboard callers, and asynchronous document media. The adapter retains list virtualization and the document's native adjustment for ordinary scrolling. No preferences, UI strings, dependencies, toolkit/runtime patches, or runner logic changed; the mutation runner only gains one named scenario entry. Full local Rust/E2E suites were intentionally omitted for this bounded change; required CI remains authoritative.

Commands/results:

  • ./scripts/quality.sh fmt and ./scripts/quality.sh clippy: passed on final code, using the verified pinned image and Rust 1.98.1.
  • ./scripts/test-headless.py -- ui::virtual_preview:: ui::document_media:: ui::preview::tests::find:: ui::window::tests::keyboard_dispatch::preview_ownership::: 29 passed, covering the initial implementation and affected callers.
  • After the endpoint correction, ./scripts/test-headless.py ui::virtual_preview::: 21 passed, no ignored/skipped GTK cases. This includes frozen-range behavior, reachable endpoints, deferred-release cancellation, unmap/reopen, and widget/model lifetime.
  • STRATA_CONTAINER_ENGINE=podman ./scripts/e2e.sh tests/e2e/scenarios/test_quick_preview.py -k 'document_scrollbar_holds or preview_renders_markdown or markdown_equations or rendered_document_word or preview_find_navigates or sandboxed_office_files or space_opens_and_closes' --junitxml=target/e2e-1749-scoped.xml: 21 passed, 1 failed. The existing equation test showed a preview-unavailable fallback; no cause was established from that run.
  • Exact isolated rerun: STRATA_CONTAINER_ENGINE=podman ./scripts/e2e.sh tests/e2e/scenarios/test_quick_preview.py::test_markdown_equations_preserve_inline_prose_source_and_fallbacks -n 0 --junitxml=target/e2e-1749-equations-rerun.xml: 1 passed unchanged. The full selection was not repeated to recover a green summary.
  • Final regression: STRATA_CONTAINER_ENGINE=podman ./scripts/e2e.sh tests/e2e/scenarios/test_quick_preview.py -k document_scrollbar_holds -n 0 --junitxml=target/e2e-1749-edges.xml: 2 passed on GTK 4.22.5. Assertions check actual document text/character offsets during unchanged-coordinate pointer events, both document ends, and wheel input after an outside-thumb release—not widget geometry or just thumb position. The endpoint assertions failed before the edge correction.
  • STRATA_CONTAINER_ENGINE=podman ./scripts/e2e-mutation-check.sh preview-scrollbar: detected on final code: both baseline cases pass; deliberately removing the held-range guard causes 2 assertion failures, with no setup errors. The script restored the source afterwards.
  • git diff --check, mutation patch applicability, shell syntax, and Python compilation checks passed.

Requested recording: the final rendered-document case also passed while recording the real app on its private Xvfb display. The owner's explicit recording request was followed without using the desktop/session bus. The ignored local file is target/e2e-recordings/issue-1749-fixed.mp4 (H.264, 1200×760, 30 fps, 17.07 seconds); it was decoded successfully with FFmpeg and a frame was reviewed. Neither the recording nor its one-off capture plugin was committed or uploaded as PR evidence.

@JoeJoeflyn

Copy link
Copy Markdown
Collaborator Author

still working on

Keep GTK's visible-row anchor when re-estimated document heights would map thumb movement backwards. Extend the existing drag regressions to cover moving content and releasing the thumb without duplicating scrolling or layout machinery.\n\nRefs #1749
@JoeJoeflyn

JoeJoeflyn commented Oct 18, 2026 •

Copy link
Copy Markdown
Collaborator Author

Follow-up: reproduce movement, not just stationary holds

Pushed 95221e1. The previous version still reapplied an absolute fractional target behind GTK's corrected visible-row anchor during a forward drag. The old stationary-hold test missed this. The existing regression now checks actual visible text order during movement, interior progress, held content, endpoints, outside-thumb release, and subsequent wheel input. Its original-PR baseline fails in both rendered/source cases; all three A/B baseline repetitions fail the same backward-content assertion, with no setup errors.

Architecture/implementation: only 13 additional production lines in the existing adapter, including one per-drag scalar. Preserve GTK's corrected anchor when an estimate would reverse the user's movement. No duplicated scrolling/reveal machinery, buffer copies, caches, timers, preferences, strings, dependencies, or toolkit changes. Larger buffer/reveal/row-sizing experiments were rejected and are not included. Existing unit/E2E coverage owners were extended, not duplicated.

Final local checks — verified pinned Podman, GTK 4.22.5, private displays/buses:

  • STRATA_CONTAINER_ENGINE=podman ./scripts/quality.sh fmt — passed.
  • STRATA_CONTAINER_ENGINE=podman ./scripts/quality.sh clippy — passed.
  • Targeted Rust invocation below — 26 passed, 0 failed/ignored. This includes the existing scrollbar lifecycle/anchor fixture, document selection/copy, asynchronous media, find, and relevant keyboard owners. An intermediate experimental queued-release expectation failed; the original expectation was restored, the exact test reran successfully, and the final affected selection passed.
  • Final pointer regression below — 2 passed. The additional assertion that dragging actually visits interior content also passed on this final run.
  • Affected preview callers below — 20 passed (Markdown/media, equations, selection/copy, source/rendered find, office documents, and preview close/reopen). Only Python GI deprecation warnings were reported; no failing application-warning check.
  • The exact fix(preview): rendered Markdown jumps between two positions while holding the scrollbar #1749 mixed Markdown generator also passed the isolated real-pointer probe, with the rendered view explicitly required: 1 passed, no backward-content samples or release change.
  • git diff --check, scenario syntax, and existing mutation patch applicability — passed. No debug instrumentation is shipped.

Exact scoped commands:

# Ignored local wrapper: same pinned Podman base and quality-container cache;
# private xvfb-run + dbus-run-session, GTK_A11Y=none, NO_AT_BRIDGE=1,
# STRATA_REQUIRE_GTK_TESTS=1; cargo test --locked --all-targets --all-features.
bash target/preview-scroll-profile/rust-scoped.sh -- ui::virtual_preview:: ui::document_media:: ui::preview::tests::find:: ui::window::tests::keyboard_dispatch::preview_ownership::default_editing_keys_reach_a_focused_preview ui::window::tests::keyboard_dispatch::preview_ownership::tenxer_preview_owns_document_keys_until_returned

STRATA_CONTAINER_ENGINE=podman ./scripts/e2e.sh tests/e2e/scenarios/test_quick_preview.py -k document_scrollbar_holds -n 0 -s --junitxml=target/e2e-1749-final-regression.xml

STRATA_CONTAINER_ENGINE=podman ./scripts/e2e.sh tests/e2e/scenarios/test_quick_preview.py -k 'preview_renders_markdown or markdown_equations or rendered_document_word or preview_find_navigates or sandboxed_office_files or space_opens_and_closes' -n 2 --junitxml=target/e2e-1749-directional-callers.xml

# Ignored, one-off diagnostics, not maintained/committed harness additions:
STRATA_CONTAINER_ENGINE=podman ./scripts/e2e.sh 'tests/e2e/scenarios/test_quick_preview.py::test_document_scrollbar_holds_content_still_while_rows_recycle[rendered]' -n 0 -p target.preview_scroll_probe -s --junitxml=target/e2e-1749-mixed-final.xml
python3 target/preview-scroll-profile/run-comparisons.py

Profiling: three alternating before/after runs of the same 100-movement fixture/input sequence, comparing original PR a96569b9 with this change. Same machine, verified image c3eeda033623… (inputs 803375aa…), Rust 1.98.1, unoptimized dev builds with debug/incremental disabled, Cairo/private Xvfb. Stack samples pointed to GTK/Pango text layout; removing backward revisits reduces that work. These are application CPU measurements, not release-build FPS or battery-life measurements.

Preview Median scroll CPU before After
Rendered Markdown 4.40 s 3.06 s (-30.5%)
Virtual source 2.95 s 2.88 s (essentially unchanged within run variation)

All six final A/B candidate cases passed the content-direction/release probe. Idle main-thread CPU stayed at 0–0.01 s per three-second sample, and voluntary context switches were comparable (roughly 60–67 per sample, one candidate sample 52). The existing idle activity is not fixed by this change. No real-hardware battery-life improvement is claimed. Provenance, raw samples, logs, and the one-off drivers remain ignored under target/preview-scroll-profile/; none are committed or uploaded.

Scope/omissions: this is a bounded private preview-adapter change with its affected input/selection/find/media callers covered above. Full local Rust/E2E suites were intentionally omitted; CI remains authoritative and required checks must pass before merge. No validation override was used. The PR remains draft. After this push, GitHub metadata checks passed, but the full quality/lint/test jobs were skipped while draft, not passed. They still need to run and pass before merge.

Ignore hidden prefetched rows during pointer hit testing and reuse GTK item positions for constant-time binding cleanup. Share source display/copy storage and render line-number gutters without retained text layouts.

Replace idle table polling with notified fitting and drag-only autoscroll while preserving shared live-theme updates. Keep GTK virtualization and the existing scrollbar adapter.

Refs #1749
@JoeJoeflyn JoeJoeflyn changed the title fix(preview): stabilize virtual document scrollbar drags fix(preview): stabilize scrolling and reduce preview resource usage Oct 18, 2026
@JoeJoeflyn

Copy link
Copy Markdown
Collaborator Author

Follow-up: ordinary scrolling, source RAM, and idle table work

This follow-up addresses confirmed preview-layer issues, not just thumb dragging. The browser and Open/Save picker use the same PreviewDrawer; file/folder-list scrolling is unchanged. The PR remains draft: the owner's physical-touchpad symptom and remaining initial-loading delay still need retesting.

Architecture / implementation: hidden prefetched rows keep stale allocations, so the shared mapped-row helper excludes them from pointer hit testing. The new smooth-scroll regression checks GTK's actual picked row against the document target, rather than sampling whitespace as though it were text. Removing the mapped-row guards makes this exact regression fail (Some(26) versus GTK's visible Some(29)). Binding/unbinding now uses the existing PDF preview's item-position pattern instead of scanning/upgrading every weak widget reference. Source display borrows a prefix of its copy buffer; line-number gutters use GTK/Pango with only dimension metadata retained, not editor buffers or off-screen shaping layouts. Table fitting is coalesced after allocation only when notified; selection autoscroll exists only during a drag and reuses scrolling::advance. Retained selection colors use the shared theme binding, including live previews, two windows, and rebuilt tables.

No second scroll engine, additional document/pixel/layout cache, new setting/string, dependency/toolkit/runtime patch, build/CI change, or maintained harness change was added. The GtkLabel gutter prototype was rejected because its retained layouts did not consistently improve ordinary multiline memory. Early synchronous table-fitting prototypes were also rejected after manual visual checks; final initial/narrow/restored table views and source gutters at normal/increased/reset text sizes were reviewed on private displays. No capture is committed or uploaded as PR evidence.

Final targeted validation

Scope rationale: bounded virtual-preview and interactive-table behavior, including their selection/copy/find, media, keyboard, theme, and browser/picker callers. No global infrastructure or preference-storage behavior changed. Full local Rust/E2E suites were intentionally omitted; CI remains the authoritative full gate. No owner override was used.

  • Final pinned fmt and clippy: passed.
  • Final Rust selection below: 34 passed, 0 failed/ignored, with GTK required. This includes the new smooth-scroll targeting and live-theme regressions, existing UTF-8/copy/line-boundary, widget/model lifetime, media, find, keyboard ownership, and chooser coverage. The chooser case exercises Open/Save in Columns, Icons, and List.
  • Final canonical E2E selection below: 26 passed. This includes real wheel/pointer routes, the retained thumb regression, source/rendered find/copy, Markdown/media/equations, office documents, preview lifecycle, and CSV/TSV/Markdown/HTML table sorting, selection, and drag autoscroll. Only existing Python GI deprecation warnings were reported by pytest.
  • git diff --check: passed. No debug instrumentation is shipped.
STRATA_CONTAINER_ENGINE=podman ./scripts/quality.sh fmt
STRATA_CONTAINER_ENGINE=podman ./scripts/quality.sh clippy

# Ignored local wrapper: verified pinned Podman base, retained quality-container
# cache, private Xvfb + D-Bus, inherited display/bus cleared, GTK_A11Y=none,
# NO_AT_BRIDGE=1, STRATA_REQUIRE_GTK_TESTS=1; no desktop fallback.
# Runs cargo test --locked --all-targets --all-features with these libtest filters:
bash target/preview-scroll-profile/rust-scoped.sh -- ui::virtual_preview:: ui::table_view:: ui::document_media:: ui::preview::tests::find:: ui::window::tests::keyboard_dispatch::preview_ownership::default_editing_keys_reach_a_focused_preview ui::window::tests::keyboard_dispatch::preview_ownership::tenxer_preview_owns_document_keys_until_returned ui::chooser::tests::filtered_preview::space_toggles_the_selected_search_result_in_open_and_save_choosers

STRATA_CONTAINER_ENGINE=podman ./scripts/e2e.sh tests/e2e/scenarios/test_quick_preview.py -k 'document_scrollbar_holds or preview_renders_markdown or markdown_equations or rendered_document_word or preview_find_navigates or sandboxed_office_files or space_opens_and_closes or large_table_header_sort' -n 2 --junitxml=target/preview-scroll-profile/final-e2e.xml

Resource measurements — qualified results, not release/hardware claims

Same verified image c3eeda033623…, GTK 4.22.5, Rust 1.98.1, Cairo/private Xvfb, unoptimized dev builds with debug and incremental disabled. Baseline is original PR commit a96569b (the later thumb-direction change is not exercised by these ordinary-wheel cases). Baseline binary SHA256: 598f1651b549952ba3016540e063d2312ddcc89899eddb730eff62582d3e2a75; final CPU/idle candidate: dfc1d0f25c18df70f2e963df4f2493e4de3d99bc7be51276eaf6b829c8783e01. RAM repetitions exercised the final source/gutter implementation before the later table-only theme-binding cleanup; that cleanup is not exercised by the source fixtures. The final pathological-source confirmation also used this final binary. Profilers/drivers/raw logs stay ignored under target/preview-scroll-profile/.

RAM: three runs per variant and fixture, each performing three real open/wheel-scroll/close cycles of a 1 MiB source file. Final alternating pairs reported zero swap. Values below are median retained measurements after cycle three (KiB); these are application measurements, not a general leak fix.

Fixture RSS before → after Private dirty before → after
Ordinary multiline source 242,648 → 232,272 82,956 → 72,596
Pathological long source lines 262,184 → 250,476 102,164 → 90,660

That is about 10–11 MiB less RSS and 10–11 MiB less private dirty memory in these fixtures. Incremental private growth above each run's startup baseline fell from 30,420 to 19,940 KiB for ordinary lines, and 49,640 to 38,068 KiB for pathological lines. Retained memory stabilizes across the repeated cycles; this is not a claim that GTK returns all allocated pages on close or that media-runtime/GPU RAM growth is fixed.

Idle activity: three alternating baseline/candidate CSV-table runs, with two seconds settling and a three-second idle sample. Median main-thread voluntary context switches fell 561 → 170 (~70%); all three candidate samples were lower. Median sampled main-thread CPU was 0.05 → 0.03 s, but that tiny timing signal is noisy. No real-hardware battery-life gain is claimed.

Scrolling/loading: the earlier ~9% CPU improvement did not repeat reliably on final code and is withdrawn. In the final three alternating 300-wheel-event runs, mean application scroll CPU was 7.377 → 7.380 s, effectively unchanged; timings varied across runs. Initial-loading speed also did not consistently improve. GTK/Pango layout and mixed-table construction remain significant costs. The actual wheel probes did not reproduce visible backward movement in the baseline, so they are not evidence that every physical-touchpad jump is resolved; the confirmed new correctness regression is stale-row hit testing.

Exact one-off measurement commands (not maintained test/harness additions):

python3 target/preview-scroll-profile/run-touchpad-comparison.py /workspace/target/preview-scroll-profile/pr1752-before final-scroll
python3 target/preview-scroll-profile/repeat-idle-comparisons.py
python3 target/preview-scroll-profile/repeat-memory-comparisons.py
# Each invokes ./scripts/e2e.sh -n 0 with an ignored diagnostic plugin and
# writes its exact configuration, raw samples, log, and JUnit report under target/.

Some exploratory diagnostics were intentionally discarded: a too-early tool timeout interrupted a profiled run; a mixed Markdown source-offset sampler had too few unique text observations to count as a regression verdict. Neither is reported as passing. Maintained final selections above passed after the final changes. Physical touchpad, release-build FPS, real battery life, and the residual initial-loading delay remain unverified/unresolved.

Keep scrollbar presentation in visible document coordinates instead of GTK's changing virtual-row pixel estimates. Preserve native pixel-based scrolling and held-thumb behavior, and cancel stale kinetic trajectories when the estimated range changes.

Extend the smooth-input regression to verify actual thumb progress in both directions, native momentum, and keyboard endpoints. Document the early-end momentum trade-off.

Refs #1749
@JoeJoeflyn

Copy link
Copy Markdown
Collaborator Author

Correcting the missed touchpad-driven scrollbar bug

The owner confirmed that the previous hit-testing/RAM work did not fix the reported scrollbar jump. The earlier tests checked visible text and held-thumb behavior, not ordinary-scroll indicator progress. That was the wrong completion signal.

Reproduced the actual indicator failure: a forward-only content-wheel run showed 96 backward painted-thumb frames out of 724. GTK's frame state—not three separate accessibility property reads—confirmed it. One example moved the indicator from ~66% to ~5% while the visible text continued forward within paragraph 67. A direct GTK controller regression also failed before the fix (0.317443887557202 → 0.31567067927773). Both failures came from mirroring a pixel coordinate system whose estimates change during virtualization.

Implementation: the private DocumentPosition presentation adjustment follows visible model/text coordinates, reusing mapped-row targeting and GTK text iterators. It updates through a coalesced one-shot after-paint handler, not a permanent tick/poll or retained layout cache. A passive, non-consuming smooth-input observer keeps measurement corrections from reversing an active gesture's indicator. The existing scrollbar adapter still drives GTK's native pixel adjustment, preserving frozen dragging, directional input, generation checks, endpoints, and release behavior; the drag origin reconciles the two coordinate systems. Keyboard/accessibility endpoint commands map to the real document edges.

Important momentum trade-off: GTK's native kinetic trajectory stores an absolute pixel origin. A separate regression reproduced an old trajectory jumping backward after a range re-estimate. The preview now cancels that invalid trajectory via GTK and restores the original kinetic-scrolling setting. It does not disable all momentum or introduce another physics engine. A flick may end early when newly measured rows change the range. The regression verifies that momentum still advances a settled viewport, then checks forward gestures, release/momentum, stopping, and reverse gestures in both Rendered and Source. This behavior is documented in docs/document-previews.md; physical-device feel remains unverified.

Rejected local prototypes exposed regressions in source/rendered thumb dragging. They were not pushed. The final implementation keeps native pixel-based thumb seeking instead of a two-frame scroll_to/fraction correction that exposed intermediate content. No unsafe code, new UI text/setting/dependency/runtime patch, or maintained harness change is shipped.

Validation and scope

Bounded scope: private virtual-document scrollbar presentation/input, with existing source/rendered selection/copy/find, media, lifecycle, keyboard, and browser/picker callers. Table infrastructure, preferences storage, build/CI, and GTK libraries are unchanged. Full local Rust/E2E suites were intentionally omitted under risk-based validation; CI remains the authoritative full gate. No test-skipping override was requested or used.

  • Bounded Rust selection: 28 passed on the final implementation before the last endpoint addition. It includes virtual preview/selection/lifetime, media, find, both keyboard modes, and Open/Save chooser previews in Columns/Icons/List.
  • After the endpoint fix: scoped 8 passed, including the new logical-range Home/End regression, all existing adapter regressions, the full smooth-input/momentum/reverse regression, and both keyboard ownership cases. Earlier unaffected results are preserved rather than rerunning the entire selection merely for a green summary.
  • Canonical E2E: 8 find cases passed, followed by 2 held-thumb/real-pointer cases passed after the final endpoint fix (Rendered and virtual Source). Earlier caller results remain recorded separately; failed prototypes are not counted as passes.
  • Final pinned formatting and Clippy: passed. git diff --check: passed.
  • Final one-off painted-frame probes: 0 backward frames / 682 frames for the alternating-paragraph fixture, and 0 / 780 for the original mixed Markdown fixture. Each used 300 real XTest wheel events over content. These are correctness probes, not FPS/battery benchmarks. Separate accessibility property reads still occasionally appeared inconsistent across frames, so they were not used as the authoritative verdict. The mixed probe specifically checks painted scrollbar progress, not complete source-offset coverage.

Exact local commands (the wrapper and diagnostic plugins remain ignored under target/; they use the verified pinned Podman base, private Xvfb + D-Bus, clear inherited display/session variables, and never fall back to the desktop; GTK is required):

bash target/preview-scroll-profile/rust-scoped.sh -- ui::virtual_preview:: ui::document_media:: ui::preview::tests::find:: ui::window::tests::keyboard_dispatch::preview_ownership::default_editing_keys_reach_a_focused_preview ui::window::tests::keyboard_dispatch::preview_ownership::tenxer_preview_owns_document_keys_until_returned ui::chooser::tests::filtered_preview::space_toggles_the_selected_search_result_in_open_and_save_choosers

bash target/preview-scroll-profile/rust-scoped.sh -- ui::virtual_preview::scrollbar:: ui::virtual_preview::tests::smooth_content_scrolling_keeps_thumb_and_hit_testing_in_document_order ui::window::tests::keyboard_dispatch::preview_ownership::default_editing_keys_reach_a_focused_preview ui::window::tests::keyboard_dispatch::preview_ownership::tenxer_preview_owns_document_keys_until_returned

STRATA_CONTAINER_ENGINE=podman ./scripts/e2e.sh tests/e2e/scenarios/test_quick_preview.py -k 'preview_find_navigates' -n 2 --junitxml=target/preview-scroll-profile/touchpad-actual-final-find-e2e.xml
STRATA_CONTAINER_ENGINE=podman ./scripts/e2e.sh tests/e2e/scenarios/test_quick_preview.py -k 'document_scrollbar_holds' -n 2 --junitxml=target/preview-scroll-profile/touchpad-final-edge-drag-e2e.xml
STRATA_CONTAINER_ENGINE=podman ./scripts/quality.sh fmt
STRATA_CONTAINER_ENGINE=podman ./scripts/quality.sh clippy

Pinned environment: image c3eeda033623…, GTK 4.22.5, Rust 1.98.1, unoptimized dev builds. Final test binary SHA256: ffa1ff18063e004432a37668f937e75e15f1122f81624bfc9c34f15db33b0d5c. Raw diagnostics, exact probe configurations, failed-prototype logs, and successful reruns remain local under target/preview-scroll-profile/. No screenshot/log/capture script is committed or uploaded as PR evidence. Previous source-RAM/table-idle results are not re-labelled as new measurements of this last scrollbar patch; no fresh CPU, RAM, release-FPS, energy, or battery gain is claimed.

Desktop launch / remaining verification

The owner explicitly requested launching the updated app on their desktop, authorizing that launch exception to normal GUI isolation. The launch was not performed: ibara's computer_status repeatedly reported OmarchyThinkpad offline because its hostname could not resolve; nothing was sent. No alternative desktop-control route was used. All actual builds/tests remained pinned and isolated.

The candidate binary is available locally at target/e2e-container/build/debug/strata. Physical-touchpad confirmation, the early-end momentum feel, and the residual initial-loading delay remain open. Keep the PR in draft.

@JoeJoeflyn

Copy link
Copy Markdown
Collaborator Author

Owner-requested desktop launch is now running: the updated local binary was started on the existing Wayland display with a new private D-Bus session (no automated desktop input and no interference with existing Strata windows). The application reported window presentation and its first themed frame, and loaded the three-file manual scrolling fixture folder. This is the explicitly requested desktop-launch exception only; automated validation remains pinned/headless and physical-touchpad results are still for the owner to confirm.

@JoeJoeflyn
JoeJoeflyn marked this pull request as ready for review October 19, 2026 14:26
GTK can re-anchor a virtual document's pixel origin without changing its range. Detect layout corrections after native kinetic updates and resynchronize GTK's next input origin when cancelling the stale trajectory. The owner confirmed the real-touchpad jump no longer reproduces.

Defer intermediate rendered-row materialization and scope Settings tab label styling to avoid unrelated preview style invalidation. Keep source rows eager for stable thumb seeking.

Refs #1749
Preserve both the scrollbar regression's regular-expression import and main's binary-STL fixture import. Retain both preview coverage paths.

Refs #1749
@JoeJoeflyn

Copy link
Copy Markdown
Collaborator Author

Pushed the follow-up to this PR:

  • 82f772b5 — cancel stale momentum after virtual pixel-origin corrections, synchronize GTK's next input origin, defer intermediate rendered-row construction, and narrow Settings tab CSS invalidation.
  • 03c240c6 — merge main at e0f73973. Resolve the sole conflict in test_quick_preview.py by retaining both re for document-scroll coverage and struct for the new binary-STL fixture. Both implementations are preserved.

The owner confirmed that the real-touchpad candidate no longer jumps. That confirmation predates the latest-main merge; the merged runtime has not been manually retested. Temporary production debug logging was removed before committing; diagnostic scripts and captures remain ignored and are not part of the PR.

Final pre-push commands, after the merge resolution:

STRATA_CONTAINER_ENGINE=podman ./scripts/quality.sh fmt
STRATA_CONTAINER_ENGINE=podman ./scripts/quality.sh clippy
git diff --check origin/main...HEAD

All passed. Formatting initially requested one let-else reflow before the merge; it was corrected and the checks rerun on the final merged code. The verified pinned container and existing Cargo caches were reused; no images, runtime inputs, or dependencies were rebuilt or changed for validation.

Explicit owner override: after pausing automated tests and manually confirming the touchpad result, the owner answered “push” directly to the question asking whether to push without further tests while retaining formatting/Clippy. Rust and E2E reruns were therefore intentionally omitted for this push, including after the merge. Earlier scoped results are not represented as tests of the final momentum fix. Required GitHub checks still apply.

Validation scope: the current follow-up extends the existing GTK kinetic guard and row-materialization paths, with the existing shared browser/picker preview and Settings action-label callers. The merge's only textual conflict was the two independently required imports; no new test behavior was invented in resolution.

Remaining limits: re-anchoring can end a flick early; initial-loading speed, battery-life gains, and post-merge runtime behavior are unverified. No physical-device energy or general speedup claim is made.

@JoeJoeflyn

Copy link
Copy Markdown
Collaborator Author

g2g

GTK truncates both fractional kinetic positions and restored row anchors to integer pixels. Comparing them exactly cancels valid momentum before the viewport advances. Ignore their combined sub-two-pixel quantization while retaining cancellation for stale pixel-origin jumps.

Refs #1749
@JoeJoeflyn

Copy link
Copy Markdown
Collaborator Author

Fixed the shard-2 failure in db64a82.

Cause: DocumentPosition treated GTK's fractional kinetic positions and integer-quantized ListView anchors as different pixel origins. This cancelled valid native momentum. GTK truncates twice; the guard now ignores their combined sub-two-pixel rounding while retaining cancellation for larger stale-origin corrections.

Scoped validation: this changes only the private virtual-preview momentum guard shared by rendered/source document previews in browsers and pickers. No preferences, dependencies, toolkit patches, or harness/workflow code changed. Existing coverage owns this regression; no parallel smoke test was added.

Using the verified pinned Podman base c3eeda033623f5f9426d1ab7167adb4e1c8a08d222dd68b590e9d33680e5fbb7, existing quality caches, and private Xvfb/D-Bus with GTK tests required:

  • Before the fix: ./scripts/test-headless.py ui::virtual_preview::tests::smooth_content_scrolling_keeps_thumb_and_hit_testing_in_document_order -- --exact --nocapture reproduced the CI assertion, 0 passed / 1 failed.
  • Final code: ./scripts/test-headless.py ui::virtual_preview:: -- --nocapture — 23 passed, 0 failed, including both rendered/source smooth-input and momentum checks, scrollbar lifecycle/edge behavior, hit testing, selection, and row recycling.
  • STRATA_CONTAINER_ENGINE=podman ./scripts/quality.sh fmt — passed.
  • STRATA_CONTAINER_ENGINE=podman ./scripts/quality.sh clippy — passed.
  • git diff --check — passed.

Full Rust and E2E suites intentionally not rerun for this bounded correction; CI remains authoritative. No desktop/manual touchpad retest performed. No owner override was used for this follow-up. The build/lint job was already green on the previous run; the aggregate failure came from shard 2.

@l0gicgate

Copy link
Copy Markdown
Contributor

Review

Merged main at b5b7a13a (clean, no conflicts) as e021dbb8. No merge-blocking issues found; no code changes beyond the merge.

Checked

  • StableScrollbar / DocumentPosition: no Rc cycles (the bar owns the controller closure, adjustments hold weak refs), frame-clock handlers are disconnected on cancel/drop, and edge/drag generation guards are correct. The position fraction stays within [0, 1]: normalize_preview_text preserves char counts, and inline math only shrinks the buffer.
  • Deferred rendered-row materialization: unbind by position is safe because the model is static, and stale tick callbacks are dropped by the position/materialized checks. schedule_document_view_size still sizes unmapped views through the existing map handler.
  • link_point_at's link-span fast path keeps link_info_at semantics. SourceUnit::display_text slices at a boundary from strip_suffix.
  • Table: recycled cells still highlight through Selection::bind, and clear resets old highlights on drag start. Autoscroll runs only during drags and uses scrolling::advance. Theme colors go through bind_theme_preference. Column fitting now runs on viewport page-size changes.
  • The Settings tab CSS is scoped to the three editor_page labels, which are the only tabs in .settings-action-tabs. The mutation patch still applies.
  • Tests: new Rust and E2E cases check behavior (document order, endpoints, release stability, live theme in two windows / rebuilt tables). No tautological or layout tests.
  • Comments: every added comment documents a GTK constraint or an invariant; nothing to remove.

Non-blocking notes

  • Rendered rows that GTK rebinds while mapped are built on the next tick, so a far jump (e.g. a thumb drag) can show the previous unit for one frame. The E2E drag scenario checks content only after it settles, so a manual pass on real hardware after this merge is still worthwhile, as the PR description notes.
  • smooth_content_scrolling_… depends on wall-clock time (~20 s). It already needed one rounding fix after a shard-2 failure, so keep an eye on it in CI.

Local verification (scoped, e021dbb8)

  • ./scripts/test-headless.py -- ui::virtual_preview:: ui::table_view:: ui::document_media:: ui::preview::tests::find:: ui::window::tests::keyboard_dispatch::preview_ownership:: ui::chooser::tests::filtered_preview:: → 71 passed, 0 failed
  • STRATA_CONTAINER_ENGINE=podman ./scripts/e2e.sh tests/e2e/scenarios/test_quick_preview.py tests/e2e/scenarios/test_custom_actions.py -k 'document_scrollbar_holds or preview_renders_markdown or markdown_equations or rendered_document_word or preview_find_navigates or sandboxed_office_files or space_opens_and_closes or large_table_header_sort or action_editor_tabs' → 28 passed
  • cargo fmt --all --check, cargo clippy --all-targets --all-features -- -D warnings, git diff --check → clean

I didn't run the full local Rust/E2E suites: the merged main commit (release picker) doesn't touch the preview code. I also didn't do a manual touchpad check. CI on e021dbb8 is green.

@l0gicgate
l0gicgate merged commit 372c8b7 into main Oct 20, 2026
9 checks passed
@l0gicgate
l0gicgate deleted the fix/1749-investigate-preview-scroll branch October 20, 2026 23:29
l0gicgate added a commit that referenced this pull request Oct 22, 2026
* test!: remove the Python E2E suite and the QA twin metadata

QA scenarios are now the only GUI suite. The Python suite under tests/e2e,
its runners, diagnostics, sharding and mutation scripts, and the E2E and
E2E cache workflows are gone. The QA job in ci.yml runs only when CI
is started by hand, and a failing scenario fails that run.

- Move the image recipe to tests/container/ and drop the pytest venv;
  the image key changes, so the base is rebuilt once and republished by
  the trusted-main publisher.
- Move the headless display, environment, process and XTest helpers that
  test-headless.py and benchmark-scroll.py use to scripts/headless/.
- Move baselines, fixtures and mutation patches under tests/qa/, and let
  STRATA_QA_UPDATE_BASELINES=1 regenerate a baseline.
- Drop twin, state_parity_ignore and input_parity_ignore from every
  scenario and from the runner, drop the test_ prefix from scenario
  folders, and replace qa-parity with qa-mutation.sh, which checks that
  each scenario with a mutation passes unmodified and fails under its patch.
- $python is now the image's absolute /usr/bin/python3, as a file
  provider's manifest command must be.
- Rename docs/e2e-testing.md to docs/testing.md and update AGENTS.md,
  the docs and the QA skills.
- Drop the held-document-scrollbar E2E test from #1752 and its mutation
  patch rather than convert it: three GTK tests in
  src/ui/virtual_preview/scrollbar/tests.rs already fail under that patch.

BREAKING CHANGE: scripts/e2e.sh, e2e-native.sh and qa-parity.sh are removed;
scenario headers reject twin and the parity ignore keys.

* test(qa): prune the lowest-value third of the QA scenarios

Remove the 134 scenarios with the lowest quality score per square root of
their measured cost, which favours removing long-running, low-scoring
scenarios. Scenarios with a mutation patch and the visual baselines were
kept. The suite keeps 269 scenarios and 512 runs; a full run drops from
about 106 s to 41 s.

Quality notes in the remaining headers still describe coverage as it was
before this removal.

* test(qa): rebuild the 20 highest-scoring pruned scenarios as short runs

Each was dropped for its run time, not its value. Rewrite each as one or
two runs that keep the behaviour its quality note names: one view where
the views share the code path, several cases in one launch instead of a
launch per case, fixtures set up before launch, and keyboard or activate
steps where the pointer is not under test. Together they took about 645 s
of CI time over 172 runs and now take about 55 s over 23 runs.

Each rewrite was run at least three times, shown to fail at a broken
expected value, and re-rated with the qa-quality rubric; none has a
measured cost yet.

* test(qa): trace Strata's UI thread through the QA runner

#1729 added scripts/trace-main-io.py on top of the Python E2E harness,
which this branch removes. With STRATA_QA_MAIN_IO set, the QA runner now
starts every Strata launch of a run under strace, tracing only the
initial thread: the application, its restarts, the portal backend and
the second instances launch steps start. Each launch leaves the trace,
its log and the meta.json the script classifies paths by under
target/main-io/<run>/<scenario>__<label>/launch-<n>/. Its startup phase
ends at the first reply that shows a pane, once the first window or the
portal backend's first chooser is up.

The runner's own places (the shared shader cache, the launch's logs and
the PATH folders) are listed in meta.json and count as toolkit. QA
mode's own disk reads, for pref and file predicates, now run on a helper
thread, and --qa no longer checks its directory before launch, so an
audit sees only calls a release build would make.

proc steps now ask about the traced Strata rather than strace. qa.sh
forwards STRATA_QA_MAIN_IO and STRATA_UI_STALL_MS, and the runner passes
the stall limit to every launch. The script runs qa.sh with its other
arguments, and the allowlist moves to tests/qa/.

* test(qa): check that a launch leaves the folder it started in

#1729 made Strata change its working folder to / once it has read its
arguments, so a launch folder on a removable drive or share stays
unmountable, and asserted it in the Python startup-argument test. Add a
proc app_cwd query and check it at the end of
multiple-arguments-non-utf8.

* ci: install git for the script tests in the Arch packaging job

scripts/test_qa_mutation.py applies its patches with git, which the
archlinux:base-devel image lacks.

* test(qa): drop the repeat double-clicks from the archive activation scenario

archive-double-click-extracts-subfolder was skipped for #1772: a repeat
double-click within about a second of an extraction that selects the
new folder is lost. That needs input faster than real use produces, and
archive-activation-extracts-subfolder already covers repeat extractions
into fresh folders through Return and Extract here. Keep the first
double-click, which bundles a multi-root zip or tar.gz into a subfolder
and selects it in Columns, and run it again.

* build!: rename the E2E image tooling for the QA suite

The pinned image now serves only the QA scenarios and the Rust quality
runs, so its tooling no longer carries the removed suite's name.

- Rename scripts/e2e_{bundle,base,images}.py to
  scripts/image_{inputs,base,registry}.py, e2e-images.yml to
  test-image.yml, STRATA_E2E_* to STRATA_TEST_*, target/e2e-container to
  target/qa-container, and the GHCR package, labels, container user and
  in-image paths to their test-image names.
- Stop publishing the runtime image and drop the registry cache
  discovery; only the removed E2E jobs consumed them. The publisher's
  anonymous check now verifies the build tag and the base.
- Point the links and doc comments that still named docs/e2e-testing.md
  at docs/testing.md, delete the stale evidence for #928, and drop the
  pytest ignore and the unused GTK version variable.

BREAKING CHANGE: scripts/e2e_base.py, STRATA_E2E_IMAGE and
STRATA_E2E_CARGO_CACHE are renamed, and the published base moves to
ghcr.io/lgse/strata-test-image, which must be made public after its
first publication.

* docs(qa): keep one catalogue of the QA protocol

docs/testing.md and the qa-scenarios skill's reference.md both listed
every step, target and predicate, and the copies had drifted: testing.md
said the pane predicate reads the focused pane, and placed the area
repainted ignores at the box's centre. Many of its rows also explained
behaviour through the removed Python harness.

- Make reference.md the only catalogue. Move into it what only
  testing.md had: input timing, target resolution, share rounding, the
  labelled-by naming rules, the semantics of repainted, accent_pixels,
  largest_image, compare and each NAMES key, the snapshot keys, the input
  log format, and the harness-error rule.
- Replace testing.md's tables, snapshot and input-log sections with a
  short overview that links to the reference, and drop the Python
  comparisons from the timer-waits list.
- Point the qa-scenarios skill, CONTRIBUTING.md and the src/qa doc
  comments at the reference, and tell runner changes to recheck the
  main-thread I/O audit.

* docs(qa): fix stale suite references and catalogue gaps

The pr-review skill merged from main still named the E2E suite and
qa-parity; the qa.sh example run label columns-ru does not exist for
arrow-keys-move-focus; the qa-scenarios skill named a section that
docs/testing.md renamed; and the protocol catalogue lacked the
selectable and editable states, the field-within target, and the
count spec's rendered and states options.

* refactor(scripts): drop the unused sys import from image_registry

* test(qa): drop dead header data and name the pin-order scenario after its check

Eleven scenarios kept a case variable that only the removed twin ids
read, wildcard-filter-patterns remembered a field no step used, and
folder-pins-order-and-restart no longer restarts: it verifies the
bookmarks file instead.

---------

Co-authored-by: Pierre Berube <[email protected]>
l0gicgate added a commit that referenced this pull request Oct 22, 2026
* test!: remove the Python E2E suite and the QA twin metadata

QA scenarios are now the only GUI suite. The Python suite under tests/e2e,
its runners, diagnostics, sharding and mutation scripts, and the E2E and
E2E cache workflows are gone. The QA job in ci.yml runs only when CI
is started by hand, and a failing scenario fails that run.

- Move the image recipe to tests/container/ and drop the pytest venv;
  the image key changes, so the base is rebuilt once and republished by
  the trusted-main publisher.
- Move the headless display, environment, process and XTest helpers that
  test-headless.py and benchmark-scroll.py use to scripts/headless/.
- Move baselines, fixtures and mutation patches under tests/qa/, and let
  STRATA_QA_UPDATE_BASELINES=1 regenerate a baseline.
- Drop twin, state_parity_ignore and input_parity_ignore from every
  scenario and from the runner, drop the test_ prefix from scenario
  folders, and replace qa-parity with qa-mutation.sh, which checks that
  each scenario with a mutation passes unmodified and fails under its patch.
- $python is now the image's absolute /usr/bin/python3, as a file
  provider's manifest command must be.
- Rename docs/e2e-testing.md to docs/testing.md and update AGENTS.md,
  the docs and the QA skills.
- Drop the held-document-scrollbar E2E test from #1752 and its mutation
  patch rather than convert it: three GTK tests in
  src/ui/virtual_preview/scrollbar/tests.rs already fail under that patch.

BREAKING CHANGE: scripts/e2e.sh, e2e-native.sh and qa-parity.sh are removed;
scenario headers reject twin and the parity ignore keys.

* test(qa): prune the lowest-value third of the QA scenarios

Remove the 134 scenarios with the lowest quality score per square root of
their measured cost, which favours removing long-running, low-scoring
scenarios. Scenarios with a mutation patch and the visual baselines were
kept. The suite keeps 269 scenarios and 512 runs; a full run drops from
about 106 s to 41 s.

Quality notes in the remaining headers still describe coverage as it was
before this removal.

* test(qa): rebuild the 20 highest-scoring pruned scenarios as short runs

Each was dropped for its run time, not its value. Rewrite each as one or
two runs that keep the behaviour its quality note names: one view where
the views share the code path, several cases in one launch instead of a
launch per case, fixtures set up before launch, and keyboard or activate
steps where the pointer is not under test. Together they took about 645 s
of CI time over 172 runs and now take about 55 s over 23 runs.

Each rewrite was run at least three times, shown to fail at a broken
expected value, and re-rated with the qa-quality rubric; none has a
measured cost yet.

* test(qa): trace Strata's UI thread through the QA runner

#1729 added scripts/trace-main-io.py on top of the Python E2E harness,
which this branch removes. With STRATA_QA_MAIN_IO set, the QA runner now
starts every Strata launch of a run under strace, tracing only the
initial thread: the application, its restarts, the portal backend and
the second instances launch steps start. Each launch leaves the trace,
its log and the meta.json the script classifies paths by under
target/main-io/<run>/<scenario>__<label>/launch-<n>/. Its startup phase
ends at the first reply that shows a pane, once the first window or the
portal backend's first chooser is up.

The runner's own places (the shared shader cache, the launch's logs and
the PATH folders) are listed in meta.json and count as toolkit. QA
mode's own disk reads, for pref and file predicates, now run on a helper
thread, and --qa no longer checks its directory before launch, so an
audit sees only calls a release build would make.

proc steps now ask about the traced Strata rather than strace. qa.sh
forwards STRATA_QA_MAIN_IO and STRATA_UI_STALL_MS, and the runner passes
the stall limit to every launch. The script runs qa.sh with its other
arguments, and the allowlist moves to tests/qa/.

* test(qa): check that a launch leaves the folder it started in

#1729 made Strata change its working folder to / once it has read its
arguments, so a launch folder on a removable drive or share stays
unmountable, and asserted it in the Python startup-argument test. Add a
proc app_cwd query and check it at the end of
multiple-arguments-non-utf8.

* ci: install git for the script tests in the Arch packaging job

scripts/test_qa_mutation.py applies its patches with git, which the
archlinux:base-devel image lacks.

* test(qa): drop the repeat double-clicks from the archive activation scenario

archive-double-click-extracts-subfolder was skipped for #1772: a repeat
double-click within about a second of an extraction that selects the
new folder is lost. That needs input faster than real use produces, and
archive-activation-extracts-subfolder already covers repeat extractions
into fresh folders through Return and Extract here. Keep the first
double-click, which bundles a multi-root zip or tar.gz into a subfolder
and selects it in Columns, and run it again.

* build!: rename the E2E image tooling for the QA suite

The pinned image now serves only the QA scenarios and the Rust quality
runs, so its tooling no longer carries the removed suite's name.

- Rename scripts/e2e_{bundle,base,images}.py to
  scripts/image_{inputs,base,registry}.py, e2e-images.yml to
  test-image.yml, STRATA_E2E_* to STRATA_TEST_*, target/e2e-container to
  target/qa-container, and the GHCR package, labels, container user and
  in-image paths to their test-image names.
- Stop publishing the runtime image and drop the registry cache
  discovery; only the removed E2E jobs consumed them. The publisher's
  anonymous check now verifies the build tag and the base.
- Point the links and doc comments that still named docs/e2e-testing.md
  at docs/testing.md, delete the stale evidence for #928, and drop the
  pytest ignore and the unused GTK version variable.

BREAKING CHANGE: scripts/e2e_base.py, STRATA_E2E_IMAGE and
STRATA_E2E_CARGO_CACHE are renamed, and the published base moves to
ghcr.io/lgse/strata-test-image, which must be made public after its
first publication.

* docs(qa): keep one catalogue of the QA protocol

docs/testing.md and the qa-scenarios skill's reference.md both listed
every step, target and predicate, and the copies had drifted: testing.md
said the pane predicate reads the focused pane, and placed the area
repainted ignores at the box's centre. Many of its rows also explained
behaviour through the removed Python harness.

- Make reference.md the only catalogue. Move into it what only
  testing.md had: input timing, target resolution, share rounding, the
  labelled-by naming rules, the semantics of repainted, accent_pixels,
  largest_image, compare and each NAMES key, the snapshot keys, the input
  log format, and the harness-error rule.
- Replace testing.md's tables, snapshot and input-log sections with a
  short overview that links to the reference, and drop the Python
  comparisons from the timer-waits list.
- Point the qa-scenarios skill, CONTRIBUTING.md and the src/qa doc
  comments at the reference, and tell runner changes to recheck the
  main-thread I/O audit.

* docs(qa): fix stale suite references and catalogue gaps

The pr-review skill merged from main still named the E2E suite and
qa-parity; the qa.sh example run label columns-ru does not exist for
arrow-keys-move-focus; the qa-scenarios skill named a section that
docs/testing.md renamed; and the protocol catalogue lacked the
selectable and editable states, the field-within target, and the
count spec's rendered and states options.

* refactor(scripts): drop the unused sys import from image_registry

* test(qa): drop dead header data and name the pin-order scenario after its check

Eleven scenarios kept a case variable that only the removed twin ids
read, wildcard-filter-patterns remembered a field no step used, and
folder-pins-order-and-restart no longer restarts: it verifies the
bookmarks file instead.

---------

Co-authored-by: Pierre Berube <[email protected]>
wmfeht added a commit to wmfeht/strata-feature-map that referenced this pull request Oct 24, 2026
Sync lgse/strata#1752–#1776: density sliders, preview scrollbar, chooser save names
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants