diff --git a/desktop/src/features/channels/ui/AgentSessionAuxiliaryPanel.tsx b/desktop/src/features/channels/ui/AgentSessionAuxiliaryPanel.tsx new file mode 100644 index 0000000000..4ee5a6b879 --- /dev/null +++ b/desktop/src/features/channels/ui/AgentSessionAuxiliaryPanel.tsx @@ -0,0 +1,72 @@ +import { AgentSessionThreadPanel } from "@/features/channels/ui/AgentSessionThreadPanel"; +import * as agentSessionSelection from "@/features/channels/ui/agentSessionSelection"; +import type { ChannelPaneProps } from "@/features/channels/ui/ChannelPane.types"; + +type AgentSessionAuxiliaryPanelProps = Pick< + ChannelPaneProps, + "openAgentSessionChannelId" | "profiles" +> & { + activeChannel: NonNullable; + // ChannelPane defaults this prop, so it is always defined at this call site. + activityAgents: NonNullable; + isSinglePanelView: boolean; + onBack: ChannelPaneProps["onBackFromAgentSession"]; + onClose: ChannelPaneProps["onCloseAgentSession"]; + selectedAgent: NonNullable< + ReturnType + >; + useSplitAuxiliaryPane: boolean; + widthPx: number; +}; + +/** + * Assembles the agent-session auxiliary pane for ChannelPane's pane chain. + * Split out of ChannelPane.tsx to keep it under the per-file line cap. + */ +export function AgentSessionAuxiliaryPanel({ + activeChannel, + activityAgents, + isSinglePanelView, + onBack, + onClose, + openAgentSessionChannelId, + profiles, + selectedAgent, + useSplitAuxiliaryPane, + widthPx, +}: AgentSessionAuxiliaryPanelProps) { + // When the panel was opened from a different channel than the currently + // active one, re-scope it to the active channel so that both the + // content/header AND channel-backed actions (e.g. Stop current turn) + // operate on the same channel object. + const effectiveAgentSessionChannelId = + openAgentSessionChannelId && activeChannel.id !== openAgentSessionChannelId + ? activeChannel.id + : openAgentSessionChannelId; + return ( + + ); +} diff --git a/desktop/src/features/channels/ui/ChannelPane.tsx b/desktop/src/features/channels/ui/ChannelPane.tsx index 56d9475464..cabbd213e0 100644 --- a/desktop/src/features/channels/ui/ChannelPane.tsx +++ b/desktop/src/features/channels/ui/ChannelPane.tsx @@ -28,9 +28,9 @@ import { buildVideoReviewPresentationByMessageId } from "@/features/messages/lib import { isThreadReply } from "@/features/messages/lib/threading"; import { useComposerHeightPadding } from "@/features/messages/ui/useComposerHeightPadding"; import { UserProfilePanel } from "@/features/profile/ui/UserProfilePanel"; -import { AgentSessionThreadPanel } from "@/features/channels/ui/AgentSessionThreadPanel"; +import { AgentSessionAuxiliaryPanel } from "@/features/channels/ui/AgentSessionAuxiliaryPanel"; import { ChannelManagementAuxiliaryPanel } from "@/features/channels/ui/ChannelManagementAuxiliaryPanel"; -import { MarkdownDocPanel } from "@/features/channels/ui/MarkdownDocPanel"; +import { MarkdownDocAuxiliaryPanel } from "@/features/channels/ui/MarkdownDocAuxiliaryPanel"; import { RightAuxiliaryPane } from "@/features/channels/ui/RightAuxiliaryPane"; import { ThreadViewModeToggle } from "@/features/channels/ui/ThreadViewModeToggle"; import { FocusThreadDrawer } from "@/features/channels/ui/FocusThreadDrawer"; @@ -948,42 +948,21 @@ export const ChannelPane = React.memo(function ChannelPane({ return wrapThreadPanel(panel); })() ) : activeChannel && selectedAgent ? ( - (() => { - const effectiveAgentSessionChannelId = - openAgentSessionChannelId && - activeChannel.id !== openAgentSessionChannelId - ? activeChannelId - : openAgentSessionChannelId; - const panel = ( - - ); - return wrapAux(panel, "agent-session-thread-panel"); - })() + wrapAux( + , + "agent-session-thread-panel", + ) ) : profilePanelPubkey ? ( (() => { const panel = ( @@ -1009,29 +988,16 @@ export const ChannelPane = React.memo(function ChannelPane({ return wrapAux(panel, "user-profile-panel"); })() ) : openMarkdownDoc && onCloseMarkdownDoc ? ( - (() => { - // Lowest-priority pane: a higher-priority pane opened afterwards - // (thread, activity, profile) shows immediately, and the document - // reappears when it closes. Opening a document clears competitors - // in the screen-level handler, so it is never dead on arrival. - const panel = ( - // Keyed by URL so opening a different document resets the - // Preview/Code toggle instead of inheriting the previous doc's. - - ); - return wrapAux(panel, "markdown-doc-panel"); - })() + wrapAux( + , + "markdown-doc-panel", + ) ) : null} diff --git a/desktop/src/features/channels/ui/ChannelScreen.tsx b/desktop/src/features/channels/ui/ChannelScreen.tsx index b60f1706b4..2b6872dcdf 100644 --- a/desktop/src/features/channels/ui/ChannelScreen.tsx +++ b/desktop/src/features/channels/ui/ChannelScreen.tsx @@ -833,9 +833,7 @@ export function ChannelScreen({ searchTarget, ) ) : ( - // Scoped to the pane that hosts the markdown-doc auxiliary - // panel — the forum branch has no host, so its FileCards keep - // download behavior instead of a dead open-in-viewer click. + // Forum has no doc-panel host; its FileCards keep downloading. void; + useSplitAuxiliaryPane: boolean; + widthPx: number; +}; + +/** + * Assembles the markdown-document auxiliary pane for ChannelPane's pane + * chain. Split out of ChannelPane.tsx to keep it under the per-file line + * cap. + * + * This is the chain's lowest-priority pane: a higher-priority pane opened + * afterwards (thread, activity, profile) shows immediately, and the document + * reappears when it closes. Opening a document clears competitors in the + * screen-level handler, so it is never dead on arrival. + */ +export function MarkdownDocAuxiliaryPanel({ + doc, + isSinglePanelView, + onClose, + useSplitAuxiliaryPane, + widthPx, +}: MarkdownDocAuxiliaryPanelProps) { + return ( + // Keyed by URL so opening a different document resets the Preview/Code + // toggle instead of inheriting the previous document's. + + ); +}