teodor-new-chat-ui 4.3.396 → 4.3.398

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.
@@ -11,6 +11,7 @@
11
11
  * msg3 appears in multiple checkpoints = multiple attempts/versions
12
12
  */
13
13
  import type { HydratedCheckpointSnapshot } from "@/types/models";
14
+ import type { CheckpointAttemptInfo } from "@/types/checkpoints";
14
15
  export interface AttemptMetadata {
15
16
  attemptIndex: number;
16
17
  attemptCount: number;
@@ -23,10 +24,5 @@ export interface AttemptMetadata {
23
24
  */
24
25
  export declare function buildAttemptMaps(checkpoints: HydratedCheckpointSnapshot[]): {
25
26
  attemptMetaById: Map<string, AttemptMetadata>;
26
- userMessageIdToAttempts: Map<string, Array<{
27
- checkpointId: string;
28
- attemptIndex: number;
29
- attemptCount: number;
30
- isLatestAttempt: boolean;
31
- }>>;
27
+ userMessageIdToAttempts: Map<string, CheckpointAttemptInfo[]>;
32
28
  };
@@ -0,0 +1,15 @@
1
+ import type { HydratedCheckpointSnapshot } from "@/types";
2
+ import type { CheckpointAttemptInfo, CheckpointMeta, CheckpointMetaWithAttempts, TimelineCheckpoint } from "@/types/checkpoints";
3
+ export interface CheckpointIndex {
4
+ checkpoints: HydratedCheckpointSnapshot[];
5
+ checkpointMetaById: Map<string, CheckpointMeta>;
6
+ checkpointIndexByKey: Map<string, CheckpointMeta[]>;
7
+ attemptMetaById: Map<string, CheckpointMetaWithAttempts>;
8
+ userMessageIdToAttempts: Map<string, CheckpointAttemptInfo[]>;
9
+ timeline: TimelineCheckpoint[];
10
+ messagePreviews: Map<string, string>;
11
+ getLatest: () => CheckpointMeta | undefined;
12
+ getCheckpoint: (id: string) => CheckpointMeta | undefined;
13
+ getAttempts: (userMessageId: string) => CheckpointAttemptInfo[];
14
+ }
15
+ export declare function buildCheckpointIndex(checkpoints: HydratedCheckpointSnapshot[]): CheckpointIndex;
@@ -13,8 +13,6 @@ export type { MessageComponentProps } from '../components/chat/MessageComponent'
13
13
  export { MessageList } from '../components/chat/MessageList';
14
14
  export type { MessageListProps } from '../components/chat/MessageList';
15
15
  export { ThreadManager } from '../components/chat/ThreadManager';
16
- export { TimelineColumn } from '../components/chat/TimelineColumn';
17
- export type { TimelineColumnProps } from '../components/chat/TimelineColumn';
18
16
  export { useMessagesReducer } from '@/context/reducers/MessageReducer';
19
17
  export { useStream as useChatStream } from '@/hooks/use-stream';
20
18
  export { ChatApi, chatApiClient } from '../api/chat-api';
@@ -25,6 +23,8 @@ export { ChatSettings } from '@/components/settings/ChatSettings';
25
23
  export type { ChatSettingsConfig } from '@/components/settings/ChatSettings';
26
24
  export type { ChatMessage, ChatRequest, StateSnapshot, HistoryPayload, HydratedCheckpointSnapshot, MessagePart, PregelTask, Role, StreamEvent, TextPart, ThreadInfo, ThreadShareTarget, ThreadSummary, ToolEndEvent } from '@/types';
27
25
  export { buildMessagePreviewMap } from './messagePreviews';
26
+ export { buildCheckpointIndex } from './checkpointIndex';
27
+ export type { CheckpointIndex } from './checkpointIndex';
28
28
  export type { ChatAppProps, SimpleChatProps } from '../components/chat/ChatApp';
29
29
  export type { ChatProvidersProps } from '../context/ChatProviders';
30
30
  export { ChatApp as default } from '../components/chat/ChatApp';
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Message Metadata Resolver
3
+ *
4
+ * Pure function that resolves checkpoint metadata for a single message.
5
+ * Extracted from the hook for:
6
+ * - Better testability (pure function)
7
+ * - Reusability outside React context
8
+ * - Clear separation of heuristics from memoization
9
+ */
10
+ import type { ChatMessage, DefaultMessage } from "@/types";
11
+ import type { CheckpointIndex } from "@/lib/checkpointIndex";
12
+ import type { CheckpointMeta } from "@/types/checkpoints";
13
+ export interface ResolvedMessageMetadata {
14
+ checkpointCandidates: CheckpointMeta[];
15
+ defaultCheckpointId: string | null;
16
+ resolvedStep: number | null;
17
+ resolvedSource: string | null;
18
+ }
19
+ /**
20
+ * Resolves checkpoint metadata for a message given a checkpoint index.
21
+ *
22
+ * Handles:
23
+ * - Multi-source step/source fallback (additionalKwargs > responseMetadata > index)
24
+ * - Checkpoint candidate lookup by step:source key
25
+ * - Attempt filtering for edited/multi-version messages
26
+ * - Attempt metadata enrichment
27
+ *
28
+ * @param message - The message to resolve metadata for
29
+ * @param index - The pre-built checkpoint index (consolidates all lookup maps)
30
+ * @returns Resolved metadata including candidates and resolved step/source
31
+ */
32
+ export declare function resolveMessageMetadata(message: ChatMessage | DefaultMessage | undefined, index: CheckpointIndex): ResolvedMessageMetadata;
@@ -1,5 +1,6 @@
1
1
  import type { ChatMessage } from '@/types';
2
2
  import type { HydratedCheckpointSnapshot } from '@/types/models';
3
+ export declare function getPreviewForMessage(message: ChatMessage): string;
3
4
  /**
4
5
  * Legacy function: builds a map of message ID -> preview text.
5
6
  * This creates a single preview per message ID, with later occurrences overwriting earlier ones.
@@ -0,0 +1,33 @@
1
+ export type EditMeta = {
2
+ checkpointId?: string | null;
3
+ checkpointNs?: string | null;
4
+ };
5
+ export type CheckpointMeta = {
6
+ id: string;
7
+ step: number | null;
8
+ source: string | null;
9
+ createdAt: string | null;
10
+ namespace: string | null;
11
+ parentId: string | null;
12
+ };
13
+ export type CheckpointMetaWithAttempts = CheckpointMeta & {
14
+ attemptIndex: number;
15
+ attemptCount: number;
16
+ isLatestAttempt: boolean;
17
+ baseUserMessageId: string | null;
18
+ };
19
+ export type CheckpointAttemptInfo = {
20
+ checkpointId: string;
21
+ attemptIndex: number;
22
+ attemptCount: number;
23
+ isLatestAttempt: boolean;
24
+ };
25
+ export type TimelineCheckpoint = {
26
+ id: string;
27
+ messageId: string | null;
28
+ step: number | null;
29
+ source: string | null;
30
+ createdAt: string | null;
31
+ next?: string | null;
32
+ parentConfig?: Record<string, unknown> | null;
33
+ };
@@ -1,5 +1,5 @@
1
1
  import type { StreamCommand } from "./events";
2
- import type { TimelineCheckpoint } from "@/hooks/useCheckpointSelectors";
2
+ import type { TimelineCheckpoint } from "@/hooks/checkpoints";
3
3
  export interface ChatRequest {
4
4
  threadId?: string | null;
5
5
  payload?: Record<string, unknown>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teodor-new-chat-ui",
3
- "version": "4.3.396",
3
+ "version": "4.3.398",
4
4
  "description": "React chat UI components with streaming support, tool calls, and modern design",
5
5
  "main": "dist/index.umd.js",
6
6
  "module": "dist/index.esm.js",
@@ -1,12 +0,0 @@
1
- import type { TimelineCheckpoint } from "@/hooks/useCheckpointSelectors";
2
- export interface TimelineColumnProps {
3
- timelineEntries: TimelineCheckpoint[];
4
- activeCheckpointId?: string | null;
5
- onSelectCheckpoint?: (checkpointId: string | null) => Promise<void> | void;
6
- messagePreviews?: Map<string, string>;
7
- className?: string;
8
- onHoverStart?: () => void;
9
- onHoverEnd?: () => void;
10
- }
11
- export declare const TimelineColumn: ({ timelineEntries, activeCheckpointId, onSelectCheckpoint, messagePreviews, className, onHoverStart, onHoverEnd, }: TimelineColumnProps) => import("react/jsx-runtime").JSX.Element | null;
12
- export default TimelineColumn;
@@ -1,33 +0,0 @@
1
- /**
2
- * useCheckpointMetadata Hook
3
- *
4
- * Builds checkpoint metadata maps from server checkpoint options.
5
- *
6
- * Encapsulates logic for:
7
- * - Normalizing and sorting checkpoint options
8
- * - Building checkpoint lookups (by ID, by step:source)
9
- * - Detecting edited messages (attempt detection via buildAttemptMaps)
10
- *
11
- * This hook moves ~107 lines of metadata preparation logic from ChatInterface,
12
- * resulting in cleaner separation of concerns.
13
- */
14
- import type { HydratedCheckpointSnapshot } from "@/types";
15
- import type { CheckpointMeta, CheckpointMetaWithAttempts } from "@/hooks/useCheckpointSelectors";
16
- export interface CheckpointMetadataResult {
17
- checkpointMetaById: Map<string, CheckpointMeta>;
18
- checkpointIndexByKey: Map<string, CheckpointMeta[]>;
19
- attemptMetaById: Map<string, CheckpointMetaWithAttempts>;
20
- userMessageIdToAttempts: Map<string, Array<{
21
- checkpointId: string;
22
- attemptIndex: number;
23
- attemptCount: number;
24
- isLatestAttempt: boolean;
25
- }>>;
26
- }
27
- /**
28
- * Hook to build and memoize checkpoint metadata from server options.
29
- *
30
- * @param checkpointOptions - Raw checkpoint snapshots from the server
31
- * @returns Memoized metadata maps for efficient lookups
32
- */
33
- export declare function useCheckpointMetadata(checkpointOptions: HydratedCheckpointSnapshot[]): CheckpointMetadataResult;
@@ -1,36 +0,0 @@
1
- import type { HydratedCheckpointSnapshot, PendingInterrupt as Interrupt } from "@/types";
2
- export type EditMeta = {
3
- checkpointId?: string | null;
4
- checkpointNs?: string | null;
5
- };
6
- export type TimelineCheckpoint = {
7
- id: string;
8
- label: string;
9
- messageId: string | null;
10
- step: number | null;
11
- source: string | null;
12
- createdAt: string | null;
13
- next?: string | null;
14
- parentConfig?: Record<string, unknown> | null;
15
- };
16
- export declare function useCheckpointTimeline(checkpoints: HydratedCheckpointSnapshot[]): TimelineCheckpoint[];
17
- export type CheckpointMeta = {
18
- id: string;
19
- step: number | null;
20
- source: string | null;
21
- createdAt: string | null;
22
- namespace: string | null;
23
- parentId: string | null;
24
- };
25
- export declare function useCheckpointMeta(checkpoints: HydratedCheckpointSnapshot[]): CheckpointMeta[];
26
- export type CheckpointMetaWithAttempts = CheckpointMeta & {
27
- attemptIndex: number;
28
- attemptCount: number;
29
- isLatestAttempt: boolean;
30
- baseUserMessageId: string | null;
31
- };
32
- export declare function useCheckpointAttempts(checkpoints: HydratedCheckpointSnapshot[]): CheckpointMetaWithAttempts[];
33
- export declare function isExecutionPaused(snapshot: HydratedCheckpointSnapshot): boolean;
34
- export declare function getCurrentInterrupt(snapshot: HydratedCheckpointSnapshot): Interrupt | null;
35
- export declare function getLatestCheckpoint(checkpoints: HydratedCheckpointSnapshot[]): HydratedCheckpointSnapshot | undefined;
36
- export declare function useCheckpointById(checkpoints: HydratedCheckpointSnapshot[], checkpointId: string | null): HydratedCheckpointSnapshot | undefined;
@@ -1,39 +0,0 @@
1
- /**
2
- * useMessageMetadata Hook
3
- *
4
- * Resolves and enriches metadata for a single message, including:
5
- * - Checkpoint candidates (versions/branches of a conversation)
6
- * - Attempt information (if message was edited/attempted multiple times)
7
- * - Resolved step/source from multiple possible sources
8
- *
9
- * This hook encapsulates ~120 lines of complex metadata resolution logic
10
- * that was previously embedded in MessageList.tsx's render function.
11
- */
12
- import type { ChatMessage, DefaultMessage } from "@/types";
13
- import type { CheckpointMeta, CheckpointMetaWithAttempts } from "@/hooks/useCheckpointSelectors";
14
- export interface MetadataResolverMaps {
15
- checkpointMetaById?: Map<string, CheckpointMeta>;
16
- checkpointIndexByKey?: Map<string, CheckpointMeta[]>;
17
- attemptMetaById?: Map<string, CheckpointMetaWithAttempts>;
18
- userMessageIdToAttempts?: Map<string, Array<{
19
- checkpointId: string;
20
- attemptIndex: number;
21
- attemptCount: number;
22
- isLatestAttempt: boolean;
23
- }>>;
24
- }
25
- export interface ResolvedMessageMetadata {
26
- checkpointCandidates: CheckpointMeta[];
27
- defaultCheckpointId: string | null;
28
- attemptMeta: CheckpointMetaWithAttempts | null;
29
- resolvedStep: number | null;
30
- resolvedSource: string | null;
31
- }
32
- /**
33
- * Hook to resolve metadata for a single message.
34
- *
35
- * @param message - The message to resolve metadata for (ChatMessage or DefaultMessage)
36
- * @param maps - Container with all required metadata lookup maps
37
- * @returns Resolved metadata including candidates, attempt info, and step/source
38
- */
39
- export declare function useMessageMetadata(message: ChatMessage | DefaultMessage | undefined, maps: MetadataResolverMaps): ResolvedMessageMetadata;