feat(frontend): Phase 9 memory UI and admin policy controls

↗ view on GitHub · Claude · 2026-05-16 · 792fc3ec

Backend additions:

- GET /me now returns a policy slice { allow_memory,
  memory_max_per_user, memory_max_chars, allow_user_instructions }
  so frontend panels can decide whether to render without an extra
  request.
- PATCH /admin/org-settings accepts allow_memory,
  memory_max_per_user, memory_max_chars, and use_layered_prompt.
  Memory cap and char limits are bounds-checked at the route
  layer (1-500 and 1-2000 respectively) so admins see a clean 400
  rather than a DB CHECK violation.

Frontend additions:

- frontend/src/app/(pages)/account/MemoriesPanel.tsx: renders
  nothing when allow_memory is false at the org level. When on,
  shows the list ordered as the injector orders it (pinned first,
  then by last_used_at descending), with add/edit/pin/unpin/delete
  actions and a confirm-twice Clear all. Export downloads the JSON
  blob from /me/memories/export.
  - Pin toggle is disabled when pinned count is at 10 (server-side
    trigger enforces, frontend just prevents the click).
  - Char counter and Add button are gated on the org's
    memory_max_chars and memory_max_per_user.
- Mounted on the existing /account page below
  CustomInstructionsPanel.
- shared/types.ts AssistantEvent union gains memory_saved with
  preview text.
- useAssistantChat.ts demuxes the SSE memory_saved event into
  pushEvent.
- AssistantMessage.tsx renders the memory_saved event as a small
  amber pill linking to /account ("🧠 Memory saved: ..."). No
  separate component; the pill is plain markup colocated with the
  other event renderers.

Admin policy page (/admin/policy):

- New "Memory" section with: allow_memory toggle,
  memory_max_per_user input, memory_max_chars input, and a
  use_layered_prompt toggle. Inline help text explains the
  layered-prompt switch is the emergency rollback for the new
  assembly chain and should be left on unless troubleshooting.

pipApi.ts OrgSettings interface extended with allow_memory,
memory_max_per_user, memory_max_chars, use_layered_prompt;
adminUpdateOrgSettings payload widens to accept the same.

Type-check: both backend and frontend `tsc --noEmit` pass clean.
Repository cpatpa/PIP
Author Claude <noreply@anthropic.com>
Authored
Parents 085a9d78
Stats 9 files changed , +623 , -1
Part of Phase 9 - persistent user memory and layered system-prompt assembly

Capture this commit into my fork

Download a Markdown prompt that tells Claude how to port this exact commit into your working tree. Run it via claude -p < capture-commit-792fc3ec.md from inside the repo you want the change in.

⬇ Download capture-commit-792fc3ec.md