Fix the review's findings: drag on pointer events, read the window back
Build App / compute-version (pull_request) Successful in 4s
Build App / build-macos (pull_request) Successful in 2m30s
Build App / build-linux (pull_request) Successful in 5m11s
Build App / build-windows (pull_request) Successful in 5m23s
Build App / create-tag (pull_request) Skipped
Build App / sync-to-github (pull_request) Skipped
Build App / compute-version (pull_request) Successful in 4s
Build App / build-macos (pull_request) Successful in 2m30s
Build App / build-linux (pull_request) Successful in 5m11s
Build App / build-windows (pull_request) Successful in 5m23s
Build App / create-tag (pull_request) Skipped
Build App / sync-to-github (pull_request) Skipped
Ten findings from the review of the previous commit, all applied. **The tab drag is now pointer events, not HTML5 drag-and-drop.** Two independent reasons, either one fatal. Tauri's `dragDropEnabled` blocks HTML5 drag inside the webview on Windows, and it cannot just be turned off — `TerminalView` needs Tauri's native drag-drop event, which is the only one that carries dropped *file paths*. And an HTML5 drag carries a `DataTransfer`: released over any text field in the app, the default handler types `term:<uuid>` into it, and in Config that is then saved with the project. Pointer events have neither problem, and the drag is measured from the tabs on screen rather than from the event target, so the marker and the drop agree even over the marker itself. Escape abandons a drag; a press under 4px stays a click; the click that ends a drag does not select. **`Ctrl+Shift+←/→` no longer swallows word-wise selection.** It is bound on `document` in the capture phase, so in any input — the rename field, Config, Settings — it was taking the OS's extend-selection chord *and* silently reordering the strip. Guarded by `inTextField()`, which excludes xterm's helper textarea: that is an input-method shim, and the terminal is where the shortcut matters most. **The pop-out's state is read from the window, never remembered.** The pane is unmounted whenever another Project Home sub-tab is selected, so "Keep on top" came back Off over a window still floating on top. `get_browser_view_popout_state` returns both facts from the window itself, and the change event carries them. `poppedOut` is tri-state: until the answer arrives the iframe is not mounted, because guessing "not popped out" is what flashes a second viewer onto the browser. Also: `popout::close` and the off-status emit in the supervisor are behind the same epoch guard as the deregistration above them, so a supervisor whose teardown outlives a restart can no longer destroy the *new* session's window; `close()` returns its `destroy()` error instead of logging it and reporting success, since the pane restores its iframe on success; the drop marker is `pointer-events-none` and is placed before the first *visible* tab at or past the slot, so it neither refuses a drop nor vanishes when a `tabOrder` entry renders nothing; and the "Keep on top" Toggle's accessible name now matches its visible text. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
||||
import { renderHook } from "@testing-library/react";
|
||||
import { useKeyboardShortcuts } from "./useKeyboardShortcuts";
|
||||
import { useAppState, homeTabKey, terminalTabKey } from "../store/appState";
|
||||
|
||||
vi.mock("./useTerminal", () => ({
|
||||
useTerminal: () => ({ open: vi.fn(), close: vi.fn() }),
|
||||
}));
|
||||
|
||||
const HOME = homeTabKey("p1");
|
||||
const S1 = terminalTabKey("s1");
|
||||
const S2 = terminalTabKey("s2");
|
||||
|
||||
const order = () => useAppState.getState().tabOrder;
|
||||
|
||||
/** Press a chord, from whatever is focused. */
|
||||
function press(key: string, { shift = false } = {}) {
|
||||
document.dispatchEvent(
|
||||
new KeyboardEvent("keydown", { key, ctrlKey: true, shiftKey: shift, bubbles: true }),
|
||||
);
|
||||
}
|
||||
|
||||
/** Focus a real element of the given kind, inside `parent` if given. */
|
||||
function focus(tag: "input" | "textarea", parentClass?: string): HTMLElement {
|
||||
const el = document.createElement(tag);
|
||||
if (parentClass) {
|
||||
const parent = document.createElement("div");
|
||||
parent.className = parentClass;
|
||||
parent.appendChild(el);
|
||||
document.body.appendChild(parent);
|
||||
} else {
|
||||
document.body.appendChild(el);
|
||||
}
|
||||
el.focus();
|
||||
return el;
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
useAppState.setState({ tabOrder: [HOME, S1, S2], activeTabKey: S1, activeSessionId: "s1" });
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
document.body.innerHTML = "";
|
||||
});
|
||||
|
||||
describe("Ctrl+Shift+←/→", () => {
|
||||
it("moves the active tab along the strip", () => {
|
||||
renderHook(() => useKeyboardShortcuts());
|
||||
|
||||
press("ArrowLeft", { shift: true });
|
||||
expect(order()).toEqual([S1, HOME, S2]);
|
||||
|
||||
press("ArrowRight", { shift: true });
|
||||
expect(order()).toEqual([HOME, S1, S2]);
|
||||
});
|
||||
|
||||
it("leaves word-wise selection alone in a text field", () => {
|
||||
// Ctrl+Shift+←/→ already means "extend the selection by a word" in every
|
||||
// input in the app — the rename field, Config fields, Settings fields.
|
||||
// Taking it there would break selection *and* silently reorder tabs.
|
||||
renderHook(() => useKeyboardShortcuts());
|
||||
focus("input");
|
||||
|
||||
press("ArrowLeft", { shift: true });
|
||||
|
||||
expect(order()).toEqual([HOME, S1, S2]);
|
||||
});
|
||||
|
||||
it("still moves tabs from the terminal, whose focus lives in a textarea", () => {
|
||||
// xterm keeps a hidden textarea focused as its input-method shim. It is
|
||||
// not a field anyone edits word-wise, and the terminal is where these
|
||||
// shortcuts matter most, so it is not treated as one.
|
||||
renderHook(() => useKeyboardShortcuts());
|
||||
focus("textarea", "xterm xterm-helper-textarea-host");
|
||||
|
||||
press("ArrowLeft", { shift: true });
|
||||
|
||||
expect(order()).toEqual([S1, HOME, S2]);
|
||||
});
|
||||
|
||||
it("does nothing without Shift — that chord is readline's word motion", () => {
|
||||
renderHook(() => useKeyboardShortcuts());
|
||||
|
||||
press("ArrowLeft");
|
||||
|
||||
expect(order()).toEqual([HOME, S1, S2]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user