Repository navigation
@flue/react: expose bounded history (limit, before, loadOlder) in useFlueAgent #840
rikbrown
started this conversation in
Feature Request
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Problem
@flue/sdk2.2.0 added bounded history reads (54cabb7):observe({ limit }), thebeforecursor on the observed state, andhistoryBefore(cursor, { limit }).@flue/reactdoes not expose them.AgentSession.start()callsthis.client.observe({ live })with nolimit,UseFlueAgentOptionshas nolimitoption, and the public snapshot does not includebefore.A React chat UI that uses
useFlueAgenttherefore downloads the whole conversation on each mount and each reconnect. To load only the newest messages, it must wrap the client to addlimit, and hold the older pages outside the hook.Requested API
limitoption onuseFlueAgent, passed toobserve().beforeon the hook's return value.loadOlder({ limit })action that callshistoryBefore, prepends the page tomessages, and drops the loaded pages whenbeforechanges (a re-base).loadingOlder, andhasOlder(before !== null).The hook already reconciles optimistic and canonical user messages in
converge. If the hook holds the older pages, one message list keeps stable ids and keys, so each caller does not need its own merge.Related: #339 (closed, older API).
All reactions