Reintent

The Morning Inbox

Ask only about what is shown. Sixteen emails, one declaration. System One triages the ones in view, and is asked again only when something it reads changes.

What it shows

One declaration, many instances, and a model asked only about what is shown. Every email is an instance of one entity, found by its id. Only the rows in view are read, so only they are asked about; an answer is kept for what it read, so scrolling back asks nothing. When something changes, the earlier answer stands in, marked stale, until the new one comes, and a decision you make meanwhile is not overwritten when it does. One rule can cover every email at once.

Why this scenario. A greeting card is one item, always fully in view, and waiting a moment for its tone costs nothing. An inbox has many items, sees a few at a time, and is read faster than a model answers. Here the number of questions follows the screen, not the data; the counter at the top shows it. An answer that arrives after you changed your mind must not undo you, and a rule like "archive nothing" is plainly different from your call on one email. None of these mean much with one card; in a list they are what makes a model affordable and trustworthy.

You will seeWhat does it
One set of triage buttons on every email; a click changes that oneentity('mail', …), an instance per email; decide(mail.label(id))
›: the count goes up by four; ‹: it staysOnly what is shown asks; an answer is kept for its uses
On holiday: the rows in view dim, then changeintent.tell; the earlier answer stands in, stale
A click while a row is dim stays when the answer arrivesAnswers carry their inputs; a belief only fills its own layer
No archive until read: every archived email moves, your own calls stayconstrain({ name: 'label' }, …): a rule over every instance
Scrolling is not undone by UndoWhere the view is, is the root's input (intent.setInput)

Learn more: Entities, Showing an intent, Judging, A person's decisions.

Where it fits: triage and moderation queues, feeds and search results judged as they scroll into view, any list where a model labels items a person reviews.

Open the inbox

It is Monday morning. Sixteen emails, four in view: System One triages them, and the count at the top says it was asked four times. Press › twice and ‹ twice: the count goes to twelve and stays there. Tell it you are On holiday this week: the four in view dim while it thinks them over. Before they change, press Reply on Jun's dinner invitation; when the answers come, your reply stays. Turn on No archive until read: every archived email moves to later, except any you archived yourself.

/** @jsxImportSource ./mailbox */
import {
  action,
  entity,
  useChoiceStatus,
  useInput,
  type HostNode,
  type Intent,
  type Realization,
} from '@reintent/core';
import { LABELS, type Row } from './catalog';
import { MAILS, type Mail } from './mails';

export { LABELS, MAILS, type Mail, type Row };

/** How many emails are in view at once. */
export const WINDOW = 4;

/** One declaration for every email: an instance each, found by the email's id. */
export const mail = entity('mail', {
  label: {
    kinds: [...LABELS],
    default: 'later',
    judge:
      'Triage this email in a busy Monday-morning inbox: reply (needs an answer today), later (worth reading, no hurry) or archive (nothing to do).',
  },
});

/** A rule for the whole inbox: it rules archive out of every email, not just one. */
export const NO_ARCHIVE = { name: 'label' };

/** What the person can tell System One about this week, one sentence at a time. */
export const WEEK = [
  'I am on holiday this week: only what cannot wait needs a reply.',
  'We launch on Friday: anything about the launch needs a reply today.',
] as const;

/** An email's row: it reads its own instance's label, and writes no id. */
export const MailRow = mail(function MailRow(p: Mail) {
  const label = useChoiceStatus(mail.label, {
    uses: { from: p.from, subject: p.subject, preview: p.preview },
  });
  return (
    <mail-row
      id={p.id}
      from={p.from}
      subject={p.subject}
      preview={p.preview}
      label={label.value}
      source={label.source}
      stale={!!label.stale}
      pick={action.decide(mail.label(p.id))}
      clear={action.forget(mail.label(p.id))}
    />
  );
});

/** How many times System One was asked: every judgment the intent sent. */
export const askedOf = (intent: Intent) =>
  intent.inspect().requests.filter((r) => r.effect === 'judge').length;

/** The rows in a realization. */
export const rowsOf = (r: Realization) =>
  ((r.tree as HostNode).children as HostNode[]).map((n) => n.props as Row);

/** The inbox: only the emails in view are read, so only they are asked about. Where the view is, is the root's input. */
export default function Inbox() {
  const { from = 0 } = (useInput() ?? {}) as { from?: number };
  const shown = MAILS.slice(from, from + WINDOW);
  return (
    <inbox from={from} to={from + shown.length} total={MAILS.length}>
      {shown.map((m) => (
        <MailRow key={m.id} {...m} />
      ))}
    </inbox>
  );
}
ChoicesC

Starting…

Realizationλ

Starting…

What happened

Nothing logged.

Why Reintent

The program declares the triage once, as data, and renders a row for each email in view; the row reads its own instance's label, with the email's sender, subject and first line as what the judgment reads. Nothing in the program counts requests or caches answers: a request goes out for what a host shows, an answer is kept for its inputs and the sentences said, and a newer fact is never overwritten by an older answer. The app holds the Intent and sets where the view is, the root's input, so scrolling is not part of the history. All emails are invented; System One's answers are recorded, and arrive after a moment on purpose, so the page calls no model.

Last updated on

Edit on GitHub