fix(tui): clear local session on /reset in agent mode
This commit is contained in:
@@ -377,7 +377,7 @@ describe('MinimalTui backend command', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('uses agent.reset for /reset when an agent is configured', async () => {
|
it('clears local session and resets agent for /reset when an agent is configured', async () => {
|
||||||
const mockSession = {
|
const mockSession = {
|
||||||
id: 'test',
|
id: 'test',
|
||||||
getHistory: () => [],
|
getHistory: () => [],
|
||||||
@@ -401,8 +401,8 @@ describe('MinimalTui backend command', () => {
|
|||||||
|
|
||||||
await minimalTuiPrivates(tui).handleCommand({ type: 'reset' });
|
await minimalTuiPrivates(tui).handleCommand({ type: 'reset' });
|
||||||
|
|
||||||
|
expect(mockSession.clear).toHaveBeenCalledOnce();
|
||||||
expect(mockAgent.reset).toHaveBeenCalledOnce();
|
expect(mockAgent.reset).toHaveBeenCalledOnce();
|
||||||
expect(mockSession.clear).not.toHaveBeenCalled();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('prints tools output when /tools is invoked', async () => {
|
it('prints tools output when /tools is invoked', async () => {
|
||||||
|
|||||||
@@ -468,11 +468,11 @@ export class MinimalTui {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'reset':
|
case 'reset':
|
||||||
if (this.config.agent) {
|
// Always clear the local session transcript, even in agent-backed mode,
|
||||||
this.config.agent.reset();
|
// so the UI view matches the reset agent context.
|
||||||
} else {
|
this.config.session.clear();
|
||||||
this.config.session.clear();
|
this.config.agent?.reset();
|
||||||
}
|
|
||||||
this.totalUsage = { inputTokens: 0, outputTokens: 0 };
|
this.totalUsage = { inputTokens: 0, outputTokens: 0 };
|
||||||
console.log(`${colors.gray}Session cleared.${colors.reset}\n`);
|
console.log(`${colors.gray}Session cleared.${colors.reset}\n`);
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user