Skip to content

A full-featured download manager.

fix(tray): allow linux icon colors and restore activity updates (#2162)

Dr_rOotdbb89ded83e9
diff --git a/src/core/settings/settings-manager.test.ts b/src/core/settings/settings-manager.test.ts
index 50e9b51b..59c3e2d3 100644
--- a/src/core/settings/settings-manager.test.ts
+++ b/src/core/settings/settings-manager.test.ts
@@ -1532,7 +1532,25 @@ describe('SettingsManager', () => {
const app = manager.getApp()
expect(app.runMode).toBe(1) // RunMode.Standard
expect(app.traySpeedometer).toBe(true)
- })
+ expect(app.trayIconColor).toBe('auto')
+ })
+
+ it.each(['light', 'dark', 'auto'] as const)(
+ 'persists tray color %s without changing the app theme or requiring restart',
+ async (trayIconColor) => {
+ const theme = manager.getApp().theme
+ const result = await manager.update({ app: { trayIconColor } })
+ expect(result.requiresRestart).toBe(false)
+ expect(manager.getApp().theme).toBe(theme)
+ const saved = mockedFs.writeFile.mock.calls.at(-1)?.[1] as string
+ expect(JSON.parse(saved).app.trayIconColor).toBe(trayIconColor)
+ mockedFs.readFile.mockResolvedValue(saved)
+ const reloaded = new SettingsManager(TEST_PATH)
+ await reloaded.load()
+ expect(reloaded.getApp().trayIconColor).toBe(trayIconColor)
+ expect(reloaded.getApp().theme).toBe(theme)
+ }
+ )
})
describe('rpcSecret seeding', () => {
diff --git a/src/main/platform/tray-icon.test.ts b/src/main/platform/tray-icon.test.ts
index ffdf51f6..57c47af2 100644
--- a/src/main/platform/tray-icon.test.ts
+++ b/src/main/platform/tray-icon.test.ts
@@ -16,6 +16,7 @@ vi.mock('@resvg/resvg-wasm', () => ({
Resvg: vi.fn(),
}))
+import type { TrayIconColor } from '@shared/schemas/tray-icon-color'
import { createLinuxIconProvider, formatSpeed } from './tray-icon'
describe('createLinuxIconProvider', () => {
@@ -66,6 +67,48 @@ describe('createLinuxIconProvider', () => {
filePath: path.join(assetDir, 'mo-tray-dark-active.png'),
})
})
+
+ it.each([
+ { color: 'light' as const, background: 'dark' },
+ { color: 'dark' as const, background: 'light' },
+ ])(
+ 'keeps $color artwork independent of the application theme',
+ async ({ color, background }) => {
+ const provider = createLinuxIconProvider(assetDir, () => color)
+ for (const dark of [false, true]) {
+ nativeThemeMock.shouldUseDarkColors = dark
+ await provider.init()
+ for (const active of [false, true]) {
+ expect(provider.getIcon(active)).toEqual({
+ filePath: path.join(
+ assetDir,
+ `mo-tray-${background}-${active ? 'active' : 'normal'}.png`
+ ),
+ })
+ }
+ }
+ }
+ )
+
+ it('reloads a changed preference and resumes following the application theme', async () => {
+ let color: TrayIconColor = 'light'
+ const provider = createLinuxIconProvider(assetDir, () => color)
+ await provider.init()
+ expect(provider.getIcon(false)).toEqual({
+ filePath: path.join(assetDir, 'mo-tray-dark-normal.png'),
+ })
+ color = 'dark'
+ await provider.init()
+ expect(provider.getIcon(true)).toEqual({
+ filePath: path.join(assetDir, 'mo-tray-light-active.png'),
+ })
+ color = 'auto'
+ nativeThemeMock.shouldUseDarkColors = true
+ await provider.init()
+ expect(provider.getIcon(true)).toEqual({
+ filePath: path.join(assetDir, 'mo-tray-dark-active.png'),
+ })
+ })
})
describe('formatSpeed', () => {
diff --git a/src/main/platform/tray-icon.ts b/src/main/platform/tray-icon.ts
index ebf11d10..f3bff679 100644
--- a/src/main/platform/tray-icon.ts
+++ b/src/main/platform/tray-icon.ts
@@ -3,6 +3,10 @@ import {
type ByteUnitSystem,
DEFAULT_BYTE_UNIT_SYSTEM,
} from '@shared/schemas/byte-unit-system'
+import {
+ DEFAULT_TRAY_ICON_COLOR,
+ type TrayIconColor,
+} from '@shared/schemas/tray-icon-color'
import type { NativeImage } from 'electron'
import { nativeImage, nativeTheme } from 'electron'
@@ -109,13 +113,16 @@ export function createWindowsIconProvider(
// ─── Linux: themed PNG icons ────────────────────────────────
export function createLinuxIconProvider(
- trayAssetDir: string
+ trayAssetDir: string,
+ getColor: () => TrayIconColor = () => DEFAULT_TRAY_ICON_COLOR
): TrayIconProvider {
let normalIcon: NativeImage | null = null
let activeIcon: NativeImage | null = null
function getThemePrefix(): string {
// Asset names describe the background: dark uses white artwork and vice versa.
+ const color = getColor()
+ if (color !== 'auto') return color === 'light' ? 'dark' : 'light'
return nativeTheme.shouldUseDarkColors ? 'dark' : 'light'
}
@@ -147,7 +154,8 @@ export function createLinuxIconProvider(
export function createIconProvider(
svgPath: string,
- trayAssetDir: string
+ trayAssetDir: string,
+ getColor?: () => TrayIconColor
): TrayIconProvider {
switch (process.platform) {
case 'darwin':
@@ -155,6 +163,6 @@ export function createIconProvider(
case 'win32':
return createWindowsIconProvider(trayAssetDir)
default:
- return createLinuxIconProvider(trayAssetDir)
+ return createLinuxIconProvider(trayAssetDir, getColor)
}
}
diff --git a/src/main/platform/tray.test.ts b/src/main/platform/tray.test.ts
index 3a43b1c3..5f6df5ff 100644
--- a/src/main/platform/tray.test.ts
+++ b/src/main/platform/tray.test.ts
@@ -3,6 +3,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
const {
appDock,
+ iconProviderFactory,
icon,
iconProvider,
nativeThemeMock,
@@ -24,6 +25,7 @@ const {
return {
appDock: { hide: vi.fn(), show: vi.fn() },
+ iconProviderFactory: vi.fn(),
icon: { kind: 'tray-icon' },
iconProvider: {
getIcon: vi.fn(),
@@ -70,7 +72,7 @@ vi.mock('@core/logger', () => ({
}))
vi.mock('./tray-icon', () => ({
- createIconProvider: () => iconProvider,
+ createIconProvider: iconProviderFactory,
}))
vi.mock('./tray-speedometer', () => ({
@@ -79,29 +81,22 @@ vi.mock('./tray-speedometer', () => ({
import { RunMode } from '@shared/constants'
import { Events } from '@shared/protocol/events'
+import { DEFAULT_APP_SETTINGS } from '@shared/schemas'
+import type { MotrixAppSettings } from '@shared/types/settings'
import { setupTray, type TrayDeps } from './tray'
const originalPlatform = process.platform
const trayMenu = { kind: 'tray-menu' }
const toggleMainWindow = vi.fn()
-function createDeps(
- appSettings: {
- lightweightMode: boolean
- runMode: RunMode
- traySpeedometer: boolean
- } = {
- lightweightMode: false,
- runMode: RunMode.Standard,
- traySpeedometer: false,
- }
-): TrayDeps {
+function createDeps(appSettings: Partial<MotrixAppSettings> = {}): TrayDeps {
+ const settings = { ...DEFAULT_APP_SETTINGS, ...appSettings }
return {
eventBus: {
off: vi.fn(),
on: vi.fn(),
},
- settingsManager: { getApp: () => appSettings },
+ settingsManager: { getApp: () => settings },
menuManager: {
getTrayMenu: () => trayMenu,
onTrayRebuilt: vi.fn(),
@@ -135,6 +130,7 @@ function getThemeUpdatedHandler(): () => Promise<void> {
describe('setupTray', () => {
beforeEach(() => {
vi.resetAllMocks()
+ iconProviderFactory.mockReturnValue(iconProvider)
iconProvider.getIcon.mockReturnValue(icon)
iconProvider.init.mockResolvedValue(undefined)
})
@@ -202,6 +198,22 @@ describe('setupTray', () => {
expect(trayConstructor).not.toHaveBeenCalled()
})
+ it('keeps Linux activity changes received while tray icons are loading', async () => {
+ Object.defineProperty(process, 'platform', { value: 'linux' })
+ const pending = Promise.withResolvers<void>()
+ iconProvider.init.mockReturnValueOnce(pending.promise)
+ const deps = createDeps()
+ const handle = setupTray(deps)
+ const activeChanged = vi
+ .mocked(deps.eventBus.on)
+ .mock.calls.find(([event]) => event === Events.EngineActiveChanged)?.[1]
+ activeChanged?.(true)
+ pending.resolve()
+ await vi.waitFor(() => expect(trayConstructor).toHaveBeenCalledOnce())
+ expect(iconProvider.getIcon).toHaveBeenLastCalledWith(true)
+ handle.destroy()
+ })
+
it.each(['win32', 'linux'])(
'destroys the native tray while preparing to quit on %s',
async (platform) => {
@@ -242,6 +254,86 @@ describe('setupTray', () => {
}
)
+ it.each(['linux', 'win32'])(
+ 'updates activity on %s even with the default macOS speedometer preference',
+ async (platform) => {
+ Object.defineProperty(process, 'platform', { value: platform })
+ const deps = createDeps()
+ expect(deps.settingsManager.getApp().traySpeedometer).toBe(true)
+ const handle = setupTray(deps)
+ await vi.waitFor(() => expect(trayConstructor).toHaveBeenCalledOnce())
+ const activeChanged = vi
+ .mocked(deps.eventBus.on)
+ .mock.calls.find(([event]) => event === Events.EngineActiveChanged)?.[1]
+ for (const active of [true, false]) {
+ trayInstance.setImage.mockClear()
+ activeChanged?.(active)
+ expect(iconProvider.getIcon).toHaveBeenLastCalledWith(active)
+ expect(trayInstance.setImage).toHaveBeenCalledExactlyOnceWith(icon)
+ }
+ expect(speedometer.setEnabled).not.toHaveBeenCalled()
+ handle.destroy()
+ }
+ )
+
+ it('does not replace an enabled macOS speedometer on activity changes', async () => {
+ Object.defineProperty(process, 'platform', { value: 'darwin' })
+ const deps = createDeps()
+ const handle = setupTray(deps)
+ await vi.waitFor(() => expect(trayConstructor).toHaveBeenCalledOnce())
+ const activeChanged = vi
+ .mocked(deps.eventBus.on)
+ .mock.calls.find(([event]) => event === Events.EngineActiveChanged)?.[1]
+ activeChanged?.(true)
+ expect(speedometer.setEnabled).toHaveBeenCalledWith(true)
+ expect(trayInstance.setImage).not.toHaveBeenCalled()
+ handle.destroy()
+ })
+
+ it('applies Linux color changes immediately and resumes automatic theme updates', async () => {
+ Object.defineProperty(process, 'platform', { value: 'linux' })
+ const deps = createDeps()
+ const handle = setupTray(deps)
+ await vi.waitFor(() => expect(trayConstructor).toHaveBeenCalledOnce())
+ const activeChanged = vi
+ .mocked(deps.eventBus.on)
+ .mock.calls.find(([event]) => event === Events.EngineActiveChanged)?.[1]
+ const settingsChanged = vi
+ .mocked(deps.eventBus.on)
+ .mock.calls.find(([event]) => event === Events.SettingsChanged)?.[1]
+ activeChanged?.(true)
+ const getColor = iconProviderFactory.mock.calls[0]?.[2]
+ expect(getColor).toBeTypeOf('function')
+
+ for (const trayIconColor of ['light', 'dark', 'auto'] as const) {
+ const old = { app: { ...deps.settingsManager.getApp() } }
+ deps.settingsManager.getApp().trayIconColor = trayIconColor
+ trayInstance.setImage.mockClear()
+ settingsChanged?.({
+ old,
+ updated: { app: deps.settingsManager.getApp() },
+ })
+ await vi.waitFor(() =>
+ expect(trayInstance.setImage).toHaveBeenCalledExactlyOnceWith(icon)
+ )
+ expect(getColor()).toBe(trayIconColor)
+ expect(iconProvider.getIcon).toHaveBeenLastCalledWith(true)
+ expect(trayConstructor).toHaveBeenCalledOnce()
+
+ iconProvider.init.mockClear()
+ trayInstance.setImage.mockClear()
+ await getThemeUpdatedHandler()()
+ if (trayIconColor === 'auto') {
+ expect(iconProvider.init).toHaveBeenCalledOnce()
+ expect(trayInstance.setImage).toHaveBeenCalledExactlyOnceWith(icon)
+ } else {
+ expect(iconProvider.init).not.toHaveBeenCalled()
+ expect(trayInstance.setImage).not.toHaveBeenCalled()
+ }
+ }
+ handle.destroy()
+ })
+
it.each(['darwin', 'win32'])(
'does not reload native tray icons for theme changes on %s',
async (platform) => {
diff --git a/src/main/platform/tray.ts b/src/main/platform/tray.ts
index 677a48f4..2d94ee20 100644
--- a/src/main/platform/tray.ts
+++ b/src/main/platform/tray.ts
@@ -86,12 +86,16 @@ export function setupTray(deps: TrayDeps): TrayHandle {
if (tray || isDisposed) return
log.info('creating tray')
- const nextIconProvider = createIconProvider(svgPath, trayAssetDir)
+ const nextIconProvider = createIconProvider(
+ svgPath,
+ trayAssetDir,
+ () => settingsManager.getApp().trayIconColor
+ )
await nextIconProvider.init()
if (isDisposed) return
iconProvider = nextIconProvider
- const icon = iconProvider.getIcon(false)
+ const icon = iconProvider.getIcon(isActive)
tray =
process.platform === 'darwin'
? new Tray(icon, MACOS_TRAY_GUID)
@@ -209,7 +213,7 @@ export function setupTray(deps: TrayDeps): TrayHandle {
// ─── EventBus Listeners ─────────────────────────────────
- async function onNativeThemeUpdated() {
+ async function refreshTrayIcon() {
const currentTray = tray
const currentProvider = iconProvider
if (!currentTray || !currentProvider) return
@@ -220,10 +224,15 @@ export function setupTray(deps: TrayDeps): TrayHandle {
if (tray !== currentTray || iconProvider !== currentProvider) return
currentTray.setImage(currentProvider.getIcon(isActive))
} catch (err) {
- log.error({ err }, 'tray theme refresh failed')
+ log.error({ err }, 'tray icon refresh failed')
}
}
+ async function onNativeThemeUpdated() {
+ if (settingsManager.getApp().trayIconColor !== 'auto') return
+ await refreshTrayIcon()
+ }
+
function onSettingsChanged(payload: unknown) {
const { old: oldSettings, updated } = payload as {
old: AppSettings
@@ -267,8 +276,18 @@ export function setupTray(deps: TrayDeps): TrayHandle {
)
}
- // Speedometer toggled
- if (oldSettings.app.traySpeedometer !== updated.app.traySpeedometer) {
+ if (
+ process.platform === 'linux' &&
+ oldSettings.app.trayIconColor !== updated.app.trayIconColor
+ ) {
+ void refreshTrayIcon()
+ }
+
+ // Only macOS renders a speedometer in place of the static icon.
+ if (
+ process.platform === 'darwin' &&
+ oldSettings.app.traySpeedometer !== updated.app.traySpeedometer
+ ) {
speedometer?.setEnabled(updated.app.traySpeedometer)
if (!updated.app.traySpeedometer && tray && iconProvider) {
// Revert to static icon
@@ -279,7 +298,9 @@ export function setupTray(deps: TrayDeps): TrayHandle {
function onEngineActiveChanged(active: unknown) {
isActive = active as boolean
- if (tray && iconProvider && !settingsManager.getApp().traySpeedometer) {
+ const usesSpeedometer =
+ process.platform === 'darwin' && settingsManager.getApp().traySpeedometer
+ if (tray && iconProvider && !usesSpeedometer) {
tray.setImage(iconProvider.getIcon(isActive))
}
}
diff --git a/src/renderer/routes/settings/cards/appearance-dialog.test.tsx b/src/renderer/routes/settings/cards/appearance-dialog.test.tsx
index a8d3a4b8..f893fae0 100644
--- a/src/renderer/routes/settings/cards/appearance-dialog.test.tsx
+++ b/src/renderer/routes/settings/cards/appearance-dialog.test.tsx
@@ -69,6 +69,93 @@ beforeEach(async () => {
})
describe('<AppearanceDialog>', () => {
+ it.each(['darwin', 'win32', 'web'])(
+ 'hides the Linux tray color selector on %s',
+ async (platform) => {
+ Object.defineProperty(transport, 'platform', {
+ configurable: true,
+ value: platform,
+ })
+ render(
+ <AppearanceDialog
+ open
+ onClose={vi.fn()}
+ labelKey="settings.cards.appearance.title"
+ descKey="settings.cards.appearance.desc"
+ />
+ )
+ await screen.findByRole('combobox', { name: 'Theme' })
+ expect(
+ screen.queryByRole('combobox', { name: 'Tray icon color' })
+ ).toBeNull()
+ }
+ )
+
+ it('lets Linux users save only the tray color without changing the application theme', async () => {
+ Object.defineProperty(transport, 'platform', {
+ configurable: true,
+ value: 'linux',
+ })
+ render(
+ <AppearanceDialog
+ open
+ onClose={vi.fn()}
+ labelKey="settings.cards.appearance.title"
+ descKey="settings.cards.appearance.desc"
+ />
+ )
+ const select = await screen.findByRole('combobox', {
+ name: 'Tray icon color',
+ })
+ expect(select).toHaveTextContent('Follow app theme')
+ const user = userEvent.setup({ pointerEventsCheck: 0 })
+ await user.click(select)
+ await user.click(
+ await screen.findByRole('option', { name: 'Light icon (dark panel)' })
+ )
+ expect(transport.invoke).not.toHaveBeenCalledWith(
+ Commands.UpdateSettings,
+ expect.anything()
+ )
+ await user.click(screen.getByRole('button', { name: 'Save' }))
+ expect(transport.invoke).toHaveBeenCalledWith(Commands.UpdateSettings, {
+ app: { trayIconColor: 'light' },
+ })
+ })
+
+ it('hydrates the saved Linux tray color and discards edits on cancel', async () => {
+ Object.defineProperty(transport, 'platform', {
+ configurable: true,
+ value: 'linux',
+ })
+ vi.mocked(transport.invoke).mockResolvedValue({
+ app: { ...FIXTURE.app, trayIconColor: 'dark' },
+ })
+ render(
+ <AppearanceDialog
+ open
+ onClose={vi.fn()}
+ labelKey="settings.cards.appearance.title"
+ descKey="settings.cards.appearance.desc"
+ />
+ )
+ const select = await screen.findByRole('combobox', {
+ name: 'Tray icon color',
+ })
+ await waitFor(() =>
+ expect(select).toHaveTextContent('Dark icon (light panel)')
+ )
+ const user = userEvent.setup({ pointerEventsCheck: 0 })
+ await user.click(select)
+ await user.click(
+ await screen.findByRole('option', { name: 'Follow app theme' })
+ )
+ await user.click(screen.getByRole('button', { name: 'Cancel' }))
+ expect(transport.invoke).not.toHaveBeenCalledWith(
+ Commands.UpdateSettings,
+ expect.anything()
+ )
+ })
it.each(['darwin', 'win32', 'linux', 'web'])(
'uses the existing glass switch and saves only that preference on %s',
async (platform) => {
diff --git a/src/renderer/routes/settings/cards/appearance-dialog.tsx b/src/renderer/routes/settings/cards/appearance-dialog.tsx
index cd7b4379..d4314249 100644
--- a/src/renderer/routes/settings/cards/appearance-dialog.tsx
+++ b/src/renderer/routes/settings/cards/appearance-dialog.tsx
@@ -56,6 +56,7 @@ type AppearanceFields = Pick<
| 'language'
| 'byteUnitSystem'
| 'traySpeedometer'
+ | 'trayIconColor'
| 'runMode'
| 'liquidGlassEffect'
| 'lightweightMode'
@@ -70,6 +71,7 @@ const DEFAULTS: AppearanceFields = {
language: DEFAULT_APP_SETTINGS.language,
byteUnitSystem: DEFAULT_APP_SETTINGS.byteUnitSystem,
traySpeedometer: DEFAULT_APP_SETTINGS.traySpeedometer,
+ trayIconColor: DEFAULT_APP_SETTINGS.trayIconColor,
runMode: DEFAULT_APP_SETTINGS.runMode,
liquidGlassEffect: DEFAULT_APP_SETTINGS.liquidGlassEffect,
lightweightMode: DEFAULT_APP_SETTINGS.lightweightMode,
@@ -108,6 +110,7 @@ export function AppearanceDialog({
language: all.app.language,
byteUnitSystem: all.app.byteUnitSystem ?? DEFAULTS.byteUnitSystem,
traySpeedometer: all.app.traySpeedometer,
+ trayIconColor: all.app.trayIconColor ?? DEFAULTS.trayIconColor,
runMode:
transport.platform !== 'darwin' &&
all.app.runMode === RunMode.HideTray
@@ -174,6 +177,11 @@ export function AppearanceDialog({
}>
const isMac = transport.platform === 'darwin'
const isLinux = transport.platform === 'linux'
+ const trayIconColorOptions = [
+ { value: 'auto', label: t('settings.appearance.trayIconColorAuto') },
+ { value: 'light', label: t('settings.appearance.trayIconColorLight') },
+ { value: 'dark', label: t('settings.appearance.trayIconColorDark') },
+ ] satisfies Array<{ value: AppearanceFields['trayIconColor']; label: string }>
const showRunMode = transport.platform !== 'web'
const runModeOptions = isMac
? [
@@ -361,6 +369,50 @@ export function AppearanceDialog({
)}
/>
+ {isLinux && (
+ <FormField
+ control={form.control}
+ name="trayIconColor"
+ render={({ field }) => (
+ <SettingsFormRow>
+ <div className="space-y-1">
+ <FormLabel>
+ {t('settings.appearance.trayIconColor')}
+ </FormLabel>
+ <FormDescription className="text-xs">
+ {t('settings.appearance.trayIconColorDesc')}
+ </FormDescription>
+ </div>
+ <FormControl>
+ <Select
+ items={trayIconColorOptions}
+ value={field.value}
+ onValueChange={(value) => {
+ if (value !== null) field.onChange(value)
+ }}
+ >
+ <SettingsSelectTrigger>
+ <SelectValue />
+ </SettingsSelectTrigger>
+ <SelectContent>
+ <SelectGroup>
+ {trayIconColorOptions.map((option) => (
+ <SelectItem
+ key={option.value}
+ value={option.value}
+ >
+ {option.label}
+ </SelectItem>
+ ))}
+ </SelectGroup>
+ </SelectContent>
+ </Select>
+ </FormControl>
+ </SettingsFormRow>
+ )}
+ />
+ )}
+
{isMac && (
<FormField
control={form.control}
diff --git a/src/renderer/routes/settings/cards/settings-form-schemas.test.ts b/src/renderer/routes/settings/cards/settings-form-schemas.test.ts
index f5706a98..397a6a50 100644
--- a/src/renderer/routes/settings/cards/settings-form-schemas.test.ts
+++ b/src/renderer/routes/settings/cards/settings-form-schemas.test.ts
@@ -75,6 +75,7 @@ describe('Settings form schemas', () => {
['general', 'defaultSaveDir', ' '],
['general', 'notifyOnComplete', 'yes'],
['appearance', 'theme', 'unknown'],
+ ['appearance', 'trayIconColor', 'white'],
['appearance', 'runMode', 999],
['advanced', 'rpcPort', 65536],
['advanced', 'rpcPort', NaN],
diff --git a/src/renderer/routes/settings/cards/settings-form-schemas.ts b/src/renderer/routes/settings/cards/settings-form-schemas.ts
index 0ad271e9..803bc43f 100644
--- a/src/renderer/routes/settings/cards/settings-form-schemas.ts
+++ b/src/renderer/routes/settings/cards/settings-form-schemas.ts
@@ -22,6 +22,7 @@ export const appearanceFormSchema = appSettingsInputSchema.pick({
language: true,
byteUnitSystem: true,
traySpeedometer: true,
+ trayIconColor: true,
runMode: true,
liquidGlassEffect: true,
lightweightMode: true,
diff --git a/src/shared/locales/en-US.json b/src/shared/locales/en-US.json
index 99d93f20..9fae72e5 100644
--- a/src/shared/locales/en-US.json
+++ b/src/shared/locales/en-US.json
@@ -1111,6 +1111,11 @@
"language": "Language",
"traySpeedometer": "Show real-time speed in tray",
"traySpeedometerDesc": "macOS only — display the current speed next to the tray icon.",
+ "trayIconColor": "Tray icon color",
+ "trayIconColorDesc": "Your panel may use a different theme from Motrix. Choose a light icon for a dark panel, or a dark icon for a light panel.",
+ "trayIconColorAuto": "Follow app theme",
+ "trayIconColorLight": "Light icon (dark panel)",
+ "trayIconColorDark": "Dark icon (light panel)",
"reduceMotion": "Reduce motion",
"reduceMotionDesc": "Reduce interface animations, including the glass motion effects on the Downloads page.",
"liquidGlassEffect": "Enable Liquid Glass effect",
diff --git a/src/shared/locales/zh-CN.json b/src/shared/locales/zh-CN.json
index add7214f..343ac1b0 100644
--- a/src/shared/locales/zh-CN.json
+++ b/src/shared/locales/zh-CN.json
@@ -1098,6 +1098,11 @@
"language": "语言",
"traySpeedometer": "在托盘显示实时速度",
"traySpeedometerDesc": "仅 macOS — 在托盘图标旁显示当前速度。",
+ "trayIconColor": "托盘图标颜色",
+ "trayIconColorDesc": "面板主题可能与 Motrix 不同。深色面板请选择浅色图标,浅色面板请选择深色图标。",
+ "trayIconColorAuto": "跟随应用主题",
+ "trayIconColorLight": "浅色图标(深色面板)",
+ "trayIconColorDark": "深色图标(浅色面板)",
"reduceMotion": "减少动画",
"reduceMotionDesc": "减少界面动画,包括下载页的玻璃动态效果。",
"liquidGlassEffect": "启用液态玻璃效果",
diff --git a/src/shared/locales/zh-TW.json b/src/shared/locales/zh-TW.json
index ff5a6a00..34ad16c0 100644
--- a/src/shared/locales/zh-TW.json
+++ b/src/shared/locales/zh-TW.json
@@ -1098,6 +1098,11 @@
"language": "語言",
"traySpeedometer": "在系統匣顯示即時速度",
"traySpeedometerDesc": "僅限 macOS,在系統匣圖示旁顯示目前速度。",
+ "trayIconColor": "系統匣圖示色彩",
+ "trayIconColorDesc": "面板佈景主題可能與 Motrix 不同。深色面板請選擇淺色圖示,淺色面板請選擇深色圖示。",
+ "trayIconColorAuto": "跟隨應用程式主題",
+ "trayIconColorLight": "淺色圖示(深色面板)",
+ "trayIconColorDark": "深色圖示(淺色面板)",
"reduceMotion": "減少動畫",
"reduceMotionDesc": "減少介面動畫,包括下載頁的玻璃動態效果。",
"liquidGlassEffect": "啟用液態玻璃效果",
diff --git a/src/shared/schemas/app-settings.test.ts b/src/shared/schemas/app-settings.test.ts
index ed1e18a7..d1c512d0 100644
--- a/src/shared/schemas/app-settings.test.ts
+++ b/src/shared/schemas/app-settings.test.ts
@@ -1,7 +1,28 @@
import { describe, expect, it } from 'vitest'
-import { appSettingsSchema, DEFAULT_APP_SETTINGS } from './app-settings'
+import {
+ appSettingsInputSchema,
+ appSettingsSchema,
+ DEFAULT_APP_SETTINGS,
+} from './app-settings'
describe('appSettingsSchema', () => {
+ it('defaults old or invalid tray colors to auto without resetting valid preferences', () => {
+ expect(DEFAULT_APP_SETTINGS.trayIconColor).toBe('auto')
+ for (const trayIconColor of [undefined, null, 'white', true]) {
+ expect(appSettingsSchema.parse({ trayIconColor }).trayIconColor).toBe(
+ 'auto'
+ )
+ }
+ for (const trayIconColor of ['auto', 'light', 'dark']) {
+ expect(appSettingsSchema.parse({ trayIconColor }).trayIconColor).toBe(
+ trayIconColor
+ )
+ }
+ expect(
+ appSettingsInputSchema.partial().safeParse({ trayIconColor: 'white' })
+ .success
+ ).toBe(false)
+ })
it('keeps selection timeout downloads opt-in with a 60 second default', () => {
expect(DEFAULT_APP_SETTINGS.magnetFileSelectionAutoDownload).toBe(false)
expect(DEFAULT_APP_SETTINGS.magnetFileSelectionTimeoutSeconds).toBe(60)
diff --git a/src/shared/schemas/app-settings.ts b/src/shared/schemas/app-settings.ts
index bbc9ff78..34a3c762 100644
--- a/src/shared/schemas/app-settings.ts
+++ b/src/shared/schemas/app-settings.ts
@@ -9,6 +9,7 @@ import {
import { DirectoryPreferencesSchema } from './directory-preferences'
import { supportedLocaleSchema } from './locale'
import { settingsInputObject } from './settings-input'
+import { DEFAULT_TRAY_ICON_COLOR, trayIconColorSchema } from './tray-icon-color'
export const appUpdateChannelSchema = z.enum(['stable', 'beta'])
@@ -46,6 +47,7 @@ export const appSettingsSchema = z.object({
runMode: z.enum(RunMode).catch(RunMode.Standard),
lightweightMode: z.boolean().catch(false),
traySpeedometer: z.boolean().catch(true),
+ trayIconColor: trayIconColorSchema.catch(DEFAULT_TRAY_ICON_COLOR),
magnetFileSelection: z.boolean().catch(true),
magnetFileSelectionAutoDownload: z.boolean().catch(false),
magnetFileSelectionTimeoutSeconds:
diff --git a/src/shared/schemas/tray-icon-color.ts b/src/shared/schemas/tray-icon-color.ts
new file mode 100644
index 00000000..eea1cffe
--- /dev/null
+++ b/src/shared/schemas/tray-icon-color.ts
@@ -0,0 +1,6 @@
+import { z } from 'zod'
+
+// Explicit colors describe the artwork, not the panel background.
+export const trayIconColorSchema = z.enum(['auto', 'light', 'dark'])
+export type TrayIconColor = z.infer<typeof trayIconColorSchema>
+export const DEFAULT_TRAY_ICON_COLOR: TrayIconColor = 'auto'
diff --git a/src/shared/types/settings.ts b/src/shared/types/settings.ts
index c2f4767a..1c5b92b8 100644
--- a/src/shared/types/settings.ts
+++ b/src/shared/types/settings.ts
@@ -1,4 +1,5 @@
import type { ByteUnitPreference } from '@shared/schemas/byte-unit-system'
+import type { TrayIconColor } from '@shared/schemas/tray-icon-color'
import type { RunMode } from '../constants'
import type { EnginePerformanceProfile } from '../constants/engine-performance-profiles'
import type { SupportedLocale } from '../constants/locales'
@@ -237,6 +238,8 @@ export interface MotrixAppSettings {
* services such as downloads, notifications, and the tray keep running. */
lightweightMode: boolean
traySpeedometer: boolean
+ /** Linux tray artwork color; auto follows the resolved application theme. */
+ trayIconColor: TrayIconColor
magnetFileSelection: boolean
magnetFileSelectionAutoDownload: boolean
magnetFileSelectionTimeoutSeconds: number