Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
1590980
fix(screening): the audit reads the rule as the screening does, and o…
sickerine Nov 28, 2026
de35419
fix(screening): a held paper's votes stand as counted, answer edits c…
sickerine Nov 28, 2026
81ce2a8
perf(screening): Papers counts two narrowings from kept counts; fix(s…
sickerine Nov 28, 2026
7dcd637
perf(screening): the open screening is the same object until its data…
sickerine Nov 28, 2026
d345089
perf(screening): a save re-reads the papers only where it can move or…
sickerine Nov 28, 2026
bf972e9
fix(screening): what round 2's walkers found
sickerine Nov 28, 2026
594b7ee
fix(screening): a stated reason wins a tie, history exports leave mod…
sickerine Nov 28, 2026
7fd2dc9
fix(sharing): an accepted invitation shows what its guest may do now
sickerine Nov 28, 2026
178dca9
fix(screening): files too large for one email are said to be before S…
sickerine Nov 28, 2026
a7076e6
perf(screening): every reviewer pair fits one settling step, three-wa…
sickerine Nov 28, 2026
cc90a34
fix(screening): what the cross-family review of round 2 found
sickerine Nov 28, 2026
cbde344
fix(screening): what round 2's visual reviewers found in the figures
sickerine Nov 28, 2026
4d55a33
fix(screening): a step that hands its papers in parts moves the sourc…
sickerine Nov 28, 2026
2002dd7
test(screening): the 5,000-paper size cases have the time convex-test…
sickerine Nov 28, 2026
bb0e99e
fix(screening): a paper included while the workspace has no room for …
sickerine Nov 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions components/screening/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export { SOMEONE };
/** A reviewer's name where there is little room: a person's first name, and a model's whole name, since its first word alone only names its maker. */
export const shortName = (reviewer: { kind: "person" | "model"; name: string; email?: string }) => (reviewer.kind === "person" && !reviewer.email ? firstName(reviewer.name) : reviewer.name);
/** A name as part of a file's name or an address. */
export const slug = (name: string) => name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
export const slug = (name: string) => name.normalize("NFC").toLowerCase().replace(/[^\p{L}\p{M}\p{N}]+/gu, "-").replace(/^-|-$/g, "");
/** A number as people read it: "1,204". */
export const num = (n: number) => n.toLocaleString("en-GB");
/** A small number as a word at the start of a sentence: "Three of the 5 reviewers". */
Expand Down Expand Up @@ -188,7 +188,7 @@ export function removedOf(sources: Source[], kept = paperTotal(sources)) {
export type Rule = Omit<SharedRule, "each" | "models"> & { each: `${number}` | "all"; models: NonNullable<SharedRule["models"]> };
/** What each answer to a criterion is worth, yes, no and unclear, and the points each star starts at. Points only make stars: no vote follows from them. */
export type Scoring = { points: Record<string, [number, number, number]>; stars: number[] };
export type WriteProblem = "role" | "notFound" | "unreadable";
export type WriteProblem = "role" | "notFound" | "unreadable" | "full";
export type Destination = { kind: "none" | "new" | "collection" | "community"; name: string; collection?: string; prune: boolean; /** A community that refused or didn't answer the last write of included papers, adding them or taking them out, until one gets through. */ problem?: WriteProblem; pruneProblem?: WriteProblem; /** In a community: which one, and the collection of the person's there, or a new one of theirs to make (`collection: "new"`). */ community?: { libraryId: string; collection: string; private: boolean; requestId: string } };

/** Why a paper is excluded when no criterion is the reason: shown after the criteria in the list of reasons. */
Expand Down
3 changes: 3 additions & 0 deletions components/screening/export-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { showStyledToast } from "@/components/ui/sonner";
import { Spinner } from "@/components/ui/spinner";
import { api } from "@/convex/_generated/api";
import { useCursorPage } from "@/lib/hooks/use-cursor-page";
import { EMAILED_FILES_BYTES } from "@/lib/export";
import { getErrorMessage } from "@/lib/toast/use-app-toast";
import { inWorkspace, useWorkspace as usePageWorkspace, useWorkspaceAction } from "@/lib/workspaces/url";
import type { Id } from "@/convex/_generated/dataModel";
Expand Down Expand Up @@ -408,6 +409,8 @@ function SendFiles({ jobId, files }: { jobId: string; files: Array<{ format: str
setBusy(true);
try {
const made = await Promise.all(chosen.map((one) => one.make()));
// Files too large for one email together are said to be before they go: the server would refuse them, or the request never reach it.
if (new TextEncoder().encode(JSON.stringify(made)).length > EMAILED_FILES_BYTES) return void showStyledToast("error", t("send.tooLarge", { count: made.length }));
await sendFiles({ jobId: jobId as Id<"screeningJobs">, to: to.trim(), files: made, ...(note.trim() ? { note: note.trim() } : {}) });
toast(t("send.sent", { to: to.trim(), count: made.length }));
setOpen(false);
Expand Down
19 changes: 12 additions & 7 deletions components/screening/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// same rows, and what is hidden from someone on a page is hidden from them in every file.

import type { ConvexReactClient } from "convex/react";
import { hidesVotes, modelsAdvise } from "@/lib/screening/rules";
import { hidesVotes, modelsAdvise, OTHER_REASON } from "@/lib/screening/rules";
import { effortOf } from "@/components/settings/model-map";
import type { EFFORTS } from "@/lib/ai/core/call-options";
import { api } from "@/convex/_generated/api";
Expand Down Expand Up @@ -79,6 +79,9 @@ const filedOf = (sources: Screening["sources"]) => sources.reduce((sum, source)
/** A source's set as a file gives it: an upload's, a list's or a drop's handle opens nothing outside the app, so it is left out. */
/** Everyone the whole record lists as a reviewer: all who were on the screening, taken off or not; someone invited who never joined is counted apart. */
export const recordReviewers = (screening: Pick<Screening, "reviewers">) => screening.reviewers.filter((reviewer) => !reviewer.email);
/** Who sees a vote before casting their own, as the record says it of the rule now and of each version before. */
const HIDDEN_SEEN = "Hidden from a reviewer only while the paper waits for that reviewer's own vote, and from nobody once the screening is marked finished";
const ADVICE_SEEN = "People's votes are hidden from a reviewer only while the paper waits for that reviewer's own vote, and from nobody once the screening is marked finished. The AI models' votes are advice, and show to a reviewer before they vote";
const withoutFiles = (set: NonNullable<Screening["sources"][number]["set"]>) => {
const { file: _file, batch: _batch, ...rest } = set as typeof set & { file?: unknown; batch?: unknown };
return rest;
Expand Down Expand Up @@ -176,7 +179,8 @@ export function paperRows({ screening }: Pick<Taken, "screening">, papers: Paper
source: screening.sources.find((source) => source.id === paper.source)?.name ?? "",
added: paper.addedAt === undefined ? "At the start" : iso(paper.addedAt),
result: RESULT_LABEL[settled.result],
excluded_for: settled.result === "exclude" && paper.reason ? failedLabel(paper.reason, reasonCriteria(screening)) : "",
// Another reason carries what was written for it: the settler's words, else the voter's.
excluded_for: settled.result === "exclude" && paper.reason ? [failedLabel(paper.reason, reasonCriteria(screening)), ...(paper.reason === OTHER_REASON ? [settled.resolvedBy ? settled.note : paper.cast.find((one) => one.vote?.reason === OTHER_REASON && one.vote?.note)?.vote?.note].filter(Boolean).map((text) => `"${text}"`) : [])].join(", ") : "",
settled_by: settled.resolvedBy ? nameOn(screening, settled.resolvedBy) : "",
settled_note: settled.note ?? "",
votes_include: how("include"),
Expand Down Expand Up @@ -474,7 +478,8 @@ export function methodsOf(out: Taken) {
changed ? `The settings or the reviewers were changed ${changed === 1 ? "once" : `${changed} times`} after screening began${changedParts.length ? ` (${listed(changedParts)})` : ""}. The screening's exported record lists each change and what it did.` : "",
pair ? `Agreement between ${pairOn![0].name} and ${pairOn![1].name} over the ${pair.papers} records both assessed was ${Math.round(pair.same * 100)}% (${pair.kappa === null ? "Cohen's kappa could not be estimated, as both gave the same decision every time" : `Cohen's kappa ${pair.kappa.toFixed(2)}`}).` : "",
kappas.length > 1 ? `Across the ${kappas.length} pairs of reviewers with a value${modelPairs ? `, ${modelPairs} among them` : ""}, pairwise agreement (Cohen's kappa) ranged from ${kappas[0]!.toFixed(2)} to ${kappas.at(-1)!.toFixed(2)}${alike ? `; ${alike === 1 ? "one other pair" : `${alike} other pairs`} gave the same decision on every record they shared, so kappa has no value for ${alike === 1 ? "it" : "them"}` : ""}.` : "",
`${plural(counts.include, "record was", "records were")} included${counts.maybe ? `, and ${plural(counts.maybe, "was", "were")} left at Maybe` : ""}.`,
// Where the records stand: included, and the excluded and Maybe ones where there are any.
`${listed([`${plural(counts.include, "record was", "records were")} included`, ...(counts.exclude ? [`${num(counts.exclude)} excluded`] : []), ...(counts.maybe ? [`${num(counts.maybe)} left at Maybe`] : [])])}.`,
].filter(Boolean).join(" ");
}

Expand Down Expand Up @@ -504,8 +509,8 @@ export async function recordOf(convex: ConvexReactClient, workspaceId: Id<"works
const rows = voteRows(screening, papers);
const hidden = { votes: rows.filter((row) => row.kept).length, papers: new Set(rows.flatMap((row) => (row.kept ? [row.paper.id] : []))).size };
// A rule and a criterion, said one way wherever the file says them: as they stand now, and in each version of the history.
// A version of the history is said from its own rule alone: who reviewed then isn't kept, and today's reviewers say nothing of it.
const ruleOut = (rule: Rule, now = true) => ({ people_on_each_paper: rule.each === "all" ? "Everyone" : eachOf(rule), settled_when: SETTLE_LABEL[rule.settle], models_votes: now && !modelsOf(screening).length ? null : rule.settle === "one" ? "Advice on papers a person has" : rule.models === "advice" ? "Advice only" : "Count like a person's", conflicts_settled_by: rule.settle === "one" ? null : nameOn(screening, rule.resolver), other_votes_seen: rule.blind !== "after" ? "At any time" : !now ? "Hidden from a reviewer only while the paper waits for that reviewer's own vote, and from nobody once the screening is marked finished" : !hidesVotes(rule, hidingReaders(screening, out.invited), modelsVoting(screening)) ? (modelsVoting(screening) ? "At any time, since one person reads each paper and the AI models' votes are advice" : "At any time, since one person reads each paper") : advisedIn(screening, out.invited) ? "People's votes are hidden from a reviewer only while the paper waits for that reviewer's own vote, and from nobody once the screening is marked finished. The AI models' votes are advice, and show to a reviewer before they vote" : "Hidden from a reviewer only while the paper waits for that reviewer's own vote, and from nobody once the screening is marked finished" });
// A version of the history is said from its own rule and the models that were on the screening while it stood (`span`, from it to the next): who else reviewed then isn't kept.
const ruleOut = (rule: Rule, span?: readonly [number, number]) => { const now = !span; const modelsThen = span ? screening.reviewers.filter((one) => one.kind === "model" && one.addedAt < span[1] && (one.left === undefined || one.left > span[0])).length : 0; return ({ people_on_each_paper: rule.each === "all" ? "Everyone" : eachOf(rule), settled_when: SETTLE_LABEL[rule.settle], models_votes: (now ? !modelsOf(screening).length : !modelsThen) ? null : rule.settle === "one" ? "Advice on papers a person has" : rule.models === "advice" ? "Advice only" : "Count like a person's", conflicts_settled_by: rule.settle === "one" ? null : nameOn(screening, rule.resolver), other_votes_seen: rule.blind !== "after" ? "At any time" : !now ? (modelsThen && (rule.settle === "one" || rule.models === "advice") ? ADVICE_SEEN : HIDDEN_SEEN) : !hidesVotes(rule, hidingReaders(screening, out.invited), modelsVoting(screening)) ? (modelsVoting(screening) ? "At any time, since one person reads each paper and the AI models' votes are advice" : "At any time, since one person reads each paper") : advisedIn(screening, out.invited) ? ADVICE_SEEN : HIDDEN_SEEN }); };
const criterionOut = (criterion: Omit<Criterion, "addedAt">, [yes, no, unclear]: readonly number[]) => ({ key: criterion.key, short_name: criterion.short, question: criterion.text, must_have: criterion.must, guidance: criterion.note ?? null, marked_words: criterion.terms, points: { yes, no, unclear } });
// What a part of the screening carries from before it began is dated from its start.
const since = (when: number) => iso(Math.max(when, screening.createdAt));
Expand Down Expand Up @@ -537,11 +542,11 @@ export async function recordOf(convex: ConvexReactClient, workspaceId: Id<"works
sources: screening.sources.map((source, at) => ({ id: source.id, kind: source.kind, name: source.name, detail: source.detail, set: source.set ? withoutFiles(source.set) : null, filters: source.filters ?? [], records_taken: source.scope === "range" ? { first: source.range[0], last: source.range[1] } : "all", last_checked_at: source.read?.checkedAt ? iso(source.read.checkedAt) : null, last_read_failed: source.read?.state === "failed" ? (source.read.failure ?? true) : null, left_out_count: leftOf(source), left_out_without_abstract: bareOf(source), left_out: leftOut[at]!.map((row) => ({ name: row.name, why: english.words.t(`leftWhy.${row.why}`) })), duplicates_merged: merged[at]!.map((row) => ({ name: row.name, same_as_paper_id: row.paper?.id ?? null })), added_at: since(source.addedAt), found: taken(source) + leftOf(source), after_duplicates: keptOf(source) })),
papers: paperRows(out, papers).map((row, i) => ({ ...row, source_id: papers[i]!.source ?? null, settled_at: papers[i]!.settledAt ? iso(papers[i]!.settledAt!) : null })),
// What its rule and criteria were from each moment on, the first first: a paper's result is read against the version in force at its settled_at. Changes made before these were kept are not in it.
history: versions.map((one) => ({
history: versions.map((one, at) => ({
from: iso(one.at),
// Null where nobody made the change by hand: who settles conflicts passed on when they left.
by: one.by,
rule: ruleOut({ ...one.rule, each: one.rule.each === "all" ? "all" : `${one.rule.each}`, resolver: one.rule.resolver as string, models: one.rule.models ?? "vote" }, false),
rule: ruleOut({ ...one.rule, each: one.rule.each === "all" ? "all" : `${one.rule.each}`, resolver: one.rule.resolver as string, models: one.rule.models ?? "vote" }, [one.at, versions[at + 1]?.at ?? Infinity]),
criteria: one.criteria.map((criterion) => criterionOut(criterion, [criterion.points.yes, criterion.points.no, criterion.points.unclear])),
})),
// The votes that were cast and show, each with the sentence a model named for its answers and how sure it was.
Expand Down
13 changes: 9 additions & 4 deletions components/screening/overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,11 @@ function Reviewers({ open, figures, now }: { open: Open; figures: Figures | unde
// Moving someone's papers opens over the page as the screening's other dialogs do: a step in the history, with whose papers they are.
const [moving, setMoving] = useOpenInAddress("moveFrom", null);
const reviewers = inOrder(activeReviewers(screening), open.me);
const isPerson = new Set(screening.reviewers.filter((one) => one.kind === "person").map((one) => one.id));
// The people listed here: agreement is of the reviewers on the screening, as the figure over them and the Agreement section say it.
const isPerson = new Set(reviewers.filter((one) => one.kind === "person").map((one) => one.id));
const rows: ReviewerRowData[] = reviewers.map((reviewer) => {
const tally = reviewer.tally;
// A vote is compared with each person's on the same paper, and never with a model's: every pair of votes on a paper both voted on, and how many of them are the same.
// A vote is compared with each listed person's on the same paper, and never with a model's: every pair of votes on a paper both voted on, and how many of them are the same.
const withPeople = (figures?.pairs ?? []).filter((pair) => (pair.a === reviewer.id && isPerson.has(pair.b)) || (pair.b === reviewer.id && isPerson.has(pair.a)));
const compared = withPeople.reduce((sum, pair) => sum + pair.matrix.reduce((all, n) => all + n, 0), 0);
// Where the share rests on one other person it opens the papers the two voted on; on more, the comparison pair by pair.
Expand Down Expand Up @@ -561,6 +562,8 @@ function ReviewerRow({ open, row, onLeave, onMove }: { open: Open; row: Reviewer
const { reviewer, assigned, done, split, agrees, agreesHref, known, compared, missed, included, left, perDay, idle } = row;
const t = useTranslations("screening.overview");
const tp = useTranslations("screening.pieces");
// What a model isn't given is said as Settings says it: one sentence for one fact.
const form = useTranslations("screening.form");
const words = useWords();
// The people there are to compare a vote with: none, where it is the only person or a model with no people beside it.
const peopleOn = readersOf(screening).people.length;
Expand Down Expand Up @@ -626,7 +629,7 @@ function ReviewerRow({ open, row, onLeave, onMove }: { open: Open; row: Reviewer
</PopoverContent>
</Popover>
) : null}
{notGiven?.papers ? <p className="flex items-start gap-1 text-xs text-muted-foreground"><FileText className="mt-px size-3.5 shrink-0" />{notGiven.why === "text" ? t("row.notGivenText", { count: notGiven.papers }) : t("row.notGivenLong", { count: notGiven.papers })}</p> : null}
{notGiven?.papers ? <p className="flex items-start gap-1 text-xs text-muted-foreground"><FileText className="mt-px size-3.5 shrink-0" />{form("reviewers.pdfsMissed", { why: notGiven.why, count: notGiven.papers })}</p> : null}
</div>
{/* How someone else voted is kept from a reviewer who still has papers to vote on: their own row, and how far each of the others is, say everything else. */}
{reviewer.tally?.kept ? (
Expand Down Expand Up @@ -863,6 +866,8 @@ function Facts({ open }: { open: Open }) {
const { screening, counts } = open;
const t = useTranslations("screening.overview");
const tl = useTranslations("screening.list");
// The balance is said as the form and Settings say it.
const form = useTranslations("screening.form");
const words = useWords();
const workspace = screening.workspace;
const models = modelsOf(screening);
Expand Down Expand Up @@ -936,7 +941,7 @@ function Facts({ open }: { open: Open }) {
</div>
<Meter value={spent} max={Math.max(most, 1)} fill={left < most - spent ? "bg-warning" : "bg-foreground/45"} />
<div className="flex flex-wrap gap-1.5">
{/* Billing is its workspace's members' to open: anyone else reads the balance. */}{open.wallet === undefined ? null : <LinkChip href="/settings/billing" tone={left < most - spent ? "warning" : "neutral"} icon={Coins}>{t("credits.leftIn", { credits: words.credits(left), workspace: workspace.name, own: String(screening.workspace.kind === "personal" && open.canChange) })}</LinkChip>}
{/* Billing is its workspace's members' to open: anyone else reads the balance. */}{open.wallet === undefined ? null : <LinkChip href="/settings/billing" tone={left < most - spent ? "warning" : "neutral"} icon={Coins}>{form("cost.inWorkspace", { credits: words.credits(left), workspace: workspace.name, own: String(screening.workspace.kind === "personal" && open.canChange) })}</LinkChip>}
{models.length ? <Chip>{words.count("models", models.length)}</Chip> : null}
{/* The total counts what a model spent before it was taken off: said, so it adds up with the rows above. */}
{offSpent >= 1 ? <Chip>{t("credits.takenOff", { credits: words.credits(offSpent) })}</Chip> : null}
Expand Down
Loading
Loading