add generation cancellation middleware and refactor chat/message workflows to support HTTP client disconnections
CI / check (22) (push) Failing after 4m54s
CI / check (24) (push) Failing after 4m54s

This commit is contained in:
2026-10-05 23:21:42 +02:00
parent c48e1b17c4
commit 1c0f06716e
17 changed files with 620 additions and 172 deletions
+12 -1
View File
@@ -29,6 +29,7 @@ on Node 22 and 24.
- `npm run dev`: run the server with Node watch mode.
- `npm run lint`: syntax-check the backend and browser modules.
- `npm test`: run API tests with Node's built-in test runner.
- `npm run test:browser`: serve the navigation regression harness locally; open the printed URL in a browser. The same cases run with a lightweight DOM fixture in `npm test`.
- `npm run user:role -- <username> <user|admin>`: assign or revoke a role from the server console.
## Administrative access
@@ -75,7 +76,7 @@ Duplicate registrations, including concurrent inserts, return HTTP 409 with
- `MODEL_UNLOAD_AFTER_MS`: delay before idle local request bookkeeping is cleared. Model unloading is managed by Ollama through `OLLAMA_KEEP_ALIVE`.
- `MODELS_CACHE_TTL_MS`: model list cache TTL.
- `AUTH_RATE_LIMIT_*`: rate-limit window and thresholds for registration/login.
- `CHAT_RATE_LIMIT_*`: rate-limit window and thresholds for chat and retry endpoints.
- `CHAT_RATE_LIMIT_*`: shared rate-limit window and thresholds for chat, retry, roleplay openers, marketplace openers, and edit/resend endpoints.
- `RATE_LIMIT_CLEANUP_INTERVAL_MS`: interval for pruning stale in-memory rate-limit buckets.
- `DROP_LEGACY_CHATS`: when `true`, migrate any legacy `chats` table into `chat_sessions` / `chat_messages` and remove the old table.
@@ -107,6 +108,11 @@ accepts older JSON exports, which contain attachment references only and reconne
images only when those IDs already belong to the importing account. Archives are
limited to 250 MB uncompressed, and each image must meet the destination's upload limit.
Imports remap persona, chat and message IDs, including template, memory, continuity,
branch, retry and summary references. References absent from the import are left
unassigned. Legacy histories without parent fields are restored as ordered message
chains; explicit branch roots remain separate. Unset generation settings remain unset.
`CHAT_LIMIT` defaults to 10 active chats per account. Archived chats remain available
without using an active slot; restoring one requires a free slot.
@@ -215,6 +221,11 @@ request still uses `stream: true` and the existing capability-checked reasoning
Stop/disconnect cancels the current vision or final generation request. Logging includes
IDs, sizes, types and cache events only, never images/Base64/private analysis.
Roleplay and marketplace initialization use the same chat generation lock and
cancellation tracking as other replies. Concurrent initializations return HTTP 409
and save at most one opener. Edit/resend holds the source chat's lock while generating
its branch, and Stop can cancel it through the source chat or the new branch.
Dependencies added: `multer` (bounded multipart handling), `sharp` (content detection,
dimensions and full image decoding). Install through the normal `npm install`/`npm ci`
workflow, including Sharp's platform-specific optional dependencies in Docker. The