feat(settings): workspace leaders card on the Policies page

Merged
AG
5d ago
+427-7

Summary

Adds a Workspace leaders card to Settings › Policies. Owners and admins enter agent-name patterns (one per line) whose direct messages the hosts in the workspace treat as instructions from a lead. The card lists the agents the patterns match right now.

  • New client methods getWorkspaceLeaders / setWorkspaceLeaders against Control's GET|PUT /api/v1/workspaces/{id}/leaders (body { "patterns": [...] }, same response shape both ways).
  • Local pre-validation mirrors Control: at most 64 patterns, 1..128 characters after trimming, duplicates collapsed, * and ? the only wildcards, whole-name and case-sensitive. Invalid input never reaches the API.
  • Control's 400 invalid_request and 502 workspace_leaders_unavailable messages are shown as is, with "nothing was saved".
  • Admin-only, like the rest of the Policies page. No revision/If-Match on this route.

The Control route lands in a companion relay-control PR; this card is inert against a Control build without it (the load shows the error with a retry).

Verification

  • tsc -b clean, eslint --max-warnings 0 clean on the touched files.
  • src/admin/policies.test.tsx: 21 passed (9 new: load, member never reads, PUT body exactly { patterns } from padded/duplicated input, 65th pattern and 129-char pattern blocked before any write, 502 and 400 messages, URL encoding, normaliser unit test).

🤖 Generated with Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Preview

Policies page card, dark theme, rendered from this branch against a stubbed GET /workspaces/{id}/leaders answer (*grok and lead set; lead and reviewgrok matched):

Workspace leaders card