Fixed Context Menus & other things

This commit is contained in:
2026-02-28 19:51:34 +11:00
parent 76b1e264f8
commit 3e51ac45f8
+56 -7
View File
@@ -1319,10 +1319,12 @@ const handleStickyLyricsTrackChange = (): void => {
); );
}; };
// MARKER: Injected API Lyrics (for non tidal lyric tracks) // MARKER: Injected API Lyrics (for non tidal lyric tracks)
let injectedTablistClickCleanup: (() => void) | null = null; let injectedTablistClickCleanup: (() => void) | null = null;
let isTrackChangeRunning = false;
let trackChangeRunSeq = 0;
const hiddenPanelsByInjected = new Set<HTMLElement>();
const getTabsRoot = (): HTMLElement | null => { const getTabsRoot = (): HTMLElement | null => {
const roots = Array.from( const roots = Array.from(
@@ -1338,12 +1340,16 @@ const hideInjectedLyricsTab = (): void => {
if (!injectedTabEl || !injectedPanelEl) return; if (!injectedTabEl || !injectedPanelEl) return;
const root = getTabsRoot(); const root = getTabsRoot();
if (root) { if (root) {
for (const panel of hiddenPanelsByInjected) {
panel.style.removeProperty("display");
}
hiddenPanelsByInjected.clear();
const nativePanels = Array.from( const nativePanels = Array.from(
root.querySelectorAll('div[role="tabpanel"]'), root.querySelectorAll('div[role="tabpanel"]'),
) as HTMLElement[]; ) as HTMLElement[];
for (const panel of nativePanels) { for (const panel of nativePanels) {
if (panel === injectedPanelEl) continue; if (panel === injectedPanelEl) continue;
panel.removeAttribute("aria-hidden");
panel.style.removeProperty("display"); panel.style.removeProperty("display");
} }
} }
@@ -1402,14 +1408,21 @@ const showInjectedLyricsTab = (): void => {
const nativePanels = Array.from( const nativePanels = Array.from(
root.querySelectorAll('div[role="tabpanel"]'), root.querySelectorAll('div[role="tabpanel"]'),
) as HTMLElement[]; ) as HTMLElement[];
for (const panel of hiddenPanelsByInjected) {
panel.style.removeProperty("display");
}
hiddenPanelsByInjected.clear();
for (const tab of tabs) { for (const tab of tabs) {
if (tab === injectedTabEl) continue; if (tab === injectedTabEl) continue;
if (activeTabClass) tab.classList.remove(activeTabClass); if (activeTabClass) tab.classList.remove(activeTabClass);
} }
for (const panel of nativePanels) { for (const panel of nativePanels) {
if (panel === injectedPanelEl) continue; if (panel === injectedPanelEl) continue;
panel.setAttribute("aria-hidden", "true"); if (panel.classList.contains("react-tabs__tab-panel--selected")) {
panel.style.display = "none"; panel.style.display = "none";
hiddenPanelsByInjected.add(panel);
}
} }
injectedTabEl.setAttribute("aria-selected", "true"); injectedTabEl.setAttribute("aria-selected", "true");
@@ -1626,6 +1639,12 @@ function setupStickyLyricsObserver(): void {
// Apply word lyrics when lyrics container appears or reappears // Apply word lyrics when lyrics container appears or reappears
observe<HTMLElement>(unloads, '[data-test="lyrics-lines"]', () => { observe<HTMLElement>(unloads, '[data-test="lyrics-lines"]', () => {
if (isTrackChangeRunning) return;
const lyricsLines = document.querySelector(
'[data-test="lyrics-lines"]',
) as HTMLElement;
if (lyricsLines?.querySelector(".rl-wbw-container")) return;
if (lyricsMode === "line-tidal") { if (lyricsMode === "line-tidal") {
void reapplyTidalLines(); void reapplyTidalLines();
} else if (lyricsData) { } else if (lyricsData) {
@@ -2805,6 +2824,23 @@ const stopTidalFollowLoop = (): void => {
} }
}; };
// smthn GPT 5.3 Codex did
const setTidalFallbackLineWordState = (
lineEl: HTMLElement,
active: boolean,
): void => {
const words = lineEl.querySelectorAll(".rl-wbw-word");
for (const word of words) {
if (active) {
word.classList.add("rl-wbw-active");
word.classList.remove("rl-wbw-finished");
} else {
word.classList.remove("rl-wbw-active");
word.classList.add("rl-wbw-finished");
}
}
};
const updateTidalFollowActiveLine = (): void => { const updateTidalFollowActiveLine = (): void => {
if (!isActive || lyricsMode !== "line-tidal" || lines.length === 0) return; if (!isActive || lyricsMode !== "line-tidal" || lines.length === 0) return;
@@ -2824,6 +2860,7 @@ const updateTidalFollowActiveLine = (): void => {
if (!newActiveSet.has(idx) && idx < lines.length) { if (!newActiveSet.has(idx) && idx < lines.length) {
lines[idx].el.classList.remove("rl-wbw-line-active"); lines[idx].el.classList.remove("rl-wbw-line-active");
lines[idx].el.removeAttribute("data-current"); lines[idx].el.removeAttribute("data-current");
setTidalFallbackLineWordState(lines[idx].el, false);
} }
} }
@@ -2832,6 +2869,7 @@ const updateTidalFollowActiveLine = (): void => {
lines[activeIndex].el.classList.remove("rl-pos-1", "rl-pos-2", "rl-pos-3"); lines[activeIndex].el.classList.remove("rl-pos-1", "rl-pos-2", "rl-pos-3");
lines[activeIndex].el.setAttribute("data-current", "true"); lines[activeIndex].el.setAttribute("data-current", "true");
} }
setTidalFallbackLineWordState(lines[activeIndex].el, true);
const prevPrimary = primaryLineIdx; const prevPrimary = primaryLineIdx;
primaryLineIdx = activeIndex; primaryLineIdx = activeIndex;
@@ -3192,7 +3230,7 @@ const startTickLoop = (): void => {
span.removeAttribute("data-current"); span.removeAttribute("data-current");
} }
if (nowMs - lastLogTime >= 1000) { if (!isLineStyle && nowMs - lastLogTime >= 1000) {
lastLogTime = nowMs; lastLogTime = nowMs;
sylLog(`[RL-Syllable] Playback | ${nowMs.toFixed(0)} ms`); sylLog(`[RL-Syllable] Playback | ${nowMs.toFixed(0)} ms`);
} }
@@ -3430,10 +3468,12 @@ const startTickLoop = (): void => {
word.el.style.animation = wipe + sylAnim; word.el.style.animation = wipe + sylAnim;
} }
activeWordEls.set(lineIdx, word.el); activeWordEls.set(lineIdx, word.el);
if (!isLineStyle) {
sylLog( sylLog(
`[RL-Syllable] Word/Syllable "${word.el.textContent}" | ${word.start} ms - ${word.end} ms [${nowMs.toFixed(0)} ms]`, `[RL-Syllable] Word/Syllable "${word.el.textContent}" | ${word.start} ms - ${word.end} ms [${nowMs.toFixed(0)} ms]`,
); );
} }
}
} else { } else {
word.el.classList.remove(CLS_ACTIVE); word.el.classList.remove(CLS_ACTIVE);
if (isSyl) word.el.style.animation = ""; if (isSyl) word.el.style.animation = "";
@@ -3510,8 +3550,10 @@ const startTickLoop = (): void => {
const onTrackChange = async (): Promise<void> => { const onTrackChange = async (): Promise<void> => {
teardown(); teardown();
const token = ++trackChangeToken; const runId = ++trackChangeRunSeq;
isTrackChangeRunning = true;
const token = ++trackChangeToken;s
try {
const trackInfo = await getTrackInfo(); const trackInfo = await getTrackInfo();
if (token !== trackChangeToken) return; if (token !== trackChangeToken) return;
if (!trackInfo) { if (!trackInfo) {
@@ -3580,7 +3622,9 @@ const onTrackChange = async (): Promise<void> => {
); );
} }
lyricsData = lyricsData =
response.type === "Word" ? response.data : normalizeLineData(response.data); response.type === "Word"
? response.data
: normalizeLineData(response.data);
lyricsResponse = response; lyricsResponse = response;
isActive = true; isActive = true;
if (!lyricsData || lyricsData.length === 0) { if (!lyricsData || lyricsData.length === 0) {
@@ -3601,6 +3645,11 @@ const onTrackChange = async (): Promise<void> => {
// Start the highlight loop // Start the highlight loop
startTickLoop(); startTickLoop();
} finally {
if (runId === trackChangeRunSeq) {
isTrackChangeRunning = false;
}
}
}; };
// Reapply word lyrics (for tab switch back) // Reapply word lyrics (for tab switch back)