# Group: agent-behaviour — dossier

Files: `routes/agent/Behaviour.tsx`, `routes/agent/situations-knowledge.tsx`
(embedded in Behaviour), `routes/AgentKnowledgeDoc.tsx` (orphaned full-page
editor). Shared CSS: `routes/agent/situations.css`.

## Screen 1 — Behaviour (`Behaviour.tsx` + `situations.css`)

**Legacy markers:** 0 (not in `LEGACY_BASELINE` — fully swept). Zero raw
`<input>`/`<select>`; two `<textarea>`, both wrapped in `cm-input`. All values
`--cm-*` tokens; `situations.css` uses container queries (`@container`) for
320/375/768, not viewport media queries.

- **IA:** 4 tabs (Global + 3 situations) × 5 fixed headings (Role/Goal/Tone/
  Knowledge/Guardrails), each field optionally carrying per-channel "extra
  wording" segments. That's three nested concepts (situation → heading →
  channel-append) a first-time operator must hold before touching anything.
- **Interaction:** deliberate, well-reasoned: one Edit unlocks every field on
  the tab, one Save commits them all; switching tabs mid-edit is blocked with
  an inline notice rather than silently discarding a draft. Keyboard/focus
  handled (tabs are real `role="tab"`, `focus-visible` rings). No dead ends
  found.
- **Content/copy:** plain words throughout ("What the bot is told, per
  situation", "Nothing here yet. Press Edit and type what you want."). The
  channel-append semantic — added text can never replace or switch off the
  base text — is explained nowhere in the UI itself, only in code comments;
  an operator sees a second box under a channel chip with no label saying
  what relationship it has to the box above it.
- **Visual/tokens:** clean; Global's filled-tab / hairline-row treatment is
  the only deliberate visual distinction from the three situation cards, and
  it reads correctly as "the shared parent, not a fourth situation."
- **A11y/responsive:** tabs have `aria-selected`/`aria-disabled`; the exact-
  prompt panel is a proper side panel with its own scroll region. Container
  queries mean this survives 320px already (per the CSS's own stated intent).

**VERDICT: keep.** Rebuilt to spec, on-token, no interaction dead ends — the
only real risk is the unlabelled channel-append semantic (content note, not a
visual one).

## Screen 2 — Knowledge rows (`situations-knowledge.tsx`, lives under each tab's Knowledge heading)

**Legacy markers:** 0. Zero raw `<input>` (uses `Input`/`Field`); one
`<textarea>` via `cm-input`.

- **IA:** one more concept than Behaviour needs an operator to hold: rows are
  scoped by *tab* (situation) and *filterable* by channel via a
  `SegmentedControl` that appears only when a channel-narrowed row exists.
  That's reasonable ("shows itself only when relevant") and matches the
  operator's own 2026-07-28 ruling.
- **Interaction:** row is a `div[role=button]` with real `onKeyDown`
  Enter/Space handling (correctly avoids nesting a `⋯` button inside a
  `<button>`). Menu is View/Edit/Delete, consistent with the rest of the app.
- **Content/copy:** "Nothing in the library yet." / "Add Knowledge" — plain,
  consistent with Behaviour.
- **Visual/tokens:** ManyChat-shaped row (title, "Updated …" meta, channel
  chips, `⋯`) exactly as the operator asked for; on-token throughout.
- **A11y/responsive:** row keyboard support present; chips hide under 420px
  container width rather than wrapping into overflow — a deliberate
  container-query call, consistent with the rest of the sheet.
- **Correctness risk (not a token/visual issue, but blocks "keep"):** the
  inline `EditPanel` used for both "Add Knowledge" and row "Edit" only ever
  reads/writes `title`, `content`, `channels`. It never sees `kind` or `data`.
  For any document created as a structured kind (area guide, process, fees,
  FAQ — see Screen 3) `content` is saved empty by the real editor, so opening
  such a row's "Edit" here shows an **empty content box for a document that
  visibly has real content** in its View panel. Saving from here is a silent
  no-op on the actual data but looks like data loss to the operator.

**VERDICT: polish.** Visually and structurally right; needs either a route
into the structured editor for non-article kinds, or a content-mismatch guard
so "Edit" never presents an empty box for a document that has real content
elsewhere.

## Screen 3 — `AgentKnowledgeDoc.tsx` (structured document editor, `/agent/behaviour/knowledge/new|:id`)

**Legacy markers:** 24 (pinned `LEGACY_BASELINE` entry — pre-rethink debt).
Every field is a raw `<input>`/`<textarea>` styled with inline
`React.CSSProperties` objects (no `Field`/`Input` components); ~18 raw native
controls across the Area/Process/Fees/FAQ editors alone, plus title, category,
tags, content, and the enabled checkbox.

- **IA:** the richest concept here — kind (5 types) → typed fields per kind →
  scope (situations × channels) → generated retrieval chunks — is coherent
  *on its own*, but it now has **no discoverable entry point**. `agentRoutes.tsx`
  only reaches it via `/agent/behaviour/knowledge/new` or `/knowledge/:id`
  typed/bookmarked URLs; every in-app affordance (Add Knowledge, row Edit, the
  View panel's Edit button) opens Screen 2's lightweight panel instead. This
  is an orphaned screen, not a linked one.
- **Interaction:** internally fine (kind picker, repeatable-rows editor with
  add/remove, chunk preview after save) but unreachable, so none of it can be
  exercised from the rebuilt surface.
- **Content/copy:** plain and specific ("Each structured field becomes one
  retrieval fact…"), no engineering vocabulary.
- **Visual/tokens:** off-sheet. Hardcoded legacy CSS vars, not `--cm-*`:
  `var(--navy)` (cardTitle) and `var(--gold-2)` (ordinals) — both explicitly
  **DEAD in product UI** per `docs/DECISIONS.md` § Design & UI — plus
  `var(--muted)`, `var(--bg)`, `var(--line)`, `var(--text)`. Fixed
  `'DM Sans'`/`'DM Mono'` font-family literals bypass `--cm-font`.
- **A11y/responsive:** labels correctly wrap their controls; kind picker uses
  `role="radiogroup"`/`role="radio"`. But layout is fixed CSS Grid
  (`editorGrid: "2fr 1fr"`, `feeGrid: "1fr 1fr 1fr 1fr"`) with no media/
  container query — the 4-column fee-row grid will not survive 320px.

**VERDICT: redesign.** Correct concept, wrong body: on-token structured
editing needs to exist somewhere reachable, but this file is 24-marker legacy
debt, uses two DEAD tokens by name, and has no door into it from the screen
that replaced it.

## Forks (operator-only)

1. **Is the structured KB (area guides / fee tables / step lists / FAQ pairs)
   still wanted?** It has no path in from Behaviour today and Screen 2's
   editor silently can't touch it. Recommend: yes, keep it — rebuild
   `AgentKnowledgeDoc.tsx` on `--cm-*` and add a "More fields" (or similar)
   door from the row menu / View panel for any non-`article` kind, rather
   than retiring structured kinds outright.
2. **Channel-append semantics under each heading** (extra text can only be
   *added after* the base, never override it) has no in-UI explanation.
   Recommend a one-line hint under the "Add for one channel" control rather
   than changing the model itself — it was deliberately chosen and re-shipped
   twice already.
3. **All-or-nothing tab save** (one Edit/Save covers all 5 headings, locks
   other tabs) — recently reaffirmed. Recommend: keep as-is; flagging only in
   case the operator wants per-heading save now that Knowledge rows already
   save independently of this Edit mode.
