Skip to content

fix(chat): keep the focus on a todo update its run folds in, and show each update's own input and output (#1601) - #2161

Merged
devswha merged 4 commits into
mainfrom
fix/todo-fold-focus
Oct 28, 2026
Merged

devswha merged 4 commits into
mainfrom
fix/todo-fold-focus

Conversation

@devswha

@devswha devswha commented Oct 28, 2026

Copy link
Copy Markdown
Owner

Change

Fixes the two gaps #1601 still had after #1846 folded contiguous todo updates into one Plan row.

  • Focus survives the fold. When the agent's second todo update turned the single row the reader was on into a Plan row, the focused button left the page and the keyboard focus fell to <body> (expansion already carried over since fix(chat): keep a tool you opened in place while GJC streams, and through its rewrites #1937). A row head now records in its timeline row's memory that it holds the focus (useRowFocus, src/lib/chatRowState.tsx). The head drawn in its place in the same render takes the focus back: the same update inside the opened run, or the run's own head when it is folded. Focus the reader moved elsewhere is never taken, a head that leaves with no replacement ends its record (a row scrolled back or reopened later never grabs the focus), and a fold while the reader is in another app keeps it too.
  • Each attempt shows its own call. An update opened inside the Plan row showed the parsed list again, which the run already shows above it. It now shows the input the agent sent (JSON indented, under "Input") and the output it got back, including "Show the whole output" for a cut one.

Design: the Codex and Claude apps keep one row per action under the turn and keep the reader's place while a turn streams. This follows that, as #1846's DESIGN.md entry does; the entry now records both rules. "Input" is translated into Korean, Japanese and Chinese. A changelog.d/ fragment is included.

Closes #1601.

Validation

  • Regressions that fail before and pass after:
    • scripts/chat-gjc-streaming-browser-qa.ts (browser lane): its todo scenario now asserts the focus is on the opened update inside the Plan row after the next update arrives. On main all four variants (1440/390 × append/rewrite) failed with the focus on BODY; on this branch all pass.
    • src/components/ChatTurn.test.ts: an opened two-update run shows each update's raw input and output.
  • scripts/todo-snapshots-demo-regression.ts: 21/21 pass (1440/390, light/dark, Korean), including "open, focused run through append and poll".
  • bun run check fast: green on b4d51fd (unit tests 7886 pass, 0 fail). On the final head 12c0c34 (one line added to useRowFocus), typecheck, build and generated files pass; the unit tests had one timeout in an untouched file, scripts/ci-browser.test.ts "creates evidence under .ci when CI has no CHECK_DIR" (5029 ms on a 5 s limit at host load ~66). Rerun on its own, it passes in 3.4 s (7/7).
  • Not covered by an automated test: the background-window case (headless Chromium always reports the page focused) and StrictMode's rehearsed unmount (the browser fixture renders without StrictMode). Both were reviewed at source level and confirmed by Codex's last round.
  • Reviews: omo-native-code-reviewer PASS (its MEDIUM, a window blur ending the record, fixed; the over-long DESIGN.md line fixed; other LOWs out of scope). Codex Sol 6.1 Fast xhigh: round 1 MEDIUM (a stale record after a head left with no replacement) fixed; round 2 MEDIUMs (StrictMode rehearsal, focus events deferred while the window is in the background) fixed; the confirmation round on the final head PASS with no findings.

… each update's own input and output (#1601)

When the next todo update turned the single row the reader was on into a Plan row, the
button holding the keyboard's focus left the page and the focus fell to <body>. A row head
now records that it holds the focus in the timeline row's memory, and the head drawn in its
place (the same update inside the opened run, or the run's own head) takes it back when the
focus fell to the page; focus the reader moved elsewhere is never taken.

An update opened inside the Plan row showed the parsed list again, which the run already
shows. It now shows the input the agent sent (JSON indented) and the output it got back.
…the window is away

Review follow-up. A head that left with no head drawn in its place in the same render kept its
record, so a row remounted later (scrolled back, opened again) could take the focus from the
page. The record is now one object per focus and ends a microtask after its head leaves unless
a replacement took it. A blur from the window losing the focus no longer ends it, so a fold that
happens while the reader is in another app still keeps the focus on their row.
…nmount

StrictMode runs an effect's cleanup and the effect again on the same element; the record's
cleanup now ends it only when its head has really left the page.
…not only on the event

With the window in the background the browser moves the focus to the restored head but sends
its focus event only when the reader comes back, so the record was not renewed and the old
head's cleanup ended it; the next regrouping before the reader returned dropped the focus.
@coderabbitai

coderabbitai Bot commented Oct 28, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 9 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 99547b0 and 12c0c34.

Files selected for processing: 9
  • DESIGN.md
  • changelog.d/todo-run-focus-raw-attempts.md
  • scripts/chat-gjc-streaming-browser-qa.ts
  • src/components/ChatTurn.test.ts
  • src/components/ChatView.tsx
  • src/lib/chatRowState.tsx
  • src/lib/i18n/chat.ja.ts
  • src/lib/i18n/chat.ko.ts
  • src/lib/i18n/chat.zh.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devswha

devswha commented Oct 28, 2026

Copy link
Copy Markdown
Owner Author

Fast checks on 12c0c34 failed on one test outside this PR: server/codex.test.ts:912 "reads short answers in bounded time however many unclosed links the answers hold" measured a timing ratio of 9.13 against a limit of 8 (job 122618868817). This PR changes only client code (src/, the GJC browser QA script, docs and the changelog) and touches no Codex parsing. Typecheck, build, generated files and the other 7903 unit tests passed. I will rerun the failed job once when the run finishes.

@devswha

devswha commented Oct 28, 2026

Copy link
Copy Markdown
Owner Author

The rerun failed on the same test again (server/codex.test.ts:912, ratio 8.40 against 8, job 122627600699). Everything else is green, including Integration and browser, which runs this PR's GJC focus check and the todo demo regression. That bound is being fixed in #2169. Once #2169 merges I will merge main into this branch, so Fast checks reruns with the fixed bound; the merge pass may also take it as is.

@devswha

devswha commented Oct 28, 2026

Copy link
Copy Markdown
Owner Author

Fast checks passed on the rerun of 12c0c34, so every required check on this head is green. I am not pushing the merge of main I mentioned: it would only restart green CI. A local merge with current main (d9050a0, which includes #2169) merges cleanly, and bun run check fast on it passed (7926 pass, 0 fail).

@devswha

devswha commented Oct 28, 2026

Copy link
Copy Markdown
Owner Author

Merging 12c0c34: omo-native-code-reviewer and Codex both pass this head, and the new input/output test fails on main. The required checks are green; Fast checks first failed on #2150's new CPU-ratio test in server/codex.test.ts and passed on rerun. CodeRabbit did not review this head. The LOW notes go to a follow-up issue.

@devswha
devswha merged commit 97f957b into main Oct 28, 2026
27 of 29 checks passed
@devswha
devswha deleted the fix/todo-fold-focus branch October 28, 2026 04:46
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.

Chat: fold consecutive todo updates into one expandable row

1 participant