Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ export function SecondaryPanelLayout({
}: SecondaryPanelLayoutProps) {
const paneContext = useOptionalPaneContext();
const secondaryPanelHost = paneContext?.secondaryPanelHost ?? null;
const inlinePaneTargetId =
secondaryPanelHost === null ? paneContext?.paneId : undefined;
const renderAsDrawer = useIsCompactViewport();
const sidebarDrawerShowing = useSyncExternalStore(
subscribeCompactSidebarDrawerShowing,
Expand Down Expand Up @@ -297,6 +299,7 @@ export function SecondaryPanelLayout({

const mainContent = (
<div
data-split-pane-id={inlinePaneTargetId}
data-conversation-collapsed={isMainCollapsed}
inert={isMainCollapsed}
className={cn(
Expand Down
1 change: 1 addition & 0 deletions apps/app/src/components/sidebar/usePaneContentSplitDrag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ export function usePaneContentSplitActions() {
zone,
threadAlreadyOpen: findPaneByContent(layout.root, content) !== null,
atMaxPanes: countPanes(layout.root) >= MAX_PANES,
singlePane: countPanes(layout.root) === 1,
});
},
onDrop: (target) => {
Expand Down
1 change: 1 addition & 0 deletions apps/app/src/components/sidebar/useThreadRowSplitDrag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export function useThreadRowSplitDrag({
threadAlreadyOpen:
findPaneByThread(layout.root, projectId, threadId) !== null,
atMaxPanes: countPanes(layout.root) >= MAX_PANES,
singlePane: countPanes(layout.root) === 1,
});
},
onDrop: (target) => {
Expand Down
11 changes: 11 additions & 0 deletions apps/app/src/lib/split-drag/zones.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,17 @@ describe("decideThreadDrop", () => {
).toEqual({ zone: "center", label: "Replace this chat" });
});

it("splits a center zone when the workspace has a single pane", () => {
expect(
decideThreadDrop({
zone: "center",
threadAlreadyOpen: false,
atMaxPanes: false,
singlePane: true,
}),
).toEqual({ zone: "right", label: "Split right" });
});

it("coerces edges to center-replace at the pane cap", () => {
expect(
decideThreadDrop({
Expand Down
10 changes: 8 additions & 2 deletions apps/app/src/lib/split-drag/zones.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,28 @@ interface ThreadDropInput {
zone: SplitZone;
threadAlreadyOpen: boolean;
atMaxPanes: boolean;
singlePane?: boolean;
}

export function decideThreadDrop({
zone,
threadAlreadyOpen,
atMaxPanes,
singlePane = false,
}: ThreadDropInput): ZoneDecision {
if (threadAlreadyOpen) {
return { zone: "center", label: "Already open — focus pane" };
}
if (atMaxPanes) {
return { zone: "center", label: "Replace this chat" };
}
const resolvedZone = singlePane && zone === "center" ? "right" : zone;
return {
zone,
label: zone === "center" ? "Replace this chat" : `Split ${zone}`,
zone: resolvedZone,
label:
resolvedZone === "center"
? "Replace this chat"
: `Split ${resolvedZone}`,
};
}

Expand Down