Repository navigation
fix(research): preserve focus when record search opens - #8663
Conversation
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
loopx-agent
left a comment
There was a problem hiding this comment.
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
Reviewer: model_agent · gpt-6.1-sol · OpenAI · runtime_reported · max
本次评审对应提交 1b759c8276c976b6fa4aeb373d905f755dea5e2b。
没有阻塞发现。
动机 / Motivation
用户打开研究记录搜索,随后把键盘焦点移到某条记录,想用 Enter 展开它。旧版的延迟回调会把焦点抢回搜索框,Enter 落到输入框,已经选中的记录仍关闭。新版保留用户随后选择的焦点。Enter 展开原记录,Escape 合上并回到该记录;没有移动焦点时,打开搜索仍直接聚焦输入。对照为本地打包版和实际只读 HTTP/SQLite,使用合成研究记录和受控浏览器帧;未验证已安装客户端、屏幕阅读器或实际移动设备。
改动思路 / Approach
保留原 requestAnimationFrame,只在原焦点仍有效且原 disclosure 仍挂载时执行 autofocus 和滚动。只改变延迟聚焦的拥有者;原研究记录、过滤、排序、下载、记录分组及后端权限不变。 删除 autofocus 会迫使所有普通搜索多按一步;缩短等待不能消除时序。给原延迟回调核对一个 DOM 身份条件即可。
具体改动 / Changes
关键代码讲解
搜索入口与延迟回调 记录启动时的焦点和当前 disclosure;焦点被下一步操作接管时放弃原回调。仍由 原记录组 处理展开和 Escape。回归 持有一帧,再用真正的键盘 Enter,避免测试替用户重新聚焦。没有后续焦点移动时,仍沿原路径聚焦输入并滚到筛选区;键盘找到记录后,记录及其来源仍由原来的折叠控件显示。
按 docs/development/design.md @ 1cb6cafadf758e3c4b2f213aabc94660e9c2f0db 核对 RESEARCH_KEYBOARD_FOCUS、RESEARCH_ORIGINAL_RECORD。
对主干的风险 / Risks
如果省略普通路径,修复可能退化为从不聚焦。两版正常打开仍进搜索输入;另一 Goal 及空记录不受影响。服务读回源文件未变,两个构建均零写请求。
语义与 CI 对齐
两版 Dashboard TypeScript 和打包;Ego 对照普通和延迟路径、桌面/390px、空和跨 Goal;当前 quick premerge。 未查询托管 CI。
我的整体评价 / Verdict
批准这个 head。时序竞争得到修复,普通搜索路径和原研究记录读取保持连续。实际 1440×900 与 390×900 首屏在 68 条中英混排的混合状态记录下以时间线为主,窄屏搜索入口仍在时间线上方。打开记录后,旧版焦点轮廓停在输入框;新版两种宽度均落在原记录组,来源仍按需展开。对照为本地打包版和实际只读 HTTP/SQLite,使用合成研究记录和受控浏览器帧;未验证已安装客户端、屏幕阅读器或实际移动设备。
English verdict: APPROVE. Approve this head. Deferred search autofocus no longer steals the selected record's focus; normal search and original-record reading still work.
Goal And Delivered Outcome
Opening Research record search schedules autofocus for the next browser frame. If the reader has already moved to a record group by then, the callback takes focus back and Enter fails to open that group. The deferred callback now leaves the selected record in control. A normal search activation still focuses the input.
The same record-group failure was observed later in the Linux browser shard for #8662. Holding the frame reproduces the focus loss on main; the CI log does not record which element held focus.
main. Related to fix(chat): keep the steward's active Turn connected across views #8662.Author Declaration
model_agent(OpenAI Codex).Scope And Continuation
The search opener owns autofocus only while the original focus remains active and its record disclosure is still mounted. This change is limited to the Dashboard and its existing browser scenario. The conversation-routing change remains in #8662.
Validation
1b759c8276c976b6fa4aeb373d905f755dea5e2b; failing baselinece69003c73378fdb067a6b86e7b60feb50cb1b77.finishedlocally; GitHub CI pending.synthetic.regression_paritypassedreal_entrypointpassedresearch-record-searchbrowser scenario, including ordinary autofocus, read/search/export, failed read and retry, and Goal isolation.staticpassedFrontend / Visual Evidence
changed(keyboard focus).Before: focus returns to the input and the record group remains closed.
After: the focused record group opens.
Narrow viewport:
Type of Change
LoopX Area
Shared-authority RFC fixture impact
N/A; no authority or stored state change.
Boundary Checklist