Files
pxpipe/scripts
teamchong 5c2f303cfd Fix Python padding bug: single-column images now tight-bound
src/proxy.py:125 was computing image height as
  tallest = max(lines_per_col, last_col_lines) if c_needed == 1 else lines_per_col

The max(lines_per_col, ...) made every single-column render pad to the
full MAX_EDGE=1568 canvas height regardless of content, wasting ~99% of
the image-token budget for small prompts.

Fix: tight-bound the single-column case.
  tallest = max(1, last_col_lines) if c_needed == 1 else lines_per_col

Multi-column (c_needed > 1) is unchanged — all earlier columns must be
lines_per_col tall to fit them, so the image must be too.

Measured impact (scripts/visual_compare.py):

  sample          before          after           change
  -----------     ------------    ------------    -----------
  17 chars        241x1568        241x14          -99% pixels
  176 chars       241x1568        241x42          -97% pixels
  885 chars       241x1568        241x315         -80% pixels

Verified edge cases hold:
  - empty/short text: still gated by MIN_COMPRESS_CHARS
  - 5000-char single line: 241x441 (63 wrapped lines, tight)
  - 80-char boundary: 241x14 (2 lines, tight)
  - 500-line multi-column: 731x1568 (unchanged, correctly padded)
  - 20KB realistic system prompt: 68.5% savings (matches existing 65-73%)

Added scripts/visual_compare.py to inspect Python vs Rust renderings
side-by-side with labels and dimensions.

This is the immediate win that's independent of the Rust rewrite — every
proxied request gets fewer image tokens starting at the next proxy restart.
2026-05-18 11:58:04 -04:00
..