Python
Artifact chip opens the viewer again while the rail is hidden
Rohit C Prasadf63222ff9d18
diff --git a/surfaces/gui/src/components/RightRail.tsx b/surfaces/gui/src/components/RightRail.tsxindex 892cc9a0..1154ec50 100644--- a/surfaces/gui/src/components/RightRail.tsx+++ b/surfaces/gui/src/components/RightRail.tsx@@ -169,6 +169,8 @@ export function RightRail({const [content, setContent] = useState<ArtifactContent | null>(null);const artifactListRequest = useRef(0);const artifactContentRequest = useRef(0);+ const sessionRef = useRef(sessionId);+ sessionRef.current = sessionId;// Every refresh owns a monotonically increasing request id. Session switches, live refreshes,// and manual refreshes can overlap; only the newest response may update this rail.@@ -293,10 +295,19 @@ export function RightRail({setSelected(found);return;}- refreshArtifacts(- (list) => setSelected(match(list, path) ?? minimal(path)),- () => setSelected(minimal(path)),- );+ // Not routed through the list request id: App unhides the rail on this same+ // event, and that refresh would supersede this one and drop the selection+ // (owner-hit 2026-10-25). Only a session switch mid-flight discards the answer.+ const owner = sessionId;+ getArtifacts(owner)+ .then((list) => {+ if (owner !== sessionRef.current) return;+ setArtifacts(list);+ setSelected(match(list, path) ?? minimal(path));+ })+ .catch(() => {+ if (owner === sessionRef.current) setSelected(minimal(path));+ });};window.addEventListener(OPEN_ARTIFACT_EVENT, onOpen);return () => window.removeEventListener(OPEN_ARTIFACT_EVENT, onOpen);