@@ -41,6 +41,12 @@ interface StudySessionState {
4141 cardStartTime : Date | null ;
4242 /** v0.9.0: 本次会话中收集的 goldenErrors */
4343 goldenErrors : GoldenError [ ] ;
44+ /** v0.29: 上一次评分的 stability 变化(供 MemoryStrengthPulse 消费) */
45+ lastStabilityBefore : number | null ;
46+ lastStabilityAfter : number | null ;
47+ lastRating : number | null ;
48+ /** v0.29: 记忆强度脉冲可见性 */
49+ showStrengthPulse : boolean ;
4450
4551 // 会话操作
4652 startSession : ( deckId : string ) => Promise < void > ;
@@ -84,6 +90,10 @@ export const useStudySessionStore = create<StudySessionState>((set, get) => {
8490 isActive : false ,
8591 cardStartTime : null ,
8692 goldenErrors : [ ] ,
93+ lastStabilityBefore : null ,
94+ lastStabilityAfter : null ,
95+ lastRating : null ,
96+ showStrengthPulse : false ,
8797
8898 // -----------------------------------------------------------------------
8999 // startSession:加载到期卡片 + 补充新卡(带每日限额)
@@ -100,12 +110,11 @@ export const useStudySessionStore = create<StudySessionState>((set, get) => {
100110 ) ;
101111 const now = new Date ( ) ;
102112
103- // 每日限额:查询当日已复习数量
113+ // 每日限额:用 reviewedAt 索引查询当日已复习数量,避免 getAll 全量加载
114+ // 所有复习记录(增长最快的数据,半年可达数万条)再内存 filter(P1-8 性能修复)
104115 const todayStart = new Date ( now . getFullYear ( ) , now . getMonth ( ) , now . getDate ( ) ) ;
105- const allReviews = await flashcardReviewStore . getAll ( ) ;
106- const reviewsToday = allReviews . filter (
107- ( r ) => new Date ( r . reviewedAt ) >= todayStart ,
108- ) . length ;
116+ const reviewsToday = await flashcardReviewStore . getTable ( )
117+ . where ( 'reviewedAt' ) . aboveOrEqual ( todayStart ) . count ( ) ;
109118 const maxReviews = getMaxReviewsPerDay ( ) ;
110119 const maxNewCards = getMaxNewCardsPerDay ( ) ;
111120
@@ -308,6 +317,11 @@ export const useStudySessionStore = create<StudySessionState>((set, get) => {
308317 isActive : false ,
309318 isFlipped : false ,
310319 cardStartTime : null ,
320+ // v0.29: 记忆强度追踪
321+ lastStabilityBefore : card . stability ?? 0 ,
322+ lastStabilityAfter : result . stability ?? 0 ,
323+ lastRating : rating ,
324+ showStrengthPulse : true ,
311325 } ) ;
312326 } else {
313327 // 推进到下一张卡片
@@ -319,6 +333,11 @@ export const useStudySessionStore = create<StudySessionState>((set, get) => {
319333 goldenErrors : newGoldenErrors ,
320334 isFlipped : false ,
321335 cardStartTime : new Date ( ) ,
336+ // v0.29: 记忆强度追踪
337+ lastStabilityBefore : card . stability ?? 0 ,
338+ lastStabilityAfter : result . stability ?? 0 ,
339+ lastRating : rating ,
340+ showStrengthPulse : true ,
322341 } ) ;
323342 }
324343 } ,
0 commit comments