fix: Corregir scroll del emulador y serializacion circular de FindCursor en mongosh

This commit is contained in:
2026-08-12 03:35:41 +00:00
parent 827db0a356
commit c06ca1db79
2 changed files with 10 additions and 4 deletions
+8 -2
View File
@@ -828,8 +828,14 @@ app.post('/api/admin/mongosh', async (req, res) => {
})();
`);
const result = await evalFn(dbProxy, ObjectId);
res.json({ result });
let finalResult = await evalFn(dbProxy, ObjectId);
// Si el resultado es un cursor de MongoDB (ej. db.collection.find()), lo convertimos a array
if (finalResult && typeof finalResult === 'object' && typeof finalResult.toArray === 'function') {
finalResult = await finalResult.toArray();
}
res.json({ result: finalResult });
} catch (err) {
res.status(400).json({ error: err.message || String(err) });
}
+2 -2
View File
@@ -169,7 +169,7 @@ export function SeccionSistema() {
<CardContent>
<div
className="bg-gray-900 text-green-400 font-mono text-sm p-4 rounded-md h-[400px] overflow-y-auto flex flex-col gap-1 relative cursor-text group"
onClick={() => inputRef.current?.focus()}
onClick={() => inputRef.current?.focus({ preventScroll: true })}
>
{consoleHistory.length === 0 && (
<div className="text-gray-500 italic mb-2">Conectado. Esperando comandos... Ej: db.pacientes.find()</div>
@@ -194,7 +194,7 @@ export function SeccionSistema() {
<input
ref={inputRef}
type="text"
className="opacity-0 absolute inset-0 w-full h-full pointer-events-none"
className="opacity-0 w-[1px] h-[1px] absolute overflow-hidden p-0 m-0 border-0 pointer-events-none"
value={mongoshCommand}
onChange={(e) => setMongoshCommand(e.target.value)}
onKeyDown={handleKeyDown}