mirror of https://github.com/kortix-ai/suna.git
agents query
This commit is contained in:
parent
63f2d8e5ec
commit
653e98475d
|
@ -72,6 +72,12 @@ export function NavAgents() {
|
|||
const projects = await getProjects() as Project[]
|
||||
console.log("Projects loaded:", projects.length, projects.map(p => ({ id: p.id, name: p.name })));
|
||||
|
||||
// If no projects are found, the user might not be logged in
|
||||
if (projects.length === 0) {
|
||||
setThreads([])
|
||||
return
|
||||
}
|
||||
|
||||
// Create a map of projects by ID for faster lookups
|
||||
const projectsById = new Map<string, Project>();
|
||||
projects.forEach(project => {
|
||||
|
@ -113,6 +119,8 @@ export function NavAgents() {
|
|||
setThreads(sortThreads(threadsWithProjects))
|
||||
} catch (err) {
|
||||
console.error("Error loading threads with projects:", err)
|
||||
// Set empty threads array on error
|
||||
setThreads([])
|
||||
} finally {
|
||||
if (showLoading) {
|
||||
setIsLoading(false)
|
||||
|
|
|
@ -294,8 +294,25 @@ export const deleteProject = async (projectId: string): Promise<void> => {
|
|||
// Thread APIs
|
||||
export const getThreads = async (projectId?: string): Promise<Thread[]> => {
|
||||
const supabase = createClient();
|
||||
|
||||
// Get the current user's ID to filter threads
|
||||
const { data: userData, error: userError } = await supabase.auth.getUser();
|
||||
if (userError) {
|
||||
console.error('Error getting current user:', userError);
|
||||
return [];
|
||||
}
|
||||
|
||||
// If no user is logged in, return an empty array
|
||||
if (!userData.user) {
|
||||
console.log('[API] No user logged in, returning empty threads array');
|
||||
return [];
|
||||
}
|
||||
|
||||
let query = supabase.from('threads').select('*');
|
||||
|
||||
// Always filter by the current user's account ID
|
||||
query = query.eq('account_id', userData.user.id);
|
||||
|
||||
if (projectId) {
|
||||
console.log('[API] Filtering threads by project_id:', projectId);
|
||||
query = query.eq('project_id', projectId);
|
||||
|
|
|
@ -83,9 +83,9 @@ export const siteConfig = {
|
|||
buttonText: "Hire Suna",
|
||||
buttonColor: "bg-secondary text-white",
|
||||
isPopular: false,
|
||||
hours: "no free usage at this time",
|
||||
hours: "10 min",
|
||||
features: [
|
||||
"no free usage",
|
||||
"10 minutes",
|
||||
// "Community support",
|
||||
// "Single user",
|
||||
// "Standard response time",
|
||||
|
|
Loading…
Reference in New Issue