feat: close tab with Cmd+W when tab bar is visible#3458
Open
ttmouse wants to merge 10 commits into
Open
Conversation
- 删除 TabBar 组件及其所有相关 state/handlers(tabOrderIds、tabRevealSignal、 visibleTabs、handleTabChange/Close/Reorder/NewTab 等) - 删除 workspace-tabs-bar 容器及 .workspace-tabs-bar CSS - 将右侧面板切换按钮移入 topicbar__actions 末尾,使用与 Copy/Export 一致的 topicbar__action-btn topicbar__action-btn--icon 样式 - 删除之前误加的 chat-pane__topbar 独立条及其 CSS - 还原被构建过程误删的 dist/.gitkeep
- 非编辑模式:h1 直接显示 tab.topicTitle,不再包含 workspace 前缀 - 编辑模式:去掉 topicbarProjectPrefix / 前缀 - 删除不再需要的 topicbarProjectPrefix 变量
移除 .project-tree__topic 的 margin-right: var(--project-tree-action-column), 该 36px 右间距是为一级菜单的 '+' 按钮预留的,二级菜单没有操作按钮, 却保留了该间距导致右侧出现多余空白,无法撑满全宽。
删除项目行左侧无实际意义的 Folder 图标,只保留展开箭头和颜色标识圆点。 这样一二级菜单的视觉更简洁统一。
- 将 .project-tree__topic 的 margin-left 从 22px 改为 11px - 文字起始位置 = 11px (margin) + 30px (padding: 14+16) = 41px - 与一级菜单文字起始位置 8+12+7+7+7=41px 完全对齐
给 .sidebar__new、.project-tree__search、.project-tree__header 添加 flex-shrink: 0,防止当项目列表内容过多时被 flex 容器压缩高度。
在新增项目按钮左侧增加一个双向箭头按钮,点击切换全部折叠/展开。 - 递归收集所有可展开节点 key 判断当前状态 - 动态 Tooltip:全部已展开→'Collapse all',否则→'Expand all' - 样式与旁边的 '+' 按钮一致
- 双击二级菜单直接进入重命名模式 - 选中状态改为圆角,移除左侧彩色条纹 - 右侧显示相对时间(3 分钟、1 天等),去掉'前'字 - 折叠/展开按钮图标区分状态:展开时 ⥮,折叠时 ⇅
- 新增 TAB_BAR_HIDDEN_KEY + loadTabBarHidden + tabBarHidden state - 恢复 TabBar 条件渲染:勾选(默认)= 显示,取消 = 隐藏 - 隐藏 Tab 栏时,面板切换按钮移到 topicbar__actions 右侧 - 恢复 workspace-tabs-bar CSS - SettingsPanel Appearance 最底部添加 On/Off 分段开关 - 通过自定义事件 reasonix:tabbar-visibility-changed 同步
Add a TabHotkeys component that closes the active tab on Cmd+W (macOS) or Ctrl+W (Windows/Linux). On macOS the native menu intercepts the shortcut and emits an 'app:close-tab' Wails event; the JS keydown listener is kept as a fallback on platforms without a native menu. Replace menu.WindowMenu() with a custom Window submenu that omits the conflicting 'Close Window' accelerator, and add a 'Close Tab' item to the File menu with Cmd+W bound to the new event.
esengine
requested changes
Jun 11, 2026
esengine
left a comment
Owner
There was a problem hiding this comment.
The Cmd/Ctrl+W mechanism itself is right (native menu emit + keydown fallback, refs avoiding stale closures, custom Window submenu to free the key) and we want it. Please strip the PR to exactly that:
- The "show tab bar" off-switch is an undisclosed product change — that needs an issue/discussion first, and any such setting must persist via desktop config (a SetXxx binding) like every other setting, not localStorage.
topicTitle(activeTab)→ hardcoded English "Untitled" drops i18n and the project prefix.- The ProjectTree restyling (collapse/expand-all, the
/前$/time-label suffix hack, icon/accent removal) duplicates #3698 and is unrelated here.
Re-cut from current main-v2 with just the close-tab feature + menu.go change and this merges quickly — fork CI gets approved as soon as it's pushed.
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
当顶部的 Tab 栏展开时,按下
Cmd+W(macOS)/Ctrl+W(Windows/Linux)关闭当前标签页。实现方式
File > Close Tab绑定 Cmd+W,通过runtime.EventsEmit发射app:close-tab事件到前端keydown监听作为 fallback(菜单在这些平台为 nil)tabBarHidden,仅 Tab 栏可见时生效文件变更
desktop/menu.go:新增Close Tab菜单项;替换menu.WindowMenu()为自定义 Window 子菜单(移除冲突的Cmd+W关闭窗口加速键)desktop/frontend/src/App.tsx:新增TabHotkeys组件,支持 Wails 事件 + JS keydown 双通路,使用 refs 防闭包过期