Skip to content

fix(dashboard): scale preview terminal font instead of CSS transform - #13103

Closed
brennanb2025 wants to merge 2 commits into
mainfrom
brennanb2025/preview-font-scale-blur
Closed

brennanb2025 wants to merge 2 commits into
mainfrom
brennanb2025/preview-font-scale-blur

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes a standing blur in the agent terminal preview. (Correction: an earlier revision of this description attributed the Aug 7 field screenshot to this surface — that screenshot is a regular split pane, and its blur is still under investigation. This PR stands on its own: the preview's claim-denied path has always rendered smeared.) When the PTY grid is owned elsewhere (the live pane in the worktree, a phone), AgentTerminalPreview correctly keeps the source cols/rows (replaying serialized ANSI into different dimensions rewraps into garbage) but shrank the whole rendered terminal with transform: scale(<1) — resampling every glyph into smear. Measured signature of the CSS-scaled path: stretched character advance with lumpy resampled edges versus the crisp floored-advance rendering of an unscaled terminal.

The preview now shrinks the font size instead: same grid (no rewrap), glyphs rasterize natively at the final size. A residual CSS transform remains only for the sliver the half-px font step cannot express (≤2%, imperceptible) and below a 4 px readability floor. The base font is restored when the box grows or the grid claim succeeds, and the settings-appearance effect re-runs the fit after it rewrites fontSize. Fit-scale planning lives in a pure module (preview-terminal-fit-scale.ts) with a measure→apply→measure oscillation guard; the fit/anchor logic moved to preview-terminal-fit.ts (also keeps the component under its max-lines cap). Cursor anchoring behavior is unchanged.

Screenshots

Visual before/after on a live claim-denied preview is owed at review time (needs a grid owned by a live pane). The fix makes the preview rasterize at the final size, which removes the resample step entirely.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test — targeted: full src/renderer/src/components/dashboard-popout/ suite (207 tests) green locally; full suite left to CI
  • pnpm build — left to CI
  • Added or updated high-quality tests that would catch regressions: 7 planner tests (fits-already, full shrink expressed as font, sub-step residual, never-above-base restore, oscillation hold within tolerance, min-font transform fallback, degenerate-measure inertness); Terminal mock now models the live options bag the fit path reads/writes

AI Review Report

Reviewed by the implementing agent. Main risks checked: (1) rewrap — cols/rows are never touched; only fontSize changes, which re-renders cells without reflowing the buffer; (2) oscillation — the planner holds the current font within a 2% tolerance and rounds to half-px steps, so measure→apply→measure settles in one pass with the residual transform absorbing rounding; (3) appearance-settings clobber — the appearance effect rewrites fontSize from settings, so it now re-schedules the fit through a ref (nulled on unmount); (4) restore path — when the box grows or createPreviewGridClaim resizes the terminal to fit, the plan clamps back to the settings base font and drops the transform; (5) anchor math — cursor anchoring uses the residual scale against post-font-change measurements, preserving the top/bottom anchoring contract. Cross-platform: renderer-only, DOM renderer (the preview never takes WebGL), no shortcuts/labels/paths/shell/Electron platform differences; fractional CSS font sizes render fine on macOS/Linux/Windows.

Security Audit

Renderer-internal layout logic only. No input handling, command execution, path handling, auth, secrets, dependency, or IPC changes.

Notes

When the PTY grid is owned elsewhere (live pane, phone), the agent terminal
preview keeps the source cols/rows and shrank the whole rendered terminal
with transform: scale(<1) — resampling every glyph into visible smear (the
'Orca text is blurry' reports; measured advance 8.4 vs the crisp 8.0 in the
same screenshot). Shrink the font size instead: same grid, no rewrap, glyphs
rasterize natively at the final size. A residual transform remains only for
the sliver the half-px font step cannot express and below the 4px floor.
The base font is restored when the box grows or the grid claim succeeds,
and the appearance effect re-runs the fit after rewriting fontSize.
@coderabbitai

coderabbitai Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a preview terminal fit-scale planner that adjusts font size and residual CSS scaling. Adds a scheduler that validates measurements, remeasures after font changes, anchors the terminal based on cursor visibility, and coalesces requests with requestAnimationFrame. Normalizes grid claims with base-font metrics. Updates AgentTerminalPreview to use the scheduler and rerun fitting after appearance changes. Updates terminal mocks and adds coverage for fitting and grid-claim behavior.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly and concisely describes the primary change: scaling the preview terminal font instead of using a CSS transform.
Description check ✅ Passed The description covers the change, testing, review, security, platform compatibility, and risks, while clearly documenting deferred full tests and build.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Electron QA on exact HEAD f635f88d2716e787fdd894f6b090ffca4707f2c7 passed through the repo-required agent-browser CDP flow.

Claim-denied path:

  • Kept the source pane visible and reclaimed at 144×58 with configured font size 14px.
  • Narrow preview preserved 144×58, reduced its rendered font to 9.5px, and left the fit host transform empty (getComputedStyle(...).transform === "none").
  • Smaller preview settled at 5px with the same 144×58 PTY grid and no transform.
  • Enlarging settled back to 10.5px, still 144×58 and transform-free.
  • No page errors or preview-related console errors.

Source pane owning the wide grid:

source pane

Claim-denied preview, crisp via font fitting:

claim-denied preview

Smaller settled preview:

smaller preview

Restored larger preview:

restored preview

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Closing without merging, deliberately. Post-review reality check: this fix was motivated by a field screenshot that turned out to be a different bug entirely (a normal pane with a stale-dpr canvas backing — fixed and merged as #13159). With that attribution corrected, this PR has zero field reports behind it, and the transform-scale fallback it fixes only engages when the preview's grid claim is denied — in practice a phone-paired PTY or a mid-dialog host reclaim, since the claim machinery parks even a live pane and renders the dialog 1:1 crisp in normal desktop use. The mechanism was never reproduced under real usage.

The branch (brennanb2025/preview-font-scale-blur) stays. Reopen criteria: a report of smeared text in the agent terminal dialog while the PTY grid is owned elsewhere (most plausibly a phone-paired agent), at which point the fix must first be validated against a real reproduction of that state — the planner unit tests here verify the math, not the trigger.

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