Skip to content

v1.4.1 — Hardened Web Studio API, Safer init/uninstall, Battery Status & v1.4.0 Features

Choose a tag to compare

@mvsoares mvsoares released this 21 Nov 02:02

🚀 What's New in WezTerm Studio v1.4.1

Heads-up: this is the first PyPI release since v1.3.0. It ships everything from v1.3.1 and v1.4.0 (never published on their own), plus a security and reliability hardening pass over the Web Studio API, init / uninstall, and every file the tool writes.


🔒 Security: Hardened Web Studio API (wezterm-theme web)

Before this release, any web page open in your browser could POST to http://127.0.0.1:7777 (a text/plain "simple request" needs no CORS preflight) and rewrite your WezTerm config, including the command launched by file:line links (editor_cmd). Every request is now checked:

  • Host allowlist: a loopback-bound server only answers loopback Host names on its own port, which blocks DNS rebinding.
  • JSON only: POST requires Content-Type: application/json (415 otherwise). That forces a CORS preflight, which the server never approves.
  • Origin check: an Origin header, when present, must match the Host (403 otherwise).
  • Per-process session token: injected into the page as <meta name="studio-token"> and sent back as X-Studio-Token (403 when missing or wrong).
  • Response headers: X-Frame-Options: DENY, Content-Security-Policy: frame-ancestors 'none', Referrer-Policy: no-referrer and X-Content-Type-Options: nosniff. Request bodies are capped at 5 MB.
  • Clean errors: bad input (for example theme_id: "abc" or invalid JSON) returns a 400 JSON error, and unexpected failures return 500 instead of an empty reply. --host <non-loopback> prints a prominent warning.

🧩 Safer init / uninstall with a Lua-aware Scanner

  • Exact handler matching: conflicting wezterm.on('format-tab-title', …) handlers are now found by a scanner that skips comments and strings and balances parentheses. init disables only that call. It no longer swallows unrelated config after named handlers, breaks on nested closures such as pcall(function() … end), or re-comments the same handler on every run.
  • Handlers re-enabled on uninstall: uninstall restores the handlers that init disabled, including blocks written by ≤ 1.4.0, so running init and then uninstall gives back the original wezterm.lua byte for byte. Pass --keep-disabled-handlers to opt out.
  • Hook lookup:
    • The hook now tries the absolute module path first, which fixes ~/.wezterm.lua combined with a custom $XDG_CONFIG_HOME.
    • Load failures are logged with wezterm.log_error and log_warn instead of being swallowed.
    • Re-running init upgrades an outdated hook in place.

💾 Config Integrity, Atomic Writes & Backups

  • settings.json is never clobbered: a hand-edited loader file that fails to parse (one trailing comma is enough) used to be silently replaced. Now nothing is written, and you get the file, line and column of the error. wezterm_theme.json gets the same protection.
  • Atomic writes: every managed file is written through a temp file, fsync and os.replace, so WezTerm never reloads a half-written config.
    • Symlinked dotfiles (stow, chezmoi) are followed instead of being replaced.
    • The existing file mode is preserved.
    • On Windows, the write retries while WezTerm holds the file.
  • Serialized changes: concurrent Web Studio clicks can no longer mix JSON and Lua from different themes, or roll back each other's writes.
  • One validation path: every appearance setting (CLI, TUI, Web Studio, presets) is checked once, covering types, ranges, #rrggbb cursor colors and control characters. Lua strings now escape control characters as well.
  • Missing wezterm is reported: when no wezterm binary is found, you now get a warning that validation was skipped (it used to be silent), and a non-zero exit from wezterm counts as a failure.
  • Backups:
    • Restoring by exact filename (the Web UI used a list index that shifted).
    • Cross-mode restores (standalone ↔ loader) no longer overwrite the wrong JSON.
    • Automatic backups are pruned: the newest 10 pre_restore copies are kept, plus the newest 10 wezterm.lua backups and the pristine pre_init. Labeled backups are never pruned.
    • Backups taken in the same second never collide.
  • Preset import: importing a long JSON preset no longer fails with ENAMETOOLONG on Python ≤ 3.12.
  • Color-scheme cache: the cache is now rebuilt after a WezTerm upgrade.

🔋 Battery Status with Level & Charging Icons

  • The Studio right-status bar now maps state_of_charge to 11 Nerd Font battery glyphs (󰂎 → 󰁹), shows a charging icon (󰂄), and color-codes the level:

    State Color
    Charging or Full emerald #34d399
    AC hold mint #86efac
    ≤ 30% amber #fbbf24
    ≤ 15% bold crimson #f87171

✨ From v1.3.1 & v1.4.0: Frosted Glass, OLED, Sessionizer, Session Snapshots & GPU Tuner

  • Frosted-glass blur across platforms with --blur 0-100. It uses macos_window_background_blur on macOS, kde_window_background_blur on KDE and win32_system_backdrop on Windows 11.
  • Background and cursor overrides:
    • An OLED #000000 background override.
    • A custom cursor color that keeps WCAG contrast.
    • Automatic Symbols Nerd Font Mono + Emoji fallback chains.
  • Workspace switcher: a zero-dependency switcher for zoxide and Git projects.
  • Session snapshots: save and restore workspaces to wezterm_session.json from Ctrl+Shift+P, the CLI (wezterm-theme session) or the Web Studio.
  • GPU and rendering tuning:
    • front_end (WebGpu / OpenGL / Software), max_fps, animation_fps and Wayland controls.
    • DevOps quick_select_patterns (Ctrl+Shift+Space).
    • CPU and Software-renderer diagnostics in wezterm-theme doctor.
  • Conflict detection: wezterm-theme doctor, init and the Web Studio detect conflicting format-tab-title handlers, and the Web Studio offers a Fix Automatically button.
  • Web Studio layout: fixed card and button overflow on narrow and multi-column grids.

⚠ Upgrade Notes

  • Run wezterm-theme init once to upgrade an existing hook to the absolute-path version. Older hooks keep working in the meantime.
  • Reload any open Web Studio tab after upgrading. POST requests now need the session token embedded in the page.
  • Changes are serialized only inside one process. A CLI command run while wezterm-theme web is running is not serialized with the server.

📦 Upgrade / Install

pipx upgrade wezterm-theme
# or: uv tool upgrade wezterm-theme
# or: pip install --upgrade --user wezterm-theme

🙏 Credits & Community Inspirations

Full Changelog: v1.3.0...v1.4.1