Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(posthog-ai): give quill code blocks a header bar for the copy button (#111385)

Shy Alter3028f795c1de
diff --git a/products/posthog_ai/frontend/components/quill/QuillMessages.tsx b/products/posthog_ai/frontend/components/quill/QuillMessages.tsx
index c42099ca3218..ecefa86d9511 100644
--- a/products/posthog_ai/frontend/components/quill/QuillMessages.tsx
+++ b/products/posthog_ai/frontend/components/quill/QuillMessages.tsx
@@ -26,6 +26,14 @@ const ASSISTANT_TABLE_CLASS = cn(
'[&_:is(th,td):first-child]:sticky [&_:is(th,td):first-child]:left-0 [&_:is(th,td):first-child]:z-1 [&_:is(th,td):first-child]:bg-(--background)'
)
+// The copy button sits in a header bar above the code, so it never covers the first line.
+const ASSISTANT_CODE_CLASS = cn(
+ '[&_.CodeSnippet_pre]:!pt-10',
+ '[&_.CodeSnippet_pre]:![background:linear-gradient(var(--border),var(--border))_0_2rem/100%_1px_no-repeat,linear-gradient(var(--muted),var(--muted))_0_0/100%_2rem_no-repeat,var(--card)]',
+ '[&_.CodeSnippet>div:first-child]:!top-1.5 [&_.CodeSnippet>div:first-child]:!right-1.5 [&_.CodeSnippet>div:first-child]:!bg-transparent',
+ '[&_.CodeSnippet>div:first-child_svg]:!text-(--muted-foreground)'
+)
+
/**
* Clamps a user bubble to five lines with a Show more toggle. Overflow depends on wrapping width, so it
* is measured against the clamped height and re-measured on resize, and the toggle only appears when the
@@ -107,7 +115,11 @@ export const QuillAssistantMessage = memo(function QuillAssistantMessage({ item
<ChatMessageContent className="gap-1">
<ChatBubble variant="ghost">
<ChatBubbleContent>
- <MarkdownMessage content={item.text ?? ''} id={item.id} className={ASSISTANT_TABLE_CLASS} />
+ <MarkdownMessage
+ content={item.text ?? ''}
+ id={item.id}
+ className={cn(ASSISTANT_TABLE_CLASS, ASSISTANT_CODE_CLASS)}
+ />
</ChatBubbleContent>
</ChatBubble>
</ChatMessageContent>