Skip to content

fix(bwrap): make OpenTUI width counting match Zellij - #30

Merged
Matt Snyder (maatthias) merged 1 commit into
NSLS2:mainfrom
stuwilkins:fix/bwrap-zellij-wcwidth
Oct 26, 2026
Merged

Matt Snyder (maatthias) merged 1 commit into
NSLS2:mainfrom
stuwilkins:fix/bwrap-zellij-wcwidth

Conversation

@stuwilkins

Copy link
Copy Markdown
Contributor

Zellij drops zero-width code points (emoji variation selectors, ZWJ) and has
no grapheme width mode (DEC 2027), so OpenTUI's default width counting drifts
from Zellij's grid. OpenTUI only redraws cells it thinks changed, so the
OpenCode TUI is left garbled until a resize. OpenTUI switches to wcwidth
counting for tmux and screen, but not for Zellij.

  • Pass ZELLIJ, ZELLIJ_SESSION_NAME and ZELLIJ_PANE_ID into the sandbox, so
    OpenTUI can tell it runs inside Zellij (no Zellij socket is mounted).
  • Set OPENTUI_FORCE_WCWIDTH=1 when ZELLIJ is set, unless the user already
    set OPENTUI_FORCE_WCWIDTH.
  • Applies to bwopencode and bwopencode2 (shared build_env_vars).

Checked with --dry-run (the variables appear only when ZELLIJ is set) and
pre-commit (shfmt, shellcheck, codespell, gitleaks). Confirmed inside a
Zellij pane after restarting bwopencode2.

Assisted-by: opencode:claude-sonnet-5-5

Zellij drops zero-width code points (emoji variation selectors, ZWJ)
and has no grapheme width mode, so OpenTUI's default width counting
drifts from Zellij's and leaves the screen garbled until a resize.

Pass ZELLIJ, ZELLIJ_SESSION_NAME and ZELLIJ_PANE_ID into the sandbox and
set OPENTUI_FORCE_WCWIDTH=1 inside Zellij unless the user already set it.

Assisted-by: opencode:claude-sonnet-5-5
Copilot AI balanced review requested due to automatic review settings October 26, 2026 23:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The narrow shared-environment change preserves user overrides, serves both wrappers, and has no identified blocking issues.

No open issues 🎉

What changed in this PR

This PR addresses OpenCode TUI rendering drift inside Zellij by adjusting width-counting settings in the shared sandbox environment builder used by both wrappers.

Changes:

  • Pass through Zellij session identifiers and default OPENTUI_FORCE_WCWIDTH to 1 inside Zellij, preserving explicit user values.
  • Document the environment behavior in both OpenCode wrappers.
File Description
lib/​bwrap_sandbox_lib.sh Adds Zellij environment passthrough and the conditional width-counting default.
bin/​bwopencode2 Documents Zellij passthrough and width-counting behavior in comments.
bin/​bwopencode Documents the same behavior in comments.

Review effort: Balanced

@maatthias
Matt Snyder (maatthias) merged commit 5d5c5d8 into NSLS2:main Oct 26, 2026
1 check passed
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.

3 participants