Skip to content

Commit 6ddb20d

Browse files
skeptomaiclaude
andcommitted
fix: Remove duplicate prompt by handling echo in JavaScript
The double prompt issue was caused by both WASM and JavaScript showing prompts. Changes: - WASM: Removed prompt echo from process_input (src/wasm.rs) Web UI now handles all display, WASM just processes commands - JavaScript: Echo ">command" to output history when user submits This makes the prompt+command permanent in scroll history InputArea shows live "> " that disappears after Enter Flow now: 1. User sees "> " in InputArea (live, not in history) 2. User types "look" and presses Enter 3. JavaScript adds ">look" to permanent output history 4. InputArea disappears while processing 5. Game output appears 6. New InputArea shows "> " for next command Result: Single prompt visible at any time, behaves like traditional terminal. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 3f4a19e commit 6ddb20d

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/wasm.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,9 +433,7 @@ impl WasmInterpreter {
433433

434434
/// Process text input
435435
fn process_input(&mut self, inst: &Instruction, input: &str) -> Result<(), String> {
436-
self.display.print(">").ok();
437-
self.display.print(input).ok();
438-
self.display.print_char('\n').ok();
436+
// Note: Web UI handles echoing the prompt and command, so we don't print it here
439437

440438
let text_buffer = self.get_operand(inst, 0)?;
441439
let parse_buffer = if inst.operands.len() > 1 {

web/js/main.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,13 @@ function App() {
490490
if (!interpreter) return;
491491

492492
try {
493+
// Echo the command to output with prompt (since WASM no longer does this)
494+
setGameState(prev => ({
495+
...prev,
496+
outputLines: [...prev.outputLines, `>${command}`],
497+
waitingForInput: false,
498+
}));
499+
493500
// Send command to WASM interpreter
494501
interpreter.provide_input(command);
495502

0 commit comments

Comments
 (0)