-
Notifications
You must be signed in to change notification settings - Fork 166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rework reconnect logic, add "Port could not be opened" modal #1513
base: pr/vscode-connect-info
Are you sure you want to change the base?
Conversation
f79588c
to
f68639f
Compare
202b490
to
2648fde
Compare
onClose={() => send({ type: "closeModal" })} | ||
onRetry={() => send({ type: "retry" })} | ||
/> | ||
<Modals /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All modals live in that file now.
<BannerAlert /> | ||
<Tabs | ||
value={selected} | ||
onChange={(screen) => currentScreen(screen)} | ||
className="flex flex-col h-screen bg-primary dark:bg-primary-dark" | ||
> | ||
<div className="flex items-center border-b border-b-primary dark:border-b-primary-dark gap-4 px-4"> | ||
<a | ||
<ExternalLink |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<a
tags in VSCode cannot open new windows, so I need a component for that. The base implementation really just renders an a
tag, and we have a .vscode.tsx
version of that.
@@ -21,7 +22,7 @@ export const SECTIONS = { | |||
<!-- Please provide the version of \`@apollo/client\` you are using. --> | |||
`, | |||
devtoolsVersion: `### Apollo Client Devtools version | |||
${VERSION} | |||
${VERSION} (${__IS_FIREFOX__ ? "Firefox" : __IS_VSCODE__ ? "VSCode" : "Chrome"}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some additional info can be very helpful here to distinguish the different builds in bug reports.
@@ -18,15 +18,17 @@ interface ModalProps { | |||
className?: string; | |||
children: ReactNode; | |||
open: boolean; | |||
onClose: (value: boolean) => void; | |||
onClose?: (value: boolean) => void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making onClose
optional since most of our modals cannot be closed.
open: boolean; | ||
onClose: () => void; | ||
onRetry: () => void; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This modal cannot be closed anymore - before, closing it would leave the user with a somewhat defunct UI, so it never made much sense to me. Going this step massively simplifies logic.
invoke: { | ||
id: "reconnect", | ||
src: "reconnect", | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This invokes the child machine while in this state and stops it as soon as this state is left.
}, | ||
}, | ||
}); | ||
|
||
export const DevToolsMachineContext = createContext<DevToolsActor | null>(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We now use Context to pass this down into the React app - but not the createContext
from xState, as that would create the actor from the machine and we want to create the actor outside of React (the Actor renders React).
"reconnect.retry": "retrying", | ||
}, | ||
entry: ["notifyNotFound"], | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously, this also had a timedout
state, but we never triggered it from anywhere.
}, | ||
}, | ||
}, | ||
notFound: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The modal is now shown while the machine is in this state. If we wanted to show the modal in more states that just one, we could look into tag
.
export const reconnectMachine = setup({ | ||
delays: { connectTimeout: 500 }, | ||
}).createMachine({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In VSCode, we want to show this from the start, as it has valuable information.
We will wait for a very short amount of time though, in case something immediately connects - that way we avoid flickering of the modal.
f68639f
to
961a1ae
Compare
405da4b
to
6975f63
Compare
commit: |
Also see the accompanying apollographql/vscode-graphql#197