chore(cleanup): remove assistant-exclusive skills
Removes the meeting transcription/recording feature end-to-end (get_last_meeting_summary, meetingRecorder/meetingStore/summarize, the useMeetingRecorder renderer hook, and the related IPC/preload wiring) and the remember_info/forget_info long-term memory skills: all three were only ever reachable from the now-removed Assistant mode. adjust_mood and its mood store are unrelated (transversal) and are kept as-is. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -26,9 +26,6 @@ vi.mock('../../../src/renderer/src/voice/useVoiceAssistant', () => ({ useVoiceAs
|
||||
vi.mock('../../../src/renderer/src/voice/useProactiveSpeech', () => ({
|
||||
useProactiveSpeech: vi.fn()
|
||||
}))
|
||||
vi.mock('../../../src/renderer/src/voice/useMeetingRecorder', () => ({
|
||||
useMeetingRecorder: vi.fn()
|
||||
}))
|
||||
|
||||
let onUpdateAvailableCb: (() => void) | undefined
|
||||
let onUpdateReadyCb: (() => void) | undefined
|
||||
@@ -53,7 +50,6 @@ function setupWindowApi(): void {
|
||||
return () => {}
|
||||
}),
|
||||
onToggleListening: vi.fn(() => () => {}),
|
||||
onToggleMeetingTranscription: vi.fn(() => () => {}),
|
||||
onProactiveSpeech: vi.fn(() => () => {}),
|
||||
getPathForFile,
|
||||
sendDroppedFiles,
|
||||
@@ -126,7 +122,7 @@ describe('<App />', () => {
|
||||
expect(sendDroppedFiles).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('should request the context menu with the current listening/transcribing state', () => {
|
||||
it('should request the context menu with the current listening state', () => {
|
||||
// Faux par defaut (ecoute non activee tant qu'aucun compte n'est connecte, voir
|
||||
// getAuthStatus ci-dessus qui renvoie loggedIn: false).
|
||||
render(<App />)
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
||||
import { renderHook } from '@testing-library/react'
|
||||
|
||||
let onToggleCallback: ((transcribing: boolean) => void) | undefined
|
||||
const sendMeetingAudioChunk = vi.fn()
|
||||
const sendMeetingRecordingStopped = vi.fn()
|
||||
const onToggleMeetingTranscription = vi.fn((cb: (transcribing: boolean) => void) => {
|
||||
onToggleCallback = cb
|
||||
return () => {}
|
||||
})
|
||||
|
||||
function fakeStream(): MediaStream {
|
||||
const stop = vi.fn()
|
||||
return { getTracks: () => [{ stop }] } as unknown as MediaStream
|
||||
}
|
||||
|
||||
const getUserMedia = vi.fn(async () => fakeStream())
|
||||
const enumerateDevices = vi.fn(async () => [])
|
||||
|
||||
class FakeMediaRecorder {
|
||||
static instances: FakeMediaRecorder[] = []
|
||||
state: 'recording' | 'inactive' = 'recording'
|
||||
ondataavailable: ((event: { data: Blob }) => void) | null = null
|
||||
onstop: (() => void) | null = null
|
||||
constructor(
|
||||
public stream: MediaStream,
|
||||
public options: { mimeType: string }
|
||||
) {
|
||||
FakeMediaRecorder.instances.push(this)
|
||||
}
|
||||
start(): void {
|
||||
this.state = 'recording'
|
||||
}
|
||||
stop(): void {
|
||||
this.state = 'inactive'
|
||||
this.ondataavailable?.({ data: new Blob(['chunk'], { type: 'audio/webm' }) })
|
||||
this.onstop?.()
|
||||
}
|
||||
}
|
||||
|
||||
const { useMeetingRecorder } = await import('../../../src/renderer/src/voice/useMeetingRecorder')
|
||||
|
||||
describe('useMeetingRecorder()', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
FakeMediaRecorder.instances = []
|
||||
;(window as unknown as { api: Record<string, unknown> }).api = {
|
||||
onToggleMeetingTranscription,
|
||||
sendMeetingAudioChunk,
|
||||
sendMeetingRecordingStopped
|
||||
}
|
||||
Object.defineProperty(navigator, 'mediaDevices', {
|
||||
value: { getUserMedia, enumerateDevices },
|
||||
configurable: true
|
||||
})
|
||||
vi.stubGlobal('MediaRecorder', FakeMediaRecorder)
|
||||
})
|
||||
|
||||
it('should start recording the microphone when transcription is toggled on', async () => {
|
||||
renderHook(() => useMeetingRecorder())
|
||||
onToggleCallback?.(true)
|
||||
await vi.waitFor(() => expect(FakeMediaRecorder.instances.length).toBe(1))
|
||||
expect(getUserMedia).toHaveBeenCalledWith({ audio: true })
|
||||
})
|
||||
|
||||
it('should give up quietly when the microphone is unavailable, without ever starting a recorder', async () => {
|
||||
getUserMedia.mockRejectedValueOnce(new Error('no mic'))
|
||||
renderHook(() => useMeetingRecorder())
|
||||
onToggleCallback?.(true)
|
||||
await vi.waitFor(() => expect(getUserMedia).toHaveBeenCalled())
|
||||
// Rien n'a jamais demarre : stopper ensuite ne doit ni planter ni envoyer de notification pour
|
||||
// une session qui n'a jamais existe.
|
||||
expect(() => onToggleCallback?.(false)).not.toThrow()
|
||||
expect(FakeMediaRecorder.instances.length).toBe(0)
|
||||
})
|
||||
|
||||
it('should send the recorded chunk and notify the main process when stopped', async () => {
|
||||
renderHook(() => useMeetingRecorder())
|
||||
onToggleCallback?.(true)
|
||||
await vi.waitFor(() => expect(FakeMediaRecorder.instances.length).toBe(1))
|
||||
|
||||
onToggleCallback?.(false)
|
||||
await vi.waitFor(() => expect(sendMeetingAudioChunk).toHaveBeenCalled())
|
||||
expect(sendMeetingRecordingStopped).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('should start a new segment automatically instead of stopping when not asked to stop', async () => {
|
||||
renderHook(() => useMeetingRecorder())
|
||||
onToggleCallback?.(true)
|
||||
await vi.waitFor(() => expect(FakeMediaRecorder.instances.length).toBe(1))
|
||||
|
||||
FakeMediaRecorder.instances[0]?.stop()
|
||||
await vi.waitFor(() => expect(FakeMediaRecorder.instances.length).toBe(2))
|
||||
expect(sendMeetingRecordingStopped).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
@@ -1,84 +0,0 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
||||
|
||||
const NotificationShow = vi.fn()
|
||||
class NotificationMock {
|
||||
constructor(public options: { title: string; body: string }) {}
|
||||
show = NotificationShow
|
||||
}
|
||||
vi.mock('electron', () => ({ Notification: NotificationMock }))
|
||||
|
||||
const transcribeAudio = vi.fn(async () => 'Un segment transcrit.')
|
||||
const synthesizeSpeech = vi.fn(async () => Buffer.from([1, 2, 3]))
|
||||
vi.mock('../../src/main/ai/elevenlabs', () => ({ transcribeAudio, synthesizeSpeech }))
|
||||
|
||||
const sendToRenderer = vi.fn()
|
||||
vi.mock('../../src/main/windowBridge', () => ({ sendToRenderer }))
|
||||
|
||||
const summarizeMeeting = vi.fn(async () => 'Resume de la reunion.')
|
||||
vi.mock('../../src/main/meeting/summarize', () => ({ summarizeMeeting }))
|
||||
|
||||
const saveMeeting = vi.fn()
|
||||
vi.mock('../../src/main/meeting/meetingStore', () => ({ saveMeeting }))
|
||||
|
||||
const { startMeetingSession, enqueueMeetingAudioChunk, finishMeetingSession } =
|
||||
await import('../../src/main/meeting/meetingRecorder')
|
||||
|
||||
describe('meetingRecorder', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
})
|
||||
|
||||
it('should do nothing when a chunk arrives without an active session', async () => {
|
||||
enqueueMeetingAudioChunk(Buffer.from('audio'), 'audio/webm')
|
||||
await finishMeetingSession()
|
||||
expect(transcribeAudio).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('should notify when stopping a session with no speech detected', async () => {
|
||||
startMeetingSession()
|
||||
await finishMeetingSession()
|
||||
expect(NotificationShow).toHaveBeenCalled()
|
||||
expect(summarizeMeeting).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('should transcribe queued chunks in order and summarize the full session', async () => {
|
||||
startMeetingSession()
|
||||
enqueueMeetingAudioChunk(Buffer.from('audio1'), 'audio/webm')
|
||||
enqueueMeetingAudioChunk(Buffer.from('audio2'), 'audio/webm')
|
||||
await finishMeetingSession()
|
||||
|
||||
expect(transcribeAudio).toHaveBeenCalledTimes(2)
|
||||
expect(summarizeMeeting).toHaveBeenCalledWith('Un segment transcrit.\nUn segment transcrit.')
|
||||
expect(saveMeeting).toHaveBeenCalledWith(
|
||||
'Un segment transcrit.\nUn segment transcrit.',
|
||||
'Resume de la reunion.'
|
||||
)
|
||||
expect(sendToRenderer).toHaveBeenCalledWith('proactive-speech', expect.anything())
|
||||
})
|
||||
|
||||
it('should skip a segment whose transcription fails, without aborting the session', async () => {
|
||||
transcribeAudio.mockRejectedValueOnce(new Error('echec reseau'))
|
||||
startMeetingSession()
|
||||
enqueueMeetingAudioChunk(Buffer.from('audio1'), 'audio/webm')
|
||||
enqueueMeetingAudioChunk(Buffer.from('audio2'), 'audio/webm')
|
||||
await finishMeetingSession()
|
||||
expect(summarizeMeeting).toHaveBeenCalledWith('Un segment transcrit.')
|
||||
})
|
||||
|
||||
it('should notify a failure when summarizing throws', async () => {
|
||||
summarizeMeeting.mockRejectedValueOnce(new Error('echec resume'))
|
||||
startMeetingSession()
|
||||
enqueueMeetingAudioChunk(Buffer.from('audio1'), 'audio/webm')
|
||||
await finishMeetingSession()
|
||||
expect(NotificationShow).toHaveBeenCalled()
|
||||
expect(saveMeeting).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('should do nothing when finishing a session that was already finished', async () => {
|
||||
startMeetingSession()
|
||||
await finishMeetingSession()
|
||||
NotificationShow.mockClear()
|
||||
await finishMeetingSession()
|
||||
expect(NotificationShow).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
@@ -14,9 +14,8 @@ let currentSkills: FakeSkill[] = []
|
||||
const loadSkills = vi.fn(() => currentSkills)
|
||||
vi.mock('../../src/main/skills', () => ({ loadSkills }))
|
||||
|
||||
const getMemoriesText = vi.fn(() => '')
|
||||
const getMood = vi.fn(() => 0)
|
||||
vi.mock('../../src/main/memory/store', () => ({ getMemoriesText, getMood }))
|
||||
vi.mock('../../src/main/memory/store', () => ({ getMood }))
|
||||
|
||||
const synthesizeSpeech = vi.fn(async () => Buffer.from([1, 2, 3]))
|
||||
vi.mock('../../src/main/ai/elevenlabs', () => ({ synthesizeSpeech }))
|
||||
|
||||
@@ -9,48 +9,9 @@ vi.mock('electron', () => ({
|
||||
app: { getPath: () => tempDir }
|
||||
}))
|
||||
|
||||
const { getMemoriesText, getMood } = await import('../../src/main/memory/store')
|
||||
const { rememberInfo } = await import('../../src/main/skills/memory/rememberInfo')
|
||||
const { forgetInfo } = await import('../../src/main/skills/memory/forgetInfo')
|
||||
const { getMood } = await import('../../src/main/memory/store')
|
||||
const { adjustMoodSkill } = await import('../../src/main/skills/memory/adjustMood')
|
||||
|
||||
describe('remember_info', () => {
|
||||
it('should refuse an empty piece of information', async () => {
|
||||
await expect(rememberInfo.execute({ info: ' ' })).rejects.toThrow(/manquante/)
|
||||
})
|
||||
|
||||
it('should persist the information so it is retrievable later', async () => {
|
||||
const result = await rememberInfo.execute({ info: 'aime le cafe sans sucre' })
|
||||
expect(result).toMatch(/Retenu/)
|
||||
expect(getMemoriesText()).toMatch(/aime le cafe sans sucre/)
|
||||
})
|
||||
})
|
||||
|
||||
describe('forget_info', () => {
|
||||
it('should refuse an empty query', async () => {
|
||||
await expect(forgetInfo.execute({ query: '' })).rejects.toThrow(/manquante/)
|
||||
})
|
||||
|
||||
it('should report when nothing matches the query', async () => {
|
||||
const result = await forgetInfo.execute({ query: 'inexistant-xyz' })
|
||||
expect(result).toMatch(/Aucune information/)
|
||||
})
|
||||
|
||||
it('should remove a previously remembered piece of information matching the query', async () => {
|
||||
await rememberInfo.execute({ info: 'deteste le lundi matin' })
|
||||
const result = await forgetInfo.execute({ query: 'lundi' })
|
||||
expect(result).toMatch(/oubliee/)
|
||||
expect(getMemoriesText()).not.toMatch(/lundi/)
|
||||
})
|
||||
|
||||
it('should clear every memory when the query is "tout"', async () => {
|
||||
await rememberInfo.execute({ info: 'un souvenir quelconque' })
|
||||
const result = await forgetInfo.execute({ query: 'tout' })
|
||||
expect(result).toMatch(/effacee/)
|
||||
expect(getMemoriesText()).toBe('')
|
||||
})
|
||||
})
|
||||
|
||||
describe('adjust_mood', () => {
|
||||
it('should increase the mood score on a positive change', async () => {
|
||||
const before = getMood()
|
||||
|
||||
+1
-17
@@ -3,7 +3,7 @@ import { mkdtempSync, writeFileSync } from 'node:fs'
|
||||
import { tmpdir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
|
||||
const tempDir = mkdtempSync(join(tmpdir(), 'forge-avatar-vision-meeting-test-'))
|
||||
const tempDir = mkdtempSync(join(tmpdir(), 'forge-avatar-web-documents-test-'))
|
||||
|
||||
vi.mock('electron', () => ({
|
||||
app: { getPath: () => tempDir }
|
||||
@@ -20,9 +20,6 @@ vi.mock('mammoth', () => ({
|
||||
}))
|
||||
|
||||
const { searchWeb } = await import('../../src/main/skills/web/searchWeb')
|
||||
const { getLastMeetingSummarySkill } =
|
||||
await import('../../src/main/skills/meeting/getLastMeetingSummary')
|
||||
const { saveMeeting } = await import('../../src/main/meeting/meetingStore')
|
||||
const { extractText } = await import('../../src/main/skills/documents/extractText')
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -68,19 +65,6 @@ describe('search_web', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('get_last_meeting_summary', () => {
|
||||
it('should report no session recorded yet', async () => {
|
||||
const result = await getLastMeetingSummarySkill.execute({})
|
||||
expect(result).toMatch(/Aucune session/)
|
||||
})
|
||||
|
||||
it('should return the last saved meeting summary', async () => {
|
||||
saveMeeting('transcript complet', 'resume de la reunion')
|
||||
const result = await getLastMeetingSummarySkill.execute({})
|
||||
expect(result).toMatch(/resume de la reunion/)
|
||||
})
|
||||
})
|
||||
|
||||
describe('extractText()', () => {
|
||||
it('should read a plain text file as-is', async () => {
|
||||
const filePath = join(tempDir, 'note.txt')
|
||||
@@ -1,48 +0,0 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
||||
import { summarizeMeeting } from '../../src/main/meeting/summarize'
|
||||
|
||||
describe('summarizeMeeting()', () => {
|
||||
beforeEach(() => {
|
||||
vi.stubGlobal('fetch', vi.fn())
|
||||
process.env.OPENROUTER_API_KEY = 'test-key'
|
||||
})
|
||||
|
||||
it('should throw when the API key is missing', async () => {
|
||||
delete process.env.OPENROUTER_API_KEY
|
||||
await expect(summarizeMeeting('court transcript')).rejects.toThrow(/OPENROUTER_API_KEY/)
|
||||
})
|
||||
|
||||
it('should summarize a short transcript in a single call', async () => {
|
||||
vi.mocked(fetch).mockResolvedValue({
|
||||
ok: true,
|
||||
json: () => Promise.resolve({ choices: [{ message: { content: 'Resume concis.' } }] })
|
||||
} as Response)
|
||||
|
||||
const summary = await summarizeMeeting('Un court transcript de reunion.')
|
||||
expect(summary).toBe('Resume concis.')
|
||||
expect(fetch).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('should throw a descriptive error when the API call fails', async () => {
|
||||
vi.mocked(fetch).mockResolvedValue({
|
||||
ok: false,
|
||||
status: 500,
|
||||
text: () => Promise.resolve('panne')
|
||||
} as Response)
|
||||
await expect(summarizeMeeting('transcript')).rejects.toThrow(/Resume echoue/)
|
||||
})
|
||||
|
||||
it('should split a long transcript into chunks, summarize each, then merge', async () => {
|
||||
const longTranscript = 'a'.repeat(25000)
|
||||
vi.mocked(fetch).mockResolvedValue({
|
||||
ok: true,
|
||||
json: () =>
|
||||
Promise.resolve({ choices: [{ message: { content: 'Resume partiel ou final.' } }] })
|
||||
} as Response)
|
||||
|
||||
const summary = await summarizeMeeting(longTranscript)
|
||||
expect(summary).toBe('Resume partiel ou final.')
|
||||
// 25000 chars / 12000 max => 3 chunks + 1 fusion = 4 appels.
|
||||
expect(fetch).toHaveBeenCalledTimes(4)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user