Skip to content

chore(site): remove terminal xservice #10234

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

Merged
merged 8 commits into from
Oct 20, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Prevent handleWebLink change from recreating terminal
Depending on the timing, handleWebLink was causing the terminal to get
recreated.  We only need to create the terminal once unless the render
type changes.

Recreating the terminal was also recreating the web socket pointlessly.
  • Loading branch information
code-asher committed Oct 19, 2023
commit 15d3f5825dfa91725175790020d6754ddd85e9d7
8 changes: 6 additions & 2 deletions site/src/pages/TerminalPage/TerminalPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ const TerminalPage: FC = () => {
},
[workspaceAgent, workspace.data, username, proxy.preferredWildcardHostname],
);
const handleWebLinkRef = useRef(handleWebLink);
useEffect(() => {
handleWebLinkRef.current = handleWebLink;
}, [handleWebLink]);

// Create the terminal!
useEffect(() => {
Expand Down Expand Up @@ -127,7 +131,7 @@ const TerminalPage: FC = () => {
terminal.unicode.activeVersion = "11";
terminal.loadAddon(
new WebLinksAddon((_, uri) => {
handleWebLink(uri);
handleWebLinkRef.current(uri);
}),
);
setTerminal(terminal);
Expand All @@ -141,7 +145,7 @@ const TerminalPage: FC = () => {
window.removeEventListener("resize", listener);
terminal.dispose();
};
}, [renderer, config.isLoading, xtermRef, handleWebLink]);
}, [renderer, config.isLoading, xtermRef, handleWebLinkRef]);

// Updates the reconnection token into the URL if necessary.
useEffect(() => {
Expand Down