Skip to content

fix(layout): correct straight-edge 1-char misalignment#10

Merged
cristipufu merged 4 commits intomainfrom
fix/straight-edge-centering
Feb 9, 2026
Merged

fix(layout): correct straight-edge 1-char misalignment#10
cristipufu merged 4 commits intomainfrom
fix/straight-edge-centering

Conversation

@cristipufu
Copy link
Member

@cristipufu cristipufu commented Feb 9, 2026

Summary

  • fix(layout): Replace int(desired - w/2) with round(desired) - w // 2 in all 3 coordinate assignment phases. Rounds the desired center to an integer first, then offsets by w // 2 — matching how Box.cx (x + w // 2) computes the connector position. The old int() truncation biased odd-width boxes 1 char left, causing visible misalignment in linear chains with mixed even/odd box widths.
  • fix(renderer): Size canvas to fit edge labels that extend past the rightmost box, preventing clipping.
  • feat: Add book-writer-agent sample (6-node linear chain that exposed the layout bug) and regenerate all screenshots.
  • chore: Bump to v0.1.5, update benchmarks in README.

Test plan

  • uv run pytest tests/ -v — all 82 tests pass
  • uv run graphtty samples/book-writer-agent/graph.json__end__ edge centered
  • uv run graphtty samples/function-agent/graph.json — no regression
  • uv run ruff format . && uv run ruff check --fix . — clean
  • uv run ty check — clean

🤖 Generated with Claude Code

cristipufu and others added 4 commits February 9, 2026 14:13
Round the desired center to an integer first, then subtract w // 2, to
match how Box.cx computes the connector position (x + w // 2). The old
int(desired - w/2) truncated toward zero, biasing odd-width boxes 1 char
left of their parent's visual center.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@cristipufu cristipufu force-pushed the fix/straight-edge-centering branch from 0ca162a to e2f6cad Compare February 9, 2026 12:13
@cristipufu cristipufu merged commit 5486549 into main Feb 9, 2026
7 checks passed
@cristipufu cristipufu deleted the fix/straight-edge-centering branch February 9, 2026 12:14
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