feat: 预览标签页支持鼠标中键关闭 - #30
Merged
Merged
Conversation
Add middle-mouse-button (button===1) close support to preview panel tabs (file/browser/session-changes/git-changes), aligning with Chrome and VS Code behavior. Closing reuses the existing onCloseTab -> closePreview -> requestPreviewClose path, so unsaved-draft confirmation is inherited for free. Two changes in PreviewDetailsPanel.jsx: - handleTabMouseDown: middle button now calls preventDefault() to suppress the browser autoscroll cursor, then returns early (does NOT close here). - tab <button>: new onAuxClick handler routes middle-click to onCloseTab. Using auxclick (fires on button release) instead of mousedown keeps the close trigger isolated from the existing mousedown/pointerdown drag-reorder logic. No preference toggle added; the feature is always on (matches editor/terminal defaults). macOS trackpads have no middle button, so this only affects physical mice. Includes source-regex regression test in previewWorkbenchArchitecture.test.js and a SPEC doc at docs/superpowers/specs/.
shaohaozhi286
approved these changes
Aug 31, 2026
shaohaozhi286
left a comment
Collaborator
There was a problem hiding this comment.
批准合入。
中键关闭走 auxclick + onCloseTab,能复用未保存确认。handleTabMouseDown 对 button === 1 只 preventDefault 不关 tab;handleTabPointerDown 本来就只处理左键,不会跟拖拽冲突。源码正则回归覆盖了这条路径。
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.
摘要
在工作区预览面板的标签条(文档 / 浏览器 / 会话变更 / git 变更)上,支持鼠标中键按下即关闭对应标签页,对齐 Chrome、VS Code 的默认行为。
实现要点
改动集中在
web/src/components/PreviewDetailsPanel.jsx:<button>新增onAuxClick(button === 1)→ 复用现有onCloseTab→closePreview→requestPreviewClose链路。因此未保存草稿的确认弹窗免费继承,与 ✕ 按钮、右键菜单走同一条路径,未重写任何关闭逻辑。handleTabMouseDown对button === 1仅做preventDefault()挡掉浏览器中键自动滚动光标后早返回,不在此关闭;关闭交给独立的auxclick事件,与现有左键拖拽重排 / 激活逻辑完全隔离。决策背景
经澄清,相较 mousedown 方案选择
auxclick(按键抬起后派发,语义更标准,且不与拖拽启动逻辑在同一事件竞争分支)。macOS 触控板无中键,仅实体鼠标生效。验证
web/src/lib/previewWorkbenchArchitecture.test.js:onAuxClick路由到onCloseTab,且mousedown中键分支只抑制 autoscroll 不关闭。已通过。docs/superpowers/specs/2026-08-31-close-preview-tab-on-middle-click-design.md已知边界
stopPropagation拦截,结果一致,可接受)。🤖 Generated with WorkBuddy