Skip to content

Add Markdown preview theme controls#64

Merged
GordonBeeming merged 8 commits into
mainfrom
gb/markdown-preview-theme
Jul 17, 2026
Merged

Add Markdown preview theme controls#64
GordonBeeming merged 8 commits into
mainfrom
gb/markdown-preview-theme

Conversation

@GordonBeeming

@GordonBeeming GordonBeeming commented Jul 17, 2026

Copy link
Copy Markdown
Owner
  • add a floating light/dark switch to Markdown previews
  • add persisted Auto, Light, and Dark preview theme preferences
  • make Auto display the resolved theme inline, so one click directly selects the opposite explicit theme

Why

Markdown and Mermaid content can be authored for a different colour scheme than the app. Preview themes should be independently adjustable without changing the editor or requiring an intermediate Auto selection.

User impact

The preview now has a compact sun/moon control in its top-right corner. Settings > Preview Features provides Auto, Light, and Dark; the choice persists across sessions.

Validation

  • ./run-tests.sh
  • 428 frontend tests passed
  • 239 Rust tests passed
  • production build, smoke tests, bundle budgets, and security audits passed
  • visually verified light and dark previews, Mermaid rendering, Auto resolution, direct one-click override, and persisted Settings state in the debug macOS bundle

Summary by CodeRabbit

  • New Features
    • Added a Markdown preview theme preference (Auto, Light, Dark) with an in-preview toggle.
    • Added a “Markdown preview theme” dropdown under Preview Features, persisted across sessions (including single-file mode) and reflected in the preview.
  • Bug Fixes
    • Invalid/unknown saved theme values now safely fall back to Auto.
    • Preserves already-rendered diagrams when resizing the editor/preview split.
  • Tests
    • Expanded coverage for theme persistence, sanitization/defaulting, and preview behavior during resize.

Copilot AI review requested due to automatic review settings July 17, 2026 01:31
@GordonBeeming GordonBeeming changed the title ## Summary Add Markdown preview theme controls Jul 17, 2026

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.

Pull request overview

Adds independent, persisted theme controls for Markdown previews so preview rendering can be toggled between Auto/Light/Dark without changing the app/editor theme.

Changes:

  • Introduces a persisted markdownPreviewThemePreference setting (TS + Rust) with sanitization/defaulting.
  • Adds a compact light/dark toggle UI to the Markdown preview and applies theme-specific CSS variables via data-preview-theme.
  • Extends frontend + backend tests to cover preference sanitization, UI behavior, and persistence wiring.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/tauri.ts Adds MarkdownPreviewThemePreference, default, sanitization, and persists it in PersistedViewSettings defaults.
src/tauri.test.ts Updates UI snapshot expectations and adds sanitization tests for the new preference.
src/MarkdownPreview.tsx Adds the toggle UI and applies data-preview-theme for theming the preview surface.
src/MarkdownPreview.test.tsx Tests the resolved theme indicator and direct switching behavior via the toggle.
src/MarkdownPreview.css Defines light/dark theme variable sets and styles the floating toggle control.
src/App.tsx Wires preference state, resolves Auto to the effective app theme, persists updates, and exposes the setting in “Preview Features”.
src/App.test.tsx Verifies inline Auto resolution and persistence of light/dark selection through UI interactions.
src-tauri/src/lib.rs Persists the new field in Rust UI state with serde defaults and sanitization + tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request introduces a new markdown_preview_theme_preference setting, allowing users to configure the Markdown preview theme to "auto", "light", or "dark". The setting is integrated into the Tauri backend and the React frontend, complete with UI controls in the settings dialog, an inline theme toggle on the preview itself, and corresponding CSS theme variables. Feedback on the changes suggests refactoring the hardcoded hex values in the dark theme CSS to use established design tokens, and defining a constant for the allowed theme preferences in the Rust backend to maintain consistency with other settings.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/MarkdownPreview.css Outdated
Comment thread src-tauri/src/lib.rs Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 486e59f3dc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/App.tsx Outdated
Copilot AI review requested due to automatic review settings July 17, 2026 01:46
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds persisted Auto/Light/Dark Markdown preview theming, inline theme controls, Settings integration, separate view-state persistence, theme-specific CSS, sanitization, and tests covering persistence, resolution, accessibility state, and diagram preservation.

Changes

Markdown preview theme

Layer / File(s) Summary
Theme preference contract and backend persistence
src/tauri.ts, src-tauri/src/lib.rs, src/tauri.test.ts
Defines the theme preference type, defaults, persisted state fields, allowed values, sanitization behavior, and a dedicated view-settings update command with Rust and TypeScript coverage.
Application state and settings integration
src/App.tsx, src/App.test.tsx
Resolves Auto against the application theme, restores and persists the preference, routes single-file updates through view settings, and adds the Preview Features selector with integration coverage.
Preview rendering and theme controls
src/MarkdownPreview.tsx, src/MarkdownPreview.css, src/MarkdownPreview.test.tsx
Adds DOM theme state, optional Light/Dark controls, memoized markdown rendering, theme styling, focus states, text selection, and resize-preservation tests.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Settings
  participant App
  participant MarkdownPreview
  participant UIState
  Settings->>App: Select Auto, Light, or Dark
  App->>MarkdownPreview: Pass resolved preview theme
  MarkdownPreview->>App: Report inline theme selection
  App->>UIState: Persist markdownPreviewThemePreference
Loading

Possibly related PRs

  • GordonBeeming/ide#62: Both changes update the Markdown preview component, styling, and App integration.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding Markdown preview theme controls and persistence.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch gb/markdown-preview-theme

Comment @coderabbitai help to get the list of available commands.

@GordonBeeming

Copy link
Copy Markdown
Owner Author

@codex review

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/App.test.tsx`:
- Around line 1412-1416: Update the assertion around tauriMocks.updateUiState to
inspect the last call directly and assert its second argument with
toBe(savedWorkspace), while retaining the existing
markdownPreviewThemePreference check for the first argument.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 0ee1906c-d6a6-411c-8d76-6858b240ecc3

📥 Commits

Reviewing files that changed from the base of the PR and between 3f1644d and 0a9e249.

📒 Files selected for processing (2)
  • src/App.test.tsx
  • src/App.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/App.tsx

Comment thread src/App.test.tsx

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0a9e249b40

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/App.tsx Outdated
@GordonBeeming

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d26851311d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/App.tsx Outdated

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.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 17, 2026 02:00

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.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 17, 2026 02:14
@GordonBeeming

Copy link
Copy Markdown
Owner Author

@codex review

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.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src-tauri/src/lib.rs (1)

3643-3670: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Exercise update_view_settings in the persistence regression.

This test calls apply_view_runtime_settings, manually assigns ui_state.view, and persists it, so a broken update_view_settings implementation could still pass. Invoke the command itself (or add a focused command test) and retain the workspace-preservation assertions.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src-tauri/src/lib.rs` around lines 3643 - 3670, The test
view_settings_updates_preserve_workspace_state currently bypasses
update_view_settings by calling apply_view_runtime_settings and assigning
ui_state.view directly. Exercise update_view_settings itself (or add a focused
command test), then persist and retain assertions verifying the existing
workspace state remains unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src-tauri/src/lib.rs`:
- Around line 1414-1421: Update update_view_settings and update_ui_state so each
mutation, snapshot, and persist_ui_state call occurs while holding the same
ui_state write lock, preventing an older snapshot from being written after a
newer update. Adjust the regression test to invoke the actual command path and
verify concurrent updates are persisted without stale overwrites.

---

Nitpick comments:
In `@src-tauri/src/lib.rs`:
- Around line 3643-3670: The test view_settings_updates_preserve_workspace_state
currently bypasses update_view_settings by calling apply_view_runtime_settings
and assigning ui_state.view directly. Exercise update_view_settings itself (or
add a focused command test), then persist and retain assertions verifying the
existing workspace state remains unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 2cfe2efd-b397-4510-9bed-d9222bd7b3b5

📥 Commits

Reviewing files that changed from the base of the PR and between d268513 and eba723c.

📒 Files selected for processing (7)
  • src-tauri/src/lib.rs
  • src/App.test.tsx
  • src/App.tsx
  • src/MarkdownPreview.test.tsx
  • src/MarkdownPreview.tsx
  • src/tauri.test.ts
  • src/tauri.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/tauri.ts
  • src/MarkdownPreview.tsx
  • src/App.tsx

Comment thread src-tauri/src/lib.rs Outdated
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: eba723c06f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copilot AI review requested due to automatic review settings July 17, 2026 02:25
@GordonBeeming

Copy link
Copy Markdown
Owner Author

@codex review

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.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Comment thread src-tauri/src/lib.rs Outdated
Comment thread src-tauri/src/lib.rs Outdated
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: afd2c32249

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copilot AI review requested due to automatic review settings July 17, 2026 02:32
@GordonBeeming

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 6880d7f9ae

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@GordonBeeming
GordonBeeming merged commit a21a70c into main Jul 17, 2026
3 of 6 checks passed
@GordonBeeming
GordonBeeming deleted the gb/markdown-preview-theme branch July 17, 2026 02:40
Copilot stopped reviewing on behalf of GordonBeeming due to an error July 17, 2026 02:52

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.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Comment thread src-tauri/src/lib.rs
Comment on lines +417 to +419
fn default_markdown_preview_theme_preference() -> String {
"auto".to_string()
}
Comment thread src-tauri/src/lib.rs
Comment on lines +1421 to +1431
let (_persist_guard, path) = lock_ui_state_store(state)?;
let view = apply_view_runtime_settings(state, view)?;
let ui_state = {
let mut ui_state = state
.ui_state
.write()
.map_err(|_| CommandError::UiState("ui state lock poisoned".to_string()))?;
ui_state.view = view;
ui_state.clone()
};
persist_ui_state_value(&path, &ui_state)
Comment thread src-tauri/src/lib.rs
Comment on lines +1409 to +1415
#[tauri::command]
fn update_view_settings(
state: State<'_, AppState>,
view: PersistedViewSettings,
) -> Result<(), CommandError> {
update_view_settings_state(&state, view)
}
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.

2 participants