Files
Matt RossmanandJoshen Lim 4bb36b944f feat(studio): let High Compliance projects opt-in to Assistant data access (#50548)
Orgs with the HIPAA add-on had the Assistant's opt-in level forced to
`disabled` on any project marked High Compliance, regardless of what the
org picked in its AI settings. The restriction predated our AI provider
BAAs. The consequence is those users see the Assistant failing to answer
questions about their data w/ no clear path how to fix it, even though
the LLM provider supports this use case.

This PR removes these Assistant restrictions on the server and client so
those projects honor the org's chosen level. Braintrust conversation
tracing is unchanged and still blocked for these projects, see [this
test
case](https://github.com/supabase/supabase/blob/b9800ccf16/apps/studio/lib/ai/braintrust-logger.test.ts#L16-L20).
See
[comments](https://linear.app/supabase/issue/AI-1153/allow-hipaa-orgs-to-opt-in-to-assistant-data-access-for-high#comment-485a0d46)
for legal approval and conditions.

The client-side changes enable features like "Debug with AI" on SQL
query failures, “Generate/Rename with AI” for snippet titles, and
generated Assistant chat titles for these customers.

The AI opt-in copy now adds a reminder to obtain consent from data
subjects, linking the [shared responsibility
model](https://supabase.com/docs/guides/deployment/shared-responsibility-model)
based also on [this
comment](https://linear.app/supabase/issue/AI-1153/allow-hipaa-orgs-to-opt-in-to-assistant-data-access-for-high#comment-f81ee610).

<img width="400" alt="CleanShot 2026-09-17 at 5 01 02 PM@2x"
src="https://github.com/user-attachments/assets/d02123f2-3e32-4d83-9f98-7d15e59222ef"
/>

To test with a HIPAA-enabled project in staging, you can use this [Plan
Change
[Staging]](https://app.hex.tech/supabase/app/Plan-Change-Staging-032BD32jo1EaisCS85qunf/latest)
Hex to add the HIPAA add-on. Once the add-on is present, you can turn on
High Compliance from a project's settings. Also in org settings, crank
up the Assistant data opt-in level and verify the Assistant is able to
answer questions about the project's data.

My results testing with opt-in level "Schema, Logs & Database Data":

| High compliance setting | Data opt-in working |
|--------|--------|
| <img width="1302" height="422" alt="CleanShot 2026-09-17 at 5 03 36
PM@2x"
src="https://github.com/user-attachments/assets/c416371b-2eb8-49df-9c07-6d8eababb443"
/> | <img width="1566" height="1516" alt="CleanShot 2026-09-17 at 5 05
14 PM@2x"
src="https://github.com/user-attachments/assets/39624355-7f8f-46ce-9f08-a8acfb9da830"
/> |

Closes AI-1153


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

## New Features

- AI-assisted query renaming, snippet title generation, debugging, and
tools now follow organization AI opt-in settings rather than project
HIPAA status.
- Debugging assistance and AI actions remain available for eligible
users without additional HIPAA-based blocking.
- AI metadata warnings consistently show standard opt-in messaging and
permission settings.
- AI settings remind users to obtain consent before entering personal
data and link to shared responsibility guidance.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2026-09-18 08:21:50 -04:00

127 lines
4.8 KiB
TypeScript

import { PermissionAction } from '@supabase/shared-types/out/constants'
import { useParams } from 'common'
import { Loader2 } from 'lucide-react'
import { useEffect, useState } from 'react'
import { toast } from 'sonner'
import { Card, CardContent, Switch, Tooltip, TooltipContent, TooltipTrigger } from 'ui'
import {
PageSection,
PageSectionContent,
PageSectionDescription,
PageSectionMeta,
PageSectionSummary,
PageSectionTitle,
} from 'ui-patterns/PageSection'
import { AlertError } from '@/components/ui/AlertError'
import { DocsButton } from '@/components/ui/DocsButton'
import { InlineLink } from '@/components/ui/InlineLink'
import { useComplianceConfigUpdateMutation } from '@/data/config/project-compliance-config-mutation'
import { useProjectSettingsV2Query } from '@/data/config/project-settings-v2-query'
import { useAsyncCheckPermissions } from '@/hooks/misc/useCheckPermissions'
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
import { DOCS_URL } from '@/lib/constants'
export const ComplianceConfig = () => {
const { ref } = useParams()
const { data: project } = useSelectedProjectQuery()
const [isSensitive, setIsSensitive] = useState(false)
const { can: canUpdateComplianceConfig } = useAsyncCheckPermissions(
PermissionAction.UPDATE,
'projects',
{
resource: { project_id: project?.id },
}
)
const {
data: settings,
error,
isError,
isPending: isLoading,
isSuccess,
} = useProjectSettingsV2Query({ projectRef: ref })
const initialIsSensitive = settings?.is_sensitive || false
const { mutate: updateComplianceConfig, isPending: isSubmitting } =
useComplianceConfigUpdateMutation({
onSuccess: () => {
toast.success('Successfully updated project compliance configuration')
},
onError: (error) => {
setIsSensitive(initialIsSensitive)
toast.error(`Failed to update project compliance configuration: ${error.message}`)
},
})
const toggleIsSensitive = async () => {
if (!ref) return console.error('Project ref is required')
setIsSensitive(!isSensitive)
updateComplianceConfig({ projectRef: ref, isSensitive: !isSensitive })
}
useEffect(() => {
if (!isLoading) setIsSensitive(initialIsSensitive)
}, [isLoading])
return (
<PageSection id="compliance-configuration">
<PageSectionMeta>
<div className="w-full flex flex-col gap-3 @lg:flex-row @lg:items-center @lg:justify-between">
<PageSectionSummary>
<PageSectionTitle>High Compliance Configuration</PageSectionTitle>
<PageSectionDescription>
For projects storing and processing sensitive data (HIPAA).
</PageSectionDescription>
</PageSectionSummary>
<DocsButton href={`${DOCS_URL}/guides/platform/hipaa-projects`} />
</div>
</PageSectionMeta>
<PageSectionContent>
<Card>
<CardContent className="flex flex-col gap-4 @lg:flex-row @lg:items-center @lg:justify-between">
<div className="space-y-2 max-w-2xl">
<p className="text-sm">Apply additional compliance controls to project</p>
<p className="text-sm text-foreground-light">
Enable security warnings in the{' '}
<InlineLink href={`/project/${ref}/advisors/security`}>Security Advisor</InlineLink>{' '}
to enforce requirements for managing sensitive data.
</p>
</div>
<div className="flex items-center justify-end space-x-2">
{(isLoading || isSubmitting) && (
<Loader2 className="animate-spin" strokeWidth={1.5} size={16} />
)}
{isError && (
<AlertError error={error} subject="Failed to retrieve project settings" />
)}
{isSuccess && (
<Tooltip>
<TooltipTrigger asChild>
{/* [Joshen] Added div as tooltip is messing with data state property of toggle */}
<div>
<Switch
size="large"
checked={isSensitive}
disabled={isLoading || isSubmitting || !canUpdateComplianceConfig}
onCheckedChange={toggleIsSensitive}
/>
</div>
</TooltipTrigger>
{!canUpdateComplianceConfig && (
<TooltipContent side="bottom" className="w-64 text-center">
You need additional permissions to update the compliance configuration for
your project
</TooltipContent>
)}
</Tooltip>
)}
</div>
</CardContent>
</Card>
</PageSectionContent>
</PageSection>
)
}