Skip to content

fix(shell): scope dark default to terminal#366

Merged
Nima-Naderi merged 2 commits into
mainfrom
codex/fix-terminal-dark-default
Jun 5, 2026
Merged

fix(shell): scope dark default to terminal#366
Nima-Naderi merged 2 commits into
mainfrom
codex/fix-terminal-dark-default

Conversation

@Nima-Naderi
Copy link
Copy Markdown
Collaborator

@Nima-Naderi Nima-Naderi commented Jun 5, 2026

Summary

  • Restores the shell first-run/fetch-failure fallback to the light DEFAULT_THEME so Settings, Billing, and other shell UI no longer inherit the dark preset by default.
  • Scopes the dark default to the terminal by changing new terminal settings from themeId: "system" to themeId: "one-dark".
  • Keeps Match OS available and preserves existing persisted terminal settings, including explicit system preferences.
  • Moves the terminal default constant into a dependency-free module so tests can import the real default without loading the Zustand store.

Tests

  • /home/nima/matrix-os/node_modules/.bin/vitest run tests/shell/useTheme.test.ts tests/shell/terminal-settings.test.ts --config /home/nima/matrix-os/vitest.config.ts passed: 15 tests.
  • ./scripts/review/check-patterns.sh --diff origin/main passed: no violations or warnings.
  • GitHub PR checks passed: Vercel, Vercel Preview Comments, and check.

Review/Monitoring

  • Latest commit: 6070ba387ee10ec5aa82ccad072c730c5f3059bc.
  • Greptile latest trusted review: 5/5 on latest commit.
  • Review threads: stale Greptile source-inspection thread resolved after the direct-import fix.

Invariants

  • Source of truth: saved shell themes still come from system/theme.json; terminal appearance defaults come from terminal-specific settings.
  • Lock/transaction scope: no database, filesystem write path, or multi-step mutation changed.
  • Acceptable orphan states: if shell theme fetch fails, shell renders with DEFAULT_THEME; terminal still defaults to one-dark unless a terminal preference is already persisted.
  • Auth source of truth: unchanged existing gateway auth for /api/settings/theme.
  • Deferred scope: no migration of existing terminal settings, no Settings/Billing redesign, and no global theme preset changes.

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
matrix-os-www Ready Ready Preview, Comment Jun 5, 2026 12:33pm

Request Review

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Jun 5, 2026

Greptile Summary

This PR decouples shell UI theming from terminal theming by restoring the light DEFAULT_THEME as the shell first-run/fetch-failure fallback and scoping the dark default exclusively to new terminal sessions via DEFAULT_TERMINAL_THEME_ID = "one-dark".

  • useTheme.ts: Removes SHELL_FALLBACK_THEME (dark preset) and updates normalizeTheme, getThemeFallback, and fetchTheme to fall back to the light DEFAULT_THEME. The style-fallback logic previously implicit in ...fallbackWithoutMode is now written explicitly — behavior is equivalent for all current Theme fields.
  • terminal-defaults.ts: New file housing TerminalThemeId and DEFAULT_TERMINAL_THEME_ID; extracted so tests and other consumers can import the constant without pulling in Zustand.
  • terminal-settings.ts: Switches the Zustand initial themeId from "system" to DEFAULT_TERMINAL_THEME_ID; Zustand's persist middleware means existing stored preferences (including "system") are unaffected.

Confidence Score: 5/5

Safe to merge — the change is narrowly scoped to default values and does not alter any persisted state, API contract, or auth path.

Both theme paths (shell fallback and terminal initial state) are covered by updated tests that directly import the exported constants. Existing users with persisted terminal settings are shielded by Zustand's persist middleware. The refactored style-fallback logic in normalizeTheme is behaviorally identical to the old spread approach for every current Theme field.

No files require special attention.

Important Files Changed

Filename Overview
shell/src/hooks/useTheme.ts Removes dark SHELL_FALLBACK_THEME; restores DEFAULT_THEME (light) as the shell fallback in normalizeTheme, getThemeFallback, and fetchTheme. Style fallback logic made explicit instead of relying on the former spread.
shell/src/stores/terminal-defaults.ts New file extracting TerminalThemeId union type and DEFAULT_TERMINAL_THEME_ID = "one-dark" to allow import without pulling in Zustand.
shell/src/stores/terminal-settings.ts Imports and re-exports from terminal-defaults; changes initial themeId from hardcoded "system" to DEFAULT_TERMINAL_THEME_ID. Existing persisted settings are unaffected by Zustand's persist middleware.
tests/shell/terminal-settings.test.ts New test file; imports DEFAULT_TERMINAL_THEME_ID directly from terminal-defaults and verifies it equals "one-dark".
tests/shell/useTheme.test.ts Updates fallback mode assertions from dark to light/undefined, adds a new saved-dark-theme preservation test, and re-labels test descriptions to match new light-first-run semantics.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[App starts] --> B{Fetch theme\nfrom API}
    B -- success --> C[normalizeTheme\nvalue, DEFAULT_THEME]
    B -- failure / first-run --> D[DEFAULT_THEME\nlight fallback]
    C --> E[Apply shell theme\nlight or dark]
    D --> E

    A --> F[useTerminalSettings\nZustand persist]
    F -- persisted value exists --> G[Use stored themeId\ne.g. system, one-dark]
    F -- no persisted value --> H[DEFAULT_TERMINAL_THEME_ID\none-dark]
    G --> I[Terminal renders\nwith chosen theme]
    H --> I
Loading

Reviews (2): Last reviewed commit: "test(shell): import terminal default dir..." | Re-trigger Greptile

Comment thread tests/shell/terminal-settings.test.ts
@Nima-Naderi Nima-Naderi merged commit 1a36a76 into main Jun 5, 2026
5 checks 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.

1 participant