Graduate Supabase integration from experiments (#29)
This commit is contained in:
@@ -1,64 +0,0 @@
|
|||||||
import { useState, useEffect } from "react";
|
|
||||||
import { Switch } from "@/components/ui/switch";
|
|
||||||
import { useSettings } from "@/hooks/useSettings";
|
|
||||||
import { showSuccess, showError } from "@/lib/toast";
|
|
||||||
|
|
||||||
interface SupabaseIntegrationSwitchProps {
|
|
||||||
showToast?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function SupabaseIntegrationSwitch({
|
|
||||||
showToast = true,
|
|
||||||
}: SupabaseIntegrationSwitchProps) {
|
|
||||||
const { settings, updateSettings, refreshSettings } = useSettings();
|
|
||||||
const [isEnabled, setIsEnabled] = useState(false);
|
|
||||||
const [isUpdating, setIsUpdating] = useState(false);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (settings) {
|
|
||||||
setIsEnabled(settings.experiments?.enableSupabaseIntegration || false);
|
|
||||||
}
|
|
||||||
}, [settings]);
|
|
||||||
|
|
||||||
const handleToggle = async () => {
|
|
||||||
try {
|
|
||||||
setIsUpdating(true);
|
|
||||||
const newValue = !isEnabled;
|
|
||||||
|
|
||||||
await updateSettings({
|
|
||||||
experiments: {
|
|
||||||
enableSupabaseIntegration: newValue,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
setIsEnabled(newValue);
|
|
||||||
if (showToast) {
|
|
||||||
showSuccess(
|
|
||||||
`Supabase integration ${newValue ? "enabled" : "disabled"}`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
refreshSettings();
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Error toggling Supabase integration:", error);
|
|
||||||
if (showToast) {
|
|
||||||
showError("Failed to update Supabase integration setting");
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
setIsUpdating(false);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="flex items-center justify-between">
|
|
||||||
<label className="text-sm font-medium text-gray-700 dark:text-gray-300">
|
|
||||||
Enable Supabase Integration
|
|
||||||
</label>
|
|
||||||
<Switch
|
|
||||||
checked={isEnabled}
|
|
||||||
onCheckedChange={handleToggle}
|
|
||||||
disabled={isUpdating}
|
|
||||||
className="data-[state=checked]:bg-blue-600"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -154,7 +154,6 @@ export function registerChatStreamHandlers() {
|
|||||||
content: message.content,
|
content: message.content,
|
||||||
}));
|
}));
|
||||||
let systemPrompt = SYSTEM_PROMPT;
|
let systemPrompt = SYSTEM_PROMPT;
|
||||||
if (readSettings().experiments?.enableSupabaseIntegration) {
|
|
||||||
if (updatedChat.app?.supabaseProjectId) {
|
if (updatedChat.app?.supabaseProjectId) {
|
||||||
systemPrompt +=
|
systemPrompt +=
|
||||||
"\n\n" +
|
"\n\n" +
|
||||||
@@ -166,7 +165,7 @@ export function registerChatStreamHandlers() {
|
|||||||
} else {
|
} else {
|
||||||
systemPrompt += "\n\n" + SUPABASE_NOT_AVAILABLE_SYSTEM_PROMPT;
|
systemPrompt += "\n\n" + SUPABASE_NOT_AVAILABLE_SYSTEM_PROMPT;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
const { textStream } = streamText({
|
const { textStream } = streamText({
|
||||||
maxTokens: 8_000,
|
maxTokens: 8_000,
|
||||||
temperature: 0,
|
temperature: 0,
|
||||||
|
|||||||
@@ -90,7 +90,8 @@ export const SupabaseSchema = z.object({
|
|||||||
export type Supabase = z.infer<typeof SupabaseSchema>;
|
export type Supabase = z.infer<typeof SupabaseSchema>;
|
||||||
|
|
||||||
export const ExperimentsSchema = z.object({
|
export const ExperimentsSchema = z.object({
|
||||||
enableSupabaseIntegration: z.boolean().optional(),
|
// Deprecated
|
||||||
|
enableSupabaseIntegration: z.boolean().describe("DEPRECATED").optional(),
|
||||||
});
|
});
|
||||||
export type Experiments = z.infer<typeof ExperimentsSchema>;
|
export type Experiments = z.infer<typeof ExperimentsSchema>;
|
||||||
|
|
||||||
|
|||||||
@@ -16,9 +16,7 @@ const DEFAULT_SETTINGS: UserSettings = {
|
|||||||
telemetryConsent: "unset",
|
telemetryConsent: "unset",
|
||||||
telemetryUserId: uuidv4(),
|
telemetryUserId: uuidv4(),
|
||||||
hasRunBefore: false,
|
hasRunBefore: false,
|
||||||
experiments: {
|
experiments: {},
|
||||||
enableSupabaseIntegration: false,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const SETTINGS_FILE = "user-settings.json";
|
const SETTINGS_FILE = "user-settings.json";
|
||||||
|
|||||||
@@ -249,9 +249,7 @@ export default function AppDetailsPage() {
|
|||||||
<MessageCircle className="h-4 w-4" />
|
<MessageCircle className="h-4 w-4" />
|
||||||
</Button>
|
</Button>
|
||||||
<GitHubConnector appId={appId} folderName={selectedApp.path} />
|
<GitHubConnector appId={appId} folderName={selectedApp.path} />
|
||||||
{appId && settings?.experiments?.enableSupabaseIntegration && (
|
{appId && <SupabaseConnector appId={appId} />}
|
||||||
<SupabaseConnector appId={appId} />
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Rename Dialog */}
|
{/* Rename Dialog */}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import { IpcClient } from "@/ipc/ipc_client";
|
|||||||
import { showSuccess, showError } from "@/lib/toast";
|
import { showSuccess, showError } from "@/lib/toast";
|
||||||
import { AutoApproveSwitch } from "@/components/AutoApproveSwitch";
|
import { AutoApproveSwitch } from "@/components/AutoApproveSwitch";
|
||||||
import { TelemetrySwitch } from "@/components/TelemetrySwitch";
|
import { TelemetrySwitch } from "@/components/TelemetrySwitch";
|
||||||
import { SupabaseIntegrationSwitch } from "@/components/SupabaseIntegrationSwitch";
|
|
||||||
import { useSettings } from "@/hooks/useSettings";
|
import { useSettings } from "@/hooks/useSettings";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { ArrowLeft } from "lucide-react";
|
import { ArrowLeft } from "lucide-react";
|
||||||
@@ -152,13 +151,7 @@ export default function SettingsPage() {
|
|||||||
Experiments
|
Experiments
|
||||||
</h2>
|
</h2>
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<div className="space-y-2">
|
There are no experiments currently available.
|
||||||
<SupabaseIntegrationSwitch />
|
|
||||||
<div className="text-sm text-gray-500 dark:text-gray-400">
|
|
||||||
Enable integration with Supabase for auth, database and server
|
|
||||||
function support.
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user