Skip to content

armgit / orca

Public Imported from GitHub
0

Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

fix(native-chat): agent message cards no longer reserve a row for the copy button (#36189)

Brennan Benson9a7f76ef2818
diff --git a/src/renderer/src/components/native-chat/NativeChatAgentMessageCard.test.tsx b/src/renderer/src/components/native-chat/NativeChatAgentMessageCard.test.tsx
index cd0b335feff..f4831cd700e 100644
--- a/src/renderer/src/components/native-chat/NativeChatAgentMessageCard.test.tsx
+++ b/src/renderer/src/components/native-chat/NativeChatAgentMessageCard.test.tsx
@@ -202,6 +202,28 @@ function slots(message: NativeChatMessage) {
})
}
+it('keeps a short message footer-free with copy beside the header timestamp', () => {
+ const message: NativeChatMessage = {
+ id: 'short-agent-message',
+ role: 'user',
+ source: 'transcript',
+ timestamp: 1,
+ from,
+ blocks: [{ type: 'text', text: 'Short agent message.' }]
+ }
+ const { container } = render(card(message))
+ expect(screen.queryByRole('button', { name: /Show more|Show less/ })).toBeNull()
+ const body = screen.getByText('Short agent message.').closest('div[id]')
+ expect(body).toBeInTheDocument()
+ expect(body?.nextElementSibling).toBeNull()
+
+ const copy = screen.getByRole('button', { name: 'Copy message' })
+ const timestamp = container.querySelector('time')
+ expect(timestamp).toBeInTheDocument()
+ expect(screen.getByText('Message from').parentElement).toContainElement(copy)
+ expect(copy.parentElement).toBe(timestamp?.parentElement)
+})
+
it.each(['task', 'mail'] as const)(
'keeps native %s progress independent from Markdown and reparses own edits',
async (kind) => {
diff --git a/src/renderer/src/components/native-chat/NativeChatAgentMessageCard.tsx b/src/renderer/src/components/native-chat/NativeChatAgentMessageCard.tsx
index 1bf0771e9b9..803decb0fed 100644
--- a/src/renderer/src/components/native-chat/NativeChatAgentMessageCard.tsx
+++ b/src/renderer/src/components/native-chat/NativeChatAgentMessageCard.tsx
@@ -94,10 +94,19 @@ export function NativeChatAgentMessageCard({
<div className="min-w-0 flex-1">
<div className="flex items-center justify-between gap-2 text-xs text-muted-foreground">
<span>{heading(from)}</span>
- <NativeChatMessageTimestamp
- timestamp={message.timestamp}
- className="text-muted-foreground"
- />
+ <div className="flex items-center gap-1">
+ {agentMessageCanCopy(text) ? (
+ // Why: -my-1 keeps the 24px button inside the text-xs header line, so copy costs no row of its own.
+ <NativeChatCopyButton
+ text={text}
+ className="-my-1 transition-opacity can-hover:pointer-events-none can-hover:opacity-0 group-hover:pointer-events-auto group-hover:opacity-100 [.group:has(:focus-visible)_&]:pointer-events-auto [.group:has(:focus-visible)_&]:opacity-100"
+ />
+ ) : null}
+ <NativeChatMessageTimestamp
+ timestamp={message.timestamp}
+ className="text-muted-foreground"
+ />
+ </div>
</div>
<NativeChatAgentMessageSenders from={from} chatWorktreeId={worktreeId} target={target} />
<NativeChatImageAttachments
@@ -129,35 +138,25 @@ export function NativeChatAgentMessageCard({
allowFileUriLinks={allowFileUriLinks}
/>
</div>
- <div className="flex items-center justify-between">
- {overflows ? (
- <Button
- type="button"
- variant="ghost"
- size="xs"
- aria-expanded={disclosure.open}
- aria-controls={clipId}
- onClick={() => {
- disclosure.setOpen(!disclosure.open)
- if (disclosure.open) {
- requestAnimationFrame(onRefolded)
- }
- }}
- >
- {agentMessageFoldLabel(disclosure.open) === 'expanded'
- ? translate('components.native-chat.userMessage.showLess', 'Show less')
- : translate('components.native-chat.agentMessage.showMore', 'Show more')}
- </Button>
- ) : (
- <span />
- )}
- {agentMessageCanCopy(text) ? (
- <NativeChatCopyButton
- text={text}
- className="transition-opacity can-hover:pointer-events-none can-hover:opacity-0 group-hover:pointer-events-auto group-hover:opacity-100 [.group:has(:focus-visible)_&]:pointer-events-auto [.group:has(:focus-visible)_&]:opacity-100"
- />
- ) : null}
- </div>
+ {overflows ? (
+ <Button
+ type="button"
+ variant="ghost"
+ size="xs"
+ aria-expanded={disclosure.open}
+ aria-controls={clipId}
+ onClick={() => {
+ disclosure.setOpen(!disclosure.open)
+ if (disclosure.open) {
+ requestAnimationFrame(onRefolded)
+ }
+ }}
+ >
+ {agentMessageFoldLabel(disclosure.open) === 'expanded'
+ ? translate('components.native-chat.userMessage.showLess', 'Show less')
+ : translate('components.native-chat.agentMessage.showMore', 'Show more')}
+ </Button>
+ ) : null}
</div>
</div>
)