mirror of https://github.com/kortix-ai/suna.git
cleanup
This commit is contained in:
parent
0c4b1345c6
commit
e636ac20fe
|
@ -1,18 +1,11 @@
|
|||
from fastapi import APIRouter, Depends, HTTPException
|
||||
from fastapi import APIRouter
|
||||
from utils.logger import logger
|
||||
from flags.flags import list_flags, is_enabled, get_flag_details
|
||||
from utils.auth_utils import get_current_user_id_from_jwt
|
||||
|
||||
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
|
||||
@router.get("/feature-flags")
|
||||
async def get_feature_flags(user_id: str = Depends(get_current_user_id_from_jwt)):
|
||||
if not user_id:
|
||||
raise HTTPException(status_code=401, detail="Unauthorized")
|
||||
async def get_feature_flags():
|
||||
try:
|
||||
flags = await list_flags()
|
||||
return {"flags": flags}
|
||||
|
@ -20,12 +13,8 @@ async def get_feature_flags(user_id: str = Depends(get_current_user_id_from_jwt)
|
|||
logger.error(f"Error fetching feature flags: {str(e)}")
|
||||
return {"flags": {}}
|
||||
|
||||
|
||||
|
||||
@router.get("/feature-flags/{flag_name}")
|
||||
async def get_feature_flag(flag_name: str, user_id: str = Depends(get_current_user_id_from_jwt)):
|
||||
if not user_id:
|
||||
raise HTTPException(status_code=401, detail="Unauthorized")
|
||||
async def get_feature_flag(flag_name: str):
|
||||
try:
|
||||
enabled = await is_enabled(flag_name)
|
||||
details = await get_flag_details(flag_name)
|
||||
|
|
|
@ -16,6 +16,7 @@ import { Pagination } from './_components/pagination';
|
|||
import { useRouter } from 'next/navigation';
|
||||
import { DEFAULT_AGENTPRESS_TOOLS } from './_data/tools';
|
||||
import { AgentsParams } from '@/hooks/react-query/agents/utils';
|
||||
import { useFeatureFlags } from '@/lib/feature-flags';
|
||||
|
||||
type ViewMode = 'grid' | 'list';
|
||||
type SortOption = 'name' | 'created_at' | 'updated_at' | 'tools_count';
|
||||
|
@ -34,6 +35,7 @@ export default function AgentsPage() {
|
|||
const [editingAgentId, setEditingAgentId] = useState<string | null>(null);
|
||||
const [viewMode, setViewMode] = useState<ViewMode>('grid');
|
||||
|
||||
|
||||
// Server-side parameters
|
||||
const [page, setPage] = useState(1);
|
||||
const [searchQuery, setSearchQuery] = useState('');
|
||||
|
|
|
@ -33,7 +33,7 @@ import { useThreadQuery } from '@/hooks/react-query/threads/use-threads';
|
|||
|
||||
const PENDING_PROMPT_KEY = 'pendingAgentPrompt';
|
||||
|
||||
export function DashboardContent({ customAgentsEnabled }: { customAgentsEnabled: boolean }) {
|
||||
export function DashboardContent() {
|
||||
const [inputValue, setInputValue] = useState('');
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
const [autoSubmit, setAutoSubmit] = useState(false);
|
||||
|
@ -198,7 +198,6 @@ export function DashboardContent({ customAgentsEnabled }: { customAgentsEnabled:
|
|||
selectedAgentId={selectedAgentId}
|
||||
onAgentSelect={setSelectedAgentId}
|
||||
variant="heading"
|
||||
customAgentsEnabled={customAgentsEnabled}
|
||||
/>
|
||||
</div>
|
||||
<p className="tracking-tight text-3xl font-normal text-muted-foreground/80 mt-2">
|
||||
|
|
|
@ -5,7 +5,6 @@ import { Skeleton } from "@/components/ui/skeleton";
|
|||
import { isFlagEnabled } from "@/lib/feature-flags";
|
||||
|
||||
export default async function DashboardPage() {
|
||||
const customAgentsEnabled = await isFlagEnabled('custom_agents');
|
||||
return (
|
||||
<Suspense
|
||||
fallback={
|
||||
|
@ -26,7 +25,7 @@ export default async function DashboardPage() {
|
|||
</div>
|
||||
}
|
||||
>
|
||||
<DashboardContent customAgentsEnabled={customAgentsEnabled} />
|
||||
<DashboardContent />
|
||||
</Suspense>
|
||||
);
|
||||
}
|
|
@ -15,13 +15,13 @@ import { useAgents } from '@/hooks/react-query/agents/use-agents';
|
|||
import { useRouter } from 'next/navigation';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { CreateAgentDialog } from '@/app/(dashboard)/agents/_components/create-agent-dialog';
|
||||
import { useFeatureFlags } from '@/lib/feature-flags';
|
||||
|
||||
interface AgentSelectorProps {
|
||||
onAgentSelect?: (agentId: string | undefined) => void;
|
||||
selectedAgentId?: string;
|
||||
className?: string;
|
||||
variant?: 'default' | 'heading';
|
||||
customAgentsEnabled?: boolean;
|
||||
}
|
||||
|
||||
export function AgentSelector({
|
||||
|
@ -29,13 +29,16 @@ export function AgentSelector({
|
|||
selectedAgentId,
|
||||
className,
|
||||
variant = 'default',
|
||||
customAgentsEnabled = true
|
||||
}: AgentSelectorProps) {
|
||||
const { data: agentsResponse, isLoading, refetch: loadAgents } = useAgents({
|
||||
limit: 100,
|
||||
sort_by: 'name',
|
||||
sort_order: 'asc'
|
||||
});
|
||||
|
||||
|
||||
const { flags, loading: flagsLoading } = useFeatureFlags(['custom_agents']);
|
||||
const customAgentsEnabled = flags.custom_agents;
|
||||
|
||||
const router = useRouter();
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
|
@ -81,25 +84,6 @@ export function AgentSelector({
|
|||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={cn("flex items-center gap-2", className)}>
|
||||
<div className="flex items-center gap-2 px-3 py-2 rounded-lg border bg-background">
|
||||
<User className="h-4 w-4 text-muted-foreground" />
|
||||
<div className="flex flex-col items-start">
|
||||
<div className="flex items-center gap-1">
|
||||
<span className="text-sm font-medium">Suna</span>
|
||||
<Badge variant="outline" className="text-xs px-1 py-0">
|
||||
Default
|
||||
</Badge>
|
||||
</div>
|
||||
<span className="text-xs text-muted-foreground">
|
||||
Your personal AI employee
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (isLoading) {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import React from 'react';
|
||||
import { createClient } from './supabase/client';
|
||||
|
||||
const API_URL = process.env.NEXT_PUBLIC_BACKEND_URL || '';
|
||||
|
||||
|
@ -39,13 +38,10 @@ export class FeatureFlagManager {
|
|||
if (cached && Date.now() - cached.timestamp < CACHE_DURATION) {
|
||||
return cached.value;
|
||||
}
|
||||
const supabase = createClient();
|
||||
const { data: { session }} = await supabase.auth.getSession();
|
||||
const response = await fetch(`${API_URL}/feature-flags/${flagName}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Bearer ${session?.access_token}`,
|
||||
},
|
||||
});
|
||||
if (!response.ok) {
|
||||
|
@ -68,15 +64,11 @@ export class FeatureFlagManager {
|
|||
}
|
||||
|
||||
async getFlagDetails(flagName: string): Promise<FeatureFlag | null> {
|
||||
const supabase = createClient();
|
||||
const { data: { session }} = await supabase.auth.getSession();
|
||||
|
||||
try {
|
||||
const response = await fetch(`${API_URL}/feature-flags/${flagName}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Bearer ${session?.access_token}`,
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -94,9 +86,6 @@ export class FeatureFlagManager {
|
|||
}
|
||||
|
||||
async getAllFlags(): Promise<Record<string, boolean>> {
|
||||
const supabase = createClient();
|
||||
const { data: { session }} = await supabase.auth.getSession();
|
||||
|
||||
try {
|
||||
if (globalFlagsCache && Date.now() - globalFlagsCache.timestamp < CACHE_DURATION) {
|
||||
return globalFlagsCache.flags;
|
||||
|
@ -106,7 +95,6 @@ export class FeatureFlagManager {
|
|||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer ${session.access_token}`,
|
||||
},
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue