# Numu — Actions, AI Agents, Approvals & UI/UX Refactoring — Implementation Report

**Branch:** `feature/managed-agents` (uncommitted working tree)
**Scope:** Reorganize Actions/Drop-Lists UI, central Actions screen, multi-agent action assignment, typed AI Agents (Startup/Investor), Approvals date filters, nav changes. **Reuses** the existing Labels/Options, agent_action_policies, ActionPolicyService and Approvals stacks. **One** additive DB change.

---

## 1. Implementation summary

| # | Requirement | Status | How (reuse) |
|---|---|---|---|
| 1 | Sidebar: **Actions → Drop Lists**, **Action Details → Actions** | ✅ | Renamed nav labels + route/controller/view `action-details`→`actions` |
| 2 | **Actions screen** redesign — Startups/Investors tabs + table (drag · name · Notify · Enabled · Policy · View · Delete) | ✅ | New `actions/index.blade.php`; drag/toggle/delete call the **existing** Label option endpoints |
| 3 | **Action Details** page = the `/admin/labels/options/{id}` page + new **Allowed Agents** (multi-agent) + per-agent policy | ✅ | Extended `option-edit.blade.php`; reuses `agent_action_policies` |
| 4 | **Separate Actions** from other Drop Lists (UI-only, no DB change) | ✅ | `listLabels` excludes `key='action'`; Actions get their own screen |
| 5 | **AI Agents** screen — Startup/Investor tabs + Agent Type selector on create | ✅ | `agent_type` column + tabs + radio selector |
| 6 | **Seed 7 canonical startup agents** + their actions | ✅ | `AgentsSeeder` (typed, idempotent) + action assignments |
| 7 | **Investor agents** — none seeded, UI-creatable | ✅ | Type selector + empty-state guidance |
| 8 | **AI Agents** out of sidebar → user-menu dropdown (with Notes/Links) | ✅ | Added to `navbar.blade.php`, removed from `sidebar.blade.php` |
| 9 | **Approvals** From/To `created_at` filters (URL params, combined) | ✅ | `ApprovalController::index` + filter bar |
| 10 | UI/UX polish of the 5 screens | ✅ | Tabs, switches, badge policies, modern cards, empty states |
| 11 | Verification | ✅ | Renders + 14 agent tests + end-to-end smokes (below) |

---

## 2. Database changes

**One additive migration** — `2026_06_27_110000_add_agent_type_to_agents.php`:
- `agents.agent_type` `string(16)` default **`startup`**, indexed. Backward-compatible (existing agents → `startup`).

**No other schema change.** Drop-Lists separation, multi-agent assignment, Actions table and Approvals filters all run on existing tables (`labels`, `label_options`, `agent_action_policies`, `agent_approval_requests`).

**Data sync (seeder, not schema):** the canonical startup action options missing locally (`request_more_info`, `move_to_initial_dd`, `move_to_committee`, `move_to_prelist`, `move_to_listing`) are inserted by `AgentsSeeder` to match production — existing slugs reused, no new definitions.

---

## 3. API / route changes

| Route | Change |
|---|---|
| `admin.action-details.index/policy` | **Renamed** → `admin.actions.index` / `admin.actions.policy` |
| `admin.actions.agents` | **New** — sync an action's Allowed Agents (assign/unassign + per-agent policy) |
| `admin.agents.index` | `tab` (startups/investors) + `agent_type` filter |
| `admin.agents.store` | now requires `agent_type` (startup/investor) |
| `admin.approvals.index` | new `date_from` / `date_to` query params (combine with `status`) |
| Label option endpoints (`labels.options.reorder/update/destroy/show`) | **Unchanged** — reused by the Actions table |

No MCP / external API changes. Make integrations untouched (same action slugs, same `agent_action_policies`).

---

## 4. UI changes

- **Drop Lists** (`labels/index`): renamed; action labels no longer listed (moved to Actions).
- **Actions** (`actions/index` — new): Startups/Investors tabs; table with drag-reorder, Action name+slug, **Notify** switch, **Enabled** switch, **Policy** badges (per assigned agent), **View** (eye → option page) and **Delete**; toast feedback; empty state.
- **Action Details** (`labels/option-edit`): added **AI Agents · Allowed Agents** card — every agent of the action's type with a policy select (`Not assigned` / Always Allow / Needs Approval / Blocked). Multi-agent. Existing General/Notification/Automation behavior preserved.
- **AI Agents** (`agents/index`): Startup/Investor tabs with counts; **Agent Type** radio on the register form (defaults to the active tab); type-aware empty states.
- **Approvals** (`approvals/index`): From/To date bar that combines with the status pills; Clear button; status pills preserve the date range; date range overrides default pending-only scope.
- **Navbar**: AI Agents link in the top-right user-menu (beside Notes). **Sidebar**: AI Agents removed; “Actions”→“Drop Lists”, “Action Details”→“Actions”.

---

## 5. Migration summary

```
php artisan migrate          # 2026_06_27_110000_add_agent_type_to_agents  → DONE
php artisan db:seed --class=AgentsSeeder
  # syncs 8 canonical startup action options (adds the 5 missing)
  # upserts 7 typed startup agents + their action assignments
  # soft-removes stale seed agents not in the canonical list
```

**7 seeded startup agents → actions**

| Agent | Actions |
|---|---|
| Intake Triage Agent | move_to_review, reject |
| Pre-screen Agent | request_more_info, request_meeting, reject |
| Founder Response Analysis Agent | request_meeting, reject |
| Screening Call Analysis Agent | move_to_initial_dd, reject |
| Initial Due Diligence Agent | move_to_committee, reject |
| Committee Analysis Agent | move_to_prelist, reject |
| Investment Memo Agent | move_to_listing |

---

## 6. Verification report

| Check | Result |
|---|---|
| Migration `agent_type` applied | ✅ column present, indexed |
| Seeder — 7 typed startup agents + correct actions | ✅ verified each agent's action set |
| Canonical action options synced | ✅ 8/8 present (5 added) |
| Stale seed agents removed | ✅ 0 remaining |
| Actions screen renders (both tabs) | ✅ 14 startup / 7 investor actions |
| Action ordering / Notify / Enabled / Delete | ✅ reuse `labels.options.reorder/update/destroy` (partial-update safe — methods not wiped) |
| Action Details — Allowed Agents | ✅ lists all type agents; `move_to_review` → `intake_triage` assigned; unassign via `effective_to` |
| Multi-agent assignment | ✅ `reject` shows **6** agents |
| AI Agents tabs + type selector | ✅ startup=7 / investor=0; investor agent create persists `agent_type=investor` |
| Approvals date filters (combined + URL) | ✅ renders with `date_from`/`date_to`+`status` |
| Drop Lists excludes actions | ✅ no `action` key in startup/investor label lists |
| AI Agents in user-menu, removed from sidebar | ✅ navbar link present |
| No stale `action-details` references | ✅ none in app/resources/routes |
| Agents test suite | ✅ **14 passed** (29 assertions) |
| Labels/options + automations + Make slugs | ✅ untouched (no DB/logic change) |

**Pre-existing, unrelated failures** (present before this work): `ExampleTest` (`/`→302) and the guarded `drop_legacy_name_from_investors` migration — not caused by these changes.

---

## 7. Files

**Created:** `database/migrations/2026_06_27_110000_add_agent_type_to_agents.php`, `app/Http/Controllers/Admin/Agents/ActionsController.php`, `resources/views/admin/actions/index.blade.php`, this report.
**Modified:** `app/Models/Agent.php`, `database/seeders/AgentsSeeder.php`, `app/Http/Controllers/Admin/Agents/AgentConsoleController.php`, `app/Http/Controllers/Admin/Agents/ApprovalController.php`, `app/Http/Controllers/Admin/LabelManagementController.php` (showOption agent data + Drop-Lists exclusion), `resources/views/admin/agents/index.blade.php`, `resources/views/admin/approvals/index.blade.php`, `resources/views/admin/labels/option-edit.blade.php`, `resources/views/components/admin/sidebar.blade.php`, `resources/views/components/admin/navbar.blade.php`, `resources/views/admin/agents/show.blade.php`, `routes/web.php`, `lang/en/admin.php`, `lang/ar/admin.php`.
**Deleted:** `app/Http/Controllers/Admin/Agents/ActionDetailsController.php`, `resources/views/admin/action-details/`.
