Skip to content

Add mobile-friendly Pyodide REPL#221

Merged
simonw merged 4 commits intomainfrom
claude/mobile-pyodide-repl-nJJfE
Feb 10, 2026
Merged

Add mobile-friendly Pyodide REPL#221
simonw merged 4 commits intomainfrom
claude/mobile-pyodide-repl-nJJfE

Conversation

@simonw
Copy link
Owner

@simonw simonw commented Feb 10, 2026

Create pyodide-repo.html

Inspired by https://pyodide.org/en/stable/console.html (fetch with curl to
/tmp) but that page isn’t mobile friendly - so build a mobile friendly version of the REPL using a neatly styled but simple textarea for the input since mobile keyboards are tricky

Test it works by serving it with python -m http.server and then exercising it using “uvx rodney –help”

A mobile-friendly alternative to pyodide.org/en/stable/console.html
which uses jQuery Terminal and doesn't work well on mobile. Uses a
textarea for input (avoids mobile keyboard issues), with Enter to
run and Shift+Enter for newlines. Supports multiline code, command
history, and micropip package installation.

https://claude.ai/code/session_0127moedQbAB2MR6H3epKAV7

A mobile-friendly alternative to pyodide.org/en/stable/console.html
which uses jQuery Terminal and doesn't work well on mobile. Uses a
textarea for input (avoids mobile keyboard issues), with Enter to
run and Shift+Enter for newlines. Supports multiline code, command
history, and micropip package installation.

https://claude.ai/code/session_0127moedQbAB2MR6H3epKAV7
@claude
Copy link
Contributor

claude bot commented Feb 10, 2026

Claude finished @simonw's task —— View job


Code Review Complete ✅

I've reviewed the mobile-friendly Pyodide REPL implementation. This is a well-crafted tool that addresses real usability issues with mobile Python development. Here's my detailed feedback:

Review Tasks

  • Read and analyze the new pyodide-repo.html file
  • Review code quality and best practices
  • Check for potential bugs or issues
  • Assess performance considerations
  • Evaluate security concerns
  • Review test coverage
  • Post comprehensive review feedback

✅ Code Quality & Best Practices

Excellent aspects:

  • Clean architecture: Well-structured separation between UI, console logic, and Python execution
  • Modern CSS: Uses CSS custom properties for theming, proper flexbox layouts, responsive design
  • Accessibility: Good keyboard navigation, proper ARIA attributes implicit in semantic HTML
  • Mobile optimization: Thoughtful touches like font-size: 16px on mobile to prevent iOS zoom (line 172)
  • Memory management: Proper PyProxy cleanup in pyodide-repo.html:266-268 and pyodide-repo.html:276-278

Minor improvements:

  • Consider extracting the large inline styles into a separate CSS file for better maintainability
  • The JavaScript could benefit from being split into modules for better organization

🐛 Potential Issues

Low-risk issues found:

  1. Non-breaking space handling (pyodide-repo.html:308): Good defensive programming to replace \u00a0 with regular spaces
  2. Error handling: Robust error handling for both Python errors and JavaScript exceptions (pyodide-repo.html:269-279)
  3. Input validation: Proper checks for empty input and console state (pyodide-repo.html:284-287)

Areas to watch:

  • History array could grow indefinitely - consider implementing a max history limit
  • No explicit handling of extremely large outputs (though reprShorten helps)

⚡ Performance Considerations

Well optimized:

  • Uses Pyodide v0.26.2 from CDN for fast loading
  • Efficient DOM updates with scrollTop management
  • Proper async/await usage prevents blocking
  • Smart history navigation (only when single-line, pyodide-repo.html:346)

Performance notes:

  • Initial load time will depend on Pyodide download (~10MB) - this is inherent to the technology
  • Memory usage will grow with session length due to Python runtime - consider documenting this

🔒 Security Assessment

Good security practices:

  • No use of innerHTML or eval() - all content added via textContent
  • Loads Pyodide from official CDN (jsdelivr.net)
  • Uses specific version (v0.26.2) rather than latest
  • No sensitive data exposure

Security considerations:

  • Pyodide runs in browser sandbox, which is appropriate for this use case
  • prompt() usage for stdin (pyodide-repo.html:381) is safe but basic - acceptable for a REPL
  • External CDN dependency introduces availability risk but is standard practice

🧪 Test Coverage

Current state: No automated tests present

Recommendations:

  • Consider adding basic functionality tests (input handling, output display, history navigation)
  • Integration tests for Pyodide console interaction would be valuable
  • Mobile-specific testing for touch interactions and virtual keyboard behavior

Test scenarios to consider:

  • Multiline input handling
  • History navigation edge cases
  • Error state recovery
  • Memory cleanup verification

🎯 Overall Assessment

This is high-quality code that successfully addresses the mobile usability issues of the standard Pyodide console. The implementation is thoughtful, well-structured, and demonstrates good understanding of both web development best practices and Python-in-browser constraints.

Strengths:

  • Excellent mobile UX with textarea-based input
  • Robust error handling and memory management
  • Clean, maintainable code structure
  • Good performance optimizations

Ready for production with the minor suggestions noted above being non-blocking improvements for future iterations.

- Rename pyodide-repo.html -> pyodide-repl.html
- Input area now flows inline after output instead of being anchored
  at the bottom, so it sits where the next >>> line would naturally go
- Add toggle between single-line mode (Enter to run) and multi-line
  mode (Ctrl+Enter to run, Enter inserts newlines) for entering
  function definitions and other multi-line code on mobile
- Add bottom spacer so keyboard doesn't obscure the input
- Include mobile (375x812) and desktop (1024x768) screenshots

https://claude.ai/code/session_0127moedQbAB2MR6H3epKAV7
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Feb 10, 2026

Deploying tools with  Cloudflare Pages  Cloudflare Pages

Latest commit: 27f6305
Status: ✅  Deploy successful!
Preview URL: https://0ff6a631.tools-b1q.pages.dev
Branch Preview URL: https://claude-mobile-pyodide-repl-n.tools-b1q.pages.dev

View logs

@claude
Copy link
Contributor

claude bot commented Feb 10, 2026

Claude finished @simonw's task —— View job


Code Review Complete ✅

I've conducted a thorough review of the mobile-friendly Pyodide REPL implementation. This is a well-crafted tool that successfully addresses mobile usability issues with Python-in-browser experiences.

Review Tasks

  • Read and analyze the pyodide-repl.html implementation
  • Review code quality and best practices
  • Check for potential bugs or issues
  • Assess performance considerations
  • Evaluate security concerns
  • Review test coverage

✅ Code Quality & Best Practices

Excellent implementation with:

  • Clean architecture: Well-structured separation between UI, console logic, and Python execution
  • Modern CSS: Effective use of CSS custom properties, responsive design with proper breakpoints
  • Mobile optimization: Thoughtful details like font-size: 16px on mobile (pyodide-repl.html:187) to prevent iOS zoom
  • Accessibility: Good semantic HTML, keyboard navigation support, proper focus management
  • Memory management: Proper PyProxy cleanup throughout (pyodide-repl.html:325, 336, 484)

Code organization strengths:

  • Clear separation of concerns between DOM manipulation, Pyodide integration, and input handling
  • Consistent error handling patterns
  • Well-structured async/await usage preventing UI blocking

🐛 Potential Issues Found

Low-risk issues addressed:

  1. Input sanitization (pyodide-repl.html:366): Good handling of non-breaking spaces (\u00a0 → regular spaces)
  2. Incomplete code blocks (pyodide-repl.html:369-372): Proper completion of multi-line statements
  3. Memory leaks: Consistent PyProxy destruction prevents memory accumulation

Areas for consideration:

  • History growth: Command history array grows unbounded - consider implementing max history limit (~1000 commands)
  • Large output handling: While reprShorten helps, extremely large outputs could still impact performance
  • Continuation prompt reset: Proper handling when syntax errors occur in multi-line mode

⚡ Performance Analysis

Well optimized:

  • Fast loading: Uses Pyodide v0.26.2 from reliable CDN (jsdelivr.net)
  • Efficient rendering: Smart DOM updates with requestAnimationFrame scrolling (pyodide-repl.html:258-260)
  • Resource cleanup: Proper disposal of Python objects prevents memory leaks
  • Input responsiveness: Auto-resize logic only in single-line mode avoids unnecessary calculations

Performance considerations:

  • Initial load time (~10MB Pyodide download) is inherent to the technology
  • Memory usage grows with session length due to Python runtime - this is expected behavior

🔒 Security Assessment

Strong security practices:

  • XSS prevention: Uses textContent exclusively, never innerHTML (pyodide-repl.html:251)
  • CDN integrity: Loads from reputable jsdelivr.net with specific version pinning
  • Sandbox execution: Python runs in browser sandbox with no file system access
  • Input validation: No dangerous eval() usage, all code executed through Pyodide's safe APIs

Security notes:

  • prompt() usage for stdin (pyodide-repl.html:457) is basic but appropriate for a REPL environment
  • No sensitive data exposure vectors identified

🧪 Test Coverage

Current state: No automated tests present (expected for this type of tool)

Testing recommendations:

  • Unit tests: Input parsing, history navigation, mode switching
  • Integration tests: Pyodide console interaction, error handling flows
  • Mobile testing: Virtual keyboard behavior, touch interactions
  • Edge cases: Large outputs, rapid input, network interruption recovery

📱 Mobile UX Excellence

Outstanding mobile features:

  • Textarea-based input: Solves the primary mobile keyboard issues with contenteditable
  • Touch-optimized controls: Proper button sizing and touch-action handling
  • Keyboard adaptation: Smart font size and viewport handling
  • Mode flexibility: Single-line vs multi-line modes accommodate different input scenarios

🎯 Overall Assessment

This is production-ready code that demonstrates excellent understanding of both web development best practices and Python-in-browser constraints. The implementation successfully solves the stated problem of mobile-unfriendly Python REPLs.

Key strengths:

  • Excellent mobile UX with thoughtful input handling
  • Robust error handling and memory management
  • Clean, maintainable code architecture
  • Good performance optimizations
  • Strong security practices

Minor enhancements for future versions:

  • Consider history size limits for long sessions
  • Add optional syntax highlighting for enhanced UX
  • Implement session save/restore capabilities

Verdict: Ready for deployment. This tool fills a genuine need in the mobile Python development space with a high-quality implementation.


@claude
Copy link
Contributor

claude bot commented Feb 10, 2026

Claude finished @simonw's task —— View job


Code Review Complete ✅

I've reviewed the mobile-friendly Pyodide REPL implementation. This is a well-crafted tool that addresses real usability issues with mobile Python development. Here's my detailed feedback:

Review Tasks

  • Read and analyze the new pyodide-repl.html file
  • Review code quality and best practices
  • Check for potential bugs or issues
  • Assess performance considerations
  • Evaluate security concerns
  • Review test coverage
  • Post comprehensive review feedback

✅ Code Quality & Best Practices

Excellent aspects:

  • Clean architecture: Well-structured separation between UI, console logic, and Python execution
  • Modern CSS: Uses CSS custom properties for theming, proper flexbox layouts, responsive design
  • Accessibility: Good keyboard navigation, proper ARIA attributes implicit in semantic HTML
  • Mobile optimization: Thoughtful touches like font-size: 16px on mobile to prevent iOS zoom (pyodide-repl.html:187)
  • Memory management: Proper PyProxy cleanup in pyodide-repl.html:324-326 and pyodide-repl.html:335-336

Minor improvements:

  • Consider extracting the large inline styles into a separate CSS file for better maintainability
  • The JavaScript could benefit from being split into modules for better organization

🐛 Potential Issues

Low-risk issues found:

  1. Non-breaking space handling (pyodide-repl.html:366): Good defensive programming to replace \u00a0 with regular spaces
  2. Error handling: Robust error handling for both Python errors and JavaScript exceptions (pyodide-repl.html:327-337)
  3. Input validation: Proper checks for empty input and console state (pyodide-repl.html:342-345)

Areas to watch:

  • History array could grow indefinitely - consider implementing a max history limit
  • No explicit handling of extremely large outputs (though reprShorten helps)

⚡ Performance Considerations

Well optimized:

  • Uses Pyodide v0.26.2 from CDN for fast loading
  • Efficient DOM updates with scrollToInput() management
  • Proper async/await usage prevents blocking
  • Smart history navigation (only when single-line, pyodide-repl.html:422)

Performance notes:

  • Initial load time will depend on Pyodide download (~10MB) - this is inherent to the technology
  • Memory usage will grow with session length due to Python runtime - consider documenting this

🔒 Security Assessment

Good security practices:

  • No use of innerHTML or eval() - all content added via textContent
  • Loads Pyodide from official CDN (jsdelivr.net)
  • Uses specific version (v0.26.2) rather than latest
  • No sensitive data exposure

Security considerations:

  • Pyodide runs in browser sandbox, which is appropriate for this use case
  • prompt() usage for stdin (pyodide-repl.html:457) is safe but basic - acceptable for a REPL
  • External CDN dependency introduces availability risk but is standard practice

🧪 Test Coverage

Current state: No automated tests present

Recommendations:

  • Consider adding basic functionality tests (input handling, output display, history navigation)
  • Integration tests for Pyodide console interaction would be valuable
  • Mobile-specific testing for touch interactions and virtual keyboard behavior

Test scenarios to consider:

  • Multiline input handling
  • History navigation edge cases
  • Error state recovery
  • Memory cleanup verification

🎯 Overall Assessment

This is high-quality code that successfully addresses the mobile usability issues of the standard Pyodide console. The implementation is thoughtful, well-structured, and demonstrates good understanding of both web development best practices and Python-in-browser constraints.

Strengths:

  • Excellent mobile UX with textarea-based input
  • Robust error handling and memory management
  • Clean, maintainable code structure
  • Good performance optimizations

Ready for production with the minor suggestions noted above being non-blocking improvements for future iterations.

@claude
Copy link
Contributor

claude bot commented Feb 10, 2026

Claude finished @simonw's task —— View job


Code Review Complete ✅

I've conducted a thorough review of the mobile-friendly Pyodide REPL implementation. This is a well-crafted tool that successfully addresses mobile usability issues with Python-in-browser experiences.

Review Tasks

  • Read and analyze the pyodide-repl.html implementation
  • Review code quality and best practices
  • Check for potential bugs or issues
  • Assess performance considerations
  • Evaluate security concerns
  • Review test coverage

✅ Code Quality & Best Practices

Excellent implementation with:

  • Clean architecture: Well-structured separation between UI, console logic, and Python execution
  • Modern CSS: Effective use of CSS custom properties, responsive design with proper breakpoints
  • Mobile optimization: Thoughtful details like font-size: 16px on mobile (pyodide-repl.html:187) to prevent iOS zoom
  • Accessibility: Good semantic HTML, keyboard navigation support, proper focus management
  • Memory management: Proper PyProxy cleanup throughout (pyodide-repl.html:325, 336, 484)

Code organization strengths:

  • Clear separation of concerns between DOM manipulation, Pyodide integration, and input handling
  • Consistent error handling patterns
  • Well-structured async/await usage preventing UI blocking

🐛 Potential Issues Found

Low-risk issues addressed:

  1. Input sanitization (pyodide-repl.html:366): Good handling of non-breaking spaces (\u00a0 → regular spaces)
  2. Incomplete code blocks (pyodide-repl.html:369-372): Proper completion of multi-line statements
  3. Memory leaks: Consistent PyProxy destruction prevents memory accumulation

Areas for consideration:

  • History growth: Command history array grows unbounded - consider implementing max history limit (~1000 commands)
  • Large output handling: While reprShorten helps, extremely large outputs could still impact performance
  • Continuation prompt reset: Proper handling when syntax errors occur in multi-line mode

⚡ Performance Analysis

Well optimized:

  • Fast loading: Uses Pyodide v0.26.2 from reliable CDN (jsdelivr.net)
  • Efficient rendering: Smart DOM updates with requestAnimationFrame scrolling (pyodide-repl.html:258-260)
  • Resource cleanup: Proper disposal of Python objects prevents memory leaks
  • Input responsiveness: Auto-resize logic only in single-line mode avoids unnecessary calculations

Performance considerations:

  • Initial load time (~10MB Pyodide download) is inherent to the technology
  • Memory usage grows with session length due to Python runtime - this is expected behavior

🔒 Security Assessment

Strong security practices:

  • XSS prevention: Uses textContent exclusively, never innerHTML (pyodide-repl.html:251)
  • CDN integrity: Loads from reputable jsdelivr.net with specific version pinning
  • Sandbox execution: Python runs in browser sandbox with no file system access
  • Input validation: No dangerous eval() usage, all code executed through Pyodide's safe APIs

Security notes:

  • prompt() usage for stdin (pyodide-repl.html:457) is basic but appropriate for a REPL environment
  • No sensitive data exposure vectors identified

🧪 Test Coverage

Current state: No automated tests present (expected for this type of tool)

Testing recommendations:

  • Unit tests: Input parsing, history navigation, mode switching
  • Integration tests: Pyodide console interaction, error handling flows
  • Mobile testing: Virtual keyboard behavior, touch interactions
  • Edge cases: Large outputs, rapid input, network interruption recovery

📱 Mobile UX Excellence

Outstanding mobile features:

  • Textarea-based input: Solves the primary mobile keyboard issues with contenteditable
  • Touch-optimized controls: Proper button sizing and touch-action handling
  • Keyboard adaptation: Smart font size and viewport handling
  • Mode flexibility: Single-line vs multi-line modes accommodate different input scenarios

🎯 Overall Assessment

This is production-ready code that demonstrates excellent understanding of both web development best practices and Python-in-browser constraints. The implementation successfully solves the stated problem of mobile-unfriendly Python REPLs.

Key strengths:

  • Excellent mobile UX with thoughtful input handling
  • Robust error handling and memory management
  • Clean, maintainable code architecture
  • Good performance optimizations
  • Strong security practices

Minor enhancements for future versions:

  • Consider history size limits for long sessions
  • Add optional syntax highlighting for enhanced UX
  • Implement session save/restore capabilities

Verdict: Ready for deployment. This tool fills a genuine need in the mobile Python development space with a high-quality implementation.


@simonw simonw merged commit eb2634f into main Feb 10, 2026
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants