Skip to content

fix(research): preserve focus when record search opens - #8663

Merged
huangruiteng merged 1 commit into
mainfrom
codex/research-record-focus-ownership
Nov 13, 2026
Merged

huangruiteng merged 1 commit into
mainfrom
codex/research-record-focus-ownership

Conversation

@loopx-agent

Copy link
Copy Markdown
Collaborator

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.

Author Declaration

  • Written by: model_agent (OpenAI Codex).
  • Implemented against: no separate written specification; the Research keyboard regression above is the basis.
  • Self-check: Reproduced the loss before changing the component and ran the full packaged search scenario after the fix.

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

  • Tested revision: 1b759c8276c976b6fa4aeb373d905f755dea5e2b; failing baseline ce69003c73378fdb067a6b86e7b60feb50cb1b77.
  • Run state: finished locally; GitHub CI pending.
  • Input classes: synthetic.
Check kind Result Evidence
regression_parity passed Same held-frame interaction loses focus on the baseline; the packaged fix retains focus, opens the selected group on Enter, and closes it on Escape.
real_entrypoint passed Packaged research-record-search browser scenario, including ordinary autofocus, read/search/export, failed read and retry, and Goal isolation.
static passed Dashboard TypeScript check and verified Chat bundle.

Frontend / Visual Evidence

  • UI impact: changed (keyboard focus).
  • First viewport: packaged Dashboard, synthetic Research records. Desktop 1440 × 900 before and after the delayed callback and Enter; narrow 390 × 900 after. The focus outline and expanded records show which element received Enter.

Before: focus returns to the input and the record group remains closed.

Before: the search input retakes focus and the record group is closed

After: the focused record group opens.

After: the focused research record group opens when Enter is pressed

Narrow viewport:

Narrow viewport: the focused record group opens

Type of Change

  • Bug fix
  • Test update

LoopX Area

  • Public docs or presentation surface (README, protocols, dashboard)

Shared-authority RFC fixture impact

N/A; no authority or stored state change.

Boundary Checklist

  • Public-safe diff and synthetic screenshots.
  • Scoped change; no RFC pair changed.
  • Visual evidence included.
  • Every commit includes a DCO sign-off.

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@huangruiteng
huangruiteng merged commit c89262d into main Nov 13, 2026
32 of 37 checks passed
@huangruiteng
huangruiteng deleted the codex/research-record-focus-ownership branch November 13, 2026 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants