Skip to content

armgit / qm

Public Imported from GitHub
0

Multiplayer agent harness for work.

Remove Cmd/Ctrl+1-9 session-switch hotkeys (#1546)

Joshua France0ba49de5d9b4
diff --git a/plugins/web-ui/src/main.ts b/plugins/web-ui/src/main.ts
index b7f929c62..eaf5f9ddc 100644
--- a/plugins/web-ui/src/main.ts
+++ b/plugins/web-ui/src/main.ts
@@ -2,7 +2,6 @@ import "dockview-core/dist/styles/dockview.css";
import "./shell.css";
import { bootSafely, closeUserMenu } from "./shell";
import { registerChatSearchHotkey } from "./search";
-import { registerSessionJumpHotkeys } from "./session-jump";
import { closeFormMenus } from "./ui";
import { allConversations } from "./conversations";
import {
@@ -104,5 +103,4 @@ document.addEventListener(
);
registerChatSearchHotkey();
-registerSessionJumpHotkeys();
void bootSafely();
diff --git a/plugins/web-ui/src/search.ts b/plugins/web-ui/src/search.ts
index 2307c830d..5e779126f 100644
--- a/plugins/web-ui/src/search.ts
+++ b/plugins/web-ui/src/search.ts
@@ -27,7 +27,7 @@ interface ChatSearchHit {
const MIN_QUERY_LEN = 2;
const DEBOUNCE_MS = 150;
-export const isMac = /Mac|iP(hone|ad|od)/.test(navigator.platform);
+const isMac = /Mac|iP(hone|ad|od)/.test(navigator.platform);
const searchState = {
open: false,
diff --git a/plugins/web-ui/src/session-jump.ts b/plugins/web-ui/src/session-jump.ts
deleted file mode 100644
index 6188578cd..000000000
--- a/plugins/web-ui/src/session-jump.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-import { appState } from "./shell-state";
-import { isMac } from "./search";
-
-export function registerSessionJumpHotkeys(): void {
- document.addEventListener("keydown", (e) => {
- if (!(isMac ? e.metaKey : e.ctrlKey) || e.altKey || e.shiftKey) return;
- const digit = /^Digit([1-9])$/.exec(e.code)?.[1];
- if (!digit) return;
- const target = appState.listEl?.querySelectorAll<HTMLAnchorElement>("a.session")[Number(digit) - 1];
- if (!target) return;
- e.preventDefault();
- target.click();
- });
-}
diff --git a/plugins/web-ui/test/session-jump.test.ts b/plugins/web-ui/test/session-jump.test.ts
deleted file mode 100644
index 95ceaf279..000000000
--- a/plugins/web-ui/test/session-jump.test.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-import assert from "node:assert/strict";
-import { readFileSync } from "node:fs";
-import test from "node:test";
-
-const jump = readFileSync(new URL("../src/session-jump.ts", import.meta.url), "utf8");
-const main = readFileSync(new URL("../src/main.ts", import.meta.url), "utf8");
-const sessions = readFileSync(new URL("../src/sessions.ts", import.meta.url), "utf8");
-
-test("cmd+digit jumps to the Nth rendered sidebar session", () => {
- assert.match(jump, /isMac \? e\.metaKey : e\.ctrlKey/, "meta on mac, ctrl elsewhere");
- assert.match(jump, /e\.altKey \|\| e\.shiftKey/, "alt/shift combinations are left alone");
- assert.match(
- jump,
- /\^Digit\(\[1-9\]\)\$.*exec\(e\.code\)/,
- "physical digit keys, so shifted-digit layouts like AZERTY still work",
- );
- assert.match(
- jump,
- /appState\.listEl\?\.querySelectorAll<HTMLAnchorElement>\("a\.session"\)\[Number\(digit\) - 1\]/,
- "targets the Nth session anchor in rendered sidebar order, so pinned rows and visibility rules are honored for free",
- );
- assert.ok(
- jump.indexOf("e.preventDefault()") > jump.indexOf("if (!target) return"),
- "digits without a matching row fall through untouched",
- );
- assert.match(jump, /target\.click\(\)/, "reuses the row's click path (openSession, split intercept, view switch)");
-});
-
-test("the session jump hotkey is registered at boot", () => {
- assert.match(main, /registerSessionJumpHotkeys\(\)/);
-});
-
-test("sidebar session rows expose the anchor the hotkey targets", () => {
- const row = sessions.match(/function sessionRow\([^]*?\n\}/)?.[0] ?? "";
- assert.match(row, /class="session"/, "sessionRow renders an a.session anchor");
- assert.match(row, /void openSession\(s\);/, "clicking the anchor opens the session");
-});