Compare commits

...
Author SHA1 Message Date
Cursor Agentand陈大猫 a608507586 fix(window): let close blur the focused field during inline rename
Minimize and maximize still suppress mousedown focus so restore keeps the terminal focused. Close does not, so session and host-group renames can commit on blur.

Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com>
2026-10-19 15:21:21 +00:00
Cursor Agentand陈大猫 6c7338463d fix(window): keep terminal focus when clicking title-bar window controls
Prevent the frameless minimize, maximize, and close buttons from taking
DOM focus on mousedown so restore from the taskbar leaves the terminal
textarea focused.

Co-authored-by: 陈大猫 <binaricat@users.noreply.github.com>
2026-10-19 15:03:58 +00:00
2 changed files with 28 additions and 2 deletions

No files matched your search

+20
View File
@@ -294,6 +294,26 @@ test("session close button double click stays on the close button", () => {
assert.match(topTabItemsSource, /onDoubleClick=\{stopCloseButtonDoubleClickPropagation\}/);
});
test("main window controls keep mouse presses from taking focus", () => {
const windowControlsSource = topTabItemsSource.slice(
topTabItemsSource.indexOf("export const WindowControls"),
topTabItemsSource.indexOf("WindowControls.displayName"),
);
assert.match(
windowControlsSource,
/const preventWindowControlFocus: React\.MouseEventHandler<HTMLButtonElement> = \(event\) => \{\s*event\.preventDefault\(\);\s*\};/,
);
assert.equal(windowControlsSource.match(/onMouseDown=\{preventWindowControlFocus\}/g)?.length, 2);
const closeButton = windowControlsSource.match(
/<button type="button" className=\{closeControlClassName\}[^>]*>/,
)?.[0] ?? "";
assert.equal(closeButton.includes("onMouseDown"), false);
assert.match(windowControlsSource, /onClick=\{handleMinimize\}/);
assert.match(windowControlsSource, /onClick=\{handleMaximize\}/);
assert.match(windowControlsSource, /onClick=\{handleClose\}/);
});
test("session top tab label only shows the host label for ssh sessions", () => {
assert.equal(
formatSessionTopTabLabel({
+8 -2
View File
@@ -310,13 +310,19 @@ export const WindowControls: React.FC = memo(() => {
const controlClassName = 'window-control-btn app-no-drag';
const closeControlClassName = 'window-control-btn window-control-btn--close app-no-drag';
// Mouse press would move DOM focus onto minimize/maximize. After restore
// that leaves the terminal textarea unfocused, so keystrokes do nothing.
// Close skips this so the active field still blurs (inline rename commits on blur).
const preventWindowControlFocus: React.MouseEventHandler<HTMLButtonElement> = (event) => {
event.preventDefault();
};
return (
<div className="ml-2 flex h-7 items-center overflow-visible app-no-drag">
<button type="button" className={controlClassName} onClick={handleMinimize}>
<button type="button" className={controlClassName} onMouseDown={preventWindowControlFocus} onClick={handleMinimize}>
<Minus size={16} />
</button>
<button type="button" className={controlClassName} onClick={handleMaximize}>
<button type="button" className={controlClassName} onMouseDown={preventWindowControlFocus} onClick={handleMaximize}>
{isMaximized ? <Copy size={14} /> : <Square size={14} />}
</button>
<button type="button" className={closeControlClassName} onClick={handleClose}>