Skip to content

feat(staged): warn when pikchr elements extend beyond diagram bounds#872

Merged
matt2e merged 1 commit into
mainfrom
out-of-bounds-diagram-warning
Jul 9, 2026
Merged

feat(staged): warn when pikchr elements extend beyond diagram bounds#872
matt2e merged 1 commit into
mainfrom
out-of-bounds-diagram-warning

Conversation

@matt2e

@matt2e matt2e commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

The generate_pikchr preview analysis only flagged overlapping elements, so text laid out wider than Pikchr's own width estimates could spill past the diagram edge and get clipped without the inner specialist session ever hearing about it.

  • Extend the preview's layout analysis to compare every box and label rectangle against the diagram's drawing area (the 0-origin viewBox), reusing the same per-kind hairline thresholds as overlap detection so font-metric noise isn't flagged.
  • Report out-of-bounds elements in the preview summary with per-edge overhang distances plus repair advice.
  • Generalize the sub-session repair loop's overlap prompt into a layout-warning prompt so it re-prompts on out-of-bounds warnings exactly like overlap warnings.

Testing

  • Unit tests for the out-of-bounds detector, summary rendering, and preview flag.
  • A sub-session test that repairs an out-of-bounds render, using a negative-margin fixture whose box geometry crosses the canvas edge independent of host fonts.

🤖 Generated with Claude Code

The generate_pikchr preview analysis only flagged overlapping elements,
so text laid out wider than Pikchr's own width estimates could spill
past the diagram edge and get clipped without the inner specialist
session ever hearing about it.

Extend the preview's layout analysis to also compare every box and
label rectangle against the diagram's drawing area (the 0-origin
viewBox), reusing the same per-kind hairline thresholds as overlap
detection so font-metric noise isn't flagged. Out-of-bounds elements
are reported in the preview summary with per-edge overhang distances
plus repair advice, and the sub-session repair loop now re-prompts on
them exactly like overlap warnings via a generalized layout-warning
prompt.

Covered by unit tests for the detector, summary, and preview flag, and
a sub-session test that repairs an out-of-bounds render (via a
negative-margin fixture whose box geometry crosses the canvas edge
independent of host fonts).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Matt Toohey <contact@matttoohey.com>
@matt2e matt2e requested review from baxen and wesbillman as code owners July 9, 2026 05:25
@matt2e matt2e merged commit 0d07332 into main Jul 9, 2026
4 checks passed
@matt2e matt2e deleted the out-of-bounds-diagram-warning branch July 9, 2026 06:53
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.

1 participant