mirror of https://github.com/kortix-ai/suna.git
lil faster
This commit is contained in:
parent
958df5496f
commit
0a97b43beb
|
@ -7,7 +7,7 @@ import { Button } from '@/components/ui/button';
|
|||
import {
|
||||
ArrowDown, CircleDashed, Info, File, ChevronRight, Play, Pause
|
||||
} from 'lucide-react';
|
||||
import { getMessages, getProject, getThread, Project, Message as BaseApiMessageType } from '@/lib/api';
|
||||
import { getMessages, getProject, getThread, Project, Message as BaseApiMessageType, getAgentRuns } from '@/lib/api';
|
||||
import { toast } from 'sonner';
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { FileViewerModal } from '@/components/thread/file-viewer-modal';
|
||||
|
@ -600,11 +600,20 @@ export default function ThreadPage({ params }: { params: Promise<ThreadParams> }
|
|||
try {
|
||||
if (!threadId) throw new Error('Thread ID is required');
|
||||
|
||||
// Fetch the thread to check if it's public
|
||||
const threadData = await getThread(threadId).catch(err => {
|
||||
// If it fails with 404, we'll catch it here
|
||||
// Start loading all data in parallel
|
||||
const [threadData, agentRuns, messagesData] = await Promise.all([
|
||||
getThread(threadId).catch(err => {
|
||||
throw new Error('Failed to load thread data: ' + err.message);
|
||||
});
|
||||
}),
|
||||
getAgentRuns(threadId).catch(err => {
|
||||
console.warn('Failed to load agent runs:', err);
|
||||
return [];
|
||||
}),
|
||||
getMessages(threadId).catch(err => {
|
||||
console.warn('Failed to load messages:', err);
|
||||
return [];
|
||||
})
|
||||
]);
|
||||
|
||||
if (!isMounted) return;
|
||||
|
||||
|
@ -613,10 +622,15 @@ export default function ThreadPage({ params }: { params: Promise<ThreadParams> }
|
|||
// throw new Error('This thread is not available for public viewing.');
|
||||
// }
|
||||
|
||||
if (threadData?.project_id) {
|
||||
try {
|
||||
const projectData = await getProject(threadData.project_id);
|
||||
if (isMounted && projectData) {
|
||||
// Load project data if we have a project ID
|
||||
const projectData = threadData?.project_id ?
|
||||
await getProject(threadData.project_id).catch(err => {
|
||||
console.warn('[SHARE] Could not load project data:', err);
|
||||
return null;
|
||||
}) : null;
|
||||
|
||||
if (isMounted) {
|
||||
if (projectData) {
|
||||
console.log('[SHARE] Project data loaded:', projectData);
|
||||
|
||||
// Set project data
|
||||
|
@ -630,20 +644,20 @@ export default function ThreadPage({ params }: { params: Promise<ThreadParams> }
|
|||
}
|
||||
|
||||
setProjectName(projectData.name || '');
|
||||
}
|
||||
} catch (projectError) {
|
||||
// Don't throw an error if project can't be loaded
|
||||
// Just log it and continue with the thread
|
||||
console.warn('[SHARE] Could not load project data:', projectError);
|
||||
} else {
|
||||
// Set a generic name if we couldn't load the project
|
||||
setProjectName('Shared Conversation');
|
||||
}
|
||||
|
||||
// Set agent run ID if available
|
||||
if (agentRuns && agentRuns.length > 0) {
|
||||
const latestRun = agentRuns[0];
|
||||
if (latestRun.status === 'running') {
|
||||
setAgentRunId(latestRun.id);
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch all messages for the thread
|
||||
const messagesData = await getMessages(threadId);
|
||||
if (isMounted) {
|
||||
// Log raw messages fetched from API
|
||||
// Process messages data
|
||||
console.log('[SHARE] Raw messages fetched:', messagesData);
|
||||
|
||||
// Map API message type to UnifiedMessage type
|
||||
|
|
|
@ -139,6 +139,8 @@ export const getProject = async (projectId: string): Promise<Project> => {
|
|||
|
||||
// If project has a sandbox, ensure it's started
|
||||
if (data.sandbox?.id) {
|
||||
// Fire off sandbox activation without blocking
|
||||
const ensureSandboxActive = async () => {
|
||||
try {
|
||||
const { data: { session } } = await supabase.auth.getSession();
|
||||
|
||||
|
@ -165,8 +167,11 @@ export const getProject = async (projectId: string): Promise<Project> => {
|
|||
}
|
||||
} catch (sandboxError) {
|
||||
console.warn('Failed to ensure sandbox is active:', sandboxError);
|
||||
// Non-blocking error - continue with the project data
|
||||
}
|
||||
};
|
||||
|
||||
// Start the sandbox activation without awaiting
|
||||
ensureSandboxActive();
|
||||
}
|
||||
|
||||
// Map database fields to our Project type
|
||||
|
|
Loading…
Reference in New Issue