Skip to content

Where agent teams gather. Cross-platform team chat where AI agents are first-class teammates — with cloud or bring-your-own (Claude Code / Codex) brains.

TypeScript

fix(windows): integrate native controls into app title bar

bingqilinweimaotai480196eb006a
diff --git a/electron/main.cjs b/electron/main.cjs
index 34ae50d..e3331af 100644
--- a/electron/main.cjs
+++ b/electron/main.cjs
@@ -606,6 +606,63 @@ let appIsQuitting = false
/** The "real" app window. */
let mainWindow = null
+
+function windowsTitleBarOverlay() {
+ const dark = nativeTheme.shouldUseDarkColors
+ return {
+ height: 44,
+ color: dark ? '#21252b' : '#FAFCFE',
+ symbolColor: dark ? '#abb2bf' : '#233A53',
+ }
+}
+
+function syncMainWindowTheme() {
+ if (!mainWindow || mainWindow.isDestroyed()) return
+ mainWindow.setBackgroundColor(nativeTheme.shouldUseDarkColors ? '#21252b' : '#E6F3FB')
+ if (process.platform === 'win32') mainWindow.setTitleBarOverlay(windowsTitleBarOverlay())
+}
+
+function buildWindowsMenu(locale) {
+ const zh = locale === 'zh-CN'
+ return Menu.buildFromTemplate([
+ {
+ id: 'app',
+ label: zh ? '应用' : 'App',
+ submenu: [
+ { label: zh ? '关于 Cumora' : 'About Cumora', click: () => app.showAboutPanel() },
+ { type: 'separator' },
+ { role: 'reload', label: zh ? '重新加载' : 'Reload' },
+ { role: 'forceReload', label: zh ? '强制重新加载' : 'Force Reload' },
+ { role: 'toggleDevTools', label: zh ? '开发者工具' : 'Developer Tools' },
+ { type: 'separator' },
+ { role: 'resetZoom', label: zh ? '实际大小' : 'Actual Size' },
+ { role: 'zoomIn', label: zh ? '放大' : 'Zoom In' },
+ { role: 'zoomOut', label: zh ? '缩小' : 'Zoom Out' },
+ { role: 'togglefullscreen', label: zh ? '切换全屏' : 'Toggle Full Screen' },
+ { type: 'separator' },
+ { role: 'minimize', label: zh ? '最小化' : 'Minimize' },
+ { role: 'close', label: zh ? '关闭窗口' : 'Close Window' },
+ { role: 'quit', label: zh ? '退出 Cumora' : 'Quit Cumora' },
+ ],
+ },
+ {
+ id: 'edit',
+ label: zh ? '编辑' : 'Edit',
+ submenu: [
+ { role: 'undo', label: zh ? '撤销' : 'Undo' },
+ { role: 'redo', label: zh ? '重做' : 'Redo' },
+ { type: 'separator' },
+ { role: 'cut', label: zh ? '剪切' : 'Cut' },
+ { role: 'copy', label: zh ? '复制' : 'Copy' },
+ { role: 'paste', label: zh ? '粘贴' : 'Paste' },
+ { role: 'pasteAndMatchStyle', label: zh ? '粘贴为纯文本' : 'Paste as Plain Text' },
+ { role: 'delete', label: zh ? '删除' : 'Delete' },
+ { type: 'separator' },
+ { role: 'selectAll', label: zh ? '全选' : 'Select All' },
+ ],
+ },
+ ])
+}
/** Frameless transparent always-on-top window pinned to the top-right
* of the primary display. Renders the same React bundle with the
* `#notifications` hash so it shows only the toast stack. Hidden when
@@ -1143,7 +1200,8 @@ function createWindow() {
show: false,
backgroundColor: '#E6F3FB',
icon: ICON_PATH,
- titleBarStyle: process.platform === 'darwin' ? 'hidden' : 'default',
+ titleBarStyle: process.platform === 'darwin' || process.platform === 'win32' ? 'hidden' : 'default',
+ ...(process.platform === 'win32' ? { titleBarOverlay: windowsTitleBarOverlay() } : {}),
trafficLightPosition: { x: 16, y: 15 },
webPreferences: {
preload: path.join(__dirname, 'preload.cjs'),
@@ -1157,6 +1215,12 @@ function createWindow() {
},
})
+ if (process.platform === 'win32') {
+ // Keep native menu accelerators registered without reserving a menu-bar row.
+ Menu.setApplicationMenu(buildWindowsMenu(app.getLocale().startsWith('zh') ? 'zh-CN' : 'en'))
+ mainWindow.setMenuBarVisibility(false)
+ }
+
// Forward native OS-level focus state to the renderer. We can't rely on
// `document.hasFocus()` from inside the renderer — in Electron on macOS
// it returns stale `true` values when the window is unfocused, which
@@ -1431,20 +1495,29 @@ ipcMain.handle('clipboard:write-text', (event, value) => {
if (clipboard.readText() !== value) throw new Error('clipboard write failed')
})
+ipcMain.handle('window:show-menu', (event, options) => {
+ if (process.platform !== 'win32' || !mainWindow || mainWindow.isDestroyed()
+ || event.sender !== mainWindow.webContents) return
+ const { menu, locale, x, y } = options ?? {}
+ if ((menu !== 'app' && menu !== 'edit') || !Number.isFinite(x) || !Number.isFinite(y)) return
+ const [width, height] = mainWindow.getContentSize()
+ const zoom = mainWindow.webContents.getZoomFactor()
+ buildWindowsMenu(locale).getMenuItemById(menu).submenu.popup({
+ window: mainWindow,
+ x: Math.max(0, Math.min(width - 1, Math.round(x * zoom))),
+ y: Math.max(0, Math.min(height - 1, Math.round(y * zoom))),
+ })
+})
+
ipcMain.on('theme:set', (_event, source) => {
if (source !== 'system' && source !== 'light' && source !== 'dark') return
nativeTheme.themeSource = source
- if (mainWindow && !mainWindow.isDestroyed()) {
- const dark = source === 'dark' || (source === 'system' && nativeTheme.shouldUseDarkColors)
- mainWindow.setBackgroundColor(dark ? '#21252b' : '#E6F3FB')
- }
+ syncMainWindowTheme()
})
nativeTheme.on('updated', () => {
if (nativeTheme.themeSource !== 'system') return
- if (mainWindow && !mainWindow.isDestroyed()) {
- mainWindow.setBackgroundColor(nativeTheme.shouldUseDarkColors ? '#21252b' : '#E6F3FB')
- }
+ syncMainWindowTheme()
})
// Renderer asks main to open a URL in the user's default browser
diff --git a/electron/preload.cjs b/electron/preload.cjs
index d0af5b0..f0339e8 100644
--- a/electron/preload.cjs
+++ b/electron/preload.cjs
@@ -24,6 +24,10 @@ contextBridge.exposeInMainWorld('cumora', {
},
},
+ window: {
+ showMenu: (options) => ipcRenderer.invoke('window:show-menu', options),
+ },
+
/** OS clipboard write, independent of Chromium document focus. */
clipboard: {
writeText: (value) => ipcRenderer.invoke('clipboard:write-text', value),
diff --git a/src/desktop/TitleBar.tsx b/src/desktop/TitleBar.tsx
index 0a40a82..51a4b9f 100644
--- a/src/desktop/TitleBar.tsx
+++ b/src/desktop/TitleBar.tsx
@@ -1,10 +1,13 @@
+import type { CSSProperties, MouseEvent } from 'react'
import { CloudLogo } from '@/components/Avatar'
import { CompanySwitcher } from '@/components/CompanySwitcher'
-import { isElectron, trafficLightInset } from '@/lib/runtime'
-import { useT } from '@/lib/i18n'
+import { isElectron, isWindows, trafficLightInset } from '@/lib/runtime'
+import { useLocaleStore, useT } from '@/lib/i18n'
export function TitleBar() {
const t = useT()
+ const locale = useLocaleStore((s) => s.locale)
+ const windowsChrome = isElectron && isWindows
// In Electron with hidden titleBarStyle on mac, native traffic lights land in this strip.
// Reserve space on the left for them, and make the bar a draggable region.
const dragStyle = isElectron
@@ -17,17 +20,37 @@ export function TitleBar() {
// to be. The auto middle column shrinks to the title's intrinsic width,
// so the 1fr cells on either side balance perfectly.
const reservedLeft = Math.max(84, trafficLightInset)
+ const showMenu = (menu: 'app' | 'edit', event: MouseEvent<HTMLButtonElement>) => {
+ const rect = event.currentTarget.getBoundingClientRect()
+ void window.cumora?.window?.showMenu({ menu, locale, x: rect.left, y: rect.bottom })
+ }
+
return (
<header
- className="grid items-center px-4 border-b border-ink-100"
+ className={`grid shrink-0 items-center px-4 ${windowsChrome ? '' : 'border-b border-ink-100'}`}
style={{
height: 44,
- background: 'var(--chrome)',
+ background: windowsChrome ? 'var(--paper)' : 'var(--chrome)',
gridTemplateColumns: `1fr auto 1fr`,
...dragStyle,
}}
>
- {!isElectron ? (
+ {windowsChrome ? (
+ <div className="flex items-center gap-1" style={{ WebkitAppRegion: 'no-drag' } as CSSProperties}>
+ <button
+ type="button"
+ aria-haspopup="menu"
+ onClick={(event) => showMenu('app', event)}
+ className="rounded-md px-2 py-1 text-[12px] text-ink-500 hover:bg-ink-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-skype"
+ >{t('common.applicationMenu')}</button>
+ <button
+ type="button"
+ aria-haspopup="menu"
+ onClick={(event) => showMenu('edit', event)}
+ className="rounded-md px-2 py-1 text-[12px] text-ink-500 hover:bg-ink-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-skype"
+ >{t('common.editMenu')}</button>
+ </div>
+ ) : !isElectron ? (
<div className="flex gap-2" style={{ paddingLeft: 0 }}>
<span className="w-3 h-3 rounded-full" style={{ background: '#FF6058', boxShadow: 'inset 0 -1px 0 rgba(0,0,0,0.1)' }} />
<span className="w-3 h-3 rounded-full" style={{ background: '#FFBD2E', boxShadow: 'inset 0 -1px 0 rgba(0,0,0,0.1)' }} />
@@ -43,9 +66,15 @@ export function TitleBar() {
<div className="flex items-center justify-center gap-2.5 font-display font-medium text-[14px] text-ink-700 tracking-wide whitespace-nowrap">
<CloudLogo />
<span>Cumora</span>
- <em className="font-normal text-ink-500" style={{ fontStyle: 'italic' }}>{t('common.titlebarTagline')}</em>
+ <em className={`${windowsChrome ? 'hidden xl:inline' : ''} font-normal text-ink-500`} style={{ fontStyle: 'italic' }}>{t('common.titlebarTagline')}</em>
</div>
- <div className="flex items-center justify-end pr-2">
+ <div
+ className="flex min-w-0 items-center justify-end pr-2"
+ style={windowsChrome ? {
+ // Overlay geometry follows Windows DPI, window state, and renderer zoom.
+ paddingRight: 'calc(100vw - env(titlebar-area-x, 0px) - env(titlebar-area-width, calc(100vw - 138px)) + 8px)',
+ } : undefined}
+ >
<CompanySwitcher />
</div>
</header>
diff --git a/src/lib/runtime.ts b/src/lib/runtime.ts
index 728c040..4143f46 100644
--- a/src/lib/runtime.ts
+++ b/src/lib/runtime.ts
@@ -37,6 +37,9 @@ interface CumoraBridge {
isFocused: () => Promise<boolean>
onFocusChange: (handler: (focused: boolean) => void) => () => void
}
+ window?: {
+ showMenu: (options: { menu: 'app' | 'edit'; locale: string; x: number; y: number }) => Promise<void>
+ }
/** Native clipboard write for desktop commands; works while the renderer is unfocused. */
clipboard?: {
writeText: (value: string) => Promise<void>
diff --git a/src/locales/en.ts b/src/locales/en.ts
index edba73b..9b7c1bc 100644
--- a/src/locales/en.ts
+++ b/src/locales/en.ts
@@ -28,6 +28,8 @@ export const en = {
'common.chatLayout.thread': 'Official',
'common.chatLayout.bubble': 'Left & right',
'common.titlebarTagline': '— where agent teams gather',
+ 'common.applicationMenu': 'App',
+ 'common.editMenu': 'Edit',
'common.daemonOutdatedTip': 'A computer daemon needs updating — open You',
'common.cancel': 'Cancel',
'common.done': 'Done',
diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.ts
index 129b3f6..b0b9e34 100644
--- a/src/locales/zh-CN.ts
+++ b/src/locales/zh-CN.ts
@@ -34,6 +34,8 @@ export const zhCN: Partial<Record<keyof typeof en, string>> = {
'common.chatLayout.thread': '官方',
'common.chatLayout.bubble': '左右气泡',
'common.titlebarTagline': '—— 智能体团队的汇合地',
+ 'common.applicationMenu': '应用',
+ 'common.editMenu': '编辑',
'common.daemonOutdatedTip': '某台计算机的守护进程需要更新——打开「我」',
'common.cancel': '取消',
'common.done': '完成',