(null);
useEffect(() => {
const el = codeRef.current;
if (!el) return;
const distance = el.scrollHeight - el.scrollTop - el.clientHeight;
if (distance < 24) el.scrollTop = el.scrollHeight;
}, [code]);
const head = (label: React.ReactNode) => (
Daytona sandbox
{language}
{label}
);
const codeBlock = code ? (
<>
Generated code:
{code}
>
) : null;
if (status === "inProgress") {
return (
{head(
<>
preparing…
>,
)}
{codeBlock}
);
}
if (status === "executing") {
return (
{head(
<>
running…
>,
)}
{codeBlock}
);
}
let stdout = "";
let exitCode = 0;
try {
const parsed = JSON.parse(result ?? "{}");
stdout = typeof parsed.stdout === "string" ? parsed.stdout : "";
exitCode = typeof parsed.exitCode === "number" ? parsed.exitCode : 0;
} catch {
stdout = String(result ?? "");
}
const ok = exitCode === 0;
return (
{head(
{ok ? "✓ done" : `✗ exit ${exitCode}`}
,
)}
{codeBlock}
Result:
{stdout || "(no output)"}
);
}
function RegisterRenderers() {
useRenderTool(
{
name: "runCode",
parameters: runCodeSchema,
render: (props) => (
}
result={(props as { result?: string }).result}
/>
),
},
[],
);
// Starter pills under the input — descriptive titles, kept available across
// the conversation so users can try each language without scrolling back.
useConfigureSuggestions(
{
available: "always",
suggestions: [
{
title: "Python — Zoo animals",
message: "Run a Python snippet listing 20 popular zoo animals",
},
{
title: "TypeScript — Fibonacci numbers",
message:
"Run TypeScript that builds an array of the first 10 Fibonacci numbers and logs the JSON",
},
{
title: "JavaScript — Current timestamp",
message: "Run JavaScript that logs the current timestamp",
},
],
},
[],
);
return null;
}
export default function Page() {
return (
);
}