Declare the desktop app as the preferred bridge channel - #271
Open
philipp-winterle wants to merge 1 commit into
Open
philipp-winterle wants to merge 1 commit into
philipp-winterle wants to merge 1 commit into
Conversation
The server's UI operation bridge picks whichever UI connected first as the channel that answers every MCP and CTL operation. With the desktop app and a browser tab both open, which one that is comes down to startup order, and the user has no way to steer it. The bridge now accepts an optional priority in the operations message. Sending 1 from the desktop shell and 0 from a browser tab makes the app the user is actually driving win, whatever the connection order was. isDesktopShell() reads the injected desktop API directly, because it has to answer synchronously here - desktopVersion never resolves in a browser, so it can't tell the two apart.
Open
5 tasks
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.
The problem
The server's UI operation bridge picks whichever UI connected first as the
channel that answers every MCP and CTL operation, and whose account decides
isPaidUser(). With the desktop app and a browser tab both pointed at the sameserver, which one wins comes down to startup order, and the user has no way to
steer it.
The change
The bridge accepts an optional
priorityin the operations message(httptoolkit/httptoolkit-server#246). The desktop shell sends 1, a browser tab
sends 0, so the app the user is actually driving takes the role whatever the
connection order was.
isDesktopShell()reads the injected desktop API directly because it has toanswer synchronously here.
desktopVersioncan't be used for this - by its owncomment it never resolves in a browser, so it cannot tell the two apart.
Test plan
tsc --noEmitreports nothing in either changed file. (The repo haspre-existing type errors elsewhere under a bare
tsc, so this is scoped tothe diff.)
server-operation-bridge.tshas no test file today andno seam to reach the socket through, and the behaviour this field drives is
covered by the server-side PR's tests. Glad to add one if you can point me
at the shape you'd want.
shell set up, only the local web UI, where
isDesktopShell()correctlyreports false.