Skip to content

Commit 5bed17a

Browse files
Fix desktop right-side panel chrome overlap (#806)
Co-authored-by: Cursor <[email protected]>
1 parent ede8ddb commit 5bed17a

36 files changed

Lines changed: 1020 additions & 568 deletions

‎desktop/src/app/AppTopChrome.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function GlobalTopDivider() {
2323
return (
2424
<div
2525
aria-hidden="true"
26-
className="pointer-events-none fixed right-0 top-10 z-50 h-px bg-border/35"
26+
className="pointer-events-none fixed right-0 top-10 z-40 h-px bg-border/35"
2727
style={{ left: state === "expanded" ? "var(--sidebar-width)" : 0 }}
2828
/>
2929
);
@@ -48,7 +48,7 @@ export function AppTopChrome({
4848
data-tauri-drag-region
4949
/>
5050
<GlobalTopDivider />
51-
<div className="fixed left-[80px] top-[9px] z-[80] flex items-center gap-0.5">
51+
<div className="fixed left-[80px] top-[9px] z-[45] flex items-center gap-0.5">
5252
<SidebarTrigger className="h-[22px] w-[22px] text-muted-foreground/70 hover:bg-muted/60 hover:text-foreground" />
5353
<Button
5454
aria-label="Go back"
@@ -75,7 +75,7 @@ export function AppTopChrome({
7575
</div>
7676
<TopbarSearch
7777
channels={channels}
78-
className="fixed left-1/2 top-[7px] z-[80] hidden w-[300px] max-w-[34vw] -translate-x-1/2 md:block lg:w-[360px] lg:max-w-[38vw] xl:w-[420px] xl:max-w-[42vw] 2xl:w-[480px] 2xl:max-w-[44vw]"
78+
className="fixed left-1/2 top-[7px] z-[45] block w-[220px] max-w-[calc(100vw-11rem)] -translate-x-1/2 md:w-[300px] md:max-w-[34vw] lg:w-[360px] lg:max-w-[38vw] xl:w-[420px] xl:max-w-[42vw] 2xl:w-[480px] 2xl:max-w-[44vw]"
7979
currentPubkey={currentPubkey}
8080
focusRequest={searchFocusRequest}
8181
onOpenChannel={onOpenChannel}

‎desktop/src/features/agents/ui/AgentSessionTranscriptList.tsx‎

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
import * as React from "react";
22
import { Bot, Brain, ChevronDown, Radio, TerminalSquare } from "lucide-react";
33

4+
import {
5+
resolveUserLabel,
6+
type UserProfileLookup,
7+
} from "@/features/profile/lib/identity";
48
import { cn } from "@/shared/lib/cn";
59
import { Markdown } from "@/shared/ui/markdown";
10+
import { UserAvatar } from "@/shared/ui/UserAvatar";
611
import type { TranscriptItem } from "./agentSessionTypes";
712
import { ToolItem } from "./AgentSessionToolItem";
813
import { formatTranscriptTime } from "./agentSessionUtils";
@@ -12,10 +17,12 @@ export function AgentSessionTranscriptList({
1217
agentName,
1318
emptyDescription,
1419
items,
20+
profiles,
1521
}: {
1622
agentName: string;
1723
emptyDescription: string;
1824
items: TranscriptItem[];
25+
profiles?: UserProfileLookup;
1926
}) {
2027
if (items.length === 0) {
2128
return (
@@ -31,12 +38,16 @@ export function AgentSessionTranscriptList({
3138
<div
3239
aria-label="Live ACP transcript"
3340
aria-live="polite"
34-
className="mx-auto w-full max-w-3xl py-1"
41+
className="w-full py-1"
3542
role="log"
3643
>
3744
{items.map((item) => (
3845
<div className="mt-4 first:mt-0" key={item.id}>
39-
<TranscriptItemView agentName={agentName} item={item} />
46+
<TranscriptItemView
47+
agentName={agentName}
48+
item={item}
49+
profiles={profiles}
50+
/>
4051
</div>
4152
))}
4253
</div>
@@ -46,12 +57,16 @@ export function AgentSessionTranscriptList({
4657
const TranscriptItemView = React.memo(function TranscriptItemView({
4758
agentName,
4859
item,
60+
profiles,
4961
}: {
5062
agentName: string;
5163
item: TranscriptItem;
64+
profiles?: UserProfileLookup;
5265
}) {
5366
if (item.type === "message") {
54-
return <MessageItem agentName={agentName} item={item} />;
67+
return (
68+
<MessageItem agentName={agentName} item={item} profiles={profiles} />
69+
);
5570
}
5671
if (item.type === "tool") {
5772
return <ToolItem item={item} />;
@@ -68,24 +83,44 @@ const TranscriptItemView = React.memo(function TranscriptItemView({
6883
function MessageItem({
6984
agentName,
7085
item,
86+
profiles,
7187
}: {
7288
agentName: string;
7389
item: Extract<TranscriptItem, { type: "message" }>;
90+
profiles?: UserProfileLookup;
7491
}) {
7592
const isAssistant = item.role === "assistant";
7693
const text = item.text.trim();
94+
const authorProfile = item.authorPubkey
95+
? profiles?.[item.authorPubkey.toLowerCase()]
96+
: null;
97+
const authorLabel = item.authorPubkey
98+
? resolveUserLabel({
99+
pubkey: item.authorPubkey,
100+
fallbackName: item.title,
101+
profiles,
102+
})
103+
: item.title || "User";
104+
77105
return (
78106
<div
79107
className={cn(
80-
"flex px-1 py-1 animate-in fade-in duration-200 motion-reduce:animate-none",
81-
isAssistant ? "flex-row" : "ml-auto flex-row-reverse",
108+
"flex flex-row px-1 py-1 animate-in fade-in duration-200 motion-reduce:animate-none",
82109
)}
83110
data-role={isAssistant ? "assistant-message" : "user-message"}
84111
>
112+
{!isAssistant ? (
113+
<UserAvatar
114+
avatarUrl={authorProfile?.avatarUrl ?? null}
115+
className="mr-2 mt-1 h-5 w-5 shrink-0 rounded-full text-[8px]"
116+
displayName={authorLabel}
117+
size="xs"
118+
/>
119+
) : null}
85120
<div
86121
className={cn(
87-
"group relative min-w-0 flex flex-col gap-1",
88-
isAssistant ? "w-full items-start" : "max-w-[85%] items-end",
122+
"group relative min-w-0 flex flex-col items-start gap-1",
123+
isAssistant ? "w-full" : "max-w-[85%]",
89124
)}
90125
>
91126
{isAssistant ? (
@@ -182,7 +217,7 @@ function LifecycleItem({
182217
return (
183218
<div
184219
className={cn(
185-
"flex items-center justify-center gap-1.5 px-4 py-2 text-center text-xs",
220+
"flex items-center justify-start gap-1.5 px-1 py-2 text-left text-xs",
186221
isError ? "text-destructive" : "text-muted-foreground",
187222
)}
188223
>

‎desktop/src/features/agents/ui/ManagedAgentSessionPanel.tsx‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
} from "lucide-react";
1010

1111
import { isManagedAgentActive } from "@/features/agents/lib/managedAgentControlActions";
12+
import type { UserProfileLookup } from "@/features/profile/lib/identity";
1213
import type { ManagedAgent } from "@/shared/api/types";
1314
import { cn } from "@/shared/lib/cn";
1415
import { Badge } from "@/shared/ui/badge";
@@ -30,6 +31,7 @@ type ManagedAgentSessionPanelProps = {
3031
emptyDescription?: string;
3132
showHeader?: boolean;
3233
showRaw?: boolean;
34+
profiles?: UserProfileLookup;
3335
};
3436

3537
export function ManagedAgentSessionPanel({
@@ -39,6 +41,7 @@ export function ManagedAgentSessionPanel({
3941
emptyDescription = "Mention this agent in a channel to watch the next turn.",
4042
showHeader = true,
4143
showRaw = true,
44+
profiles,
4245
}: ManagedAgentSessionPanelProps) {
4346
const hasObserver = isManagedAgentActive(agent);
4447
const { connectionState, errorMessage, events } = useObserverEvents(
@@ -96,6 +99,7 @@ export function ManagedAgentSessionPanel({
9699
errorMessage={errorMessage}
97100
events={scopedEvents}
98101
hasObserver={hasObserver}
102+
profiles={profiles}
99103
showRaw={showRaw}
100104
transcript={scopedTranscript}
101105
/>
@@ -145,6 +149,7 @@ function SessionBody({
145149
errorMessage,
146150
events,
147151
hasObserver,
152+
profiles,
148153
showRaw,
149154
transcript,
150155
}: {
@@ -154,6 +159,7 @@ function SessionBody({
154159
errorMessage: string | null;
155160
events: ObserverEvent[];
156161
hasObserver: boolean;
162+
profiles?: UserProfileLookup;
157163
showRaw: boolean;
158164
transcript: TranscriptItem[];
159165
}) {
@@ -175,6 +181,7 @@ function SessionBody({
175181
agentName={agentName}
176182
emptyDescription={emptyDescription}
177183
items={transcript}
184+
profiles={profiles}
178185
/>
179186
{showRaw ? <RawEventRail events={events} /> : null}
180187
</div>

‎desktop/src/features/agents/ui/agentSessionTranscript.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ function upsertMessage(
116116
text: string,
117117
timestamp: string,
118118
channelId: string | null,
119+
authorPubkey: string | null = null,
119120
) {
120121
const currentKey = d.activeMessageKey.get(id);
121122

@@ -126,6 +127,7 @@ function upsertMessage(
126127
...existing,
127128
text: existing.text + text,
128129
channelId,
130+
authorPubkey: authorPubkey ?? existing.authorPubkey,
129131
});
130132
return;
131133
}
@@ -141,6 +143,7 @@ function upsertMessage(
141143
text,
142144
timestamp,
143145
channelId,
146+
authorPubkey,
144147
});
145148
d.activeMessageKey = new Map(d.activeMessageKey);
146149
d.activeMessageKey.set(id, newKey);
@@ -318,6 +321,7 @@ export function processTranscriptEvent(
318321
parsedPrompt.userText,
319322
event.timestamp,
320323
channelId,
324+
parsedPrompt.userPubkey,
321325
);
322326
}
323327
if (parsedPrompt.sections.length > 0) {

‎desktop/src/features/agents/ui/agentSessionTranscriptHelpers.ts‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,16 @@ export function parsePromptText(text: string): {
1717
sections: PromptSection[];
1818
userText: string;
1919
userTitle: string;
20+
userPubkey: string | null;
2021
} {
2122
const sections = parsePromptSections(text);
2223
if (sections.length === 0) {
23-
return { sections: [], userText: text.trim(), userTitle: "Prompt" };
24+
return {
25+
sections: [],
26+
userText: text.trim(),
27+
userTitle: "Prompt",
28+
userPubkey: null,
29+
};
2430
}
2531

2632
const eventSection = sections.find((section) =>
@@ -29,12 +35,16 @@ export function parsePromptText(text: string): {
2935
const eventContent = eventSection
3036
? extractEventContent(eventSection.body)
3137
: "";
38+
const eventAuthorPubkey = eventSection
39+
? extractEventAuthorPubkey(eventSection.body)
40+
: null;
3241
const eventKind = eventSection?.title.split(":").slice(1).join(":").trim();
3342

3443
return {
3544
sections,
3645
userText: eventContent,
3746
userTitle: eventKind ? titleCase(eventKind) : "Sprout event",
47+
userPubkey: eventAuthorPubkey,
3848
};
3949
}
4050

@@ -79,6 +89,11 @@ function extractEventContent(body: string): string {
7989
return contentMatch?.[1]?.trim() ?? "";
8090
}
8191

92+
function extractEventAuthorPubkey(body: string): string | null {
93+
const fromMatch = body.match(/^From:.*\bhex:\s*([0-9a-fA-F]{64})/m);
94+
return fromMatch?.[1]?.toLowerCase() ?? null;
95+
}
96+
8297
export function extractContentText(value: unknown): string {
8398
if (typeof value === "string") return value;
8499
if (Array.isArray(value)) return value.map(extractBlockText).join("\n");

‎desktop/src/features/agents/ui/agentSessionTypes.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export type TranscriptItem =
2828
title: string;
2929
text: string;
3030
timestamp: string;
31+
authorPubkey?: string | null;
3132
channelId?: string | null;
3233
}
3334
| {

0 commit comments

Comments
 (0)