From 9905687f69392bb6a06ef944524f556a662780bd Mon Sep 17 00:00:00 2001 From: sickerine Date: Sat, 5 Dec 2026 23:42:15 +0000 Subject: [PATCH 1/3] feat(reports): choose where the DOI leads on the DOI step, and say what that asks of the author Both first-use walkers learned only at the address field, after signing and uploading, that the official page must show the DOI. Where the DOI leads is now chosen under the reserved DOI, before the byline (kept on the report until its details are read, then theirs: reports/flow:chooseLanding), and comes right after The work in the details and corrections. Under the place picked, a box says what to do and why: the report's page needs nothing; a place past it asks for the DOI on that page as text near the title, with the DOI to copy, why readers and Crossref need it there, and that Openscholar doesn't check the page. Without an official page yet, the step says the report's page can stay and the place can change later. The series' settings tell the admin what a place past the report's page asks of authors. Part of OpenDevEd/openscholar#1746 --- components/reports/details-step.tsx | 14 ++++--- components/reports/doi-landing.tsx | 59 +++++++++++++++++++++++++++-- components/reports/publish-flow.tsx | 35 ++++++++++++++++- convex/reports/flow.test.ts | 25 ++++++++++++ convex/reports/flow.ts | 25 +++++++++++- convex/reports/readingState.ts | 3 +- convex/reports/validators.ts | 2 + messages/en-GB.json | 13 +++++++ messages/en-US.json | 13 +++++++ scripts/user-actions-exempt.json | 1 + 10 files changed, 176 insertions(+), 14 deletions(-) diff --git a/components/reports/details-step.tsx b/components/reports/details-step.tsx index efcf7af22..19256ad6d 100644 --- a/components/reports/details-step.tsx +++ b/components/reports/details-step.tsx @@ -763,6 +763,14 @@ export function DetailsStep({ ) : null} + {/* Where the DOI leads, right after what the work is, so a change of place is found + first and not under every other detail. */} + {landing && offersLanding(landing, m.landing) ? ( +
+ set("landing", next)} /> +
+ ) : null} +
{m.authors.length}}>
    @@ -1059,12 +1067,6 @@ export function DetailsStep({ void toast.error(words)} />
- {landing && offersLanding(landing, m.landing) ? ( -
- set("landing", next)} /> -
- ) : null} -
{wrongLinks ? {t("wrongLink")} : null} {m.relations.length ? ( diff --git a/components/reports/doi-landing.tsx b/components/reports/doi-landing.tsx index e3cb4259d..ddd850911 100644 --- a/components/reports/doi-landing.tsx +++ b/components/reports/doi-landing.tsx @@ -19,7 +19,7 @@ import { Input } from "@/components/ui/input"; import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"; import { Switch } from "@/components/ui/switch"; import { StatusChip } from "@/components/evidence-libraries/configuration/status-chip"; -import { ArrowRight, ArrowUpRight, FileText, Globe, Hash, Hourglass, Lock } from "@/components/icons"; +import { ArrowRight, ArrowUpRight, Check, CircleCheck, Copy, FileText, Globe, Hash, Hourglass, Info, Lock } from "@/components/icons"; import { FieldLabel } from "@/components/reports/field-help"; import { LogoMark } from "@/components/logo"; import { LIST, LOCKED_LOOK, Locked, Shut, Zone } from "@/components/settings/parts"; @@ -92,6 +92,8 @@ export function LandingSettings({ landings, crossrefOn }: { landings: Landings; })}
  • {allowed.length > 1 ? t("pickNote") : t(needsUrl(allowed[0]!) ? "fixedUrlNote" : "fixedNote", { to: t(`to_${allowed[0]!}`) })} + {/* What a place past the report's page asks of its authors, said to the admin who allows it. */} + {landings.notice || landings.official ? ` ${t("adminWhy")}` : null}
  • @@ -229,9 +231,58 @@ export function LandingSection({ value, options, onChange, id, invalid }: { valu ) : null} - - {host ?

    {t("mustShow", { host, doi: options.doi })}

    : null} -
    + {/* The place picked leads into what the author has to do about it, and why. */} + + + ); +} + +/** + * Under the place picked, what its author has to do and why. Its page: nothing. A place + * past it: put the DOI on the official page, which readers from the DOI reach; with the DOI to copy once it is + * reserved, or word that it comes when they sign. + */ +function WhatToDo({ place, host, doi }: { place: LandingPlace; /** The official page's host, once its address is right. */ host: string | null; /** The report's DOI; empty before it is reserved. */ doi: string }) { + const t = useTranslations("publishReports.lead"); + const [copied, setCopied] = useState(false); + if (place === "page") { + return ( +

    + + {t("todoPage")} +

    + ); + } + return ( +
    +

    + + {host ? t("todoTitle", { host }) : t("todoTitleNoHost")} +

    +
    + {doi ? ( + <> +

    {t("todoDoi")}

    +

    + {`https://doi.org/${doi}`} + +

    + + ) : ( +

    {t("todoDoiLater")}

    + )} +

    {t(place === "notice" ? "todoWhy_notice" : "todoWhy_official", { seconds: NOTICE_SECONDS })}

    +

    {t("todoUnchecked")}

    +
    ); } diff --git a/components/reports/publish-flow.tsx b/components/reports/publish-flow.tsx index d5e66cc74..a041e3938 100644 --- a/components/reports/publish-flow.tsx +++ b/components/reports/publish-flow.tsx @@ -36,6 +36,7 @@ import { PaperCover } from "@/components/papers/paper-cover"; import { DetailsStep } from "@/components/reports/details-step"; import { NewPdf } from "@/components/reports/new-pdf"; import { FieldHelp, RegistrarsProvider, type HelpKey } from "@/components/reports/field-help"; +import { LandingSection, offersLanding } from "@/components/reports/doi-landing"; import { RegistrationChips } from "@/components/reports/registration"; import { SHOWS, STATUS, StatusFilter, YourReports, stageShown, useStageChip } from "@/components/reports/your-reports"; import { Problem, useProblem } from "@/components/reports/problem"; @@ -929,7 +930,7 @@ function Screens({ form, beside, preparing, onPrepared, onUnprepare, into, onInt // Until the run is there, a moment after Submit, the list is what the same rule says a run of it would run. ({ id: check.id, name: check.name, result: report.run?.results.find((result) => result.checkId === check.id) }))} report={null} humanReview={basics.humanReview} /> ) : report.step === "doi" ? ( - (toTop(), onMoved("upload"))} /> + (toTop(), onMoved("upload"))} /> ) : report.step === "upload" ? ( onMoved("details")} onBack={() => onStep("doi")} onNext={report.pdf?.pages !== undefined && report.metadata ? () => onStep("details") : undefined} /> ) : report.step === "details" && report.metadata && report.pdf ? ( @@ -1643,7 +1644,7 @@ function AgreementStep({ basics: ours, starts: here, workspaceId: pageWorkspace, * The DOI, and nothing else: its mark, then the DOI itself set large and arriving letter by letter, with one sweep of * light across it. Plays only right after signing; opened any other way it is already settled. */ -function DoiStep({ report, fresh, onNext }: { report: Report; fresh: boolean; onNext: () => void }) { +function DoiStep({ report, fresh, onNext, landings }: { report: Report; fresh: boolean; onNext: () => void; /** The places the report's series allows its DOI to lead. */ landings: Basics["landing"] }) { // A report signed where no byline is asked for has no line to make and no choice of who adds it. const { bylineOff } = report; // The choice made here, or the one a PDF already attached was uploaded with. @@ -1651,6 +1652,26 @@ function DoiStep({ report, fresh, onNext }: { report: Report; fresh: boolean; on const by = chosen ?? report.pdf?.bylineBy ?? null; const reduce = useReducedMotion(); const t = useTranslations("publishReports.flow"); + // Where the DOI leads, picked here where the DOI is first shown: kept as it is picked, a moment after the last change, + // as the report's until its details are read, then as theirs (convex/reports/flow.ts `chooseLanding`). + const tLead = useTranslations("publishReports.lead"); + const chooseLanding = useMutation(api.reports.flow.chooseLanding); + const [landing, setLanding] = useState(report.metadata?.landing ?? report.landing); + const keeping = useRef<{ timer: ReturnType; send: () => void } | null>(null); + const keepNow = () => { + if (!keeping.current) return; + clearTimeout(keeping.current.timer); + keeping.current.send(); + keeping.current = null; + }; + const pickLanding = (next: NonNullable) => { + setLanding(next); + if (keeping.current) clearTimeout(keeping.current.timer); + const send = () => { + if (workspaceId) void chooseLanding({ workspaceId, key: report.key, landing: next }).catch((error: unknown) => void toast.error(getErrorMessage(error, t("saveFailed")))); + }; + keeping.current = { send, timer: setTimeout(() => ((keeping.current = null), send()), 400) }; + }; // Next, pressed with the line's choice not made, says so at the choice and goes there. const choice = useId(); const { tried, go } = useStepForm(); @@ -1682,6 +1703,8 @@ function DoiStep({ report, fresh, onNext }: { report: Report; fresh: boolean; on const editor = useId(); const [nudged, setNudged] = useState(0); const next = () => { + // A place picked a moment ago is kept before the step moves on. + keepNow(); if (edit !== "none" && editing) setNudged((n) => n + 1); go([!printed && minting, edit !== "none" && editing && editor, !bylineOff && !by && bylineField(choice)], onNext); }; @@ -1815,6 +1838,14 @@ function DoiStep({ report, fresh, onNext }: { report: Report; fresh: boolean; on + {/* Where the DOI leads, chosen where the DOI is first shown, so the box under the place picked can give it to copy. + Without an address yet the report's page can stay, and the place changes later. */} + {offersLanding({ landings, crossref: report.registration.crossref, doi: report.doi }, landing) ? ( + + {tLead(landings.page ? "doiStepIntro" : "doiStepIntroNeeded")} + + + ) : null} {/* What the DOI is for, said where the author first meets it: the line their PDF needs, before they make it. Laid out as the upload's page is, which comes next. */} {bylineOff ? ( diff --git a/convex/reports/flow.test.ts b/convex/reports/flow.test.ts index e66028783..122e7b727 100644 --- a/convex/reports/flow.test.ts +++ b/convex/reports/flow.test.ts @@ -721,3 +721,28 @@ describe("a workspace's list of reports", () => { await expect(world.t.query(internal.reports.flow.pageForAssistant, { userId: world.strangerId, workspaceId: world.lab, page: 1 })).rejects.toThrow(); }); }); + +describe("where the DOI leads, picked on the DOI step", () => { + it("goes into the details once the PDF is read, follows the details after, and can't change once the checks start", async () => { + vi.stubEnv("NEXT_PUBLIC_APP_URL", "https://openscholar.test"); + onTestFinished(() => void vi.unstubAllEnvs()); + const world = await setup(); + const { author, own } = world; + const key = await sign(author, own); + const official = { place: "official" as const, url: "https://www.example.org/reports/shade-trees" }; + await author.mutation(api.reports.flow.chooseLanding, { workspaceId: own, key, landing: official }); + expect((await read(author, own, key)).landing).toEqual(official); + // Read from the PDF, the details take it: the reading itself knows nothing of it. + const file = await uploaded(world, { by: author, bytes: 17 }); + await author.mutation(api.reports.flow.attachPdf, { workspaceId: own, key, file, name: "report.pdf" }); + const { _id: reportId, pdf } = await row(world.t, key); + await world.t.mutation(internal.reports.readingState.finish, { reportId, at: pdf!.at, pages: 12, metadata: details() }); + expect((await read(author, own, key)).metadata?.landing).toEqual(official); + // Back on the DOI step, a new pick changes the details too. + const page = { place: "page" as const, url: official.url }; + await author.mutation(api.reports.flow.chooseLanding, { workspaceId: own, key, landing: page }); + expect((await read(author, own, key)).metadata?.landing).toEqual(page); + await author.mutation(internal.reports.checkRuns.start, { workspaceId: own, key, metadata: details(), runId: "run-1", from: { pdfAt: pdf!.at } }); + await expect(author.mutation(api.reports.flow.chooseLanding, { workspaceId: own, key, landing: official })).rejects.toMatchObject(refused("CONFLICT")); + }); +}); diff --git a/convex/reports/flow.ts b/convex/reports/flow.ts index 0fd169b82..9ab25ec09 100644 --- a/convex/reports/flow.ts +++ b/convex/reports/flow.ts @@ -34,7 +34,7 @@ import { formVersion } from "./corrections"; import { notify } from "./mail"; import { register } from "./registering"; import { accountsFor, checkNames, checksOf, humanReviewOf, limitsOf, reportSettings, reviewedIn, seriesFor, seriesReader, settingsRow, type ReportSettings } from "./settings"; -import { ELSEWHERE_WORKSPACES, doiEditValidator, authorRowValidator, checkNamesValidator, bylineByValidator, bylineTroubleValidator, fileAccessValidator, licenceValidator, metadataValidator, optionalPlainResults, pdfTroubleValidator, plainResults, referenceLookupValidator, reportRowsValidator, signedAgreementValidator, stageValidator, waitingWorkspacesValidator, payWithValidator, serviceIdValidator, voucherValidator } from "./validators"; +import { ELSEWHERE_WORKSPACES, landingValidator, doiEditValidator, authorRowValidator, checkNamesValidator, bylineByValidator, bylineTroubleValidator, fileAccessValidator, licenceValidator, metadataValidator, optionalPlainResults, pdfTroubleValidator, plainResults, referenceLookupValidator, reportRowsValidator, signedAgreementValidator, stageValidator, waitingWorkspacesValidator, payWithValidator, serviceIdValidator, voucherValidator } from "./validators"; /** What an upload is told while its report's numbered DOI is still being reserved: the line its PDF carries names it. */ const DOI_WAITS = "This report's DOI is still being reserved. Upload its PDF once it shows."; @@ -542,6 +542,26 @@ export const saveDetails = workspaceMutation({ }, }); +/** + * Where a report's DOI leads, picked on its DOI step: its details' own once they are read (./readingState.ts), and + * until then the report's. Checked like the rest of its details when its checks run (`requireLanding`): an address is + * kept as it is typed here. + */ +export const chooseLanding = workspaceMutation({ + args: { key: v.string(), landing: landingValidator }, + returns: v.null(), + handler: async (ctx, actor, { key, landing }) => { + await refuseApps(ctx); + const report = await changing(ctx, actor, key); + if (report.step === "done" || report.run) throw createError("CONFLICT", "This report's checks have started: change where its DOI leads in its details."); + if (landing.url.length > DETAIL_TEXT.link) throw createError("VALIDATION_ERROR", `Keep the official page's address to ${DETAIL_TEXT.link} characters.`); + const details = await detailsOf(ctx, report._id); + if (details.metadata) await ctx.db.patch("reportDetails", details._id, { metadata: { ...details.metadata, landing } }); + await touch(ctx, report, { landing }); + return null; + }, +}); + /** Gives up a report that never went live and no reviewer approved: it, its PDF and its reserved DOI are gone. The * day's start it used stays used. */ export const discard = workspaceMutation({ @@ -965,6 +985,8 @@ const reportValidator = v.object({ doi: v.string(), /** The DOI it was reserved, where its author chose another (./ownDoi.ts). */ reservedDoi: v.optional(v.string()), + /** Where its DOI leads, picked on its DOI step: its details' once they are read. */ + landing: v.optional(landingValidator), /** What its author may change of its DOI now (`doiEditOf`). */ doiEdit: doiEditValidator, /** Its author can go back to the DOI it was reserved (`doiBackOf`). */ @@ -1046,6 +1068,7 @@ export const getAction = defineUserQuery({ ...(await row(ctx, actor, report, settings, seriesReader(ctx, (await reportSettings(ctx)).series))), doi: report.doi, ...(report.reservedDoi && { reservedDoi: report.reservedDoi }), + ...(report.landing && { landing: report.landing }), doiEdit: mayChange(actor, report) ? doiEditOf(report, settings.series.doiEdit) : "none", doiBack: mayChange(actor, report) && doiBackOf(report), doiTaken: !!report.doiTaken && report.doiTaken === report.doi, diff --git a/convex/reports/readingState.ts b/convex/reports/readingState.ts index 970f11f0a..954d9864a 100644 --- a/convex/reports/readingState.ts +++ b/convex/reports/readingState.ts @@ -112,7 +112,8 @@ export const finish = internalMutation({ } if (text) await keepFor(ctx, reportId, text); const profile = (await ctx.db.get("users", report.ownerId))?.profile; - const kept = held ?? keptDetails(signerFilledIn(metadata!, report.signedBy.name, profile), licenceOf(report)); + // Where its DOI leads, if its author picked it on the DOI step, goes into the details made now. + const kept = held ?? keptDetails({ ...signerFilledIn(metadata!, report.signedBy.name, profile), ...(report.landing && { landing: report.landing }) }, licenceOf(report)); if (!held) { await ctx.db.patch("reportDetails", details._id, { metadata: kept }); await startLookup(ctx, details._id, reportId, kept.citations ?? [], titles ?? []); diff --git a/convex/reports/validators.ts b/convex/reports/validators.ts index dfe87fadc..6bab707a5 100644 --- a/convex/reports/validators.ts +++ b/convex/reports/validators.ts @@ -389,6 +389,8 @@ export const reportFields = { doiUnder: v.optional(v.string()), /** The DOI it was reserved, once its author chose another for it (reports/ownDoi.ts): theirs to go back to. */ reservedDoi: v.optional(v.string()), + /** Where its DOI leads, picked on its DOI step before its details are read: its details take it when they are made. */ + landing: v.optional(landingValidator), /** Its DOI, which doi.org said was registered elsewhere when asked before it went live (reports/ownDoi.ts): it can't go live with it. */ doiTaken: v.optional(v.string()), /** Why that reservation couldn't be made, until it is asked again: kept apart from `registrationError`, which DOCiD's minting clears. */ diff --git a/messages/en-GB.json b/messages/en-GB.json index a5b1c844a..16709b719 100644 --- a/messages/en-GB.json +++ b/messages/en-GB.json @@ -6274,6 +6274,19 @@ "url_missing": "Give the official page's address.", "url_invalid": "That isn't a web address. It starts with https://.", "leadsTo": "DOI leads to", + "doiStepIntro": "Where readers who follow this DOI end up. No official page yet? Keep the report's page for now. You can change it in the details, or after the report is live.", + "doiStepIntroNeeded": "Where readers who follow this DOI end up. No address yet? You can give it when you check the details, and change it after the report is live.", + "adminWhy": "Authors who pick a place past the report's page are asked to put the DOI on that page, and told why. Readers from the DOI find it there, as Crossref asks of every page a DOI leads to.", + "todoPage": "Readers who follow the DOI land on the report's page here, so that page is its official page. There's nothing to add anywhere else.", + "todoTitle": "Put the DOI on {host}", + "todoTitleNoHost": "Put the DOI on the official page", + "todoDoi": "Show this DOI on that page as text, near the report's title, before the report goes live.", + "todoDoiLater": "Your DOI is reserved when you sign and shown to you on the next step. Show it on that page as text, near the report's title, before the report goes live.", + "todoWhy_notice": "Readers who follow the DOI see the report's page here for {seconds} seconds, then move on to that page. Finding the DOI there tells them they reached the right report, and Crossref asks it of every page a DOI leads to.", + "todoWhy_official": "Readers who follow the DOI land straight on that page and never see Openscholar. Finding the DOI there tells them they reached the right report, and Crossref asks it of every page a DOI leads to.", + "todoUnchecked": "Openscholar doesn't check the page, as many sites turn automated visits away.", + "copyDoi": "Copy the DOI", + "copied": "Copied", "leadsToAfter": "{host} after {seconds} s", "url_long": "That address is too long. Keep it to 500 characters.", "url_gone": "This place isn't allowed for this report any more. Choose another.", diff --git a/messages/en-US.json b/messages/en-US.json index aa9e0e6dd..14d5eb778 100644 --- a/messages/en-US.json +++ b/messages/en-US.json @@ -6274,6 +6274,19 @@ "url_missing": "Give the official page's address.", "url_invalid": "That isn't a web address. It starts with https://.", "leadsTo": "DOI leads to", + "doiStepIntro": "Where readers who follow this DOI end up. No official page yet? Keep the report's page for now. You can change it in the details, or after the report is live.", + "doiStepIntroNeeded": "Where readers who follow this DOI end up. No address yet? You can give it when you check the details, and change it after the report is live.", + "adminWhy": "Authors who pick a place past the report's page are asked to put the DOI on that page, and told why. Readers from the DOI find it there, as Crossref asks of every page a DOI leads to.", + "todoPage": "Readers who follow the DOI land on the report's page here, so that page is its official page. There's nothing to add anywhere else.", + "todoTitle": "Put the DOI on {host}", + "todoTitleNoHost": "Put the DOI on the official page", + "todoDoi": "Show this DOI on that page as text, near the report's title, before the report goes live.", + "todoDoiLater": "Your DOI is reserved when you sign and shown to you on the next step. Show it on that page as text, near the report's title, before the report goes live.", + "todoWhy_notice": "Readers who follow the DOI see the report's page here for {seconds} seconds, then move on to that page. Finding the DOI there tells them they reached the right report, and Crossref asks it of every page a DOI leads to.", + "todoWhy_official": "Readers who follow the DOI land straight on that page and never see Openscholar. Finding the DOI there tells them they reached the right report, and Crossref asks it of every page a DOI leads to.", + "todoUnchecked": "Openscholar doesn't check the page, as many sites turn automated visits away.", + "copyDoi": "Copy the DOI", + "copied": "Copied", "leadsToAfter": "{host} after {seconds} s", "url_long": "That address is too long. Keep it to 500 characters.", "url_gone": "This place isn't allowed for this report any more. Choose another.", diff --git a/scripts/user-actions-exempt.json b/scripts/user-actions-exempt.json index 686fd745c..e67dc11fb 100644 --- a/scripts/user-actions-exempt.json +++ b/scripts/user-actions-exempt.json @@ -338,6 +338,7 @@ "reports/settings:workspace": "Site administration, for Openscholar's own admins on the admin pages.", "reports/flow:sign": "Publishing a report under a signed agreement, with its PDF and its checks: done on the Publish page, where the person reads what they sign and sees what goes public.", "reports/flow:saveDetails": "Publishing a report under a signed agreement, with its PDF and its checks: done on the Publish page, where the person reads what they sign and sees what goes public.", + "reports/flow:chooseLanding": "Publishing a report under a signed agreement, with its PDF and its checks: done on the Publish page, where the person reads what they sign and sees what goes public.", "reports/flow:discard": "Publishing a report under a signed agreement, with its PDF and its checks: done on the Publish page, where the person reads what they sign and sees what goes public.", "reports/flow:goTo": "Publishing a report under a signed agreement, with its PDF and its checks: done on the Publish page, where the person reads what they sign and sees what goes public.", "reports/flow:backToChecks": "Publishing a report under a signed agreement, with its PDF and its checks: done on the Publish page, where the person reads what they sign and sees what goes public.", From 936cf4216a37cf62f4f7985f032b7fcff5939e9c Mon Sep 17 00:00:00 2001 From: sickerine Date: Sat, 5 Dec 2026 23:50:31 +0000 Subject: [PATCH 2/3] fix(reports): a new place for the DOI sends a reopened report through its checks again Codex review: a ready report reopened at the DOI step could change where its DOI leads and go back to its earlier checks with Back to checks, skipping the address checks; the pick now clears reopened, as saving any other detail does. And once the details are read, none there is the report's page: the DOI step no longer falls back to the pick kept on the report before them. --- components/reports/publish-flow.tsx | 4 +++- convex/reports/flow.test.ts | 4 ++++ convex/reports/flow.ts | 4 +++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/components/reports/publish-flow.tsx b/components/reports/publish-flow.tsx index a041e3938..b0ec7fb02 100644 --- a/components/reports/publish-flow.tsx +++ b/components/reports/publish-flow.tsx @@ -1656,7 +1656,9 @@ function DoiStep({ report, fresh, onNext, landings }: { report: Report; fresh: b // as the report's until its details are read, then as theirs (convex/reports/flow.ts `chooseLanding`). const tLead = useTranslations("publishReports.lead"); const chooseLanding = useMutation(api.reports.flow.chooseLanding); - const [landing, setLanding] = useState(report.metadata?.landing ?? report.landing); + // Once the details are read they hold it, and none there is the report's page: the pick kept on the report is only + // for before then. + const [landing, setLanding] = useState(report.metadata ? report.metadata.landing : report.landing); const keeping = useRef<{ timer: ReturnType; send: () => void } | null>(null); const keepNow = () => { if (!keeping.current) return; diff --git a/convex/reports/flow.test.ts b/convex/reports/flow.test.ts index 122e7b727..83d08729a 100644 --- a/convex/reports/flow.test.ts +++ b/convex/reports/flow.test.ts @@ -742,6 +742,10 @@ describe("where the DOI leads, picked on the DOI step", () => { const page = { place: "page" as const, url: official.url }; await author.mutation(api.reports.flow.chooseLanding, { workspaceId: own, key, landing: page }); expect((await read(author, own, key)).metadata?.landing).toEqual(page); + // A pick made on a report reopened from its checks sends it through them again. + await world.t.run((ctx) => ctx.db.patch("reports", reportId, { reopened: true })); + await author.mutation(api.reports.flow.chooseLanding, { workspaceId: own, key, landing: official }); + expect(await row(world.t, key)).not.toHaveProperty("reopened"); await author.mutation(internal.reports.checkRuns.start, { workspaceId: own, key, metadata: details(), runId: "run-1", from: { pdfAt: pdf!.at } }); await expect(author.mutation(api.reports.flow.chooseLanding, { workspaceId: own, key, landing: official })).rejects.toMatchObject(refused("CONFLICT")); }); diff --git a/convex/reports/flow.ts b/convex/reports/flow.ts index 9ab25ec09..71fce00fc 100644 --- a/convex/reports/flow.ts +++ b/convex/reports/flow.ts @@ -557,7 +557,9 @@ export const chooseLanding = workspaceMutation({ if (landing.url.length > DETAIL_TEXT.link) throw createError("VALIDATION_ERROR", `Keep the official page's address to ${DETAIL_TEXT.link} characters.`); const details = await detailsOf(ctx, report._id); if (details.metadata) await ctx.db.patch("reportDetails", details._id, { metadata: { ...details.metadata, landing } }); - await touch(ctx, report, { landing }); + // Changed, its checks run again before it goes on, as a change to any other detail: one reopened from its checks + // can't go back to the results they gave before. + await touch(ctx, report, { landing, ...(details.metadata && { reopened: undefined }) }); return null; }, }); From 2e730249d91f661258015a5d45ed39d13cfe4706 Mon Sep 17 00:00:00 2001 From: sickerine Date: Sat, 5 Dec 2026 23:57:06 +0000 Subject: [PATCH 3/3] fix(reports): a DOI place picked just before the page closes is kept Cross-family review: a pick made in the last 400 ms before a reload or close was lost. It is sent as the page goes, as the details form sends its edits. --- components/reports/publish-flow.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/components/reports/publish-flow.tsx b/components/reports/publish-flow.tsx index b0ec7fb02..f03aaf937 100644 --- a/components/reports/publish-flow.tsx +++ b/components/reports/publish-flow.tsx @@ -1674,6 +1674,17 @@ function DoiStep({ report, fresh, onNext, landings }: { report: Report; fresh: b }; keeping.current = { send, timer: setTimeout(() => ((keeping.current = null), send()), 400) }; }; + // The page closing or reloading: a pick still waiting to be kept is sent first, as the details form does. + useEffect(() => { + const leave = () => { + if (!keeping.current) return; + clearTimeout(keeping.current.timer); + keeping.current.send(); + keeping.current = null; + }; + window.addEventListener("pagehide", leave); + return () => window.removeEventListener("pagehide", leave); + }, []); // Next, pressed with the line's choice not made, says so at the choice and goes there. const choice = useId(); const { tried, go } = useStepForm();