fix(tui): reset agent-backed minimal sessions
This commit is contained in:
@@ -377,6 +377,34 @@ describe('MinimalTui backend command', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('uses agent.reset for /reset when an agent is configured', async () => {
|
||||
const mockSession = {
|
||||
id: 'test',
|
||||
getHistory: () => [],
|
||||
addMessage: vi.fn(),
|
||||
clear: vi.fn(),
|
||||
replaceHistory: vi.fn(),
|
||||
};
|
||||
const mockAgent = {
|
||||
reset: vi.fn(),
|
||||
setModelTier: vi.fn(),
|
||||
getModelTier: vi.fn(() => 'default'),
|
||||
process: vi.fn(),
|
||||
};
|
||||
|
||||
const tui = new MinimalTui({
|
||||
session: asSession(mockSession),
|
||||
modelClient: asModelClient({}),
|
||||
systemPrompt: 'test',
|
||||
agent: asAgent(mockAgent),
|
||||
});
|
||||
|
||||
await minimalTuiPrivates(tui).handleCommand({ type: 'reset' });
|
||||
|
||||
expect(mockAgent.reset).toHaveBeenCalledOnce();
|
||||
expect(mockSession.clear).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('prints tools output when /tools is invoked', async () => {
|
||||
const mockSession = {
|
||||
id: 'test',
|
||||
|
||||
@@ -468,7 +468,11 @@ export class MinimalTui {
|
||||
break;
|
||||
|
||||
case 'reset':
|
||||
if (this.config.agent) {
|
||||
this.config.agent.reset();
|
||||
} else {
|
||||
this.config.session.clear();
|
||||
}
|
||||
this.totalUsage = { inputTokens: 0, outputTokens: 0 };
|
||||
console.log(`${colors.gray}Session cleared.${colors.reset}\n`);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user