Skip to content

fix(display): remeasure point-dependent position geometry - #618

Open
eval-exec wants to merge 3 commits into
mainfrom
fix/616-point-dependent-query-geometry
Open

eval-exec wants to merge 3 commits into
mainfrom
fix/616-point-dependent-query-geometry

Conversation

@eval-exec

@eval-exec eval-exec commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

Moving point before redisplay can change mode/header/tab-line heights and which row receives the taller line-number-current-line face. PR #616's point-only shortcut could return a hidden target or coordinates measured with the previous current-line face.

Make the canonical freshness token carry a closed PointGeometryReuse enum, and capture the selected window's live buffer point before its saved marker is synchronized. Literal, property-free chrome without dynamic substitutions retains the shortcut; dynamic/structured chrome and active line numbering use canonical targeted measurement.

The real GUI regression also exposed a producer gap: position queries shared window-end's accepted-chrome policy. Distinct enum variants now make position queries measure live chrome with the existing renderer. One-use native retry state avoids duplicate observable :eval calls during height convergence. Queries preserve accepted redisplay snapshots and isolate native chrome bookkeeping with thread-confined RAII guards. Cache reuse across viewport/position scopes remains available only when live chrome is absent; active-chrome position results cannot become scalar-Lisp-blind cache entries.

This follows the two explicitly deferred review comments in #616:

GNU source references, live probes, root causes and reuse policy are recorded in docs/research/point-dependent-position-query-geometry.md. Related to #607; its native macOS memory spike remains unverified.

Validation (all final test runs used cargo nextest):

  • New regressions failed first: dynamic header visibility, absolute current-line metrics, stale selected-window point, canonical live-chrome measurement, duplicate evaluation, preceding window-end cache reuse and enclosing chrome bookkeeping.
  • 353 layout-engine query/position/chrome/mode-line tests passed.
  • 141 core window/position-query tests passed on the final source.
  • Full release fresh-build passed, including matching dump and Lisp byte compilation.
  • Oracle tests: 2/2; TUI GNU comparison: 1/1.
  • Private-display GUI tests: 3/3, including live GNU/Neomacs geometry, startup/readback and loaded-Lisp timer navigation. Both engines returned [true,false] for all three chrome cases; current-line Y decreased from 38 to 20 in GNU and from 35 to 18 in Neomacs.
  • Navigation exercised hardware quality_mode=Full, reached line 261 and recorded 317 scene commits, 494 root glyph passes and 1,099 composite-only frames in the final periodic sample. Startup readback was visually checked.
  • Standards/spec review found no blocking issue; changed Rust formatting and whitespace checks pass.

The first release failed the new live GUI regression and led to the selected-point and producer fixes above; the rebuilt final source passes it. All GUI processes ran on private displays. CI was not used as a completion gate, per the requested workflow.

@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ad63ad00-7708-4db7-b611-ef2085ff1730
Commits

Reviewing files that changed from the base of the PR and between f2b799e and 145bbdb.

Files selected for processing: 19
  • crates/neomacs-gui-tests/fixtures/point-query-geometry/init.el
  • crates/neomacs-gui-tests/tests/gui.rs
  • crates/neomacs-gui-tests/tests/point_query_geometry.rs
  • crates/neomacs-layout-engine/src/buffer_source/render_attempt.rs
  • crates/neomacs-layout-engine/src/buffer_source/render_plan.rs
  • crates/neomacs-layout-engine/src/display_status_line.rs
  • crates/neomacs-layout-engine/src/engine.rs
  • crates/neomacs-layout-engine/src/engine/query_cache.rs
  • crates/neomacs-layout-engine/src/engine/tests/chrome_memo_engine_test.rs
  • crates/neomacs-layout-engine/src/engine/tests/engine_test.rs
  • crates/neomacs-layout-engine/src/engine/tests/query_source_horizon_test.rs
  • crates/neomacs-layout-engine/src/incremental_layout/chrome_memo.rs
  • crates/neovm-core/src/emacs_core/display/xdisp/mod.rs
  • crates/neovm-core/src/emacs_core/display/xdisp/tests/xdisp_test.rs
  • crates/neovm-core/src/window/chrome.rs
  • crates/neovm-core/src/window/display.rs
  • crates/neovm-core/src/window/mod.rs
  • crates/neovm-core/src/window/tests/window_test.rs
  • docs/research/point-dependent-position-query-geometry.md

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

Walkthrough

Position-query freshness and layout now account for geometry that changes with point, including evaluated chrome and current-line number faces. Position queries measure live chrome when required, while preserving redisplay state. Engine and GUI tests cover these cases.

Changes: Position-query geometry

Layer / File(s) Summary
Certify point-geometry reuse
crates/neovm-core/src/window/*, crates/neovm-core/src/window/tests/window_test.rs, crates/neovm-core/src/emacs_core/display/xdisp/{mod.rs,tests/xdisp_test.rs}
Freshness uses the selected window’s live point and records whether point-dependent geometry can be reused. Retained-row reuse now relies on that certification. Tests cover line-number settings, selected-window point changes, dynamic header height, and current-line face geometry.
Measure live chrome in position queries
crates/neomacs-layout-engine/src/buffer_source/*, crates/neomacs-layout-engine/src/engine.rs, crates/neomacs-layout-engine/src/engine/query_cache.rs, crates/neomacs-layout-engine/src/engine/tests/*
Position queries use a distinct publication mode and measure live chrome. If measurement requires relayout, the query retries with chrome marked measured. Viewport observations cover position queries only when chrome is absent. Tests check measurement, retry behavior, and query results.
Isolate query-local records
crates/neomacs-layout-engine/src/display_status_line.rs, crates/neomacs-layout-engine/src/incremental_layout/chrome_memo.rs, crates/neomacs-layout-engine/src/engine.rs, crates/neomacs-layout-engine/src/engine/tests/*, crates/neovm-core/src/emacs_core/display/xdisp/mod.rs
Query scopes isolate and restore chrome-generation, fingerprint, column-consumption, and line-evaluation records. Tests check that position queries preserve the enclosing redisplay’s records.
Verify geometry across engine and GUI
crates/neomacs-gui-tests/fixtures/point-query-geometry/init.el, crates/neomacs-gui-tests/tests/{gui.rs,point_query_geometry.rs}, docs/research/point-dependent-position-query-geometry.md
The GUI fixture records position visibility and coordinates before and after point changes. The integration test compares GNU Emacs and native-engine results. The research document records observations, query rules, and verification notes.

Priority: Normal

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant posn_at_point
  participant LayoutEngine
  participant QueryCache
  participant FrameLayout
  posn_at_point->>LayoutEngine: Request a Position query
  LayoutEngine->>QueryCache: Check viewport observation coverage
  QueryCache-->>LayoutEngine: Do not cover the query when chrome is present
  LayoutEngine->>FrameLayout: Measure live chrome
  FrameLayout-->>LayoutEngine: Report whether relayout is required
  LayoutEngine->>FrameLayout: Retry with chrome marked Measured
Loading

Possibly related issues

  • eval-exec/neomacs#612: The issue reports navigation stalls involving pos-visible-in-window and query_window_layout. This PR changes reuse and measurement in that position-query path, but does not establish the full cause of the stalls.
  • eval-exec/neomacs#607: The issue reports high CPU and memory use during line navigation. This PR changes position-query reuse and measurement for point-dependent geometry, but does not establish the reported memory cause.

Possibly related PRs

  • eval-exec/neomacs#616: This PR extends the retained-row reuse and position-query freshness work with point-dependent chrome and line-number geometry.

Suggested reviewers: vritser

Merge Risk: Minimal · up to 145bb

No merge-blocking issue was identified; the reviewed point-geometry behavior is ready for normal merge checks.

Pre-merge checks: Passed 4 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Docstring Coverage Inconclusive Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies the main change: remeasuring point-dependent position geometry.
Description check Passed The description directly explains the geometry issue, implementation, regression coverage, and validation results.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 20 functions across 16 files. (3 skipped: 2 unsupported, 1 too large.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 2
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@eval-exec
eval-exec marked this pull request as ready for review October 28, 2026 15:09
Copilot AI balanced review requested due to automatic review settings October 28, 2026 15:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

A subtle redisplay/geometry parity change on a performance-sensitive hot path tied to an unverified macOS spike, with CI not serving as a completion gate, calls for hands-on human validation of the GUI and performance behavior.

No open issues 🎉

What changed in this PR

This PR corrects point-dependent display geometry for posn-at-point / pos-visible-in-window-p queries issued after point moves but before redisplay. PR #616's point-only shortcut could reuse rows whose geometry actually depends on point: window chrome (mode/header/tab line) whose :eval/propertized/%-substituted content changes height, and active line numbering where the line-number-current-line face shifts gutter width and row height. The fix introduces a canonical PointGeometryReuse certification carried by the freshness token, captures the selected window's live buffer point before its marker syncs (matching GNU window_point), and routes dynamic/structured chrome and any active numbering through canonical live-chrome measurement while retaining the fast path only for literal, property-free chrome.

Changes:

  • Add a closed PointGeometryReuse enum and WindowChromePresence::{is_empty, point_geometry_reuse}; gate point-only row reuse on it and on the selected-window live point, replacing the removed line_numbers_are_point_independent helper.
  • Distinguish window-end from position queries in the layout engine: position queries measure live chrome once via a new PositionQueryChrome::{Measure, Measured} one-use retry, isolate thread-local chrome bookkeeping with RAII guards, and never publish start/end markers or replace the accepted snapshot.
  • Restrict viewport→position cache reuse to chrome-absent windows; add core, layout-engine, and live GUI regression coverage plus a research write-up.
File Description
crates/​neovm-core/​src/​window/​chrome.rs New PointGeometryReuse enum; is_empty and point_geometry_reuse classifying literal vs. dynamic chrome.
crates/​neovm-core/​src/​window/​display.rs Projects selected-window live point; classifies point-geometry reuse (numbering + chrome).
crates/​neovm-core/​src/​window/​mod.rs Freshness carries point_geometry_reuse; comparison blocks reuse unless both tokens certify independence.
crates/​neovm-core/​src/​emacs_core/​display/​xdisp/​mod.rs Adds ColumnSpecConsumptionScope; removes line_numbers_are_point_independent, deferring to the canonical token.
crates/​neomacs-layout-engine/​src/​engine.rs Adds SynchronousPositionQuery/one-use chrome retry plumbing and chrome-record isolation for position queries.
crates/​neomacs-layout-engine/​src/​buffer_source/​render_attempt.rs New publication variant + preserves_reserved_chrome split from is_synchronous_query.
crates/​neomacs-layout-engine/​src/​buffer_source/​render_plan.rs Chooses recompute vs. preserve chrome via preserves_reserved_chrome.
crates/​neomacs-layout-engine/​src/​display_status_line.rs ChromeQueryRecordScope RAII isolating generation/eval-count/fingerprint/column records.
crates/​neomacs-layout-engine/​src/​incremental_layout/​chrome_memo.rs ChromeFingerprintRecordScope RAII for fingerprint records.
crates/​neomacs-layout-engine/​src/​engine/​query_cache.rs Gates viewport→position cache reuse on chrome absence.
crates/​neomacs-layout-engine/​src/​engine/​tests/​* New engine tests for remeasurement, non-publication, and record preservation; MemoGuard exposed.
crates/​neovm-core/​src/​.../​tests/​*_test.rs Core tests for live selected-point and default/local numbering reuse.
crates/​neomacs-gui-tests/​{tests/​point_query_geometry.rs,tests/​gui.rs,fixtures/​.../​init.el} Live GNU vs. Neomacs GUI regression for point-dependent chrome/gutter.
docs/​research/​point-dependent-position-query-geometry.md Records GNU references, root cause, and reuse policy.

No blocking code defects were found within the changed regions. The implementation is internally consistent, exported symbols resolve across crates, removed/renamed symbols have no stale references, and the new behavior is well covered by core, layout-engine, and GUI tests. Given the subtlety of the redisplay-geometry parity change, its performance sensitivity (relation to the unverified #607 macOS spike), and that CI was explicitly not used as a completion gate, final sign-off is best confirmed by a human.

Review effort: Balanced

@github-actions github-actions Bot added the merge-conflict Pull request has merge conflicts; removed automatically once resolved label Oct 29, 2026

This branch has not been deployed

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

Labels

merge-conflict Pull request has merge conflicts; removed automatically once resolved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants