Skip to content

Commit e6738c5

Browse files
tellahonpub1223z34hd7vtwc6qj4s7flsxkj644nlre2nthu7lrrmkumhu3xddsrx9r6w
andauthored
refactor(desktop): centralize auxiliary panel shell (#1343)
Signed-off-by: Taylor Ho <[email protected]> Co-authored-by: npub1223z34hd7vtwc6qj4s7flsxkj644nlre2nthu7lrrmkumhu3xddsrx9r6w <52a228d6edf316ec6812ac3c9fc0d696ab59fc7954d77e7be31eedcddf91335b@sprout-oss.stage.blox.sqprod.co>
1 parent db1b617 commit e6738c5

26 files changed

Lines changed: 1206 additions & 626 deletions
Lines changed: 102 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ArrowLeft, CircleDot, Octagon, X } from "lucide-react";
1+
import { Octagon, Settings } from "lucide-react";
22
import { toast } from "sonner";
33

44
import { ManagedAgentSessionPanel } from "@/features/agents/ui/ManagedAgentSessionPanel";
@@ -8,24 +8,22 @@ import type { Channel } from "@/shared/api/types";
88
import { useEscapeKey } from "@/shared/hooks/useEscapeKey";
99
import { useIsThreadPanelOverlay } from "@/shared/hooks/use-mobile";
1010
import { useStickToBottom } from "@/shared/hooks/useStickToBottom";
11-
import { cn } from "@/shared/lib/cn";
11+
import { AuxiliaryPanel } from "@/shared/layout/AuxiliaryPanel";
12+
import { AuxiliaryPanelBody } from "@/shared/layout/AuxiliaryPanel";
1213
import {
1314
AuxiliaryPanelHeader,
15+
AuxiliaryPanelHeaderActions,
1416
AuxiliaryPanelHeaderGroup,
1517
AuxiliaryPanelTitle,
16-
auxiliaryPanelContentPaddingClass,
17-
} from "@/shared/layout/AuxiliaryPanelHeader";
18-
import { Badge } from "@/shared/ui/badge";
18+
} from "@/shared/layout/AuxiliaryPanel";
1919
import { Button } from "@/shared/ui/button";
2020
import type { UserProfileLookup } from "@/features/profile/lib/identity";
2121
import {
22-
OverlayPanelBackdrop,
23-
PANEL_ENTER_BASE_CLASS,
24-
PANEL_OVERLAY_CLASS,
25-
PANEL_SINGLE_COLUMN_HEADER_LAYER_CLASS,
26-
} from "@/shared/ui/OverlayPanelBackdrop";
27-
import { THREAD_PANEL_MIN_WIDTH_PX } from "@/shared/hooks/useThreadPanelWidth";
28-
import { Tooltip, TooltipContent, TooltipTrigger } from "@/shared/ui/tooltip";
22+
DropdownMenu,
23+
DropdownMenuContent,
24+
DropdownMenuItem,
25+
DropdownMenuTrigger,
26+
} from "@/shared/ui/dropdown-menu";
2927
import type { ChannelAgentSessionAgent } from "./useChannelAgentSessions";
3028

3129
type AgentSessionThreadPanelProps = {
@@ -57,8 +55,7 @@ export function AgentSessionThreadPanel({
5755
}: AgentSessionThreadPanelProps) {
5856
const isLive = isManagedAgentActive(agent);
5957
const isOverlay = useIsThreadPanelOverlay();
60-
const isFloatingOverlay = isOverlay && !isSinglePanelView;
61-
const isSplitLayout = layout === "split";
58+
const canStopCurrentTurn = isWorking && canInterruptTurn;
6259
useEscapeKey(onClose, isOverlay || isSinglePanelView);
6360

6461
const { ref: scrollRef, onScroll } = useStickToBottom<HTMLDivElement>();
@@ -83,146 +80,116 @@ export function AgentSessionThreadPanel({
8380
}
8481

8582
const agentHeaderActions = (
86-
<div className="ml-auto flex shrink-0 items-center gap-2">
83+
<AuxiliaryPanelHeaderActions>
8784
{isLive && isWorking ? (
88-
<Badge className="shrink-0 gap-1 px-2 py-0 text-2xs" variant="default">
89-
<CircleDot className="h-2.5 w-2.5" />
90-
Live
91-
</Badge>
92-
) : null}
93-
{isLive && isWorking ? (
94-
<Tooltip>
95-
<TooltipTrigger asChild>
85+
<DropdownMenu modal={false}>
86+
<DropdownMenuTrigger asChild>
9687
<Button
97-
aria-label="Stop current agent turn"
98-
className="h-6 px-2 text-2xs"
88+
aria-label="Open activity settings"
89+
className="relative"
90+
data-testid="agent-session-settings-menu-trigger"
91+
size="icon"
92+
title="Activity settings"
93+
type="button"
94+
variant="ghost"
95+
>
96+
<Settings />
97+
{canStopCurrentTurn ? (
98+
<span
99+
aria-hidden="true"
100+
className="absolute right-1 bottom-1 h-2 w-2 rounded-full bg-primary ring-2 ring-background"
101+
data-testid="agent-session-settings-live-badge"
102+
/>
103+
) : null}
104+
</Button>
105+
</DropdownMenuTrigger>
106+
<DropdownMenuContent
107+
align="end"
108+
className="min-w-56"
109+
onCloseAutoFocus={(event) => event.preventDefault()}
110+
>
111+
<DropdownMenuItem
112+
className="items-start gap-3"
99113
data-testid="agent-session-stop-turn"
100-
disabled={!canInterruptTurn}
101-
onClick={() => {
114+
disabled={!canStopCurrentTurn}
115+
onSelect={() => {
102116
void handleInterruptTurn();
103117
}}
104-
size="sm"
105-
type="button"
106-
variant="outline"
118+
title={
119+
canStopCurrentTurn
120+
? "Interrupt the current ACP turn without stopping the agent process."
121+
: "Only locally managed agents can be interrupted from this workspace."
122+
}
107123
>
108-
<Octagon className="h-4 w-4" />
109-
Stop
110-
</Button>
111-
</TooltipTrigger>
112-
<TooltipContent side="bottom" className="text-xs">
113-
{canInterruptTurn
114-
? "Interrupt the current ACP turn without stopping the agent process."
115-
: "This agent cannot be interrupted from this workspace."}
116-
</TooltipContent>
117-
</Tooltip>
124+
<Octagon className="mt-0.5 h-4 w-4 text-muted-foreground" />
125+
<span className="min-w-0 flex-1">
126+
<span className="block text-sm font-medium">
127+
Stop current turn
128+
</span>
129+
{!canStopCurrentTurn ? (
130+
<span className="mt-0.5 block text-xs text-muted-foreground">
131+
Only available for locally managed agents.
132+
</span>
133+
) : null}
134+
</span>
135+
</DropdownMenuItem>
136+
</DropdownMenuContent>
137+
</DropdownMenu>
118138
) : null}
119-
<Button
120-
aria-label="Close activity panel"
121-
data-testid="agent-session-close"
122-
onClick={onClose}
123-
size="icon"
124-
type="button"
125-
variant="ghost"
126-
>
127-
<X />
128-
</Button>
129-
</div>
139+
</AuxiliaryPanelHeaderActions>
130140
);
131141

132142
const agentHeaderContent = (
133143
<>
134-
<AuxiliaryPanelHeaderGroup>
135-
<Button
136-
aria-label="Back from activity"
137-
className="shrink-0"
138-
data-testid="agent-session-back"
139-
onClick={onBackToProfile}
140-
size="icon"
141-
type="button"
142-
variant="outline"
143-
>
144-
<ArrowLeft />
145-
</Button>
144+
<AuxiliaryPanelHeaderGroup
145+
backButtonAriaLabel="Back from activity"
146+
backButtonTestId="agent-session-back"
147+
onBack={onBackToProfile}
148+
>
146149
<AuxiliaryPanelTitle>Activity</AuxiliaryPanelTitle>
147150
</AuxiliaryPanelHeaderGroup>
148151
{agentHeaderActions}
149152
</>
150153
);
151154

152-
const agentBody = (
153-
<div
154-
ref={scrollRef}
155-
onScroll={onScroll}
156-
className={cn(
157-
"min-h-0 flex-1 overflow-y-auto px-3 pb-4",
158-
isSplitLayout && auxiliaryPanelContentPaddingClass,
159-
!isSplitLayout && (isFloatingOverlay ? "pt-4" : "pt-[3.25rem]"),
160-
)}
161-
>
162-
<ManagedAgentSessionPanel
163-
agent={agent}
164-
channelId={channel?.id ?? null}
165-
className="border-0 bg-transparent p-0 shadow-none"
166-
emptyDescription={
167-
channel
168-
? `Mention ${agent.name} in the channel to see its work here.`
169-
: `Mention ${agent.name} in any channel to see its work here.`
170-
}
171-
profiles={profiles}
172-
showHeader={false}
173-
showRaw={false}
174-
/>
175-
</div>
176-
);
177-
178-
if (isSplitLayout) {
179-
return (
180-
<div className="flex min-h-0 flex-1 flex-col">
181-
<AuxiliaryPanelHeader transparent={transparentChrome}>
182-
{agentHeaderContent}
183-
</AuxiliaryPanelHeader>
184-
{agentBody}
185-
</div>
186-
);
187-
}
188-
189155
return (
190-
<>
191-
{isFloatingOverlay && <OverlayPanelBackdrop onClose={onClose} />}
192-
<aside
193-
className={cn(
194-
PANEL_ENTER_BASE_CLASS,
195-
isSinglePanelView && "border-l-0",
196-
isFloatingOverlay && PANEL_OVERLAY_CLASS,
197-
)}
198-
data-testid="agent-session-thread-panel"
199-
style={{
200-
width: isSinglePanelView
201-
? "100%"
202-
: `min(${widthPx}px, calc(100% - ${THREAD_PANEL_MIN_WIDTH_PX}px))`,
203-
}}
204-
>
205-
{!isOverlay ? (
206-
<div
207-
aria-hidden="true"
208-
className="pointer-events-none absolute inset-x-0 top-0 z-40 h-[3.25rem] bg-background/75 backdrop-blur-md supports-[backdrop-filter]:bg-background/65 dark:bg-background/45 dark:backdrop-blur-xl dark:supports-[backdrop-filter]:bg-background/35"
209-
/>
210-
) : null}
211-
212-
<div
213-
className={cn(
214-
"flex cursor-default select-none items-center",
215-
isSinglePanelView
216-
? `relative ${PANEL_SINGLE_COLUMN_HEADER_LAYER_CLASS} -mb-[3.25rem] min-h-[3.25rem] shrink-0 gap-2.5 bg-background/80 px-4 py-2 backdrop-blur-md supports-[backdrop-filter]:bg-background/70 sm:pl-6 sm:pr-3 dark:bg-background/70 dark:backdrop-blur-xl dark:supports-[backdrop-filter]:bg-background/55`
217-
: "relative z-50 min-h-[3.25rem] shrink-0 gap-3 bg-background/80 px-5 py-2 backdrop-blur-md supports-[backdrop-filter]:bg-background/70 dark:bg-background/70 dark:backdrop-blur-xl dark:supports-[backdrop-filter]:bg-background/55",
218-
)}
219-
data-tauri-drag-region
156+
<AuxiliaryPanel
157+
isSinglePanelView={isSinglePanelView}
158+
layout={layout}
159+
onClose={onClose}
160+
testId="agent-session-thread-panel"
161+
transparentChrome={transparentChrome}
162+
widthPx={widthPx}
163+
header={
164+
<AuxiliaryPanelHeader
165+
backdrop={layout !== "split" && !isOverlay}
166+
backdropSurface="soft"
167+
inset={layout !== "split" ? "wide" : "default"}
220168
>
221169
{agentHeaderContent}
222-
</div>
223-
224-
{agentBody}
225-
</aside>
226-
</>
170+
</AuxiliaryPanelHeader>
171+
}
172+
>
173+
<AuxiliaryPanelBody
174+
ref={scrollRef}
175+
onScroll={onScroll}
176+
className="overflow-y-auto px-3 pb-4"
177+
panelPadding
178+
>
179+
<ManagedAgentSessionPanel
180+
agent={agent}
181+
channelId={channel?.id ?? null}
182+
className="border-0 bg-transparent p-0 shadow-none"
183+
emptyDescription={
184+
channel
185+
? `Mention ${agent.name} in the channel to see its work here.`
186+
: `Mention ${agent.name} in any channel to see its work here.`
187+
}
188+
profiles={profiles}
189+
showHeader={false}
190+
showRaw={false}
191+
/>
192+
</AuxiliaryPanelBody>
193+
</AuxiliaryPanel>
227194
);
228195
}

0 commit comments

Comments
 (0)