1import type { PreviewStreamControl } from "@t3tools/client-runtime/preview/server-browser-stream";
2
3type Dialog = PreviewStreamControl["dialog"];
4
5/** Updates the native response draft when a browser control message arrives. */
6export function previewPromptText(previous: Dialog, next: Dialog, draft: string) {
7 if (
8 next?.type !== previous?.type ||
9 next?.message !== previous?.message ||
10 next?.defaultValue !== previous?.defaultValue
11 ) {
12 return next?.defaultValue ?? "";
13 }
14 return draft;
15}