diff --git a/CLAUDE.md b/CLAUDE.md
index f4dad49..89977b0 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -365,7 +365,12 @@ agent-browser connect 9222
- `HOME` の付け替えは要らない(Windows の userData は `--user-data-dir` だけで決まる)。
- `electron out/main/index.js` で起動すると、「このアプリについて」の版は Electron の版になる
(package.json の無い `out/main` がアプリのパスになるため)。`npm run dev` なら正しい。
-- ウィンドウ枠ごと撮る `screencapture` に当たるものは無い。ページの描画は `agent-browser screenshot` で撮る。
+- ウィンドウ枠ごと撮る `screencapture` に当たるものは無い。ページの描画は `agent-browser screenshot` で撮る。枠やメニューバーまで
+ 見るときは、PowerShell で `GetWindowRect` と `Graphics.CopyFromScreen` を使い、**アプリのウィンドウの範囲だけ**を撮る
+ (画面全体を撮ると、利用者が開いている別の内容が写り込む)。
+- 通知は画面を撮らずに、`ToastNotificationManager.History.GetHistory('io.github.eddybean.exolobe')` で中身(本文・ボタン)を読む。
+- このセッションから送ったキー入力(`keybd_event` / SendKeys)では、グローバルショートカットが反応しなかった。登録できているかは、
+ 同じ組み合わせを `RegisterHotKey` で取りに行き、失敗する(Exolobe が握っている)ことで確かめ、押したときの動きは手で確かめる。
- **agent-browser の出力をパイプに通さない**(`| head` など)。最初の呼び出しで起動する常駐プロセスがパイプを
握ったままになり、コマンドが返らない。見たいときはファイルへリダイレクトしてから読む。
- `npm install -g agent-browser` を mise の Node で入れたら `mise reshim` する。しないと PATH に出てこない。
diff --git a/docs/decisions.html b/docs/decisions.html
index 58eb9fb..50bb92a 100644
--- a/docs/decisions.html
+++ b/docs/decisions.html
@@ -4456,6 +4456,12 @@
残した判断
変換とチャンネルの混ぜ合わせは Source Reader に任せた(左右に別の音を入れたステレオで、両方が残ることを確かめた)。
読める形式は afconvert と違い、webm / mkv / mov / wma / avi を読み、ogg / opus / aiff / caf を読まない(実機で確認)。
webm の Opus のように、ストアの拡張機能が入っているかで変わるものもある。
+ 画面・メニュー・トレイ・通知を Windows 11 の実機で見た(2026-10)。ウィンドウは標準の枠で、ナビとも重ならない。メニューバーは出したまま
+ (autoHideMenuBar にしない。録音の操作をメニューからも辿れるようにするため)。Windows では役割のメニューが Electron の既定の英語のまま
+ 出て日英が混ざったので、役割の項目にも UI の言語の名前とアクセスキーを付ける(macOS は OS の訳に任せる)。トレイの待機中のアイコンは
+ テンプレート画像が効かず黒のままで、ダークのタスクバーで見えなかったので、タスクバーの明暗に合わせて白く塗る。左クリックでウィンドウ、
+ 右クリックでメニュー(Windows の慣例)。ウィンドウを閉じても終わらず、二重起動でウィンドウが戻る。通知は Electron 44 が Windows の
+ トーストにもボタンを付けるので、トーストの XML は自前で書かない。書体は和文が Yu Gothic UI、等幅が Consolas で描かれる。
要約・チャット・意味検索(node-llama-cpp)と話者識別(sherpa-onnx-node)を Windows 11(RTX 5090、RAM 64GB)で動かした(2026-10)。
54 分・3 話者の合成会議で、文字起こし・話者識別・要約・エンコードが通り、チャットは引用付きで答え、意味検索も答えた。
ワーカーはジョブの後・使われなくなった後に終わり、VRAM も元に戻る(ADR-008)。声紋の取り出し(enableExternalBuffer = false)も Electron の中で通った。
diff --git a/src/main/i18n.ts b/src/main/i18n.ts
index 2ab92a7..6b75d6b 100644
--- a/src/main/i18n.ts
+++ b/src/main/i18n.ts
@@ -28,6 +28,33 @@ const ja = {
view: '表示',
openDocs: 'ドキュメントを開く'
},
+ /**
+ * Windows のメニューバー。macOS は役割のメニューを OS が訳すが、Windows では Electron の既定(英語)の
+ * まま出るので、役割の項目にも名前を付ける。(&F) などは Alt キーで開くためのアクセスキー。
+ */
+ windowsMenu: {
+ file: 'ファイル(&F)',
+ recording: '録音(&R)',
+ edit: '編集(&E)',
+ view: '表示(&V)',
+ window: 'ウィンドウ(&W)',
+ help: 'ヘルプ(&H)',
+ quit: '終了',
+ undo: '元に戻す',
+ redo: 'やり直し',
+ cut: '切り取り',
+ copy: 'コピー',
+ paste: '貼り付け',
+ selectAll: 'すべて選択',
+ reload: '再読み込み',
+ toggleDevTools: '開発者ツール',
+ resetZoom: '実際のサイズ',
+ zoomIn: '拡大',
+ zoomOut: '縮小',
+ togglefullscreen: '全画面表示',
+ minimize: '最小化',
+ close: '閉じる'
+ },
tray: {
recording: (title: string) => `録音中: ${title}`,
idle: '停止中',
@@ -111,6 +138,29 @@ const en: MainMessages = {
view: 'View',
openDocs: 'Open Documentation'
},
+ windowsMenu: {
+ file: '&File',
+ recording: '&Recording',
+ edit: '&Edit',
+ view: '&View',
+ window: '&Window',
+ help: '&Help',
+ quit: 'Exit',
+ undo: 'Undo',
+ redo: 'Redo',
+ cut: 'Cut',
+ copy: 'Copy',
+ paste: 'Paste',
+ selectAll: 'Select All',
+ reload: 'Reload',
+ toggleDevTools: 'Developer Tools',
+ resetZoom: 'Actual Size',
+ zoomIn: 'Zoom In',
+ zoomOut: 'Zoom Out',
+ togglefullscreen: 'Full Screen',
+ minimize: 'Minimize',
+ close: 'Close'
+ },
tray: {
recording: (title: string) => `Recording: ${title}`,
idle: 'Not Recording',
diff --git a/src/main/index.ts b/src/main/index.ts
index ab16bb0..0053eb1 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -8,6 +8,7 @@ import { registerIpcHandlers } from './ipc/handlers'
import { createApplicationMenu } from './menu'
import { createTray } from './tray'
import { claimSingleInstance } from './singleInstance'
+import appIcon from '../../build/icon.png?asset'
/**
* アプリのエントリポイント。
@@ -42,6 +43,9 @@ const createWindow = (): BrowserWindow => {
// macOS は信号機ボタンだけを残してナビゲーションをタイトルバーに重ねる。hiddenInset は macOS 専用で、
// Windows に渡すと最小化・閉じるのボタンごと消えるので、Windows は標準の枠のままにする(ADR-048)。
...(process.platform === 'darwin' ? { titleBarStyle: 'hiddenInset' as const } : {}),
+ // Windows はウィンドウの左上とタスクバーにアイコンを出す。指定しないと、開発中は Electron の既定のアイコンになる。
+ // macOS のウィンドウにはアイコンが出ず、Dock はアプリのアイコンを使うので渡さない。
+ ...(process.platform === 'darwin' ? {} : { icon: appIcon }),
webPreferences: {
preload: join(__dirname, '../preload/index.js'),
sandbox: false,
diff --git a/src/main/menu.ts b/src/main/menu.ts
index b9fe82f..adfa4ea 100644
--- a/src/main/menu.ts
+++ b/src/main/menu.ts
@@ -10,6 +10,76 @@ import { toAppPlatform, type AppPlatform } from '@shared/platform'
export const leadingMenuRole = (platform: AppPlatform): 'appMenu' | 'fileMenu' =>
platform === 'windows' ? 'fileMenu' : 'appMenu'
+export interface MenuActions {
+ readonly start: () => void
+ readonly stop: () => void
+ readonly showWindow: () => void
+ readonly openDocs: () => void
+}
+
+type Role = NonNullable
+type WindowsLabels = ReturnType['windowsMenu']
+
+/**
+ * 役割の項目。Windows では Electron の既定の名前(英語)が出るので UI の言語の名前を付け、
+ * macOS は OS の訳に任せて名前を付けない。
+ */
+const roleItem = (role: Role & keyof WindowsLabels, platform: AppPlatform): MenuItemConstructorOptions =>
+ platform === 'windows' ? { role, label: text().windowsMenu[role] } : { role }
+
+/**
+ * Windows で役割の「メニュー」(fileMenu など)を使わずに組む中身。役割のメニューは中の項目まで
+ * 英語の名前で作られるため、項目を並べて名前を付ける。
+ */
+const windowsSubmenu = (label: string, roles: readonly (Role & keyof WindowsLabels)[]): MenuItemConstructorOptions => ({
+ label,
+ submenu: roles.map((role) => roleItem(role, 'windows'))
+})
+
+/** メニューの中身。Electron に触らない純粋な関数にして、OS ごとの違いをテストで確かめる。 */
+export const applicationMenuTemplate = (params: {
+ platform: AppPlatform
+ active: boolean
+ actions: MenuActions
+}): MenuItemConstructorOptions[] => {
+ const { platform, active, actions } = params
+ const windows = platform === 'windows'
+ const w = text().windowsMenu
+
+ return [
+ windows ? windowsSubmenu(w.file, ['quit']) : { role: leadingMenuRole(platform) },
+ {
+ label: windows ? w.recording : text().menu.recording,
+ submenu: [
+ { label: text().menu.start, accelerator: 'CmdOrCtrl+R', enabled: !active, click: actions.start },
+ { label: text().menu.stop, accelerator: 'CmdOrCtrl+.', enabled: active, click: actions.stop },
+ { type: 'separator' },
+ { label: text().menu.showWindow, accelerator: 'CmdOrCtrl+0', click: actions.showWindow }
+ ]
+ },
+ windows ? windowsSubmenu(w.edit, ['undo', 'redo', 'cut', 'copy', 'paste', 'selectAll']) : { role: 'editMenu' },
+ {
+ label: windows ? w.view : text().menu.view,
+ submenu: [
+ roleItem('reload', platform),
+ roleItem('toggleDevTools', platform),
+ { type: 'separator' },
+ roleItem('resetZoom', platform),
+ roleItem('zoomIn', platform),
+ roleItem('zoomOut', platform),
+ { type: 'separator' },
+ roleItem('togglefullscreen', platform)
+ ]
+ },
+ windows ? windowsSubmenu(w.window, ['minimize', 'close']) : { role: 'windowMenu' },
+ {
+ role: 'help',
+ ...(windows ? { label: w.help } : {}),
+ submenu: [{ label: text().menu.openDocs, click: actions.openDocs }]
+ }
+ ]
+}
+
/**
* アプリケーションメニュー。
*
@@ -21,60 +91,22 @@ export const leadingMenuRole = (platform: AppPlatform): 'appMenu' | 'fileMenu' =
* 状態の変化を個別に監視するより、その都度組み立てた方が確実にずれない。
*/
export const createApplicationMenu = (controller: TransportController, showWindow: () => void): void => {
- const build = (): Menu => {
- const active = controller.state().active
-
- const template: MenuItemConstructorOptions[] = [
- { role: leadingMenuRole(toAppPlatform(process.platform)) },
- {
- label: text().menu.recording,
- submenu: [
- {
- label: text().menu.start,
- accelerator: 'CmdOrCtrl+R',
- enabled: !active,
- click: () => controller.request('start')
- },
- {
- label: text().menu.stop,
- accelerator: 'CmdOrCtrl+.',
- enabled: active,
- click: () => controller.request('stop')
- },
- { type: 'separator' },
- { label: text().menu.showWindow, accelerator: 'CmdOrCtrl+0', click: showWindow }
- ]
- },
- { role: 'editMenu' },
- {
- label: text().menu.view,
- submenu: [
- { role: 'reload' },
- { role: 'toggleDevTools' },
- { type: 'separator' },
- { role: 'resetZoom' },
- { role: 'zoomIn' },
- { role: 'zoomOut' },
- { type: 'separator' },
- { role: 'togglefullscreen' }
- ]
- },
- { role: 'windowMenu' },
- {
- role: 'help',
- submenu: [
- {
- label: text().menu.openDocs,
- click: () => {
- void shell.openExternal('https://github.com/eddybean/exolobe/tree/main/docs')
- }
- }
- ]
- }
- ]
-
- return Menu.buildFromTemplate(template)
+ const actions: MenuActions = {
+ start: () => controller.request('start'),
+ stop: () => controller.request('stop'),
+ showWindow,
+ openDocs: () => {
+ void shell.openExternal('https://github.com/eddybean/exolobe/tree/main/docs')
+ }
}
+ const build = (): Menu =>
+ Menu.buildFromTemplate(
+ applicationMenuTemplate({
+ platform: toAppPlatform(process.platform),
+ active: controller.state().active,
+ actions
+ })
+ )
Menu.setApplicationMenu(build())
diff --git a/src/main/tray.ts b/src/main/tray.ts
index b115b03..0c1fdaf 100644
--- a/src/main/tray.ts
+++ b/src/main/tray.ts
@@ -1,7 +1,8 @@
-import { Menu, Tray, nativeImage, type NativeImage } from 'electron'
+import { Menu, Tray, nativeImage, nativeTheme, type NativeImage } from 'electron'
import type { TransportController } from './ipc/handlers'
-import { trayIconFor } from './trayIcon'
+import { trayIconFor, whitenBitmap, type TrayAppearance } from './trayIcon'
import { text } from './i18n'
+import { toAppPlatform } from '@shared/platform'
/**
* メニューバーからの録音操作。
@@ -9,24 +10,35 @@ import { text } from './i18n'
* 会議中はウィンドウを閉じている(あるいは他アプリの背後にある)ことが多いため、
* 開始・停止だけはウィンドウ無しでも常に届く場所に置く。
*/
-const iconFor = (recording: boolean): NativeImage => {
- const choice = trayIconFor(recording)
+const iconFor = (recording: boolean, appearance: TrayAppearance): NativeImage => {
+ const choice = trayIconFor(recording, appearance)
// 32x32 を scaleFactor 2 として渡すと、16pt のアイコンとして扱われ Retina で滲まない。
- const icon = nativeImage.createFromBuffer(Buffer.from(choice.pngBase64, 'base64'), {
- width: 32,
- height: 32,
- scaleFactor: 2
- })
- // 待機中はテンプレート画像にしてライト/ダークに自動で色を合わせ、録音中は赤をそのまま見せる。
+ const size = { width: 32, height: 32, scaleFactor: 2 }
+ const decoded = nativeImage.createFromBuffer(Buffer.from(choice.pngBase64, 'base64'), size)
+ const icon = choice.whiten ? nativeImage.createFromBitmap(whitenBitmap(decoded.toBitmap()), size) : decoded
+ // macOS の待機中はテンプレート画像にしてライト/ダークに自動で色を合わせ、録音中は赤をそのまま見せる。
icon.setTemplateImage(choice.template)
return icon
}
+/** いまのタスクバー(メニューバー)の見た目。Windows のタスクバーはアプリの外観と別に明暗を持つ。 */
+const currentAppearance = (): TrayAppearance => ({
+ platform: toAppPlatform(process.platform),
+ darkTaskbar: nativeTheme.shouldUseDarkColorsForSystemIntegratedUI
+})
+
export const createTray = (controller: TransportController, showWindow: () => void): Tray => {
- const icons = { idle: iconFor(false), recording: iconFor(true) }
+ const makeIcons = (): { idle: NativeImage; recording: NativeImage } => {
+ const appearance = currentAppearance()
+ return { idle: iconFor(false, appearance), recording: iconFor(true, appearance) }
+ }
+ let icons = makeIcons()
const tray = new Tray(icons.idle)
tray.setToolTip('Exolobe')
+ // Windows ではトレイのアイコンを左クリックしたらウィンドウを出すのが慣例(右クリックはメニュー)。
+ // macOS はクリックでメニューを出すのが慣例なので、そのままにする。
+ if (process.platform === 'win32') tray.on('click', showWindow)
const refresh = (): void => {
const state = controller.state()
@@ -53,6 +65,11 @@ export const createTray = (controller: TransportController, showWindow: () => vo
}
refresh()
+ // タスクバーの明暗が変わったら、待機中のアイコンの色を合わせ直す(Windows)。
+ nativeTheme.on('updated', () => {
+ icons = makeIcons()
+ refresh()
+ })
// 録音状態が変わったら表示を追従させる。クリック時だけの更新では、
// ウィンドウ側で停止したときにトレイの表示が古いままになる。
controller.onStateChanged(refresh)
diff --git a/src/main/trayIcon.ts b/src/main/trayIcon.ts
index 498cd41..99100d6 100644
--- a/src/main/trayIcon.ts
+++ b/src/main/trayIcon.ts
@@ -1,3 +1,5 @@
+import type { AppPlatform } from '@shared/platform'
+
/**
* メニューバー用のアイコン。アプリアイコンと同じ「二本の軌跡」で、
* 中心線の上下に波形を分けて置く(上=相手、下=自分)。
@@ -29,9 +31,42 @@ export interface TrayIconChoice {
readonly pngBase64: string
/** テンプレート画像にすると OS が単色に塗り直すため、色を見せたいときは外す。 */
readonly template: boolean
+ /** 白く塗ってから使う(whitenBitmap)。 */
+ readonly whiten: boolean
+}
+
+/** アイコンを置く場所の見た目。Windows はタスクバー、macOS はメニューバー。 */
+export interface TrayAppearance {
+ readonly platform: AppPlatform
+ /** タスクバーがダークか。macOS は OS が塗り直すので見ない。 */
+ readonly darkTaskbar: boolean
}
-export const trayIconFor = (recording: boolean): TrayIconChoice =>
- recording
- ? { pngBase64: TRAY_ICON_RECORDING_PNG_BASE64, template: false }
- : { pngBase64: TRAY_ICON_PNG_BASE64, template: true }
+/**
+ * 待機中と録音中で使う画像。
+ *
+ * macOS の待機中はテンプレート画像にして OS に明暗を合わせさせる。Windows は setTemplateImage が効かず、
+ * 黒いままだとダークのタスクバーで見えなくなるので、タスクバーの明暗に合わせて待機中だけ白く塗る(ADR-048)。
+ * 録音中は、どちらでも赤をそのまま見せる。
+ */
+export const trayIconFor = (recording: boolean, appearance: TrayAppearance): TrayIconChoice => {
+ if (recording) return { pngBase64: TRAY_ICON_RECORDING_PNG_BASE64, template: false, whiten: false }
+ if (appearance.platform === 'macos') return { pngBase64: TRAY_ICON_PNG_BASE64, template: true, whiten: false }
+ return { pngBase64: TRAY_ICON_PNG_BASE64, template: false, whiten: appearance.darkTaskbar }
+}
+
+/**
+ * 4 バイト 1 画素(BGRA)の画像を、形(透明度)を保ったまま白く塗る。
+ * 色は透明度と同じ値にする。nativeImage の画素が透明度を乗算済みでも、乗算前でも白く見える
+ * (乗算前なら縁がわずかに暗くなるだけで、ダークのタスクバーでは目立たない)。
+ */
+export const whitenBitmap = (bitmap: Buffer): Buffer => {
+ const out = Buffer.from(bitmap)
+ for (let i = 0; i + 3 < out.length; i += 4) {
+ const alpha = out[i + 3] ?? 0
+ out[i] = alpha
+ out[i + 1] = alpha
+ out[i + 2] = alpha
+ }
+ return out
+}
diff --git a/src/renderer/styles.css b/src/renderer/styles.css
index 7f76103..d3f30ad 100644
--- a/src/renderer/styles.css
+++ b/src/renderer/styles.css
@@ -2210,6 +2210,12 @@ textarea:focus {
margin-top: 12px;
}
+/* 横に並ぶ説明が長い(英語)と、狭い幅でボタンの方が押し縮められて 2 行に折れる。折り返すのは説明だけにする。 */
+.permissions__test > button {
+ flex-shrink: 0;
+ white-space: nowrap;
+}
+
.permissions__results {
list-style: none;
margin: 12px 0 0;
diff --git a/src/types/electron-vite-assets.d.ts b/src/types/electron-vite-assets.d.ts
new file mode 100644
index 0000000..5784704
--- /dev/null
+++ b/src/types/electron-vite-assets.d.ts
@@ -0,0 +1,2 @@
+// main から `?asset` で読み込むファイル(ビルド時に出力先へ写され、実行時のパスになる)の型。
+///
diff --git a/tests/main/menu.test.ts b/tests/main/menu.test.ts
index 2e9ab5a..57fd68b 100644
--- a/tests/main/menu.test.ts
+++ b/tests/main/menu.test.ts
@@ -1,8 +1,10 @@
+import type { MenuItemConstructorOptions } from 'electron'
import { describe, expect, it, vi } from 'vitest'
vi.mock('electron', () => ({ Menu: {}, app: {}, shell: {} }))
-const { leadingMenuRole } = await import('../../src/main/menu')
+const { applicationMenuTemplate, leadingMenuRole } = await import('../../src/main/menu')
+const { setAppLocale, text } = await import('../../src/main/i18n')
describe('leadingMenuRole', () => {
it('macOS は先頭にアプリ名のメニュー(appMenu)を置く', () => {
@@ -13,3 +15,63 @@ describe('leadingMenuRole', () => {
expect(leadingMenuRole('windows')).toBe('fileMenu')
})
})
+
+const noop = (): void => {}
+const actions = { start: noop, stop: noop, showWindow: noop, openDocs: noop }
+
+/** 区切り線以外のすべての項目(入れ子を含む)。 */
+const items = (template: readonly MenuItemConstructorOptions[]): MenuItemConstructorOptions[] =>
+ template.flatMap((item) => [
+ ...(item.type === 'separator' ? [] : [item]),
+ ...(Array.isArray(item.submenu) ? items(item.submenu) : [])
+ ])
+
+describe('applicationMenuTemplate', () => {
+ it('Windows では、役割の項目にも UI の言語の名前を付ける(Electron の既定は英語のまま出る)', () => {
+ const template = applicationMenuTemplate({ platform: 'windows', active: false, actions })
+
+ expect(items(template).filter((item) => item.label === undefined)).toEqual([])
+ expect(template.map((item) => item.label)).toEqual([
+ 'ファイル(&F)',
+ '録音(&R)',
+ '編集(&E)',
+ '表示(&V)',
+ 'ウィンドウ(&W)',
+ 'ヘルプ(&H)'
+ ])
+ })
+
+ it('Windows のファイルメニューに終了がある', () => {
+ const [file] = applicationMenuTemplate({ platform: 'windows', active: false, actions })
+
+ expect(Array.isArray(file?.submenu) && file.submenu.some((item) => item.role === 'quit')).toBe(true)
+ })
+
+ it('英語の UI では英語の名前になる', () => {
+ setAppLocale('en')
+ try {
+ const template = applicationMenuTemplate({ platform: 'windows', active: false, actions })
+ expect(template.map((item) => item.label)).toEqual(['&File', '&Recording', '&Edit', '&View', '&Window', '&Help'])
+ } finally {
+ setAppLocale('ja')
+ }
+ })
+
+ it('macOS の役割のメニューは OS の訳に任せ、名前を付けない', () => {
+ const template = applicationMenuTemplate({ platform: 'macos', active: false, actions })
+
+ expect(template[0]).toEqual({ role: 'appMenu' })
+ expect(template.find((item) => item.role === 'editMenu')).toEqual({ role: 'editMenu' })
+ expect(template.find((item) => item.role === 'windowMenu')).toEqual({ role: 'windowMenu' })
+ })
+
+ it('録音中かどうかで開始と停止の有効・無効が入れ替わる', () => {
+ const recording = (active: boolean) =>
+ items(applicationMenuTemplate({ platform: 'windows', active, actions })).filter(
+ (item) => item.label === text().menu.start || item.label === text().menu.stop
+ )
+
+ expect(recording(false).map((item) => item.enabled)).toEqual([true, false])
+ expect(recording(true).map((item) => item.enabled)).toEqual([false, true])
+ })
+})
diff --git a/tests/main/tray-icon.test.ts b/tests/main/tray-icon.test.ts
index 966b564..3ef69ed 100644
--- a/tests/main/tray-icon.test.ts
+++ b/tests/main/tray-icon.test.ts
@@ -1,6 +1,11 @@
import { inflateSync } from 'node:zlib'
import { describe, expect, it } from 'vitest'
-import { TRAY_ICON_PNG_BASE64, TRAY_ICON_RECORDING_PNG_BASE64, trayIconFor } from '../../src/main/trayIcon'
+import {
+ TRAY_ICON_PNG_BASE64,
+ TRAY_ICON_RECORDING_PNG_BASE64,
+ trayIconFor,
+ whitenBitmap
+} from '../../src/main/trayIcon'
/**
* メニューバーのアイコンが実際に描画できる PNG であることを確かめる。
@@ -158,8 +163,50 @@ describe('待機中と録音中の見分け', () => {
expect(alphas(recording)).toEqual(alphas(idle))
})
- it('待機中はテンプレート画像、録音中は色付きの画像を使う', () => {
- expect(trayIconFor(false)).toEqual({ pngBase64: TRAY_ICON_PNG_BASE64, template: true })
- expect(trayIconFor(true)).toEqual({ pngBase64: TRAY_ICON_RECORDING_PNG_BASE64, template: false })
+ it('macOS の待機中はテンプレート画像(OS が明暗に合わせて塗る)、録音中は色付きの画像を使う', () => {
+ const macos = { platform: 'macos', darkTaskbar: false } as const
+ expect(trayIconFor(false, macos)).toEqual({ pngBase64: TRAY_ICON_PNG_BASE64, template: true, whiten: false })
+ expect(trayIconFor(true, macos)).toEqual({
+ pngBase64: TRAY_ICON_RECORDING_PNG_BASE64,
+ template: false,
+ whiten: false
+ })
+ })
+})
+
+/**
+ * Windows はテンプレート画像を塗り直さないので、黒いままだとダークのタスクバーで見えない。
+ * タスクバーの明暗に合わせて、待機中だけ白く塗る。
+ */
+describe('Windows のトレイのアイコン', () => {
+ it('ダークのタスクバーでは待機中のアイコンを白くする', () => {
+ expect(trayIconFor(false, { platform: 'windows', darkTaskbar: true })).toEqual({
+ pngBase64: TRAY_ICON_PNG_BASE64,
+ template: false,
+ whiten: true
+ })
+ })
+
+ it('ライトのタスクバーでは黒のまま見せる', () => {
+ expect(trayIconFor(false, { platform: 'windows', darkTaskbar: false })).toEqual({
+ pngBase64: TRAY_ICON_PNG_BASE64,
+ template: false,
+ whiten: false
+ })
+ })
+
+ it('録音中は明暗によらず赤のまま', () => {
+ expect(trayIconFor(true, { platform: 'windows', darkTaskbar: true })).toEqual({
+ pngBase64: TRAY_ICON_RECORDING_PNG_BASE64,
+ template: false,
+ whiten: false
+ })
+ })
+
+ it('白くするときは形(透明度)を変えず、色だけを透明度に合わせて塗る', () => {
+ // BGRA の 3 画素: 不透明の黒・半透明の黒・透明。乗算済みの画素でも壊れないよう、色は透明度と同じ値にする。
+ const bitmap = Buffer.from([0, 0, 0, 255, 0, 0, 0, 128, 0, 0, 0, 0])
+
+ expect([...whitenBitmap(bitmap)]).toEqual([255, 255, 255, 255, 128, 128, 128, 128, 0, 0, 0, 0])
})
})