Repository navigation
fix: 建立前端统一运行环境判断层并修复宽屏触控设备进入会话误弹软键盘 - #1829
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a1b8e14821
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| focusSearch: (opts?: { avoidKeyboard?: boolean }) => | ||
| ((opts?.avoidKeyboard ? null : searchInput.value) ?? scrollEl.value)?.focus({ preventScroll: true }), |
There was a problem hiding this comment.
Preserve listbox keyboard handling when bypassing search focus
On a coarse-pointer tablet with a hardware keyboard and at least 20 models, opening the composer’s model submenu now focuses the scroll viewport instead of the search input. However, ModelOptions only attaches the viewport’s onKeydown handler when showSearch is false, while composer-model-menu.vue stops these key events from propagating. Consequently, Arrow keys no longer update the active model and Enter cannot select it from the initial focus position. Keep the listbox keyboard handler available on the viewport when avoidKeyboard redirects focus there, so avoiding the software keyboard does not break hardware-keyboard navigation.
Useful? React with 👍 / 👎.
a1b8e14 to
0261838
Compare
Author
Type
Summary
问题
composables/useIsMobile.ts仅查询视口宽度width < 768px(紧凑单栏布局断点),但函数名使用了移动设备含义。store/workspace-tabs.ts中的focusChatInputAfterEntry与composer-model-menu.vue复用了isMobile判断是否跳过自动聚焦或点选后收起子菜单。在视口宽度>= 768px的触控主导设备(iPad、Android 平板、横屏现代 iPhone、开启桌面版网站的手机)上,isMobile为false,用户点击会话项切换会话时,微任务链在点击手势有效期内调用textarea.focus(),触发 WebKit 每次弹出虚拟软键盘。message-item.vue单独调用useMediaQuery判断触控指针;平台识别在keyboard-bindings.ts、pages/runtimes/command.ts、useMacTrafficReserve.ts中存在三套实现;prefers-reduced-motion在 Web 与 Desktop 共 12 处直接调用window.matchMedia;6 处布局与页面各自调用inject(DesktopShellKey, false)。修改内容
apps/web/src/lib/runtime-env.ts(同步原语,导出@memohai/web/lib/runtime-env供 Desktop 渲染层复用):集中定义标准媒体查询常量、操作系统族识别detectOsFamily(区分android、ios、mac、windows、linux、unknown)与同步减动效读取prefersReducedMotion。apps/web/src/composables/useEnvironment.ts(响应式组合层):按四个正交维度拆分提供useCompactShell(布局空间< 768px)、useCoarsePointer/useTouchPointer/useCanHover/useInputModality(主输入与any-*共存输入矩阵及canAutoFocusInput)、useDesktopShell(宿主容器)与useReducedMotion(减动效偏好)。composables/useIsMobile.ts:workspace-tabs单栈约束、master-detail-sidebar-layout、settings-section、bots/detail、composer-continue-on)改用useCompactShell。workspace-tabsfocusChatInputAfterEntry)与模型选择器子菜单聚焦/收起(composer-model-menu、model-options)改用useCoarsePointer。message-item)、平台识别(keyboard-bindings、runtimes/command、useMacTrafficReserve)、宿主壳读取与全部 12 处prefers-reduced-motion调用点(含apps/desktop/src/renderer/src/connect/ConnectServer.vue)统一迁入新入口。eslint.config.mjs新增no-restricted-syntax规则,禁止apps/web/src与apps/desktop/src/renderer业务代码直接调用useMediaQuery、matchMedia或读取navigator.platform/userAgent/maxTouchPoints。.agents/skills/memoh-frontend-rules(SKILL.md、references/rules.md、references/review.md、references/architecture.md、references/upkeep.md)及目录行号。行为、外观与默认值变更清单(D2)
width >= 768px且pointer: coarse,含 iPad、平板及横屏手机):保持双栏多面板布局不变;打开/切换会话与新建会话不再自动聚焦对话输入框;展开模型子菜单不再自动聚焦搜索输入框(改为聚焦滚动容器),且点选模型或推理强度后自动收起当前子菜单。用户主动点击输入框或外接实体键盘直接按键(经useUnfocusedComposerInput)仍正常输入。width < 768px且非pointer: coarse,如拉窄窗口的桌面浏览器):切换为紧凑单栏布局,进入会话时继续自动聚焦输入框。send-morph-icon.vue与dot-matrix-bg.vue改为响应式订阅useReducedMotion(),运行期切换系统减动效设置立即生效。workspaceTabs.isMobilestore 属性名保持不变以避免 Cloud 侧调用冲突;同步至felinics/Memoh-Cloud时需将 Cloud 专属页面(如pages/saas/*.vue、components/feedback/feedback-dialog.vue)中的直接navigator.platform/useMediaQuery调用同步迁入统一入口以满足新增 ESLint 规则。Related Issues
Validation
自动化检查
pnpm exec eslint apps/ packages/ eslint.config.mjs:0 errors(含新增环境原语拦截规则)。node scripts/check-ui-contract.mjs与node scripts/check-settings-rows.mjs:通过。pnpm --filter @memohai/web typecheck与pnpm --filter @memohai/desktop typecheck:通过。pnpm test(Vitest 全量前端测试):312 个测试文件全部通过(2913 passed, 1 skipped),含新增的runtime-env.test.ts、useEnvironment.test.ts及workspace-tabs.test.ts宽屏触控平板与窄窗口桌面回归测试。Agent 本地运行与真实界面验证(非人工 QA)
http://127.0.0.1:8084)代理连接本地memoh-dev后端(http://localhost:18080),使用ego-browser(Chromium)实测并截图:1280x800,pointer: fine):双栏工作台正常渲染,点击历史会话后document.activeElement自动落入TEXTAREA,输入框呈现聚焦边线。1024x768,pointer: coarse,width >= 768px):保持双栏工作台布局,点击新建会话与切换历史会话后document.activeElement未落入TEXTAREA(输入框保持静息边线,不触发软键盘);主动点击输入框后正常聚焦TEXTAREA。390x844,pointer: coarse,width < 768px):切换为紧凑单栏移动端外壳,进入会话不自动聚焦TEXTAREA。Screenshots / Recordings
1. 桌面精细指针(
1280x800):双栏布局 + 切换会话自动聚焦输入框2. 宽屏粗指针平板(
1024x768,pointer: coarse):保持双栏布局 + 切换会话不自动聚焦输入框3. 窄屏粗指针手机(
390x844):紧凑单栏外壳 + 不自动聚焦输入框Human QA