npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

oc-bg-color-sync

v0.0.2

Published

Synchronize the terminal's native background color with OpenTUI's renderer background color. Fixes mismatched border/gutter colors in terminals that draw padding outside the application viewport.

Readme

oc-bg-color-sync

Synchronize the terminal's native background color with OpenTUI's renderer background color. Fixes mismatched border/gutter colors in terminals that draw padding outside the application viewport.

Why

OpenTUI renders its own background, but the terminal emulator may show its own default color in gutters, borders, or padding areas around the app. This plugin emits OSC 11 whenever the renderer background changes so the terminal stays in sync.

On cleanup it emits OSC 111 to restore the terminal's original background.

The Bug

What you see

When OpenCode's TUI renders with a dark theme but your terminal profile has a light background (or vice versa), you get visible color mismatches in:

  • Terminal gutters/padding around the app
  • Border areas not covered by the renderer
  • Scrollback regions showing the "wrong" background

Root cause

This was originally fixed upstream in @opentui/core via PR #951 by having setBackgroundColor() emit OSC 11 to sync the terminal's native background with the renderer's background.

However, PR #969 ("more reliable theme mode") removed the OSC 11 emission from setBackgroundColor() because it caused issues in Ghostty:

"Do not mirror renderer background to terminal default background via OSC 11 for now. In Ghostty, once OSC 11 has been used, later system light/dark theme changes can leave OSC 11 queries stuck on stale bg values even after OSC 111 resets. Theme detection relies on fresh OSC 10/11 replies, so mutating terminal default bg here breaks that."

The PR also disabled the OSC 111 reset in terminal.zig's resetState():

"OSC 111 is intentionally disabled for now. In Ghostty, sending the reset alone is enough to poison later OSC 11 background reporting for system light/dark theme changes, which breaks theme detection on the next app startup even though the immediate reset appears to work."

So after PR #969:

  • renderer.setBackgroundColor() only updates the internal render buffer
  • The terminal's native background stays at its profile default
  • Theme detection is more reliable, but border/gutter colors break

This plugin restores the OSC 11 sync as a userland workaround until upstream finds a solution that works for both use cases.

How it works

  • Wraps renderer.setBackgroundColor()
  • After the native call, converts the RGBA color to hex and writes OSC 11;rgb:rr/gg/bb\x07 to stdout
  • On plugin dispose, calls renderer.resetTerminalBgColor() which writes OSC 111\x07

Timing fix

ThemeProvider calls setBackgroundColor() during initial render before plugins are loaded. If we only patched the method, the terminal would stay out of sync until the theme changed again. The plugin therefore reads api.theme.current.background after patching and calls the patched method once to force an immediate sync.

OSC sequence reference

  • OSC 11 — Set terminal background color
    Format: \x1b]11;rgb:RR/GG/BB\x07
  • OSC 111 — Reset terminal background to default
    Format: \x1b]111\x07

See VT100.net OSC 11 docs and OSC 110-112 for more.

Install

Add the plugin to your OpenCode config (tui.json or equivalent):

{
  "plugin": ["oc-bg-color-sync"]
}

Debugging

To verify the plugin is emitting OSC sequences, run OpenCode in a terminal that logs escape sequences, or sniff stdout with script:

# Start a typescript session; all escape sequences are recorded
script -q /tmp/opencode-osc.log
opencode
# quit opencode, then exit the script shell
exit
# Search for OSC 11/111 in the log
grep -o $'\x1b]11;[^\x07]*\x07' /tmp/opencode-osc.log
grep -o $'\x1b]111\x07' /tmp/opencode-osc.log

You should see an OSC 11 on startup and an OSC 111 on exit.

Requirements

  • A terminal emulator that supports OSC 11/111 (most modern terminals do; Ghostty has quirks with theme detection after OSC 11/111 usage)

License

MIT