: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(today): give space feed cards a subtle hover and clean their previews (#109661)
Shy Alter861d65335051
diff --git a/frontend/src/styles/quill-bridge.scss b/frontend/src/styles/quill-bridge.scssindex 1dc300d99990..2cab6cc3833c 100644--- a/frontend/src/styles/quill-bridge.scss+++ b/frontend/src/styles/quill-bridge.scss@@ -154,12 +154,12 @@}/*- * PostHog's compiled `hover:bg-muted` reads `--muted-3000`, which is a text colour, and it is `!important`.- * Pin the hover to quill's muted surface, like `.bg-muted` above.+ * Use this for a quill hover fill, not `hover:bg-muted`. PostHog's compiled `hover:bg-muted` reads `--muted-3000`,+ * a dark text colour, and it is `!important` inside a cascade layer, so no rule in this file can override it.*//* stylelint-disable-next-line selector-class-pattern -- the name of Tailwind's hover variant class */-[data-quill] .hover\:bg-muted:hover {- background-color: var(--muted) !important;+[data-quill] .hover\:bg-fill-hover:hover {+ background-color: var(--fill-hover);}[data-quill] .bg-destructive-foreground {diff --git a/products/tasks/frontend/spaces/SpaceFeedCard.tsx b/products/tasks/frontend/spaces/SpaceFeedCard.tsxindex 76ebb747cdab..e7a80c07213b 100644--- a/products/tasks/frontend/spaces/SpaceFeedCard.tsx+++ b/products/tasks/frontend/spaces/SpaceFeedCard.tsx@@ -57,7 +57,7 @@ export function SpaceFeedCard({ task, pinned, unread, repository }: SpaceFeedCarreturn (<Cardsize="sm"- className="group/card relative my-1.5 gap-0 rounded-xl px-4 pt-3.5 pb-3 transition-colors hover:bg-muted"+ className="group/card relative my-1.5 gap-0 rounded-xl px-4 pt-3.5 pb-3 transition-colors hover:bg-fill-hover"><div className="flex min-w-0 items-center gap-3">{renaming?.sessionId === task.id && renaming.surface === 'feed' ? (@@ -73,7 +73,7 @@ export function SpaceFeedCard({ task, pinned, unread, repository }: SpaceFeedCar<SpaceFeedStatusIcon item={item} className="translate-y-0.5" /><LinkPrimitiveto={urls.aiTask(task.id)}- className="min-w-0 truncate text-sm leading-snug font-semibold text-foreground after:absolute after:inset-0 hover:underline"+ className="min-w-0 truncate text-sm leading-snug font-semibold text-foreground after:absolute after:inset-0"data-attr="today-space-feed-card">{item.title || 'Untitled session'}diff --git a/products/tasks/frontend/spaces/SpaceFeedPullRequestRow.tsx b/products/tasks/frontend/spaces/SpaceFeedPullRequestRow.tsxindex 530b0a307e72..f974b7f7281c 100644--- a/products/tasks/frontend/spaces/SpaceFeedPullRequestRow.tsx+++ b/products/tasks/frontend/spaces/SpaceFeedPullRequestRow.tsx@@ -81,12 +81,15 @@ export function SpaceFeedPullRequestRow({)}return (- <Card size="sm" className="relative my-1.5 gap-0 rounded-xl px-4 pt-3.5 pb-3 transition-colors hover:bg-muted">+ <Card+ size="sm"+ className="relative my-1.5 gap-0 rounded-xl px-4 pt-3.5 pb-3 transition-colors hover:bg-fill-hover"+ ><div className="flex min-w-0 items-center gap-3"><div className="flex min-w-0 flex-1 items-baseline gap-1.5"><span className="flex translate-y-0.5">{icon}</span>{number}- {link('text-sm leading-snug font-semibold hover:underline')}+ {link('text-sm leading-snug font-semibold')}{age && (<Text render={<span />} size="xs" variant="muted" className="shrink-0" translate="no">{`· ${age}`}diff --git a/products/tasks/frontend/spaces/spaceFeedPreview.test.ts b/products/tasks/frontend/spaces/spaceFeedPreview.test.tsindex 5e5d65477fa3..5d6da728be78 100644--- a/products/tasks/frontend/spaces/spaceFeedPreview.test.ts+++ b/products/tasks/frontend/spaces/spaceFeedPreview.test.ts@@ -29,6 +29,18 @@ describe('spaceFeedPreview', () => {'Explain <user_custom_instructions>how it works</user_custom_instructions>','Explain <user_custom_instructions>how it works</user_custom_instructions>',],+ [+ 'self-closing mentions',+ '<github_pr number="42" title="Fix "retry"" url="https://github.com/example/repo/pull/42" /> review <file path="/src/app/main.ts" /> with <skill name="deploy" source="user" path="/skills/deploy" />',+ '@#42 - Fix "retry" review @app/main.ts with /deploy',+ ],+ [+ 'paired mentions',+ 'Compare <report id="7">Weekly signups</report> to <hogql>SELECT 1</hogql><comment_context label="Line 4">Rename this</comment_context>',+ 'Compare Weekly signups to SELECT 1Line 4',+ ],+ ['a mention with nothing to name', 'Look at <insight /> again', 'Look at again'],+ ['a mention the preview cut mid-tag', 'Check <github_pr number="9" title="Loa', 'Check'],])('cleans %s', (_, text, expected) => {expect(spaceFeedPreview(text)).toEqual(expected)})diff --git a/products/tasks/frontend/spaces/spaceFeedPreview.ts b/products/tasks/frontend/spaces/spaceFeedPreview.tsindex 50f3693b6177..310dece14bc5 100644--- a/products/tasks/frontend/spaces/spaceFeedPreview.ts+++ b/products/tasks/frontend/spaces/spaceFeedPreview.ts@@ -12,6 +12,33 @@ const INJECTED_TAGS = [const CUSTOM_INSTRUCTIONS_TAG = 'user_custom_instructions'const CUSTOM_INSTRUCTIONS_PREAMBLE = 'The user has saved custom instructions that apply to all of their tasks.'+// The mentions the composer writes into a prompt. A card shows each one as the label PostHog Desktop prints for it.+const ID_MENTION_TAGS = ['error', 'experiment', 'insight', 'feature_flag']+const OBJECT_MENTION_TAGS = [+ 'dashboard',+ 'replay',+ 'flag',+ 'survey',+ 'ticket',+ 'report',+ 'trace',+ 'eval',+ 'event',+ 'cohort',+ 'action',+ 'person',+]+const SELF_CLOSING_MENTION_TAGS = [+ 'file',+ 'folder',+ 'skill',+ ...ID_MENTION_TAGS,+ ...OBJECT_MENTION_TAGS,+ 'github_issue',+ 'github_pr',+]+const PAIRED_MENTION_TAGS = ['report', 'hogql', 'comment_context']+const COMPLETE_BLOCK = new RegExp(`<(${INJECTED_TAGS.join('|')})\\b[^>]*>[\\s\\S]*?</\\1>`, 'g')const CUSTOM_INSTRUCTIONS_BLOCK = new RegExp(`<${CUSTOM_INSTRUCTIONS_TAG}\\b[^>]*>([\\s\\S]*?)</${CUSTOM_INSTRUCTIONS_TAG}>`,@@ -21,6 +48,67 @@ const CUSTOM_INSTRUCTIONS_BLOCK = new RegExp(const TRUNCATED_BLOCK = new RegExp(`<(${[...INJECTED_TAGS, CUSTOM_INSTRUCTIONS_TAG].join('|')})\\b(?![\\s\\S]*</\\1>)[\\s\\S]*$`)+const MENTION_TAG = new RegExp(+ `<(${SELF_CLOSING_MENTION_TAGS.join('|')})\\b([^>]*?)\\s*/>|<(${PAIRED_MENTION_TAGS.join('|')})\\b([^>]*)>([\\s\\S]*?)</\\3>`,+ 'g'+)+// Runs after the complete mentions are gone, so any mention tag left is one the truncation cut.+const TRUNCATED_MENTION = new RegExp(+ `<(?:${SELF_CLOSING_MENTION_TAGS.join('|')})\\b[^>]*$|<(${PAIRED_MENTION_TAGS.join('|')})\\b(?![\\s\\S]*</\\1>)[\\s\\S]*$`+)+const XML_ATTR = /(\w+)="([^"]*)"/g++function unescapeXml(value: string): string {+ return value+ .replace(/"/g, '"')+ .replace(/'/g, "'")+ .replace(/</g, '<')+ .replace(/>/g, '>')+ .replace(/&/g, '&')+}++function parseAttrs(raw: string): Record<string, string> {+ const attrs: Record<string, string> = {}+ for (const [, name, value] of raw.matchAll(XML_ATTR)) {+ attrs[name] = unescapeXml(value)+ }+ return attrs+}++/** A file mention shows its folder and name, like `spaces/SpaceFeed.tsx`. */+function fileLabel(path: string): string {+ const segments = path.split('/').filter(Boolean)+ const name = segments.pop() ?? path+ const folder = segments.pop()+ return folder ? `${folder}/${name}` : name+}++/** The text Desktop prints for a mention, or an empty string for a tag with nothing to name. */+function mentionLabel(tag: string, attrs: Record<string, string>, body: string): string {+ if (tag === 'file' || tag === 'folder') {+ return attrs.path ? `@${fileLabel(attrs.path)}` : ''+ }+ if (tag === 'skill') {+ return attrs.name ? `/${attrs.name}` : ''+ }+ if (ID_MENTION_TAGS.includes(tag)) {+ return attrs.id ? `@${attrs.id}` : ''+ }+ if (tag === 'github_issue' || tag === 'github_pr') {+ if (!attrs.number && !attrs.url) {+ return ''+ }+ return attrs.title ? `@#${attrs.number ?? ''} - ${attrs.title}` : `@#${attrs.number ?? ''}`+ }+ if (tag === 'hogql') {+ return unescapeXml(body).trim()+ }+ if (tag === 'comment_context') {+ return attrs.label || 'Comment'+ }+ // A PostHog object. A paired report carries its name as the tag body.+ return attrs.id ? unescapeXml(body).trim() || attrs.id : ''+}export function spaceFeedPreview(text: string | null | undefined): string {if (!text) {@@ -32,6 +120,23 @@ export function spaceFeedPreview(text: string | null | undefined): string {inner.trimStart().startsWith(CUSTOM_INSTRUCTIONS_PREAMBLE) ? '' : block).replace(TRUNCATED_BLOCK, '')+ .replace(+ MENTION_TAG,+ (+ _: string,+ selfClosingTag: string | undefined,+ selfClosingAttrs: string | undefined,+ pairedTag: string | undefined,+ pairedAttrs: string | undefined,+ body: string | undefined+ ) =>+ mentionLabel(+ selfClosingTag ?? pairedTag ?? '',+ parseAttrs(selfClosingAttrs ?? pairedAttrs ?? ''),+ body ?? ''+ )+ )+ .replace(TRUNCATED_MENTION, '').replace(/\n{3,}/g, '\n\n').trim()}