Spaces:
Running
Running
Commit ·
22a357d
1
Parent(s): 25ebccb
commit initial 09-12-2025 36
Browse files- src/App.js +7 -0
src/App.js
CHANGED
|
@@ -327,6 +327,8 @@ const [interactivePromptShown, setInteractivePromptShown] = useState(false);
|
|
| 327 |
|
| 328 |
|
| 329 |
// Initial Run: do NOT run if code needs interactive input and there's no accumulated stdin.
|
|
|
|
|
|
|
| 330 |
const handleRun = async () => {
|
| 331 |
const node = getNodeByPath(tree, activePath);
|
| 332 |
if (!node || node.type !== "file") {
|
|
@@ -339,6 +341,10 @@ const handleRun = async () => {
|
|
| 339 |
return;
|
| 340 |
}
|
| 341 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 342 |
const needs = codeNeedsInput(node.content, selectedLang);
|
| 343 |
const haveAccum = !!(accumStdin && accumStdin.length > 0);
|
| 344 |
const haveLegacyStdin = !!(stdin && stdin.length > 0);
|
|
@@ -388,6 +394,7 @@ const handleRun = async () => {
|
|
| 388 |
};
|
| 389 |
|
| 390 |
|
|
|
|
| 391 |
// Send from the small input box: delegate to runCodeWithUpdatedInput to keep behavior uniform
|
| 392 |
const sendTerminalInput = async () => {
|
| 393 |
const line = (terminalInput || "").replace(/\r$/, "");
|
|
|
|
| 327 |
|
| 328 |
|
| 329 |
// Initial Run: do NOT run if code needs interactive input and there's no accumulated stdin.
|
| 330 |
+
// Replace your existing handleRun with this version.
|
| 331 |
+
// This version clears accumulated stdin at the start so "Run" asks fresh input every time.
|
| 332 |
const handleRun = async () => {
|
| 333 |
const node = getNodeByPath(tree, activePath);
|
| 334 |
if (!node || node.type !== "file") {
|
|
|
|
| 341 |
return;
|
| 342 |
}
|
| 343 |
|
| 344 |
+
// Always reset accumulated stdin when the user clicks Run so they must provide fresh input.
|
| 345 |
+
// (If you want the old interactive continuation behavior, remove this line.)
|
| 346 |
+
setAccumStdin("");
|
| 347 |
+
|
| 348 |
const needs = codeNeedsInput(node.content, selectedLang);
|
| 349 |
const haveAccum = !!(accumStdin && accumStdin.length > 0);
|
| 350 |
const haveLegacyStdin = !!(stdin && stdin.length > 0);
|
|
|
|
| 394 |
};
|
| 395 |
|
| 396 |
|
| 397 |
+
|
| 398 |
// Send from the small input box: delegate to runCodeWithUpdatedInput to keep behavior uniform
|
| 399 |
const sendTerminalInput = async () => {
|
| 400 |
const line = (terminalInput || "").replace(/\r$/, "");
|