Skip to content

Commit

Permalink
fix: Do not pin span in url for playground trace details slideover (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
cephalization authored Oct 28, 2024
1 parent 106a42f commit 7f41824
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
17 changes: 16 additions & 1 deletion app/src/pages/playground/Playground.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react";
import React, { useEffect } from "react";
import { Panel, PanelGroup, PanelResizeHandle } from "react-resizable-panels";
import { useSearchParams } from "react-router-dom";
import { css } from "@emotion/react";

import {
Expand Down Expand Up @@ -40,6 +41,20 @@ const playgroundWrapCSS = css`

export function Playground(props: InitialPlaygroundState) {
const showStreamToggle = useFeatureFlag("playgroundNonStreaming");
const [, setSearchParams] = useSearchParams();

useEffect(() => {
setSearchParams(
(searchParams) => {
// remove lingering selectedSpanNodeId param so as to not poison the trace details slideover
// with stale data from previous pages
searchParams.delete("selectedSpanNodeId");
return searchParams;
},
{ replace: true }
);
}, [setSearchParams]);

return (
<PlaygroundProvider {...props}>
<div css={playgroundWrapCSS}>
Expand Down
6 changes: 5 additions & 1 deletion app/src/pages/playground/SpanPlaygroundPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ export function SpanPlaygroundPage() {
return (
<Flex direction="column" height={"100%"}>
<SpanPlaygroundBanners span={span} parsingErrors={parsingErrors} />
<Playground instances={[playgroundInstance]} />
<Playground
// remount the playground when the span changes, resetting all local state, closing dialogs, etc.
key={span.id}
instances={[playgroundInstance]}
/>
</Flex>
);
}
Expand Down

0 comments on commit 7f41824

Please sign in to comment.