mirror of
https://github.com/supabase/supabase.git
synced 2026-06-29 03:50:30 -04:00
033daf223c
Re-adds support form Assistant response using a lighter weight Streamdown component vs the more heavy `Message` component. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * AI Assistant follow-up card after ticket submission for project-scoped requests. * In-chat support request preview panels showing submitted subject and message. * **Improvements** * Smarter project selection when opening the support form via route/context. * Success screen: cleaner layout, project-name messaging, optional finish action, and a "Join Discord" button. * Category prompt text updated to "What issue are you having?" * New success/feedback section for consistent layouts. * **Tests** * Added tests covering support prompt serialization/parsing and UI previews. <!-- review_stack_entry_start --> [](https://app.coderabbit.ai/change-stack/supabase/supabase/pull/46248?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) <!-- review_stack_entry_end --> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
69 lines
2.3 KiB
TypeScript
69 lines
2.3 KiB
TypeScript
import { SupportCategories } from '@supabase/shared-types/out/constants'
|
|
import { describe, expect, it } from 'vitest'
|
|
|
|
import { buildSupportAssistantPrompt, parseSupportAssistantPrompt } from './SupportAssistant.utils'
|
|
import type { SubmittedSupportRequest } from './SupportForm.state'
|
|
|
|
const supportRequest: SubmittedSupportRequest = {
|
|
organizationSlug: 'org-1',
|
|
projectRef: 'project-1',
|
|
category: SupportCategories.PROBLEM,
|
|
severity: 'Normal',
|
|
subject: 'API requests fail',
|
|
message: 'Requests fail with <500> & timeouts',
|
|
affectedServices: 'api;database',
|
|
library: 'javascript',
|
|
allowSupportAccess: true,
|
|
dashboardLogs: 'https://example.com/logs',
|
|
}
|
|
|
|
describe('SupportAssistant utils', () => {
|
|
it('formats support requests as tagged assistant prompts', () => {
|
|
const prompt = buildSupportAssistantPrompt(supportRequest)
|
|
|
|
expect(prompt).toContain('<support>')
|
|
expect(prompt).toContain('<assistant_context>')
|
|
expect(prompt).toContain('a human member of the Supabase Support team is already looking at it')
|
|
expect(prompt).toContain('<subject>API requests fail</subject>')
|
|
expect(prompt).not.toContain('<organization_slug>')
|
|
expect(prompt).not.toContain('<project_ref>')
|
|
})
|
|
|
|
it('parses and unescapes tagged assistant prompts', () => {
|
|
const parsed = parseSupportAssistantPrompt(buildSupportAssistantPrompt(supportRequest))
|
|
|
|
expect(parsed).toMatchObject({
|
|
category: 'Problem',
|
|
severity: 'Normal',
|
|
subject: 'API requests fail',
|
|
message: 'Requests fail with <500> & timeouts',
|
|
support_access: 'Granted',
|
|
dashboard_logs: 'Attached',
|
|
})
|
|
})
|
|
|
|
it('falls back when optional support request fields are missing', () => {
|
|
const parsed = parseSupportAssistantPrompt(
|
|
buildSupportAssistantPrompt({
|
|
...supportRequest,
|
|
organizationSlug: undefined,
|
|
projectRef: undefined,
|
|
library: undefined,
|
|
dashboardLogs: undefined,
|
|
allowSupportAccess: false,
|
|
})
|
|
)
|
|
|
|
expect(parsed).toMatchObject({
|
|
library: 'Not provided',
|
|
support_access: 'Not granted',
|
|
dashboard_logs: 'Not attached',
|
|
})
|
|
})
|
|
|
|
it('returns null for text without a valid support payload', () => {
|
|
expect(parseSupportAssistantPrompt('Help me debug this issue')).toBeNull()
|
|
expect(parseSupportAssistantPrompt('<support></support>')).toBeNull()
|
|
})
|
|
})
|