# Numu — Action Agent Policies / Actions / Approvals UI Fixes — Report

**Branch:** `feature/managed-agents` (uncommitted). **No schema changes.** All on existing `labels` / `label_options` / `agent_action_policies`. Make slugs + automations untouched.

---

## 1. Implementation summary

| # | Requirement | Status | How |
|---|---|---|---|
| 1 | "Action Agent Policies" = **per-action, assigned agents only** (no matrix) | ✅ | `matrix` → `agentPolicies(?action=)`; vertical list of only assigned agents + editable policy |
| 2 | 🤖 icon shows **only when the action has assigned agents** | ✅ | `<template x-if="r.policies.length">` around the icon |
| 3 | **Remove** the "Agent assignment moved…" block from Action Details | ✅ | Pointer block + its data fully deleted from `option-edit` |
| 4 | **Approvals** UI further polish | ✅ | Labeled filter groups (Status / Date range) + prior redesign |
| 5 | Sidebar: **Actions → Core, under Demos** | ✅ | Moved into `core` after Demos; `settings` group removed |
| 6 | Actions table shows **Arabic + English names**, **inline-editable** | ✅ | Two inline inputs per row → `updateOption` (partial) |
| 7 | **+ New Action** button + modal (AR / EN / slug / enabled / notify), tab-aware | ✅ | Modal → `storeOption` on the tab's action label |
| 8 | **Remove slug column** (slug internal, editable in modal) | ✅ | Slug dropped from table; present only in the create modal |
| 9 | Verification | ✅ | Renders + create smoke + 14 agent tests |

---

## 2. Action Agent Policies — before / after

```
BEFORE (matrix)                         AFTER (per-action)
all actions × all agents grid           🤖 on "reject"  →  Reject
"Not assigned" cells everywhere                            Committee Analysis Agent  [Blocked ▼]
                                                           Founder Response Agent    [Needs Approval ▼]
                                                           Intake Triage Agent       [Always Allow ▼]
```

- Shows **only** agents with an active policy for that one action — no unassigned, no other actions, no grid.
- Each row's policy dropdown saves instantly (AJAX → unified `actions.policy`).
- The 🤖 icon (and therefore this screen) only appears for actions that already have assigned agents.

---

## 3. Actions table — final shape

| Drag | Name (AR + EN, inline-edit) | Notify | Enabled | Policy (assigned only) | 👁 · 🤖* · 🗑 |

- **Names:** Arabic (bold) + English (muted), both editable in place → `PATCH labels/options/{id}` (`name_ar` / `name_en`), partial update (never wipes channels).
- **Slug column removed** — slug lives in the create modal + the option page only.
- **🤖** rendered only when `policies.length > 0`.
- **+ New Action** (top-right): modal with Arabic name, English name, slug (optional → auto-from-EN), Enabled, Notify → `POST labels/{actionLabel}/options`. The label is the **current tab's** action label (Startup vs Investor), so the action is created for the right type. Reuses the existing options architecture — **no new table**.

---

## 4. Schema / migrations

**None.** One controller endpoint (`storeOption`) gained an additive, backward-compatible `notifications_enabled` field so the modal's Notify persists on create. Nothing to migrate or seed.

---

## 5. API / route changes

| Route | Change |
|---|---|
| `admin.actions.matrix` | **Removed** |
| `admin.actions.agent-policies` (GET `?action=&tab=`) | **New** — per-action assigned-agents screen |
| `admin.labels.options.store` | now accepts `notifications_enabled` (additive) |
| `admin.actions.policy` (POST) | unchanged (unified set/`none`) |

---

## 6. Verification report

| Check | Result |
|---|---|
| Per-action policy screen — assigned only | ✅ `reject` → 6 assigned agents, editable; no grid/unassigned |
| 🤖 icon hidden when no agents | ✅ `x-if="r.policies.length"` |
| Option page — agent block removed | ✅ no `agents_moved` / `aa-pointer` in output |
| Sidebar order | ✅ Demos → **Actions** → (management) Logs |
| Actions table — AR + EN names, inline-editable | ✅ both inputs → `updateOption` |
| Slug column removed | ✅ table headers = Name / Notify / Enabled / Policy / actions |
| New Action create (tab-aware) | ✅ created startup action; `name_ar` + `notifications_enabled=false` persisted; cleaned up |
| Approvals redesign + labeled filters | ✅ renders |
| Agent test suite | ✅ **14 passed** (29 assertions) |
| Make slugs / automations / policies model | ✅ unchanged — no workflows broken |

**No existing workflows broken:** action slugs, `agent_action_policies`, label options, notification channels and Make triggers are all on the same tables/keys; only the admin UI changed.

---

## 7. Affected files

**Created:** `resources/views/admin/actions/agent-policies.blade.php`, this report.
**Modified:** `app/Http/Controllers/Admin/Agents/ActionsController.php` (`matrix`→`agentPolicies`), `app/Http/Controllers/Admin/LabelManagementController.php` (`storeOption` + `notifications_enabled`), `resources/views/admin/actions/index.blade.php` (AR/EN inline names, no slug col, conditional 🤖, New Action modal), `resources/views/admin/labels/option-edit.blade.php` (pointer removed), `resources/views/admin/approvals/index.blade.php` (labeled filter groups), `resources/views/components/admin/sidebar.blade.php` (Actions → Core), `routes/web.php` (agent-policies route), `lang/en/admin.php`, `lang/ar/admin.php`.
**Deleted:** `resources/views/admin/actions/matrix.blade.php`.
