@neeter/react
Advanced tools
+3
-1
@@ -53,3 +53,5 @@ import type { ChatMessage, McpServerStatus, PermissionRequest, SSEEvent } from "@neeter/types"; | ||
| */ | ||
| export declare function replayEvents(store: ChatStore, events: SSEEvent[]): void; | ||
| export declare function replayEvents(store: ChatStore, events: SSEEvent[], options?: { | ||
| stopAtCheckpoint?: string; | ||
| }): void; | ||
| export {}; |
+9
-1
@@ -188,4 +188,6 @@ import { immer } from "zustand/middleware/immer"; | ||
| */ | ||
| export function replayEvents(store, events) { | ||
| export function replayEvents(store, events, options) { | ||
| const s = store.getState(); | ||
| const stopAt = options?.stopAtCheckpoint; | ||
| let foundTarget = false; | ||
| for (const evt of events) { | ||
@@ -228,2 +230,4 @@ const data = JSON.parse(evt.data); | ||
| s.addCheckpoint(data.userMessageUuid); | ||
| if (stopAt && data.userMessageUuid === stopAt) | ||
| foundTarget = true; | ||
| break; | ||
@@ -234,2 +238,4 @@ case "turn_complete": | ||
| s.addCost(data.cost ?? 0, data.numTurns ?? 0); | ||
| if (foundTarget) | ||
| return; | ||
| break; | ||
@@ -240,2 +246,4 @@ case "session_error": | ||
| s.addSystemMessage(`Session ended: ${data.subtype}`); | ||
| if (foundTarget) | ||
| return; | ||
| break; | ||
@@ -242,0 +250,0 @@ } |
@@ -18,2 +18,3 @@ import type { CustomEvent, PermissionResponse, RewindFilesResult, SessionHistoryEntry } from "@neeter/types"; | ||
| sdkSessionId?: string; | ||
| resumeSessionAt?: string; | ||
| }) => Promise<void>; | ||
@@ -20,0 +21,0 @@ rewindSession: (checkpointId: string, options?: { |
@@ -210,3 +210,5 @@ import { useCallback, useEffect, useRef, useState, useSyncExternalStore } from "react"; | ||
| const events = await eventsRes.json(); | ||
| replayEvents(store, events); | ||
| replayEvents(store, events, { | ||
| stopAtCheckpoint: options?.resumeSessionAt, | ||
| }); | ||
| } | ||
@@ -223,2 +225,3 @@ } | ||
| forkSession: options?.fork, | ||
| resumeSessionAt: options?.resumeSessionAt, | ||
| }), | ||
@@ -225,0 +228,0 @@ }); |
+2
-2
| { | ||
| "name": "@neeter/react", | ||
| "version": "0.11.0", | ||
| "version": "0.12.0", | ||
| "description": "React components and hooks for building chat UIs on top of the Claude Agent SDK", | ||
@@ -29,3 +29,3 @@ "license": "MIT", | ||
| "tailwind-merge": "^3.5.0", | ||
| "@neeter/types": "0.11.0" | ||
| "@neeter/types": "0.12.0" | ||
| }, | ||
@@ -32,0 +32,0 @@ "peerDependencies": { |
104356
0.51%2010
0.7%+ Added
- Removed
Updated