Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat: let an environment publish themes as a file #8569

Mergedryanrhughes(GitHub profile, opens in a new tab)merged 16 commits intomain fromrefs/pull/8569/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

What Changed

Allows a machine can drop theme files into <stateDir>/themes/ and they show up as themes in every web and desktop client connected to that environment. The filename is the id — themes/nightfall.json becomes nightfall.

The server watches that directory and streams the set over subscribeServerConfig. Clients render each one as a card in the theme library. Change a file, connected clients retint in about 100ms.

Two formats work. A theme exported straight out of T3 Code — the Download button's JSON — drops in unchanged. Or a short seeded form if all you've got is a background and an accent:

{ "name": "Nightfall", "appearance": "dark", "canvas": "#1a1b26", "accent": "#7aa2f7" }

The seeded form runs through createVividThemeColors, the same generator the guided editor uses, so it comes out looking like a T3 Code theme instead of a transplant from someone else's app.

Also adds t3 theme set <id|file>, t3 theme clear, and t3 theme show. set takes an id or a path — a path publishes the file and sets it in one step.

Things I specifically made sure of:

  • The new stream event is gated behind a client capability flag. Without it, an already-shipped client hits an unknown union member and its whole config subscription dies — settings, keybindings, provider status, all of it, for the rest of the session. Old clients just never get the event.
  • Reserved ids can't be published. A dark.json would otherwise hijack everyone whose stored preference is the stock "dark".
  • A theme you saved locally always beats a published one with the same id.
  • Each theme set applies once per client. Pick something else in Settings afterward and that sticks until the next set.
  • Mobile keeps its own appearance settings. It has no custom theme support at all, so there was nothing to hook into.

Why

Selfishly, getting proper theme synchronization to work properly with Omarchy was the main motivation here. However the implementation has been approached such that the use cases are broader than Omarchy and in no way Omarchy-specific.

Themes live in browser localStorage today. That's per-client — so a machine has no way to offer one, a file has no way to carry one, and there's no way to provision a box so T3 Code opens matching it.

This is a primitive for file-based themes, not a desktop integration. Drop a theme file in, get a live card. Share one file to theme a whole team's environment. Edit it in vim and watch clients retint. Delete it and it's gone everywhere.

If it's helpful at all, https://github.com/basecamp/omarchy/pull/8784 is the counterpart PR in Omarchy showing this in action.

UI Changes

The UI itself doesn't change other than when a change to the active theme file triggers an update.

https://github.com/user-attachments/assets/8bdf626d-484a-499c-be52-5675d0b366fa

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Note

Medium Risk Touches filesystem publishing, concurrent settings.json writes, and the config WebSocket stream; mitigated by capability gating, atomic publish/rollback, and extensive integration tests, but skewed or mis-provisioned themes could still surprise connected clients.

Overview Adds environment-published themes: machines can place theme JSON under the state directory’s themes/ folder (or use t3 theme set / clear / show) so web and desktop clients see live palette cards and can follow a defaultTheme provisioned in settings.json.

The server gains an EnvironmentTheme watcher (guarded reads, size/id limits, debounced directory refresh) and advertises environmentThemes capability. subscribeServerConfig only emits environmentThemesUpdated when the client opts in, so older clients are not broken by a new stream event. Client-runtime keeps published themes out of the config cache and across reconnect snapshots only while the server still supports the feature.

On web, published themes merge into the theme library (duplicate-only cards), useDefaultThemeAdoption applies each environment set once per generation, and theme storage/preview handling is tightened so late-arriving published ids and editor drafts are not dropped incorrectly.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit b211fa428549c2aecb777e4c3db0a5e04a739b82. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Add environment-published themes with server file streaming and CLI

  • Server reads theme JSON files from <stateDir>/themes, validates them (size, name, symlinks, reserved ids), and streams updates to opted-in clients via a new environmentThemesUpdated event on subscribeServerConfig.
  • Adds a t3 theme CLI to set/clear a default theme and publish theme files into the themes directory.
  • Client runtime treats environmentThemes as ephemeral (stripped from cached/persisted config), carries them through projections only when the server advertises the environmentThemes capability, and drops them on reconnect to a downgraded server.
  • Web app syncs published themes into the theme library, lists them as non-editable duplicate-only cards in ThemeLibrary, and adopts an environment default theme once per generation via useDefaultThemeAdoption.
  • useTheme gains preservePreview on applyTheme/refreshTheme, exposes resolvedTheme in the snapshot, and setThemeHalf now reads raw halves to avoid pruning unresolved references.
  • Risk: subscribeServerConfig payload schema changed from empty struct to optional environmentThemes boolean; old servers still accept {environmentThemes: true} but any out-of-tree decoder assuming the exact empty struct may fail. getThemeDefinition resolution order now checks environmentThemeDefinitions after built-in and custom themes, so a user-saved theme with the same id as a published one still wins.
Macroscope summarized b211fa4.

Maintainer follow-up

Live theme changes now update React's resolved appearance. An open theme editor keeps its draft while files, defaults, or system appearance change. Closing the editor restores the latest selected palette. Published palettes with no usable colors are omitted on that client.

Verified with 96 focused tests, the web typecheck, and targeted lint. Rebased onto current main. Browser verification has not run.

Hosted app support and publication limits are unchanged.

Original feature by @ryanrhughes. Follow-up fixes by GPT-5.6 Sol using Codex.

    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: 4f8db60d-703d-45f1-81b0-7a8df0dd2671

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review

      Comment `@coderabbitai help` to get the list of available commands.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. Effect service conventions review of the new EnvironmentTheme service and t3 theme CLI. The service definition, layer wiring, namespace imports, and consumer updates (server.ts, ws.ts, server.test.ts) follow the conventions. Findings are limited to the CLI error model in apps/server/src/cli/theme.ts and one make export nit.

      Posted via Macroscope — Effect Service Conventions
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      src/environmentTheme.ts:63

      This module owns construction, so make should be exported alongside layer (the prevailing pattern across apps/server/src services).

      export const make = Effect.gen(function* () {

      No longer relevant as of 41cc4af51f7383d87d7812b23e672f3ddaa1f910

    4. Two consistency issues in the new environment-theme UI paths; both are small, contained fixes in apps/web/src. Everything else (card composition, Tailwind ownership, lenientThemeColorOverrides extraction, atom wiring) matches the existing theme-library patterns.

      Posted via Macroscope — UI Consistency
    5. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This PR adds a substantial environment-wide theme capability spanning filesystem watching, CLI settings, WebSocket contracts, client state, and live web behavior. It also introduces environment-selected theme defaults that can change how connected clients initialize and respond, so the breadth and product impact require human review.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    6. Two error-modeling nits in apps/server/src/cli/theme.ts; the earlier findings (per-failure tagged errors, exported make in environmentTheme.ts) look addressed.

      Posted via Macroscope — Effect Service Conventions
    7. One finding on the new environment-theme adoption path; the two issues flagged on the previous run (published-card onUse half assignment and the over-broad managed: true) are resolved in this revision.

      Posted via Macroscope — UI Consistency
    8. One finding: assigning a published environment theme to a light/dark half persists an id whose resolvability is transient, and the existing half-write path prunes unresolvable ids before writing.

      Posted via Macroscope — UI Consistency
    9. One follow-up on the published-id/theme-mix interaction; the readStoredThemeHalvesRaw fix covers setThemeHalf, but two read-modify-write flows in ThemeSettings still rebuild the mix from the pruned snapshot.

      Posted via Macroscope — UI Consistency
    10. This is super close. Want to make sure react state doesn't go out of sync. Will push a few small changes and get this merged

    11. github-actions[bot](GitHub profile, opens in a new tab) removed labelsvouch:unvouched

    12. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    13. Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

      Fix All in Cursor ❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot). Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 4d855e920b6748fcd23fb8ca1b9f4b52d7a45e52. Configure [here](https://www.cursor.com/dashboard/bugbot).

Sign in to join this conversation.