@@ -19,6 +19,7 @@ import { getCaptureRateScale, onPerformanceModeChange } from './performanceMode.
1919import { loadProcessAudioNative } from './audio/processAudioNative.js' ;
2020import { parseHwndFromSourceId , buildNativeIndex , resolveGeometrySignals } from './windowSignals.js' ;
2121import type { NativeWindowSignal } from './windowSignals.js' ;
22+ import { recordChoice , clearMemory , lookupMemory , computeMemoryBoost } from './windowHistory.js' ;
2223
2324// ================================================================
2425// 模块级状态
@@ -259,7 +260,18 @@ export function registerScreenCaptureHandlers(): void {
259260 } ) ;
260261
261262 // 智能评分、过滤与排序(阶段一:空信号映射,纯标题评分)
262- return scoreAndFilterWindows ( rawWindows , { signalsBySourceId : buildSignalMap ( sources ) } ) ;
263+ const scored = scoreAndFilterWindows ( rawWindows , {
264+ signalsBySourceId : buildSignalMap ( sources ) ,
265+ memoryLookup : ( processName : string , title : string ) => {
266+ const entry = lookupMemory ( processName , title ) ;
267+ if ( ! entry ) return null ;
268+ return {
269+ courseName : entry . courseName ,
270+ boost : computeMemoryBoost ( entry , Date . now ( ) ) ,
271+ } ;
272+ } ,
273+ } ) ;
274+ return scored ;
263275 } catch ( err ) {
264276 logger . error ( '[IPC] screen_list_windows failed:' , err ) ;
265277 return [ ] ;
@@ -295,7 +307,17 @@ export function registerScreenCaptureHandlers(): void {
295307 return { id : src . id , title : src . name , thumbnail : thumb . toDataURL ( ) } ;
296308 } ) ;
297309
298- const scored = scoreAndFilterWindows ( rawWindows , { signalsBySourceId : buildSignalMap ( sources ) } ) ;
310+ const scored = scoreAndFilterWindows ( rawWindows , {
311+ signalsBySourceId : buildSignalMap ( sources ) ,
312+ memoryLookup : ( processName : string , title : string ) => {
313+ const entry = lookupMemory ( processName , title ) ;
314+ if ( ! entry ) return null ;
315+ return {
316+ courseName : entry . courseName ,
317+ boost : computeMemoryBoost ( entry , Date . now ( ) ) ,
318+ } ;
319+ } ,
320+ } ) ;
299321
300322 // 推送到渲染进程
301323 const mainWindowId = getMainWindowId ( ) ;
@@ -323,6 +345,22 @@ export function registerScreenCaptureHandlers(): void {
323345 }
324346 return { success : true } ;
325347 } ) ;
348+
349+ safeHandle ( 'window_memory_record' , async ( _event , payload : { processName ?: string ; title ?: string ; courseName ?: string } ) => {
350+ const processName = typeof payload ?. processName === 'string' ? payload . processName : '' ;
351+ const title = typeof payload ?. title === 'string' ? payload . title : '' ;
352+ if ( ! processName || ! title ) {
353+ return { success : false } ;
354+ }
355+ const courseName = typeof payload ?. courseName === 'string' ? payload . courseName : undefined ;
356+ recordChoice ( processName , title , courseName ) ;
357+ return { success : true } ;
358+ } ) ;
359+
360+ safeHandle ( 'window_memory_clear' , async ( ) => {
361+ clearMemory ( ) ;
362+ return { success : true } ;
363+ } ) ;
326364}
327365
328366/**
0 commit comments