chore(autonomous-session): consolidate uncommitted work from prior session

Bundles the prior autonomous-session output that was sitting unstaged:

- Em-dash sweep across src/ + tests/ (en-dash/em-dash to hyphen, ~2280 instances)
- country-flag-icons rollout (CountryFlag component, replaces emoji glyphs that
  never rendered on Windows; lazy-loads the 3x2 SVG index as a single chunk
  after the per-subpath dynamic-import approach silently failed in webpack)
- Admin IA Phase 1+2: 7-domain regroup, 41 to 38 pages, /admin/berths index,
  redirects (ocr to ai, reports to dashboard, invitations to users),
  docs/admin-ia-proposal.md
- Per-template email tester (registry + endpoint + UI on Email admin page)
- Cancel-document mode picker (delete-from-Documenso vs keep-for-audit)
- Dashboard PDF report: 25 widgets, SVG charts, date-range picker, 11 resolvers
- Customize-widgets per-region sortables at xl+ (charts/rails/feed); single
  flat sortable below xl when the layout stacks; per-viewport saved orders
- Audit doc updates capturing each shipped item
- Lint fixes: react-compiler immutability in DonutChart (reduce instead of
  let-reassign), set-state-in-effect disables in CountryFlag and
  UploadForSigning preview-bytes effect, unused 'confirm' destructures in
  interest contract + reservation tabs, unescaped apostrophe in test-template
  card copy
This commit is contained in:
2026-05-23 00:52:59 +02:00
parent 43719b49e9
commit 221ae5784e
749 changed files with 7440 additions and 3118 deletions

View File

@@ -189,7 +189,7 @@ export async function sendReminderIfAllowed(
* Performance: the pre-bulk version called `sendReminderIfAllowed` per
* doc, which re-fetched the port row (invariant), the template-by-type
* map (repeats heavily), the last reminder event, and the pending
* signers 5×N round trips per cron tick. This implementation hoists
* signers - 5×N round trips per cron tick. This implementation hoists
* the invariants out of the loop and turns the per-row queries into
* grouped scans (one per dimension), so a port with 500 in-flight docs
* is now ~7 round trips total instead of ~2500.
@@ -206,7 +206,7 @@ export async function processReminderQueue(portId: string): Promise<void> {
fileId: documents.fileId,
})
.from(documents)
// CRITICAL: scope the join to the same port `documentTemplates.templateType`
// CRITICAL: scope the join to the same port - `documentTemplates.templateType`
// is not unique across ports, so a leftJoin without `portId` produces a
// cartesian explosion (one output row per template-type match across
// every port). The downstream loop fires `documensoRemind` per row,
@@ -234,16 +234,16 @@ export async function processReminderQueue(portId: string): Promise<void> {
// Hoist invariants out of the per-doc loop ────────────────────────────────
// (1) Port row (timezone) invariant across the whole batch.
// (1) Port row (timezone) - invariant across the whole batch.
const port = await db.query.ports.findFirst({ where: eq(ports.id, portId) });
const timezone = port?.timezone ?? 'UTC';
const currentHour = getCurrentHourInTimezone(timezone);
if (currentHour < 9 || currentHour >= 16) {
// Outside the 9-16 window nothing to do this tick.
// Outside the 9-16 window - nothing to do this tick.
return;
}
// (2) Per-type template cadence map repeats per documentType.
// (2) Per-type template cadence map - repeats per documentType.
const distinctTypes = Array.from(new Set(activeDocs.map((d) => d.documentType)));
const templateRows = await db
.select({
@@ -261,7 +261,7 @@ export async function processReminderQueue(portId: string): Promise<void> {
templateRows.map((r) => [r.templateType, r.reminderCadenceDays ?? null]),
);
// (3) Latest reminder_sent event per doc one grouped query.
// (3) Latest reminder_sent event per doc - one grouped query.
const docIds = activeDocs.map((d) => d.id);
const lastReminderRows = await db
.select({
@@ -278,7 +278,7 @@ export async function processReminderQueue(portId: string): Promise<void> {
.groupBy(documentEvents.documentId);
const lastReminderByDoc = new Map(lastReminderRows.map((r) => [r.documentId, r.lastAt]));
// (4) Pending signers per doc one inArray scan.
// (4) Pending signers per doc - one inArray scan.
const pendingSignerRows = await db
.select()
.from(documentSigners)
@@ -291,7 +291,7 @@ export async function processReminderQueue(portId: string): Promise<void> {
pendingByDoc.set(row.documentId, arr);
}
// Per-doc fire at this point every per-row query is a Map.get.
// Per-doc fire - at this point every per-row query is a Map.get.
for (const doc of activeDocs) {
try {
const due = isReminderDue({