Skip to content

Commit 654b6c3

Browse files
tellahonpub1223z34hd7vtwc6qj4s7flsxkj644nlre2nthu7lrrmkumhu3xddsrx9r6w
andauthored
feat(profile): embed live activity feed in profile aux panel (#1380)
Signed-off-by: Taylor Ho <[email protected]> Co-authored-by: npub1223z34hd7vtwc6qj4s7flsxkj644nlre2nthu7lrrmkumhu3xddsrx9r6w <52a228d6edf316ec6812ac3c9fc0d696ab59fc7954d77e7be31eedcddf91335b@sprout-oss.stage.blox.sqprod.co>
1 parent 204a0fd commit 654b6c3

70 files changed

Lines changed: 4309 additions & 670 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎desktop/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"@tiptap/starter-kit": "^3.22.3",
6060
"class-variance-authority": "^0.7.1",
6161
"clsx": "^2.1.1",
62+
"embla-carousel-react": "^8.6.0",
6263
"emoji-mart": "^5.6.0",
6364
"jdenticon": "^3.3.0",
6465
"lucide-react": "^1.0.0",

‎desktop/src/features/agents/observerRelayStore.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,19 @@ export function injectObserverEventsForE2E(
443443
notifyListeners();
444444
}
445445

446+
/**
447+
* Synchronize the observer store with a sorted buffer of events for one agent.
448+
* Used by test harnesses and replay bridges that already hold decoded frames.
449+
*/
450+
export function syncAgentObserverEvents(
451+
agentPubkey: string,
452+
events: ObserverEvent[],
453+
) {
454+
for (const event of events) {
455+
appendAgentEvent(agentPubkey, event);
456+
}
457+
}
458+
446459
export function resetAgentObserverStore() {
447460
generation += 1;
448461
const unsubscribe = unsubscribeRelay;

‎desktop/src/features/agents/ui/AgentSessionToolItem/CompactMessageSummary.tsx‎

Lines changed: 140 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
import * as React from "react";
22
import { CheckCheck } from "lucide-react";
33

4+
import { useAppNavigation } from "@/app/navigation/useAppNavigation";
45
import { cn } from "@/shared/lib/cn";
6+
import { useProfilePanel } from "@/shared/context/ProfilePanelContext";
7+
import { Markdown } from "@/shared/ui/markdown";
58
import { UserAvatar } from "@/shared/ui/UserAvatar";
9+
import { useAgentSessionTranscriptVariant } from "../agentSessionTranscriptContext";
10+
import { MessageLinkHoverCue } from "../activityRenderClasses/MessageLinkHoverCue";
611
import { TranscriptTimestamp } from "../activityRenderClasses/TranscriptTimestamp";
12+
import { useTranscriptBubbleOverflow } from "../activityRenderClasses/useTranscriptBubbleOverflow";
713
import { compactSummaryTone } from "./CompactToolSummaryRow";
814
import type { SentMessageLink } from "./messageLinks";
915
import { SentMessageContextDialog } from "./SentMessageContextDialog";
@@ -20,6 +26,7 @@ export function CompactMessageSummary({
2026
label,
2127
messageLink,
2228
preview,
29+
pubkey,
2330
result,
2431
timestamp,
2532
}: {
@@ -34,34 +41,139 @@ export function CompactMessageSummary({
3441
label: string;
3542
messageLink: SentMessageLink | null;
3643
preview: string | null;
44+
pubkey: string;
3745
result: string;
3846
timestamp: string;
3947
}) {
4048
const [detailsOpen, setDetailsOpen] = React.useState(false);
49+
const variant = useAgentSessionTranscriptVariant();
50+
const { goChannel } = useAppNavigation();
51+
const { openProfilePanel } = useProfilePanel();
52+
const isCompactPreview = variant === "compactPreview";
53+
const shouldClampBubble = !isCompactPreview;
54+
const [bubbleRef, hasBubbleOverflow] =
55+
useTranscriptBubbleOverflow(shouldClampBubble);
56+
const canOpenMessage = shouldClampBubble && messageLink !== null;
4157
const mutedTone = compactSummaryTone();
58+
const avatarClassName = cn(
59+
"mr-2 mt-1 shrink-0",
60+
isCompactPreview ? "size-5" : "size-7",
61+
);
62+
const handleBubbleClick = React.useCallback(
63+
(event: React.MouseEvent<HTMLDivElement>) => {
64+
if (!messageLink || isNestedInteractiveTarget(event)) return;
65+
event.preventDefault();
66+
event.stopPropagation();
67+
void goChannel(messageLink.channelId, {
68+
messageId: messageLink.messageId,
69+
});
70+
},
71+
[goChannel, messageLink],
72+
);
73+
const handleBubbleKeyDown = React.useCallback(
74+
(event: React.KeyboardEvent<HTMLDivElement>) => {
75+
if (
76+
!messageLink ||
77+
isNestedInteractiveTarget(event) ||
78+
(event.key !== "Enter" && event.key !== " ")
79+
) {
80+
return;
81+
}
82+
83+
event.preventDefault();
84+
event.stopPropagation();
85+
void goChannel(messageLink.channelId, {
86+
messageId: messageLink.messageId,
87+
});
88+
},
89+
[goChannel, messageLink],
90+
);
91+
const bubbleLinkProps = canOpenMessage
92+
? {
93+
onClick: handleBubbleClick,
94+
onKeyDown: handleBubbleKeyDown,
95+
role: "link" as const,
96+
tabIndex: 0,
97+
}
98+
: {};
4299
return (
43100
<>
44101
<div className="flex max-w-full flex-row items-start justify-start">
45-
<UserAvatar
46-
avatarUrl={avatarUrl}
47-
className="mr-2 mt-1 shrink-0"
48-
displayName={displayName}
49-
size="xs"
50-
testId="transcript-agent-sent-avatar"
51-
/>
52-
<div className="flex max-w-[85%] min-w-0 flex-col items-start gap-1">
102+
{openProfilePanel && !isCompactPreview ? (
103+
<button
104+
aria-label={`Open ${displayName} profile`}
105+
className={cn(
106+
avatarClassName,
107+
"pointer-events-auto rounded-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
108+
)}
109+
onClick={(event) => {
110+
event.preventDefault();
111+
event.stopPropagation();
112+
openProfilePanel(pubkey);
113+
}}
114+
type="button"
115+
>
116+
<UserAvatar
117+
avatarUrl={avatarUrl}
118+
className="size-full text-xs"
119+
displayName={displayName}
120+
size="sm"
121+
testId="transcript-agent-sent-avatar"
122+
/>
123+
</button>
124+
) : (
125+
<UserAvatar
126+
avatarUrl={avatarUrl}
127+
className={cn(
128+
avatarClassName,
129+
isCompactPreview ? "text-3xs" : "text-xs",
130+
)}
131+
displayName={displayName}
132+
size="sm"
133+
testId="transcript-agent-sent-avatar"
134+
/>
135+
)}
136+
<div className="flex min-w-0 flex-1 flex-col items-start gap-1">
53137
<div
54138
className={cn(
55-
"min-w-0 rounded-2xl border px-3 py-2 text-sm leading-relaxed shadow-sm",
56-
isError
57-
? "border-destructive/25 bg-destructive/10 text-destructive"
58-
: "border-primary/15 bg-primary/6 text-foreground",
139+
"w-full min-w-0 rounded-2xl border px-3 py-2 shadow-sm",
140+
isCompactPreview
141+
? "text-xs leading-4"
142+
: "text-sm leading-relaxed",
143+
shouldClampBubble && "relative max-h-36 overflow-hidden",
144+
canOpenMessage &&
145+
"group/bubble cursor-pointer transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
146+
isCompactPreview
147+
? isError
148+
? "border-destructive/25 bg-destructive/10 text-destructive"
149+
: "border-transparent bg-muted text-foreground"
150+
: isError
151+
? "border-destructive/25 bg-destructive/10 text-destructive"
152+
: "border-transparent bg-muted text-foreground",
153+
canOpenMessage &&
154+
(isError ? "hover:bg-destructive/15" : "hover:bg-muted/90"),
59155
)}
60156
data-testid="transcript-tool-message-preview"
157+
ref={bubbleRef}
158+
{...bubbleLinkProps}
61159
>
62-
<p className="whitespace-pre-wrap wrap-break-word">
63-
{preview || "Message content unavailable."}
64-
</p>
160+
<Markdown
161+
className={isCompactPreview ? "text-xs leading-4" : "leading-5"}
162+
content={preview || "Message content unavailable."}
163+
/>
164+
{hasBubbleOverflow ? (
165+
<span
166+
className={cn(
167+
"pointer-events-none absolute inset-x-0 bottom-0 h-8 rounded-b-2xl bg-linear-to-b from-transparent",
168+
isError
169+
? "to-destructive/10"
170+
: isCompactPreview
171+
? "to-muted"
172+
: "to-muted",
173+
)}
174+
/>
175+
) : null}
176+
{canOpenMessage ? <MessageLinkHoverCue /> : null}
65177
</div>
66178
<div className="inline-flex max-w-full items-center gap-1.5 px-1">
67179
<TranscriptTimestamp
@@ -100,3 +212,16 @@ export function CompactMessageSummary({
100212
</>
101213
);
102214
}
215+
216+
function isNestedInteractiveTarget(
217+
event: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>,
218+
) {
219+
const target =
220+
event.target instanceof Element
221+
? event.target.closest(
222+
"a,button,input,select,textarea,summary,[role='button'],[role='link']",
223+
)
224+
: null;
225+
226+
return target !== null && target !== event.currentTarget;
227+
}

‎desktop/src/features/agents/ui/AgentSessionToolItem/CompactToolSummaryRow.tsx‎

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,51 @@ import * as React from "react";
22
import { ChevronDown } from "lucide-react";
33

44
import { cn } from "@/shared/lib/cn";
5-
import { rewriteRelayUrl } from "@/shared/lib/mediaUrl";
5+
import { useAgentSessionTranscriptVariant } from "../agentSessionTranscriptContext";
66
import type { AgentActivityAction } from "../agentSessionTypes";
7-
import type { CompactFileEditSummary } from "../agentSessionToolSummary";
8-
import { isInlineImageData } from "../agentSessionUtils";
7+
import type {
8+
CompactFileEditSummary,
9+
CompactToolKind,
10+
} from "../agentSessionToolSummary";
11+
import { resolveToolImageSrc } from "../agentSessionUtils";
912
import {
1013
ActivityRowLabel,
1114
splitActivityRowLabel,
1215
type ActivityRowLabelParts,
1316
} from "../activityRenderClasses/ActivityRow";
1417

1518
export function compactSummaryTone() {
16-
return "text-muted-foreground/60 group-open:text-foreground";
19+
return "text-muted-foreground/60 transition-colors group-hover/row:text-foreground group-open:text-foreground";
1720
}
1821

1922
export function CompactToolSummaryRow({
2023
action,
2124
duration,
2225
fileEditSummary,
26+
kind,
2327
label,
2428
preview,
2529
thumbnailSrc,
2630
}: {
2731
action: AgentActivityAction | null;
2832
duration: string | null;
2933
fileEditSummary: CompactFileEditSummary | null;
34+
kind: CompactToolKind;
3035
label: string;
3136
preview: string | null;
3237
thumbnailSrc: string | null;
3338
}) {
3439
const [thumbnailFailed, setThumbnailFailed] = React.useState(false);
40+
const variant = useAgentSessionTranscriptVariant();
41+
const isCompactPreview = variant === "compactPreview";
3542
const mutedTone = compactSummaryTone();
3643
const resolvedThumbnail = React.useMemo(() => {
3744
if (!thumbnailSrc || thumbnailFailed) return null;
38-
return resolveImageSrc(thumbnailSrc);
45+
return resolveToolImageSrc(thumbnailSrc);
3946
}, [thumbnailFailed, thumbnailSrc]);
4047
const actionLabel = fileEditSummary
4148
? null
42-
: getCompactToolActionLabel(action, label, preview);
49+
: getCompactToolActionLabel(action, kind, label, preview);
4350

4451
return (
4552
<>
@@ -53,7 +60,13 @@ export function CompactToolSummaryRow({
5360
verb={actionLabel.verb}
5461
/>
5562
) : (
56-
<span className={cn("shrink-0 text-sm font-semibold", mutedTone)}>
63+
<span
64+
className={cn(
65+
"shrink-0 font-semibold",
66+
isCompactPreview ? "text-xs" : "text-sm",
67+
mutedTone,
68+
)}
69+
>
5770
{label}
5871
</span>
5972
)}
@@ -69,7 +82,11 @@ export function CompactToolSummaryRow({
6982
/>
7083
) : !fileEditSummary && !actionLabel && preview ? (
7184
<span
72-
className={cn("min-w-0 max-w-48 truncate text-sm", mutedTone)}
85+
className={cn(
86+
"min-w-0 max-w-48 truncate",
87+
isCompactPreview ? "text-xs" : "text-sm",
88+
mutedTone,
89+
)}
7390
title={preview}
7491
>
7592
{preview}
@@ -90,6 +107,7 @@ export function CompactToolSummaryRow({
90107

91108
function getCompactToolActionLabel(
92109
action: AgentActivityAction | null,
110+
kind: CompactToolKind,
93111
label: string,
94112
preview: string | null,
95113
): (ActivityRowLabelParts & { title?: string }) | null {
@@ -108,10 +126,11 @@ function getCompactToolActionLabel(
108126
if (!preview) return parts;
109127

110128
if (
111-
label === "Ran command" ||
112-
label === "Read file" ||
113-
label === "Updated todos" ||
114-
label === "Viewed image"
129+
kind === "shell" ||
130+
kind === "file-read" ||
131+
kind === "skill-read" ||
132+
kind === "plan" ||
133+
kind === "image"
115134
) {
116135
return { verb: parts.verb, object: preview, title: preview };
117136
}
@@ -138,7 +157,3 @@ function CompactFileEditSummaryView({
138157
/>
139158
);
140159
}
141-
142-
function resolveImageSrc(source: string): string {
143-
return isInlineImageData(source) ? source : rewriteRelayUrl(source);
144-
}

‎desktop/src/features/agents/ui/AgentSessionToolItem/ShellCommandBlock.tsx‎

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Terminal } from "lucide-react";
22

3+
import { ScrollFadeMonoPanel } from "../FileContentBlock";
34
import { parseShellToolOutput } from "../agentSessionUtils";
45

56
export function ShellCommandBlock({
@@ -14,17 +15,28 @@ export function ShellCommandBlock({
1415

1516
return (
1617
<div
17-
className="rounded-lg bg-muted/40 px-3 py-2 font-mono text-xs leading-5"
18+
className="overflow-hidden rounded-lg bg-muted font-mono text-xs leading-5"
1819
data-testid="transcript-shell-command"
1920
>
20-
<p className="whitespace-pre-wrap wrap-break-word text-muted-foreground/70">
21-
<Terminal className="mr-2 inline h-3.5 w-3.5 align-[-0.1875rem] text-accent-foreground" />
22-
{command}
23-
</p>
21+
<ScrollFadeMonoPanel
22+
fadeFromClassName="from-muted"
23+
maxHeightClassName="max-h-36"
24+
>
25+
<p className="whitespace-pre-wrap wrap-break-word text-muted-foreground/70">
26+
<Terminal className="mr-2 inline h-3.5 w-3.5 align-[-0.1875rem] text-primary" />
27+
{command}
28+
</p>
29+
</ScrollFadeMonoPanel>
2430
{stdout ? (
25-
<pre className="mt-2 max-h-64 overflow-auto whitespace-pre-wrap wrap-break-word text-foreground">
26-
{stdout}
27-
</pre>
31+
<ScrollFadeMonoPanel
32+
className="mt-2"
33+
fadeFromClassName="from-muted"
34+
maxHeightClassName="max-h-36"
35+
>
36+
<pre className="whitespace-pre-wrap wrap-break-word text-foreground">
37+
{stdout}
38+
</pre>
39+
</ScrollFadeMonoPanel>
2840
) : null}
2941
</div>
3042
);

0 commit comments

Comments
 (0)