---
id: TASK-12
title: 'Add inner padding to the sources, articles, and reader panes'
status: Done
assignee:
  - '@ross'
created_date: '2026-06-29 19:59'
updated_date: '2026-06-29 20:58'
labels:
  - rust
  - ui
dependencies:
  - TASK-11
documentation:
  - docs/tui_research.md
priority: medium
ordinal: 12
---

## Description

<!-- SECTION:DESCRIPTION:BEGIN -->
The three TUI panes render text flush against their borders. Add a small inner margin between each pane's border and its content for breathing room - roughly one cell of horizontal padding (~6px), with a modest top/bottom inset. Keep the existing line height/spacing of body text unchanged. In ratatui this is the bordered Block's padding (Padding) or an inset inner Rect, applied consistently to all three panes (sources, articles, reader).
<!-- SECTION:DESCRIPTION:END -->

## Acceptance Criteria
<!-- AC:BEGIN -->
- [x] #1 The sources, articles, and reader panes inset their content from the borders with horizontal padding of about one cell, giving visible breathing room.
- [x] #2 Body-text line height/spacing is unchanged.
- [x] #3 Padding is applied consistently across all three panes.
<!-- AC:END -->

## Implementation Plan

<!-- SECTION:PLAN:BEGIN -->
1. Add a consistent inner Padding to all three panes via the shared column_block() Block (Padding::uniform(1): ~1 cell horizontal + modest 1-row top/bottom inset). This covers AC#1 and AC#3 in one place; the empty-state Paragraphs reuse the same block so they inset too.
2. Fix draw_reader scroll-clamp math: derive the true content rect from block.inner(area) (accounts for border AND padding) instead of the hardcoded saturating_sub(2), so reader_scroll stays correct with padding.
3. Body text keeps single-line spacing — padding only insets the content rect, no inter-line gaps (AC#2).
4. Tests: add/adjust a TestBackend assertion that content is inset from the border; run fmt + clippy -D warnings + test, 10x for stability; watch CI green.
<!-- SECTION:PLAN:END -->

## Implementation Notes

<!-- SECTION:NOTES:BEGIN -->
Implemented via a single Padding::uniform(1) on the shared column_block() — 1 cell horizontal + a 1-row top/bottom inset, applied to all three panes (AC#1, AC#3). Body text keeps single-line spacing; padding only insets the content rect (AC#2). Fixed draw_reader's scroll-clamp + draw()'s reader_width to derive geometry from block.inner(area) (border + padding) instead of hardcoded area-2, so scroll bounds and pre-fetched image width stay correct under padding. Added regression test panes_inset_content_from_their_borders (verifies the inset at the exact border/padding/content columns of all three panes). fmt + clippy -D warnings clean; 55 tests pass, stable 10/10. Updated docs/architecture.md (layout + reader-scroll notes).

Refinement (user feedback): reduce top/bottom inset by 50%. Terminal padding is whole-cell only, so halving 1→0.5 isn't representable; dropped top/bottom to 0, keeping the one-cell horizontal padding (Padding::horizontal(1)). Updated regression test (content now starts on row 1, just below the top border) and docs/architecture.md. fmt + clippy clean; 55 tests pass, stable 10/10.
<!-- SECTION:NOTES:END -->

## Final Summary

<!-- SECTION:FINAL_SUMMARY:BEGIN -->
Added consistent horizontal padding to all three TUI panes via the shared column_block() (Padding::horizontal(1)), so content no longer sits flush against the borders. Per review the top/bottom inset was dropped to 0 (terminal padding is whole-cell only, so a 50% reduction of one cell rounds to none). Reworked the reader's wrapped-height scroll clamp and the pre-fetch reader_width to derive geometry from block.inner(area) — which accounts for border AND padding — instead of a hardcoded area-2, so both stay correct as padding changes. Body-text line spacing is unchanged. Verified: cargo fmt --check, clippy --all-targets -D warnings, 55 tests pass (incl. new regression test panes_inset_content_from_their_borders), stable 10/10, CI green on the branch. docs/architecture.md updated in the same commits.
<!-- SECTION:FINAL_SUMMARY:END -->
