fix(ui): persist selected model across playground navigation

Read selectedModel from sessionStorage on initialization so the
model selection survives navigating away from and back to the
playground page. The value was already being saved to sessionStorage
on change but never restored on mount.

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>
This commit is contained in:
Cursor Agent 2026-03-03 05:59:50 +00:00
parent 2d24b48e56
commit c96f8a0cad

View file

@ -157,7 +157,10 @@ const ChatUI: React.FC<ChatUIProps> = ({
return [];
}
});
const [selectedModel, setSelectedModel] = useState<string | undefined>(simplified ? fixedModel : undefined);
const [selectedModel, setSelectedModel] = useState<string | undefined>(() => {
if (simplified) return fixedModel;
return sessionStorage.getItem("selectedModel") || undefined;
});
const [showCustomModelInput, setShowCustomModelInput] = useState<boolean>(false);
const [modelInfo, setModelInfo] = useState<ModelGroup[]>([]);
const [agentInfo, setAgentInfo] = useState<Agent[]>([]);