mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-16 23:33:29 +00:00
Tell the four document-summary outcomes apart
Opening a document said "the summary is being prepared" and kept saying it. The view had one fallback for a null summary column and used it for every outcome: a document nobody ever enqueued, a missing vision provider, a spent budget, a withdrawn consent, an unreadable file, a provider error, and a summary the outbound screen withheld all rendered as work in progress. The common case is not the screen. The background job is enqueued at exactly one place — a fresh upload with the auto-read opt-in already on — and no backfill reaches anything else. Every document uploaded before the toggle went on has a null column no job will ever fill, and the view promised all of them a summary that was never coming. Record the outcome as `summary_state` (migration 0254, additive, defaults to NONE which is truthful for every existing row) and branch on it. Only PENDING, set when a job genuinely exists, may claim generation is running. NONE, WITHHELD and UNAVAILABLE each say what happened and offer to generate one. The withhold keeps its rule and loses its dead end. Blocked prose is still never shown and never stored — only the fact of the refusal is kept, and it is no longer terminal, so asking again re-runs the gauntlet. That was the original intent; leaving the column null defeated it, because null read as "generating" and the guard meant nothing would ever overwrite it. The on-demand summary now persists what it produces. It is the only repair path for the documents the job never ran for, and re-deriving the same paragraph on every open costs a provider call for nothing. Generation is still only ever a click — nothing runs because a view rendered. Transcription stays session-only. Also drop the "read by AI" line from the detail footer.
This commit is contained in:
1 parent
e6e2210314
commit
d773f460e5
19 files changed
+713
-82
No files matched your search
@@ -98,6 +98,22 @@ export function toContentIndexSource(
|
||||
: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* What became of a document's plain-language summary. Mirrors the Prisma
|
||||
* `DocumentSummaryState` enum. The detail view branches on this rather than on
|
||||
* a null summary, which cannot tell "never attempted" from "in flight" from
|
||||
* "withheld" from "could not produce".
|
||||
*/
|
||||
export const DOCUMENT_SUMMARY_STATES = [
|
||||
"NONE",
|
||||
"PENDING",
|
||||
"READY",
|
||||
"WITHHELD",
|
||||
"UNAVAILABLE",
|
||||
] as const;
|
||||
export type DocumentSummaryStateValue =
|
||||
(typeof DOCUMENT_SUMMARY_STATES)[number];
|
||||
|
||||
/** The document lifecycle states. STORED is the library default. */
|
||||
export const INBOUND_DOCUMENT_STATUSES = [
|
||||
"STORED",
|
||||
@@ -301,6 +317,13 @@ export interface InboundDocumentDetailDto extends InboundDocumentDto {
|
||||
summary: string | null;
|
||||
/** When the background summary was generated (ISO 8601), or null. */
|
||||
summaryGeneratedAt: string | null;
|
||||
/**
|
||||
* What became of the summary. A null `summary` is ambiguous on its own —
|
||||
* never attempted, mid-flight, withheld by the safety screen and could-not-
|
||||
* produce all look identical — so the view reads this instead of guessing
|
||||
* "still generating".
|
||||
*/
|
||||
summaryState: DocumentSummaryStateValue;
|
||||
}
|
||||
|
||||
// ─── Edit (correction before approval) ─────────────────────────────────────
|
||||
|
||||
Reference in new issue
Block a user