perf(read): 库读取链路与入库总量解耦(A 提速 + B 结构性分页)#2
Merged
Conversation
Stage A(行为不变的提速,不改 DTO 形状与功能):去掉侧边栏树响应的服务层/IPC/前端三重 Zod 校验;readSnapshot/Lite 始终 safeParse 不深拷贝;focus/visibilitychange 前台刷新加最小间隔去重;readLibrarySnapshotLite 在 DB 有数据时不再触发整库 readSnapshot。验收:lint 0 warning、build 通过、911/913 测试通过。
为结构性分页打基础,纯加法、行为不变: - 新增 readSourceImages IPC 链路(channels/schema/types/preload/facade/service/repository/mock):按 source_id 从内存快照返回单个源的可见图片项 - ImagePackage 视图模型新增可选 imageCount/coverMediaLocator,mapImagePackageDto 从现有 images 派生填充(消费点后续以 ?? images.length 兜底切换) 验收:build + build:electron + lint 0 warning + 912 测试通过。
为 B-3 切换(侧边栏不再携带全量 images)做准备,行为中性(当前 imageCount == images.length): - 新增 resolveSourceImageCount(source) = imageCount ?? images.length,结构化最小参数类型 - 将 allScopedRefs 枚举、visibleImageRefs、导航/钳制边界、totalPages、node-browse 计数、rar/7z 待归一化判断、会话光标恢复等约 12 处 images.length/枚举改指 imageCount - node-browse 可见计数改用服务端权威的 directImageCount 验收:build + lint 0 warning + 912 测试通过。
为侧边栏瘦身做准备,当前完全惰性(sidebar 仍带 images 时不触发加载、不改合并结果): - 新增 useSourceImageCache:按 source id 懒加载图片、会话内保留、includeHidden/库版本变化时失效 - useAppSidebarScopeState 注入 repository/selectedPackageId/includeHidden,仅在源 images 为空且 imageCount>0 时按需加载并合并 - validImageIdSet 改为从合并后的 packageByIdEffective 取 id 验收:build + lint 0 warning + 912 测试通过。
结构性分页切换完成:渲染进程不再常驻全库 images,单文件夹浏览代价与入库总量解耦。 后端:readImageSidebarTree 响应改为 image_count + cover_media_locator(去 images[]);新增 imageSourceSidebarDtoSchema;mock 同步瘦身。 前端:mapImageSourceSidebarDto 产出空 images + imageCount + coverMediaLocator;自动聚焦/首图判定改用 imageCount/cover(不再扫描 images);node-browse 封面改用 coverMediaLocator;按需缓存补同步路径供测试。 测试:sidebar 响应构造助手与后端集成测试改用 image_count/readSourceImages。 验收:build + build:electron + lint 0 warning + madge 0 循环 + 912 测试通过。
向量检索结果横跨多个源,原先仅加载选中包会导致其它源缩略图空白;neededSourceIds 在向量模式下纳入全部结果源。验收:build + lint + 912 测试通过。
Stage B 引入按需加载后,ad-review 结果横跨多源时只显示首包、默认 0/N。 - useManageAdReviewActions 将候选 package_id 与 image_id 经 sessionState 回传 - useAppSidebarScopeState 把候选包纳入 neededSourceIds(按需加载这些源),并把候选 image_id 纳入 validImageIdSet(防止加载窗口内被 useManageSelection 剪枝导致默认全选被清空) 修复:①父级目录聚合结果自动全显示;②默认全选 N/N(非 blur),人工剔除才变 blur。 验收:build + build:electron + lint 0 warning + madge 0 循环 + 912 测试通过。
记录侧边栏 slim + readSourceImages 按需加载模型、跨源视图预加载约束、resolveSourceImageCount 计数规则。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
入库内容达到一定量后整体卡顿,根因是整库 images 常驻渲染进程并在侧边栏/快照读取链路被反复全量遍历 + 三重 Zod + IPC 序列化。
Stage A(行为不变的提速)
Stage B(结构性分页)
验收
build + build:electron + lint 0 warning + madge 0 循环 + 912 测试通过;已用大库实测切换/alt-tab/全屏/AdReview。文档已同步 docs/04、docs/06。