fix(subtitle-sidebar): address CodeRabbit follow-ups

This commit is contained in:
2026-03-21 20:49:44 -07:00
parent a42fe599cb
commit 45d183d02d
4 changed files with 39 additions and 2 deletions

View File

@@ -5,7 +5,7 @@ status: In Progress
assignee:
- '@codex'
created_date: '2026-03-21 00:00'
updated_date: '2026-03-22 02:34'
updated_date: '2026-03-22 03:26'
labels:
- pr-review
- subtitle-sidebar
@@ -60,6 +60,8 @@ Verification:
2026-03-21: Addressed the latest CodeRabbit follow-up pass in commit d70c6448 after rebasing onto the updated remote branch tip.
2026-03-21: Reopened for the latest CodeRabbit round on commit d70c6448; current actionable item is the invalid ctx.state.isOverSubtitleSidebar assignment in subtitle-sidebar.ts.
2026-03-22: Addressed the live hover-state and startup mouse-ignore follow-ups from the latest CodeRabbit pass. `handleMouseLeave()` now clears `isOverSubtitle` and drops `secondary-sub-hover-active` when leaving the secondary subtitle container toward the primary container, and renderer startup now calls `syncOverlayMouseIgnoreState(ctx)` instead of forcing `setIgnoreMouseEvents(true, { forward: true })`. The sidebar IPC hover catch and CSS spacing comments were already satisfied in the current tree.
<!-- SECTION:NOTES:END -->
## Final Summary

View File

@@ -141,6 +141,36 @@ test('moving between primary and secondary subtitle containers keeps the hover p
assert.deepEqual(mpvCommands, [['set_property', 'pause', 'yes']]);
});
test('secondary leave toward primary subtitle container clears the secondary hover class', async () => {
const ctx = createMouseTestContext();
const mpvCommands: Array<(string | number)[]> = [];
const handlers = createMouseHandlers(ctx as never, {
modalStateReader: {
isAnySettingsModalOpen: () => false,
isAnyModalOpen: () => false,
},
applyYPercent: () => {},
getCurrentYPercent: () => 10,
persistSubtitlePositionPatch: () => {},
getSubtitleHoverAutoPauseEnabled: () => true,
getYomitanPopupAutoPauseEnabled: () => false,
getPlaybackPaused: async () => false,
sendMpvCommand: (command) => {
mpvCommands.push(command);
},
});
await handlers.handleSecondaryMouseEnter();
await handlers.handleSecondaryMouseLeave({
relatedTarget: ctx.dom.subtitleContainer,
} as unknown as MouseEvent);
assert.equal(ctx.state.isOverSubtitle, false);
assert.equal(ctx.dom.secondarySubContainer.classList.contains('secondary-sub-hover-active'), false);
assert.deepEqual(mpvCommands, [['set_property', 'pause', 'yes']]);
});
test('auto-pause on subtitle hover skips when playback is already paused', async () => {
const ctx = createMouseTestContext();
const mpvCommands: Array<(string | number)[]> = [];

View File

@@ -163,6 +163,10 @@ export function createMouseHandlers(
? ctx.dom.subtitleContainer
: ctx.dom.secondarySubContainer;
if (relatedTarget && isWithinOtherSubtitleContainer(relatedTarget, otherContainer)) {
ctx.state.isOverSubtitle = false;
if (hideSecondaryHover) {
ctx.dom.secondarySubContainer.classList.remove('secondary-sub-hover-active');
}
return;
}

View File

@@ -39,6 +39,7 @@ import { createRuntimeOptionsModal } from './modals/runtime-options.js';
import { createSubsyncModal } from './modals/subsync.js';
import { createPositioningController } from './positioning.js';
import { createOverlayContentMeasurementReporter } from './overlay-content-measurement.js';
import { syncOverlayMouseIgnoreState } from './overlay-mouse-ignore.js';
import { createRendererState } from './state.js';
import { createSubtitleRenderer } from './subtitle-render.js';
import { isYomitanPopupVisible, registerYomitanLookupListener } from './yomitan-popup.js';
@@ -584,7 +585,7 @@ async function init(): Promise<void> {
measurementReporter.schedule();
if (ctx.platform.shouldToggleMouseIgnore) {
window.electronAPI.setIgnoreMouseEvents(true, { forward: true });
syncOverlayMouseIgnoreState(ctx);
}
measurementReporter.emitNow();