[PR #1787] [CLOSED] [GUI] saved chats in a sidebar, kept in the browser (#676), opt-in #3673

Closed
opened 2026-11-07 15:29:58 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/1787
Author: @Scotty-Hudson
Created: 10/10/2026
Status: ❌ Closed

Base: main ← Head: f-676-sidebar


📝 Commits (8)

  • da3d892 web: saved chats in a sidebar, kept in localStorage (#676), opt-in
  • 9702d6b web: the new chat stays empty after a reload (#1787)
  • 0619514 web: the chat list in IndexedDB (#1787)
  • 213af4a web: read the list from the request, not the store (#1787)
  • a193d27 web: the review fixes for the chat sidebar (#1787)
  • 7fcbfc7 web: the chat sidebar tests, run against app.js (#1787)
  • e340b95 web: the review fixes for the chat sidebar and its tests, second pass (#1787)
  • fb38ddc web: a click inside the rename field keeps the rename open (#1787)

📊 Changes

6 files changed (+920 additions, -38 deletions)

View changed files

➕ serve/test_chat_sidebar.js (+401 -0)
➕ serve/test_chat_sidebar.py (+183 -0)
📝 serve/web/app.css (+36 -0)
📝 serve/web/app.js (+253 -10)
📝 serve/web/index.html (+46 -28)
📝 serve/web/sprite.svg (+1 -0)

📄 Description

Issue: Resolves #676

Problem and result

The web page keeps one chat. A reload, a "New chat", or a tab switch leaves the conversation on the screen and nowhere else, so there is nothing to go back to.

With the switch on (off by default), the left sidebar holds the list of chats: open one, rename it, delete it with Undo, search it, grouped by day. They live in the browser — IndexedDB, database strata, store chats, one record per chat — because a conversation can be several megabytes and localStorage is capped at about 5 MB for the whole page. With the switch off the page is the one from the last release: one chat under strata.chat, and IndexedDB is never opened.

#676 is the request (the tracker sweep closed it as stale on 2026-10-13; a comment with the 0.1.44.1 version line asks for it to be reopened). #361 was closed with the note that this serve/web/app.js work is welcome. The +1 there said a minimal version — list, open, rename, delete, storage — would cover them; this is that, plus the day groups and the search box.

The review on #1787 raised two things, both fixed in the branch: New chat duplicated the chat migrated from strata.chat after a reload, and localStorage (about 5 MB for the whole page) is too small for multi-megabyte conversations, so the list moved to IndexedDB. A third report — a click inside the rename field ended the rename — is fixed too.

Approach

serve/web/app.js

  • The switch (strata.history, off by default) and the chat list: entries of {id, title, time, messages}, one IndexedDB record per chat — cheaper than re-serialising the whole list for one message. 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, a click inside the field keeps it open), delete with Undo, and a collapse to a rail.
  • A browser that only had strata.chat gets it as the first record; a browser that will not take IndexedDB (private mode) keeps the list in memory and says so once.
  • Pictures and files are stored as their names only — a data URL would fill the storage. A write the browser refuses warns once, and the message fits the reason (QuotaExceededError says the storage is full, an abort for another reason does not).

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, serve/test_chat_sidebar.js — new, described under Validation.

What it leaves alone: every engine file and the request path; store.set and the other storage keys (the small ones — the switch, which chat is open — stay in localStorage); 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.

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. 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 sits 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 will generate it from JS.

Validation

Passed:

python3 -m unittest serve.test_chat_sidebar          15 tests, OK
node serve/test_chat_sidebar.js                      20 scenarios, all ok
node --check serve/web/app.js                        clean
python3 -m unittest serve.test_frontend serve.test_web_sampling     29 tests, OK

On fb38ddc7, rebased onto main at cbfd5b92 (v0.2.1.3). Linux, Python 3.14.4, node v24.21.0. Re-run after the rebase; the earlier runs were on 9094446b / f57c0adc.

serve/test_chat_sidebar.py checks the page and the served routes, and runs the js file (it skips on a machine without node). serve/test_chat_sidebar.js runs app.js against a stub DOM and a stub IndexedDB — twenty outcomes: the read, the write, private mode, a full storage, a store that is not there, a blocked open, a fresh database, a read transaction that aborts, an abort for another reason, a reload, the single chat when off, the search, the day groups, rename through the field, a click inside the rename field, delete with Undo, and delete of a chat the list does not hold.

The stub is faithful only where the code depends on it: the result of a read is on the request and not on the store, a refused write fires abort, a blocked open never resolves on its own, the chats store exists only because the upgrade handler made it, and requests answer on a later tick, so the code cannot pass by answering too early.

Each check was verified by putting the old code back and running it again: eighteen fail, including the two bugs the review found.

Failed: none observed.

Not run: real quota limits (no browser here fills a quota on demand); the cross-tab case (a chat written in another tab does not show until that page is reloaded, because there is no event for it); a real browser's IndexedDB — headless Chrome here cannot persist storage across invocations, and the server serves an allowlist of serve/web files, so the js file is a model of the page, not a browser.

Limits

The search reads every chat's message text, so the whole store is in memory after the first load — which is the multi-megabyte case raised in the review. The search box stays in the PR; if you would rather have it over titles only, that would let the app keep titles and timestamps apart from the message bodies.

Pictures and files are stored as their names only, so a picture shows while the page lives and becomes its name after a reload. IndexedDB would allow keeping them as blobs; that needs a second store (so the list can load without the images) and an eviction rule, so it is not in this PR.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/1787 **Author:** [@Scotty-Hudson](https://github.com/Scotty-Hudson) **Created:** 10/10/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `f-676-sidebar` --- ### 📝 Commits (8) - [`da3d892`](https://github.com/Niko1221/Strata/commit/da3d892ac826ee902fc76cb3f1d88a8e68a08d9e) web: saved chats in a sidebar, kept in localStorage (#676), opt-in - [`9702d6b`](https://github.com/Niko1221/Strata/commit/9702d6bd64c90e8f68dbbdde32676844b8890fad) web: the new chat stays empty after a reload (#1787) - [`0619514`](https://github.com/Niko1221/Strata/commit/06195142c09a5a64085599894247406f79e60154) web: the chat list in IndexedDB (#1787) - [`213af4a`](https://github.com/Niko1221/Strata/commit/213af4a6bc507800495b3b1080f05230ede8f06f) web: read the list from the request, not the store (#1787) - [`a193d27`](https://github.com/Niko1221/Strata/commit/a193d275f6aea35a2c3915166bc81bb69f5a3452) web: the review fixes for the chat sidebar (#1787) - [`7fcbfc7`](https://github.com/Niko1221/Strata/commit/7fcbfc71d1ebecce6c9b06c652a894e8357a2519) web: the chat sidebar tests, run against app.js (#1787) - [`e340b95`](https://github.com/Niko1221/Strata/commit/e340b9524dc24ebdeca5b243f164cac60033c0fb) web: the review fixes for the chat sidebar and its tests, second pass (#1787) - [`fb38ddc`](https://github.com/Niko1221/Strata/commit/fb38ddc758178bb0e24e8a826497cb0618edcb39) web: a click inside the rename field keeps the rename open (#1787) ### 📊 Changes **6 files changed** (+920 additions, -38 deletions) <details> <summary>View changed files</summary> ➕ `serve/test_chat_sidebar.js` (+401 -0) ➕ `serve/test_chat_sidebar.py` (+183 -0) 📝 `serve/web/app.css` (+36 -0) 📝 `serve/web/app.js` (+253 -10) 📝 `serve/web/index.html` (+46 -28) 📝 `serve/web/sprite.svg` (+1 -0) </details> ### 📄 Description Issue: Resolves #676 ## Problem and result The web page keeps one chat. A reload, a "New chat", or a tab switch leaves the conversation on the screen and nowhere else, so there is nothing to go back to. With the switch on (off by default), the left sidebar holds the list of chats: open one, rename it, delete it with Undo, search it, grouped by day. They live in the browser — IndexedDB, database `strata`, store `chats`, one record per chat — because a conversation can be several megabytes and `localStorage` is capped at about 5 MB for the whole page. With the switch off the page is the one from the last release: one chat under `strata.chat`, and IndexedDB is never opened. ## Related discussion #676 is the request (the tracker sweep closed it as stale on 2026-10-13; a comment with the 0.1.44.1 version line asks for it to be reopened). #361 was closed with the note that this `serve/web/app.js` work is welcome. The +1 there said a minimal version — list, open, rename, delete, storage — would cover them; this is that, plus the day groups and the search box. The review on #1787 raised two things, both fixed in the branch: `New chat` duplicated the chat migrated from `strata.chat` after a reload, and `localStorage` (about 5 MB for the whole page) is too small for multi-megabyte conversations, so the list moved to IndexedDB. A third report — a click inside the rename field ended the rename — is fixed too. ## Approach **`serve/web/app.js`** - The switch (`strata.history`, off by default) and the chat list: entries of `{id, title, time, messages}`, one IndexedDB record per chat — cheaper than re-serialising the whole list for one message. 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, a click inside the field keeps it open), delete with Undo, and a collapse to a rail. - A browser that only had `strata.chat` gets it as the first record; a browser that will not take IndexedDB (private mode) keeps the list in memory and says so once. - Pictures and files are stored as their names only — a data URL would fill the storage. A write the browser refuses warns once, and the message fits the reason (`QuotaExceededError` says the storage is full, an abort for another reason does not). **`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`**, **`serve/test_chat_sidebar.js`** — new, described under Validation. What it leaves alone: every engine file and the request path; `store.set` and the other storage keys (the small ones — the switch, which chat is open — stay in `localStorage`); 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. 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. 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 sits 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 will generate it from JS. ## Validation **Passed:** ``` python3 -m unittest serve.test_chat_sidebar 15 tests, OK node serve/test_chat_sidebar.js 20 scenarios, all ok node --check serve/web/app.js clean python3 -m unittest serve.test_frontend serve.test_web_sampling 29 tests, OK ``` On `fb38ddc7`, rebased onto `main` at `cbfd5b92` (v0.2.1.3). Linux, Python 3.14.4, node v24.21.0. Re-run after the rebase; the earlier runs were on `9094446b` / `f57c0adc`. `serve/test_chat_sidebar.py` checks the page and the served routes, and runs the js file (it skips on a machine without node). `serve/test_chat_sidebar.js` runs `app.js` against a stub DOM and a stub IndexedDB — twenty outcomes: the read, the write, private mode, a full storage, a store that is not there, a blocked open, a fresh database, a read transaction that aborts, an abort for another reason, a reload, the single chat when off, the search, the day groups, rename through the field, a click inside the rename field, delete with Undo, and delete of a chat the list does not hold. The stub is faithful only where the code depends on it: the result of a read is on the request and not on the store, a refused write fires `abort`, a blocked open never resolves on its own, the `chats` store exists only because the upgrade handler made it, and requests answer on a later tick, so the code cannot pass by answering too early. Each check was verified by putting the old code back and running it again: eighteen fail, including the two bugs the review found. **Failed:** none observed. **Not run:** real quota limits (no browser here fills a quota on demand); the cross-tab case (a chat written in another tab does not show until that page is reloaded, because there is no event for it); a real browser's IndexedDB — headless Chrome here cannot persist storage across invocations, and the server serves an allowlist of `serve/web` files, so the js file is a model of the page, not a browser. ## Limits The search reads every chat's message text, so the whole store is in memory after the first load — which is the multi-megabyte case raised in the review. The search box stays in the PR; if you would rather have it over titles only, that would let the app keep titles and timestamps apart from the message bodies. Pictures and files are stored as their names only, so a picture shows while the page lives and becomes its name after a reload. IndexedDB would allow keeping them as blobs; that needs a second store (so the list can load without the images) and an eviction rule, so it is not in this PR. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 15:29:58 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#3673
No description provided.