Skip to content

BL-15300 Switch TBT highlighting to pseudoelement#7754

Open
nabalone wants to merge 1 commit intomasterfrom
BL-15300_switch_tbt_highlighting_to_pseudoelement
Open

BL-15300 Switch TBT highlighting to pseudoelement#7754
nabalone wants to merge 1 commit intomasterfrom
BL-15300_switch_tbt_highlighting_to_pseudoelement

Conversation

@nabalone
Copy link
Copy Markdown
Contributor

@nabalone nabalone commented Mar 18, 2026


Open with Devin

This change is Reviewable

Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 2 potential issues.

View 2 additional findings in Devin Review.

Open in Devin Review

Comment on lines +17 to +44
const getDocumentWindow = (contextNode: Node): Window | undefined => {
return contextNode.ownerDocument?.defaultView ?? undefined;
};

const getHighlightRegistry = (
contextNode: Node,
): HighlightRegistry | undefined => {
const docWindow = getDocumentWindow(contextNode) as
| (Window & typeof globalThis)
| undefined;
const cssWithHighlights = docWindow?.CSS as
| (typeof globalThis.CSS & {
highlights?: HighlightRegistry;
})
| undefined;
return cssWithHighlights?.highlights;
};

const getHighlightConstructor = (
contextNode: Node,
): HighlightConstructor | undefined => {
const docWindow = getDocumentWindow(contextNode) as
| (Window & {
Highlight?: HighlightConstructor;
})
| undefined;
return docWindow?.Highlight;
};
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration bot Mar 18, 2026

Choose a reason for hiding this comment

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

🟡 Module-level functions use arrow-function syntax instead of function declarations

The src/BloomBrowserUI/AGENTS.md rule states: "For functions, prefer typescript 'function' syntax over const foo = () => functions." Three new module-level functions in audioTextHighlightManager.ts (getDocumentWindow, getHighlightRegistry, getHighlightConstructor) are defined as const arrow-function assignments instead of using the function keyword. The existing codebase consistently follows the function declaration pattern for standalone utility functions.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +4411 to +4413
this.audioTextHighlightManager.clearManagedHighlights(
currentTextBox ?? undefined,
);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🚩 clearAudioSplit silently skips highlight cleanup when currentTextBox is null

At audioRecording.ts:4411-4413, if getCurrentTextBox() returns null, clearManagedHighlights receives undefined and returns immediately at audioTextHighlightManager.ts:48-49 — leaving any existing ::highlight() entries in the registry. With the old CSS approach, removing the bloom-postAudioSplit class from the element was sufficient since the CSS selectors would stop matching. With the new approach, the registry entries persist independently. In practice this is mitigated because removeAudioCurrentFromPageDocBody also clears highlights and is called on most highlight transitions. But if a code path calls clearAudioSplit expecting to remove the visual split colors, and no highlight change follows, the colors could linger.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@nabalone nabalone force-pushed the BL-15300_switch_tbt_highlighting_to_pseudoelement branch from 3dd43e2 to d20ed54 Compare March 26, 2026 19:47
Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 3 new potential issues.

View 5 additional findings in Devin Review.

Open in Devin Review

Comment on lines +347 to +349
expect(sentenceRule?.cssText).toContain(
"--bloom-audio-highlight-color: rgb(1, 2, 3)",
);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 Test uses wrong CSS variable name --bloom-audio-highlight-color instead of --bloom-audio-highlight-text-color

The test at line 348 asserts that sentenceRule?.cssText contains "--bloom-audio-highlight-color: rgb(1, 2, 3)", but the production code in StyleEditor.ts:688 sets the property as "--bloom-audio-highlight-text-color". The substring --bloom-audio-highlight-color does not appear in --bloom-audio-highlight-text-color (which has an extra text- segment), so the toContain assertion will fail.

Suggested change
expect(sentenceRule?.cssText).toContain(
"--bloom-audio-highlight-color: rgb(1, 2, 3)",
);
expect(sentenceRule?.cssText).toContain(
"--bloom-audio-highlight-text-color: rgb(1, 2, 3)",
);
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.


it("copies the current highlight colors from CSS variables", async () => {
SetupIFrameFromHtml(
'<div id="page1"><div class="bloom-editable" data-audiorecordingmode="Sentence"><p><span id="span1" class="audio-sentence ui-audioCurrent" style="--bloom-audio-highlight-background: rgb(1, 2, 3); --bloom-audio-highlight-color: rgb(4, 5, 6);">One.</span></p></div></div>',
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 Test inline style uses wrong CSS variable name --bloom-audio-highlight-color instead of --bloom-audio-highlight-text-color

The test HTML at line 2199 sets the inline style --bloom-audio-highlight-color: rgb(4, 5, 6) on the span, but audioTextHighlightManager.ts:10 reads via kCurrentHighlightColorSourceCssVar which is "--bloom-audio-highlight-text-color". Since the wrong variable name is set on the element, getComputedStyle in audioTextHighlightManager.ts:299-300 will not find it, and the assertion at line 2234 that expects --bloom-audio-current-highlight-color to be "rgb(4, 5, 6)" will fail.

Suggested change
'<div id="page1"><div class="bloom-editable" data-audiorecordingmode="Sentence"><p><span id="span1" class="audio-sentence ui-audioCurrent" style="--bloom-audio-highlight-background: rgb(1, 2, 3); --bloom-audio-highlight-color: rgb(4, 5, 6);">One.</span></p></div></div>',
'<div id="page1"><div class="bloom-editable" data-audiorecordingmode="Sentence"><p><span id="span1" class="audio-sentence ui-audioCurrent" style="--bloom-audio-highlight-background: rgb(1, 2, 3); --bloom-audio-highlight-text-color: rgb(4, 5, 6);">One.</span></p></div></div>',
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

updatedCssRules,
Does.Contain(
".Bubble-style span.ui-audioCurrent { background-color: transparent; color: rgb(0, 255, 255); }"
".Bubble-style span.ui-audioCurrent { --bloom-audio-highlight-background: transparent; --bloom-audio-highlight-color: rgb(0, 255, 255); background-color: transparent; color: rgb(0, 255, 255); }"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 C# test assertions use wrong CSS variable name --bloom-audio-highlight-color instead of --bloom-audio-highlight-text-color

Multiple test assertions in AddMissingAudioHighlightRules_WorksForMissing use the CSS variable name --bloom-audio-highlight-color, but HtmlDom.cs:3853 defines highlightColorVariable = "--bloom-audio-highlight-text-color". The AddAudioHighlightCssVariables method inserts --bloom-audio-highlight-text-color into the CSS text, so Does.Contain("--bloom-audio-highlight-color") will not find a match (the substring highlight-color is not present in highlight-text-color). This affects assertions at lines 1270, 1282, and 1294.

Prompt for agents
In src/BloomTests/Book/HtmlDomTests.cs, replace all occurrences of the CSS variable name `--bloom-audio-highlight-color` with `--bloom-audio-highlight-text-color` in the test assertion strings. This affects:

Line 1270: Change `--bloom-audio-highlight-color:` to `--bloom-audio-highlight-text-color:` in the Bubble-style sentence rule assertion
Line 1282: Change `--bloom-audio-highlight-color:` to `--bloom-audio-highlight-text-color:` in the Bubble-style enableHighlight rule assertion
Line 1294: Change `--bloom-audio-highlight-color:` to `--bloom-audio-highlight-text-color:` in the standalone variable assertion
Line 1339: Change `--bloom-audio-highlight-color:` to `--bloom-audio-highlight-text-color:` in the WorksForNoneMissing Bubble-style sentence rule assertion
Line 1345: Change `--bloom-audio-highlight-color:` to `--bloom-audio-highlight-text-color:` in the WorksForNoneMissing Bubble-style enableHighlight rule assertion
Line 1351: Change `--bloom-audio-highlight-color:` to `--bloom-audio-highlight-text-color:` in the WorksForNoneMissing Bubble-style paragraph rule assertion

The production code in src/BloomExe/Book/HtmlDom.cs line 3853 uses `--bloom-audio-highlight-text-color` as the variable name.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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.

1 participant