The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat: add similar threads on contribute (#42638)
Tomás Pozo549ca3677efe
diff --git a/apps/www/.env.local.example b/apps/www/.env.local.exampleindex 7aeebf4c668..b2c47601c2f 100644--- a/apps/www/.env.local.example+++ b/apps/www/.env.local.example@@ -1,15 +1,20 @@# Copy this file in the same folder, rename it to .env.local and fill out the env vars to get www working-NEXT_PUBLIC_API_URL="http://localhost:8080/platform"-NEXT_PUBLIC_DESIGN_SYSTEM_URL="http://localhost:3003"-NEXT_PUBLIC_DOCS_URL="http://localhost:3005"-NEXT_PUBLIC_MISC_USE_ANON_KEY="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im9idWxkYW5ycHRsb2t0eGNmZnZuIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MTg2MTQ2ODUsImV4cCI6MjAzNDE5MDY4NX0.NFt49g6DFkc1X5khCzN5p01iAVo2TMxlx88cY1V0E2M"-NEXT_PUBLIC_MISC_USE_URL="https://obuldanrptloktxcffvn.supabase.co"-MISC_USE_SERVICE_ROLE_KEY="secret"-NEXT_PUBLIC_REFERENCE_DOCS_URL="https://localhost:3010"-NEXT_PUBLIC_STUDIO_URL="http://localhost:8082"-NEXT_PUBLIC_SUPABASE_ANON_KEY="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InhndWloeHV6cWlid3hqbmlteGV2Iiwicm9sZSI6ImFub24iLCJpYXQiOjE2NzUwOTQ4MzUsImV4cCI6MTk5MDY3MDgzNX0.0PMlOxtKL4O9GGZuAP_Xl4f-Tut1qOnW4bNEmAtoB8w"-NEXT_PUBLIC_SUPABASE_URL="https://xguihxuzqibwxjnimxev.supabase.co"-SUPABASE_COM_SERVICE_ROLE_KEY="secret"-NEXT_PUBLIC_URL="http://localhost:3000"-NEXT_PUBLIC_HCAPTCHA_SITE_KEY="10000000-ffff-ffff-ffff-000000000001"-HCAPTCHA_SECRET_KEY="0x0000000000000000000000000000000000000000"+CMS_API_KEY=secret+CMS_PREVIEW_SECRET=secret+HCAPTCHA_SECRET_KEY=0x0000000000000000000000000000000000000000+MISC_USE_SERVICE_ROLE_KEY=secret+NEXT_PUBLIC_API_URL=http://localhost:8080/platform+NEXT_PUBLIC_DESIGN_SYSTEM_URL=http://localhost:3003+NEXT_PUBLIC_DOCS_URL=http://localhost:3005+NEXT_PUBLIC_HCAPTCHA_SITE_KEY=10000000-ffff-ffff-ffff-000000000001+NEXT_PUBLIC_MISC_USE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im9idWxkYW5ycHRsb2t0eGNmZnZuIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MTg2MTQ2ODUsImV4cCI6MjAzNDE5MDY4NX0.NFt49g6DFkc1X5khCzN5p01iAVo2TMxlx88cY1V0E2M+NEXT_PUBLIC_MISC_USE_URL=https://obuldanrptloktxcffvn.supabase.co+NEXT_PUBLIC_REFERENCE_DOCS_URL=https://localhost:3010+NEXT_PUBLIC_STUDIO_URL=http://localhost:8082+NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InhndWloeHV6cWlid3hqbmlteGV2Iiwicm9sZSI6ImFub24iLCJpYXQiOjE2NzUwOTQ4MzUsImV4cCI6MTk5MDY3MDgzNX0.0PMlOxtKL4O9GGZuAP_Xl4f-Tut1qOnW4bNEmAtoB8w+NEXT_PUBLIC_SUPABASE_CONTRIBUTE_PUBLISHABLE_KEY=ssb_publishable_mNwzuU1NFNYbzROZi6hJYw_iaNl18Qg+NEXT_PUBLIC_SUPABASE_CONTRIBUTE_URL=https://blqulwhtcjeuoxjesbas.supabase.co+NEXT_PUBLIC_SUPABASE_URL=https://xguihxuzqibwxjnimxev.supabase.co+NEXT_PUBLIC_UI_LIBRARY_URL=http://localhost:3004+NEXT_PUBLIC_URL=http://localhost:3000+SUPABASE_COM_SERVICE_ROLE_KEY=secretdiff --git a/apps/www/app/contribute/actions.ts b/apps/www/app/contribute/actions.tsnew file mode 100644index 00000000000..9bc02e876ea--- /dev/null+++ b/apps/www/app/contribute/actions.ts@@ -0,0 +1,69 @@+'use server'++import { createContributeServerClient } from '~/lib/supabaseContribute.server'+import type {+ SimilarThreadFeedbackSubmission,+ SimilarThreadFeedbackResult,+} from '~/types/contribute'++const CONTRIBUTE_FEEDBACK_FN = 'contribute-feedback'++export async function submitSimilarThreadFeedback(+ submission: SimilarThreadFeedbackSubmission+): Promise<SimilarThreadFeedbackResult> {+ const supabase = await createContributeServerClient()++ const { data, error } = await supabase.functions.invoke<{ id: string }>(CONTRIBUTE_FEEDBACK_FN, {+ body: {+ action: 'create',+ parent_thread_id: submission.parentThreadId,+ similar_thread_key: submission.similarThreadKey ?? null,+ reaction: submission.reaction,+ },+ })++ if (error) {+ console.error('[SimilarThreadFeedback] create error:', error)+ return { success: false }+ }++ const id = data?.id+ if (!id) {+ console.error('[SimilarThreadFeedback] create: no id in response')+ return { success: false }+ }++ return { success: true, id }+}++export async function updateSimilarThreadFeedback(+ id: string,+ reaction: 'positive' | 'negative',+ feedback: string | null+): Promise<SimilarThreadFeedbackResult> {+ const supabase = await createContributeServerClient()++ const { data, error } = await supabase.functions.invoke<{ success: boolean }>(+ CONTRIBUTE_FEEDBACK_FN,+ {+ body: {+ action: 'update',+ id,+ reaction,+ feedback: feedback ?? null,+ },+ }+ )++ if (error) {+ console.error('[SimilarThreadFeedback] update error:', error)+ return { success: false }+ }++ if (!data?.success) {+ console.error('[SimilarThreadFeedback] update: unexpected response')+ return { success: false }+ }++ return { success: true }+}diff --git a/apps/www/app/contribute/t/[id]/loading.tsx b/apps/www/app/contribute/t/[id]/loading.tsxindex 09e3c8b3200..9992c59c62f 100644--- a/apps/www/app/contribute/t/[id]/loading.tsx+++ b/apps/www/app/contribute/t/[id]/loading.tsx@@ -1,17 +1,10 @@-// eslint-disable-next-line no-restricted-exports+import { ContributePageLayout } from '~/components/Contribute/ContributePageLayout'+import PageLoading from './page-loading'+export default function Loading() {return (- <div className="mb-6">- <div className="grid gap-4">- <div className="border border-border rounded-lg p-4 bg-surface-100 animate-pulse">- <div className="h-4 bg-muted rounded w-3/4 mb-3"></div>- <div className="h-4 bg-muted rounded w-1/2"></div>- <div className="flex items-center gap-2 mt-3">- <div className="h-3 bg-muted rounded w-20"></div>- <div className="h-3 bg-muted rounded w-24"></div>- </div>- </div>- </div>- </div>+ <ContributePageLayout>+ <PageLoading />+ </ContributePageLayout>)}diff --git a/apps/www/app/contribute/t/[id]/page-loading.tsx b/apps/www/app/contribute/t/[id]/page-loading.tsxindex ed16c5b1540..e38efddc2f6 100644--- a/apps/www/app/contribute/t/[id]/page-loading.tsx+++ b/apps/www/app/contribute/t/[id]/page-loading.tsx@@ -1,7 +1,7 @@// eslint-disable-next-line no-restricted-exportsexport default function PageLoading() {return (- <div className="border border-border rounded-lg p-8 bg-surface-200">+ <div className="rounded-lg p-8 bg-surface-200"><div className="flex items-start justify-between gap-4 mb-6"><div className="flex-1"><div className="flex items-center gap-3 mb-4">diff --git a/apps/www/app/contribute/t/[id]/page.tsx b/apps/www/app/contribute/t/[id]/page.tsxindex 357b49dedbe..04a9f658fdf 100644--- a/apps/www/app/contribute/t/[id]/page.tsx+++ b/apps/www/app/contribute/t/[id]/page.tsx@@ -1,11 +1,10 @@-import Link from 'next/link'+import { notFound } from 'next/navigation'import { Suspense } from 'react'-import { ArrowLeft } from 'lucide-react'-import DefaultLayout from '~/components/Layouts/Default'-import { ThreadContent } from '~/components/Contribute/ThreadContent'-import PageLoading from './page-loading'+import { ContributePageLayout } from '~/components/Contribute/ContributePageLayout'+import { Conversation } from '~/components/Contribute/Conversation'+import { getThreadById } from '~/data/contribute'import type { Metadata } from 'next'-import { ContributeGuard } from '../../ContributeGuard'+import PageLoading from './page-loading'export const metadata: Metadata = {robots: {@@ -14,29 +13,21 @@ export const metadata: Metadata = {},}-// eslint-disable-next-line no-restricted-exportsexport default async function ThreadPage({ params }: { params: Promise<{ id: string }> }) {const { id } = await params+ const thread = await getThreadById(id)- return (- <ContributeGuard>- <DefaultLayout>- <main className="min-h-screen flex flex-col items-center">- <div className="flex-1 w-full max-w-4xl mx-auto px-4 py-16">- <Link- href="/contribute"- className="inline-flex items-center gap-2 text-foreground-lighter hover:text-foreground transition-colors mb-8"- >- <ArrowLeft className="h-4 w-4" />- Back to threads- </Link>+ if (!thread) {+ notFound()+ }- <Suspense fallback={<PageLoading />}>- <ThreadContent id={id} />- </Suspense>- </div>- </main>- </DefaultLayout>- </ContributeGuard>+ return (+ <ContributePageLayout>+ <Suspense fallback={<PageLoading />}>+ <div className="grid gap-6">+ <Conversation thread={thread} />+ </div>+ </Suspense>+ </ContributePageLayout>)}diff --git a/apps/www/app/contribute/u/[id]/loading.tsx b/apps/www/app/contribute/u/[id]/loading.tsxindex 3d95385620d..9c7601b612c 100644--- a/apps/www/app/contribute/u/[id]/loading.tsx+++ b/apps/www/app/contribute/u/[id]/loading.tsx@@ -1,7 +1,11 @@+import { ContributePageLayout } from '~/components/Contribute/ContributePageLayout'+export default function Loading() {return (- <div className="border border-border rounded-lg p-8 text-center text-muted-foreground bg-surface-200">- Loading user profile...- </div>+ <ContributePageLayout>+ <div className="border border-border rounded-lg p-8 text-center text-muted-foreground bg-surface-200">+ Loading user profile...+ </div>+ </ContributePageLayout>)}diff --git a/apps/www/app/contribute/u/[id]/not-found.tsx b/apps/www/app/contribute/u/[id]/not-found.tsxindex 949d5f01a19..cb654c543b9 100644--- a/apps/www/app/contribute/u/[id]/not-found.tsx+++ b/apps/www/app/contribute/u/[id]/not-found.tsx@@ -1,20 +1,13 @@-import Link from 'next/link'-import { ArrowLeft } from 'lucide-react'+import { BackToThreadsLink } from '~/components/Contribute/BackToThreadsLink'export default function NotFound() {return (<div className="border border-border rounded-lg p-8 bg-surface-200 text-center"><h2 className="text-xl font-semibold text-foreground mb-2">User Not Found</h2><p className="text-foreground-light mb-6">- This user hasn't created any threads or replies yet, or doesn't exist.+ This user hasn’t created any threads or replies yet, or doesn’t exist.</p>- <Link- href="/contribute"- className="inline-flex items-center gap-2 text-brand hover:underline transition-colors"- >- <ArrowLeft className="h-4 w-4" />- Back to threads- </Link>+ <BackToThreadsLink /></div>)}diff --git a/apps/www/app/contribute/u/[id]/page.tsx b/apps/www/app/contribute/u/[id]/page.tsxindex d311e192d03..fda37b4e4ca 100644--- a/apps/www/app/contribute/u/[id]/page.tsx+++ b/apps/www/app/contribute/u/[id]/page.tsx@@ -1,10 +1,7 @@-import Link from 'next/link'import { Suspense } from 'react'-import { ArrowLeft } from 'lucide-react'-import DefaultLayout from '~/components/Layouts/Default'+import { ContributePageLayout } from '~/components/Contribute/ContributePageLayout'import { UserProfile } from '~/components/Contribute/UserProfile'import type { Metadata } from 'next'-import { ContributeGuard } from '../../ContributeGuard'export const metadata: Metadata = {robots: {@@ -21,30 +18,15 @@ function UserProfileLoading() {)}-// eslint-disable-next-line no-restricted-exportsexport default async function UserProfilePage({ params }: { params: Promise<{ id: string }> }) {const { id } = await paramsconst username = decodeURIComponent(id)return (- <ContributeGuard>- <DefaultLayout>- <main className="min-h-screen flex flex-col items-center">- <div className="flex-1 w-full max-w-4xl mx-auto px-4 py-16">- <Link- href="/contribute"- className="inline-flex items-center gap-2 text-foreground-lighter hover:text-foreground transition-colors mb-8"- >- <ArrowLeft className="h-4 w-4" />- Back to threads- </Link>-- <Suspense fallback={<UserProfileLoading />}>- <UserProfile username={username} />- </Suspense>- </div>- </main>- </DefaultLayout>- </ContributeGuard>+ <ContributePageLayout>+ <Suspense fallback={<UserProfileLoading />}>+ <UserProfile username={username} />+ </Suspense>+ </ContributePageLayout>)}diff --git a/apps/www/components/Contribute/BackToThreadsLink.tsx b/apps/www/components/Contribute/BackToThreadsLink.tsxnew file mode 100644index 00000000000..9c9435ac38b--- /dev/null+++ b/apps/www/components/Contribute/BackToThreadsLink.tsx@@ -0,0 +1,14 @@+import Link from 'next/link'+import { ArrowLeft } from 'lucide-react'++export function BackToThreadsLink() {+ return (+ <Link+ href="/contribute"+ className="inline-flex items-center gap-1.5 text-xs text-foreground-lighter hover:text-foreground transition-colors mb-4"+ >+ <ArrowLeft className="h-3 w-3" />+ Threads+ </Link>+ )+}diff --git a/apps/www/components/Contribute/ContributePageLayout.tsx b/apps/www/components/Contribute/ContributePageLayout.tsxnew file mode 100644index 00000000000..94f04f1b8b3--- /dev/null+++ b/apps/www/components/Contribute/ContributePageLayout.tsx@@ -0,0 +1,18 @@+import DefaultLayout from '~/components/Layouts/Default'+import { BackToThreadsLink } from '~/components/Contribute/BackToThreadsLink'+import { ContributeGuard } from '~/app/contribute/ContributeGuard'++export function ContributePageLayout({ children }: { children: React.ReactNode }) {+ return (+ <ContributeGuard>+ <DefaultLayout>+ <main className="min-h-screen flex flex-col items-center">+ <div className="flex-1 w-full max-w-4xl mx-auto px-4 py-16">+ <BackToThreadsLink />+ {children}+ </div>+ </main>+ </DefaultLayout>+ </ContributeGuard>+ )+}diff --git a/apps/www/components/Contribute/Conversation.tsx b/apps/www/components/Contribute/Conversation.tsxindex 80f55325a1e..cb035272fe8 100644--- a/apps/www/components/Contribute/Conversation.tsx+++ b/apps/www/components/Contribute/Conversation.tsx@@ -1,13 +1,14 @@import Link from 'next/link'import ReactMarkdown from 'react-markdown'import remarkGfm from 'remark-gfm'-import { Badge, Card, CardContent } from 'ui'+import { Badge, Card, CardContent, CardHeader, CardTitle } from 'ui'import { getThreadRepliesById } from '~/data/contribute'import type { ThreadRow } from '~/types/contribute'import { HelpOnPlatformButton } from './HelpOnPlatformButton'-import { DiscordIcon, GitHubIcon, RedditIcon } from './Icons'+import { ChannelIcon } from './Icons'import { markdownComponents } from './markdownComponents'import { RepliesList } from './RepliesList'+import { SimilarSolvedThreads } from './SimilarSolvedThreads'export async function Conversation({ thread }: { thread: ThreadRow }) {const { question, replies } = await getThreadRepliesById(thread.thread_key)@@ -17,91 +18,111 @@ export async function Conversation({ thread }: { thread: ThreadRow }) {}const validReplies = replies.filter((reply: { content: string | null }) => reply.content)+ const productAreas = thread.product_areas.filter((a: string) => a !== 'Other')+ const stackItems = thread.stack.filter((t: string) => t !== 'Other')+ const hasMetadata = productAreas.length > 0 || stackItems.length > 0return (<div className="flex flex-col gap-10">{/* Title, Question, and First Reply Section */}{question && question.content && (- <div className="bg-surface-200 p-6 rounded-lg border border-border">- {/* Title */}- <div className="mb-6">- <div className="flex items-center justify-between mb-4">- <div className="flex items-center gap-2">- {thread.channel === 'discord' && <DiscordIcon className="h-5 w-5 text-[#5865F2]" />}- {thread.channel === 'reddit' && <RedditIcon className="h-5 w-5 text-[#FF4500]" />}- {thread.channel === 'github' && <GitHubIcon className="h-5 w-5 text-foreground" />}- <span className="text-sm text-foreground-lighter capitalize">{thread.channel}</span>- <span className="text-sm text-foreground-lighter">·</span>- <span className="text-sm text-foreground-lighter">{thread.posted}</span>+ <div className="bg-surface-200 p-[var(--card-padding-x)] rounded-lg flex flex-col gap-6">+ {/* Platform, Date, Author, Title */}+ <header className="flex flex-col gap-3">+ {/* Platform, Date, Author - logo spans both rows; platform/date and author link out */}+ <div className="flex items-stretch gap-3">+ <a+ href={thread.external_activity_url}+ target="_blank"+ rel="noopener noreferrer"+ className="flex items-center justify-center bg-surface-400 h-10 w-10 rounded-md shrink-0 self-stretch hover:opacity-80 transition-opacity"+ >+ <ChannelIcon channel={thread.channel} />+ </a>+ <div className="flex flex-col gap-0.5 justify-center min-w-0 text-left">+ <a+ href={thread.external_activity_url}+ target="_blank"+ rel="noopener noreferrer"+ className="text-xs text-foreground-light hover:text-foreground transition-colors"+ >+ {thread.channelDisplayName} · {thread.posted}+ </a>+ <Link+ href={`/contribute/u/${encodeURIComponent(thread.user)}`}+ className="text-xs text-foreground-light hover:text-foreground transition-colors"+ >+ {thread.user}+ </Link></div>- <HelpOnPlatformButton- channel={thread.channel}- externalActivityUrl={thread.external_activity_url}- /></div>- <h1 className="text-2xl font-medium text-foreground mb-2">{thread.title}</h1>- <p className="text-sm text-foreground-lighter">- by{' '}- <Link- href={`/contribute/u/${encodeURIComponent(thread.user)}`}- className="hover:text-foreground transition-colors"- >- {thread.user}- </Link>- </p>- </div>++ <a+ href={thread.external_activity_url}+ target="_blank"+ rel="noopener noreferrer"+ className="hover:opacity-80 transition-opacity"+ >+ <h1 className="text-2xl font-medium text-foreground text-balance">{thread.title}</h1>+ </a>++ {/* Product areas and stack */}+ {hasMetadata && (+ <div className="flex flex-wrap gap-0.5 items-center">+ {productAreas.map((area: string) => (+ <Badge key={area} variant="default">+ {area}+ </Badge>+ ))}+ {productAreas.length > 0 && stackItems.length > 0 && (+ <span className="text-muted-foreground px-0.5">·</span>+ )}+ {stackItems.map((tech: string) => (+ <Badge key={tech} variant="default">+ {tech}+ </Badge>+ ))}+ </div>+ )}+ </header>{/* Question */}<div className="border border-border rounded-lg p-6 bg-surface-100 min-w-0 shadow-sm">- <div className="text-foreground mb-4 min-w-0">+ <div className="text-foreground min-w-0"><ReactMarkdown components={markdownComponents} remarkPlugins={[remarkGfm]}>{question.content}</ReactMarkdown></div>- <div className="flex items-center gap-2 text-xs text-muted-foreground">- {question.author && (- <>- <Badge variant="success">OP</Badge>- <Link- href={`/contribute/u/${encodeURIComponent(question.author)}`}- className="font-medium hover:text-foreground transition-colors"- >- {question.author}- </Link>- </>- )}- {question.author && question.ts && <span>·</span>}- {question.ts && question.external_activity_url ? (- <a- href={question.external_activity_url}- target="_blank"- rel="noopener noreferrer"- className="hover:text-foreground transition-colors"- >- {new Date(question.ts).toLocaleString()}- </a>- ) : (- question.ts && <span>{new Date(question.ts).toLocaleString()}</span>- )}- </div></div></div>)}{/* Summary Section */}{thread.summary && (- <div className="flex flex-col gap-3">- <h3 className="text-sm font-medium text-foreground">How to help</h3>- <Card>- <CardContent className="px-6 py-8 flex flex-col gap-6">- <div className="text-base text-foreground">- <ReactMarkdown components={markdownComponents} remarkPlugins={[remarkGfm]}>- {thread.summary}- </ReactMarkdown>- </div>- </CardContent>- </Card>- </div>+ <Card>+ <CardHeader>+ <CardTitle>How to help</CardTitle>+ </CardHeader>+ <CardContent className="px-6 py-8 flex flex-col gap-6">+ <div className="text-base text-foreground">+ <ReactMarkdown components={markdownComponents} remarkPlugins={[remarkGfm]}>+ {thread.summary}+ </ReactMarkdown>+ </div>+ {/* CTA Button */}+ <div>+ <HelpOnPlatformButton+ channel={thread.channel}+ externalActivityUrl={thread.external_activity_url}+ />+ </div>+ </CardContent>+ </Card>+ )}++ {/* Similar Solved Threads */}+ {thread.similar_solved_threads && thread.similar_solved_threads.length > 0 && (+ <SimilarSolvedThreads threads={thread.similar_solved_threads} parentThreadId={thread.id} />)}{/* Remaining Replies Section */}diff --git a/apps/www/components/Contribute/HelpOnPlatformButton.tsx b/apps/www/components/Contribute/HelpOnPlatformButton.tsxindex 30c85e51d75..28186051103 100644--- a/apps/www/components/Contribute/HelpOnPlatformButton.tsx+++ b/apps/www/components/Contribute/HelpOnPlatformButton.tsx@@ -1,22 +1,24 @@import { Button } from 'ui'+import { getChannelDisplayName } from '~/data/contribute'import type { ThreadSource } from '~/types/contribute'interface HelpOnPlatformButtonProps {channel: ThreadSourceexternalActivityUrl: string+ type?: 'primary' | 'default'className?: string}export function HelpOnPlatformButton({channel,externalActivityUrl,+ type = 'primary',className = 'w-full sm:w-fit',}: HelpOnPlatformButtonProps) {- const platformName =- channel === 'discord' ? 'Discord' : channel === 'reddit' ? 'Reddit' : 'GitHub'+ const platformName = getChannelDisplayName(channel)return (- <Button asChild type="default" className={className}>+ <Button asChild type={type} className={className}><a href={externalActivityUrl} target="_blank" rel="noopener noreferrer">Help on {platformName}</a>diff --git a/apps/www/components/Contribute/Icons.tsx b/apps/www/components/Contribute/Icons.tsxindex 0e933460ec8..fdc0651e49d 100644--- a/apps/www/components/Contribute/Icons.tsx+++ b/apps/www/components/Contribute/Icons.tsx@@ -1,5 +1,6 @@import type { SVGProps } from 'react'import { cn } from 'ui'+import type { ThreadSource } from '~/types/contribute'export function RedditIcon(props: SVGProps<SVGSVGElement>) {return (@@ -43,6 +44,20 @@ export function GitHubIcon(props: SVGProps<SVGSVGElement>) {)}+export function ChannelIcon({ channel, className }: { channel: ThreadSource; className?: string }) {+ const iconClassName = cn('h-4 w-4', className)+ if (channel === 'discord') {+ return <DiscordIcon className={cn(iconClassName, 'text-[#5865F2]')} />+ }+ if (channel === 'reddit') {+ return <RedditIcon className={cn(iconClassName, 'text-[#FF4500]')} />+ }+ if (channel === 'github') {+ return <GitHubIcon className={cn(iconClassName, 'text-foreground')} />+ }+ return null+}+export function AllIcon(props: SVGProps<SVGSVGElement>) {return (<svg@@ -51,9 +66,9 @@ export function AllIcon(props: SVGProps<SVGSVGElement>) {viewBox="0 0 24 24"fill="none"stroke="currentColor"- stroke-width="2"- stroke-linecap="round"- stroke-linejoin="round"+ strokeWidth="2"+ strokeLinecap="round"+ strokeLinejoin="round"{...props}><path d="M16 5H3" />diff --git a/apps/www/components/Contribute/RepliesList.tsx b/apps/www/components/Contribute/RepliesList.tsxindex c10bbf36b79..6c3ad21effd 100644--- a/apps/www/components/Contribute/RepliesList.tsx+++ b/apps/www/components/Contribute/RepliesList.tsx@@ -4,7 +4,7 @@ import Link from 'next/link'import { useState } from 'react'import ReactMarkdown from 'react-markdown'import remarkGfm from 'remark-gfm'-import { Badge, Button, Card, CardContent, CardFooter } from 'ui'+import { Badge, Button, Card, CardContent, CardFooter, CardHeader, CardTitle } from 'ui'import { markdownComponents } from './markdownComponents'interface Reply {@@ -34,10 +34,13 @@ export function RepliesList({ replies, questionAuthor, totalReplyCount }: Repliereturn (<div className="flex flex-col gap-3">- <h3 className="text-sm font-medium text-muted-foreground">- {displayCount} {displayCount === 1 ? 'reply' : 'replies'}- </h3><Card className="relative">+ <CardHeader>+ <CardTitle>+ Replies{' '}+ <span className="text-foreground-muted tabular-nums font-normal">({displayCount})</span>+ </CardTitle>+ </CardHeader><CardContent className="flex flex-col p-0">{displayedReplies.map((reply, index) => {const timestamp = reply.ts ? new Date(reply.ts).toLocaleString() : nulldiff --git a/apps/www/components/Contribute/SimilarSolvedThreads.tsx b/apps/www/components/Contribute/SimilarSolvedThreads.tsxnew file mode 100644index 00000000000..2020174df1b--- /dev/null+++ b/apps/www/components/Contribute/SimilarSolvedThreads.tsx@@ -0,0 +1,309 @@+'use client'++import { submitSimilarThreadFeedback, updateSimilarThreadFeedback } from '~/app/contribute/actions'+import type {+ SimilarSolvedThread,+ SimilarThreadFeedbackReaction,+ ThreadSource,+} from '~/types/contribute'+import { ChevronDown, ThumbsDown, ThumbsUp } from 'lucide-react'+import { useRef, useState } from 'react'+import {+ Badge,+ Button,+ Card,+ CardContent,+ CardFooter,+ CardHeader,+ cn,+ Dialog,+ DialogContent,+ DialogDescription,+ DialogFooter,+ DialogHeader,+ DialogSection,+ DialogSectionSeparator,+ DialogTitle,+ Label_Shadcn_,+ TextArea_Shadcn_,+ Tooltip,+ TooltipContent,+ TooltipProvider,+ TooltipTrigger,+} from 'ui'++import { ChannelIcon } from './Icons'++function getChannelFromUrl(url: string): ThreadSource {+ const u = url.toLowerCase()+ if (u.includes('discord')) return 'discord'+ if (u.includes('reddit')) return 'reddit'+ if (u.includes('github')) return 'github'+ // TODO: handle unknown URL patterns more explictly, don’t just default to GitHub+ return 'github'+}++interface SimilarSolvedThreadsProps {+ threads: SimilarSolvedThread[]+ parentThreadId: string+}++const SimilarThreadCard = ({+ thread,+ className,+}: {+ thread: SimilarSolvedThread+ className?: string+}) => {+ const channel = getChannelFromUrl(thread.external_activity_url || '')+ const filteredStack = thread.stack?.filter((s) => s !== 'Other') ?? []+ const hasStack = filteredStack.length > 0++ const url = thread.external_activity_url || null+ const linkClassName = cn(+ 'border-b border-border px-6 py-4 flex items-center gap-3 overflow-hidden hover:bg-surface-200 transition-colors',+ className+ )+ const content = (+ <>+ <div className="flex items-center justify-center bg-surface-200 dark:bg-surface-300 h-10 w-10 rounded-md shrink-0">+ <ChannelIcon channel={channel} />+ </div>+ <div className="min-w-0 flex-1 flex flex-col">+ <h4 className="text-base text-foreground truncate block">{thread.subject}</h4>+ {thread.problem_description ? (+ <p className="text-sm text-foreground-lighter leading-relaxed line-clamp-2">+ {thread.problem_description}+ </p>+ ) : null}+ {hasStack ? (+ <div className="flex flex-wrap gap-x-1.5 gap-y-1 overflow-hidden pt-1">+ {filteredStack.map((tech) => (+ <Badge key={tech} variant="default">+ {tech}+ </Badge>+ ))}+ </div>+ ) : null}+ </div>+ </>+ )++ if (url) {+ return (+ <a+ href={url}+ target="_blank"+ rel="noopener noreferrer"+ className={linkClassName}+ aria-label={`View thread: ${thread.subject}`}+ >+ {content}+ </a>+ )+ }++ return <div className={linkClassName}>{content}</div>+}++export const SimilarSolvedThreads = ({ threads, parentThreadId }: SimilarSolvedThreadsProps) => {+ const [isExpanded, setIsExpanded] = useState(true)+ const [submittedReaction, setSubmittedReaction] = useState<SimilarThreadFeedbackReaction | null>(+ null+ )+ const [feedbackId, setFeedbackId] = useState<string | null>(null)+ const [dialogOpen, setDialogOpen] = useState(false)+ const [dialogReaction, setDialogReaction] = useState<SimilarThreadFeedbackReaction>('positive')+ const [dialogFeedback, setDialogFeedback] = useState('')+ const [isSubmitting, setIsSubmitting] = useState(false)+ const isClosingProgrammatically = useRef(false)++ const handleThumbClick = async (reaction: SimilarThreadFeedbackReaction) => {+ if (submittedReaction) return+ setIsSubmitting(true)+ const result = await submitSimilarThreadFeedback({+ parentThreadId,+ reaction,+ similarThreadKey: null,+ })+ setIsSubmitting(false)+ if (result.success) {+ setFeedbackId(result.id ?? null)+ setDialogReaction(reaction)+ setDialogFeedback('')+ setDialogOpen(true)+ }+ }++ const persistAndCloseDialog = async () => {+ if (!feedbackId) return+ setIsSubmitting(true)+ const result = await updateSimilarThreadFeedback(+ feedbackId,+ dialogReaction,+ dialogFeedback.trim() || null+ )+ setIsSubmitting(false)+ if (result.success) {+ setSubmittedReaction(dialogReaction)+ isClosingProgrammatically.current = true+ setDialogOpen(false)+ queueMicrotask(() => {+ isClosingProgrammatically.current = false+ })+ }+ }++ const handleDialogOpenChange = (open: boolean) => {+ setDialogOpen(open)+ if (!open && feedbackId && !isClosingProgrammatically.current) {+ persistAndCloseDialog()+ }+ }++ return (+ <Card className={cn('relative')}>+ <CardHeader className={cn('p-0', !isExpanded && 'border-b-0')}>+ <button+ type="button"+ onClick={() => setIsExpanded((prev) => !prev)}+ className="flex w-full items-center gap-1.5 px-[var(--card-padding-x)] py-4 text-left text-xs font-mono uppercase text-card-foreground"+ >+ Related threads+ <span className="text-foreground-muted tabular-nums font-normal">({threads.length})</span>+ <ChevronDown+ className={`h-3.5 w-3.5 text-foreground-lighter transition-transform duration-200 ${+ isExpanded ? 'rotate-0' : '-rotate-90'+ }`}+ />+ </button>+ </CardHeader>+ {isExpanded && (+ <>+ <CardContent className="p-0">+ {threads.map((thread, idx) => (+ <SimilarThreadCard+ key={thread.thread_key || idx}+ thread={thread}+ className={idx === threads.length - 1 ? 'border-b-0' : undefined}+ />+ ))}+ </CardContent>+ <CardFooter className="flex items-center justify-between min-h-[58px]">+ {submittedReaction ? (+ <span className="text-sm text-foreground-muted">+ Thanks for helping improve related threads+ </span>+ ) : (+ <TooltipProvider>+ <div className="flex items-center gap-1">+ <Tooltip>+ <TooltipTrigger asChild>+ <button+ type="button"+ onClick={() => handleThumbClick('positive')}+ disabled={isSubmitting}+ className="p-1 rounded hover:bg-surface-200 transition-colors disabled:opacity-50"+ aria-label="Relevant"+ >+ <ThumbsUp className="h-4 w-4 text-foreground-muted" />+ </button>+ </TooltipTrigger>+ <TooltipContent>Relevant</TooltipContent>+ </Tooltip>+ <Tooltip>+ <TooltipTrigger asChild>+ <button+ type="button"+ onClick={() => handleThumbClick('negative')}+ disabled={isSubmitting}+ className="p-1 rounded hover:bg-surface-200 transition-colors disabled:opacity-50"+ aria-label="Irrelevant"+ >+ <ThumbsDown className="h-4 w-4 text-foreground-muted" />+ </button>+ </TooltipTrigger>+ <TooltipContent>Irrelevant</TooltipContent>+ </Tooltip>+ </div>+ </TooltipProvider>+ )}+ </CardFooter>+ </>+ )}++ <Dialog open={dialogOpen} onOpenChange={handleDialogOpenChange}>+ <DialogContent>+ <DialogHeader>+ <DialogTitle>Help improve related threads</DialogTitle>+ <DialogDescription>How relevant were these threads to your issue?</DialogDescription>+ </DialogHeader>+ <DialogSectionSeparator />+ <DialogSection className="space-y-4">+ <fieldset className="space-y-1">+ <legend className="text-sm text-foreground">Relevance</legend>+ <div className="flex items-center gap-1">+ <label+ className={cn(+ 'p-2 rounded cursor-pointer transition-colors',+ dialogReaction === 'positive'+ ? 'bg-surface-300 text-foreground'+ : 'hover:bg-surface-200 text-foreground-lighter'+ )}+ >+ <input+ type="radio"+ name="relevance"+ value="positive"+ checked={dialogReaction === 'positive'}+ onChange={() => setDialogReaction('positive')}+ className="sr-only"+ aria-label="Relevant"+ />+ <ThumbsUp className="h-4 w-4" aria-hidden />+ </label>+ <label+ className={cn(+ 'p-2 rounded cursor-pointer transition-colors',+ dialogReaction === 'negative'+ ? 'bg-surface-300 text-foreground'+ : 'hover:bg-surface-200 text-foreground-lighter'+ )}+ >+ <input+ type="radio"+ name="relevance"+ value="negative"+ checked={dialogReaction === 'negative'}+ onChange={() => setDialogReaction('negative')}+ className="sr-only"+ aria-label="Irrelevant or unhelpful"+ />+ <ThumbsDown className="h-4 w-4" aria-hidden />+ </label>+ </div>+ </fieldset>+ <div className="space-y-1">+ <Label_Shadcn_ htmlFor="feedback">+ Additional feedback <span className="text-foreground-muted">(optional)</span>+ </Label_Shadcn_>+ <TextArea_Shadcn_+ id="feedback"+ placeholder="What was helpful or missing?"+ rows={4}+ value={dialogFeedback}+ onChange={(e) => setDialogFeedback(e.target.value)}+ className="text-sm resize-none"+ />+ </div>+ </DialogSection>+ <DialogFooter>+ <Button onClick={persistAndCloseDialog} disabled={isSubmitting} loading={isSubmitting}>+ {isSubmitting ? 'Submitting...' : 'Submit feedback'}+ </Button>+ </DialogFooter>+ </DialogContent>+ </Dialog>+ </Card>+ )+}diff --git a/apps/www/components/Contribute/ThreadContent.tsx b/apps/www/components/Contribute/ThreadContent.tsxdeleted file mode 100644index 5222f3f42af..00000000000--- a/apps/www/components/Contribute/ThreadContent.tsx+++ /dev/null@@ -1,66 +0,0 @@-import { notFound } from 'next/navigation'-import { Suspense } from 'react'-import { Badge } from 'ui'-import { Conversation } from '~/components/Contribute/Conversation'-import { HelpOnPlatformButton } from '~/components/Contribute/HelpOnPlatformButton'-import { getThreadById } from '~/data/contribute'-import Loading from '../../app/contribute/t/[id]/loading'--export async function ThreadContent({ id }: { id: string }) {- const thread = await getThreadById(id)-- if (!thread) {- notFound()- }-- return (- <div className="grid gap-6">- {/* Conversation Section (includes title, question, and first reply) */}- <Suspense fallback={<Loading />}>- <Conversation thread={thread} />- </Suspense>-- {/* Metadata and Actions Section */}- <div className="border border-border rounded-lg p-6 bg-surface-200">- <div className="grid grid-cols-1 md:grid-cols-2 gap-8 mb-6 pb-6 border-b border-border">- {thread.product_areas.filter((area: string) => area !== 'Other').length > 0 && (- <div>- <h3 className="text-sm font-medium text-foreground mb-2">Product areas</h3>- <div className="flex flex-wrap gap-2">- {thread.product_areas- .filter((area: string) => area !== 'Other')- .map((area: string) => (- <Badge key={area} variant="default">- {area}- </Badge>- ))}- </div>- </div>- )}-- {thread.stack.filter((tech: string) => tech !== 'Other').length > 0 && (- <div>- <h3 className="text-sm font-medium text-foreground mb-2">Stack</h3>- <div className="flex flex-wrap gap-2">- {thread.stack- .filter((tech: string) => tech !== 'Other')- .map((tech: string) => (- <Badge key={tech} variant="default">- {tech}- </Badge>- ))}- </div>- </div>- )}- </div>- {/* CTA Button */}- <div>- <HelpOnPlatformButton- channel={thread.channel}- externalActivityUrl={thread.external_activity_url}- />- </div>- </div>- </div>- )-}diff --git a/apps/www/components/Contribute/UnansweredThreadsTable.tsx b/apps/www/components/Contribute/UnansweredThreadsTable.tsxindex 7fff25835dd..71ce44a9e3e 100644--- a/apps/www/components/Contribute/UnansweredThreadsTable.tsx+++ b/apps/www/components/Contribute/UnansweredThreadsTable.tsx@@ -25,7 +25,7 @@ import {import type { ThreadRow } from '~/types/contribute'import { FilterPopover } from './FilterPopover'-import { DiscordIcon, GitHubIcon, RedditIcon } from './Icons'+import { ChannelIcon, DiscordIcon, GitHubIcon, RedditIcon } from './Icons'interface TabConfig {id: string@@ -398,31 +398,8 @@ function ThreadRow({<TableCell className="w-auto max-w-[600px]"><div className="flex items-center gap-3 overflow-hidden">{/* Channel icon */}- <div className="flex items-center justify-center bg-surface-200 h-10 w-10 rounded-md">- {thread.channel === 'discord' && (- <DiscordIcon- className={cn(- 'h-4 w-4',- thread.channel === 'discord' ? 'text-[#5865F2]' : 'text-foreground-lighter'- )}- />- )}- {thread.channel === 'reddit' && (- <RedditIcon- className={cn(- 'h-4 w-4',- thread.channel === 'reddit' ? 'text-[#FF4500]' : 'text-foreground-lighter'- )}- />- )}- {thread.channel === 'github' && (- <GitHubIcon- className={cn(- 'h-4 w-4',- thread.channel === 'github' ? 'text-foreground' : 'text-foreground-lighter'- )}- />- )}+ <div className="flex items-center justify-center bg-surface-200 h-10 w-10 rounded-md shrink-0">+ <ChannelIcon channel={thread.channel} /></div><div className="min-w-0 flex-1 flex flex-col gap-y-0.5">{/* Thread title */}diff --git a/apps/www/components/Contribute/UserProfile.tsx b/apps/www/components/Contribute/UserProfile.tsxindex 86756c6fdd7..dd42250113e 100644--- a/apps/www/components/Contribute/UserProfile.tsx+++ b/apps/www/components/Contribute/UserProfile.tsx@@ -16,7 +16,7 @@ function ThreadCard({ thread }: { thread: ThreadRow }) {{thread.channel === 'discord' && <DiscordIcon className="h-4 w-4 text-[#5865F2]" />}{thread.channel === 'reddit' && <RedditIcon className="h-4 w-4 text-[#FF4500]" />}{thread.channel === 'github' && <GitHubIcon className="h-4 w-4 text-foreground" />}- <span className="capitalize">{thread.channel}</span>+ <span>{thread.channelDisplayName}</span><span>•</span><span>{thread.posted}</span></div>@@ -56,9 +56,7 @@ interface Reply {}function ReplyCard({ reply, thread }: { reply: Reply; thread?: ThreadRow }) {- const platformName = thread?.channel- ? thread.channel.charAt(0).toUpperCase() + thread.channel.slice(1)- : 'platform'+ const platformName = thread?.channelDisplayName ?? 'platform'return (<div className="border border-border rounded-lg p-4 bg-surface-75 min-w-0">diff --git a/apps/www/data/contribute/index.ts b/apps/www/data/contribute/index.tsindex 41e910e42d1..bbc15a07a20 100644--- a/apps/www/data/contribute/index.ts+++ b/apps/www/data/contribute/index.ts@@ -1,7 +1,9 @@import { createClient } from '@supabase/supabase-js'import type {- LeaderboardPeriod,LeaderboardRow,+ SimilarSolvedThread,+ SimilarThreadFeedbackResult,+ SimilarThreadFeedbackSubmission,Thread,ThreadRow,ThreadSource,@@ -25,6 +27,10 @@ function normalizeSource(source: string | null): ThreadSource {return source.toLowerCase().trim() as ThreadSource}+export function getChannelDisplayName(source: ThreadSource): string {+ return source === 'discord' ? 'Discord' : source === 'reddit' ? 'Reddit' : 'GitHub'+}+function mapThreadRowToThread(row: Thread): ThreadRow {const firstMsgTime = row.first_msg_time ? new Date(row.first_msg_time) : nullconst source = normalizeSource(row.source)@@ -34,6 +40,7 @@ function mapThreadRowToThread(row: Thread): ThreadRow {title: row.subject ?? row.title ?? '',user: row.author,channel: source,+ channelDisplayName: getChannelDisplayName(source),conversation: row.conversation ?? '',tags: row.product_areas ?? [],product_areas: row.product_areas ?? [],@@ -51,6 +58,8 @@ function mapThreadRowToThread(row: Thread): ThreadRow {summary: row.summary,thread_key: row.thread_key ?? null,message_count: row.message_count ?? null,+ similar_solved_threads:+ (row.similar_solved_threads as unknown as SimilarSolvedThread[] | null) ?? null,}}@@ -176,9 +185,9 @@ export async function getThreadById(id: string): Promise<ThreadRow | null> {const supabase = createClient(supabaseUrl, supabasePublishableKey)const { data, error } = await supabase- .from('v_contribute_threads')+ .from('contribute_threads').select(- 'thread_id, subject, status, author, conversation, external_activity_url, created_at, source, product_areas, stack, category, sub_category, summary, first_msg_time, message_count, thread_key'+ 'thread_id, subject, status, author, conversation, external_activity_url, created_at, source, product_areas, stack, category, sub_category, summary, first_msg_time, message_count, thread_key, contribute_thread_triage(similar_solved_threads)').eq('thread_id', id).single()@@ -192,7 +201,15 @@ export async function getThreadById(id: string): Promise<ThreadRow | null> {return null}- return mapThreadRowToThread(data as Thread)+ const triage = Array.isArray(data.contribute_thread_triage)+ ? data.contribute_thread_triage[0]+ : data.contribute_thread_triage+ const threadWithTriage = {+ ...data,+ similar_solved_threads: triage?.similar_solved_threads ?? null,+ }++ return mapThreadRowToThread(threadWithTriage as unknown as Thread)}export async function getThreadRepliesById(thread_key: string | null) {@@ -339,3 +356,65 @@ export async function getUserActivity(author: string) {},}}++const CONTRIBUTE_FEEDBACK_FN = 'contribute-feedback'++export async function submitSimilarThreadFeedback(+ submission: SimilarThreadFeedbackSubmission+): Promise<SimilarThreadFeedbackResult> {+ const supabase = createClient(supabaseUrl, supabasePublishableKey)++ const { data, error } = await supabase.functions.invoke<{ id: string }>(CONTRIBUTE_FEEDBACK_FN, {+ body: {+ action: 'create',+ parent_thread_id: submission.parentThreadId,+ similar_thread_key: submission.similarThreadKey ?? null,+ reaction: submission.reaction,+ },+ })++ if (error) {+ console.error('[SimilarThreadFeedback] create error:', error)+ return { success: false }+ }++ const id = data?.id+ if (!id) {+ console.error('[SimilarThreadFeedback] create: no id in response')+ return { success: false }+ }++ return { success: true, id }+}++export async function updateSimilarThreadFeedback(+ id: string,+ reaction: 'positive' | 'negative',+ feedback: string | null+): Promise<SimilarThreadFeedbackResult> {+ const supabase = createClient(supabaseUrl, supabasePublishableKey)++ const { data, error } = await supabase.functions.invoke<{ success: boolean }>(+ CONTRIBUTE_FEEDBACK_FN,+ {+ body: {+ action: 'update',+ id,+ reaction,+ feedback: feedback ?? null,+ },+ }+ )++ if (error) {+ console.error('[SimilarThreadFeedback] update error:', error)+ return { success: false }+ }++ if (!data?.success) {+ console.error('[SimilarThreadFeedback] update: unexpected response')+ return { success: false }+ }++ return { success: true }+}diff --git a/apps/www/lib/contribute.types.ts b/apps/www/lib/contribute.types.tsindex bd01b24e603..577a5f77321 100644--- a/apps/www/lib/contribute.types.ts+++ b/apps/www/lib/contribute.types.ts@@ -62,6 +62,33 @@ export type Database = {}Relationships: []}+ contribute_similar_thread_feedback: {+ Row: {+ id: string+ parent_thread_id: string+ similar_thread_key: string | null+ reaction: string+ feedback: string | null+ created_at: string+ }+ Insert: {+ id?: string+ parent_thread_id: string+ similar_thread_key?: string | null+ reaction: string+ feedback?: string | null+ created_at?: string+ }+ Update: {+ id?: string+ parent_thread_id?: string+ similar_thread_key?: string | null+ reaction?: string+ feedback?: string | null+ created_at?: string+ }+ Relationships: []+ }contribute_threads: {Row: {author: string@@ -92,6 +119,8 @@ export type Database = {title: stringtopic: string | nulltopic_embedding: string | null+ similar_solved_threads: Json | null+ ai_suggested_reply: string | nulltopic_id: string | nullupdated_at: string | null}diff --git a/apps/www/lib/supabaseContribute.server.ts b/apps/www/lib/supabaseContribute.server.tsnew file mode 100644index 00000000000..88585453f79--- /dev/null+++ b/apps/www/lib/supabaseContribute.server.ts@@ -0,0 +1,26 @@+import { createServerClient } from '@supabase/ssr'+import { cookies } from 'next/headers'++export async function createContributeServerClient() {+ const cookieStore = await cookies()+ return createServerClient(+ process.env.NEXT_PUBLIC_SUPABASE_CONTRIBUTE_URL!,+ process.env.NEXT_PUBLIC_SUPABASE_CONTRIBUTE_PUBLISHABLE_KEY!,+ {+ cookies: {+ getAll() {+ return cookieStore.getAll()+ },+ setAll(cookiesToSet) {+ try {+ cookiesToSet.forEach(({ name, value, options }) =>+ cookieStore.set(name, value, options)+ )+ } catch {+ // Can be ignored in Server Actions per Supabase docs+ }+ },+ },+ }+ )+}diff --git a/apps/www/package.json b/apps/www/package.jsonindex 6df69f53cf0..701953dad51 100644--- a/apps/www/package.json+++ b/apps/www/package.json@@ -34,6 +34,7 @@"@octokit/rest": "^21.0.0","@radix-ui/react-dialog": "^1.0.5","@sentry/nextjs": "catalog:",+ "@supabase/ssr": "^0.9.0","@supabase/supabase-js": "catalog:","@vercel/og": "^0.6.2","ai-commands": "workspace:*",diff --git a/apps/www/types/contribute.ts b/apps/www/types/contribute.tsindex 576ced0f3a3..d347f6b13a6 100644--- a/apps/www/types/contribute.ts+++ b/apps/www/types/contribute.ts@@ -4,12 +4,34 @@ export type Thread = Tables<'contribute_threads'>export type ThreadSource = 'discord' | 'reddit' | 'github'+export interface SimilarSolvedThread {+ subject: string+ summary: string+ root_cause: string+ similarity: number+ thread_key: string+ user_action: string+ anti_pattern: string+ match_reason: string+ problem_type: string+ product_areas: string[]+ stack: string[]+ solution_type: string+ match_keywords: string[]+ solution_steps: string[]+ error_signature: string | null+ proposed_solution: string+ problem_description: string+ external_activity_url: string+}+export interface ThreadRow {id: stringtitle: stringconversation: stringuser: stringchannel: ThreadSource+ channelDisplayName: stringtags: string[]product_areas: string[]stack: string[]@@ -21,6 +43,7 @@ export interface ThreadRow {summary: string | nullthread_key: string | nullmessage_count: number | null+ similar_solved_threads: SimilarSolvedThread[] | null}export type LeaderboardPeriod = 'all' | 'year' | 'quarter' | 'month' | 'week' | 'today'@@ -29,3 +52,17 @@ export type LeaderboardRow = {author: string | null // sometimes author can be nullreply_count: number // bigint comes back as number via supabase-js}++export type SimilarThreadFeedbackReaction = 'positive' | 'negative'++export interface SimilarThreadFeedbackSubmission {+ parentThreadId: string // the thread being viewed (e.g. "860-6_dm")+ similarThreadKey?: string | null // optional for section-level feedback+ reaction: SimilarThreadFeedbackReaction // positive = thumbs-up, negative = thumbs-down+ feedback?: string | null // optional freeform text from dialog+}++export interface SimilarThreadFeedbackResult {+ success: boolean+ id?: string // returned from insert for subsequent update+}diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex a3b275f3579..ecf699a56cf 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -1604,6 +1604,9 @@ importers:'@sentry/nextjs':specifier: 'catalog:'version: 10.27.0(@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))(@opentelemetry/[email protected](@opentelemetry/[email protected]))([email protected])([email protected](@babel/[email protected]([email protected]))(@opentelemetry/[email protected])(@playwright/[email protected])([email protected]([email protected]))([email protected])([email protected]))([email protected])([email protected])([email protected])+ '@supabase/ssr':+ specifier: ^0.9.0+ version: 0.9.0(@supabase/[email protected])'@supabase/supabase-js':specifier: 'catalog:'version: 2.98.1-canary.0@@ -8237,6 +8240,11 @@ packages:peerDependencies:'@supabase/supabase-js': ^2.43.4+ '@supabase/[email protected]':+ resolution: {integrity: sha512-UFY6otYV3yqCgV+AyHj80vNkTvbf1Gas2LW4dpbQ4ap6p6v3eB2oaDfcI99jsuJzwVBCFU4BJI+oDYyhNk1z0Q==}+ peerDependencies:+ '@supabase/supabase-js': ^2.97.0+'@supabase/[email protected]':resolution: {integrity: sha512-cYEFR5jnZlDtkNe4GHStfnXwc62o81o8BOwJNSJK+Dn+3edY4ddz9HpNYx/y1JLZsgFuAnoJb7SFMnDiEVpvSA==}engines: {node: '>=20.0.0'}@@ -25552,6 +25560,11 @@ snapshots:'@supabase/supabase-js': 2.98.1-canary.0cookie: 1.0.2+ '@supabase/[email protected](@supabase/[email protected])':+ dependencies:+ '@supabase/supabase-js': 2.98.1-canary.0+ cookie: 1.0.2+'@supabase/[email protected]':dependencies:iceberg-js: 0.8.1