Skip to content

Commit 205c723

Browse files
author
rsi-pr-agent
committed
fixup! refactor(upstream-fixes): retire the terminal focus-request gate; upstream focusTerminal owns focus
Fork-Domain: upstream-fixes Fork-Tier: bugfix Fork-Upstreamable: yes
1 parent a4b48f8 commit 205c723

3 files changed

Lines changed: 20 additions & 5 deletions

File tree

‎apps/web/src/components/ThreadTerminalDrawer.tsx‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ import {
111111
registerTerminalFocusTarget,
112112
} from "../lib/terminalFocus";
113113
import { useReattachFocusFork } from "./terminalReattachFocus.fork"; // fork-hook: zmux-estate/terminal-reattach-focus
114+
import { useTerminalRetargetEffectFork } from "./terminalRetargetEffect.fork"; // fork-hook: upstream-fixes/terminal-retarget-effect-import
114115
import {
115116
resolveTerminalFontPreference,
116117
resolveTerminalFontSizePreference,
@@ -713,12 +714,10 @@ function TerminalSessionViewport({
713714
(listener: (session: TerminalSessionState) => void) =>
714715
appAtomRegistry.subscribe(terminalSessionAtom, listener),
715716
);
716-
useEffect(() => {
717-
if (launchIdentityRef.current === launchIdentity || !attached) return;
718-
launchIdentityRef.current = launchIdentity;
717+
useTerminalRetargetEffectFork(attached, launchIdentity, launchIdentityRef, () => {
719718
if (!hasTerminalWriteAccess()) return; // fork-hook: upstream-fixes/split-session-permissions
720719
void retargetTerminal();
721-
}, [attached, launchIdentity]);
720+
}); // fork-hook: upstream-fixes/terminal-retarget-effect
722721
const writeTerminal = useEffectEvent((data: string) => {
723722
return writeToRunningTerminalFork(readTerminalSession().status, () =>
724723
runTerminalWrite({

‎apps/web/src/components/terminalReattachFocus.fork.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export function useReattachFocusFork(
7171
containerRef: RefObject<HTMLElement | null>,
7272
) {
7373
const [controller] = useState(() => createReattachFocusFork(attached));
74-
// oxlint-disable-next-line t3code/react-effect-budget -- Reads DOM focus as the zmux attachment detaches.
74+
// oxlint-disable-next-line t3code/no-unreasoned-state-sync -- Reads DOM focus as the zmux attachment detaches.
7575
useEffect(() => {
7676
controller.attach(attached, restoreOnReattach, containerRef.current);
7777
}, [attached, containerRef, controller, restoreOnReattach]);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { type RefObject, useEffect, useEffectEvent } from "react";
2+
3+
export function useTerminalRetargetEffectFork(
4+
attached: boolean,
5+
launchIdentity: string,
6+
launchIdentityRef: RefObject<string | null>,
7+
retarget: () => void,
8+
) {
9+
const retargetNow = useEffectEvent(retarget);
10+
// oxlint-disable-next-line t3code/no-unreasoned-state-sync -- Retargets the attached terminal process when the launch location changes, deferring hidden splits until they reattach.
11+
useEffect(() => {
12+
if (launchIdentityRef.current === launchIdentity || !attached) return;
13+
launchIdentityRef.current = launchIdentity;
14+
retargetNow();
15+
}, [attached, launchIdentity, launchIdentityRef]);
16+
}

0 commit comments

Comments
 (0)