Chat Handlers (CRUD API)
File: assistant/chat_handlers.go (351 lines)
HTTP handlers for persistent chat session management — creating, listing, renaming, deleting, and uploading files to chat sessions.
Endpoints
| Method | Path | Handler | Purpose |
|---|---|---|---|
| GET | /api/chats |
ListChatsHandler |
List chats for agent/user |
| POST | (rename) | RenameChatHandler |
Rename a chat session |
| POST | (delete) | DeleteChatHandler |
Delete chat + deregister |
| POST | (upload) | ChatUploadHandler |
File upload (32MB max) |
| GET | (file) | ChatFileHandler |
Serve attachment files |
Key Features
ListChatsHandler
- Requires
agentquery parameter - Resolves user via
resolveUserRoleFromRequest()orX-Dlan-Userheader - Reads
metadata.jsonfrom each chat directory - Returns sorted list of
ChatMetadataobjects
RenameChatHandler
- Updates both the in-memory
ChatTitleand the on-diskmetadata.json - Cross-user security check (requires matching username)
DeleteChatHandler
- Removes the entire chat directory from disk
- Deregisters from
activeChatSessionsmap
ChatUploadHandler
- 32MB maximum file size
- Cross-user security check
- Creates per-chat
uploads/subdirectory
ChatFileHandler
- Serves files with content-type detection (JPG, PNG, GIF, WEBP, SVG, PDF, MP3, OGG, MP4, TXT, HTML, CSS, JS, JSON)
- Path traversal protection
- Cross-user verification
See also: API Endpoints