Skip to content
This repository was archived by the owner on Sep 17, 2026. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
81c1f11
Local work: Ollama transcription, whisper.cpp, iPhone calendar bridge…
kelly1175 Sep 3, 2026
3ae2524
eval: extraction prompt+model A/B/C comparison across 18 transcripts
kelly1175 Sep 4, 2026
0795149
knowledge-graph: promote extraction to first-class tables (B1) + grou…
kelly1175 Sep 4, 2026
e95f6e7
knowledge-graph: transient fetch-retry around extraction LLM call + r…
kelly1175 Sep 4, 2026
ccc7e1f
ipc: graph:reingestRecordings — surgical re-ingest removal half (dryR…
kelly1175 Sep 4, 2026
f024c67
test: cover graph:reingestRecordings handler (dry-run, real delete, n…
kelly1175 Sep 4, 2026
0882380
knowledge-graph: full-drop personal content at the parse boundary
kelly1175 Sep 4, 2026
682a69a
ai-providers: stream the Ollama complete() path (fixes large-transcri…
kelly1175 Sep 4, 2026
8760b79
feat(knowledge-graph): graph-extraction hardening (Req 1-7,10)
kelly1175 Sep 4, 2026
00e0baa
Add Littlebird source adapter and cross-source dedup (task 12.6)
kelly1175 Sep 4, 2026
4e3ea5e
Add risks + questions tables, connector source tracking on knowledge_…
kelly1175 Sep 4, 2026
45c4b68
Route decision/action_item/risk/question SourceItems to first-class t…
kelly1175 Sep 4, 2026
72041d3
Add Littlebird relay connector: poll Supabase staging table into Work…
kelly1175 Sep 4, 2026
1c1ac4a
feat(knowledge-schema): add certainty/evidence/supersession fields (v56)
kelly1175 Sep 4, 2026
eda5cb3
fix(electron): correct cross-platform path bug and symlink gap in tru…
kelly1175 Sep 5, 2026
7240334
test(electron,meeting-recorder): fix stale mocks and rewrite dead-moc…
kelly1175 Sep 5, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/electron/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This is the **integrated vision** that unifies all previous HiDock Next iteratio

### Knowledge Extraction & Management
- **Device Management** - Sync recordings from HiDock H1/H1E/P1 devices (integrates Desktop app capabilities)
- **AI Transcription** - Automatic transcription with Google Gemini (integrates Web app capabilities)
- **AI Transcription** - Automatic cloud transcription with Gemini or private local transcription with whisper.cpp
- **Unified Library** - Browse and manage all recordings with advanced filtering and search (integrates Audio Insights capabilities)
- **Auto-Refresh** - Real-time detection and updates when new recordings are added
- **Waveform Visualization** - Immediate audio visualization on selection
Expand Down Expand Up @@ -55,7 +55,7 @@ This is not just an "audio app" - it's the foundation of a universal knowledge e

- Node.js 18+
- Ollama (for RAG chat) - [Install Ollama](https://ollama.ai)
- Google Gemini API key (for transcription)
- Google Gemini API key (optional when using Local Whisper + Ollama)

### Installation

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,33 @@ vi.mock('electron', () => ({
// Mock the knowledge-graph service
vi.mock('../../services/knowledge-graph-service', () => ({
queryStats: vi.fn(),
ingestFromDbTranscripts: vi.fn(),
ingestAllGraphSources: vi.fn(),
ingestFromFolder: vi.fn(),
queryTopAttendees: vi.fn(),
queryTopSkill: vi.fn(),
queryPersonProfile: vi.fn(),
queryMeetingGraph: vi.fn(),
removeRecordingProvenanceCore: vi.fn(),
}))

// Mock the database module the reingest handler lazy-imports.
vi.mock('../../services/database', () => ({
run: vi.fn(),
queryAll: vi.fn(),
runInTransaction: vi.fn((fn: () => unknown) => fn()), // execute the txn body inline
}))

import {
queryStats,
ingestFromDbTranscripts,
ingestAllGraphSources,
ingestFromFolder,
queryTopAttendees,
queryTopSkill,
queryPersonProfile,
queryMeetingGraph,
removeRecordingProvenanceCore,
} from '../../services/knowledge-graph-service'
import { run, queryAll, runInTransaction } from '../../services/database'

import { registerKnowledgeGraphHandlers } from '../knowledge-graph-handlers'

Expand All @@ -57,10 +67,11 @@ describe('knowledge-graph IPC handlers', () => {
// -------------------------------------------------------------------------
// Registration
// -------------------------------------------------------------------------
it('registers all 7 channels', () => {
it('registers all 8 channels', () => {
const expectedChannels = [
'graph:stats',
'graph:ingestAll',
'graph:reingestRecordings',
'graph:ingestFolder',
'graph:topAttendees',
'graph:topSkill',
Expand Down Expand Up @@ -117,14 +128,14 @@ describe('knowledge-graph IPC handlers', () => {
describe('graph:ingestAll', () => {
it('returns success with ingest result', async () => {
const mockResult = { ingested: 5, skipped: 2, errors: [] }
;(ingestFromDbTranscripts as any).mockResolvedValue(mockResult)
;(ingestAllGraphSources as any).mockResolvedValue(mockResult)

const result = await handlers['graph:ingestAll']({})
expect(result).toEqual({ success: true, data: mockResult })
})

it('returns error when no provider configured', async () => {
;(ingestFromDbTranscripts as any).mockRejectedValue(new Error('No AI provider configured'))
;(ingestAllGraphSources as any).mockRejectedValue(new Error('No AI provider configured'))
const result = await handlers['graph:ingestAll']({})
expect(result.success).toBe(false)
expect(result.error).toContain('No AI provider configured')
Expand Down Expand Up @@ -247,4 +258,95 @@ describe('knowledge-graph IPC handlers', () => {
})
})


// -------------------------------------------------------------------------
// graph:reingestRecordings — the surgical re-ingest REMOVAL half (destructive)
// -------------------------------------------------------------------------
describe('graph:reingestRecordings', () => {
// Two recordings in scope: rec-1 has a capture with B1 rows; rec-2 has NO
// matching capture_id (must not error, must not attempt a B1 delete).
const SCOPE = [
{ recording_id: 'rec-1', capture_id: 'cap-1' },
{ recording_id: 'rec-2', capture_id: null },
]

function primeMocks() {
// queryAll is used for: (1) the scope query, then per rec-1 the two COUNT
// queries (decisions, action_items). rec-2 has no capture so no counts.
;(queryAll as any).mockImplementation((sql: string) => {
if (/FROM graph_ingested_transcripts/i.test(sql)) return SCOPE
if (/FROM decisions WHERE knowledge_capture_id/i.test(sql)) return [{ n: 2 }]
if (/FROM action_items WHERE knowledge_capture_id/i.test(sql)) return [{ n: 3 }]
return []
})
;(removeRecordingProvenanceCore as any).mockImplementation((rid: string, opts: any) => ({
ok: true, recordingId: rid, dryRun: !!opts?.dryRun,
markersRemoved: 1, edgesRemoved: 4, edgeSourceRowsRemoved: 5,
meetingNodesRemoved: 1, orphanNodesRemoved: 2, orphanNodesByType: {},
sharedEdgesKept: 1, unattributedResidueKept: 0,
}))
}

beforeEach(() => {
primeMocks()
})

it('dry-run writes NOTHING but still reports scope + counts', async () => {
const result = await handlers['graph:reingestRecordings']({}, { dryRun: true })
expect(result.success).toBe(true)
expect(result.data.dryRun).toBe(true)
expect(result.data.recordingsInScope).toBe(2)
expect(result.data.recordingIds).toEqual(['rec-1', 'rec-2'])
// removeRecordingProvenanceCore called with dryRun:true for each recording
expect(removeRecordingProvenanceCore).toHaveBeenCalledTimes(2)
expect(removeRecordingProvenanceCore).toHaveBeenCalledWith('rec-1', { dryRun: true })
expect(removeRecordingProvenanceCore).toHaveBeenCalledWith('rec-2', { dryRun: true })
// NO writes: no B1 deletes, no transaction opened
expect(run).not.toHaveBeenCalled()
expect(runInTransaction).not.toHaveBeenCalled()
// counts still aggregated (rec-1: 2 decisions / 3 actions; markers 1+1)
expect(result.data.totals.markersRemoved).toBe(2)
expect(result.data.totals.decisionsRemoved).toBe(2)
expect(result.data.totals.actionItemsRemoved).toBe(3)
})

it('real-run deletes B1 rows AND calls removeRecordingProvenanceCore per in-scope recording, atomically', async () => {
const result = await handlers['graph:reingestRecordings']({}, { dryRun: false })
expect(result.success).toBe(true)
expect(result.data.dryRun).toBe(false)
// provenance removal invoked per recording with dryRun:false
expect(removeRecordingProvenanceCore).toHaveBeenCalledWith('rec-1', { dryRun: false })
expect(removeRecordingProvenanceCore).toHaveBeenCalledWith('rec-2', { dryRun: false })
// each recording wrapped in its own transaction (2 recordings → 2 txns)
expect(runInTransaction).toHaveBeenCalledTimes(2)
// B1 deletes fired ONLY for the capture-backed recording (rec-1): 2 deletes
const deleteCalls = (run as any).mock.calls.filter((c: any[]) => /DELETE FROM (decisions|action_items)/i.test(c[0]))
expect(deleteCalls).toHaveLength(2)
expect(deleteCalls.some((c: any[]) => /decisions/.test(c[0]) && c[1][0] === 'cap-1')).toBe(true)
expect(deleteCalls.some((c: any[]) => /action_items/.test(c[0]) && c[1][0] === 'cap-1')).toBe(true)
})

it('a recording with no matching capture_id does not error and skips the B1 delete', async () => {
// Scope with ONLY the capture-less recording.
;(queryAll as any).mockImplementation((sql: string) =>
/FROM graph_ingested_transcripts/i.test(sql) ? [{ recording_id: 'rec-2', capture_id: null }] : []
)
const result = await handlers['graph:reingestRecordings']({}, { dryRun: false })
expect(result.success).toBe(true)
expect(result.data.recordingsInScope).toBe(1)
expect(removeRecordingProvenanceCore).toHaveBeenCalledWith('rec-2', { dryRun: false })
// No B1 delete attempted (no capture)
const deleteCalls = (run as any).mock.calls.filter((c: any[]) => /DELETE FROM/i.test(c[0]))
expect(deleteCalls).toHaveLength(0)
expect(result.data.totals.decisionsRemoved).toBe(0)
expect(result.data.totals.actionItemsRemoved).toBe(0)
})

it('returns { success:false, error } if removal throws', async () => {
;(removeRecordingProvenanceCore as any).mockImplementation(() => { throw new Error('provenance boom') })
const result = await handlers['graph:reingestRecordings']({}, { dryRun: false })
expect(result.success).toBe(false)
expect(result.error).toContain('provenance boom')
})
})
})
4 changes: 3 additions & 1 deletion apps/electron/electron/main/ipc/briefing-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,9 @@ export function registerBriefingHandlers(): void {
todayRecordingsPending,
pendingActionables,
calendar: {
configured: Boolean(config.calendar.icsUrl),
configured: config.calendar.source === 'local-file'
? Boolean(config.calendar.localFilePath)
: Boolean(config.calendar.icsUrl),
syncEnabled: config.calendar.syncEnabled,
lastSyncAt: config.calendar.lastSyncAt
},
Expand Down
70 changes: 56 additions & 14 deletions apps/electron/electron/main/ipc/calendar-handlers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ipcMain } from 'electron'
import { BrowserWindow, dialog, ipcMain } from 'electron'
import { getConfig, updateConfig } from '../services/config'
import { emitActivityLog } from '../services/activity-log'
import {
Expand All @@ -7,6 +7,7 @@ import {
isCalendarSyncActive,
CalendarSyncResult
} from '../services/calendar-sync'
import { isCalendarFileSyncActive, syncCalendarFile } from '../services/calendar-file-sync'
import { clearAllMeetings } from '../services/database'
import { whenBootTasksSettled, areBootTasksSettled } from '../services/boot-scheduler'
import {
Expand All @@ -31,16 +32,40 @@ type CalendarSyncTrigger = 'manual' | 'mount'
*/
const MANUAL_BOOT_WAIT_MS = 2500

function isCalendarConfigured(config: ReturnType<typeof getConfig>): boolean {
return config.calendar.source === 'local-file'
? Boolean(config.calendar.localFilePath)
: Boolean(config.calendar.icsUrl)
}

function syncConfiguredCalendar(
config: ReturnType<typeof getConfig>,
options?: Parameters<typeof syncCalendar>[1]
): Promise<CalendarSyncResult> {
if (config.calendar.source === 'local-file') {
return options
? syncCalendarFile(config.calendar.localFilePath ?? '', options)
: syncCalendarFile(config.calendar.localFilePath ?? '')
}
return options ? syncCalendar(config.calendar.icsUrl, options) : syncCalendar(config.calendar.icsUrl)
}

function missingCalendarSourceError(config: ReturnType<typeof getConfig>): string {
return config.calendar.source === 'local-file'
? 'No iPhone calendar file configured'
: 'No calendar URL configured'
}

export function registerCalendarHandlers(): void {
// Sync calendar now
// AUD2-010: Verify sync result and catch unexpected errors at the IPC boundary
ipcMain.handle('calendar:sync', async (_event, rawTrigger: unknown): Promise<CalendarSyncResult> => {
const config = getConfig()

if (!config.calendar.icsUrl) {
if (!isCalendarConfigured(config)) {
return {
success: false,
error: 'No calendar URL configured',
error: missingCalendarSourceError(config),
meetingsCount: 0
}
}
Expand All @@ -60,7 +85,7 @@ export function registerCalendarHandlers(): void {
if (!areBootTasksSettled()) {
// Still busy. Start the sync behind the full gate and answer NOW, so
// the control is not silently unresponsive for the whole boot window.
void syncCalendar(config.calendar.icsUrl).catch((e) =>
void syncConfiguredCalendar(config).catch((e) =>
console.error('[calendar:sync] queued sync failed:', e)
)
emitActivityLog(
Expand All @@ -78,8 +103,8 @@ export function registerCalendarHandlers(): void {
}

// A manual sync that got here has already done its waiting.
const result = await syncCalendar(
config.calendar.icsUrl,
const result = await syncConfiguredCalendar(
config,
trigger === 'manual' ? { waitForBootMs: 0 } : {}
)
// AUD2-010: Verify result is well-formed before returning to renderer
Expand All @@ -101,18 +126,18 @@ export function registerCalendarHandlers(): void {
ipcMain.handle('calendar:clear-and-sync', async (): Promise<CalendarSyncResult> => {
const config = getConfig()

if (!config.calendar.icsUrl) {
if (!isCalendarConfigured(config)) {
return {
success: false,
error: 'No calendar URL configured',
error: missingCalendarSourceError(config),
meetingsCount: 0
}
}

try {
clearAllMeetings()
// `fresh`: must not join a sync that started before the clear.
const result = await syncCalendar(config.calendar.icsUrl, { fresh: true })
const result = await syncConfiguredCalendar(config, { fresh: true })
if (!result || typeof result.success !== 'boolean') {
console.error('[calendar:clear-and-sync] syncCalendar returned malformed result:', result)
return { success: false, error: 'Sync returned an invalid result', meetingsCount: 0 }
Expand Down Expand Up @@ -146,6 +171,23 @@ export function registerCalendarHandlers(): void {
}
})

ipcMain.handle('calendar:select-file', async () => {
try {
const focusedWindow = BrowserWindow.getFocusedWindow()
const options: Electron.OpenDialogOptions = {
title: 'Choose the iPhone calendar export',
properties: ['openFile'],
filters: [{ name: 'Calendar export', extensions: ['tsv', 'txt'] }]
}
const result = focusedWindow
? await dialog.showOpenDialog(focusedWindow, options)
: await dialog.showOpenDialog(options)
return { success: true, data: result.canceled ? null : (result.filePaths[0] ?? null) }
} catch (error) {
return { success: false, error: error instanceof Error ? error.message : 'Could not choose calendar file' }
}
})

// Toggle auto-sync
ipcMain.handle('calendar:toggle-auto-sync', async (_, enabled: unknown) => {
try {
Expand Down Expand Up @@ -207,7 +249,7 @@ export function registerCalendarHandlers(): void {
*/
export function initializeCalendarAutoSync(): void {
const config = getConfig()
if (config.calendar.syncEnabled && config.calendar.icsUrl) {
if (config.calendar.syncEnabled && isCalendarConfigured(config)) {
startAutoSync()
}
}
Expand All @@ -233,18 +275,18 @@ let autoSyncGeneration = 0
* nothing else.
*/
async function runScheduledSync(generation: number, reason: 'startup' | 'periodic'): Promise<void> {
if (reason === 'periodic' && isCalendarSyncActive()) {
if (reason === 'periodic' && (isCalendarSyncActive() || isCalendarFileSyncActive())) {
// A previous pass is still going (slow feed, or parked behind boot tasks).
// Stacking another achieves nothing — the next tick will pick it up.
console.log('Skipping periodic calendar sync: a sync is already in progress')
return
}

const currentConfig = getConfig()
if (!currentConfig.calendar.icsUrl) return
if (!isCalendarConfigured(currentConfig)) return

try {
const result = await syncCalendar(currentConfig.calendar.icsUrl, {
const result = await syncConfiguredCalendar(currentConfig, {
isStillWanted: () => generation === autoSyncGeneration
})
// The schedule may have been stopped while this was waiting on boot tasks.
Expand Down Expand Up @@ -272,7 +314,7 @@ function startAutoSync(): void {

// Sync on start. This does NOT run now: syncCalendar defers it until the boot
// tasks have drained (F15), so it no longer competes with them.
if (config.calendar.icsUrl) {
if (isCalendarConfigured(config)) {
void runScheduledSync(generation, 'startup')
}

Expand Down
Loading