mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-17 15:42:24 +00:00
fix(documents): say when an extraction stopped short instead of blaming the copy
The document review now names the two outcomes the extraction can report since it reads a long document in parts. A read that stopped at the provider's output limit before a single fact closed shows its own sentence (try a model that allows longer answers) rather than the generic "Couldn't read the document". A run that staged facts but had a part cut or not reached opens the review as before and adds a warning that some values may be missing, so the list is checked against the document. Both strings are in every locale bundle. Refs #1257
This commit is contained in:
1 parent
5a7bd95c7b
commit
5a8f59e0c0
12 files changed
+47
-7
No files matched your search
@@ -40,4 +40,10 @@ describe("documentAiErrorKey", () => {
|
||||
"documents.assist.errorGeneric",
|
||||
);
|
||||
});
|
||||
|
||||
it("says the output limit stopped the read, not that the copy was unreadable", () => {
|
||||
expect(
|
||||
documentAiErrorKey(refusal("documents.inbound.outputLimit", 422)),
|
||||
).toBe("documents.assist.errorOutputLimit");
|
||||
});
|
||||
});
|
||||
@@ -40,6 +40,7 @@ import { Label } from "@/components/ui/label";
|
||||
import { MarkerMatchField } from "@/components/labs/marker-match-field";
|
||||
import type { BiomarkerListResponse } from "@/components/labs/types";
|
||||
import { apiGet } from "@/lib/api/api-fetch";
|
||||
import type { DocumentExtractRunResult } from "@/lib/documents/ai-runs/types";
|
||||
import { useTranslations } from "@/lib/i18n/context";
|
||||
import { queryKeys } from "@/lib/query-keys";
|
||||
import { cn } from "@/lib/utils";
|
||||
@@ -473,6 +474,25 @@ function FactRow({
|
||||
* or nothing. Owner-only: staging and confirming write to the caller's own
|
||||
* record, so a delegate never sees these controls.
|
||||
*/
|
||||
/**
|
||||
* What the person is told when a stored extract finishes. The staged facts
|
||||
* arrive with the document refetch the hook starts; the review opens onto
|
||||
* them. A long document read in parts may have had a part cut at the
|
||||
* provider's output limit or not reached, and then the review is not the
|
||||
* whole document.
|
||||
*/
|
||||
function announceExtract(
|
||||
result: DocumentExtractRunResult,
|
||||
t: (key: string) => string,
|
||||
openReview: () => void,
|
||||
): void {
|
||||
if (result.factsStaged > 0) openReview();
|
||||
else toast.info(t("documents.review.extractEmpty"));
|
||||
if (result.incomplete) {
|
||||
toast.warning(t("documents.review.extractIncomplete"));
|
||||
}
|
||||
}
|
||||
|
||||
export function DocumentFactsSection({
|
||||
doc,
|
||||
canManage,
|
||||
@@ -680,13 +700,7 @@ export function DocumentFactsSection({
|
||||
onSuccess: (result) => {
|
||||
setFailures({});
|
||||
setIncluded({});
|
||||
// The staged facts arrive with the document refetch the
|
||||
// hook starts; the review opens onto them.
|
||||
if (result.factsStaged > 0) {
|
||||
setOpen(true);
|
||||
} else {
|
||||
toast.info(t("documents.review.extractEmpty"));
|
||||
}
|
||||
announceExtract(result, t, () => setOpen(true));
|
||||
},
|
||||
onError: (error) =>
|
||||
showErrorToast(aiErrorText(error), { cause: error }),
|
||||
|
||||
@@ -222,6 +222,8 @@ export function documentAiErrorKey(err: unknown): string {
|
||||
return "documents.assist.errorProvider";
|
||||
case "documents.inbound.notIndexed":
|
||||
return "documents.assist.errorNotIndexed";
|
||||
case "documents.inbound.outputLimit":
|
||||
return "documents.assist.errorOutputLimit";
|
||||
case "aiRuns.workerUnavailable":
|
||||
return "aiRuns.errorWorkerUnavailable";
|
||||
case "aiRuns.timedOut":
|
||||
|
||||
Reference in new issue
Block a user