Fix Vanishing Chats and Messages from Remote#515
Open
MrnoRac wants to merge 1 commit into
Open
Conversation
editor-open-chats is keyed by the map key, but the handlers filtered and returned chats by the record's :id field, which can drift from the key for runtime-created chats. Filter/report by key in handle-list-chats and session-state, and return the path-param key in handle-get-chat. Fixes drifted chats vanishing from the web list (and on reload) and losing messages on tab switch.
Author
|
I tried to follow the patterns I saw around the repo, but let me know if anything needs changing. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In the remote web UI two bugs appear for chats whose stored
:idfield has drifted from their:chatsmap key:GET /api/v1/chats/<id>.Reproducible on versions:
efd534ea6(ECA_VERSION0.142.2)543b428(eca-webview submodule1790003)20260622.1430(also reproduced on20260608.2031)Setup:** an ECA server with
remote.enabled: true, an editor session (e.g. eca-emacs) with at least two pre-existing chats that have message history, and the web UI (web.eca.devor a localeca-web) connected to it.Bug 1 — chat vanishes from the list / on reload:
/resume(or/sessions) an existing chat with history.GET /api/v1/chats/<id>still returns it with all its messages.Bug 2 — chat loses messages on tab switch:
Proposed Fix
Treat the map key as the authoritative id everywhere in the remote handlers as is specified here:
src/eca/features/chat.clj:1967:src/eca/db.clj:326:So...
handle-list-chats/session-state: iterate:chatspairs, filtereditor-openby key, report the key as:idhandle-get-chat: return the requested path-param key as:idCannot affect forks (they already have
:id == key).Tests
Added regression tests in
handlers_test.clj: a chat whose:idfield ≠ its key, marked editor-open, must appear inhandle-list-chats(reported by key) and round-trip throughhandle-get-chatwith the key.bb testgreen.Note / follow-up
This is just in case drift happens somewhere else, but it's probably a good idea to fix that drift there too.. it seems to happen in eca-emacs on /resume for example.