Skip to content

fix(record): preserve contenteditable line breaks - #603

Open
tlysanhuo wants to merge 1 commit into
Tencent:mainfrom
tlysanhuo:fix/record-contenteditable-lines
Open

tlysanhuo wants to merge 1 commit into
Tencent:mainfrom
tlysanhuo:fix/record-contenteditable-lines

Conversation

@tlysanhuo

Copy link
Copy Markdown

Recording a contenteditable editor used textContent, so typing Alpha, Enter, Beta produced a final Trace v3 fill of AlphaBeta. Preserve Alpha\nBeta and keep blank/trailing lines without treating a caret placeholder <br> as extra content.

Fixes #594.

Extract the existing fill verification reader into a self-contained shared function and use it for recording as well. Native inputs and textareas retain their .value; simple editable lines retain their existing whitespace/placeholder handling, and rich structures retain rendered-text handling. The fill tool serializes the same function into the page. Includes English and Chinese changelog entries.

Validation on Node.js 22.23.4 / Chrome for Testing 157.0.8103.38 (Linux):

  • The 14 new regression cases against unchanged main: 10 failed, 4 passed. With the fix, those cases plus the existing fill browser suite: 182 passed.
  • Real browser cases cover Enter, Shift+Enter, blank lines, trailing newline, rich paragraphs, pasted newlines, plaintext-only editing, textarea values, redaction, empty placeholders and clearing an editor. The minified reader is also serialized back into the page and checked.
  • Full default extension suite: 3,699 passed, 428 opt-in tests skipped. The new browser suite and existing fill browser suite were run explicitly as described above.
  • Extension TypeScript check, production build and pnpm lint passed. The lint command includes DSH checks: 713 passed, 10 skipped; dependency source-map warnings were non-fatal.
  • Changelog synchronization and git diff --check passed.

Run the browser regressions with:

BSK_CLICK_CHROME=/path/to/chrome BSK_FILL_CHROME=/path/to/chrome pnpm --filter @browser-skill/extension exec vitest run src/content/__tests__/record-contenteditable.browser.test.ts src/tools/__tests__/fill.browser.test.ts

The recording browser tests bundle the production capture, step buffer and Trace v3 reducer, using native CDP input in an isolated browser/profile. They supply synthetic observation state IDs; they do not cover the installed extension's transport, observation matching, daemon or CLI. Rust tests were not run because no Rust code changed. Browser regressions are opt-in; this PR does not change CI workflows.

Implemented and tested with Codex assistance; no independent human review is claimed.

@tlysanhuo
tlysanhuo marked this pull request as ready for review November 5, 2026 09:18

This branch has not been deployed

No deployments
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.

录制 contenteditable 多行内容时 fill 值丢失换行

1 participant