@dbx-tools/ui-mastra 0.9.181 → 0.9.184

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.react.ts CHANGED
@@ -35,7 +35,7 @@ export { useChatSessions } from "./src/react/chat-sessions.ts";
35
35
  export type { ThreadSessionReader, ThreadSessionUpdater, ThreadMessageWriter } from "./src/react/chat-sessions.ts";
36
36
  export { readMlflowTracePart, readThreadTitlePart, chatStatusForChunk, closeOnTerminalChunk, waitForTerminalChunk, useChatStream } from "./src/react/chat-stream.ts";
37
37
  export { ChatThreadLayout } from "./src/react/chat-thread-layout.tsx";
38
- export { useChatTranscriptController, ChatTranscript } from "./src/react/chat-transcript.tsx";
38
+ export { TRANSCRIPT_FOLLOW_CANCEL_EVENTS, latestVisibleAssistantIndexInTurn, useChatTranscriptController, ChatTranscript } from "./src/react/chat-transcript.tsx";
39
39
  export type { ChatTranscriptController } from "./src/react/chat-transcript.tsx";
40
40
  export { ChatView } from "./src/react/chat-view.tsx";
41
41
  export { colorizeDelta, renderDataCell, humanizeLabel, TABLE_WRAPPER_CLASSES, DataGrid } from "./src/react/data-grid.tsx";
@@ -43,7 +43,7 @@ export type { DataRow } from "./src/react/data-grid.tsx";
43
43
  export { MarkdownWithEmbeds } from "./src/react/embed-slots.tsx";
44
44
  export { ExportMenu } from "./src/react/export-menu.tsx";
45
45
  export { FeedbackControls } from "./src/react/feedback-controls.tsx";
46
- export { AssistantMarkdown, ToolMarkdown, SqlBlock, SourceBlock } from "./src/react/markdown.tsx";
46
+ export { CHAT_LINK_SAFETY, AssistantMarkdown, ToolMarkdown, SqlBlock, SourceBlock } from "./src/react/markdown.tsx";
47
47
  export { useMastraAssistant, MastraAssistant } from "./src/react/mastra-assistant.tsx";
48
48
  export type { MastraAssistantMode, MastraAssistantSide, MastraAssistantLauncherPosition, MastraAssistantResizeOptions, MastraAssistantLauncherOptions, MastraAssistantController, MastraAssistantProps } from "./src/react/mastra-assistant.tsx";
49
49
  export { useMastraChat, MastraChat } from "./src/react/mastra-chat.tsx";
@@ -60,3 +60,4 @@ export type { ToolInputPresentation, WebSearchProgressGroup } from "./src/react/
60
60
  export { isActiveChatStatus, isRespondingChatStatus } from "./src/react/types.ts";
61
61
  export type { ChatStatus, ToolEvent, ToolProgress, ChatModelOption, ChatInputMessage, QueuedSteer, FeedbackValue, FeedbackSubmission, MessageFeedback, ThreadSummary, ThreadPlacement, ChatViewProps, ApprovalDecision, PendingApproval } from "./src/react/types.ts";
62
62
  export { useChatThreadQuery } from "./src/react/use-chat-thread-query.ts";
63
+ export { CANCEL_TRANSCRIPT_KINETIC_SCROLL_EVENT, useComposerViewportLock } from "./src/react/use-composer-viewport-lock.ts";
package/index.support.ts CHANGED
@@ -37,4 +37,4 @@ export { threadStorageKey } from "./src/support/thread-persistence.ts";
37
37
  export { DEFAULT_THREAD_SESSION_KEY, createThreadSession, isSessionRunning, lastUserMessage, interruptedTurnMessages, enqueueSteer, removeSteer, reorderSteers, sessionKey } from "./src/support/thread-sessions.ts";
38
38
  export type { SessionQueuedSteer, SessionRun, ThreadSession } from "./src/support/thread-sessions.ts";
39
39
  export { THREAD_TAB_SEED_MAX, syncThreadTabs, closeThreadTab, nextActiveThreadTab } from "./src/support/thread-tabs.ts";
40
- export { compactReasoningText, genieReasoningText, toolEventsFromParts, mergeToolEvents } from "./src/support/tool-events.ts";
40
+ export { compactReasoningText, genieOutputReasoningSections, toolReasoningSections, genieReasoningText, toolEventsFromParts, mergeToolEvents } from "./src/support/tool-events.ts";
package/index.ts CHANGED
@@ -3,4 +3,4 @@
3
3
  // Hand edits are overwritten on the next watch; this file is read-only.
4
4
 
5
5
  export const PACKAGE_IDENTIFIER = "@dbx-tools/ui-mastra";
6
- export const PACKAGE_VERSION = "0.9.181";
6
+ export const PACKAGE_VERSION = "0.9.184";
package/package.json CHANGED
@@ -32,12 +32,12 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@databricks/appkit-ui": "0.81.0",
35
- "@dbx-tools/shared-auth": "^0.9.181",
36
- "@dbx-tools/shared-core": "^0.9.181",
37
- "@dbx-tools/shared-genie": "^0.9.181",
38
- "@dbx-tools/shared-mastra": "^0.9.181",
39
- "@dbx-tools/shared-model": "^0.9.181",
40
- "@dbx-tools/ui": "^0.9.181",
35
+ "@dbx-tools/shared-auth": "^0.9.184",
36
+ "@dbx-tools/shared-core": "^0.9.184",
37
+ "@dbx-tools/shared-genie": "^0.9.184",
38
+ "@dbx-tools/shared-mastra": "^0.9.184",
39
+ "@dbx-tools/shared-model": "^0.9.184",
40
+ "@dbx-tools/ui": "^0.9.184",
41
41
  "@mastra/client-js": "1.50.0",
42
42
  "@mastra/core": "1.71.0",
43
43
  "@tanstack/react-table": "^8.21.3",
@@ -46,6 +46,7 @@
46
46
  "echarts-for-react": "^3.0.2",
47
47
  "lucide-react": "^0.554.0",
48
48
  "marked": "^18.0.5",
49
+ "scrollbooster": "4.0.0",
49
50
  "sql-formatter": "^15.6.9",
50
51
  "streamdown": "^2.5.0",
51
52
  "zod": "4.3.6"
@@ -55,7 +56,7 @@
55
56
  "publishConfig": {
56
57
  "access": "public"
57
58
  },
58
- "version": "0.9.181",
59
+ "version": "0.9.184",
59
60
  "types": "index.ts",
60
61
  "dbxToolsConfig": {
61
62
  "tags": [
@@ -1,7 +1,7 @@
1
1
  import { isToolUIPart, type UIMessage } from "ai";
2
2
 
3
3
  import type { ToolEvent } from "./types.ts";
4
- import { compactReasoningText } from "../support/tool-events.ts";
4
+ import { compactReasoningText, toolReasoningSections } from "../support/tool-events.ts";
5
5
 
6
6
  /** One ordered activity entry rendered before an assistant's answer text. */
7
7
  export type AssistantActivityItem =
@@ -20,11 +20,7 @@ export const assistantActivityItems = (
20
20
  if (renderedEventIds.has(event.id)) return;
21
21
  renderedEventIds.add(event.id);
22
22
  items.push({ type: "tool", key: `tool-${event.id}`, event });
23
- const thoughts = (event.progress ?? []).flatMap((progress) => {
24
- if (progress.type !== "thinking") return [];
25
- const text = compactReasoningText(progress.text);
26
- return text ? [text] : [];
27
- });
23
+ const thoughts = toolReasoningSections(event);
28
24
  if (thoughts.length > 0) {
29
25
  items.push({ type: "thought", key: `thought-${event.id}`, text: thoughts.join("\n\n") });
30
26
  }
@@ -1,13 +1,13 @@
1
1
  import { Spinner } from "@databricks/appkit-ui/react";
2
2
 
3
- import { isRespondingChatStatus, type ChatStatus } from "./types.ts";
3
+ import { isActiveChatStatus, type ChatStatus } from "./types.ts";
4
4
 
5
5
  /** Whether an assistant bubble should show its active-response status. */
6
6
  export const shouldShowAssistantResponseStatus = (
7
7
  isLast: boolean,
8
8
  status: ChatStatus,
9
9
  hasVisibleResponse: boolean,
10
- ): boolean => isLast && hasVisibleResponse && isRespondingChatStatus(status);
10
+ ): boolean => isLast && hasVisibleResponse && isActiveChatStatus(status);
11
11
 
12
12
  /** Compact progress affordance for an active assistant response. */
13
13
  export const AssistantResponseSpinner = () => (
@@ -20,17 +20,14 @@ export interface LinkPresentation {
20
20
  absoluteUrl: string;
21
21
  }
22
22
 
23
- /** Return whether a chat URL belongs to the current app's Sandbox route space. */
24
- export function isSandboxLink(url: string, baseUrl?: string): boolean {
23
+ /** Return whether a chat URL resolves within the current app origin. */
24
+ export function isSameOriginLink(url: string, baseUrl?: string): boolean {
25
25
  const base = baseUrl ?? (typeof window === "undefined" ? undefined : window.location.href);
26
26
  if (!base) return false;
27
27
  try {
28
28
  const resolved = new URL(url, base);
29
29
  const current = new URL(base);
30
- return (
31
- resolved.origin === current.origin &&
32
- (resolved.pathname === "/sandbox" || resolved.pathname.startsWith("/sandbox/"))
33
- );
30
+ return resolved.origin === current.origin;
34
31
  } catch {
35
32
  return false;
36
33
  }
@@ -85,10 +82,10 @@ export const ExternalLinkDialog = ({ isOpen, onClose, onConfirm, url }: LinkSafe
85
82
 
86
83
  return (
87
84
  <AlertDialog open={isOpen} onOpenChange={(open) => !open && onClose()}>
88
- <AlertDialogContent className="border-border/60 p-5 shadow-2xl dark:border-white/10 sm:max-w-md">
89
- <AlertDialogHeader>
90
- <AlertDialogTitle className="flex items-center gap-2">
91
- <ExternalLinkIcon className="size-4" aria-hidden="true" />
85
+ <AlertDialogContent className="max-h-[calc(100dvh-1rem)] w-[calc(100vw-1rem)] max-w-lg gap-5 overflow-y-auto border-border/60 p-5 shadow-2xl dark:border-white/10 sm:w-full sm:p-6">
86
+ <AlertDialogHeader className="text-left">
87
+ <AlertDialogTitle className="flex items-center gap-2.5">
88
+ <ExternalLinkIcon className="size-5 shrink-0" aria-hidden="true" />
92
89
  Open external link?
93
90
  </AlertDialogTitle>
94
91
  <AlertDialogDescription>
@@ -96,14 +93,14 @@ export const ExternalLinkDialog = ({ isOpen, onClose, onConfirm, url }: LinkSafe
96
93
  </AlertDialogDescription>
97
94
  </AlertDialogHeader>
98
95
  <div
99
- className="max-h-32 overflow-y-auto break-all rounded-md bg-muted px-3 py-2 font-mono text-sm"
96
+ className="max-h-32 overflow-y-auto break-all rounded-md border border-border/50 bg-muted/70 px-3 py-2.5 font-mono text-sm leading-5"
100
97
  title={link.absoluteUrl}
101
98
  >
102
99
  {link.displayUrl}
103
100
  </div>
104
101
  <AlertDialogFooter>
105
- <AlertDialogCancel>Cancel</AlertDialogCancel>
106
- <Button type="button" variant="outline" onClick={copyLink}>
102
+ <AlertDialogCancel className="w-full sm:w-auto">Cancel</AlertDialogCancel>
103
+ <Button className="w-full sm:w-auto" type="button" variant="outline" onClick={copyLink}>
107
104
  {copied ? (
108
105
  <CheckIcon className="size-4" aria-hidden="true" />
109
106
  ) : (
@@ -111,7 +108,7 @@ export const ExternalLinkDialog = ({ isOpen, onClose, onConfirm, url }: LinkSafe
111
108
  )}
112
109
  {copied ? "Copied" : "Copy link"}
113
110
  </Button>
114
- <AlertDialogAction onClick={onConfirm}>
111
+ <AlertDialogAction className="w-full sm:w-auto" onClick={onConfirm}>
115
112
  <ExternalLinkIcon className="size-4" aria-hidden="true" />
116
113
  Open link
117
114
  </AlertDialogAction>
@@ -34,7 +34,7 @@ import {
34
34
  import { MarkdownWithEmbeds } from "./embed-slots.tsx";
35
35
  import { ExportMenu } from "./export-menu.tsx";
36
36
  import { FeedbackControls } from "./feedback-controls.tsx";
37
- import { ToolMarkdown } from "./markdown.tsx";
37
+ import { CHAT_LINK_SAFETY, ToolMarkdown } from "./markdown.tsx";
38
38
  import { ToolSessionPill, humanizeToolName } from "./tool-pill.tsx";
39
39
  import {
40
40
  isRespondingChatStatus,
@@ -62,13 +62,13 @@ const UserAvatar = () => (
62
62
  );
63
63
 
64
64
  const ThoughtsDisclosure = ({ text }: { text: string }) => (
65
- <Collapsible>
66
- <CollapsibleTrigger className="group flex w-fit cursor-pointer items-center gap-1.5 px-0 py-0.5 text-left text-xs text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">
65
+ <Collapsible className="min-w-0 max-w-full overflow-hidden rounded-md border border-border/40 bg-background/30 px-2 py-1 transition-colors">
66
+ <CollapsibleTrigger className="group flex w-full cursor-pointer items-center gap-2 text-left text-xs text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring">
67
67
  <ChevronDownIcon className="size-3 shrink-0 transition-transform group-data-[state=closed]:-rotate-90" />
68
68
  Thoughts
69
69
  </CollapsibleTrigger>
70
- <CollapsibleContent>
71
- <div className="mt-1 border-l-2 border-border/60 pl-2.5 text-xs text-muted-foreground">
70
+ <CollapsibleContent className="min-w-0 max-w-full overflow-hidden">
71
+ <div className="mt-1.5 min-w-0 max-w-full overflow-hidden text-xs text-muted-foreground">
72
72
  <ToolMarkdown className="prose-p:my-0 [&_p]:!my-0">{text}</ToolMarkdown>
73
73
  </div>
74
74
  </CollapsibleContent>
@@ -198,7 +198,11 @@ const ToolApprovalCard = ({
198
198
  {asEmailInput(input) ? (
199
199
  <EmailApprovalPreview email={asEmailInput(input)!} />
200
200
  ) : (
201
- <RecordPreview value={input} className="rounded bg-background/40" />
201
+ <RecordPreview
202
+ value={input}
203
+ linkSafety={CHAT_LINK_SAFETY}
204
+ className="rounded bg-background/40"
205
+ />
202
206
  )}
203
207
  {expired ? (
204
208
  <div className="mt-3 flex items-center gap-1.5 text-xs font-medium text-muted-foreground">
@@ -313,6 +317,8 @@ type AssistantBubbleProps = {
313
317
  message: UIMessage;
314
318
  isLast: boolean;
315
319
  status: ChatStatus;
320
+ /** Tighten the transcript gap when this is another segment of the same assistant turn. */
321
+ continuation?: boolean;
316
322
  events?: ToolEvent[];
317
323
  regenerate?: () => void;
318
324
  /** Approve / deny handler for inline {@link ToolApprovalCard}s. */
@@ -339,7 +345,7 @@ type AssistantBubbleProps = {
339
345
  feedbackRequest?: string;
340
346
  /** Last thumbs the user left on this message, for highlighting. */
341
347
  feedbackValue?: FeedbackValue;
342
- /** MLflow trace link shown only to viewers with `CAN_MANAGE`. */
348
+ /** MLflow trace link shown only to viewers with `CAN_READ` or higher. */
343
349
  mlflowTraceUrl?: string;
344
350
  };
345
351
 
@@ -348,6 +354,7 @@ export const AssistantBubble = ({
348
354
  message,
349
355
  isLast,
350
356
  status,
357
+ continuation = false,
351
358
  events,
352
359
  regenerate,
353
360
  onResolveToolApproval,
@@ -410,7 +417,12 @@ export const AssistantBubble = ({
410
417
  // nothing so the prose flows unaffected. Suggested questions
411
418
  // stay gated on settle to avoid pop-in mid-stream.
412
419
  return (
413
- <Item className="min-w-0 max-w-full items-start gap-0 overflow-hidden border-none bg-transparent p-0">
420
+ <Item
421
+ className={cn(
422
+ "min-w-0 max-w-full items-start gap-0 overflow-hidden border-none bg-transparent p-0",
423
+ continuation && "-mt-1.5",
424
+ )}
425
+ >
414
426
  {/*
415
427
  * `min-w-0` is required so wide content (markdown tables, long
416
428
  * code blocks) can shrink to fit instead of pushing the whole
@@ -453,7 +465,7 @@ export const AssistantBubble = ({
453
465
  />
454
466
  ))}
455
467
  {showFooter && (
456
- <div className="flex min-h-7 items-center gap-1">
468
+ <div className="flex min-h-7 flex-nowrap items-center gap-1">
457
469
  {hasText && isLast && regenerate && (
458
470
  <Tooltip>
459
471
  <TooltipTrigger asChild>
@@ -33,8 +33,7 @@ import { autosizeComposerTextarea, observeComposerWidth } from "./_composer-auto
33
33
  import { imageFileToUIPart, MAX_COMPOSER_IMAGES } from "./_image-attachments.ts";
34
34
  import { ModelSelector } from "./_model-selector.tsx";
35
35
  import { ExportMenu } from "./export-menu.tsx";
36
- import { SuggestionPills } from "./suggestion-pills.tsx";
37
- import { isActiveChatStatus, isRespondingChatStatus, type ChatViewProps } from "./types.ts";
36
+ import { isActiveChatStatus, type ChatViewProps } from "./types.ts";
38
37
 
39
38
  type QueuedSteerListProps = {
40
39
  queuedSteers: NonNullable<ChatViewProps["queuedSteers"]>;
@@ -236,7 +235,7 @@ const ClearConversationAction = ({ onClear, isLoadingHistory }: ClearConversatio
236
235
  };
237
236
 
238
237
  type ChatComposerProps = {
239
- isEmpty: boolean;
238
+ focusRequest: number;
240
239
  status: ChatViewProps["status"];
241
240
  sendMessage: ChatViewProps["sendMessage"];
242
241
  queuedSteers: NonNullable<ChatViewProps["queuedSteers"]>;
@@ -244,7 +243,6 @@ type ChatComposerProps = {
244
243
  onRemoveSteer: ChatViewProps["onRemoveSteer"];
245
244
  onReorderSteers: ChatViewProps["onReorderSteers"];
246
245
  onStop: ChatViewProps["onStop"];
247
- suggestions: NonNullable<ChatViewProps["suggestions"]>;
248
246
  models: ChatViewProps["models"];
249
247
  model: ChatViewProps["model"];
250
248
  onModelChange: ChatViewProps["onModelChange"];
@@ -265,7 +263,7 @@ type ChatComposerProps = {
265
263
 
266
264
  /** Internal message composer with queued steers and conversation actions. */
267
265
  export const ChatComposer = ({
268
- isEmpty,
266
+ focusRequest,
269
267
  status,
270
268
  sendMessage,
271
269
  queuedSteers,
@@ -273,7 +271,6 @@ export const ChatComposer = ({
273
271
  onRemoveSteer,
274
272
  onReorderSteers,
275
273
  onStop,
276
- suggestions,
277
274
  models,
278
275
  model,
279
276
  onModelChange,
@@ -316,8 +313,13 @@ export const ChatComposer = ({
316
313
  return observeComposerWidth(group, resizeTextarea);
317
314
  }, [resizeTextarea]);
318
315
 
316
+ useLayoutEffect(() => {
317
+ if (focusRequest === 0 || isLoadingHistory) return;
318
+ textareaRef.current?.focus({ preventScroll: true });
319
+ }, [focusRequest, isLoadingHistory]);
320
+
319
321
  const isRunning = isActiveChatStatus(status);
320
- const canStop = isRespondingChatStatus(status);
322
+ const canStop = isRunning;
321
323
  const hasDraft = Boolean(input.trim() || files.length > 0);
322
324
  const submit = () => {
323
325
  const text = input.trim();
@@ -364,20 +366,13 @@ export const ChatComposer = ({
364
366
 
365
367
  const modelChangeable = Boolean(models && models.length > 0);
366
368
  return (
367
- <>
368
- {isEmpty && !isLoadingHistory && (
369
- <SuggestionPills
370
- questions={suggestions}
371
- onSelect={(text) => sendMessage({ text })}
372
- className="mx-auto w-full max-w-4xl px-4 pb-2 md:px-6"
373
- />
374
- )}
369
+ <div data-slot="aui_composer-dock" className="shrink-0 bg-background">
375
370
  <form
376
371
  onSubmit={(event) => {
377
372
  event.preventDefault();
378
373
  submit();
379
374
  }}
380
- className="mx-auto w-full max-w-4xl px-3 pt-2 pb-[max(1rem,env(safe-area-inset-bottom))] md:px-6"
375
+ className="mx-auto w-full max-w-4xl shrink-0 px-3 pt-2 pb-[max(1rem,env(safe-area-inset-bottom))] md:px-6"
381
376
  >
382
377
  <QueuedSteerList
383
378
  queuedSteers={queuedSteers}
@@ -473,7 +468,7 @@ export const ChatComposer = ({
473
468
  }}
474
469
  placeholder="Send a message..."
475
470
  rows={1}
476
- className="field-sizing-fixed min-h-10 max-h-64 w-full flex-none overflow-y-auto px-4 pb-2 pt-4 text-sm"
471
+ className="aui-composer-input field-sizing-fixed min-h-10 max-h-[min(12rem,35dvh)] w-full flex-none overflow-y-auto px-4 pb-2 pt-4 text-base sm:text-sm"
477
472
  />
478
473
  {allowAttachments && fileError && (
479
474
  <div className="px-4 text-xs text-destructive" role="alert">
@@ -588,6 +583,6 @@ export const ChatComposer = ({
588
583
  </InputGroupAddon>
589
584
  </InputGroup>
590
585
  </form>
591
- </>
586
+ </div>
592
587
  );
593
588
  };
@@ -27,8 +27,7 @@ export interface GenieFeedbackTarget {
27
27
 
28
28
  /** Per-message feedback destination and optional Genie identity. */
29
29
  export type MessageFeedbackDestination =
30
- | { mode: "mlflow"; traceId: string }
31
- | ({ mode: "genie" } & GenieFeedbackTarget);
30
+ { mode: "mlflow"; traceId: string } | ({ mode: "genie" } & GenieFeedbackTarget);
32
31
 
33
32
  /** Read the latest Genie target from an assistant message's tool results. */
34
33
  export function genieFeedbackTarget(message: UIMessage): GenieFeedbackTarget | undefined {
@@ -65,13 +64,30 @@ export function messageFeedbackDestination(
65
64
  return undefined;
66
65
  }
67
66
 
68
- /** Build the Databricks MLflow detail URL for one captured trace. */
69
- export function mlflowTraceUrl(experimentUrl: string, traceId?: string): string | undefined {
67
+ /** Build the Databricks MLflow detail URL for one captured UC trace. */
68
+ export function mlflowTraceUrl(
69
+ experimentUrl: string,
70
+ traceId?: string,
71
+ tracePrefix?: string,
72
+ ): string | undefined {
70
73
  const resolvedTraceId = traceId?.trim();
71
74
  if (!resolvedTraceId) return undefined;
72
75
  const url = new URL(experimentUrl);
73
- url.pathname = `${url.pathname.replace(/\/+$/, "")}/traces/${encodeURIComponent(resolvedTraceId)}`;
76
+ const organizationId = url.searchParams.get("o");
77
+ url.pathname = `${url.pathname.replace(/\/+$/, "")}/traces`;
74
78
  url.search = "";
79
+ if (organizationId) url.searchParams.set("o", organizationId);
80
+ url.searchParams.set("selectedEvaluationId", resolvedTraceId);
81
+ const resolvedTracePrefix = tracePrefix
82
+ ?.trim()
83
+ .replace(/^trace:\/+/, "")
84
+ .replace(/^\/+|\/+$/g, "");
85
+ if (resolvedTracePrefix) {
86
+ url.searchParams.set(
87
+ "traceId",
88
+ `trace:/${resolvedTracePrefix}/${resolvedTraceId.replace(/^tr-/, "")}`,
89
+ );
90
+ }
75
91
  url.hash = "";
76
92
  return url.toString();
77
93
  }
@@ -42,6 +42,7 @@ export const readThreadTitlePart = (chunk: UIMessageChunk): string | undefined =
42
42
 
43
43
  /** Map lifecycle-only chunks onto the UI's active-turn state. */
44
44
  export const chatStatusForChunk = (chunk: UIMessageChunk): ChatStatus | undefined => {
45
+ if (chunk.type === "error") return "error";
45
46
  if ((chunk as { type?: string }).type === RESPONSE_COMPLETE_PART_TYPE) return "finishing";
46
47
  if (chunk.type === "finish" || chunk.type === "abort") return "finishing";
47
48
  return undefined;
@@ -69,7 +70,7 @@ export function closeOnTerminalChunk(
69
70
  }
70
71
  onChunk?.(value);
71
72
  controller.enqueue(value);
72
- if (value.type === "finish" || value.type === "abort") {
73
+ if (value.type === "finish" || value.type === "abort" || value.type === "error") {
73
74
  onTerminal?.();
74
75
  controller.close();
75
76
  await reader.cancel("terminal AI SDK chunk received").catch(() => undefined);
@@ -178,10 +179,7 @@ export function useChatStream({ getSession, updateSession, writeMessages }: UseC
178
179
  updateSession(threadId, (current) => ({
179
180
  ...current,
180
181
  runId: runIdRef.current,
181
- status:
182
- terminalReceived || current.status === "finishing"
183
- ? "finishing"
184
- : "streaming",
182
+ status: terminalReceived || current.status === "finishing" ? "finishing" : "streaming",
185
183
  }));
186
184
  }
187
185
  return threadTitle;
@@ -11,6 +11,7 @@ import React, { useEffect, useRef, useState } from "react";
11
11
  import { ThreadSidebar, type ThreadSidebarProps } from "./thread-sidebar.tsx";
12
12
  import { ThreadTabs } from "./thread-tabs.tsx";
13
13
  import type { ChatViewProps } from "./types.ts";
14
+ import { useComposerViewportLock } from "./use-composer-viewport-lock.ts";
14
15
  import { closeThreadTab, nextActiveThreadTab, syncThreadTabs } from "../support/thread-tabs.ts";
15
16
 
16
17
  const SIDE_PANEL_MIN_WIDTH_PX = 768;
@@ -111,6 +112,7 @@ export const ChatThreadLayout = ({
111
112
  onToggleSidebar,
112
113
  }: ChatThreadLayoutProps) => {
113
114
  const rootRef = useRef<HTMLDivElement>(null);
115
+ useComposerViewportLock(rootRef);
114
116
  const isNarrow = useIsNarrow(rootRef);
115
117
  const showThreads = Boolean(threads && onSelectThread) && threadPlacement !== "disabled";
116
118
  const placement = threadPlacement === "auto" ? (isNarrow ? "top" : "left") : threadPlacement;
@@ -187,6 +189,7 @@ export const ChatThreadLayout = ({
187
189
  <TooltipProvider delayDuration={200}>
188
190
  <div
189
191
  ref={rootRef}
192
+ data-slot="aui_thread-frame"
190
193
  className={cn(
191
194
  "flex h-full min-h-0",
192
195
  dockedThreads && dockedSide === "right" && "flex-row-reverse",
@@ -208,7 +211,7 @@ export const ChatThreadLayout = ({
208
211
  : inlineSidebarOpen && (
209
212
  <ThreadSidebar {...threadListProps} onHide={toggleSidebar} side={dockedSide} />
210
213
  ))}
211
- <div className="flex h-full min-w-0 flex-1 flex-col">
214
+ <div className="flex h-full min-h-0 min-w-0 flex-1 flex-col">
212
215
  {tabbedThreads && (
213
216
  <ThreadTabs
214
217
  {...threadTabListProps}