summary system backend implementation

This commit is contained in:
Storme-bit
2026-04-19 06:50:24 -07:00
parent 15c1bec609
commit 2769f436fa
10 changed files with 210 additions and 106 deletions

View File

@@ -98,14 +98,15 @@ src/
│ ├── MessageBubble.jsx # Individual message bubble — renders markdown via react-markdown
│ ├── InfoPanel.jsx # Right panel — model selector and session metadata (slide-in)
│ ├── SessionModal.jsx # Modal for session rename, project assignment, delete
│ ├── ProjectModal.jsx # Modal for project create, edit, delete
│ ├── ProjectModal.jsx # Modal for project create/edit — name, description, colour,
│ │ # system prompt override; delete confirmation
│ ├── AllChatsView.jsx # Paginated session list with project indicator column
│ ├── AllProjectsView.jsx # Project tile grid with create/edit/delete; tile click navigates to ProjectView
│ ├── ProjectView.jsx # Individual project — conversations, new chat input, memory
│ │ # placeholder, user notes, ⋮ edit/delete menu
│ ├── MemoryView.jsx # Paginated, searchable, expandable, deletable episode viewer
│ └── SettingsView.jsx # Settings — Memory limits, Models (inference params, active
│ # model, context window), Service Health, Appearance placeholder
│ └── SettingsView.jsx # Settings — Memory, Models, Behaviour (system prompt),
│ # About, Appearance
├── index.css # Global reset, CSS variables, utility classes
└── main.jsx # React entry point
```
@@ -151,7 +152,7 @@ in the `ChatWindow` header.
| View | Component | Trigger |
|---|---|---|
| `'home'` | `HomeView` | Initial load; going back from chat with no history |
| `'home'` | `HomeView` | Initial load |
| `'chat'` | `ChatWindow` | Selecting a session; new chat; sending from HomeView |
| `'all-chats'` | `AllChatsView` | "All Chats →" or ☰ icon in collapsed rail |
| `'all-projects'` | `AllProjectsView` | "View Projects" button or ⊞ icon |
@@ -178,10 +179,9 @@ leaving `'home'` expands it.
- Centred textarea input — sending creates a new session and navigates to chat
- Quick action pills that populate the input without auto-sending
Sending from HomeView uses `handleHomeSend` in `App.jsx`, which calls
`createSession()` (returns the new session object), then immediately calls
`sendMessage` with the session passed directly as a parameter — avoiding the
React state settling race condition that would cause the message to be dropped.
`handleHomeSend` in `App.jsx` calls `createSession()` (which returns the new
session object), then immediately calls `sendMessage` with the session passed
directly — avoiding the React state settling race condition.
## CSS Architecture
@@ -283,6 +283,7 @@ mode, and delete confirmation in `confirm-delete` mode.
- `useContextMenu` dismisses on a `window` click listener
- Dynamic `updateSession` SQL builds `SET` clause from only the fields passed — prevents accidental overwrites
- `AllChatsView` pagination uses `CLIENT_DEFAULTS.PAGE_SIZE` (not `API_DEFAULTS.PAGE_SIZE` which doesn't exist)
- `Sidebar` groups sessions by project — `key` must be passed directly to `<SessionRow key={...}>`, not included in the props spread object
## Sidebar — Session Grouping
@@ -302,11 +303,27 @@ The isolated toggle has been removed from `ProjectModal`.
`useProjects` fetches the project list from `GET /projects` on mount and
exposes `refreshProjects` for keeping the sidebar in sync after mutations.
`ProjectModal` handles create, edit, and delete confirmation. Fields: name
(required), description (optional), colour picker.
### ProjectModal Fields
Clicking a project tile in `AllProjectsView` calls `onSelectProject` then
navigates to `'project'`.
- **Name** (required)
- **Description** (optional)
- **Colour** — picker from six preset hex values
- **System Prompt** (optional) — overrides the global system prompt for all
conversations in this project. Leave blank to use the global default.
Stored as `system_prompt` (snake_case) matching the SQLite column.
`Enter` key does not submit — textarea fields make it ambiguous. Save button only.
`handleSave` in `ProjectView` destructures `system_prompt` (snake_case) to
match what `ProjectModal` sends. `updateProject` in `orchestration.js` uses
a passthrough pattern — spreads all fields into the request body.
### System Prompt Hierarchy
System prompt resolution in `chat/index.js` (orchestration):
1. `project.system_prompt` — if set on the project (highest priority)
2. `settings.systemPrompt` — global setting from `settings.json`
3. `ORCHESTRATION.SYSTEM_PROMPT` — hardcoded constant in `@nexusai/shared` (last resort)
### ProjectView
@@ -322,9 +339,8 @@ navigates to `'project'`.
saved value (`savedNotes` state tracks the baseline, not `initialNotes`)
`updateProject` in `orchestration.js` uses a passthrough pattern — spreads
all fields directly into the request body, only transforming `isolated` if
present. This allows partial updates like `{ notes }` without clobbering
other fields.
all fields directly into the request body. This allows partial updates like
`{ notes }` or `{ system_prompt }` without clobbering other fields.
For memory isolation behaviour, see `memory-isolation.md`.
@@ -337,9 +353,9 @@ buttons during in-flight requests.
`SettingsView` receives `settings`/`saveSetting`/`saving` from a single
`useSettings()` call at the top level and passes them as props to
`ModelsSection` and `ModelsFolderSetting` — avoiding triple fetch on mount.
`modelProps` (context window, loaded model) is fetched once in `App.jsx` and
passed down as a prop, eliminating a duplicate fetch on every settings open.
`ModelsSection`, `ModelsFolderSetting`, and `SystemPromptSetting` — avoiding
triple fetch on mount. `modelProps` (context window, loaded model) is fetched
once in `App.jsx` and passed down as a prop.
`SettingsView` is organised into sections:
@@ -347,6 +363,9 @@ passed down as a prop, eliminating a duplicate fetch on every settings open.
- **Models** — models folder path, temperature, repeat penalty, Top-P, Top-K,
active model dropdown, read-only model info panel (file, size, context window,
loaded model from llama-server)
- **Behaviour** — global system prompt textarea (`SystemPromptSetting`). Save
button appears only when content differs from `savedPrompt` state. Saving an
empty string sends `null` which reverts to the hardcoded default.
- **About** — service health check panel, version
- **Appearance** — theme (coming soon)