Make caret track resolved text color at cursor position#315
Conversation
|
Warning Review limit reached
More reviews will be available in 16 minutes and 39 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (9)
📝 WalkthroughWalkthroughThis PR implements cursor color resolution to make text-edit carets visible in dark-themed decks. It adds a color resolution helper, extends render interfaces to accept per-cursor colors, wires color computation into editors, and verifies the behavior with unit and integration tests. ChangesCursor Color Resolution and Rendering Pipeline
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/docs/test/view/themed-color.test.ts`:
- Around line 72-90: The test is a false positive because the inline text uses
the same color as the caret override; change the inline text style in the Block
from '`#ffffff`' to a different color (e.g., '`#000000`' or '`#00ff00`') so text and
caret colors differ, and then assert caret-specific drawing: use the fake canvas
context produced by makeFakeCtx() to verify the caret draw call (paintLayout ->
fillRect) used the override color '`#ffffff`' (for example by checking the last
fill style pushed to fillStyles or the specific fillRect call associated with
the cursor draw), ensuring computeLayout/paintLayout and the cursor object
passed to paintLayout are the symbols referenced.
- Around line 92-109: The test's assertion is too broad: instead of checking for
any hex color in fillStyles, pass a deterministic theme with a unique
cursorColor (e.g. '`#ABCDEF`') into paintLayout (or the fake context from
makeFakeCtx) and then assert that fillStyles contains that exact value; update
the test that uses makeFakeCtx(), computeLayout(...), and paintLayout(...) to
inject the known theme.cursorColor and replace the regex assertion with
expect(fillStyles.includes('`#ABCDEF`')).toBe(true) so the caret fallback is
verified precisely.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 8e191d10-2f4b-4a31-a6fb-1ab640a1683e
📒 Files selected for processing (9)
docs/tasks/active/20260530-cursor-follows-text-color-lessons.mddocs/tasks/active/20260530-cursor-follows-text-color-todo.mdpackages/docs/src/model/color.tspackages/docs/src/view/doc-canvas.tspackages/docs/src/view/editor.tspackages/docs/src/view/paint-layout.tspackages/docs/src/view/text-box-editor.tspackages/docs/test/model/color.test.tspackages/docs/test/view/themed-color.test.ts
Verification: verify:selfResult: ✅ PASS in 257.1s
Verification: verify:integrationResult: ✅ PASS |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
36cff78 to
6fdddc7
Compare
On a Slides deck with the Simple Dark theme (and any future theme that paints light text on a dark background), the text-edit caret was rendered with the docs `Theme.cursorColor`. That theme knows about light/dark mode of the docs package itself but not about deck-theme backgrounds, so the caret painted in dark ink and was effectively invisible against the slide background. Match Google Docs/Slides behaviour: the caret picks up the resolved text color at the cursor position. Adds `resolveColorAtPosition` next to the existing `defaultColorResolver`, widens the three caret paint sites (`paintLayout`, `DocCanvas` body/header/footer) with an optional `cursor.color` field, and threads the resolved color from the slides text-box editor and the docs full editor. Falls back to `Theme.cursorColor` when no color is supplied so existing callers keep their current rendering. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
CodeRabbit flagged the two caret-paint tests as false positives. The override test used the same color for inline text and caret override (`#ffffff`), so the assertion could not distinguish the caret pass from the text pass. The fallback test only checked that some hex string reached `fillStyle`, which any text run satisfies. Pick distinct text / caret colors and assert against the last `fillStyle` entry — paintLayout draws the caret last, so the final fillStyle write must be the cursor color. Also assert the chosen text color differs from `Theme.cursorColor` so the fallback test cannot match the text-paint fillStyle by accident. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
955f2f8 to
0136100
Compare
On a Slides deck with the Simple Dark theme (and any future deck theme that paints light text on a dark background), the text-edit caret was rendered with the docs `Theme.cursorColor`. That theme knows about light/dark mode of the docs package itself but not about per-deck slide backgrounds, so the caret painted in dark ink and was effectively invisible against the slide background. Match Google Docs / Slides behaviour: the caret picks up the resolved text color at the cursor position — light text yields a light caret, red text yields a red caret. Adds `resolveColorAtPosition` next to the existing `defaultColorResolver`, widens the three caret paint sites (`paintLayout`, `DocCanvas` body / header / footer) with an optional `cursor.color` field, and threads the resolved color from the slides text-box editor and the docs full editor. Falls back to `Theme.cursorColor` when no color is supplied so existing callers keep their current rendering. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
On a Slides deck with the Simple Dark theme (and any future deck theme that paints light text on a dark background), the text-edit caret was rendered with the docs `Theme.cursorColor`. That theme knows about light/dark mode of the docs package itself but not about per-deck slide backgrounds, so the caret painted in dark ink and was effectively invisible against the slide background. Match Google Docs / Slides behaviour: the caret picks up the resolved text color at the cursor position — light text yields a light caret, red text yields a red caret. Adds `resolveColorAtPosition` next to the existing `defaultColorResolver`, widens the three caret paint sites (`paintLayout`, `DocCanvas` body / header / footer) with an optional `cursor.color` field, and threads the resolved color from the slides text-box editor and the docs full editor. Falls back to `Theme.cursorColor` when no color is supplied so existing callers keep their current rendering. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
On a Slides deck with the Simple Dark theme (and any future deck theme that paints light text on a dark background), the text-edit caret was rendered with the docs `Theme.cursorColor`. That theme knows about light/dark mode of the docs package itself but not about per-deck slide backgrounds, so the caret painted in dark ink and was effectively invisible against the slide background. Match Google Docs / Slides behaviour: the caret picks up the resolved text color at the cursor position — light text yields a light caret, red text yields a red caret. Adds `resolveColorAtPosition` next to the existing `defaultColorResolver`, widens the three caret paint sites (`paintLayout`, `DocCanvas` body / header / footer) with an optional `cursor.color` field, and threads the resolved color from the slides text-box editor and the docs full editor. Falls back to `Theme.cursorColor` when no color is supplied so existing callers keep their current rendering. Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
PRs #257/#301/#303/#304/#305/#306/#307/#309/#315/#316/#317/#321/#322 shipped between v0.4.2 and the v0.4.3 cut, leaving their paired todo files in active with the process checkboxes still open. Flip the remaining boxes for the work that landed, then move the paired todo/lessons into docs/tasks/archive/2026/05/ via pnpm tasks:archive. Active count drops from 17 to 6; archive count grows by 21 files. Patch release covering 29 commits since v0.4.2. Headline theme is Slides editing & UX polish toward Google Slides / PowerPoint parity: smart guides (equal-spacing / distance / size), Shift drag modifiers, text inside shapes, a Format options right panel, tier-1 universal toolbar controls, text autofit (shrink + grow), group-selection visuals, and several smaller text-box / selection fixes. PPTX import gained paragraph-level bullet styles, body anchor (vertical alignment), and stretched blipFill cover-crop. Docs added a pending-inline-style at collapsed caret, a caret that tracks the resolved text color, bullet indent on Tab / Shift+Tab, font / size / line-spacing / clear formatting toolbar controls, an inline-style-attribute clear that actually lands in the CRDT, and a polished toolbar trigger / color swatch pass shared across docs / sheets / slides. Sheets gained .xlsx import. Infrastructure: Docker images now build on native arm64 runners, fixing the release hang seen on v0.4.2. No Prisma migration, no new backend env vars — the devops bump is a routine image-tag change. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Summary
Theme.cursorColorknows about light/dark mode of the docs package but not about per-deck slide backgrounds, so a dark caret painted on top of a dark slide.resolveColorAtPositionhelper next todefaultColorResolver, widens the three caret paint sites (paintLayout,DocCanvasbody/header/footer) with an optionalcursor.color, and threads the resolved color from the slides text-box editor and the docs full editor. Falls back toTheme.cursorColorwhen no color is supplied so existing callers are unaffected.Test plan
pnpm verify:fastpackages/docs/test/model/color.test.tscover the seam rule, role-color fallback, missing color, theme-aware resolverpackages/docs/test/view/themed-color.test.tsassert thecursor.coloroverride +Theme.cursorColorfallback pathspnpm dev, enter a text placeholder, confirm the caret is visible against the dark slide backgroundDesign notes in
docs/tasks/active/20260530-cursor-follows-text-color-todo.md.Out of scope: honouring
styleBuffer(toolbar-picked color before next keystroke); selection-spanning caret; peer carets already carry their own per-peer color.🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes
Documentation
Bug Fixes
Tests