fix(app): handle nullable detail consumers
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import type { FunctionReturnType } from 'convex/server';
|
||||
import { NextResponse } from 'next/server';
|
||||
import { proxyWorker } from '@/lib/agent-worker-proxy';
|
||||
import { convexAuthNextjsToken } from '@convex-dev/auth/nextjs/server';
|
||||
@@ -35,7 +36,14 @@ export const POST = async (
|
||||
{ status: 400 },
|
||||
);
|
||||
}
|
||||
const details = await fetchQuery(api.threads.get, { threadId }, { token });
|
||||
const details = (await fetchQuery(
|
||||
api.threads.get,
|
||||
{ threadId },
|
||||
{ token },
|
||||
)) as FunctionReturnType<typeof api.threads.get> | null;
|
||||
if (details === null) {
|
||||
return NextResponse.json({ error: 'Thread not found.' }, { status: 404 });
|
||||
}
|
||||
const latestJob = details.latestJob;
|
||||
const canSendToWorker =
|
||||
latestJob &&
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import type { FunctionReturnType } from 'convex/server';
|
||||
import type { CSSProperties, PointerEvent as ReactPointerEvent } from 'react';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { useMutation, useQuery } from 'convex/react';
|
||||
@@ -59,7 +60,10 @@ type PendingOverwrite = {
|
||||
};
|
||||
|
||||
export const AgentWorkspaceShell = ({ jobId }: { jobId: Id<'agentJobs'> }) => {
|
||||
const job = useQuery(api.agentJobs.get, { jobId });
|
||||
const job = useQuery(api.agentJobs.get, { jobId }) as
|
||||
| FunctionReturnType<typeof api.agentJobs.get>
|
||||
| null
|
||||
| undefined;
|
||||
const messages =
|
||||
useQuery(api.agentJobs.listMessages, { jobId, limit: 200 }) ?? [];
|
||||
const events =
|
||||
@@ -323,6 +327,14 @@ export const AgentWorkspaceShell = ({ jobId }: { jobId: Id<'agentJobs'> }) => {
|
||||
);
|
||||
}
|
||||
|
||||
if (job === null) {
|
||||
return (
|
||||
<main className='text-muted-foreground p-6'>
|
||||
This workspace was not found.
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
const activeFile = activeFilePath ? files[activeFilePath] : undefined;
|
||||
const recoverWorkspace = async () => {
|
||||
if (!job.threadId) return;
|
||||
|
||||
Reference in New Issue
Block a user