Skip to content

fix(powerline): keep Default Padding across the Powerline toggle, and report font install results correctly - #821

Open
eric-engberg wants to merge 8 commits into
sirmalloc:mainfrom
eric-engberg:fix/powerline-setup
Open

eric-engberg wants to merge 8 commits into
sirmalloc:mainfrom
eric-engberg:fix/powerline-setup

Conversation

@eric-engberg

Copy link
Copy Markdown
Contributor

What

Three fixes in Powerline Setup. A fourth, keeping a Custom theme across the Powerline toggle, reached main as #793 and is gone from this diff.

  • Default Padding. Turning Powerline off puts back the Default Padding it replaced when it was turned on. Before, a plain line came back as Model | Ctx after trying Powerline, whatever the padding had been, including none on a fresh install.
  • Font install message color. A font install that worked shows its message in green on Windows too. Before, Windows showed "Installed N Powerline fonts..." in red, the error color.
  • Font install errors. A font install that fails because GitHub can't be reached (offline, a proxy, a firewall) shows git's own error and the manual install link. Before, it said "Git is required to install Powerline fonts. Please install Git and try again." even with git installed.

Why

Default Padding. Turning Powerline on sets defaultPadding to ' ', so segment text doesn't touch the arrows. That part is deliberate, and an existing test asserts it. But the (t) branch that turns Powerline off only set enabled: false, and nothing recorded the earlier value. On main, enabling then disabling the way (t) does gave:

Default Padding before after on after off
unset (fresh install) " " " "
"" " " " "
" " " " " "

The confirmation shown when Powerline is turned on mentions only separators, and with no manual separators there is no confirmation at all.

Font install message color. Powerline Setup picked the color with fontInstallMessage.includes('success') ? 'green' : 'red'. The macOS and Linux message says "installed successfully". The Windows one, Installed ${installedCount} Powerline fonts. Please restart your terminal and select a Powerline font from your terminal settings., doesn't. The app passed on only result.message and dropped result.success, so the screen could only guess from the wording. Not run on Windows: the code path shows it.

Font install errors. The installer's catch block treated any error whose text contained git as git missing. execFileSync's error for a failed clone always starts with Command failed: git clone ..., so every clone failure matched. With a stand-in git first on PATH that fails a clone the way git does offline (exit 128, fatal: unable to access 'https://github.com/powerline/fonts.git/': Could not resolve host: github.com), installPowerlineFonts() on main returned {"success":false,"message":"Git is required to install Powerline fonts. Please install Git and try again."} under both Bun 1.4.2 and Node 26.10.0. The error it caught had no code, status 128, and git's output in stderr. With git really missing, the error has code: 'ENOENT' and path: 'git' on both runtimes (Node: spawnSync git ENOENT; Bun: Executable not found in $PATH: "git"). Only that case means Git isn't installed. The manual install link was in the other message, so it was hidden too.

How

  • PowerlineConfig gets an optional paddingToRestore. buildEnabledPowerlineSettings stores the padding it replaces there, with an unset padding stored as '' (they render the same). A new buildDisabledPowerlineSettings, used by (t), turns Powerline off. It puts that padding back while Default Padding is still the ' ' that turning on set, and always drops paddingToRestore. A padding changed while Powerline was on is the user's own choice and stays. One line in docs/USAGE.md under Default Padding & Separators says so.
  • The app keeps the whole install result (FontInstallResult, now the return type of installPowerlineFonts) instead of only its message. Powerline Setup's fontInstallMessage prop takes that result, and getFontInstallMessageColor picks green or red from success.
  • installPowerlineFonts: show "Git is required..." only for an ENOENT on starting git. Every other failure gets the existing "Failed to install Powerline fonts: ... You can manually install fonts from: https://github.com/powerline/fonts" message. It now shows one line that says why, rather than the whole command line, temp folder path and output. That is the first fatal: or error: line git wrote to stderr, or else the first stderr line that doesn't name the temp folder git clones into. That skips git's Cloning into '<temp folder>'... progress line in any language. git translates that line and its fatal: prefix (Chinese: 正克隆到 '<temp folder>'... and 致命错误:; French: Clonage dans '<temp folder>'... and fatal : ), but every translation quotes the folder, so the check doesn't depend on git's wording. If a signal stopped the command, the message says so instead, as in "git was stopped by SIGKILL". An install.sh failure is shown the same way. No period is added after a line that already ends a sentence. The existing test "removes its folder when the clone fails" now fails the clone the way a missing git does, since a plain error no longer means git is missing.

Left as is:

  • Turning Powerline on still sets Default Padding to ' ', also over a padding the user chose. Turning it off now puts that padding back.
  • Settings saved with Powerline on before this change have nothing remembered, so turning Powerline off keeps ' ', as before.
  • After a round trip from an unset padding, settings.json has "defaultPadding": "" instead of no key. Both render the same, and Global Overrides shows (none) for both.
  • Manual separators removed when Powerline is turned on still don't come back when it's turned off (Enabling Powerline mode permanently deletes manual separators #531, fix(powerline): keep manual separators when toggling Powerline on and off #713).
  • On a Mac without the Command Line Tools, /usr/bin/git is a stub that fails instead of being missing, so that case doesn't get "Git is required...". It shows the stub's first line instead, "xcode-select: note: No developer tools were found, requesting install.", which gives the cause.
  • git's line is in the language git runs in, while the rest of the message is in English. The clone doesn't set LC_ALL=C to make it English: the folder check finds git's reason in any language without it, git's reason in the user's own language says why just as well, and LC_ALL would override every locale setting for git, not only its messages. In another language the fatal:/error: preference doesn't match, so the first line after the progress line is shown. That is git's error itself, or a line before it that says why, such as GitHub's remote: Repository not found.

Overlap with open upstream PRs: #718 also changes src/utils/powerline.ts and conflicts with this one. #739 changes it too and merges cleanly with it.

Demo

The Windows message color isn't recorded: it shows only on Windows, and the demo kit records on macOS and Linux. On those, the success message already says "successfully", so it looks the same before and after.

Default Padding. Plain: the plain line with no Default Padding, as on a fresh install. (t) turns Powerline on, (t) turns it off, then Global Overrides. Powerline: the same line after Powerline was turned on by this branch, so the settings remember no padding (main ignores that key). (t) turns Powerline off, then Global Overrides. Before, the plain line comes back as Model: Claude | Ctx: 18.6k ... and Default Padding reads " ". After, it is Model: Claude | Ctx: 18.6k ... and Default Padding reads (none).

Powerline

Before:

Default Padding after turning Powerline off, Powerline, before the fix

After:

Default Padding after turning Powerline off, Powerline, after the fix

Plain

Before:

Default Padding after turning Powerline on and off, plain, before the fix

After:

Default Padding after turning Powerline on and off, plain, after the fix

Font install with GitHub out of reach. Recorded with the stand-in git first on PATH, whose clone fails like git's does offline and which passes every other command to the real git, and with HTTPS_PROXY pointed at a closed port. Nothing is downloaded or installed. (i), then Yes. Before: "Git is required to install Powerline fonts. Please install Git and try again." After: "Failed to install Powerline fonts: fatal: unable to access 'https://github.com/powerline/fonts.git/': Could not resolve host: github.com. You can manually install fonts from: https://github.com/powerline/fonts".

Powerline

Before:

Offline font install, Powerline, before the fix

After:

Offline font install, Powerline, after the fix

Plain

Before:

Offline font install, plain, before the fix

After:

Offline font install, plain, after the fix

Testing

  • 2026-11-05: merged with main after fix(powerline): keep the Custom theme when Powerline is enabled again #793 made the Custom-theme fix there. This branch now keeps fix(powerline): keep the Custom theme when Powerline is enabled again #793's code and test for it; its own test that turns Powerline on, off and on again with a Custom theme still checks the theme along with the padding, and passes on main for the theme part.
  • On main as of 2.2.34 (0c94df7): it merges cleanly. bun run lint is clean, and bun test on Linux CI gives 4424 pass, 0 fail (4403 on main). The built CLI under Bun 1.4.4 and Node 26.13.0 agrees across runtimes and matches main in plain and Powerline mode, and the TUI opens and exits cleanly under both. It adds no JavaScript or Node API newer than Node 14, the build's target.
  • 20 new tests: 4 in powerline-settings.test.ts, 7 in PowerlineSetup.test.ts and 9 in powerline-install.test.ts. All 20 fail on main. On main, PowerlineSetup.test.ts doesn't load, because getFontInstallMessageColor doesn't exist there. With that one test skipped, the other 6 fail one by one. "keeps a default padding changed since Powerline was turned on" fails on main only because the remembered padding isn't dropped, since main keeps a changed padding too. bun run lint is clean.
  • The new Ink tests passed 20 runs in a row, 24 runs at 8 in parallel, and 5 runs under Node vitest. Each waits for its key's effect, on screen or in the update it sends, never a fixed delay.
  • Node 26.10.0 vitest on the three changed test files: powerline-settings.test.ts (8) and PowerlineSetup.test.ts (15) pass. Every test in powerline-install.test.ts fails on main (2 of 2) and on this branch (11 of 11) with the same existing ESM spy error (vi.spyOn(os, 'homedir'): Cannot spy on export "homedir"). With that line removed locally, all 11 pass under Node.
  • installPowerlineFonts() end to end under Bun 1.4.2 and Node 26.10.0, with stand-in gits first on PATH: the offline one gives the message above. One that prints the macOS stub's three lines (as they appear in this Mac's system libraries) and exits 1 gives "Failed to install Powerline fonts: xcode-select: note: No developer tools were found, requesting install. You can manually install fonts from: https://github.com/powerline/fonts". One that prints Cloning into '<temp folder>'... and kills itself with SIGKILL gives "Failed to install Powerline fonts: git was stopped by SIGKILL. You can manually install fonts from: https://github.com/powerline/fonts". Two that print the offline failure as git does in Chinese (正克隆到 '<temp folder>'..., then 致命错误:无法访问 'https://github.com/powerline/fonts.git/':Could not resolve host: github.com) and in French (Clonage dans '<temp folder>'..., then fatal : impossible d'accéder à 'https://github.com/powerline/fonts.git/' : Could not resolve host: github.com) give "Failed to install Powerline fonts: 致命错误:无法访问 'https://github.com/powerline/fonts.git/':Could not resolve host: github.com. You can manually install fonts from: https://github.com/powerline/fonts" and the same with the French line. This Mac's git (Apple Git 2.50.1) is built without translations, so these are stand-ins, not a translated git. With git missing from PATH, both runtimes still return "Git is required...".
  • The built CLI renders the same as main in plain and Powerline mode under Bun 1.4.2 and Node 26.10.0, and both runtimes agree. The TUI opens and exits cleanly under both.

…ack on

Turning Powerline off and on again in Powerline Setup replaced a Custom
theme with Nord Aurora. Nord Aurora's colors then drew over every
widget's own colors, in the preview and in the status line, until the
user went back to Themes and picked Custom again.

Turning Powerline on gave the default theme to an unset theme and to
'custom' alike, treating both as the first time Powerline is enabled.
An unset theme covers that case, since the settings default is no
theme. 'custom' is only set when the user picks Custom, or copies a
theme's colors onto the widgets with (c)ustomize, so it is now kept.
… off

Turning Powerline on sets Default Padding to one space, so segment text
doesn't touch the arrows. Turning it off only cleared the enabled flag,
so the plain line kept that space for good: a line drawn as
"Model | Ctx" came back as " Model  |  Ctx " after trying Powerline,
and a padding the user had set, such as none or two spaces, was lost.
That includes a fresh install, where Default Padding is unset.

Turning Powerline on now remembers the padding it replaces in the
Powerline settings, and turning it off puts that padding back and
forgets it. When the padding was changed while Powerline was on, the
change is the user's own and is kept. An unset padding is remembered as
none, which renders the same. Settings saved before this change have
nothing remembered, so turning Powerline off keeps the padding, as
before.
On Windows, a Powerline font install that worked showed "Installed N
Powerline fonts. Please restart your terminal..." in red, the error
color. Powerline Setup picked green or red by looking for "success" in
the message. The macOS and Linux message says "installed successfully",
but the Windows one doesn't. The app passed on only the message and
dropped the install's success flag, so the screen had nothing else to
go on.

The app now keeps the whole install result, and Powerline Setup colors
the message by its success flag.
…r Git

Installing fonts from Powerline Setup while offline, behind a proxy or
behind a firewall said "Git is required to install Powerline fonts.
Please install Git and try again." with git installed. The real error
and the link to install the fonts by hand were hidden.

The installer took any error whose text contained "git" to mean git is
missing. execFileSync's error for a failed clone always starts with
"Command failed: git clone ...", so every clone failure matched,
whatever its cause. Only an ENOENT from starting git means git isn't
installed, on Node and on Bun.

That case keeps its message. Every other failure now shows the existing
"Failed to install Powerline fonts: ... You can manually install fonts
from: https://github.com/powerline/fonts" message with one line that
says why, rather than the whole command line and its output. That is
git's first "fatal:" or "error:" line, such as "fatal: unable to access
'https://github.com/powerline/fonts.git/': Could not resolve host:
github.com", or else the first line of stderr that doesn't name the
temp folder git clones into. That skips git's "Cloning into
'<folder>'..." progress line in any language. git translates it and
its "fatal:" prefix ("正克隆到 '<folder>'..." and "致命错误:" in
Chinese, "Clonage dans '<folder>'..." and "fatal : " in French), but
every translation quotes the folder. On a Mac without the Command Line
Tools, where /usr/bin/git is a stub, the line shown is the stub's
"xcode-select: note: No developer tools were found, requesting
install." A command stopped by a signal says so, as in "git was
stopped by SIGKILL". The existing cleanup test now fails the clone the
way a missing git does.
# Conflicts:
#	src/utils/__tests__/powerline-settings.test.ts
#	src/utils/powerline-settings.ts
…ss on and off

Turning Powerline on now leaves manual separators in the lines, and this
branch keeps a chosen Custom theme and puts back the padding it replaced
when Powerline goes off. Each was tested alone. A round trip through both
helpers, and through (t) in Powerline Setup with the confirmation that
manual separators bring up, checks all three come back together.
# Conflicts:
#	src/utils/__tests__/powerline-settings.test.ts
#	src/utils/powerline-settings.ts
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