You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit was created on GitHub.com and signed with GitHub’s verified signature.
Changed
View context bound to the message: a message carries the view context of the moment the user sends it, also while it waits in the queue. In 0.27.0 the bundled transport read the view context when the request went out, so a queued message carried the view of its send time (known limit of 0.27.0); now a message queued at one view goes out with that view after the user or the model navigated elsewhere, and a message sent with nothing registered goes without glirastesViewContext even if a view registered before it left the queue. AiChatProvider freezes a cleaned copy when the user sends: a typed message, send/submit, <glirastes-chat>send(), a starter, follow-up or clarification chip and a direct / command when sent (at once or queued); a command form, also of a queued command, when submitted; an entity action and the "continue" message after a cut-off answer at the click. An edit of a queued message keeps the view context of the moment it was queued (remove it and send again for the view open now). The copy stays in memory (QueuedMessage.viewContext, new optional field, also in onQueueChange and queue.items): queue.storage never gets it, a viewContext field a storage returns is dropped, and a queued message restored after a reload goes without one. The bundled transport sends only the copy the message carries and no longer reads the registry when it sends; the wire format is unchanged ({ version: 1, current }, byMessage not sent) and so is the server. The copy is read only (deeply frozen: changing QueuedMessage.viewContext throws), and the bundled transport cleans what it sends again right before sending with the cleaner registerViewContext installs (a cleaned copy stays byte-identical; a changed or forged one, also passed to its sendMessage directly, is cleaned or dropped; with nothing ever registered on the page no field). ChatTransport.sendMessage has a new optional field viewContext in its first argument, set only when a view context was frozen: a transport of your own takes this field instead of currentViewContext() (which is the view at send time, so a queued message would carry the wrong one) and puts it into its body as glirastesViewContext: { version: 1, current: viewContext }, or ignores it; a transport whose parameter declares its own viewContext field of another type no longer compiles until it is renamed; and a wrapper that passes the message object on keeps it; calling the transport without AiChatProvider sends one only when passed. No code change needed: an app on the bundled transport that registers its view as before (useViewContext, registerViewContext), also with an own composer that sends through send, submit, submitWithResult or ChatStarters and with the queue on (maxSize, autoFlush), only bumps the version; what changes in behaviour is that a queued message carries the view of the moment it was queued and one restored after a reload goes without view context. Unchanged apps: nothing changes: with nothing registered the sendMessage argument ({ text } or { text, files }), the request body, the queue storage and <glirastes-chat>send() are as before. Behaviour change against 0.27.0 for apps that register a view context: a queued message carries the view of the moment it was queued instead of the send time, one restored after a reload goes without, and a transport of your own that adds currentViewContext() when sending should take the passed viewContext instead. Size for an app that never registers anything (bun build --minify, React and the AI SDK external): AiChatProvider with the Vercel transport and <glirastes-chat> (glirastes/embed) each grow by about 0.74 KB minified (0.18 KB gzip) over 0.27.0. Known limit kept: an automatic continuation the AI SDK starts from the running request can repeat the field of the first send, which the server ignores.