@aintela/chat 0.13.2 → 0.14.0

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,49 @@
1
+ /**
2
+ * How tall the chat box is — the transcript's scroller — for a component the agent draws inside it.
3
+ *
4
+ * <p>Why it exists (AIA Issue 1970): a component drawn in the transcript must not, on its FIRST draw, be taller than
5
+ * 90% of the chat box. When the agent draws a very tall card and then writes text under it, the reader loses the
6
+ * order of the turn. Each component decides for itself how to fit — show the rows that fit plus a "mostrar mais",
7
+ * fold the details — so the library publishes the one fact they all need, and nothing else. It deliberately does NOT
8
+ * cap anything itself: a generic max-height + scroll around every card puts a scroll area inside the scroller.</p>
9
+ *
10
+ * <p>A store, not a context value: the scroller resizes often (a window drag, the mobile keyboard animating) and a
11
+ * context value would re-render ChatPane and the whole transcript on every frame. Here only the components that read
12
+ * the height re-render, coalesced to one animation frame and quantized to {@link QUANTUM_PX}.</p>
13
+ *
14
+ * <p>Every ChatPane provides its own, so a transcript nested in another — the task box's "ver detalhes" — measures
15
+ * its own box. Outside a ChatPane the hooks return `undefined`, and a component reads that as "no budget": the same
16
+ * card drawn on a page or a side panel keeps its full layout.</p>
17
+ */
18
+ export interface ChatBoxStore {
19
+ /** The scroller's height in px, or `undefined` until it has been measured. */
20
+ getHeight(): number | undefined;
21
+ subscribe(listener: () => void): () => void;
22
+ /** The ref callback ChatPane puts on its scroller. */
23
+ attach(el: HTMLElement | null): void;
24
+ }
25
+ export declare function createChatBoxStore(): ChatBoxStore;
26
+ export declare const ChatBoxContext: import('react').Context<ChatBoxStore | null>;
27
+ /**
28
+ * The chat box's current height in px — `undefined` outside a chat, or before the box has been laid out. Live: it
29
+ * follows every resize. For a component's first-draw layout use {@link useFirstDrawBudget}, which does not shrink.
30
+ */
31
+ export declare function useChatBoxHeight(): number | undefined;
32
+ /**
33
+ * The height a component may take on its first draw: `fraction` (default 90%) of the chat box — `undefined` outside
34
+ * a chat, meaning "no limit, draw the full layout".
35
+ *
36
+ * <p>It is a ratchet: it latches the first measured height and afterwards only ever GROWS. Growth the user asked for
37
+ * ("mostrar mais", an expanded row) is never undone by a later shrink — the mobile keyboard opening, a panel sliding
38
+ * in — which would otherwise fold the card under the user's finger. If the box was small when the card was drawn (the
39
+ * keyboard was up), the card grows once when the box grows: the budget is what the reader actually had.</p>
40
+ *
41
+ * <p>Inside a chat that has not been measured yet it returns the viewport's share as a provisional value — never
42
+ * `undefined`, which would draw the uncapped layout for one frame — and does not latch it.</p>
43
+ */
44
+ export declare function useFirstDrawBudget(fraction?: number): number | undefined;
45
+ /**
46
+ * How many items of `itemPx` fit in `budget` after `reservedPx` of chrome (header, footer, "mostrar mais" row),
47
+ * clamped to [`min`, `max`]. `budget` undefined (outside a chat) returns `max` — the full list.
48
+ */
49
+ export declare function itemsThatFit(budget: number | undefined, reservedPx: number, itemPx: number, min?: number, max?: number): number;
@@ -35,6 +35,8 @@ export type { PartKind, PartRendererProps, PartRenderer, PartRendererMap, Activi
35
35
  export { createUiToolRegistry, parseUiArgs, parseClientOutput } from './AiChat/ChatPane/parts';
36
36
  export type { UiToolRegistry, UiToolRegistryBuilder, UiToolContext, UiToolActionContext, UiToolArgs, UiToolRenderFn, UiToolActionFn, UiToolRenderOptions, UiToolActionOptions, UiToolEntry, UiToolRenderEntry, UiToolActionEntry, UiToolAskUserRenderers, UiToolAskUserQuestionFn, UiToolAskUserResponseFn, UiToolAskUserEntry, } from './AiChat/ChatPane/parts';
37
37
  export { useContainerRectangle } from '../hooks/useContainerWidth';
38
+ export { useChatBoxHeight, useFirstDrawBudget, itemsThatFit, ChatBoxContext, createChatBoxStore } from './AiChat/ChatPane/chatBoxHeight';
39
+ export type { ChatBoxStore } from './AiChat/ChatPane/chatBoxHeight';
38
40
  export { default as Stopwatch } from './Stopwatch';
39
41
  export { default as LoadingDots } from './Library/LoadingDots';
40
42
  export { default as MarkdownExtended } from './Library/MarkdowmExtended';
@@ -1,4 +1,5 @@
1
1
  import { default as React } from 'react';
2
+ import { TodoItem } from '../../models/todoListModel';
2
3
  import { DetachedRunView } from '../../models/detachedRunModel';
3
4
  import { DetachedRunStreamAuth } from './useDetachedRunLiveActivity';
4
5
  import { DetachedRunTranscriptPresentationProps } from './DetachedRunTranscript';
@@ -61,8 +62,24 @@ export interface DetachedRunTaskBoxProps extends DetachedRunStreamAuth {
61
62
  * shown quietly and retried — a box that goes blank because one request failed reads as the task having vanished.</p>
62
63
  */
63
64
  export declare function DetachedRunTaskBox({ runId, name, initialStatus, fetchRun, pollIntervalMs, waitingPollMs, renderConclusion, label, onSettled, baseUrl, fetchImpl, getToken, onUnauthorized, user, getUser, uiTools, partRenderers, transcriptProps, transcriptHeight, }: DetachedRunTaskBoxProps): import("react/jsx-runtime").JSX.Element;
65
+ type StepEntry = {
66
+ item: TodoItem;
67
+ } | {
68
+ gap: TodoItem[];
69
+ from: number;
70
+ };
71
+ /**
72
+ * The steps a first draw shows when they do not all fit in `capacity` rows: a window from the step before the
73
+ * current one onwards, plus every FAILED step wherever it is (a failure is never folded away), with the folded runs
74
+ * between them as gap rows. `null` when everything fits — the list is drawn whole.
75
+ *
76
+ * <p>The current step is the task list's `currentWorkingItemKey`, else the first in progress, else the first not yet
77
+ * completed — so a finished list shows its end, and a list that has not started shows its beginning.</p>
78
+ */
79
+ export declare function stepWindow(items: TodoItem[], currentKey: string | null | undefined, capacity: number): StepEntry[] | null;
64
80
  /** A task's conclusion is JSON in its own format (`{ outcome, summary, question }` for the booking task); anything
65
81
  * else is shown as it came. */
66
82
  export declare function parseDetachedRunConclusion(conclusion: string | null | undefined): DetachedRunConclusion | null;
67
83
  /** The header's one-word state. */
68
84
  export declare function detachedRunHeadline(status: string, outcome?: string, missing?: boolean): string;
85
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aintela/chat",
3
- "version": "0.13.2",
3
+ "version": "0.14.0",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"