|
| 1 | +# Plan: Isolate Memories Page + Default Memory Seeding |
| 2 | + |
| 3 | +## Context |
| 4 | +The `MemorySettings` component currently lives inside the Settings page alongside model, API key, and sandbox settings. Memories is a distinct feature (with its own CRUD pages) and deserves its own top-level page and sidebar nav entry. Additionally, new users currently start with an empty memory store β we need to seed 6 default memories on registration and provide a manual seeder script. |
| 5 | + |
| 6 | +--- |
| 7 | + |
| 8 | +## Part 1: Frontend β Memories Page & Sidebar Nav |
| 9 | + |
| 10 | +### 1. Create Memories index page |
| 11 | +**File:** `frontend/src/pages/memories/index.tsx` (new) |
| 12 | + |
| 13 | +Wrap the existing `MemorySettings` component in `ChatLayout` with `ChatNav`, matching the settings page pattern. The `MemorySettings` component is reused as-is. |
| 14 | + |
| 15 | +```tsx |
| 16 | +export default function MemoriesIndexPage() { |
| 17 | + return ( |
| 18 | + <ChatLayout> |
| 19 | + <div className="flex-1 flex flex-col min-h-0 overflow-hidden"> |
| 20 | + <ChatNav sidebarTrigger={<SidebarTrigger />} /> |
| 21 | + <div className="flex-1 min-h-0"> |
| 22 | + <ScrollArea className="h-full"> |
| 23 | + <div className="container max-w-4xl mx-auto py-8 space-y-8 px-4"> |
| 24 | + <div> |
| 25 | + <h1 className="text-3xl font-bold">Memories</h1> |
| 26 | + <p className="text-muted-foreground">Manage what the AI remembers about you.</p> |
| 27 | + </div> |
| 28 | + <MemorySettings /> |
| 29 | + </div> |
| 30 | + </ScrollArea> |
| 31 | + </div> |
| 32 | + </div> |
| 33 | + </ChatLayout> |
| 34 | + ); |
| 35 | +} |
| 36 | +``` |
| 37 | + |
| 38 | +### 2. Add `/memories` route |
| 39 | +**File:** `frontend/src/routes/AppRoutes.tsx` |
| 40 | + |
| 41 | +- Import `MemoriesIndexPage` from `@/pages/memories` |
| 42 | +- Add `<Route path="/memories" ...>` wrapped in `<PrivateRoute>`, next to existing `/memories/create` and `/memories/:memoryId/edit` routes |
| 43 | + |
| 44 | +### 3. Add sidebar nav link |
| 45 | +**File:** `frontend/src/components/drawers/app-sidebar.tsx` |
| 46 | + |
| 47 | +- Import `Brain` from `lucide-react` |
| 48 | +- Add a `SidebarGroup` with `Link to="/memories"` using the same pattern as the Assistants link (line 862-875) |
| 49 | +- Place it after the Assistants link, before `ProjectsCollapsibleGroup` |
| 50 | + |
| 51 | +### 4. Update memory create/edit back-navigation |
| 52 | +**Files:** |
| 53 | +- `frontend/src/pages/memories/create.tsx` β change `navigate("/settings")` β `navigate("/memories")` (2 occurrences: line 35, line 60) |
| 54 | +- `frontend/src/pages/memories/edit.tsx` β change `navigate("/settings")` β `navigate("/memories")` (4 occurrences: lines 49, 63, 88, 133) |
| 55 | + |
| 56 | +### 5. Remove MemorySettings from Settings page |
| 57 | +**File:** `frontend/src/pages/settings/index.tsx` |
| 58 | + |
| 59 | +- Remove `<MemorySettings />` (line 33) and its import (line 4) |
| 60 | + |
| 61 | +--- |
| 62 | + |
| 63 | +## Part 2: Backend β Default Memory Seeding |
| 64 | + |
| 65 | +### Default Memories (6 enabled files from admin user) |
| 66 | +| ID | Description | |
| 67 | +|---|---| |
| 68 | +| `SOUL.md` | Core personality/values | |
| 69 | +| `IDENTITY.md` | Self-identity template | |
| 70 | +| `MEMORY.md` | Long-term memory template | |
| 71 | +| `USER.md` | User info template | |
| 72 | +| `TOOLS.md` | Environment-specific notes | |
| 73 | +| `AGENTS.md` | Workspace instructions | |
| 74 | + |
| 75 | +### 6. Create default memories module |
| 76 | +**File:** `backend/src/constants/default_memories.py` (new) |
| 77 | + |
| 78 | +Define a list of `dict` entries with `id` and `content` for each of the 6 default memories. Content copied from the admin user's current memories. |
| 79 | + |
| 80 | +### 7. Create seed_default_memories utility |
| 81 | +**File:** `backend/src/utils/memory_seed.py` (new) |
| 82 | + |
| 83 | +```python |
| 84 | +from src.constants.default_memories import DEFAULT_MEMORIES |
| 85 | +from src.repos.memory_repo import MemoryRepo |
| 86 | + |
| 87 | +async def seed_default_memories(user_id: str, store) -> None: |
| 88 | + """Seed default memories for a new user. Skips if user already has memories.""" |
| 89 | + repo = MemoryRepo(user_id, store) |
| 90 | + existing, _ = await repo.list(limit=1) |
| 91 | + if existing: |
| 92 | + return # User already has memories |
| 93 | + for mem in DEFAULT_MEMORIES: |
| 94 | + await repo.create(content=mem["content"], path=mem["id"]) |
| 95 | +``` |
| 96 | + |
| 97 | +### 8. Hook into registration endpoints |
| 98 | +**File:** `backend/src/routes/v0/auth.py` |
| 99 | + |
| 100 | +- Add `Request` param + `get_store` dependency to the `register` endpoint |
| 101 | +- After user creation (line 44), call `await seed_default_memories(str(user.id), store)` |
| 102 | +- Same for OAuth callback (after line 169 where new OAuth users are created) |
| 103 | + |
| 104 | +### 9. Create memory seeder script |
| 105 | +**File:** `backend/seeds/memory_seeder.py` (new) |
| 106 | + |
| 107 | +Standalone script (following `user_seeder.py` pattern) that seeds default memories for all existing users who have no memories. Uses `AsyncPostgresStore` directly. |
| 108 | + |
| 109 | +### 10. Add Makefile target |
| 110 | +**File:** `backend/Makefile` |
| 111 | + |
| 112 | +Add `seeds.memory` target after `seeds.user`: |
| 113 | +```makefile |
| 114 | +seeds.memory: |
| 115 | + uv run python -m seeds.memory_seeder --env-file $(ENV_FILE) |
| 116 | +``` |
| 117 | + |
| 118 | +--- |
| 119 | + |
| 120 | +## Files Modified |
| 121 | + |
| 122 | +| File | Action | |
| 123 | +|------|--------| |
| 124 | +| `frontend/src/pages/memories/index.tsx` | Create (new page) | |
| 125 | +| `frontend/src/routes/AppRoutes.tsx` | Edit (add route) | |
| 126 | +| `frontend/src/components/drawers/app-sidebar.tsx` | Edit (add nav link) | |
| 127 | +| `frontend/src/pages/memories/create.tsx` | Edit (update redirects) | |
| 128 | +| `frontend/src/pages/memories/edit.tsx` | Edit (update redirects) | |
| 129 | +| `frontend/src/pages/settings/index.tsx` | Edit (remove MemorySettings) | |
| 130 | +| `backend/src/constants/default_memories.py` | Create (memory content) | |
| 131 | +| `backend/src/utils/memory_seed.py` | Create (seed utility) | |
| 132 | +| `backend/src/routes/v0/auth.py` | Edit (hook seed on register) | |
| 133 | +| `backend/seeds/memory_seeder.py` | Create (manual seeder) | |
| 134 | +| `backend/Makefile` | Edit (add seeds.memory target) | |
| 135 | + |
| 136 | +## Existing Code Reused |
| 137 | +- `MemorySettings` component: `frontend/src/components/settings/MemorySettings.tsx` |
| 138 | +- `MemoryRepo.create()`: `backend/src/repos/memory_repo.py:17` |
| 139 | +- `get_store` dependency: `backend/src/services/db.py:79` |
| 140 | +- Sidebar link pattern: `frontend/src/components/drawers/app-sidebar.tsx:862-875` |
| 141 | +- Seeder script pattern: `backend/seeds/user_seeder.py` |
| 142 | + |
| 143 | +## Verification |
| 144 | +1. `cd frontend && npm run build` β no build errors |
| 145 | +2. Navigate to `/memories` β shows full memory list with search, pagination, CRUD |
| 146 | +3. Sidebar shows "Memories" link with Brain icon, navigates correctly |
| 147 | +4. `/settings` no longer shows memories section |
| 148 | +5. Memory create/edit back buttons navigate to `/memories` |
| 149 | +6. Register a new user β verify 6 default memories are seeded |
| 150 | +7. `make seeds.memory` β seeds defaults for existing users without memories |
| 151 | +8. `cd backend && make test` β all tests pass |
0 commit comments