mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-18 08:02:12 +00:00
Run document summaries and filing suggestions in the background
The summary and suggest routes accept `Prefer: respond-async`: after the same quick refusals they answer 202 with a run id, and the background document AI worker runs the read under two new run kinds (DOCUMENT_SUMMARY, DOCUMENT_SUGGEST, migration 0370). Without the header both routes answer synchronously as before; both paths run one shared body, so they cannot drift. The worker asks the capability for the record and re-checks the wire for the provider it picks before every read. A summary that is to be stored marks the document PENDING while queued, READY when it lands, and UNAVAILABLE when the run fails or the write does not land. A second request attaches to a live run only when it would produce the same thing. The vault asks for both in the background and shows the same calm waiting line the index uses, worded so a transient read never promises that leaving the page keeps it. The egress guard and the route inventory now hold every run kind to its dispatcher re-check and its capability.
This commit is contained in:
1 parent
7cd323499e
commit
eda5776886
24 files changed
+2061
-800
No files matched your search
@@ -254,3 +254,35 @@ describe("<DocumentAiSection> index outcome (#776)", () => {
|
||||
expect(html).not.toContain('data-slot="document-index-outcome"');
|
||||
});
|
||||
});
|
||||
|
||||
describe("<DocumentAiSection> background reads (v1.40)", () => {
|
||||
it("a running suggestion or summary says it reads in the background without promising it is kept", () => {
|
||||
const html = render(base({ assistRunPhase: "background" }));
|
||||
expect(html).toContain('data-slot="document-assist-run-phase"');
|
||||
expect(html).toContain("With a slow model this can take a few minutes.");
|
||||
expect(html).not.toContain("You can leave this page");
|
||||
});
|
||||
|
||||
it("a read whose result lands on the document says the person may leave", () => {
|
||||
const html = render(
|
||||
base({
|
||||
indexRunPhase: "background",
|
||||
assistRunPhase: "background",
|
||||
}),
|
||||
);
|
||||
expect(html).toContain('data-slot="document-index-run-phase"');
|
||||
expect(html).toContain("You can leave this page");
|
||||
// One line at a time, never two stacked notes.
|
||||
expect(html).not.toContain('data-slot="document-assist-run-phase"');
|
||||
});
|
||||
|
||||
it("says when no worker has picked the read up yet", () => {
|
||||
const html = render(base({ assistRunPhase: "waitingForWorker" }));
|
||||
expect(html).toContain("Waiting for the background worker.");
|
||||
});
|
||||
|
||||
it("renders no note while nothing runs", () => {
|
||||
const html = render(base());
|
||||
expect(html).not.toContain("run-phase");
|
||||
});
|
||||
});
|
||||
@@ -163,3 +163,15 @@ describe("DocumentSummaryBlock — the action", () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("DocumentSummaryBlock — a background read (v1.40)", () => {
|
||||
it("says the read runs in the background and is stored with the document", () => {
|
||||
const html = base({ isGenerating: true, runPhase: "background" });
|
||||
expect(html).toContain('data-slot="document-detail-summary-run-phase"');
|
||||
expect(html).toContain("You can leave this page");
|
||||
});
|
||||
|
||||
it("renders no note while nothing runs", () => {
|
||||
expect(base()).not.toContain("run-phase");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user