feat(sessions): Integrate chat recording into GeminiChat (#6721)

This commit is contained in:
bl-ue
2025-09-02 23:29:07 -06:00
committed by GitHub
parent c9bd3ecf6a
commit b5dd6f9ea6
17 changed files with 515 additions and 72 deletions

View File

@@ -14,6 +14,32 @@ import type { NextSpeakerResponse } from './nextSpeakerChecker.js';
import { checkNextSpeaker } from './nextSpeakerChecker.js';
import { GeminiChat } from '../core/geminiChat.js';
// Mock fs module to prevent actual file system operations during tests
const mockFileSystem = new Map<string, string>();
vi.mock('node:fs', () => {
const fsModule = {
mkdirSync: vi.fn(),
writeFileSync: vi.fn((path: string, data: string) => {
mockFileSystem.set(path, data);
}),
readFileSync: vi.fn((path: string) => {
if (mockFileSystem.has(path)) {
return mockFileSystem.get(path);
}
throw Object.assign(new Error('ENOENT: no such file or directory'), {
code: 'ENOENT',
});
}),
existsSync: vi.fn((path: string) => mockFileSystem.has(path)),
};
return {
default: fsModule,
...fsModule,
};
});
// Mock GeminiClient and Config constructor
vi.mock('../core/client.js');
vi.mock('../config/config.js');
@@ -64,6 +90,17 @@ describe('checkNextSpeaker', () => {
undefined,
);
// Mock the methods that ChatRecordingService needs
mockConfigInstance.getSessionId = vi
.fn()
.mockReturnValue('test-session-id');
mockConfigInstance.getProjectRoot = vi
.fn()
.mockReturnValue('/test/project/root');
mockConfigInstance.storage = {
getProjectTempDir: vi.fn().mockReturnValue('/test/temp'),
};
mockGeminiClient = new GeminiClient(mockConfigInstance);
// Reset mocks before each test to ensure test isolation