Skip to content

fix(render): DPI-scale terminal padding and border offsets#240

Merged
forketyfork merged 3 commits intomainfrom
fix/dpi-scale-terminal-padding-border
Feb 23, 2026
Merged

fix(render): DPI-scale terminal padding and border offsets#240
forketyfork merged 3 commits intomainfrom
fix/dpi-scale-terminal-padding-border

Conversation

@forketyfork
Copy link
Owner

Summary

A recent PR increased border thickness and made it DPI-aware. Two layout bugs followed in grid view on Retina displays.

The CWD bar (current directory display) was overlapping the bottom border. reservedHeight() and renderCwdBar() both read the raw grid_border_thickness constant (6 logical px) without scaling it, so on 2x displays the bar ended up positioned too high by the scaling difference.

The border was also drawing over terminal content. terminal_padding = 8 is a logical pixel value but was used as raw physical pixels throughout renderSessionContent, terminalContentRect, and the session interaction hit-testing path. On 2x Retina the DPI-scaled border is 12px, which exceeds the 8px padding, so the border ate into the content area.

Both are fixed by applying dpi.scale() where the raw constants were used. For terminal padding, ui_scale is now threaded through to renderSessionContent and terminalContentRect in both renderer.zig and session_interaction.zig.

Test plan

  • In grid view on a Retina (2x DPI) display, verify the CWD bar sits flush inside the border with no overlap at the bottom edge
  • Verify terminal text is not obscured by the border on any edge
  • Check on a 1x display to confirm no regression (padding should remain visually equivalent)

Issue: After border thickness was increased and DPI-scaled in a recent PR, two layout bugs showed up in grid view on Retina displays: the CWD bar overlapped the bottom border, and the border drew over terminal content.

Solution: The CWD bar used the raw grid_border_thickness constant (6 logical px) instead of the DPI-scaled value, so on 2x displays its position was wrong by exactly that difference. Fixed by applying dpi.scale() to the border thickness in reservedHeight() and renderCwdBar(). The terminal_padding constant (8px logical) was also used as raw physical pixels in renderSessionContent, terminalContentRect, and the session interaction hit-testing path. On 2x Retina, the DPI-scaled border (12px) exceeded the unscaled padding (8px), so the border drew over terminal content. Fixed by threading ui_scale through to renderSessionContent and terminalContentRect and applying dpi.scale() to terminal_padding.
@forketyfork forketyfork requested a review from Copilot February 23, 2026 14:31
@forketyfork forketyfork marked this pull request as ready for review February 23, 2026 14:31
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes DPI-scaling issues in grid view rendering by ensuring border thickness and terminal padding are treated as logical units and scaled to physical pixels via dpi.scale().

Changes:

  • DPI-scale grid_border_thickness usage in CWD bar layout so it no longer overlaps the bottom border on Retina displays.
  • DPI-scale terminal_padding in terminal content rendering and terminal content rect calculation.
  • Thread ui_scale into renderSessionContent / terminalContentRect call paths (renderer + session interaction scrollbar context).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/ui/components/session_interaction.zig Scales terminal content rect padding for scrollbar layout (now takes ui_scale).
src/ui/components/cwd_bar.zig Scales grid border thickness when reserving height and positioning the CWD bar.
src/render/renderer.zig Scales terminal padding during content rendering and content-rect computation; threads ui_scale into rendering.
Comments suppressed due to low confidence (1)

src/render/renderer.zig:377

  • renderSessionContent now uses DPI-scaled terminal_padding, but term_cols/term_rows appear to be computed elsewhere using the unscaled constant. On high-DPI displays this will make term_cols/term_rows larger than what fits in drawable_w/drawable_h, causing the right/bottom of the terminal to be clipped (since visible_cols/rows are capped by max_*_fit). Consider updating the terminal sizing / PTY pixel size calculations to use dpi.scale(terminal_padding, ui_scale) (or threading ui_scale into those helpers) so sizing and rendering stay consistent.
    const padding: c_int = dpi.scale(terminal_padding, ui_scale);
    const drawable_w: c_int = rect.w - padding * 2;
    const drawable_h: c_int = rect.h - padding * 2;
    if (drawable_w <= 0 or drawable_h <= 0) return;

    const origin_x: c_int = rect.x + padding;
    const origin_y: c_int = rect.y + padding;

    const max_cols_fit: usize = @intCast(@max(0, @divFloor(drawable_w, cell_width_actual)));
    const max_rows_fit: usize = @intCast(@max(0, @divFloor(drawable_h, cell_height_actual)));
    const visible_cols: usize = @min(@as(usize, term_cols), max_cols_fit);
    const visible_rows: usize = @min(@as(usize, term_rows), max_rows_fit);

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 774020911e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Issue: Three review comments on #240 identified that the original fix left raw terminal_padding in terminal PTY sizing (layout.zig) and full-view mouse hit-testing (session_interaction.zig), causing the renderer and these paths to disagree about the content area on high-DPI displays.

Solution: Threaded ui_scale through calculateTerminalSize, calculateGridCellTerminalSize, calculateTerminalSizeForMode, and applyTerminalResize in layout.zig so PTY dimensions and pixel sizes match what the renderer actually draws. Updated fullViewCellFromMouse and fullViewPinFromMouse to use the same DPI-scaled padding, so clicks near the border resolve to the correct cell on Retina displays.
@forketyfork forketyfork merged commit e959b49 into main Feb 23, 2026
4 checks passed
@forketyfork forketyfork deleted the fix/dpi-scale-terminal-padding-border branch February 23, 2026 14:52
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.

2 participants