Skip to content

feat(theme) user theme auto-reload#21778

Open
mroemore wants to merge 6 commits intoanomalyco:devfrom
mroemore:feat/theme-auto-reload
Open

feat(theme) user theme auto-reload#21778
mroemore wants to merge 6 commits intoanomalyco:devfrom
mroemore:feat/theme-auto-reload

Conversation

@mroemore
Copy link
Copy Markdown

@mroemore mroemore commented Apr 9, 2026

Issue for this PR

Closes #14847

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Custom themes in the XDG config directory (~/.config/opencode/themes/) now reload automatically when edited. Previously you had to restart the TUI or send a SIGUSR2 signal to pick up changes.

I added a @parcel/watcher subscription inside the ThemeProvider that watches the themes directory. When a .json file is created, modified, or deleted, it re-reads the custom themes and syncs them to the store. There's a 300ms debounce to handle atomic writes. editors like Vim and VS Code write to a temp file then rename, which fires multiple watcher events.

Only the XDG config directory is watched, since that's where users iterate on personal themes. Project-level .opencode/themes/ directories are typically set once and rarely changed. Could add a setting to disable it but I don't see much reason.

How did you verify your code works?

Wrote 5 unit tests covering: new theme file added, existing theme modified, theme file deleted, missing directory handling, non-JSON file ignored. I of course manually tested in the TUI. I edited a theme JSON file and confirmed the changes appeared within approx 300ms consistently. It passes all type checking, too.

Screenshots / recordings

N/A — no visual changes, just background file watching behavior.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

Hey! Your PR title Feat/theme auto reload doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@mroemore mroemore changed the title Feat/theme auto reload feat(theme) user theme auto-reload Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update theme without restarting

1 participant