@dbx-tools/ui-mastra 0.9.185 → 0.9.187

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.support.ts CHANGED
@@ -5,7 +5,6 @@
5
5
  export * as activeRuns from "./src/support/active-runs.ts";
6
6
  export * as chartOption from "./src/support/chart-option.ts";
7
7
  export * as chartTheme from "./src/support/chart-theme.ts";
8
- export * as clipboard from "./src/support/clipboard.ts";
9
8
  export * as download from "./src/support/download.ts";
10
9
  export * as exportModule from "./src/support/export.ts";
11
10
  export * as genieClient from "./src/support/genie-client.ts";
@@ -22,7 +21,6 @@ export type { StoredActiveRun } from "./src/support/active-runs.ts";
22
21
  export { normalizeChartOption } from "./src/support/chart-option.ts";
23
22
  export { LIGHT_CHART_CHROME, resolveChartChrome, useChartChrome } from "./src/support/chart-theme.ts";
24
23
  export type { ChartChrome } from "./src/support/chart-theme.ts";
25
- export { copyText } from "./src/support/clipboard.ts";
26
24
  export { downloadFile } from "./src/support/download.ts";
27
25
  export { exportChat, messageText } from "./src/support/export.ts";
28
26
  export type { ExportFormat, ExportBrand, EmbedResolver, ExportChatOptions } from "./src/support/export.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.185";
6
+ export const PACKAGE_VERSION = "0.9.187";
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.185",
36
- "@dbx-tools/shared-core": "^0.9.185",
37
- "@dbx-tools/shared-genie": "^0.9.185",
38
- "@dbx-tools/shared-mastra": "^0.9.185",
39
- "@dbx-tools/shared-model": "^0.9.185",
40
- "@dbx-tools/ui": "^0.9.185",
35
+ "@dbx-tools/shared-auth": "^0.9.187",
36
+ "@dbx-tools/shared-core": "^0.9.187",
37
+ "@dbx-tools/shared-genie": "^0.9.187",
38
+ "@dbx-tools/shared-mastra": "^0.9.187",
39
+ "@dbx-tools/shared-model": "^0.9.187",
40
+ "@dbx-tools/ui": "^0.9.187",
41
41
  "@mastra/client-js": "1.50.0",
42
42
  "@mastra/core": "1.71.0",
43
43
  "@tanstack/react-table": "^8.21.3",
@@ -55,7 +55,7 @@
55
55
  "publishConfig": {
56
56
  "access": "public"
57
57
  },
58
- "version": "0.9.185",
58
+ "version": "0.9.187",
59
59
  "types": "index.ts",
60
60
  "dbxToolsConfig": {
61
61
  "tags": [
@@ -9,10 +9,10 @@ import {
9
9
  AlertDialogTitle,
10
10
  Button,
11
11
  } from "@databricks/appkit-ui/react";
12
+ import { copyText } from "@dbx-tools/ui/react";
12
13
  import { CheckIcon, CopyIcon, ExternalLinkIcon } from "lucide-react";
13
14
  import { useEffect, useMemo, useRef, useState } from "react";
14
15
  import type { LinkSafetyModalProps } from "streamdown";
15
- import { copyText } from "../support/clipboard.ts";
16
16
 
17
17
  /** Display and clipboard values for one confirmed chat link. */
18
18
  export interface LinkPresentation {
@@ -13,7 +13,7 @@ import {
13
13
  TooltipTrigger,
14
14
  cn,
15
15
  } from "@databricks/appkit-ui/react";
16
- import { RecordPreview } from "@dbx-tools/ui/react";
16
+ import { RecordPreview, copyText } from "@dbx-tools/ui/react";
17
17
  import type { UIMessage } from "ai";
18
18
  import {
19
19
  BugIcon,
@@ -45,7 +45,6 @@ import {
45
45
  type PendingApproval,
46
46
  type ToolEvent,
47
47
  } from "./types.ts";
48
- import { copyText } from "../support/clipboard.ts";
49
48
  import type { ExportFormat } from "../support/export.ts";
50
49
  import { mergeToolEvents, toolEventsFromParts } from "../support/tool-events.ts";
51
50
 
@@ -451,6 +451,11 @@ export const ChatComposer = ({
451
451
  ref={textareaRef}
452
452
  value={input}
453
453
  onChange={(event) => setInput(event.target.value)}
454
+ onMouseDown={(event) => {
455
+ if (event.button !== 0 || document.activeElement === event.currentTarget) return;
456
+ event.currentTarget.focus({ preventScroll: true });
457
+ event.preventDefault();
458
+ }}
454
459
  onPaste={(event) => {
455
460
  if (!allowAttachments) return;
456
461
  const pastedImages = Array.from(event.clipboardData.files).filter((file) =>
@@ -22,8 +22,6 @@ import { isActiveChatStatus, type ChatViewProps, type ToolEvent } from "./types.
22
22
  import { messageText } from "../support/export.ts";
23
23
 
24
24
  const BOTTOM_THRESHOLD_PX = 24;
25
- const FOCUS_RESIZE_BOTTOM_THRESHOLD_PX = 2;
26
- const FOCUS_RESIZE_SETTLE_MS = 650;
27
25
  const TOP_LOAD_MORE_THRESHOLD_PX = 120;
28
26
 
29
27
  /** Gestures that indicate the user is intentionally navigating transcript history. */
@@ -117,81 +115,28 @@ export const useChatTranscriptController = ({
117
115
  element.scrollTop = element.scrollHeight;
118
116
  });
119
117
  observer.observe(content);
118
+ observer.observe(element);
120
119
  return () => observer.disconnect();
121
120
  }, [messages.length, isLoadingHistory]);
122
121
 
123
122
  useLayoutEffect(() => {
124
123
  const element = scrollRef.current;
125
- const frame = element?.closest<HTMLElement>('[data-slot="aui_thread-frame"]');
126
- if (!element || !frame || typeof ResizeObserver === "undefined") return;
127
-
128
- let focusResizeActive = false;
129
- let focusPinnedToBottom = false;
130
- let focusScrollTop = 0;
131
- let focusResizeTimer = 0;
124
+ if (!element) return;
132
125
 
133
- const finishFocusResize = () => {
134
- focusResizeActive = false;
135
- focusPinnedToBottom = false;
136
- window.clearTimeout(focusResizeTimer);
137
- };
138
- const scheduleFocusResizeFinish = () => {
139
- window.clearTimeout(focusResizeTimer);
140
- focusResizeTimer = window.setTimeout(finishFocusResize, FOCUS_RESIZE_SETTLE_MS);
141
- };
142
- const restoreFocusPosition = () => {
143
- if (!focusResizeActive) return;
144
- programmaticScrollRef.current = true;
145
- if (focusPinnedToBottom) {
146
- element.scrollTop = element.scrollHeight;
147
- setIsAtBottom(true);
148
- } else {
149
- element.scrollTop = focusScrollTop;
150
- }
151
- };
152
- const beginFocusResize = () => {
153
- const distanceFromBottom = element.scrollHeight - element.scrollTop - element.clientHeight;
154
- focusPinnedToBottom = distanceFromBottom <= FOCUS_RESIZE_BOTTOM_THRESHOLD_PX;
155
- focusScrollTop = element.scrollTop;
156
- pinnedRef.current = focusPinnedToBottom;
157
- focusResizeActive = true;
158
- restoreFocusPosition();
159
- scheduleFocusResizeFinish();
160
- };
161
- const handleFocusStart = (event: Event) => {
162
- const target = event.target instanceof Element ? event.target : null;
163
- if (!target?.closest(".aui-composer-input")) return;
164
- beginFocusResize();
165
- };
166
126
  const handleReaderGesture = () => {
167
- finishFocusResize();
168
127
  // A wheel/touch gesture at the bottom may not move the viewport. Let the
169
128
  // ensuing scroll event decide whether follow mode should stop so inert
170
129
  // or downward gestures cannot detach desktop chat from new content.
171
130
  programmaticScrollRef.current = false;
172
131
  };
173
- const observer = new ResizeObserver(() => {
174
- restoreFocusPosition();
175
- if (focusResizeActive) scheduleFocusResizeFinish();
176
- });
177
-
178
- frame.addEventListener("touchstart", handleFocusStart, { passive: true, capture: true });
179
- frame.addEventListener("focusin", handleFocusStart);
180
- frame.addEventListener("focusout", finishFocusResize);
181
132
  for (const eventName of TRANSCRIPT_FOLLOW_CANCEL_EVENTS) {
182
133
  element.addEventListener(eventName, handleReaderGesture, { passive: true });
183
134
  }
184
- observer.observe(element);
185
135
 
186
136
  return () => {
187
- finishFocusResize();
188
- frame.removeEventListener("touchstart", handleFocusStart, true);
189
- frame.removeEventListener("focusin", handleFocusStart);
190
- frame.removeEventListener("focusout", finishFocusResize);
191
137
  for (const eventName of TRANSCRIPT_FOLLOW_CANCEL_EVENTS) {
192
138
  element.removeEventListener(eventName, handleReaderGesture);
193
139
  }
194
- observer.disconnect();
195
140
  };
196
141
  }, []);
197
142
 
@@ -13,13 +13,17 @@ import {
13
13
  TooltipTrigger,
14
14
  cn,
15
15
  } from "@databricks/appkit-ui/react";
16
- import { createShikiPlugin, highlightToHtml, useHighlightedHtml } from "@dbx-tools/ui/react";
16
+ import {
17
+ copyText,
18
+ createShikiPlugin,
19
+ highlightToHtml,
20
+ useHighlightedHtml,
21
+ } from "@dbx-tools/ui/react";
17
22
  import { CheckIcon, CopyIcon } from "lucide-react";
18
23
  import React, { useEffect, useRef, useState } from "react";
19
24
  import { Streamdown, type LinkSafetyConfig } from "streamdown";
20
25
  import { ExternalLinkDialog, isSameOriginLink } from "./_external-link-dialog.tsx";
21
26
  import { DataGrid, TABLE_WRAPPER_CLASSES, colorizeDelta, type DataRow } from "./data-grid.tsx";
22
- import { copyText } from "../support/clipboard.ts";
23
27
 
24
28
  // Markdown rendering for the chat: the streaming `Streamdown` engine
25
29
  // wired with shiki highlighting and AppKit table primitives, plus the
@@ -1,41 +0,0 @@
1
- /**
2
- * Clipboard write that also works off a non-secure origin.
3
- *
4
- * `navigator.clipboard` only exists in a secure context (HTTPS / localhost).
5
- * Over plain HTTP - a LAN IP, a ZeroTier address, a port-forwarded dev host -
6
- * it is `undefined`, so a copy button wired straight to it silently does
7
- * nothing. {@link copyText} falls back to a hidden `<textarea>` +
8
- * `document.execCommand("copy")`, which is deprecated but still the only thing
9
- * that works there.
10
- *
11
- * @module
12
- */
13
-
14
- /**
15
- * Copy `text` to the clipboard, returning whether it succeeded so the caller
16
- * can decide whether to show a confirmation.
17
- */
18
- export async function copyText(text: string): Promise<boolean> {
19
- try {
20
- if (navigator.clipboard?.writeText) {
21
- await navigator.clipboard.writeText(text);
22
- return true;
23
- }
24
- } catch {
25
- // Permission denied or non-secure context; fall through to execCommand.
26
- }
27
- try {
28
- const area = document.createElement("textarea");
29
- area.value = text;
30
- area.setAttribute("readonly", "");
31
- area.style.position = "fixed";
32
- area.style.opacity = "0";
33
- document.body.appendChild(area);
34
- area.select();
35
- const ok = document.execCommand("copy");
36
- area.remove();
37
- return ok;
38
- } catch {
39
- return false;
40
- }
41
- }