Files
substrata/lib/update-shared.ts
CatoandClaude Opus 5.5 d8afff1434 feat(news): fresh finds first, pull-new-news for anyone, 'On this page' for long pages (#153)
* feat(news): the news page leads with the newest finds; checked events by month

/events read as abandoned: its newest item was 3 weeks old while the sweep
had found something every day. It now opens with 'Just found' (last 14 days,
labelled not yet checked, Check this on each) using the front page's own
filter, then the checked events grouped by month with the source named up
front. Renamed News to match the nav; one filter row, kind/stage folded.

Procurement notices no longer pass as news (the Philippine Ombudsman's
scanner contract with 'Quartz Business Products' showed as high-purity
quartz); pinned in test/lead-signal.test.ts, mutation-checked.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* feat(news): anyone can pull fresh news; long pages get 'On this page'

- 'Update news now' on /events, scope 'all': each press (signed out too, no
  AI) web-searches the 3 bottlenecks searched longest ago, so presses by
  anyone walk the whole map forward; the page refreshes and new finds lead
  Just found. A sweep older than 24 h is said plainly above the button.
- SectionNav: 'On this page' built from the page's own <Heading>s and month
  headings (never a hand list), section in view marked. A rail left of the
  content on wide screens, a sticky strip under the top bar on phones.
  Opt-in per page: <Page sections>. Every Heading now carries an anchor id.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-06 03:29:35 -07:00

56 lines
1.8 KiB
TypeScript

/**
* The parts of "Update news now" a browser may import: the shapes the two
* routes answer with, and the numbers the buttons state. No database here.
*/
export type UpdateScope =
| { kind: 'bottleneck'; slug: string }
| { kind: 'company'; slug: string }
| { kind: 'desk' }
/** The news page: every bottleneck, the stalest few searched per press. */
| { kind: 'all' };
/** Leads one "Summarise with AI" drafts: a page read and up to two calls each, on the reader's key. */
export const SUMMARISE_AT_ONCE = 3;
/**
* Tokens one draft costs a reader's key: a page excerpt in, a JSON row out.
* Measured on 2026-09-25 over the drafts the free chain made before drafting
* moved to readers' keys (project note ai-and-feed-economy). Used for the
* estimates next to the buttons; the reader's vendor bills what it counts.
*/
export const TOKENS_PER_DRAFT = 3_400;
export interface UpdateLead {
id: string;
title: string;
url: string;
host: string;
bottleneck: string;
bottleneckSlug: string | null;
foundAt: string;
draft: {
status: 'drafted' | 'unusable' | 'could_not_read' | 'duplicate';
suggestion: 'event' | 'not_an_event' | null;
headline: string | null;
date: string | null;
reason: string;
} | null;
}
/** What step one answers. */
export interface UpdateResult {
covered: number;
swept: number;
found: number;
couldNotLook: number;
cooldownMinutes: number;
leads: UpdateLead[];
/** On a bottleneck page: its research databases were searched too. */
research?: { searched: boolean; itemsNew: number };
}
/** A lead a summary would still add something to. */
export function needsDraft(lead: UpdateLead): boolean {
return !lead.draft || lead.draft.status === 'unusable' || lead.draft.status === 'could_not_read';
}