Repository navigation
feat: automatically protect rich-text code from prose grammar - #412
Conversation
Recognize Quill code-block editing DOM and semantic code/literal regions through a shared, uncached adapter resolver. Preserve existing Code-mode grammar semantics and field exclusions without changing settings, predictions, or keyboard handling. Add selection-boundary, formatting-change, iframe, and shadow-root regressions plus real grammar-coordinator integration tests. Document the focused scope and remaining transaction-level safety work.
Verify that each grammar trigger receives the actual prose/protected hint through the real engine. Prove that composed-selection failures cannot silently fall back to a different valid prose caret. Document scoped fixtures and registered coverage, and restore the unchanged normal CI workflow set.
Unit failure fixed; strict self-review follow-upReviewed the eight-file PR diff, the existing grammar coordinator/engine filtering, and the selection/helper integration. Fixes are pushed through Findings and resolutions
No tests were disabled, no CI gates were weakened, and no production behavior was changed merely to make the fixtures pass. The temporary diagnostic workflow has been removed; the final diff contains no workflow changes. Final validation on
|
Carry caret-local suppression through the existing prediction request and per-run override without changing saved settings or shared predictor state. Preserve authored capitals, raw candidate casing, snippets and prose behavior. Add a regression proven to fail on the prior code, request-isolation tests, Tab-acceptance coverage and a real Quill code-to-prose browser regression.
Fixed: prediction capitalization inside Slack code blocksCommit: 27c56f0. The reported The same live code-context resolver now supplies an optional Regression and review evidence
Final current-head CI: all jobs passedTests #1039 and CodeQL #1013 both completed successfully for
Each full browser run retains the repository's seven existing dev-only skips in production mode; no skips were added by this fix. Results are from completed jobs on the current commit, not from an earlier revision. The user's live Slack test confirmed the initial grammar protection and exposed this additional prediction-casing bug. The follow-up was verified in automated real-Quill browser tests; a personal live Slack retest is not claimed. The PR remains draft and unmerged. |
Replace nested prediction override construction with explicit independent branches, retain native DOM selection types, and remove duplicate readonly classification. Share test-only editor/caret/property fixtures with verified exception-safe cleanup, reuse Quill types, and eliminate nested E2E polling. Preserve all existing behavior and add combined casing/site-override coverage. The full unit runner passes before and after the source refactor; static and coverage checks pass on this tree. No workflow changes or weakened test gates.
bartekplus
left a comment
There was a problem hiding this comment.
Simplify pass completed — bcbd78f
No Ponytail review skill was installed in the available skill catalog, so I performed the requested manual simplify pass. I read the PR diff and discussion and rechecked the inline review threads; there are no outstanding inline threads or additional external review requests. The two earlier follow-up comments remain addressed.
Findings addressed
| Finding | Change |
|---|---|
| Nested ternary/spread expression obscured how site suggestion-count overrides combine with code-casing suppression. | Replace it with two independent branches and a typed local override. Preserve undefined when neither applies and require literal true, not truthiness. |
| Redundant DOM typing and repeated readonly classification. | Use the repository's native Selection type and remove the second aria-readonly check already handled by the resolver. Keep runtime feature checks and all selection fallback/eligibility behavior. |
| Editor, caret, and property-override fixtures were duplicated across feature tests. | Share the small test-only helpers in codeContextTestUtils.ts. Add regressions for exact accessor restoration, inherited properties, nested overrides, and exceptions. |
| The Quill browser test duplicated partial API types and nested two polling loops. | Reuse the existing dependency's Quill type via a type-only import and call the non-waiting suggestion reader inside the existing waitUntil. Preserve all popup, Tab, DOM, and model assertions. |
| Combined per-site/per-request override behavior lacked direct routing coverage. | Add eight cases covering absent/independent/combined overrides, code-to-prose transitions, and truthy non-booleans. Verify tab/frame and mid-word suffix propagation. |
| Feature documentation repeated implementation history and omitted the prediction-casing file from its focused test command. | Condense the document while retaining the behavior contract, privacy constraints, scope limits, and test instructions. Update mappings under existing coverage IDs. |
All actionable findings from this simplify pass are addressed. No existing test was removed or disabled, no baseline behavior ID changed, and no CI gate was weakened. The final commit contains no temporary workflow/script, dependency, permission, or saved-setting changes.
Validation
The full repository unit runner passed with the consolidated fixtures/new cases both before and after the production refactor. This verifies the simplified implementation against the same tests rather than rewriting expectations to fit it.
On the final PR head bcbd78f, Tests #1040 completed all jobs successfully; CodeQL #1014 also passed:
- Full unit runner, coverage registry, and Python build-tooling tests: passed.
- Oxlint, Prettier, and TypeScript: passed.
- Chrome and Firefox smoke: passed.
- Chrome full: 73 passed, 0 failed.
- Firefox full: 73 passed, 0 failed.
- Dedicated Google Docs cross-world fixtures: 81 passed, 0 failed.
The named Quill code predictions keep lowercase through Tab and restore prose casing case executed and passed in both final-head browser logs. The seven pre-existing development-only skips in each production browser suite are unchanged. Execution was in GitHub Actions using the repository's Bun version, not a claimed local Bun build.
This pass preserves the existing feature scope: it is not transaction-wide replacement-range validation or stale-region tracking. No independent live Slack retest is claimed. Leaving the PR draft and unmerged.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Summary
Apply caret-local grammar and prediction-casing protection in rich-text code without changing saved settings or restarting the runtime. Supports semantic
code/pre/kbd/samp, Quill code blocks/containers, and existing Monaco/CodeMirror/Ace markers. Code elsewhere in a composer does not disable the active prose paragraph.The same resolver supplies a per-request
suppressAutoCapitalizeflag to the prediction pipeline.what . wacan offer and insertwasin code while prose offersWas. AuthoredWa/WA, raw candidate casing, and snippet content/metadata retain their existing behavior; results are not blindly lowercased. Explicit autocomplete and enabled code-safe grammar rules remain available.Simplify/review pass —
bcbd78fNo Ponytail review skill was installed in the available skill catalog, so this was a manual simplify pass. The PR discussion and inline threads were checked; there were no outstanding additional reviewer requests. The review and resolutions are posted here.
undefinedwhen no override applies and require literaltruefor casing suppression.The baseline behavior IDs, existing tests, and CI gates are unchanged. No new dependencies, permissions, settings migrations, external requests, typed-text logging, or keyboard interception are introduced. Temporary validation tooling is absent from this commit and the PR diff.
Validation — final head
bcbd78fBoth workflows completed successfully: Tests #1040 and CodeQL #1014.
The named Quill code predictions keep lowercase through Tab and restore prose casing regression executed and passed in both final-head browser logs. Each production browser suite retains the repository's seven existing development-only skips; no skips were added.
Before publishing, the full unit runner also passed with the consolidated fixtures and added routing cases both before and after the production refactor.
bun run checkandbun run check:e2e:coveragepassed on the exact source tree. Execution used the repository's Bun version in GitHub Actions, not a claimed local Bun installation. Current-head results are not carried forward from an earlier commit.The earlier Slack-casing regression was proven to fail on unfixed code and pass after
27c56f0. All those regressions remain in this PR.Earlier validation correction
The original failing unit fixture used an ineffective instance spy on jsdom's inherited
Document.getSelection. It now exercises the actual selection API through scoped property overrides and restores descriptors. The earlier report that the new test passed and unrelated prediction/Google Docs tests were responsible was incorrect; those unrelated tests were not changed to hide the failure.Scope and status
This is caret-local protection, not final replacement-range validation across inline code, prose-context clipping, or stale-prediction region tracking. Custom model-only styles and Google Docs canvas code formatting need dedicated adapters. Markdown parsing is unchanged.
The maintainer tested the original grammar protection in live Slack and reported the prediction-casing issue subsequently fixed here. Independent live Slack testing of the follow-up is not claimed. The PR remains draft and unmerged.