Skip to content

fix(layout): say the rows and columns a table's box leaves out - #3439

Merged
jgregoriorincon merged 3 commits into
opengeos:mainfrom
jgregoriorincon:fix/3416-layout-table-cut
Nov 30, 2026
Merged

jgregoriorincon merged 3 commits into
opengeos:mainfrom
jgregoriorincon:fix/3416-layout-table-cut

Conversation

@jgregoriorincon

@jgregoriorincon jgregoriorincon commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A layout's table frame draws only the rows and columns its box holds, and left the rest out without a word. It now says how many it shows:

Table "Table Frame" (2): its box shows 3 of 20 rows and 2 of 6 columns; make it larger, reduce its text size, or show fewer rows or fields

  • layout.addElement says it for a table it adds, and layout.update for a table given w, h, rows, fields, textSize, header, layer or visible (so Format and a resize in the layout view say it too; a move changes nothing the box holds and says nothing).
  • An export (PNG, region, PDF, series, SVG) says it in one notice for all the cut tables, the first ten by name; each page is counted after it is drawn, and a table cut on several pages of a series is said once, as its first cut page showed it. A report says it in one notice for the tables of every layout page it draws, each named with its layout.
  • Rows the layer hasn't are not counted: rows: 20 on a layer of five rows that fit says nothing. A hidden table, one off the page and one drawn as a placeholder say nothing.
  • The drawing and the count share one function (table_fit), so a notice can't disagree with the page. A table draws the same pixels as before.

Redrawing the layout view adds no notice of its own, as for a legend or a chart: the commands the view runs say it. Duplicating a table doesn't repeat what was said of the original.

Surfaces: everything goes through Session notices, so desktop, web, command line, Python, Assistant/MCP and the touch interface get it. No new command, parameter or project field.

Not in this PR

A cell's text shortened to its column's width is still cut without a notice.

A table of a layer read in place lists only the rows in view without saying so (as before; its own issue).

Testing

  • New tests in crates/engine/src/tests/layout_table.rs: add, update, each export format, a region, a map series and a report, written first and seen failing; one for a report over two layouts. One in the render crate checks that table_fit counts what table paints at two resolutions.
  • Full checks: fmt, clippy, doctests, layers and schema pass; nextest ran 11368 tests, 11367 passed. The one failure, line_strokes_editor_edits_one_class, also fails on main on this machine and passes in CI ([Bug]: smoke test line_strokes_editor_edits_one_class fails on main #3411).
  • After the last change (the report's single notice): the table and report tests (40), fmt and clippy pass.

UI evidence

The issue's table (60×20 mm, 20 rows asked) draws the same before and after; only the message is new.

Before:

BEFORE

After:

AFTER

Related issue

Closes #3416

Summary by CodeRabbit

  • New Features
    • Added notices when a table frame displays fewer rows or columns than requested. Notices appear when adding or changing a table and during PNG, PDF, or SVG exports and report generation.
    • Export notices identify affected tables and summarize omitted rows or columns.
  • Documentation
    • Updated the layout guide to explain when clipping notices appear and what they report.

@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Table fitting now calculates how many requested rows and columns fit in each table box. Adding or updating a table, exporting a layout, or exporting a report can produce a notice when content is omitted.

Changes: Table clipping notices

Layer / File(s) Summary
Fit calculation and clipping detection
crates/render/src/layout/table.rs, crates/render/src/layout.rs, crates/render/src/layout/picture.rs, crates/render/src/layout/tests.rs
table_fit supplies the dimensions used to draw tables. tables_cut identifies visible tables with omitted rows or columns, and table_cut_notice formats notices. Render tests compare fitted dimensions with painted dimensions.
Notices after table edits
crates/engine/src/cmd/layout/elements.rs, crates/engine/src/cmd/layout/update.rs, crates/engine/src/tests/layout_table.rs, docs/user-guide/layouts.md
Adding a table checks for clipping. Updating any table-fit property also checks for clipping, including when its value is null. Tests cover add and update notices; the guide describes when notices appear.
Notices in layout exports
crates/engine/src/cmd/layout/export.rs, crates/engine/src/tests/layout_table.rs
PNG, PDF, and SVG layout exports report clipped tables. PNG region rendering limits notices to elements that meet the requested region. Tests cover export aggregation, region rendering, and map-series behavior.
Notices in report exports
crates/engine/src/cmd/report.rs, crates/engine/src/tests/layout_table.rs
Report PNG and PDF exports check each layout page, label clipped tables with the layout name, and combine notices for multiple clipped tables. Tests cover multiple report layouts and streamed-layer data.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant LayoutExport
  participant Renderer
  participant TableCutDetection
  LayoutExport->>Renderer: Draw layout page
  LayoutExport->>TableCutDetection: Collect clipped tables
  TableCutDetection-->>LayoutExport: Return clipping results
  LayoutExport->>LayoutExport: Format and emit notice
Loading

Possibly related issues

  • opengeos/RustGIS#3409: The notices account for table options such as fields and textSize when detecting omitted columns and rows. The issue’s sorting and filtering objectives are not addressed.

Possibly related PRs

  • opengeos/RustGIS#3415: Adds table options such as fields, textSize, and header, which clipping checks use when reporting table updates.

Suggested reviewers: elpidioassinaturas, m-hollis-1, giswqs

Merge Risk: Low · up to d8e23

Layout tables that are cut off now produce notices on add, update, export and report. A table fed by a streamed layer may not give a notice in the layout view when its rows arrive later, and a notice could rarely be missed when two frames share a streamed layer. These are minor gaps and should not block merging.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: a layout table's box now gets a notice that says which rows and columns it leaves out. It uses the conventional fix(layout) prefix and fits the changeset, which adds t…
Description check Passed The description follows the template. It has a Summary that explains the change and why, a Testing section with new tests and full-check results, and a UI evidence section with before and after images…
Linked Issues check Passed Directly linked issue #3416 requires a notice when a layout table's box leaves out rows or columns, including columns chosen by fields (#3409). The PR covers these paths:
- layout.addElement calls…
Out of Scope Changes check Passed Each changed area supports the #3416 objective:
- elements.rs, update.rs, export.rs, and report.rs add the notice call sites for the required entry points.
- crates/render/src/layout/table.rs adds `Ta…
Full details: Title check

Explanation

The title names the main change: a layout table's box now gets a notice that says which rows and columns it leaves out. It uses the conventional fix(layout) prefix and fits the changeset, which adds table-cut notices across add, update, export and report paths.

Full details: Description check

Explanation

The description follows the template. It has a Summary that explains the change and why, a Testing section with new tests and full-check results, and a UI evidence section with before and after images. The Related issue section lists Closes #3416. The UI evidence images are referenced only as the placeholder text BEFORE and AFTER, and the template asks for real screenshots, but the section is still present and the change is explained. The description is mostly complete.

Full details: Linked Issues check

Explanation

Directly linked issue #3416 requires a notice when a layout table's box leaves out rows or columns, including columns chosen by fields (#3409). The PR covers these paths:

  • layout.addElement calls say_table_cut (crates/engine/src/cmd/layout/elements.rs) for an added table.
  • layout.update calls say_table_cut when a TABLE_FIT_KEYS key is present (crates/engine/src/cmd/layout/update.rs). The keys are w, h, rows, fields, textSize, header, layer, and visible.
  • PNG, region, PDF, SVG, and series exports report cut tables (crates/engine/src/cmd/layout/export.rs). A series reports once.
  • Report export reports once for all drawn layout pages, and names each table with its layout (crates/engine/src/cmd/report.rs).
  • tables_cut and table_cut_notice (crates/render/src/layout/table.rs) count cut rows and columns from table_fit. table uses the same table_fit for drawing, so the count matches the painted output.
  • Tests in crates/engine/src/tests/layout_table.rs and a render test a_tables_fit_is_what_it_draws cover add, update, exports, a region, a map series, and a two-layout report.
    The PR excludes cell text clipped to column width. #3416 does not require that case.
    Limits: the incremental diff since the previous reviewed head could not be read, and the current report.rs content was truncated. The latest report change (one combined notice) rests on the PR description and the change summary. Test results come from the PR description and were not re-run.
Full details: Out of Scope Changes check

Explanation

Each changed area supports the #3416 objective:

  • elements.rs, update.rs, export.rs, and report.rs add the notice call sites for the required entry points.
  • crates/render/src/layout/table.rs adds TableFit, table_fit, TableCut, tables_cut, and table_cut_notice. These implement the shared count and the notice text.
  • crates/render/src/layout.rs re-exports the new items. picture.rs changes notice_cut to pub(super). This visibility change lets the shared notice code be reused inside the layout module.
  • tests.rs and crates/engine/src/tests/layout_table.rs cover the new behavior.
  • docs/user-guide/layouts.md documents the Table frame notice.
    No change is unrelated to #3416. The PR adds no new command, parameter, or project field. Limits: the incremental diff could not be read, so this verdict relies on the change summary for the latest report-notice change.
Finishing Touches

Generate unit tests (beta)

  • 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

A rabbit counts the rows that fit,
Then checks the columns, bit by bit.
If boxes leave some cells unseen,
A notice marks the space between.
The pages print; the rows are clear,
And thumps of thanks ring far and near.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 3ac38d8e-45fd-4643-aa0a-f935d4232fdf
Commits

Reviewing files that changed from the base of the PR and between 7868f33 and d8e2364.

Files selected for processing: 4

  • crates/engine/src/cmd/layout/elements.rs
  • crates/engine/src/cmd/layout/export.rs
  • crates/engine/src/cmd/report.rs
  • crates/engine/src/tests/layout_table.rs

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

Comment thread crates/render/src/layout/table.rs Resolved
Comment thread crates/engine/src/cmd/layout/export.rs Resolved
Comment thread crates/engine/src/tests/layout_table.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Code review

Four inline comments are posted. Two are bugs, both about layers that are only partly loaded, and two are quality notes. There were no earlier review threads on this PR, so no earlier concerns were left alone.

Bugs

  • Windowed layers give a view-dependent row count (crates/render/src/layout/table.rs:73). A windowed layer's features hold only the part in view, but tables_cut treats them as the layer's rows. The "of N rows" notice then depends on the last view drawn, and can be missing for a layer that is cut. Confidence: medium (about 70%). I did not test this against a real streamed source.
  • Export counts before the render (crates/engine/src/cmd/layout/export.rs:82). The PNG, region and SVG paths count tables before drawing, while the series and report paths count after. A windowed layer can therefore produce a different notice for the same page, depending on the export format. Confidence: medium (about 60%).

Security

  • None found.

Performance

  • None found. tables_cut is linear in the layout's elements and adds no data copies.

Quality

  • Magic 300.0 dpi (crates/engine/src/cmd/layout/elements.rs:285). The counts don't depend on dpi, but nothing says so. Name the value and document why, or drop the parameter.
  • Misplaced test comment and repeated temp-dir setup (crates/engine/src/tests/layout_table.rs:318). The "placeholder" comment sits above the step that makes the table visible again. The three export tests also repeat the temp-dir setup and cleanup.

AGENTS.md

  • None found. Non-test code has no unwrap, expect or panic. Notices go through Session::warn. The user guide is updated. The fit is shared by the drawing and the count. Notices are tested both ways. No new command, parameter or saved field, so the schema and command-surface files don't change.

Checked

  • Add, update, PNG, region, SVG, PDF, series and report paths all call the same notice function.
  • The render and count paths use the same table_fit, and the ratios hold at the scales the tests check.
  • The TableLook copy and page_geometry clamping are consistent.

Change size

Compared: the whole PR against main (merge base f84ba87 to PR head 7868f33).

Measure Value
Files changed 10 (0 added, 10 modified, 0 removed, 0 renamed)
Size before 887.3 KB
Size after 905.9 KB
Total size change +18.6 KB
File Before After Change
crates/engine/src/tests/layout_table.rs 9.1 KB 18.8 KB +9.7 KB
crates/render/src/layout/table.rs 4.4 KB 8.6 KB +4.3 KB
crates/render/src/layout/tests.rs 467.0 KB 468.5 KB +1.6 KB
crates/engine/src/cmd/report.rs 80.1 KB 81.1 KB +1.1 KB
crates/engine/src/cmd/layout/elements.rs 75.3 KB 76.1 KB +0.8 KB
crates/engine/src/cmd/layout/export.rs 28.4 KB 29.2 KB +0.7 KB
crates/engine/src/cmd/layout/update.rs 47.4 KB 47.6 KB +0.2 KB
docs/user-guide/layouts.md 96.3 KB 96.5 KB +0.2 KB
crates/render/src/layout.rs 60.5 KB 60.6 KB +57 B
crates/render/src/layout/picture.rs 18.9 KB 18.9 KB +11 B

@jgregoriorincon
jgregoriorincon marked this pull request as draft November 30, 2026 10:12
@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

📖 Docs preview

Item Value
Preview https://preview.rustgis.app/pr-3439/
Web app https://preview.rustgis.app/pr-3439/app/
Commit d8e2364

GitHub Pages takes a minute or two to publish a new commit. Newer commits from the fork aren't published until a maintainer adds the preview label (once per commit).

Comment thread crates/engine/src/cmd/layout/update.rs Resolved
@github-actions

Copy link
Copy Markdown
Contributor

Code review

Scope: 10 files, +463 / −11 lines. The change adds notices saying how many rows and columns a layout table's box leaves out. The notices come from layout.addElement, layout.update, the PNG/region/PDF/SVG/series exports, and the report.

I checked that the counting code matches the drawing code, so a notice cannot disagree with the page:

  • tables_cut uses the same scale as the render path (k = page_geometry(...).2, ppp = k / PT_PER_MM), and the same rectangle as render (layout.rs:428-430, with the 1 px floor).
  • on_page, the frame lookup, the visible filter and the placeholder cases match the drawing code.
  • TableLook is Copy, so table_fit and asked_columns can reuse it.
  • Each export counts after drawing, and the count is taken from the layout still in s.project.layouts; it is not taken out during the render.
  • The report's say_report_tables(s, tables) moves tables inside the if !pdf block, which returns straight after, so the move is valid.
  • Every export and report path (PNG, region, PDF, SVG, series, report) calls tables_cut, and the notice is emitted only after a successful result.
  • The render crate changes are wasm-neutral: no std::time, unwrap, or threads.

Bugs

  • Off-page to on-page move gives no notice at add or update. x and y are not in TABLE_FIT_KEYS, so moving an off-page table onto the page through layout.update says nothing. The export still reports it, so the notice is late, not lost. Inline comment posted at update.rs:848. Confidence about 60%.

Security

  • None found.

Performance

  • None significant. tables_cut is O(elements) per call and runs once per page in a series or report.

Quality

  • Nit, not posted inline: say_table_cut (elements.rs:283-292) runs tables_cut over every table in the layout and then keeps only the one with id. Filtering by id first would be clearer and cheaper, and layout.update with w or h runs it on every call.

AGENTS.md

  • No breaks found. The notices go through s.warn, one notice per export or command. The docs were updated, no project field or command was added, and no schema or command-surface change was needed.

Earlier review threads

  • Four earlier threads exist. Two still apply and I did not re-post them: the windowed-layer row count in table.rs and the magic 300.0 in elements.rs (both still in the code).
  • One is fixed: the export now counts after the render, as the earlier concern asked.
  • One is outdated: the test comment and temp-directory helper. The Dir helper now exists, and the comment question is cosmetic.
  • I did not post any new concern that repeats an earlier thread.

Change size

Compared with main (merge base f84ba87 to PR head d8e2364).

Files changed Added Modified Removed Renamed
10 0 10 0 0
Measure Value
Size before 887.3 KB
Size after 908.9 KB
Total size change +21.6 KB
Path Before After Change
crates/engine/src/tests/layout_table.rs 9.1 KB 20.9 KB +11.9 KB
crates/render/src/layout/table.rs 4.4 KB 8.6 KB +4.3 KB
crates/render/src/layout/tests.rs 467.0 KB 468.5 KB +1.6 KB
crates/engine/src/cmd/report.rs 80.1 KB 81.4 KB +1.4 KB
crates/engine/src/cmd/layout/export.rs 28.4 KB 29.6 KB +1.1 KB
crates/engine/src/cmd/layout/elements.rs 75.3 KB 76.2 KB +0.9 KB
crates/engine/src/cmd/layout/update.rs 47.4 KB 47.6 KB +208 B
docs/user-guide/layouts.md 96.3 KB 96.5 KB +160 B
crates/render/src/layout.rs 60.5 KB 60.6 KB +57 B
crates/render/src/layout/picture.rs 18.9 KB 18.9 KB +11 B

@jgregoriorincon
jgregoriorincon marked this pull request as ready for review November 30, 2026 11:11
@github-actions

Copy link
Copy Markdown
Contributor

Code review

I checked the change against pr-context/AGENTS.md, the diff, and the surrounding code. I did not build or run the tests. Two earlier concerns are still open and I left them alone; three earlier threads are resolved and fixed, so I did not repeat them.

Bugs

No new bugs found. Two existing open threads still apply to the current code, so I did not repeat them:

  • table.rs tables_cut counts rows with ds.features.len(). On a windowed (read-in-place) layer that is the current view, not the layer's rows, so the notice depends on which view was drawn last. (Open thread, not outdated.)
  • update.rs TABLE_FIT_KEYS leaves out x and y. A table moved from off the page onto it is not re-checked, and the drag-move path in layoutview/interact.rs sends only x/y. (Open thread, not outdated; the author's replies did not address it.)

What I checked and found correct:

  • Draw and count share table_fit. The r rectangle (e.x*k, (e.w*k).max(1.0)) and ppp = k / PT_PER_MM match draw_page/table for full-page renders.
  • report.rs:1225: say_report_tables(s, tables) moves tables, but it sits inside the if !pdf branch before an early return, so it compiles and runs once.
  • Export counts run after drawing in every path: PNG, region, PDF, series (or_insert per table), SVG, and report PNG/PDF.

Security

None found. Layout and table names reach notices only through notice_cut, and nothing from the PR touches file or network input.

Performance

None significant. tables_cut is O(elements) and does not read layer features. The one nit is in Quality.

Quality

  • Nit (inline posted): say_table_cut runs tables_cut over the whole layout for any element update gives w/h/textSize, then keeps only id. Suggested a table guard. Confidence high.
  • On-screen gap (about 50%): ui-egui/src/layoutview.rs:456-464 re-says clipped text when the view redraws (text_warning). Tables have no equivalent, so a table cut by Undo/Redo, or by a windowed layer's view changing, is not said on screen. Exports still report it. The description calls this the same as legends and charts, so this may be intended. Worth a decision.
  • Undo/Redo (low): a Redo that re-applies a cutting resize says nothing, since only the original command says it.

AGENTS.md

No rule breaks found. I checked:

  • No unwrap/expect in non-test code.
  • Notices go through Session::warn, one per export, with counts.
  • Tests cover both lossy and clean inputs.
  • No wasm-incompatible calls (std::time).
  • No project or saved-field change, so no schema or command-surface update is needed.
  • docs/user-guide/layouts.md is updated.

Change size

Compared: the whole PR against main (merge base f84ba87 to PR head d8e2364).

Measure Value
Files changed 10 (0 added, 10 modified, 0 removed, 0 renamed)
Size before 887.3 KB
Size after 908.9 KB
Total size change +21.6 KB
Path Before After Change
crates/engine/src/tests/layout_table.rs 9.1 KB 20.9 KB +11.9 KB
crates/render/src/layout/table.rs 4.4 KB 8.6 KB +4.3 KB
crates/render/src/layout/tests.rs 467.0 KB 468.5 KB +1.6 KB
crates/engine/src/cmd/report.rs 80.1 KB 81.4 KB +1.4 KB
crates/engine/src/cmd/layout/export.rs 28.4 KB 29.6 KB +1.1 KB
crates/engine/src/cmd/layout/elements.rs 75.3 KB 76.2 KB +0.9 KB
crates/engine/src/cmd/layout/update.rs 47.4 KB 47.6 KB +0.2 KB
docs/user-guide/layouts.md 96.3 KB 96.5 KB +160 B
crates/render/src/layout.rs 60.5 KB 60.6 KB +57 B
crates/render/src/layout/picture.rs 18.9 KB 18.9 KB +11 B

@jgregoriorincon
jgregoriorincon added this pull request to the merge queue Nov 30, 2026
Merged via the queue into opengeos:main with commit 8bd8254 Nov 30, 2026
31 checks passed
@jgregoriorincon
jgregoriorincon deleted the fix/3416-layout-table-cut branch November 30, 2026 11:41
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.

[Bug]: A layout table leaves out the rows and columns its box doesn't hold without a word

1 participant