Skip to content

Commit 2183725

Browse files
committed
fix(site): Use correct UUID for web terminal when first opened
While working on #5403 I noticed the web terminal connects with a different UUID than what is serialized in the URL, this resulted in a new session being opened if I refreshed the page. The reasons seems to be that we were accessing raw DOM elements (`location.search`) for navigation and omitting `react-router-dom`. This resulted in a new navigation and UUID being generated after the fact.
1 parent 560c8ce commit 2183725

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

site/src/pages/TerminalPage/TerminalPage.tsx

+6-4
Original file line numberDiff line numberDiff line change
@@ -127,17 +127,19 @@ const TerminalPage: FC<
127127
// the reconnection token and workspace name found
128128
// from the router.
129129
useEffect(() => {
130-
const search = new URLSearchParams(location.search)
131-
search.set("reconnect", reconnectionToken)
130+
if (searchParams.get("reconnect") === reconnectionToken) {
131+
return
132+
}
133+
searchParams.set("reconnect", reconnectionToken)
132134
navigate(
133135
{
134-
search: search.toString(),
136+
search: searchParams.toString(),
135137
},
136138
{
137139
replace: true,
138140
},
139141
)
140-
}, [location.search, navigate, reconnectionToken])
142+
}, [searchParams, navigate, reconnectionToken])
141143

142144
// Apply terminal options based on connection state.
143145
useEffect(() => {

0 commit comments

Comments
 (0)