Change branch() to use entryId instead of entryIndex

- AgentSession.branch(entryId: string) now takes entry ID
- SessionBeforeBranchEvent.entryId replaces entryIndex
- getUserMessagesForBranching() returns entryId
- Update RPC types and client
- Update UserMessageSelectorComponent
- Update hook examples and tests
- Update docs (hooks.md, sdk.md)
This commit is contained in:
Mario Zechner 2025-12-31 13:47:34 +01:00
parent 027d39aa33
commit 8e1e99ca05
12 changed files with 64 additions and 50 deletions

View file

@ -83,7 +83,7 @@ describe.skipIf(!API_KEY)("AgentSession branching", () => {
expect(userMessages[0].text).toBe("Say hello");
// Branch from the first message
const result = await session.branch(userMessages[0].entryIndex);
const result = await session.branch(userMessages[0].entryId);
expect(result.selectedText).toBe("Say hello");
expect(result.cancelled).toBe(false);
@ -113,7 +113,7 @@ describe.skipIf(!API_KEY)("AgentSession branching", () => {
expect(session.messages.length).toBeGreaterThan(0);
// Branch from the first message
const result = await session.branch(userMessages[0].entryIndex);
const result = await session.branch(userMessages[0].entryId);
expect(result.selectedText).toBe("Say hi");
expect(result.cancelled).toBe(false);
@ -143,7 +143,7 @@ describe.skipIf(!API_KEY)("AgentSession branching", () => {
// Branch from second message (keeps first message + response)
const secondMessage = userMessages[1];
const result = await session.branch(secondMessage.entryIndex);
const result = await session.branch(secondMessage.entryId);
expect(result.selectedText).toBe("Say two");
// After branching, should have first user message + assistant response