Skip to content

#1044 Android: light/dark override and text sizes - #1046

Merged
ivanfenenko merged 5 commits into
mainfrom
feature/1044-appearance-text-size-android
Nov 15, 2026
Merged

ivanfenenko merged 5 commits into
mainfrom
feature/1044-appearance-text-size-android

Conversation

@ivanfenenko

@ivanfenenko ivanfenenko commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

Part of #1044 (Android half; iOS is a separate PR).

What changed

  • Settings › Appearance
    • Mode segmented control (System / Light / Dark) at the top, with the note from the issue under it. Next come the existing Theme and Code highlight rows.
    • Home list text, Session Chat text and Code text sections. Each one has a "Size" card with the current step name and a 5-step slider (Extra small 0.85, Small 0.92, Default 1.0, Large 1.12, Extra large 1.26). Under each card is a flat live sample drawn by the real components:
      • Home: a section header plus two SessionListRows.
      • Session Chat: OpenCodeOutgoingMessage, OpenCodeAssistantMessage with inline code, and OpenCodeToolCallCard.
      • Code: an OpenCodeUnifiedDiff hunk.
    • The two closing notes from the spec.
  • Overflow (⋮) menu in the Appearance top bar:
    • "Reset text sizes" is disabled when all sizes are Default.
    • "Reset all appearance" is destructive and also resets Mode to System. It is disabled when nothing differs.
  • Mode applies app-wide right away. OpenCodeTheme now defaults to openCodeAppDarkTheme(), so the root, the privacy cover, sheets and dialogs all follow it. MainActivity re-applies enableEdgeToEdge so the system bar icons follow the mode. The component gallery's "System" also follows the app mode.
  • Text sizes are a design-system mechanism. theme/TextScale.kt adds OpenCodeTextRegion(region). It provides a Density whose sp values are the phone's own (possibly non-linear) font scaling times the region's multiplier, so every Typography and CodeTextStyle size inside scales and nothing outside does. Regions do not compound: a Code sheet opened from the timeline uses the Code size alone. openCodeTextScaled(dp) grows the session-row letter avatar with its text.
    • Home: SessionListRow, which Home, Archived sessions and session search share, plus the Home section headers.
    • Session Chat: each timeline message row (messages, inline code, code blocks, tool lines) and OpenCodeSessionComposer.
    • Code: the Changes diff, the file viewer's code view, tool result and tool detail bodies, the shell output body, and the Terminal. xterm gets its font size via a new window.terminalSetFontSize.
  • Persistence: AppearancePreferences (SharedPreferences, device-local, not per Connection Profile), initialised in the Application and cleared by Clear All Data.
  • Screen Model: AppearanceSettingsViewModel with one immutable AppearanceSettingsUiState and explicit actions. It refreshes on resume.
  • New component: OpenCodeTextSizeSlider (card + stepped slider, Default tick marked), with a component gallery entry.
  • Analytics: settings_appearance_mode (mode), settings_text_size (text_region, text_size), settings_reset_text_sizes, settings_reset_appearance. iOS should use the same ids.

Checks

  • ./gradlew :app:assembleDebug passes.
  • :app:testDebugUnitTest: 3369 tests ran with 1 failure, DefaultForegroundEventStreamProtocolRecheckTest.reconnectAfterDrop_rechecksAndFollowsServerBackToV1. It is a timing test this PR does not touch, and it passed twice when run alone.
  • New tests:
    • AppearancePreferencesTest: defaults, persistence across relaunch, unknown stored values, reset text sizes keeps Mode, reset all, Clear All Data, mode resolution, step multipliers.
    • AppearanceSettingsViewModelTest: reset enablement rules, actions, analytics, no-op actions.
    • TextScaleTest: the scaled-density math.
  • ktlint: no new violations in the touched lines. The pre-existing violations in touched files were left alone to keep the diff small.
  • Not run: emulator, instrumented tests, scenario harness. UI evidence comes from the orchestrator's device check.

Needs device check

  1. Settings › Appearance in light and dark:
    • The Mode segment, the note text for each mode, and the Theme and Code highlight rows.
    • The three slider cards: current step name, the ticks with the Default tick marked, drag and tap to each step.
    • The samples sit flat on the page and resize live.
  2. Overflow menu:
    • Both entries are disabled on a fresh install.
    • Changing a size enables both entries.
    • Changing only Mode enables only "Reset all appearance", which shows in the destructive colour.
    • Each reset does what it says.
  3. Mode Dark or Light with the phone set the other way:
    • Home, Session Chat, a bottom sheet (tool output, shell output), a dialog and the overflow menu all follow the app mode.
    • Status and navigation bar icons stay readable.
    • Switching back to System follows the phone again, without a restart.
  4. Home list at Extra small and Extra large:
    • Session rows (title, path line, time, status pill, letter tile) and the section headers resize.
    • Archived sessions and session search rows resize too.
    • The dock and the top bar do not change.
  5. Session Chat at Extra small and Extra large:
    • User and assistant messages, inline code, a fenced code block, tool cards or step rail lines, and the composer (including a permission or question card) resize.
    • The top bar, floating pills and the working indicator do not.
  6. Code at Extra small and Extra large:
    • The Terminal resizes and refits (check that cols and rows update), as do the Changes diff, the file viewer code view, the tool output sheet body and the shell output sheet body.
    • A code block inside a message follows the Session Chat size, not the Code size.
  7. System font size at its largest with Extra large: sizes multiply rather than replace (text gets bigger than at the system size alone), and nothing clips badly.
  8. Relaunch: all four settings persist. Clear All Data resets them.

Risks / Follow-ups

  • shared/terminal-web/index.html is shared with iOS. This PR adds window.terminalSetFontSize there, and the iOS PR may touch the same file.
  • The Terminal now follows the phone's font scale times the Code size. Before, it ignored the phone's font scale.
  • The file viewer's rendered Markdown preview stays at its normal size; only the code view uses the Code size.

🤖 Generated with Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.


Note

Medium Risk
Wide UI/theming changes affect every main screen and the shared terminal web bundle; low security risk but high regression surface for layout and readability.

Overview
Adds Settings › Appearance controls for app-wide light/dark mode (System / Light / Dark) and per-region text size (Home list, Session Chat, Code), persisted in AppearancePreferences and cleared with Clear All Data.

Mode drives openCodeAppDarkTheme() through OpenCodeTheme, including status/navigation bar styling in MainActivity and the component gallery’s “System” preview.

Text sizes use OpenCodeTextRegion / ScaledTextDensity so only wrapped surfaces scale—home session rows, chat timeline/composer, and code surfaces (diffs, file viewer code, tool/shell output, terminal via terminalSetFontSize). The Appearance screen adds stepped sliders with live samples, reset actions, AppearanceSettingsViewModel, analytics, and unit tests.

Reviewed by Cursor Bugbot for commit 90ce733. Bugbot is set up for automated code reviews on this repo. Configure here.

Settings › Appearance gains a Mode control (System / Light / Dark) and
three text sizes (Home list, Session Chat, Code), each a stepped slider
card with a flat live sample drawn by the real components. A top-bar
overflow menu resets the sizes, or everything including Mode.

Mode applies at the theme root, including sheets, dialogs and system bar
icons. Sizes multiply the phone's font scale through text regions in the
design system, so only the surfaces in each region change size. All four
settings persist locally and are cleared by Clear All Data.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ivanfenenko

Copy link
Copy Markdown
Collaborator Author

The strings (String key parity) check fails because the new appearance_* keys have no matching iOS appearance.* keys yet. iOS is a separate PR, so this branch leaves ios/ alone. The check should pass once the iOS keys land with the same names, or when the two branches are combined. If iOS names any key differently, rename it on one side.

@ivanfenenko
ivanfenenko marked this pull request as ready for review November 15, 2026 16:58
@ivanfenenko

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using default 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.

Reviewed by Cursor Bugbot for commit 90ce733. Configure here.

@github-actions github-actions 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.

Automated review: no finding that 2+ of 3 passes agreed on.

2 finding(s) from a single pass, not posted
  • android/app/src/main/java/dev/opencode/mobile/theme/Theme.kt:22 medium: Forced Light/Dark mode is not applied to components that read the system setting directly (deepseek-v4.1-flash)
  • android/app/src/main/java/dev/opencode/mobile/ui/settings/AppearanceSettingsScreen.kt:375 low: Code sample diff declares hunk counts that do not match its body, so the parser returns an empty hunk list (deepseek-v4.1-flash)

opencode pr-review · passes: muse-spark-1.3-contributor, glm-5.3-flash, deepseek-v4.1-flash · $0.114 · 2 pass(es) stopped early

ivanfenenko and others added 3 commits November 15, 2026 18:16
- Slider thumb uses the strong ink in dark mode so it stays visible.
- Diff line-number and marker columns grow with the Code text size.
- Home sample rows show the project letter, like real Home rows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ivanfenenko

Copy link
Copy Markdown
Collaborator Author

Device check: Pixel 9a emulator, scenario harness (opencode v2, scripted model)

Checked against the "Needs device check" list. Fixes from this pass are in 9a357c5 (thumb visible in dark, diff gutter grows with Code size, sample rows use the project letter).

Step Screenshot
Appearance, System mode (phone dark)
Light override, Home list Extra large
Session Chat Extra small, Code Extra large
⋮ reset menu
Real Home at Extra large
Real Session Chat at Extra small
Terminal at Code Extra large
Tool diff sheet at Code Extra large
Dark override with phone in light (after relaunch; sizes kept)
After Reset all appearance
Menu items disabled after reset
After fix: thumb visible in dark, gutter no longer collides

Not checked on device: maximum system font scale; Changes screen and file viewer (no dirty tree in the harness project; the shared diff component was checked through the tool sheet).

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