Skip to content

fix(site): Use correct UUID for web terminal when first opened #5404

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 2 commits into from
Dec 14, 2022
Merged
Changes from all commits
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
18 changes: 7 additions & 11 deletions site/src/pages/TerminalPage/TerminalPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@ import { makeStyles } from "@material-ui/core/styles"
import { useMachine } from "@xstate/react"
import { FC, useEffect, useRef, useState } from "react"
import { Helmet } from "react-helmet-async"
import {
useLocation,
useNavigate,
useParams,
useSearchParams,
} from "react-router-dom"
import { useNavigate, useParams, useSearchParams } from "react-router-dom"
import { colors } from "theme/colors"
import { v4 as uuidv4 } from "uuid"
import * as XTerm from "xterm"
Expand All @@ -29,7 +24,6 @@ const TerminalPage: FC<
readonly renderer?: XTerm.RendererType
}>
> = ({ renderer }) => {
const location = useLocation()
const navigate = useNavigate()
const styles = useStyles()
const { username, workspace } = useParams()
Expand Down Expand Up @@ -127,17 +121,19 @@ const TerminalPage: FC<
// the reconnection token and workspace name found
// from the router.
useEffect(() => {
const search = new URLSearchParams(location.search)
search.set("reconnect", reconnectionToken)
if (searchParams.get("reconnect") === reconnectionToken) {
return
}
searchParams.set("reconnect", reconnectionToken)
navigate(
{
search: search.toString(),
search: searchParams.toString(),
},
{
replace: true,
},
)
}, [location.search, navigate, reconnectionToken])
}, [searchParams, navigate, reconnectionToken])

// Apply terminal options based on connection state.
useEffect(() => {
Expand Down