Pull requests / #1787

#1787 web: saved chats in a sidebar, kept in localStorage (#676), opt-in

open · @Scotty-Hudson · 0 Kommentare · Auf GitHub

Server & APIAMD / HIPNVIDIA / CUDADocumentation

Beschreibung

Issue: Resolves #676

## Summary

A chat list in the left sidebar, kept in `localStorage`, opt-in: the switch is off by default, and off is the page from the last release. This is the `serve/web/app.js` + `localStorage` work you said was welcome on #361; #676 is the open request for it.

## What changed

**`serve/web/app.js`**
- The switch (`strata.history`, off by default) and the chat list (`strata.chats`): entries of `{id, title, time, messages}`. The open chat is the one on the screen, so `apiMessages()` and the request path are as they were.
- The list is by recency with day groups (Today / Yesterday / Previous 7 days / Previous 30 days / Older), a search over titles and message text, rename (Enter saves, Esc cancels), delete with Undo, and a collapse to a rail.
- A browser that only had `strata.chat` gets it as the first entry; turning the switch on takes the chat on the screen as the first entry, so nothing is lost.
- Pictures and files are stored as their names only (a data URL would fill the storage). A write the browser refuses (private mode, or the storage is full) warns once instead of failing quietly.

**`serve/web/index.html`** — the `<aside>` (hidden until the switch is on) and the switch row under About > Settings.

**`serve/web/app.css`** — the sidebar, the rows, and the narrow-screen overlay (under 760px the list overlays the chat).

**`serve/web/sprite.svg`** — one symbol, `i-edit`, for rename.

**`serve/test_chat_sidebar.py`** — new.

**What it leaves alone:** every engine file and the request path; `store.set` and the other storage keys (the list uses a second method that reports whether the browser took the write); the export button; the sampling drawer, the Monitor, the API; and "New chat" when the switch is off, which still clears the chat with an Undo. No new network calls, nothing about the list goes to the server, no docs change (nothing in the README describes the page's storage).

## Extra Notes

How I checked the default path. `app.js` run against a stub DOM, the same actions on main's `app.js` and on this branch with the switch off:

```
main (last release)              this branch, switch off
at start:      strata.chat       at start:      strata.chat
after saveChat: strata.chat      after saveChat: strata.chat
after New chat: strata.chat      after New chat: strata.chat
```

Same key, same contents after every step; `strata.chats` and `strata.chatId` are not written when the switch is off. With the switch on: the old single chat becomes the first entry, "New chat" keeps the previous chat in the list, switching and deleting work, and the screen and the list share the same message array.

To be exact about "byte-identical": with the switch off the storage key, the contents and the behaviour are the same as the last release. The page does carry the sidebar markup and the switch row, and the chat is inside one extra wrapper div, so the HTML is not identical — the sidebar is hidden and nothing in it runs. If you would rather have the markup itself behind the switch, say so and I'll generate it from JS.

Tests: `serve/test_chat_sidebar.py` (new), `test_frontend`, `test_runconfig`, `test_monitor` — 32 tests, OK. `node --check serve/web/app.js` clean. No backend file is touched, so there was nothing to build for CUDA/HIP/SYCL. Run on a screen against the mock engine: both paths, the migration, rename, delete with Undo, search, collapse to the rail, and a narrow window where the list overlays the chat.

Scope: this is what #361 asked for — the sidebar kept in `localStorage`. The +1 there said a minimal version (list, open, rename, delete, `localStorage`) would cover them; this is that, plus the day groups and the search box. Nothing else is added.

Mehr auf der Site

Links zu Install, Modellen, Releases.