feat(documents): verbatim capture, chat prompt builder, budget, persistence documentId threading

This commit is contained in:
Marc-André Bombeck committed 2026-07-09 02:37:38 +02:00
1 parent d4d04c75f4
commit f5e4dc2b94
7 files changed
+232 -3

No files matched your search

+5 -1
View File
@@ -33,7 +33,11 @@ export const GET = apiHandler(async (_request: NextRequest, ctx: RouteCtx) => {
const { id } = await ctx.params;
if (!id) return apiError("coach.conversation.notFound", 404);
const detail = await fetchConversationWithMessages(auth.user.id, id);
// v1.27.33 — Coach detail is scoped to health threads (documentId null); a
// document chat is read through its own document-scoped route, not here.
const detail = await fetchConversationWithMessages(auth.user.id, id, {
documentId: null,
});
if (!detail) {
return apiError("coach.conversation.notFound", 404);
}
+6
View File
@@ -304,9 +304,12 @@ async function handleChatRequest(request: NextRequest): Promise<Response> {
let priorSummary: string | null = null;
if (conversationId) {
// v1.27.33 — scope to Coach threads (documentId null); a document chat can
// never be loaded through the Coach route.
const existing = await fetchConversationWithMessages(
userId,
conversationId,
{ documentId: null },
);
if (!existing) {
// 404, not 403 — never reveal cross-user existence
@@ -1434,6 +1437,9 @@ export const GET = apiHandler(async (request: NextRequest) => {
userId: auth.user.id,
cursor,
limit: Number.isFinite(limit) ? (limit as number) : undefined,
// v1.27.33 — the Coach rail shows only health threads; document chats
// (documentId set) live on the document sheet and are filtered out here.
documentId: null,
});
annotate({