Skip to content

ui: optionally store conversations and settings on disk via storage adapters - #39

Draft
allozaur wants to merge 2 commits into
allozaur/feat/model-configurationfrom
allozaur/feat/ui-server-storage
Draft

allozaur wants to merge 2 commits into
allozaur/feat/model-configurationfrom
allozaur/feat/ui-server-storage

Conversation

@allozaur

@allozaur allozaur commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

Overview

Conversations, groups, projects, prompts and settings can optionally be stored on disk by llama-server instead of in the browser, so they survive clearing browser data and are shared across browsers and ports. Storage goes through adapters, with llama-server as the default, so other backends (Postgres via Supabase or Neon, PocketBase, ...) can be added.

Additional information

Outside the work-in-progress stack on the fork, based on allozaur/feat/model-configuration (#36), which sits on the prompt library (#29): storage needs both under it. Its diff is only this layer (two commits), and its files are under ui/apps/chat now that the stack starts with the move to ui/ (#54). Since 13 November MCP as an extension (#61) is below it, and the extensions' on/off choices are kept through the preferences service with the rest of the user's settings.

Rebased onto the new structure on 12 November. Master's group work came after this layer was written, so three pieces of it are ported onto the storage backend: a fork keeps its source's group, an import assigns conversations to groups, and moving conversations into or out of a group. Groups list by creation, as on master.

The storage work from ggml-org#31361, rebased onto this stack and extended to the groups, projects and prompts the stack adds. The upstream PR and its branch are unchanged.

Experimental and off by default: anyone who can reach the server can read the stored data. Each browser origin picks its storage once in Settings → Import/Export → Storage. Known gaps: every save rewrites the whole conversation document, attachments included, and --connect tunnel peers can reach the storage routes.

Server
  • --ui-storage (env LLAMA_ARG_UI_STORAGE) enables it; --ui-storage-dir PATH sets the directory and implies it. The default is llama.cpp/ui in the platform data directory.
  • GET /storage/conversations, GET|POST|DELETE /storage/conversations/:id: one JSON file per conversation, { rev, conv, messages }. A write based on a stale rev gets 409.
  • GET|POST /storage/settings and GET|POST /storage/records/:kind (groups, projects, prompts, and any later kind): merged per key or id. A record whose id doesn't match its key gets 400.
  • All routes return 403 with the flag off; /props reports ui_storage. In router mode only the router serves storage.
What changed
  • First commit, no behaviour change: tree rules move out of DatabaseService into utils/conversation-tree, and rows go through a StorageBackend (IdbBackend for IndexedDB). That now includes groups, projects and prompts as "records", along with the stack's schema versions. Every localStorage access, including the stack's new ones in ui, servers, models and ModelsManager/utils, goes through PreferencesService, which marks each key as user data or device state. Model overrides and dismissed recommended servers sync; the selected model, active server and sidebar layout stay per device.
  • StorageAdapter (types/storage.d.ts) is the eight-method contract. DocumentStoreBackend implements StorageBackend on top of any adapter: it caches documents and records, batches the writes of a transaction, rolls them back when it fails, and on a conflict refetches and replays its own edits.
  • The llama-server adapter always talks to the server serving the UI (LOCAL_BACKEND_ID), whichever server chats target, and Settings offers it from serverStore.localProps. Storage activates in hydrateStores, before settings are read.
  • Switching copies this browser's conversations, records and settings, keeping what the store already holds; the API key stays in the browser. docs/storage-adapters.md sketches Postgres and PocketBase adapters, untested.
Commits (2)
  • ui: introduce storage backend and preferences service
  • ui: store conversations and settings through storage adapters
Testing
  • After the rebase: type-check passes with 0 errors, 840 unit and 310 client tests pass, including the IndexedDB tests for groups, projects and prompts on the ported code, and llama-server compiles. Prettier flags two files of the layers below, not this one's. The story tests and the E2E suite were not rerun.
  • curl: conversation create and stale-revision 409, record merge and delete per id, 400 on an id mismatch.
  • In the browser: a group and a prompt made in browser storage were copied on switch; in server storage a new project and a group rename went straight to disk, and storage settings loaded before /props.
  • Not tried in the browser: a second port, and the switch dialog on this stack (the switch ran through the same service call).

Requirements

@allozaur
allozaur added this pull request to stack #37 November 2, 2026 16:17
@allozaur allozaur changed the title allozaur/feat/ui server storage ui: optionally store conversations and settings on disk via storage adapters Nov 2, 2026
@github-actions github-actions Bot added documentation Improvements or additions to documentation server server/ui labels Nov 2, 2026
@allozaur
allozaur force-pushed the allozaur/feat/model-configuration branch from 1f901ba to 14cf1da Compare November 3, 2026 10:02
@allozaur
allozaur removed this pull request from stack #37 November 3, 2026 10:02
@allozaur
allozaur force-pushed the allozaur/feat/model-configuration branch 12 times, most recently from 73c3fba to eb7c0b4 Compare November 10, 2026 09:50
@allozaur
allozaur force-pushed the allozaur/feat/ui-server-storage branch from a2d3021 to 2bb6f89 Compare November 10, 2026 09:50
@allozaur
allozaur force-pushed the allozaur/feat/model-configuration branch 7 times, most recently from d9e5ba2 to 44e3ef4 Compare November 12, 2026 01:29
allozaur added a commit that referenced this pull request Nov 12, 2026
Replayed onto develop: only the PR's own two commits, its branch sits on a stale copy of the stack.
@allozaur
allozaur force-pushed the allozaur/feat/model-configuration branch from 44e3ef4 to 9c8d0f1 Compare November 12, 2026 11:16
@allozaur
allozaur force-pushed the allozaur/feat/ui-server-storage branch from 2bb6f89 to b309451 Compare November 12, 2026 11:16
@allozaur
allozaur force-pushed the allozaur/feat/ui-server-storage branch from 1871c0b to 5adf074 Compare November 16, 2026 11:28
@allozaur
allozaur force-pushed the allozaur/feat/model-configuration branch 2 times, most recently from 15abee0 to 770a302 Compare November 16, 2026 11:43
@allozaur
allozaur force-pushed the allozaur/feat/ui-server-storage branch from 5adf074 to 032f756 Compare November 16, 2026 11:43
@allozaur
allozaur force-pushed the allozaur/feat/model-configuration branch from 770a302 to 0bf250a Compare November 16, 2026 11:56
@allozaur
allozaur force-pushed the allozaur/feat/ui-server-storage branch from 032f756 to 1ddd03c Compare November 16, 2026 11:56
@allozaur
allozaur force-pushed the allozaur/feat/model-configuration branch from 0bf250a to b73f54a Compare November 16, 2026 12:07
@allozaur
allozaur force-pushed the allozaur/feat/ui-server-storage branch 2 times, most recently from 7cae7fa to fe20463 Compare November 16, 2026 12:13
@allozaur
allozaur force-pushed the allozaur/feat/model-configuration branch from b73f54a to 45df633 Compare November 16, 2026 12:13
@allozaur
allozaur force-pushed the allozaur/feat/ui-server-storage branch 2 times, most recently from ec2061d to 5b5c81e Compare November 16, 2026 13:09
@allozaur
allozaur force-pushed the allozaur/feat/model-configuration branch from 09603b8 to 7c32001 Compare November 16, 2026 13:44
@allozaur
allozaur force-pushed the allozaur/feat/ui-server-storage branch from 5b5c81e to 6cd48af Compare November 16, 2026 13:44
@allozaur
allozaur force-pushed the allozaur/feat/model-configuration branch from 7c32001 to 6025c8f Compare November 16, 2026 13:52
@allozaur
allozaur force-pushed the allozaur/feat/ui-server-storage branch from 6cd48af to 1e05140 Compare November 16, 2026 13:52
@allozaur
allozaur force-pushed the allozaur/feat/model-configuration branch from 6025c8f to dcbe7d9 Compare November 16, 2026 16:12
@allozaur
allozaur force-pushed the allozaur/feat/ui-server-storage branch 3 times, most recently from 9e2a5a5 to c91085d Compare November 16, 2026 17:36
@allozaur
allozaur force-pushed the allozaur/feat/model-configuration branch from 140894c to a245d3d Compare November 16, 2026 17:36
@allozaur
allozaur force-pushed the allozaur/feat/ui-server-storage branch 3 times, most recently from 7164bfa to ee39039 Compare November 17, 2026 05:21
@allozaur
allozaur force-pushed the allozaur/feat/model-configuration branch 2 times, most recently from f13c596 to f8ede25 Compare November 17, 2026 05:55
@allozaur
allozaur force-pushed the allozaur/feat/ui-server-storage branch from ee39039 to 0b63c53 Compare November 17, 2026 05:55
Split DatabaseService into pure tree rules (utils/conversation-tree) and a
row-level StorageBackend, with IdbBackend holding the Dexie code. Route
localStorage access through PreferencesService, which also classifies keys
as user data or device-local state. No behaviour change.

Assisted-by: Claude (Opus 5.5 Medium)
Add an opt-in llama-server document store (--ui-storage, --ui-storage-dir)
that keeps one JSON file per conversation under the platform data directory
and serves it on /storage/conversations, rejecting writes based on a stale
revision with 409. Settings (/storage/settings) and records such as groups,
projects and prompts (/storage/records/:kind) are merged per key or id.

In the UI, DocumentStoreBackend implements StorageBackend over a
StorageAdapter: it caches documents and records, batches writes per
transaction and replays its edits when another client wrote first.
llama-server is the built-in adapter and is always reached on the server
serving the UI; others (Postgres via Supabase or Neon, PocketBase) can be
added in $lib/storage-adapters, see docs/storage-adapters.md. Settings ->
Import/Export offers each available adapter, copies this browser's data on
switch and keeps the API key in the browser.

Assisted-by: Claude (Opus 5.5 Medium)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation server/ui server

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant