Skip to content

feat(webui): add the shared typed client and state synchronization #1842

Description

@inureyes

Parent / dependencies

Parent: #1834. Depends on #1835, #1836. Build against canonical fixtures; backend endpoint implementations are integrated later, not redefined here.

Ownership

Own webui/src/api/, generated DTO integration, webui/src/state/, authentication state, query/cache/event infrastructure and deterministic transport tests. Feature pages must not create private fetch wrappers, timers, auth storage or model-state caches.

Required behavior

  • Same-origin relative URLs from the server-provided validated API base; reject externally supplied backend URLs. Encode query parameters safely, distinguish catalog opaque ID from actual inference model string and attach autoload=false for model-scoped observation/inference. Bootstrap validates schema version and shows an actionable mismatch screen.
  • Bearer credential is memory-only, submitted through a login view; never URL/sessionStorage/localStorage/IndexedDB. Abort requests, streams and pending retries on logout/401. A 403 is forbidden, not a login loop. Distinguish server offline, empty, partial, stale and unauthorized states; show last successful update age.
  • Use fetch-based SSE for Authorization support, including model lifecycle and chat streams; implement incremental UTF-8 decoding, CRLF/multiline frames, comments/keepalives, split JSON, finite buffers and cleanup. Do not use EventSource with token query strings.
  • One shared model/catalog cache and event reducer with instance/revision checks, duplicate/out-of-order handling, snapshot fence and reset. Reconnect has jittered exponential backoff; no action auto-retry unless safely tied to the same idempotency key. Connection loss while a POST outcome is unknown triggers operation reconciliation, not a second load/download.
  • One non-overlapping fallback polling loop (2 seconds visible/30 hidden), pause unnecessary views, coalesce refreshes and cancel work on teardown/model switch. Observe without influencing LRU or autoload. Use typed nullable metrics and error codes; do not coerce failures to zero.

Acceptance criteria

  • Unit tests fuzz/split SSE at byte boundaries, including multibyte CJK and CRLF, [DONE], oversized frame, midstream failure and abort. Preserve distinct reasoning/content/tool/usage frames.
  • Fake-clock tests cover lag/reset/restart, obsolete model response, reconnect unknown POST, tab visibility, logout and mount/unmount; connection/timer counts return to baseline and requests never overlap.
  • Shared fixtures compile without any and validate runtime JSON at the boundary; seeded secrets never reach persisted stores, logs, errors or exported diagnostics.
  • Expose documented page hooks/actions so Models, Chat, Activity and Settings integrate without changing the state authority or auth design.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions