@opengeni/react 4.0.1-canary.0 → 4.0.1-canary.2

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.
@@ -0,0 +1,9 @@
1
+ export declare function markdownTableWidth({ columnLeft, columnWidth, contentLeft, contentRight, preferredWidth, }: {
2
+ columnLeft: number;
3
+ columnWidth: number;
4
+ contentLeft: number;
5
+ contentRight: number;
6
+ preferredWidth: number;
7
+ }): number;
8
+ /** Loaded only for assistant tables. Keep prose and nested scroll owners intact. */
9
+ export declare function observeMarkdownTableLayout(wrapper: HTMLDivElement, table: HTMLTableElement): (() => void) | undefined;
package/dist/index.js CHANGED
@@ -108,7 +108,7 @@ import {
108
108
  useWorkspaceModelCatalog,
109
109
  userMessageLikelyNeedsDisclosure,
110
110
  v4aToGitFileDiff
111
- } from "./chunk-HO6X4FHG.js";
111
+ } from "./chunk-CQG7YUJB.js";
112
112
  import "./chunk-YBM6CQRU.js";
113
113
  import "./chunk-5M6VTFJ5.js";
114
114
  import "./chunk-ZYRGEKWS.js";
@@ -1,9 +1,3 @@
1
- import {
2
- ComputerViewer,
3
- useComputerFrameStream,
4
- useComputerSession,
5
- useComputerSessions
6
- } from "./chunk-BV5A4OTE.js";
7
1
  import {
8
2
  BrowserViewer,
9
3
  useAttachedBrowsers,
@@ -14,6 +8,12 @@ import {
14
8
  useBrowserSessions,
15
9
  useSiteAuthConnections
16
10
  } from "./chunk-24M4YBCL.js";
11
+ import {
12
+ ComputerViewer,
13
+ useComputerFrameStream,
14
+ useComputerSession,
15
+ useComputerSessions
16
+ } from "./chunk-BV5A4OTE.js";
17
17
  import {
18
18
  useInteractionInterventions,
19
19
  useInteractionInvalidation
@@ -0,0 +1,71 @@
1
+ // src/components/markdown-table-layout.ts
2
+ function markdownTableWidth({
3
+ columnLeft,
4
+ columnWidth,
5
+ contentLeft,
6
+ contentRight,
7
+ preferredWidth
8
+ }) {
9
+ const center = columnLeft + columnWidth / 2;
10
+ const available = 2 * Math.min(center - contentLeft, contentRight - center);
11
+ return Math.max(columnWidth, Math.min(preferredWidth, available));
12
+ }
13
+ function observeMarkdownTableLayout(wrapper, table) {
14
+ const body = wrapper.parentElement;
15
+ const scroller = body?.closest("[data-og-wide-table-message]")?.closest("[data-og-timeline-scroller]");
16
+ if (!body?.classList.contains("og-markdown-body") || !scroller) return;
17
+ let width = null;
18
+ const reset = () => {
19
+ width = null;
20
+ wrapper.style.width = "";
21
+ wrapper.style.maxWidth = "";
22
+ wrapper.style.marginInline = "";
23
+ };
24
+ const measure = () => {
25
+ for (let ancestor = body; ancestor && ancestor !== scroller; ancestor = ancestor.parentElement) {
26
+ if (getComputedStyle(ancestor).overflowX !== "visible") {
27
+ reset();
28
+ return;
29
+ }
30
+ }
31
+ const column = body.getBoundingClientRect();
32
+ const panel = scroller.getBoundingClientRect();
33
+ const panelStyle = getComputedStyle(scroller);
34
+ const left = panel.left + scroller.clientLeft + parseFloat(panelStyle.paddingLeft);
35
+ const right = panel.left + scroller.clientLeft + scroller.clientWidth - parseFloat(panelStyle.paddingRight);
36
+ const previousWidth = table.style.width;
37
+ let preferred;
38
+ try {
39
+ table.style.width = "max-content";
40
+ preferred = table.getBoundingClientRect().width;
41
+ } finally {
42
+ table.style.width = previousWidth;
43
+ }
44
+ const next = markdownTableWidth({
45
+ columnLeft: column.left,
46
+ columnWidth: column.width,
47
+ contentLeft: left,
48
+ contentRight: right,
49
+ preferredWidth: preferred
50
+ });
51
+ if (width !== null && Math.abs(width - next) < 0.5) return;
52
+ width = next;
53
+ wrapper.style.width = `${width}px`;
54
+ wrapper.style.maxWidth = "none";
55
+ wrapper.style.marginInline = `calc((100% - ${width}px) / 2)`;
56
+ };
57
+ measure();
58
+ const observer = typeof ResizeObserver === "undefined" ? void 0 : new ResizeObserver(measure);
59
+ observer?.observe(scroller);
60
+ observer?.observe(body);
61
+ observer?.observe(table);
62
+ return () => {
63
+ observer?.disconnect();
64
+ reset();
65
+ };
66
+ }
67
+ export {
68
+ markdownTableWidth,
69
+ observeMarkdownTableLayout
70
+ };
71
+ //# sourceMappingURL=markdown-table-layout-3Z3AWBY7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/markdown-table-layout.ts"],"sourcesContent":["export function markdownTableWidth({\n columnLeft,\n columnWidth,\n contentLeft,\n contentRight,\n preferredWidth,\n}: {\n columnLeft: number;\n columnWidth: number;\n contentLeft: number;\n contentRight: number;\n preferredWidth: number;\n}): number {\n const center = columnLeft + columnWidth / 2;\n const available = 2 * Math.min(center - contentLeft, contentRight - center);\n return Math.max(columnWidth, Math.min(preferredWidth, available));\n}\n\n/** Loaded only for assistant tables. Keep prose and nested scroll owners intact. */\nexport function observeMarkdownTableLayout(wrapper: HTMLDivElement, table: HTMLTableElement) {\n const body = wrapper.parentElement;\n const scroller = body\n ?.closest(\"[data-og-wide-table-message]\")\n ?.closest<HTMLElement>(\"[data-og-timeline-scroller]\");\n if (!body?.classList.contains(\"og-markdown-body\") || !scroller) return;\n\n let width: number | null = null;\n const reset = () => {\n width = null;\n wrapper.style.width = \"\";\n wrapper.style.maxWidth = \"\";\n wrapper.style.marginInline = \"\";\n };\n const measure = () => {\n // Intermediate clipped/scrollable surfaces own their own content bounds.\n for (\n let ancestor: HTMLElement | null = body;\n ancestor && ancestor !== scroller;\n ancestor = ancestor.parentElement\n ) {\n if (getComputedStyle(ancestor).overflowX !== \"visible\") {\n reset();\n return;\n }\n }\n const column = body.getBoundingClientRect();\n const panel = scroller.getBoundingClientRect();\n const panelStyle = getComputedStyle(scroller);\n const left = panel.left + scroller.clientLeft + parseFloat(panelStyle.paddingLeft);\n const right =\n panel.left + scroller.clientLeft + scroller.clientWidth - parseFloat(panelStyle.paddingRight);\n\n // Measure the original table, preserving its wrapping and TSV copy DOM.\n const previousWidth = table.style.width;\n let preferred: number;\n try {\n table.style.width = \"max-content\";\n preferred = table.getBoundingClientRect().width;\n } finally {\n table.style.width = previousWidth;\n }\n const next = markdownTableWidth({\n columnLeft: column.left,\n columnWidth: column.width,\n contentLeft: left,\n contentRight: right,\n preferredWidth: preferred,\n });\n if (width !== null && Math.abs(width - next) < 0.5) return;\n width = next;\n wrapper.style.width = `${width}px`;\n wrapper.style.maxWidth = \"none\";\n wrapper.style.marginInline = `calc((100% - ${width}px) / 2)`;\n };\n\n measure();\n const observer = typeof ResizeObserver === \"undefined\" ? undefined : new ResizeObserver(measure);\n observer?.observe(scroller);\n observer?.observe(body);\n observer?.observe(table);\n return () => {\n observer?.disconnect();\n reset();\n };\n}\n"],"mappings":";AAAO,SAAS,mBAAmB;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAMW;AACT,QAAM,SAAS,aAAa,cAAc;AAC1C,QAAM,YAAY,IAAI,KAAK,IAAI,SAAS,aAAa,eAAe,MAAM;AAC1E,SAAO,KAAK,IAAI,aAAa,KAAK,IAAI,gBAAgB,SAAS,CAAC;AAClE;AAGO,SAAS,2BAA2B,SAAyB,OAAyB;AAC3F,QAAM,OAAO,QAAQ;AACrB,QAAM,WAAW,MACb,QAAQ,8BAA8B,GACtC,QAAqB,6BAA6B;AACtD,MAAI,CAAC,MAAM,UAAU,SAAS,kBAAkB,KAAK,CAAC,SAAU;AAEhE,MAAI,QAAuB;AAC3B,QAAM,QAAQ,MAAM;AAClB,YAAQ;AACR,YAAQ,MAAM,QAAQ;AACtB,YAAQ,MAAM,WAAW;AACzB,YAAQ,MAAM,eAAe;AAAA,EAC/B;AACA,QAAM,UAAU,MAAM;AAEpB,aACM,WAA+B,MACnC,YAAY,aAAa,UACzB,WAAW,SAAS,eACpB;AACA,UAAI,iBAAiB,QAAQ,EAAE,cAAc,WAAW;AACtD,cAAM;AACN;AAAA,MACF;AAAA,IACF;AACA,UAAM,SAAS,KAAK,sBAAsB;AAC1C,UAAM,QAAQ,SAAS,sBAAsB;AAC7C,UAAM,aAAa,iBAAiB,QAAQ;AAC5C,UAAM,OAAO,MAAM,OAAO,SAAS,aAAa,WAAW,WAAW,WAAW;AACjF,UAAM,QACJ,MAAM,OAAO,SAAS,aAAa,SAAS,cAAc,WAAW,WAAW,YAAY;AAG9F,UAAM,gBAAgB,MAAM,MAAM;AAClC,QAAI;AACJ,QAAI;AACF,YAAM,MAAM,QAAQ;AACpB,kBAAY,MAAM,sBAAsB,EAAE;AAAA,IAC5C,UAAE;AACA,YAAM,MAAM,QAAQ;AAAA,IACtB;AACA,UAAM,OAAO,mBAAmB;AAAA,MAC9B,YAAY,OAAO;AAAA,MACnB,aAAa,OAAO;AAAA,MACpB,aAAa;AAAA,MACb,cAAc;AAAA,MACd,gBAAgB;AAAA,IAClB,CAAC;AACD,QAAI,UAAU,QAAQ,KAAK,IAAI,QAAQ,IAAI,IAAI,IAAK;AACpD,YAAQ;AACR,YAAQ,MAAM,QAAQ,GAAG,KAAK;AAC9B,YAAQ,MAAM,WAAW;AACzB,YAAQ,MAAM,eAAe,gBAAgB,KAAK;AAAA,EACpD;AAEA,UAAQ;AACR,QAAM,WAAW,OAAO,mBAAmB,cAAc,SAAY,IAAI,eAAe,OAAO;AAC/F,YAAU,QAAQ,QAAQ;AAC1B,YAAU,QAAQ,IAAI;AACtB,YAAU,QAAQ,KAAK;AACvB,SAAO,MAAM;AACX,cAAU,WAAW;AACrB,UAAM;AAAA,EACR;AACF;","names":[]}
@@ -13,7 +13,7 @@ import {
13
13
  sessionChromeGoalPillLabel,
14
14
  sessionChromeGoalPillState,
15
15
  userMessageLikelyNeedsDisclosure
16
- } from "./chunk-HO6X4FHG.js";
16
+ } from "./chunk-CQG7YUJB.js";
17
17
  import "./chunk-YBM6CQRU.js";
18
18
  import "./chunk-5M6VTFJ5.js";
19
19
  import "./chunk-ZYRGEKWS.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeni/react",
3
- "version": "4.0.1-canary.0",
3
+ "version": "4.0.1-canary.2",
4
4
  "description": "React hooks and styled components for OpenGeni: live session streaming, chat composer, message timeline, session status, and fleet views — token-themed (CSS variables), dark-first, built on Tailwind v4 + Radix + Motion.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -120,7 +120,7 @@
120
120
  "@dnd-kit/utilities": "3.2.2",
121
121
  "@fontsource-variable/noto-sans-arabic": "5.2.10",
122
122
  "@fontsource-variable/noto-sans-jp": "5.2.10",
123
- "@opengeni/sdk": "^4.0.1-canary.0",
123
+ "@opengeni/sdk": "^4.0.1-canary.2",
124
124
  "clsx": "^2.1.1",
125
125
  "dequal": "2.0.3",
126
126
  "lucide-react": "^1.8.0",
@@ -0,0 +1,85 @@
1
+ export function markdownTableWidth({
2
+ columnLeft,
3
+ columnWidth,
4
+ contentLeft,
5
+ contentRight,
6
+ preferredWidth,
7
+ }: {
8
+ columnLeft: number;
9
+ columnWidth: number;
10
+ contentLeft: number;
11
+ contentRight: number;
12
+ preferredWidth: number;
13
+ }): number {
14
+ const center = columnLeft + columnWidth / 2;
15
+ const available = 2 * Math.min(center - contentLeft, contentRight - center);
16
+ return Math.max(columnWidth, Math.min(preferredWidth, available));
17
+ }
18
+
19
+ /** Loaded only for assistant tables. Keep prose and nested scroll owners intact. */
20
+ export function observeMarkdownTableLayout(wrapper: HTMLDivElement, table: HTMLTableElement) {
21
+ const body = wrapper.parentElement;
22
+ const scroller = body
23
+ ?.closest("[data-og-wide-table-message]")
24
+ ?.closest<HTMLElement>("[data-og-timeline-scroller]");
25
+ if (!body?.classList.contains("og-markdown-body") || !scroller) return;
26
+
27
+ let width: number | null = null;
28
+ const reset = () => {
29
+ width = null;
30
+ wrapper.style.width = "";
31
+ wrapper.style.maxWidth = "";
32
+ wrapper.style.marginInline = "";
33
+ };
34
+ const measure = () => {
35
+ // Intermediate clipped/scrollable surfaces own their own content bounds.
36
+ for (
37
+ let ancestor: HTMLElement | null = body;
38
+ ancestor && ancestor !== scroller;
39
+ ancestor = ancestor.parentElement
40
+ ) {
41
+ if (getComputedStyle(ancestor).overflowX !== "visible") {
42
+ reset();
43
+ return;
44
+ }
45
+ }
46
+ const column = body.getBoundingClientRect();
47
+ const panel = scroller.getBoundingClientRect();
48
+ const panelStyle = getComputedStyle(scroller);
49
+ const left = panel.left + scroller.clientLeft + parseFloat(panelStyle.paddingLeft);
50
+ const right =
51
+ panel.left + scroller.clientLeft + scroller.clientWidth - parseFloat(panelStyle.paddingRight);
52
+
53
+ // Measure the original table, preserving its wrapping and TSV copy DOM.
54
+ const previousWidth = table.style.width;
55
+ let preferred: number;
56
+ try {
57
+ table.style.width = "max-content";
58
+ preferred = table.getBoundingClientRect().width;
59
+ } finally {
60
+ table.style.width = previousWidth;
61
+ }
62
+ const next = markdownTableWidth({
63
+ columnLeft: column.left,
64
+ columnWidth: column.width,
65
+ contentLeft: left,
66
+ contentRight: right,
67
+ preferredWidth: preferred,
68
+ });
69
+ if (width !== null && Math.abs(width - next) < 0.5) return;
70
+ width = next;
71
+ wrapper.style.width = `${width}px`;
72
+ wrapper.style.maxWidth = "none";
73
+ wrapper.style.marginInline = `calc((100% - ${width}px) / 2)`;
74
+ };
75
+
76
+ measure();
77
+ const observer = typeof ResizeObserver === "undefined" ? undefined : new ResizeObserver(measure);
78
+ observer?.observe(scroller);
79
+ observer?.observe(body);
80
+ observer?.observe(table);
81
+ return () => {
82
+ observer?.disconnect();
83
+ reset();
84
+ };
85
+ }
@@ -411,9 +411,27 @@ function MarkdownCodeBlock({ children }: { children?: ReactNode }) {
411
411
  }
412
412
 
413
413
  function MarkdownTable({ children, className, ...props }: ComponentPropsWithoutRef<"table">) {
414
- const tableRef = useRef<HTMLTableElement | null>(null);
414
+ const wrapperRef = useRef<HTMLDivElement>(null);
415
+ const tableRef = useRef<HTMLTableElement>(null);
416
+ useEffect(() => {
417
+ const wrapper = wrapperRef.current;
418
+ const table = tableRef.current;
419
+ if (!wrapper?.closest("[data-og-wide-table-message]") || !table) return;
420
+ let disposed = false;
421
+ let cleanup: (() => void) | undefined;
422
+ // Ordinary tables remain usable even if this optional layout chunk fails.
423
+ void import("./markdown-table-layout")
424
+ .then(({ observeMarkdownTableLayout }) => {
425
+ if (!disposed) cleanup = observeMarkdownTableLayout(wrapper, table);
426
+ })
427
+ .catch(() => {});
428
+ return () => {
429
+ disposed = true;
430
+ cleanup?.();
431
+ };
432
+ }, [children]);
415
433
  return (
416
- <div className="group/copy relative mt-3 max-w-full first:mt-0">
434
+ <div ref={wrapperRef} className="group/copy relative mt-3 max-w-full first:mt-0">
417
435
  <div className="pointer-events-none absolute top-0 right-0 z-10">
418
436
  <div className="pointer-events-auto">
419
437
  <CopyButton
@@ -3273,7 +3273,12 @@ function AgentMessageRow({
3273
3273
  )
3274
3274
  }
3275
3275
  >
3276
- <div data-og-annotation-source-key={item.annotationSource?.eventId}>{body}</div>
3276
+ <div
3277
+ data-og-wide-table-message=""
3278
+ data-og-annotation-source-key={item.annotationSource?.eventId}
3279
+ >
3280
+ {body}
3281
+ </div>
3277
3282
  </CopyHoverFrame>
3278
3283
  );
3279
3284
  }