Skip to content

screen.js still monkey-patches window.showScreen — vestigial after core's feedBack#923/#924 fix; CLAUDE.md documents it as current practice #32

Description

@carochacs

screen.js:4681-4685 still does:

const _show = window.showScreen;
window.showScreen = function (id) {
    if (!FOLLOWER && id !== 'player' && active) stopSplitScreen();
    _show(id);
};

Core's static/js/session.js (current showScreen()) documents that this exact pattern — splitscreen (and stems, and the old shell.js) monkey-patching window.showScreen — was the root cause of feedBack#923/#924: three independent patches capturing whatever was installed at load-order-dependent times, causing navigation to intermittently land on a dead legacy screen. The fix moved all such logic into showScreen() itself (one guard every caller routes through) specifically so plugins wouldn't need to patch the global. shell.js:325 confirms this was deliberately reverted for the same reason: "This USED to monkey-patch window.showScreen. It doesn't any more, and that is the point."

splitscreen never got the same cleanup. The patch here is now vestigial — teardown-on-navigate could instead subscribe to the screen:changing event core now emits for exactly this purpose (see session.js's documented event contract), matching the pattern sectionmap's CLAUDE.md already recommends (event-based, not patch-based) for the same "leaving the player screen" use case.

This plugin's own CLAUDE.md (Module structure / "Hooks into core" section, and the playSong wrapper section) documents the window.showScreen wrap as intended current architecture, so the docs and code are self-consistent but both are stale relative to core's current guidance.

Suggest: replace the window.showScreen patch with a screen:changing listener (teardown on leaving 'player'), and update CLAUDE.md's module structure / hooks section accordingly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions