feat: chat list and chat detail flows with light cache #43

Merged
forgejo-bot merged 1 commit from feature/11_chat_list into main 2026-10-16 15:45:35 +00:00
Owner

Summary

Core flows for ticket #11:

  • Chat list: list_page / list_all call GET /api/v1/chats/list with the OWUI pagination scheme (1-based page param, fixed server-side page size of 60). Pagination stops on an empty page or a short page — no infinite loop, no missed chats.
  • Chat detail: get_chat calls GET /api/v1/chats/<id>; the response is parsed through the #8 models (history tree preferred, legacy flat-list fallback, defensive timestamps).
  • Cache layer light: ChatListCache persists the last seen chat list per account as JSON in the XDG cache dir (offline sidebar). Hostile account keys are sanitized so the file stays inside the cache dir; corrupt caches are treated as absent.
  • ts_defensive serde helper is now public so wire structs outside models can reuse the defensive timestamp parsing.

Acceptance (ticket #11)

  • Chatliste erscheint mit Titel + Zeitstempel (list_all → ChatSummary mit ts_defensive)
  • Chat öffnen → aktiver Thread wird korrekt aus dem Baum extrahiert (#8-Parser über get_chat + active_thread(); Test mit History-Tree)
  • Pagination über Test-Instanz mit vielen Chats verifiziert (wiremock: 60er-Page → 61er-Page → leerer Stop, plus Short-Page-Stop)
  • Offline → gecachte Liste bleibt sichtbar (ChatListCache save/load/clear + IO-Fehler → None; UI-Anzeige folgt in #15)

Design decision (per ticket): Refresh is manual/pull-to-refresh (wired in the sidebar UI, #15); no automatic background polling — chat list reloads when the sidebar gains focus or the user refreshes. Cache writes happen after every successful full load; the cache is never a source of truth, only an offline fallback.

Test coverage

49/49 core tests green (6 new: page mapping, multi-page + empty stop, short-page stop, tree parsing via get_chat, cache roundtrip + clear, hostile-key sanitization).

Closes #11

Co-Authored-By: OpenCode opencode@noreply.code.hoppe-dev.eu

## Summary Core flows for ticket #11: - **Chat list:** `list_page` / `list_all` call `GET /api/v1/chats/list` with the OWUI pagination scheme (1-based `page` param, fixed server-side page size of 60). Pagination stops on an empty page **or** a short page — no infinite loop, no missed chats. - **Chat detail:** `get_chat` calls `GET /api/v1/chats/<id>`; the response is parsed through the #8 models (history tree preferred, legacy flat-list fallback, defensive timestamps). - **Cache layer light:** `ChatListCache` persists the last seen chat list per account as JSON in the XDG cache dir (offline sidebar). Hostile account keys are sanitized so the file stays inside the cache dir; corrupt caches are treated as absent. - `ts_defensive` serde helper is now public so wire structs outside `models` can reuse the defensive timestamp parsing. ## Acceptance (ticket #11) - [x] Chatliste erscheint mit Titel + Zeitstempel (`list_all` → `ChatSummary` mit `ts_defensive`) - [x] Chat öffnen → aktiver Thread wird korrekt aus dem Baum extrahiert (#8-Parser über `get_chat` + `active_thread()`; Test mit History-Tree) - [x] Pagination über Test-Instanz mit vielen Chats verifiziert (wiremock: 60er-Page → 61er-Page → leerer Stop, plus Short-Page-Stop) - [x] Offline → gecachte Liste bleibt sichtbar (`ChatListCache` save/load/clear + IO-Fehler → `None`; UI-Anzeige folgt in #15) **Design decision (per ticket):** Refresh is manual/pull-to-refresh (wired in the sidebar UI, #15); no automatic background polling — chat list reloads when the sidebar gains focus or the user refreshes. Cache writes happen after every successful full load; the cache is never a source of truth, only an offline fallback. ## Test coverage 49/49 core tests green (6 new: page mapping, multi-page + empty stop, short-page stop, tree parsing via `get_chat`, cache roundtrip + clear, hostile-key sanitization). Closes #11 Co-Authored-By: OpenCode <opencode@noreply.code.hoppe-dev.eu>
feat: chat list and chat detail flows with light cache
All checks were successful
PR Triage / Triage pull request (pull_request) Successful in 0s
PR Triage / Triage pull request-1 (pull_request) Successful in 11s
CI / ci (pull_request) Successful in 4m38s
75d40fda47
- list_page/list_all: GET /api/v1/chats/list with 1-based paging,
  fixed page size 60, stop on empty or short page
- get_chat: GET /api/v1/chats/<id> parsed through the #8 message
  tree models (history tree wins, legacy fallback)
- ChatListCache: per-account JSON file cache for the offline
  sidebar, hostile account keys sanitized
- ts_defensive serde helper is now public for wire structs

Closes #11

Co-Authored-By: OpenCode <opencode@noreply.code.hoppe-dev.eu>
forgejo-bot scheduled this pull request to auto merge when all checks succeed 2026-10-16 15:45:30 +00:00
forgejo-bot deleted branch feature/11_chat_list 2026-10-16 15:45:36 +00:00
Sign in to join this conversation.
No description provided.