Add tree navigation tests and shared test utilities
- Add test/utilities.ts with shared helpers (API_KEY, userMsg, assistantMsg, createTestSession) - Add agent-session-tree-navigation.test.ts with e2e tests for tree navigation - Add getChildren() method to SessionManager - Add summaryEntry to navigateTree return type - Update existing tests to use shared utilities
This commit is contained in:
@@ -1582,7 +1582,7 @@ export class AgentSession {
|
||||
async navigateTree(
|
||||
targetId: string,
|
||||
options: { summarize?: boolean; customInstructions?: string } = {},
|
||||
): Promise<{ editorText?: string; cancelled: boolean; aborted?: boolean }> {
|
||||
): Promise<{ editorText?: string; cancelled: boolean; aborted?: boolean; summaryEntry?: BranchSummaryEntry }> {
|
||||
const oldLeafId = this.sessionManager.getLeafId();
|
||||
|
||||
// No-op if already at target
|
||||
@@ -1735,7 +1735,7 @@ export class AgentSession {
|
||||
await this._emitToolSessionEvent("tree", this.sessionFile);
|
||||
|
||||
this._branchSummaryAbortController = undefined;
|
||||
return { editorText, cancelled: false };
|
||||
return { editorText, cancelled: false, summaryEntry };
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -696,6 +696,19 @@ export class SessionManager {
|
||||
return this.byId.get(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all direct children of an entry.
|
||||
*/
|
||||
getChildren(parentId: string): SessionEntry[] {
|
||||
const children: SessionEntry[] = [];
|
||||
for (const entry of this.byId.values()) {
|
||||
if (entry.parentId === parentId) {
|
||||
children.push(entry);
|
||||
}
|
||||
}
|
||||
return children;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the label for an entry, if any.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user