Skip to content
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

Open
wants to merge 16 commits into
base: pr/vscode-connect-info
Choose a base branch
from

Conversation

phryneas
Copy link
Member

@phryneas phryneas commented Sep 9, 2024

Also see the accompanying apollographql/vscode-graphql#197

onClose={() => send({ type: "closeModal" })}
onRetry={() => send({ type: "retry" })}
/>
<Modals />
Copy link
Member Author

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
Copy link
Member Author

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"})
Copy link
Member Author

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;
Copy link
Member Author

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.

Comment on lines 9 to 11
open: boolean;
onClose: () => void;
onRetry: () => void;
}
Copy link
Member Author

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.

Comment on lines +192 to +195
invoke: {
id: "reconnect",
src: "reconnect",
},
Copy link
Member Author

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);
Copy link
Member Author

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"],
},
Copy link
Member Author

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: {
Copy link
Member Author

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.

Comment on lines +2 to +4
export const reconnectMachine = setup({
delays: { connectTimeout: 500 },
}).createMachine({
Copy link
Member Author

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.

@phryneas phryneas marked this pull request as ready for review September 11, 2024 08:56
@phryneas phryneas requested a review from a team as a code owner September 11, 2024 08:56
phryneas added a commit to apollographql/vscode-graphql that referenced this pull request Sep 11, 2024
phryneas added a commit to apollographql/vscode-graphql that referenced this pull request Sep 20, 2024
Copy link

pkg-pr-new bot commented Sep 20, 2024

npm i https://pkg.pr.new/apollographql/apollo-client-devtools/@apollo/client-devtools-vscode@1513

commit: e2d4385

phryneas added a commit to apollographql/vscode-graphql that referenced this pull request Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant