From 45d183d02d5f4b61ebca0315bec27e82347bed45 Mon Sep 17 00:00:00 2001 From: sudacode Date: Sat, 21 Mar 2026 20:49:44 -0700 Subject: [PATCH] fix(subtitle-sidebar): address CodeRabbit follow-ups --- ...deRabbit-follow-ups-on-subtitle-sidebar.md | 4 ++- src/renderer/handlers/mouse.test.ts | 30 +++++++++++++++++++ src/renderer/handlers/mouse.ts | 4 +++ src/renderer/renderer.ts | 3 +- 4 files changed, 39 insertions(+), 2 deletions(-) diff --git a/backlog/tasks/task-216 - Address-PR-28-CodeRabbit-follow-ups-on-subtitle-sidebar.md b/backlog/tasks/task-216 - Address-PR-28-CodeRabbit-follow-ups-on-subtitle-sidebar.md index 89c98b9..be70b6e 100644 --- a/backlog/tasks/task-216 - Address-PR-28-CodeRabbit-follow-ups-on-subtitle-sidebar.md +++ b/backlog/tasks/task-216 - Address-PR-28-CodeRabbit-follow-ups-on-subtitle-sidebar.md @@ -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. ## Final Summary diff --git a/src/renderer/handlers/mouse.test.ts b/src/renderer/handlers/mouse.test.ts index 5903a3f..1966a08 100644 --- a/src/renderer/handlers/mouse.test.ts +++ b/src/renderer/handlers/mouse.test.ts @@ -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)[]> = []; diff --git a/src/renderer/handlers/mouse.ts b/src/renderer/handlers/mouse.ts index 14b1940..43462bf 100644 --- a/src/renderer/handlers/mouse.ts +++ b/src/renderer/handlers/mouse.ts @@ -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; } diff --git a/src/renderer/renderer.ts b/src/renderer/renderer.ts index 6d08a03..f5c3508 100644 --- a/src/renderer/renderer.ts +++ b/src/renderer/renderer.ts @@ -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 { measurementReporter.schedule(); if (ctx.platform.shouldToggleMouseIgnore) { - window.electronAPI.setIgnoreMouseEvents(true, { forward: true }); + syncOverlayMouseIgnoreState(ctx); } measurementReporter.emitNow();