Repository navigation
Multi-playing: recoverable loadProfile when the browser blocks it, honest setActiveProfile across tabs - #464
Merged
Merged
Conversation
Each profile is its own browser tab, and three scripted multi-playing calls behaved worse than they had to: 1. loadProfile(): a browser opens one new tab per user gesture, so the second call in an alias, and any call from a trigger, was refused with nothing left for the user to act on. The refusal now also leaves an "Open profile <name>" link on its own line in the main console; the click is the gesture the call lacked, so one click opens the profile. A click that finds the profile already open, or is itself blocked, says so instead of opening a duplicate tab. 2. setActiveProfile(): for a profile in another tab it answered true without switching. A page cannot bring another tab forward, so it now answers false with that reason and asks the target tab (over the profiles-presence channel) to request focus and flash its title until the user switches to it, when sysProfileFocusChangeEvent fires. 3. raiseGlobalEvent(): other tabs handle the event a task later, where desktop runs every host's handlers inline. That is inherent in separate tabs, so it is recorded rather than changed. All three are recorded in e2e/knownDivergences.ts, docs/MUDLET_API.md and the luaCompletions descriptions; tests/scripting/multiProfile453.test.ts covers each point. Fixes #453 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MUGrWWjYht6BA7w5asDWRi
Investigated whether the cross-profile delay has an avoidable part: it doesn't. raise() posts synchronously and the receiving tab dispatches into Lua straight from the BroadcastChannel message event, so the browser's cross-tab hop is the only delay. Say so where a later change would add one, and test that the sender never receives its own global event, as desktop's postInterHostEvent skips the sending host. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MUGrWWjYht6BA7w5asDWRi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses #453. This PR doesn't close it; the three remaining gaps are under "Not fixed here" below.
Changes
loadProfile(): the browser blocks the new tab on a second call in one alias, and on any call from a trigger, timer or event.nil, msgand leaves an "Open profile " link on its own line in the main console.setActiveProfile(): for a profile open in another tab it now returnsfalse, msginstead of a falsetrue, since a page can't bring another tab to the front.attentionmessage over the profiles-presence BroadcastChannel and flashes its title until the user switches to it.sysProfileFocusChangeEventfires when they do.true.raiseGlobalEvent(): behaviour is unchanged.postInterHostEvent.e2e/knownDivergences.ts,docs/MUDLET_API.mdandluaCompletions.ts.tests/scripting/multiProfile453.test.ts.Not fixed here
These remain, and all of them come from running each profile in its own tab:
setActiveProfile()across tabs can't actually switch to the other tab.raiseGlobalEvent()replies arrive one task later.Closing these needs several profiles hosted in one tab, as desktop does. That's an estimated 35–50 file change and is out of scope for this PR.
Testing
yarn typecheckpasses.yarn test: 3 failures, none caused by this branch:serverEncoding.test.ts(GBK euro sign) also fails on master.added-apis(clipboard) andmapperParity295fail only in the full parallel run and pass when run alone.🤖 Generated with Claude Code
https://claude.ai/code/session_01Um3ZSHRbGj1Rbf55rAQzdM
Generated by Claude Code