fix(search): make Cmd+F work when chat is in a folder or on mobile#1692
fix(search): make Cmd+F work when chat is in a folder or on mobile#1692piorpua merged 4 commits intoiOfficeAI:mainfrom
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
When a conversation is inside a folder, hasTabs becomes true and ChatTitleEditor (which contains the minimap Cmd+F listener) doesn't render. Same on mobile where isMobile gates it out. - Add hideTrigger prop to ConversationTitleMinimap to hide the trigger button while keeping the shortcut listener and panel active - Render hidden minimap in ChatLayout when hasTabs || isMobile - Change panel positioning from trigger-anchored to header-centered - Adapt panel width to narrow viewports (< 768px) - Add vertical clamping to prevent panel overflow - Add 5 tests for getPanelWidth viewport behavior
0845cf2 to
e1705f3
Compare
Code Review:fix(search): make Cmd+F work when chat is in a folder or on mobile (#1692)变更概述本 PR 包含两个独立部分:① 修复 Cmd+F 快捷键在 hasTabs / isMobile 模式下失效的问题,通过在 方案评估结论:✅ 方案合理 Cmd+F 修复思路正确——通过互斥条件( 唯一的设计层面疑问:Cmd+F 修复与 PWA 支持是两个完全独立的功能,合并在同一 PR 增加了回滚粒度,建议下次拆分提交。 问题清单🟡 MEDIUM —
|
| # | 严重级别 | 文件 | 问题 |
|---|---|---|---|
| 1 | 🟡 MEDIUM | useMinimapPanel.ts:152–179 |
新增定位逻辑 patch 覆盖率仅 42.85%,三条定位分支无测试 |
| 2 | 🔵 LOW | public/sw.js:1 |
硬编码缓存名,部署新版本时可能出现旧资源残留 |
结论
本报告由本地 pr-review skill 生成,包含完整项目上下文,无截断限制。
Code Review:fix(search): make Cmd+F work when chat is in a folder or on mobile (#1692)变更概述本 PR 分为两部分:① Cmd+F 修复:通过新增 方案评估结论: Cmd+F 修复方案本身逻辑清晰——将 shortcut listener 的生命周期与 trigger 按钮解耦,不影响现有 问题清单🟡 MEDIUM — PR 描述与实际变更范围严重不符文件:PR 描述 问题说明:PR 标题、描述、"Files changed" 一节均仅提及 6 个 minimap 相关文件,而实际 diff 包含 14 个 PWA 相关文件: 修复建议:更新 PR 描述,增加 PWA 相关的 Summary / Files changed 说明,包括 SW 策略(navigate → networkFirst,assets → staleWhileRevalidate)、manifest 信息、以及对 Electron 运行时的豁免逻辑。 🟡 MEDIUM — 缺少 hideTrigger 路径的行为测试文件: 问题说明:本 PR 的核心修复是:当 修复建议:在 it('registers Cmd+F listener when hideTrigger=true (no trigger DOM element)', () => {
// render <ConversationTitleMinimap conversationId="c1" hideTrigger />
// fire Cmd+F keyboard event
// assert openSearchPanel was called (panel becomes visible)
});🔵 LOW — sw.js 未使用 TypeScript / 缺少类型检查覆盖文件: 问题说明: 修复建议:可在文件顶部添加 JSDoc 类型注释(如 汇总
结论
本报告由本地 |
…ription - Add test: hideTrigger=true hides trigger button (no span[role=button] rendered) - Add test: Cmd+F listener still active when hideTrigger=true (panel opens on keyboard shortcut) - Update PR iOfficeAI#1692 description to document the 14 PWA-related files that were missing from the original description (sw.js, manifest.webmanifest, registerPwa.ts, icons, build config changes, index.html updates) Review follow-up for iOfficeAI#1692
PR Fix 验证报告原始 PR: #1692
总结: ✅ 已修复 2 个 | ❌ 未能修复 0 个
|
Closes #1693
Summary
ConversationTitleMinimap, which only mounted viaChatTitleEditor— gated behind!hasTabs && !isMobilehideTrigger) inChatLayoutwhen tabs or mobile are active, keeping the Cmd+F listener alivesw.js),manifest.webmanifest, PWA icons, andregisterPwa.tsservice — Electron desktop is explicitly excluded viaisElectronDesktop()guardMotivation
When a chat is inside a folder,
hasTabsbecomes true andChatTitleEditor(which contains the minimap + Cmd+F listener) doesn't render. The shortcut silently stops working. Same on mobile —isMobilegates out the editor. Users had no way to search conversation content via keyboard in these cases.Diff
+109 −41across 20 files (5 Cmd+F fix + 14 PWA + 1 updated test)Files changed
Cmd+F fix (6 files)
ChatLayout/index.tsx— +2: render hidden minimap whenhasTabs || isMobileConversationTitleMinimap/index.tsx— +36 −27:hideTriggerprop conditionally hides trigger, panel stays activeminimapTypes.ts— +2: addedhideTriggerprop to typeminimapUtils.ts— +5 −2:getPanelWidthtakes full width on narrow viewports (< 768px)useMinimapPanel.ts— +19 −12: header-centered positioning + vertical clamping + narrow viewport handlingminimapPanelWidth.dom.test.ts— +45: new file, 5 tests forgetPanelWidthviewport behaviorPWA support (14 files)
public/sw.js— new: service worker withnavigate→networkFirst,assets→staleWhileRevalidatestrategypublic/manifest.webmanifest— new: web app manifest (name, icons, display, theme color)public/pwa/icon-180.png,icon-192.png,icon-512.png— new: PWA iconssrc/renderer/services/registerPwa.ts— new: registers SW only in browser mode (skips Electron, non-secure contexts, non-http protocols)src/renderer/main.tsx— callsregisterPwa()on startupsrc/renderer/index.html— adds manifest link and apple-touch-icon meta tagpublic/index.html— removed (superseded bysrc/renderer/index.html)electron.vite.config.ts— addspublicDirto renderer build configvite.renderer.config.ts— updates renderer build to include public assetstests/unit/renderer/services/registerPwa.dom.test.ts— 6 tests covering all guard conditionstests/integration/webui-pwa-build.test.ts— integration test verifying build output includes SW and manifesttests/unit/webuiServiceWorker.test.ts— unit tests for SW fetch strategy logicTesting
bunx tsc --noEmit— no type errorsbun run lint:fix— cleanvitest run— all tests passRisks / Side effects
Minimal — no changes to ChatTitleEditor, no new dependencies. Two minimap instances can exist but never simultaneously (mutually exclusive guards). Service worker only activates in WebUI browser mode and is guarded against insecure contexts and Electron.