[FEATURE]: Desktop v2 — custom titlebar with native window controls on Linux
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 功能
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- electron, linux, typescript
- 领域
- desktop-dev
调研方向
Start in the desktop main process where the window factory branches only on darwin/win32: add the Linux branch and check the overlay factory's max(44, 44 * zoom) height against the 36 px header. Relax the win32 guard on the setTitleBarOverlay updater so theme switches reach Linux, then align the five renderer conditions (hideVerticalTitlebar, actionInSidebarHeader, the titlebar toggle, the vertical-tabs header, useCollapsedSlot) with the Windows path. PR #52338 already holds this change, so rebasing it is the fastest route; done means WCO visible at 36 px, legible buttons in both themes, and no duplicate collapsed toggle.
由索引模型根据 Issue 内容生成。
描述
- I have checked that this feature has not been requested before (see "Related" below — the only prior request, #36225, was closed as not planned for v1 with a note to open a v2 request)
Description
On Linux the desktop app still gets a native GTK titlebar, stacked on top of its own top bar: two headers, and the app menu / sidebar toggle sit in the second one. Windows and macOS have a single custom top bar with the window controls drawn at its right edge (macOS keeps its traffic lights at the left). Linux should look the same.
Environment: OpenCode desktop v2 2.3.2 (Fedora RPM opencode-2.3.2-1.x86_64), Electron 44.9.1 / Chromium 152, Fedora 44, GNOME on Wayland, org.gnome.desktop.interface color-scheme = prefer-dark.
Electron supports this on Linux: titleBarStyle: "hidden" together with titleBarOverlay enables the Window Controls Overlay (WCO), and Chromium draws real minimize / maximize / close buttons itself — no custom button component needed. That is the same mechanism the Windows build already uses.
Related
- #36225 — Desktop: use custom titlebar instead of native GNOME/GTK titlebar on Linux. Closed as not planned for v1; the closing note said v2 still uses the native frame and a separate v2 request should be opened, hence this issue.
- #52338 — PR doing essentially the change below for v2 (Linux WCO,
frame.tsrefactor, tests, screenshots for left/right/split controls and vertical tabs). Auto-closed by the stale/cleanup bot; the author asked for it to be reopened. - #37620 — earlier attempt, closed unmerged.
If #52338 can be reopened, it is probably the better vehicle; this issue is meant to record the v2 request and the exact behaviour expected.
What the 2.3.2 build actually does
Putting the shipped app.asar next to Electron's docs:
-
Window options (main process): the factory only branches on
darwin(titleBarStyle: "hidden",trafficLightPosition) andwin32(frame: false,titleBarStyle: "hidden",titleBarOverlay). Linux matches neither, so it gets Electron's defaultframe: true. -
Overlay colours on theme change: the renderer calls
WindowSetTitlebar({ mode, scheme })whenever a theme is applied; the desktop chunk stores it and calls a helper that is guarded byprocess.platform === "win32". On Linux the overlay keeps its window-creation colours, so as soon as the app theme differs from the system theme the buttons are dark-on-dark or light-on-light. -
Renderer, non-Windows branches that exist because Linux had a native titlebar:
hideVerticalTitlebar— with vertical tabs the app top bar is hidden on every non-Windows platform.actionInSidebarHeader— on non-Windows the first action ("home" / "new session") moves into the sidebar header.- the titlebar sidebar toggle — shown only on Windows.
- the vertical-tabs sidebar header — shown on non-Windows.
useCollapsedSlot— the floating collapsed-sidebar toggle is excluded only on Windows, because elsewhere the header had no toggle of its own.
Remove the native frame without touching these and the result is worse than today: no native titlebar and no app menu (the top bar is hidden under vertical tabs).
Proposed change
- Main, window options: add a Linux branch —
frame: false,titleBarStyle: "hidden",titleBarOverlay: { ... }. Keep macOS and Windows as they are. - Overlay height: the overlay factory returns
max(44, round(44 * zoom)), sized for the Windows header (which includes a content inset). The Linux header row is 36 px, so the height should follow the platform (or the header height constant) rather than reuse 44. - Overlay colours: relax the
win32guard on thesetTitleBarOverlayupdater to "every platform with an overlay" (i.e. not macOS), so theme switches updatesymbolColor/coloron Linux too. - Renderer: treat Linux like Windows, not like macOS, in the five places above — keep the app top bar under vertical tabs, put the sidebar toggle in the top bar next to the menu button, drop the duplicate sidebar header and the floating collapsed toggle. This is what the Windows layout already is.
- GTK button layout: if feasible, respect
org.gnome.desktop.wm.preferences button-layout(buttons on the left is a common setting). Not a blocker — WCO drawn on the right matches the current Windows layout and is what my local test does. - Escape hatch: Wayland resize-by-edge behaviour with
frame: falsediffers slightly from a native frame. An env/setting gate (e.g. keep native decorations if set) would let users opt out while this settles.
Verified locally
I applied the change above as equal-length byte patches to the 2.3.2 app.asar (no source build) and measured it through the main-process inspector and renderer CDP:
BrowserWindow.getBounds()andgetContentBounds()are identical, before and after maximize/restore → no native frame remains.navigator.windowControlsOverlay.visible === true;getTitlebarAreaRect()is 1167×36 in a 1280 px window — 113 px at the top right reserved for the system buttons, matching the 36 px header row.- Top bar
[data-slot=titlebar-v2]is visible at 36 px, menu button at (12, 8), sidebar toggle at (50, 8), app menu opens normally. - Collapsing the sidebar sets
[data-slot=vertical-tabs-sidebar]width to 0 and leaves zero[data-slot=collapsed-sidebar-toggle]elements; flipping the condition back to the original makes the floating toggle reappear at (18, 54), which confirms the duplicate. - Theme switch:
setTitleBarOverlayis called withsymbolColor: "black"for the light theme and"white"for the dark one, height 36 in both. Visually the buttons stay legible in both themes. maximize()/unmaximize()/minimize()/restore()/close()all work; the WCO buttons call the sameBrowserWindowmethods.
Caveats: screenshots were not possible on this machine (no screencopy under this GNOME/Wayland session), so "the buttons are drawn" is confirmed only through the WCO API and the reserved rect — #52338's screenshots cover the visual side. Only one configuration was tested (Fedora 44 / GNOME / Wayland / Electron 44.9.1, vertical tabs), and the WCO reserve means a horizontal-tabs layout with third-party titlebar plugin items can have its rightmost item covered.
I am happy to help turn this into a source-level PR (or to review / rebase #52338) if that is useful.
- 主要语言
- TypeScript
- 星标
- 227k
- 派生
- 30.7k
- 平均合并
- 3 小时 57 分钟
- 30 天内合并 PR
- 484
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
anomalyco/opencode 的其他 Issue
-
[Site] Active section detection should respect scroll-margin-top可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭area/web reproduced type/bug
难度 2/5 1-3 小时 新手友好度 65/100
anomalyco/opencode#65384 · 1 条评论 ·
维护者通常 1 天内回复
-
area/cli type/feature version/v2
难度 2/5 1-3 小时 新手友好度 68/100
anomalyco/opencode#65379 · 1 条评论 ·
维护者通常 1 天内回复
-
Shell tool: no upper bound on the timeout a model can ask for, so one call can hold a turn for hours未关闭area/core platform/linux type/feature version/v2
难度 2/5 1-3 小时 新手友好度 75/100
anomalyco/opencode#65254 · 1 条评论 ·
维护者通常 1 天内回复
-
inference/go type/feature
难度 1/5 1-3 小时 新手友好度 72/100
anomalyco/opencode#65148 · 1 条评论 ·
维护者通常 1 天内回复
-
area/providers type/feature version/v2
难度 2/5 1-3 小时 新手友好度 68/100
anomalyco/opencode#64845 · 1 条评论 ·
维护者通常 1 天内回复
查看 anomalyco/opencode 的全部 Issue
相似的 Issue
-
[Provider] antigravity-acp catalog omits gemini-4-hydrogen and gemini-4-neon that agy acp offers未关闭catalog provider provider-compatibility
难度 2/5 1-3 小时 新手友好度 62/100
lidge-jun/opencodex#9037 · 1 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 62/100
slavakurilyak/awesome-ai-agents#1005 ·
-
kind/bug triage/unresolved
难度 2/5 1-3 小时 新手友好度 60/100
维护者通常 1 天内回复
-
effort:S P3 refactor
难度 2/5 1-3 小时 新手友好度 72/100
nightscout/nocturne#3735 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
wpilibsuite/systemcore-blocks-interface#641 ·
维护者通常 2 天内回复