@devries-cameron20 / t3code-1 / commits / 0c609ab87d
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(web): the device screen keeps focus when typing or returning to the window (#14534)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>

hayden committed Oct 19, 2026 at 00:50 UTC 0c609ab87d6066bc53c400828a69d72c6e518c9c
4 files changed +46 -1
apps/web/src/components/ChatView.logic.test.ts
+6
@@ -1953,6 +1953,12 @@ describe("shouldRefocusComposerOnWindowFocus", () => {
1953 expect(shouldRefocusComposerOnWindowFocus(element(tagName))).toBe(false);
1954 });
1955
1956 + it("leaves a focused device screen alone", () => {
1957 + expect(shouldRefocusComposerOnWindowFocus(element("DIV", { within: "application" }))).toBe(
1958 + false,
1959 + );
1960 + });
1961 +
1962 it("leaves a focused terminal alone in the drawer and the right panel", () => {
1963 expect(
1964 shouldRefocusComposerOnWindowFocus(element("BUTTON", { within: "data-terminal-owner" })),
apps/web/src/components/ChatView.logic.ts
+1 -1
@@ -1259,7 +1259,7 @@ export function shouldRefocusComposerOnWindowFocus(
1259 }
1260 return (
1261 activeElement.closest(
1262 - '[role="dialog"], [role="alertdialog"], [data-slot$="-popup"], [data-terminal-owner]',
1262 + '[role="dialog"], [role="alertdialog"], [role="application"], [data-slot$="-popup"], [data-terminal-owner]',
1263 ) === null
1264 );
1265 }
apps/web/src/components/chat/composerFocusRedirect.browser.test.ts new
+38
@@ -0,0 +1,38 @@
1 +import { afterEach, describe, expect, it } from "vite-plus/test";
2 +
3 +import { shouldTypeToFocusComposer } from "./composerFocusRedirect";
4 +
5 +// composedPath() is only populated while the event is dispatching, so decide
6 +// inside a window capture listener the way the chat view does.
7 +function typeOn(target: Element, key: string): boolean {
8 + let redirected = false;
9 + const listener = (event: KeyboardEvent) => {
10 + redirected = shouldTypeToFocusComposer(event);
11 + };
12 + window.addEventListener("keydown", listener, { capture: true });
13 + target.dispatchEvent(new KeyboardEvent("keydown", { key, bubbles: true, composed: true }));
14 + window.removeEventListener("keydown", listener, { capture: true });
15 + return redirected;
16 +}
17 +
18 +afterEach(() => {
19 + document.body.replaceChildren();
20 +});
21 +
22 +describe("shouldTypeToFocusComposer", () => {
23 + it("sends letters typed on the chat to the composer", () => {
24 + const chat = document.createElement("div");
25 + document.body.append(chat);
26 +
27 + expect(typeOn(chat, "a")).toBe(true);
28 + });
29 +
30 + it("keeps letters typed on the device screen on the device", () => {
31 + const deviceScreen = document.createElement("div");
32 + deviceScreen.setAttribute("role", "application");
33 + deviceScreen.tabIndex = 0;
34 + document.body.append(deviceScreen);
35 +
36 + expect(typeOn(deviceScreen, "a")).toBe(false);
37 + });
38 +});
apps/web/src/components/chat/composerFocusRedirect.ts
+1
@@ -13,6 +13,7 @@ const TYPE_TO_FOCUS_INTERACTIVE_SELECTOR = [
13 "button",
14 "a[href]",
15 "summary",
16 + '[role="application"]',
17 '[role="button"]',
18 '[role="checkbox"]',
19 '[role="menuitem"]',