Skip to content

feat(renderer): add left/right option for Default Padding#497

Open
vishnujayvel wants to merge 2 commits into
sirmalloc:mainfrom
vishnujayvel:feat/padding-side-482
Open

feat(renderer): add left/right option for Default Padding#497
vishnujayvel wants to merge 2 commits into
sirmalloc:mainfrom
vishnujayvel:feat/padding-side-482

Conversation

@vishnujayvel

Copy link
Copy Markdown

Closes #482, requested by @riptscripts.

Summary

The Default Padding setting always applied to both the left and
right of each widget. This adds a defaultPaddingSide setting
(both / left / right) so padding can be narrowed to one side.

  • Both (left + right) — current behavior, still the default
  • Left only
  • Right only

Existing configs are unaffected — defaultPaddingSide defaults to
'both', so nothing changes unless you opt in.

Where it's applied

  • Standard (non-Powerline) rendering — renderStatusLine in
    src/utils/renderer.ts
  • Powerline rendering — renderPowerlineStatusLine in the same file
  • Alignment width accounting — calculateMaxWidthsFromPreRendered
    now counts only the side(s) actually applied, so Powerline
    auto-align columns stay correct when padding is one-sided

merge: 'no-padding' interactions are preserved: a side that's
already suppressed by a no-padding merge stays suppressed regardless
of the padding-side setting. Covered by regression tests in both
renderers (see Testing below).

UI

Exposed in the Global Overrides menu (src/tui/components/GlobalOverridesMenu.tsx),
next to Default Padding:

  Default Padding: " "  - Press (p) to edit
     Padding Side: Both  - Press (d) to cycle

Press (d) to cycle Both → Left only → Right only → Both. Available
in both standard and Powerline modes, matching how Default Padding
itself is already exposed in both modes.

Docs

Updated docs/USAGE.md (Default Padding & Separators section) to
describe the new option and keybinding.

Testing

bun run lint              # bun tsc --noEmit && eslint . --max-warnings=0 — clean
bun test                  # full suite green once known-flaky Ink timing tests settle

Added src/utils/__tests__/renderer-padding-side.test.ts covering:

  • default (both) behavior is unchanged
  • left/right in standard rendering
  • left/right in Powerline rendering
  • calculateMaxWidthsFromPreRendered width accounting for each side
  • merge: 'no-padding' takes precedence over the padding-side setting
    (no double-pad, correct glue) in both standard and Powerline mode,
    for both left and right

All assertions strip SGR codes before comparing (stripSgrCodes from
src/utils/ansi.ts), per repo convention (see renderer-flex-width.test.ts; the
separator-collapse tests strip SGR inline the same way) — chalk.reset() reacts to ambient
color-support (FORCE_COLOR/NO_COLOR), independent of the colorLevel
set on Settings, so an unstripped exact-string assertion would be
environment-dependent. Verified the new file passing under both
FORCE_COLOR=1 and NO_COLOR=1.

Added a GlobalOverridesMenu.test.ts case for the new (d) keybinding
(cycles both → left → right → both), mirroring the existing (m)
minimalist-mode toggle test pattern.

Also updated two pre-existing widget tests
(CurrentWorkingDir.test.ts, CustomCommand.test.ts) that construct
a full Settings object literal rather than spreading
DEFAULT_SETTINGS — they needed the new required field added, same
as any other defaulted Settings field.

Full-suite runs are noisy independent of this change: a handful of
Ink stdin-timing tests (e.g. PowerlineThemeSelector, InstallMenu,
occasionally a GlobalOverridesMenu gradient-selector case,
fetchUsageData's error-handling timer case) flake under full-suite
parallel load but pass individually. Confirmed by running the full
suite twice on a clean, unmodified main checkout (via git stash) —
different tests flaked each time, none of them touching padding or
Settings. Every test file this PR touches passes consistently in
isolation.

Notes

No CURRENT_VERSION/migration bump needed — defaultPaddingSide is
a new field with a Zod .default('both'), the same pattern used for
gitCacheTtlSeconds, minimalistMode, and excludeFromAutoAlign
(none of which bumped the version either).


🤖 Drafted with Claude Code; reviewed and submitted by a human.

The Default Padding setting always applied to both sides of a widget.
Add a defaultPaddingSide setting (both/left/right, default both) so
padding can be narrowed to one side without affecting the other,
matching the request in sirmalloc#482.

Both the standard and Powerline renderers honor the new option, and
alignment width accounting (calculateMaxWidthsFromPreRendered) counts
only the sides that are actually applied. Existing configs are
unaffected: defaultPaddingSide defaults to 'both', preserving current
rendering exactly.
…TUI cycle

Independent review found the padding-side tests asserted exact strings
against chalk-wrapped padding output, which breaks under FORCE_COLOR=1
since chalk.reset() reacts to ambient color support, not the Settings
colorLevel used elsewhere in the file. Strip SGR codes before every
assertion, matching the repo's existing convention (stripSgrCodes in
renderer-flex-width.test.ts and the separator-collapse tests). Verified
passing under both FORCE_COLOR=1 and NO_COLOR=1.

Also add the two coverage gaps called out in review:
- merge:'no-padding' regression tests (standard + Powerline) proving no
  double-pad and correct glue across a no-padding merge boundary for
  both the 'left' and 'right' padding sides.
- a GlobalOverridesMenu TUI test for the (d) cycle, mirroring the
  existing (m) minimalist-mode pattern.
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.

Feature request: Default Padding — option for left-only or right-only

1 participant