mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 17:35:10 +03:00
Assistant chats from High Compliance projects now flow to Braintrust like any other project. The constraint that required suppressing them no longer applies, see AI-1241 for the details. `isTracingAllowed` now takes only the project region to maintain EU exclusion. Traces also carry an `isHighComplianceProject` metadata field, so the project's status at the time of the trace is recorded rather than looked up later against a setting customers can toggle. To verify, see [this sample trace](https://www.braintrust.dev/app/supabase.io/p/Assistant/logs?r=afabbdcc-aa89-446e-aa52-78aaa90d44a4&v=Production&s=afabbdcc-aa89-446e-aa52-78aaa90d44a4&tvt=trace) from a High Compliance project on staging which indicates that tracing is now enabled for these projects and that it carries metadata showing the high compliance status. | High Compliance project setting | `isHighComplianceProject` metadata | |--------|--------| | <img width="1554" height="454" alt="CleanShot 2026-09-22 at 5 14 58 PM@2x" src="https://github.com/user-attachments/assets/23901c6e-0d79-44e8-a6dd-43cdedba1799" /> | <img width="1674" height="990" alt="CleanShot 2026-09-22 at 5 17 40 PM@2x" src="https://github.com/user-attachments/assets/fb2fba55-bcc1-4136-a432-b33a5c7f9ca2" /> | Closes AI-1241 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Changes** * AI project compliance information is now represented by a unified high-compliance project status. * AI response tracing is now determined by project region: tracing remains disabled for EU and unknown regions, while known non-EU regions are eligible. * AI feedback and SQL generation now use the updated compliance and regional handling. * **Tests** * Updated coverage to reflect the revised compliance and tracing behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
77 lines
1.7 KiB
TypeScript
77 lines
1.7 KiB
TypeScript
import { expect, test, vi } from 'vitest'
|
|
|
|
// End of third-party imports
|
|
|
|
import rate from '../../pages/api/ai/feedback/rate'
|
|
import { sanitizeMessagePart } from '../ai/tools/tool-sanitizer'
|
|
|
|
vi.mock('../ai/tools/tool-sanitizer', () => ({
|
|
sanitizeMessagePart: vi.fn((part) => part),
|
|
}))
|
|
|
|
vi.mock('@/lib/ai/ai-details', () => ({
|
|
getAIDetails: vi.fn().mockResolvedValue({
|
|
aiOptInLevel: 'schema_and_log_and_data',
|
|
hasAccessToAdvanceModel: true,
|
|
region: 'us-east-1',
|
|
}),
|
|
}))
|
|
|
|
vi.mock('@/lib/ai/model', () => ({
|
|
getModel: vi.fn().mockResolvedValue({
|
|
modelParams: { model: {} },
|
|
}),
|
|
}))
|
|
|
|
vi.mock('ai', () => ({
|
|
generateText: vi.fn().mockResolvedValue({
|
|
output: {
|
|
category: 'sql_generation',
|
|
},
|
|
}),
|
|
Output: { object: vi.fn() },
|
|
}))
|
|
|
|
vi.mock('@/components/ui/AIAssistantPanel/Message.utils', () => ({
|
|
rateMessageResponseSchema: {},
|
|
}))
|
|
|
|
test('rate calls the tool sanitizer', async () => {
|
|
const mockReq = {
|
|
method: 'POST',
|
|
headers: {
|
|
authorization: 'Bearer test-token',
|
|
},
|
|
body: {
|
|
rating: 'negative',
|
|
messages: [
|
|
{
|
|
role: 'assistant',
|
|
parts: [
|
|
{
|
|
type: 'tool-execute_sql',
|
|
state: 'output-available',
|
|
output: 'test output',
|
|
},
|
|
],
|
|
},
|
|
],
|
|
messageId: 'test-message-id',
|
|
projectRef: 'test-project',
|
|
orgSlug: 'test-org',
|
|
reason: 'The response was not helpful',
|
|
},
|
|
on: vi.fn(),
|
|
}
|
|
|
|
const mockRes = {
|
|
status: vi.fn(() => mockRes),
|
|
json: vi.fn(() => mockRes),
|
|
setHeader: vi.fn(() => mockRes),
|
|
}
|
|
|
|
await rate(mockReq as any, mockRes as any)
|
|
|
|
expect(sanitizeMessagePart).toHaveBeenCalled()
|
|
})
|