Hardening pass: scheduler backoff, FK cascade, a11y, test safety net

Pre-traffic cleanup from an audit:

* Scheduler: poll_due_sources now keys on the last *attempt* (success or
  failure), not the last success, and scales the wait by the consecutive-
  failure streak (capped at a day). A failing feed (e.g. Phys.org's HTTP 429s)
  used to be retried every cycle because it had no successful run; it now backs
  off and recovers on its own. Extracted due_source_rows() + tests.

* FK hygiene: deleting a daily_brief is supposed to cascade to its items, but
  SQLite enforces foreign keys per-connection — connect() already sets the
  pragma, so the cascade is correct going forward; added a regression test.
  (Orphaned items + Phys.org settings were cleaned directly on the live DB.)

* a11y: modal/drawer dialogs are now focusable (tabindex), close on Escape
  (window) and on backdrop click via a target check (dropping the inner
  stopPropagation handlers). Build is warning-free.

* tests: conftest points any un-mocked LLM client at a closed port with a 1s
  timeout, so an accidental real call fails fast instead of hanging the suite.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
jay
2026-06-06 19:18:18 +00:00
parent 978edc8f4a
commit 452e5a3fe4
8 changed files with 158 additions and 20 deletions
@@ -38,8 +38,10 @@
<svelte:window onkeydown={onkey} />
<div class="overlay" onclick={onclose} role="presentation">
<div class="sheet rise" role="dialog" aria-modal="true" aria-label="Send feedback" onclick={(e) => e.stopPropagation()}>
<!-- Backdrop: clicking it closes; keyboard users close with Escape (window). -->
<!-- svelte-ignore a11y_click_events_have_key_events -->
<div class="overlay" role="presentation" onclick={(e) => e.target === e.currentTarget && onclose?.()}>
<div class="sheet rise" role="dialog" aria-modal="true" aria-label="Send feedback" tabindex="-1">
<button class="x" onclick={onclose} aria-label="Close">×</button>
{#if status === 'sent'}
@@ -64,8 +64,10 @@
{#if inline}
<section class="panel rise">{@render body()}</section>
{:else}
<div class="overlay" onclick={onclose} role="presentation">
<div class="sheet rise" role="dialog" aria-modal="true" aria-label="Customize lanes" onclick={(e) => e.stopPropagation()}>
<!-- Backdrop: clicking it closes; keyboard users close with Escape (window). -->
<!-- svelte-ignore a11y_click_events_have_key_events -->
<div class="overlay" role="presentation" onclick={(e) => e.target === e.currentTarget && onclose?.()}>
<div class="sheet rise" role="dialog" aria-modal="true" aria-label="Customize lanes" tabindex="-1">
<button class="x" onclick={onclose} aria-label="Close">×</button>
{@render body()}
</div>
@@ -28,8 +28,10 @@
<svelte:window onkeydown={onkey} />
<div class="overlay" onclick={onclose} role="presentation">
<aside class="drawer" onclick={(e) => e.stopPropagation()} aria-label="Saved articles">
<!-- Backdrop: clicking it closes; keyboard users close with Escape (window). -->
<!-- svelte-ignore a11y_click_events_have_key_events -->
<div class="overlay" role="presentation" onclick={(e) => e.target === e.currentTarget && onclose?.()}>
<div class="drawer" role="dialog" aria-modal="true" aria-label="Saved articles" tabindex="-1">
<div class="head">
<h2>Saved</h2>
<button class="x" onclick={onclose} aria-label="Close">×</button>
@@ -53,7 +55,7 @@
{:else}
<p class="muted">Nothing saved yet — tap <strong>Save</strong> on a story to keep it here.</p>
{/if}
</aside>
</div>
</div>
<style>
+10 -2
View File
@@ -19,10 +19,18 @@
error = err?.message || 'Something went wrong — try again in a moment.';
}
}
function onkey(e) {
if (e.key === 'Escape') onclose?.();
}
</script>
<div class="overlay" onclick={onclose} role="presentation">
<div class="sheet rise" role="dialog" aria-modal="true" aria-label="Sign in" onclick={(e) => e.stopPropagation()}>
<svelte:window onkeydown={onkey} />
<!-- Backdrop: clicking it closes; keyboard users close with Escape (window). -->
<!-- svelte-ignore a11y_click_events_have_key_events -->
<div class="overlay" role="presentation" onclick={(e) => e.target === e.currentTarget && onclose?.()}>
<div class="sheet rise" role="dialog" aria-modal="true" aria-label="Sign in" tabindex="-1">
<button class="x" onclick={onclose} aria-label="Close">×</button>
{#if status === 'sent'}