<!-- generated by scripts/gen-docs.mjs from docs/system/save-line.md. Edit the source and rerun. -->
# SaveLine

## Description
Says whether what a person edited is saved, in one line that never changes size: Saving, Saved, Not saved with Retry, Could not confirm with Check, or Changed elsewhere with Show latest.

`import { SaveLine } from "@/components/cobalt/ui/save-line"`, source `registry/cobalt/ui/save-line.tsx`, status `ready`.
`import { useAutosave, useSaveState, type SaveState } from "@/lib/cobalt/use-autosave"`, source `registry/cobalt/lib/use-autosave.ts`.
Foundation: `hand-rolled`. Traps checked: `trap/live-region-double`, `trap/color-only-status`, `trap/loading-layout-shift`, `trap/loading-label-swap` (n/a: the line is not a control's label; it sits beside the control), `trap/reduced-motion-ignored`, `trap/numbers-shift` (n/a: no figures), `trap/demo-on-timers` (n/a: the waits stand in for a server).

`trap/live-region-double` is answered by one status region that says the outcome, not the wait (ARIA). `trap/color-only-status` by words in every state, and a glyph for Saving and Saved (States). `trap/loading-layout-shift` by every wording that can come up stacked in one cell, so the line keeps the size of its longest (States). `trap/reduced-motion-ignored` by fades only (Motion).

### Foundation
Not applicable: hand-rolled.

| Given by the foundation | Added by the team |
|---|---|
| Not applicable: hand-rolled, with TextSwap's crossfade and the Spinner | Seven wordings in one grid cell, each inert while it is not showing, so its button takes no press and no focus; a wording whose way on is not passed takes no room; Retry, Check and Show latest as buttons with a text link's look, so the line stays one line of text tall; an always-mounted status region that says Saved, Not saved, Could not confirm and Changed elsewhere, and not Saving; `useAutosave`, after the TSA app's: a save 600ms after edits pause, one at a time in order, Saving only past the slow-wait delay, anything waiting sent on unmount and `pagehide`, a stale write that stops saving until the host shows the latest, and with `check` an unconfirmed save whose way on is Check; `useSaveState`, the line's state from one write's status |

## Examples
A profile that saves as you type: one save after you pause, Saving only when it is slow, then Saved; with the Offline control on it says Not saved, and Retry sends it again.

Real uses, 0 call sites (`rg -n "<SaveLine\b" app registry --glob '!registry/cobalt/ui/*'`): the part is new. SettingsRow draws it under each setting's name, `registry/cobalt/ui/settings-layout.tsx`. The TSA app draws the same line by hand in its settings tab (`docs/research/2026-10-17-missing-parts.md`, F2).

### Example files
| File | Covers | Caption |
|---|---|---|
| `docs/system/examples/save-line/default.tsx` | default | A profile that saves as you type: one save after you pause, Saving only when it is slow, then Saved; offline, Not saved with Retry |
| `docs/system/examples/save-line/states.tsx` | state:saving | Every wording the line can say |
| `docs/system/examples/save-line/default.tsx` | state:saved | Saved, after a pause in typing |
| `docs/system/examples/save-line/default.tsx` | state:failed | Not saved with Retry, under the Offline control |
| `docs/system/examples/save-line/unconfirmed.tsx` | state:unconfirmed | Could not confirm with Check, after a lost answer |
| `docs/system/examples/save-line/unconfirmed.tsx` | state:checking | Check asks the server |
| `docs/system/examples/save-line/stale.tsx` | state:stale | Changed elsewhere with Show latest |
| `docs/system/examples/save-line/states.tsx` | state:idle | Nothing to report: the line's `idle` content, or nothing |
| `docs/system/examples/save-line/default.tsx` | composition:Field | The line at the end of a form's heading, over its fields |

Example: A profile that saves as you type: one save after you pause, Saving only when it is slow, then Saved; offline, Not saved with Retry (`docs/system/examples/save-line/default.tsx`)

```tsx
import { useRef, useState } from "react";

import { Field, FieldLabel } from "@/components/cobalt/ui/field";
import { Input } from "@/components/cobalt/ui/input";
import { SaveLine } from "@/components/cobalt/ui/save-line";
import { useAutosave } from "@/lib/cobalt/use-autosave";

type Profile = { name: string; headline: string };

// Stands in for your API call. It answers after 700ms, and refuses while the browser is offline or
// the address has ?network=offline.
const saveProfile = (_profile: Profile) =>
  new Promise<boolean>((resolve) =>
    setTimeout(
      () => resolve(navigator.onLine && new URLSearchParams(location.search).get("network") !== "offline"),
      700,
    ),
  );

export default function Example() {
  const [draft, setDraft] = useState<Profile>({
    name: "Maya Chen",
    headline: "Portfolio manager, fixed income",
  });
  // What is typed, for a save that runs after this render, and what the server last kept.
  const latest = useRef(draft);
  const stored = useRef(draft);
  const autosave = useAutosave(() => {
    const next = latest.current;
    if (next.name === stored.current.name && next.headline === stored.current.headline) return null;
    return saveProfile(next).then((kept) => {
      if (kept) stored.current = next;
      return kept;
    });
  });
  const edit = (field: keyof Profile, value: string) => {
    latest.current = { ...latest.current, [field]: value };
    setDraft(latest.current);
    autosave.schedule();
  };
  return (
    <section aria-labelledby="profile-heading" className="flex w-full max-w-sm flex-col gap-4">
      <div className="flex items-baseline justify-between gap-4">
        <h3 id="profile-heading" className="text-base font-semibold">
          Profile
        </h3>
        <SaveLine
          state={autosave.state}
          onRetry={() => void autosave.retry()}
          className="justify-items-end"
        />
      </div>
      <Field>
        <FieldLabel>Name</FieldLabel>
        <Input value={draft.name} onChange={(e) => edit("name", e.target.value)} />
      </Field>
      <Field>
        <FieldLabel>Headline</FieldLabel>
        <Input value={draft.headline} onChange={(e) => edit("headline", e.target.value)} />
      </Field>
    </section>
  );
}
```

Example: The line at the end of a form's heading, over its fields (`docs/system/examples/save-line/default.tsx`)

```tsx
import { useRef, useState } from "react";

import { Field, FieldLabel } from "@/components/cobalt/ui/field";
import { Input } from "@/components/cobalt/ui/input";
import { SaveLine } from "@/components/cobalt/ui/save-line";
import { useAutosave } from "@/lib/cobalt/use-autosave";

type Profile = { name: string; headline: string };

// Stands in for your API call. It answers after 700ms, and refuses while the browser is offline or
// the address has ?network=offline.
const saveProfile = (_profile: Profile) =>
  new Promise<boolean>((resolve) =>
    setTimeout(
      () => resolve(navigator.onLine && new URLSearchParams(location.search).get("network") !== "offline"),
      700,
    ),
  );

export default function Example() {
  const [draft, setDraft] = useState<Profile>({
    name: "Maya Chen",
    headline: "Portfolio manager, fixed income",
  });
  // What is typed, for a save that runs after this render, and what the server last kept.
  const latest = useRef(draft);
  const stored = useRef(draft);
  const autosave = useAutosave(() => {
    const next = latest.current;
    if (next.name === stored.current.name && next.headline === stored.current.headline) return null;
    return saveProfile(next).then((kept) => {
      if (kept) stored.current = next;
      return kept;
    });
  });
  const edit = (field: keyof Profile, value: string) => {
    latest.current = { ...latest.current, [field]: value };
    setDraft(latest.current);
    autosave.schedule();
  };
  return (
    <section aria-labelledby="profile-heading" className="flex w-full max-w-sm flex-col gap-4">
      <div className="flex items-baseline justify-between gap-4">
        <h3 id="profile-heading" className="text-base font-semibold">
          Profile
        </h3>
        <SaveLine
          state={autosave.state}
          onRetry={() => void autosave.retry()}
          className="justify-items-end"
        />
      </div>
      <Field>
        <FieldLabel>Name</FieldLabel>
        <Input value={draft.name} onChange={(e) => edit("name", e.target.value)} />
      </Field>
      <Field>
        <FieldLabel>Headline</FieldLabel>
        <Input value={draft.headline} onChange={(e) => edit("headline", e.target.value)} />
      </Field>
    </section>
  );
}
```

## Variants
Not applicable: one line. Which wordings can come up follows the ways on that are passed.

## States
| State | Trigger | What the user can do | Shown by, besides color | Checked by |
|---|---|---|---|---|
| idle | nothing sent yet | edit | the `idle` content, such as a row's description, or nothing | test |
| saving | a save is out past 250ms | keep editing | the spinner and "Saving" | test |
| saved | the server holds the last edit | keep editing | the check and "Saved"; announced | test |
| failed | the server refused, or could not be reached | press Retry | "Not saved" and Retry; announced | test |
| unconfirmed | a save's answer was lost, with `check` | press Check | "Could not confirm" and Check; announced; nothing more is sent | test |
| checking | Check is out past 250ms | wait | the spinner and "Checking" | test |
| stale | the server holds a newer version | press Show latest | "Changed elsewhere" and Show latest; announced; nothing more is sent | test |

Example: Every wording the line can say (`docs/system/examples/save-line/states.tsx`)

```tsx
import { SaveLine } from "@/components/cobalt/ui/save-line";
import type { SaveState } from "@/lib/cobalt/use-autosave";

const states: { state: SaveState; when: string }[] = [
  { state: "idle", when: "Nothing sent yet" },
  { state: "saving", when: "A save is out and slow" },
  { state: "saved", when: "The server holds the last edit" },
  { state: "failed", when: "Refused, or the server was out of reach" },
  { state: "unconfirmed", when: "The answer to a save was lost" },
  { state: "checking", when: "Asking whether it landed" },
  { state: "stale", when: "A newer version was saved elsewhere" },
];

export default function Example() {
  return (
    // Each situation and its wording are one group, 4px apart, with 16px between groups when they
    // stack, so a wording is never read against the wrong situation.
    <dl className="grid w-full max-w-lg grid-cols-1 gap-y-4 text-sm sm:grid-cols-2 sm:gap-x-6 sm:gap-y-3">
      {states.map(({ state, when }) => (
        <div key={state} className="grid gap-1 sm:col-span-2 sm:grid-cols-subgrid">
          <dt className="text-muted-foreground">{when}</dt>
          <dd>
            <SaveLine
              state={state}
              idle="Shown on your profile"
              onRetry={() => {}}
              onCheck={() => {}}
              onShowLatest={() => {}}
            />
          </dd>
        </div>
      ))}
    </dl>
  );
}
```

Example: Saved, after a pause in typing (`docs/system/examples/save-line/default.tsx`)

```tsx
import { useRef, useState } from "react";

import { Field, FieldLabel } from "@/components/cobalt/ui/field";
import { Input } from "@/components/cobalt/ui/input";
import { SaveLine } from "@/components/cobalt/ui/save-line";
import { useAutosave } from "@/lib/cobalt/use-autosave";

type Profile = { name: string; headline: string };

// Stands in for your API call. It answers after 700ms, and refuses while the browser is offline or
// the address has ?network=offline.
const saveProfile = (_profile: Profile) =>
  new Promise<boolean>((resolve) =>
    setTimeout(
      () => resolve(navigator.onLine && new URLSearchParams(location.search).get("network") !== "offline"),
      700,
    ),
  );

export default function Example() {
  const [draft, setDraft] = useState<Profile>({
    name: "Maya Chen",
    headline: "Portfolio manager, fixed income",
  });
  // What is typed, for a save that runs after this render, and what the server last kept.
  const latest = useRef(draft);
  const stored = useRef(draft);
  const autosave = useAutosave(() => {
    const next = latest.current;
    if (next.name === stored.current.name && next.headline === stored.current.headline) return null;
    return saveProfile(next).then((kept) => {
      if (kept) stored.current = next;
      return kept;
    });
  });
  const edit = (field: keyof Profile, value: string) => {
    latest.current = { ...latest.current, [field]: value };
    setDraft(latest.current);
    autosave.schedule();
  };
  return (
    <section aria-labelledby="profile-heading" className="flex w-full max-w-sm flex-col gap-4">
      <div className="flex items-baseline justify-between gap-4">
        <h3 id="profile-heading" className="text-base font-semibold">
          Profile
        </h3>
        <SaveLine
          state={autosave.state}
          onRetry={() => void autosave.retry()}
          className="justify-items-end"
        />
      </div>
      <Field>
        <FieldLabel>Name</FieldLabel>
        <Input value={draft.name} onChange={(e) => edit("name", e.target.value)} />
      </Field>
      <Field>
        <FieldLabel>Headline</FieldLabel>
        <Input value={draft.headline} onChange={(e) => edit("headline", e.target.value)} />
      </Field>
    </section>
  );
}
```

Example: Not saved with Retry, under the Offline control (`docs/system/examples/save-line/default.tsx`)

```tsx
import { useRef, useState } from "react";

import { Field, FieldLabel } from "@/components/cobalt/ui/field";
import { Input } from "@/components/cobalt/ui/input";
import { SaveLine } from "@/components/cobalt/ui/save-line";
import { useAutosave } from "@/lib/cobalt/use-autosave";

type Profile = { name: string; headline: string };

// Stands in for your API call. It answers after 700ms, and refuses while the browser is offline or
// the address has ?network=offline.
const saveProfile = (_profile: Profile) =>
  new Promise<boolean>((resolve) =>
    setTimeout(
      () => resolve(navigator.onLine && new URLSearchParams(location.search).get("network") !== "offline"),
      700,
    ),
  );

export default function Example() {
  const [draft, setDraft] = useState<Profile>({
    name: "Maya Chen",
    headline: "Portfolio manager, fixed income",
  });
  // What is typed, for a save that runs after this render, and what the server last kept.
  const latest = useRef(draft);
  const stored = useRef(draft);
  const autosave = useAutosave(() => {
    const next = latest.current;
    if (next.name === stored.current.name && next.headline === stored.current.headline) return null;
    return saveProfile(next).then((kept) => {
      if (kept) stored.current = next;
      return kept;
    });
  });
  const edit = (field: keyof Profile, value: string) => {
    latest.current = { ...latest.current, [field]: value };
    setDraft(latest.current);
    autosave.schedule();
  };
  return (
    <section aria-labelledby="profile-heading" className="flex w-full max-w-sm flex-col gap-4">
      <div className="flex items-baseline justify-between gap-4">
        <h3 id="profile-heading" className="text-base font-semibold">
          Profile
        </h3>
        <SaveLine
          state={autosave.state}
          onRetry={() => void autosave.retry()}
          className="justify-items-end"
        />
      </div>
      <Field>
        <FieldLabel>Name</FieldLabel>
        <Input value={draft.name} onChange={(e) => edit("name", e.target.value)} />
      </Field>
      <Field>
        <FieldLabel>Headline</FieldLabel>
        <Input value={draft.headline} onChange={(e) => edit("headline", e.target.value)} />
      </Field>
    </section>
  );
}
```

Example: Could not confirm with Check, after a lost answer (`docs/system/examples/save-line/unconfirmed.tsx`)

```tsx
import { useRef, useState } from "react";

import { Field, FieldLabel } from "@/components/cobalt/ui/field";
import { SaveLine } from "@/components/cobalt/ui/save-line";
import { Textarea } from "@/components/cobalt/ui/textarea";
import { Toggle } from "@/components/cobalt/ui/toggle";
import { Unconfirmed } from "@/lib/cobalt/failure";
import { useAutosave } from "@/lib/cobalt/use-autosave";

export default function Example() {
  const [note, setNote] = useState("Rebalance after the June filing.");
  const latest = useRef(note);
  // Stands in for your server: what it holds, and a switch that makes the next answer get lost.
  const server = useRef(note);
  const [loseNext, setLoseNext] = useState(false);
  const autosave = useAutosave(
    () => {
      const next = latest.current;
      if (next === server.current) return null;
      const lose = loseNext;
      setLoseNext(false);
      return new Promise((resolve, reject) =>
        setTimeout(() => {
          // The save lands either way; only its answer goes missing.
          server.current = next;
          if (lose) reject(new Unconfirmed());
          else resolve(true);
        }, 700),
      );
    },
    {
      check: () =>
        new Promise((resolve) => setTimeout(() => resolve(server.current === latest.current), 600)),
    },
  );
  return (
    <div className="w-full max-w-sm">
      <Field>
        <div className="flex items-baseline justify-between gap-4">
          <FieldLabel>Note</FieldLabel>
          <SaveLine
            state={autosave.state}
            onRetry={() => void autosave.retry()}
            onCheck={() => void autosave.check()}
          />
        </div>
        <Textarea
          value={note}
          onChange={(e) => {
            latest.current = e.target.value;
            setNote(e.target.value);
            autosave.schedule();
          }}
        />
      </Field>
      {/* A docs control, not part of the form: while it is on, the next save lands but its answer is lost. */}
      <div className="mt-4 flex flex-wrap items-center gap-2 border-t border-dashed pt-3">
        <Toggle size="sm" pressed={loseNext} onPressedChange={setLoseNext}>
          Lose the next answer
        </Toggle>
      </div>
    </div>
  );
}
```

Example: Check asks the server (`docs/system/examples/save-line/unconfirmed.tsx`)

```tsx
import { useRef, useState } from "react";

import { Field, FieldLabel } from "@/components/cobalt/ui/field";
import { SaveLine } from "@/components/cobalt/ui/save-line";
import { Textarea } from "@/components/cobalt/ui/textarea";
import { Toggle } from "@/components/cobalt/ui/toggle";
import { Unconfirmed } from "@/lib/cobalt/failure";
import { useAutosave } from "@/lib/cobalt/use-autosave";

export default function Example() {
  const [note, setNote] = useState("Rebalance after the June filing.");
  const latest = useRef(note);
  // Stands in for your server: what it holds, and a switch that makes the next answer get lost.
  const server = useRef(note);
  const [loseNext, setLoseNext] = useState(false);
  const autosave = useAutosave(
    () => {
      const next = latest.current;
      if (next === server.current) return null;
      const lose = loseNext;
      setLoseNext(false);
      return new Promise((resolve, reject) =>
        setTimeout(() => {
          // The save lands either way; only its answer goes missing.
          server.current = next;
          if (lose) reject(new Unconfirmed());
          else resolve(true);
        }, 700),
      );
    },
    {
      check: () =>
        new Promise((resolve) => setTimeout(() => resolve(server.current === latest.current), 600)),
    },
  );
  return (
    <div className="w-full max-w-sm">
      <Field>
        <div className="flex items-baseline justify-between gap-4">
          <FieldLabel>Note</FieldLabel>
          <SaveLine
            state={autosave.state}
            onRetry={() => void autosave.retry()}
            onCheck={() => void autosave.check()}
          />
        </div>
        <Textarea
          value={note}
          onChange={(e) => {
            latest.current = e.target.value;
            setNote(e.target.value);
            autosave.schedule();
          }}
        />
      </Field>
      {/* A docs control, not part of the form: while it is on, the next save lands but its answer is lost. */}
      <div className="mt-4 flex flex-wrap items-center gap-2 border-t border-dashed pt-3">
        <Toggle size="sm" pressed={loseNext} onPressedChange={setLoseNext}>
          Lose the next answer
        </Toggle>
      </div>
    </div>
  );
}
```

Example: Changed elsewhere with Show latest (`docs/system/examples/save-line/stale.tsx`)

```tsx
import { useRef, useState } from "react";

import { Button } from "@/components/cobalt/ui/button";
import { Field, FieldLabel } from "@/components/cobalt/ui/field";
import { Input } from "@/components/cobalt/ui/input";
import { SaveLine } from "@/components/cobalt/ui/save-line";
import { useAutosave } from "@/lib/cobalt/use-autosave";

export default function Example() {
  // Stands in for your server: the title it holds and its version, which each save must name.
  const server = useRef({ title: "Weekly fixed income review", version: 1 });
  const [title, setTitle] = useState(server.current.title);
  const latest = useRef(title);
  const base = useRef(1);
  const autosave = useAutosave(() => {
    const next = latest.current;
    if (next === server.current.title) return null;
    return new Promise((resolve) =>
      setTimeout(() => {
        if (base.current !== server.current.version) return resolve("stale");
        server.current = { title: next, version: server.current.version + 1 };
        base.current = server.current.version;
        resolve(true);
      }, 600),
    );
  });
  return (
    <div className="w-full max-w-sm">
      <Field>
        {/* The line keeps the room of its longest wording, Changed elsewhere with Show latest, so the
            label beside it is one short word that never wraps, and the line sits at the end. */}
        <div className="flex items-baseline justify-between gap-4">
          <FieldLabel className="shrink-0">Title</FieldLabel>
          <SaveLine
            className="min-w-0 justify-items-end"
            state={autosave.state}
            onRetry={() => void autosave.retry()}
            onShowLatest={() => {
              latest.current = server.current.title;
              base.current = server.current.version;
              setTitle(server.current.title);
              autosave.resolve();
            }}
          />
        </div>
        <Input
          value={title}
          onChange={(e) => {
            latest.current = e.target.value;
            setTitle(e.target.value);
            autosave.schedule();
          }}
        />
      </Field>
      {/* A docs control, not part of the form: it stands in for a colleague saving in another tab. */}
      <div className="mt-4 flex flex-wrap items-center gap-2 border-t border-dashed pt-3">
        <Button
          variant="ghost"
          size="sm"
          onClick={() => {
            server.current = {
              title: "Fixed income review, moved to Thursday",
              version: server.current.version + 1,
            };
          }}
        >
          Save a version in another tab
        </Button>
      </div>
    </div>
  );
}
```

Example: Nothing to report: the line's `idle` content, or nothing (`docs/system/examples/save-line/states.tsx`)

```tsx
import { SaveLine } from "@/components/cobalt/ui/save-line";
import type { SaveState } from "@/lib/cobalt/use-autosave";

const states: { state: SaveState; when: string }[] = [
  { state: "idle", when: "Nothing sent yet" },
  { state: "saving", when: "A save is out and slow" },
  { state: "saved", when: "The server holds the last edit" },
  { state: "failed", when: "Refused, or the server was out of reach" },
  { state: "unconfirmed", when: "The answer to a save was lost" },
  { state: "checking", when: "Asking whether it landed" },
  { state: "stale", when: "A newer version was saved elsewhere" },
];

export default function Example() {
  return (
    // Each situation and its wording are one group, 4px apart, with 16px between groups when they
    // stack, so a wording is never read against the wrong situation.
    <dl className="grid w-full max-w-lg grid-cols-1 gap-y-4 text-sm sm:grid-cols-2 sm:gap-x-6 sm:gap-y-3">
      {states.map(({ state, when }) => (
        <div key={state} className="grid gap-1 sm:col-span-2 sm:grid-cols-subgrid">
          <dt className="text-muted-foreground">{when}</dt>
          <dd>
            <SaveLine
              state={state}
              idle="Shown on your profile"
              onRetry={() => {}}
              onCheck={() => {}}
              onShowLatest={() => {}}
            />
          </dd>
        </div>
      ))}
    </dl>
  );
}
```

### State precedence
- Saving and saved: saving wins while a save is out, and holds 400ms once shown.
- Unconfirmed and a new edit: unconfirmed wins. The edit waits, marked dirty, and goes once Check says the last save landed.
- Stale and a new edit: stale wins. Nothing is sent until the host shows the latest and calls `resolve`.
- Failed and a new edit: both show. The line says Not saved until the edit's own save answers.

### Motion
| Trigger | Kind | Preset | Properties | Reduced motion |
|---|---|---|---|---|
| a change of wording | announce | TextSwap's handover: the leaving wording on 70 percent of `--t-pop`, the arriving one on `--t-icon` | opacity | the same fades; nothing moves |

## Props

<!-- Props generated from registry/cobalt/ui/save-line.tsx with TypeScript by scripts/props-table.mjs -->
| Prop | Type | Default | Purpose |
|---|---|---|---|
| `state` | `SaveState` |  |  |
| `className?` | `string` |  |  |
| `idle?` | `ReactNode` | `null` | What the line shows with nothing to report. |
| `onCheck?` | `() => void` |  | Asks the server after `unconfirmed`. |
| `onRetry?` | `() => void` |  | Sends again after `failed`. |
| `onShowLatest?` | `() => void` |  | Shows the version saved elsewhere after `stale`. |
| `words?` | `Partial<SaveLineWords>` |  | The words, for another language. |

`state` is the line's state, from `useAutosave`'s `state` or `useSaveState(status)`. `idle` is what it shows with nothing to report. `onRetry`, `onCheck` and `onShowLatest` are the ways on; a wording whose way on is not passed takes no room. `words` replaces the English words. `className` places the line; `justify-items-end` sets it at the end of a heading.

`useAutosave(send, { check, delay })` returns `state`, `dirty`, `schedule` (call it on every edit), `flush`, `retry`, `check` and `resolve`. `send` returns the request or null, and the request resolves true or nothing when kept, false when refused, and "stale" when a newer version is there.

## Usage

### When to use
- A form that saves itself as it is edited: a profile, a note, a document's title.
- A setting that saves on its own press, under its name, through SettingsRow's `status`.
- A form that saves as a whole, beside its heading, from `useSaveState(save.status)`.

### When not to use
- A button the person waits beside. Use StateButton instead, which reports in the button.
- A save the person cannot see the result of. Use Toaster instead.
- A list's read. Use ListBody instead, which dims the rows.

### Rules
- `rule/save-line-one-implementation`: When a form saves itself, use `useAutosave` and show its `state` in `SaveLine`, instead of a debounce and a status of the form's own, because the TSA app has three autosave implementations that disagree, one of them flashing Saving on every keystroke. Evidence: app 1/2 source apps, the TSA app's `use-autosave.ts`, `use-draft-editor.ts` and the listing sheet, docs/research/2026-10-17-missing-parts.md F3. Check: review of every `setTimeout` beside a save.
  - Don't: `useEffect(() => { const t = setTimeout(() => save(draft), 500); return () => clearTimeout(t); }, [draft])`
  - Do: `const autosave = useAutosave(send); <Input onChange={(e) => { setDraft(e.target.value); autosave.schedule(); }} />`
- `rule/save-line-check-not-retry`: When a save can lose its answer, such as a write behind a timeout, pass `check` to `useAutosave` and `onCheck` to the line, instead of offering Retry, because a Retry after a lost answer can save twice or be refused as stale against its own first save. Evidence: app 1/2 source apps, Tag's "Saving wasn't confirmed" with Check status, docs/research/2026-10-17-missing-parts.md F3; person D39. Check: test `use-autosave.test.ts` "a lost answer with check is unconfirmed".
  - Don't: `<SaveLine state="failed" onRetry={resend} />` after a timeout
  - Do: `<SaveLine state={autosave.state} onCheck={() => void autosave.check()} />`
- `rule/save-line-stale-never-merges`: When a save resolves "stale", show the latest version through `onShowLatest` and call `resolve`, instead of merging or saving over it, because a merge the person did not see, or an overwrite of someone else's edit, is a change nobody chose. Evidence: app 2/2 source apps refuse a stale write and offer the latest, docs/research/2026-10-17-missing-parts.md F3. Check: test `use-autosave.test.ts` "a stale write stops saving until the host shows the latest".
  - Don't: `if (outcome === "stale") return send({ ...latest, ...draft })`
  - Do: `<SaveLine state={autosave.state} onShowLatest={() => { setDraft(latest); autosave.resolve(); }} />`

### Content
- Follows `rule/writing-status-verb-ing`.
- `rule/save-line-words-short`: When replacing the words, keep each wording to at most 4 words and each way on to 1 or 2, such as "Not saved" and "Retry", instead of a sentence, because the line sits at a heading's end or under a setting's name, where a sentence wraps. Evidence: measured the German worst case on 3 lines, 60px, at 320 and 390, against 1 line for the English words at 390, docs/system/stress/save-line.tsx. Check: review.
  - Don't: `words={{ failed: "Your changes could not be saved. Please check your connection." }}`
  - Do: `words={{ failed: "Not saved", retry: "Retry" }}`

### Anti-slop
- `rule/save-line-no-saving-flash`: When a save answers fast, let the line go from the description straight to Saved, through `useAutosave` or `useSaveState`, instead of showing Saving on every edit, because a word that flashes for 50ms on each keystroke is noise. Evidence: person D39; app 1/2 source apps, the TSA app's draft editor flashes Saving on every keystroke, docs/research/2026-10-17-missing-parts.md F3. Check: review.
  - Don't: `<SaveLine state={sending ? "saving" : "saved"} />`
  - Do: `<SaveLine state={useSaveState(save.status)} />`

### Limits
- `rule/save-line-ways-on`: When a line can only fail and retry, such as a switch's, pass `onRetry` alone, instead of all 3 ways on, because each way on adds its wording to the cell, and the widest, Changed elsewhere with Show latest, wraps to 2 lines at 320. Evidence: measured 40px, 2 lines, at 320 with all 3 ways on against 20px at 390, docs/system/stress/save-line.tsx. Check: test `save-line.test.tsx` "a wording with no way on takes no room".
  - Don't: `<SaveLine state={state} onRetry={retry} onCheck={() => {}} onShowLatest={() => {}} />`
  - Do: `<SaveLine state={state} onRetry={retry} />`

## Accessibility
Rests on a grid of wordings, the one showing in the tree and the rest inert, and a status region that is always there.

### Keyboard
| Key | Where focus is | Effect | Focus after | Checked by |
|---|---|---|---|---|
| Tab | the field before | reaches the way on that is showing, and skips the inert ones | Retry, Check or Show latest | test |
| Enter | Retry | sends again | stays; the button goes inert as the wording changes, and focus returns to the body | by hand |

### ARIA
| Part | Role | Accessible name from | States and properties | Announced | Checked by |
|---|---|---|---|---|---|
| status region | status | none | always mounted | Saved, Not saved, Could not confirm or Changed elsewhere, once each; nothing for Saving or Checking | test |
| wording | none | none | `inert` and `aria-hidden` while not showing | nothing | test |
| way on | button | its words | none | "Retry, button" | test |

## Tokens
| Part | State | Token |
|---|---|---|
| words | saving, saved, checking | `--muted-foreground` |
| words | failed | `--destructive` |
| words | unconfirmed, stale | `--foreground` |
| way on | all | `--primary-ink` |
| wording | change | `--t-pop`, `--t-icon`, `--curve` |

## Related
- StateButton: a save the person waits for beside its button.
- SettingsLayout: SettingsRow puts the line under each setting's name.
- TextSwap: a short word that changes in place, with no way on.
- Toaster: a save the person cannot see.
