Skip to content

Commit 67e585c

Browse files
committed
fix(web): only the active split pane owns the app composer handle
1 parent 0ca501f commit 67e585c

1 file changed

Lines changed: 16 additions & 12 deletions

File tree

‎apps/web/src/components/chat/SplitChatWorkspace.tsx‎

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { memo, type CSSProperties, useRef, useState, useEffect, useLayoutEffect
44

55
import "./SplitChatWorkspace.css";
66

7+
import { ComposerHandleContext, useComposerHandleContext } from "../../composerHandleContext";
78
import { usePanelAnimationSettings } from "../../panelAnimations";
89
import { cn } from "../../lib/utils";
910
import { threadTargetKey, useSplitChatStore } from "../../splitChatStore";
@@ -32,6 +33,7 @@ export const SplitChatWorkspace = memo(function SplitChatWorkspace({
3233
modalOpen,
3334
}: SplitChatWorkspaceProps) {
3435
const navigate = useNavigate();
36+
const composerHandle = useComposerHandleContext();
3537
const animations = usePanelAnimationSettings();
3638
const store = useSplitChatStore();
3739
const {
@@ -105,6 +107,7 @@ export const SplitChatWorkspace = memo(function SplitChatWorkspace({
105107
];
106108

107109
const bounds = layoutBounds(count);
110+
const activeIndex = Math.min(activePaneIndex, count - 1);
108111

109112
const navigatePrimary = (target: ThreadRouteTarget) => {
110113
setPendingPrimary({ previousKey: primaryKey, target });
@@ -411,18 +414,19 @@ export const SplitChatWorkspace = memo(function SplitChatWorkspace({
411414
) : null
412415
}
413416
>
414-
<SplitChatPaneActiveContext
415-
value={count < 2 || Math.min(activePaneIndex, count - 1) === index}
416-
>
417-
<ThreadRouteView
418-
target={target}
419-
asPane
420-
ownsRoute={index === 0}
421-
background={modalOpen}
422-
onTargetUnavailable={
423-
count > 1 ? () => close(threadTargetKey(target)) : undefined
424-
}
425-
/>
417+
<SplitChatPaneActiveContext value={index === activeIndex}>
418+
{/* The app-wide composer handle belongs to the active pane only. */}
419+
<ComposerHandleContext value={index === activeIndex ? composerHandle : null}>
420+
<ThreadRouteView
421+
target={target}
422+
asPane
423+
ownsRoute={index === 0}
424+
background={modalOpen}
425+
onTargetUnavailable={
426+
count > 1 ? () => close(threadTargetKey(target)) : undefined
427+
}
428+
/>
429+
</ComposerHandleContext>
426430
</SplitChatPaneActiveContext>
427431
</SplitChatPaneControlsContext>
428432
</div>

0 commit comments

Comments
 (0)