Skip to content

Build v86 Linux emulator with custom UI#201

Merged
simonw merged 5 commits intomainfrom
claude/build-v86-emulator-Od473
Jan 6, 2026
Merged

Build v86 Linux emulator with custom UI#201
simonw merged 5 commits intomainfrom
claude/build-v86-emulator-Od473

Conversation

@simonw
Copy link
Owner

@simonw simonw commented Jan 6, 2026

Build v86.html - a page that loads v86 from a CDN and boots a small Linux distribution in it and provides a minimal custom UI for running a command and seeing the response

Started in Claude Code for web: https://gisthost.github.io/?f203532141daf7d54e2d562b1c0c0181/index.html

Finished in Claude Code locally: https://gisthost.github.io/?d709bb43cf1e6fd3d28fe6c040f1ccc8/index.html

Browser-based x86 Linux emulator using v86 WebAssembly. Features:
- Boots minimal Buildroot Linux distribution
- Custom UI for running commands and viewing output
- Serial terminal interface for command execution
- Dark mode support
- Option to show/hide VGA screen
@claude
Copy link
Contributor

claude bot commented Jan 6, 2026

Claude finished @simonw's task —— View job


PR Review: v86 Linux Emulator

  • Read and analyze v86.html implementation
  • Evaluate code quality and best practices
  • Check for potential bugs and issues
  • Assess performance considerations
  • Review security concerns
  • Evaluate test coverage
  • Provide comprehensive feedback

Code Review Summary

This PR introduces a well-implemented web-based Linux emulator using v86. The code demonstrates good attention to UI/UX design and functionality, but there are several areas that need attention regarding security, error handling, and best practices.

Strengths

Code Quality & Design

  • Excellent responsive design with comprehensive CSS including dark mode support
  • Clean, well-organized code structure with clear separation of concerns
  • Good accessibility features including proper focus management and keyboard navigation
  • Professional UI design with terminal styling and status indicators

Functionality

  • Smart command output parsing using end markers (___CMD_END___) to detect completion
  • Proper state management with status indicators and disabled states during operations
  • Good UX patterns like auto-focus, Enter key support, and output scrolling

⚠️ Critical Issues

Security Concerns

  1. CDN Dependencies without SRI (v86.html:262, v86.html:301, v86.html:306, v86.html:309, v86.html:312)

    <script src="https://cdn.jsdelivr.net/npm/v86@latest/build/libv86.js"></script>
    • Missing Subresource Integrity (SRI) hashes
    • Using @latest tag creates supply chain vulnerability
    • External resources could be compromised without detection
  2. Cross-Origin Resource Loading (v86.html:312)

    bzimage: { url: 'https://i.copy.sh/buildroot-bzimage68.bin' }
    • Loading kernel image from third-party domain without integrity verification
    • No fallback if external resource is unavailable

Error Handling & Reliability

  1. Insufficient Error Handling (v86.html:361-364)

    } catch (error) {
        updateStatus('', 'Error: ' + error.message);
        console.error('Failed to initialize emulator:', error);
    }
    • No recovery mechanism for initialization failures
    • No guidance for users when emulator fails to load
    • Missing timeout handling for boot process
  2. Missing Input Validation (v86.html:385, v86.html:394)

    • No command sanitization or length limits
    • Potential for command injection within the emulated environment

Performance Considerations

  1. Memory Configuration (v86.html:302-303)

    memory_size: 64 * 1024 * 1024,        // 64MB
    vga_memory_size: 2 * 1024 * 1024,     // 2MB
    • Fixed memory allocation may be insufficient for some use cases
    • No detection of device capabilities
  2. Output Buffer Management (v86.html:323)

    outputBuffer += char;
    • Unlimited buffer growth could cause memory issues with verbose commands

🔧 Recommendations

High Priority

  1. Add SRI integrity checks for all external resources
  2. Pin specific versions instead of using @latest
  3. Implement comprehensive error handling with user-friendly messages
  4. Add input validation and command length limits
  5. Implement buffer size limits to prevent memory issues

Medium Priority

  1. Add loading timeouts for emulator initialization
  2. Provide offline fallbacks or error recovery
  3. Add CSP headers when hosting this page
  4. Consider adding a simple test suite for UI functionality

Code Example - Security Fix

<script src="https://cdn.jsdelivr.net/npm/v86@1.3.0/build/libv86.js" 
        integrity="sha384-[hash]" 
        crossorigin="anonymous"></script>

📋 Test Coverage

  • ❌ No automated tests present
  • ❌ No manual testing documentation
  • Recommendation: Add basic UI tests for command execution flow

🏆 Overall Assessment

This is a well-crafted implementation that successfully creates a functional Linux emulator interface. The code quality is high with excellent UI design, but security improvements are essential before production use. The functionality works as intended, but error handling and reliability need strengthening.

Score: 7/10 - Good implementation that needs security and reliability improvements.


The i.copy.sh CDN blocks cross-origin requests from unknown origins.
Switch to static.simonwillison.net which has proper CORS headers.
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jan 6, 2026

Deploying tools with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3cba249
Status:⚡️  Build in progress...

View logs

@claude
Copy link
Contributor

claude bot commented Jan 6, 2026

Claude finished @simonw's task —— View job


Claude finished reviewing the v86 emulator implementation


Code Review Tasks

  • Read and analyze v86.html implementation
  • Evaluate code quality and best practices
  • Check for potential bugs and issues
  • Assess performance considerations
  • Review security concerns
  • Evaluate test coverage
  • Provide comprehensive feedback

Code Review Summary

This PR introduces a well-implemented web-based Linux emulator using v86. The code demonstrates good attention to UI/UX design and functionality, but there are several areas that need attention regarding security, error handling, and best practices.

Strengths

Code Quality & Design

  • Excellent responsive design with comprehensive CSS including dark mode support
  • Clean, well-organized code structure with clear separation of concerns
  • Good accessibility features including proper focus management and keyboard navigation
  • Professional UI design with terminal styling and status indicators

Functionality

  • Smart command output parsing using end markers (___CMD_END___) to detect completion
  • Proper state management with status indicators and disabled states during operations
  • Good UX patterns like auto-focus, Enter key support, and output scrolling

⚠️ Critical Issues

Security Concerns

  1. CDN Dependencies without SRI (v86.html:262, v86.html:301, v86.html:306, v86.html:309, v86.html:312)

    <script src="https://cdn.jsdelivr.net/npm/v86@latest/build/libv86.js"></script>
    • Missing Subresource Integrity (SRI) hashes
    • Using @latest tag creates supply chain vulnerability
    • External resources could be compromised without detection
  2. Cross-Origin Resource Loading (v86.html:312)

    bzimage: { url: 'https://static.simonwillison.net/static/cors-allow/2026/buildroot-bzimage68.bin' }
    • Loading kernel image from third-party domain without integrity verification
    • No fallback if external resource is unavailable

Error Handling & Reliability

  1. Insufficient Error Handling (v86.html:361-364)

    } catch (error) {
        updateStatus('', 'Error: ' + error.message);
        console.error('Failed to initialize emulator:', error);
    }
    • No recovery mechanism for initialization failures
    • No guidance for users when emulator fails to load
    • Missing timeout handling for boot process
  2. Missing Input Validation (v86.html:385, v86.html:394)

    • No command sanitization or length limits
    • Potential for command injection within the emulated environment

Performance Considerations

  1. Memory Configuration (v86.html:302-303)

    memory_size: 64 * 1024 * 1024,        // 64MB
    vga_memory_size: 2 * 1024 * 1024,     // 2MB
    • Fixed memory allocation may be insufficient for some use cases
    • No detection of device capabilities
  2. Output Buffer Management (v86.html:323)

    outputBuffer += char;
    • Unlimited buffer growth could cause memory issues with verbose commands

🔧 Recommendations

High Priority

  1. Add SRI integrity checks for all external resources
  2. Pin specific versions instead of using @latest
  3. Implement comprehensive error handling with user-friendly messages
  4. Add input validation and command length limits
  5. Implement buffer size limits to prevent memory issues

Medium Priority

  1. Add loading timeouts for emulator initialization
  2. Provide offline fallbacks or error recovery
  3. Add CSP headers when hosting this page
  4. Consider adding a simple test suite for UI functionality

Code Example - Security Fix

<script src="https://cdn.jsdelivr.net/npm/v86@1.3.0/build/libv86.js" 
        integrity="sha384-[hash]" 
        crossorigin="anonymous"></script>

📋 Test Coverage

  • ❌ No automated tests present
  • ❌ No manual testing documentation
  • Recommendation: Add basic UI tests for command execution flow

🏆 Overall Assessment

This is a well-crafted implementation that successfully creates a functional Linux emulator interface. The code quality is high with excellent UI design, but security improvements are essential before production use. The functionality works as intended, but error handling and reliability need strengthening.

Score: 7/10 - Good implementation that needs security and reliability improvements.


@claude
Copy link
Contributor

claude bot commented Jan 6, 2026

Claude finished @simonw's task —— View job


Claude finished reviewing the v86 emulator implementation


Code Review Tasks

  • Read and analyze v86.html implementation
  • Evaluate code quality and best practices
  • Check for potential bugs and issues
  • Assess performance considerations
  • Review security concerns
  • Evaluate test coverage
  • Provide comprehensive feedback

Code Review Summary

This PR introduces a well-implemented web-based Linux emulator using v86. The code demonstrates good attention to UI/UX design and functionality, but there are several areas that need attention regarding security, error handling, and best practices.

Strengths

Code Quality & Design

  • Excellent responsive design with comprehensive CSS including dark mode support
  • Clean, well-organized code structure with clear separation of concerns
  • Good accessibility features including proper focus management and keyboard navigation
  • Professional UI design with terminal styling and status indicators

Functionality

  • Smart command output parsing using end markers (___CMD_END___) to detect completion
  • Proper state management with status indicators and disabled states during operations
  • Good UX patterns like auto-focus, Enter key support, and output scrolling

⚠️ Critical Issues

Security Concerns

  1. CDN Dependencies without SRI (v86.html:262, v86.html:301, v86.html:306, v86.html:309, v86.html:312)

    <script src="https://cdn.jsdelivr.net/npm/v86@latest/build/libv86.js"></script>
    • Missing Subresource Integrity (SRI) hashes
    • Using @latest tag creates supply chain vulnerability
    • External resources could be compromised without detection
  2. Cross-Origin Resource Loading (v86.html:312)

    bzimage: { url: 'https://static.simonwillison.net/static/cors-allow/2026/buildroot-bzimage68.bin' }
    • Loading kernel image from third-party domain without integrity verification
    • No fallback if external resource is unavailable

Error Handling & Reliability

  1. Insufficient Error Handling (v86.html:361-364)

    } catch (error) {
        updateStatus('', 'Error: ' + error.message);
        console.error('Failed to initialize emulator:', error);
    }
    • No recovery mechanism for initialization failures
    • No guidance for users when emulator fails to load
    • Missing timeout handling for boot process
  2. Missing Input Validation (v86.html:385, v86.html:394)

    • No command sanitization or length limits
    • Potential for command injection within the emulated environment

Performance Considerations

  1. Memory Configuration (v86.html:302-303)

    memory_size: 64 * 1024 * 1024,        // 64MB
    vga_memory_size: 2 * 1024 * 1024,     // 2MB
    • Fixed memory allocation may be insufficient for some use cases
    • No detection of device capabilities
  2. Output Buffer Management (v86.html:323)

    outputBuffer += char;
    • Unlimited buffer growth could cause memory issues with verbose commands

🔧 Recommendations

High Priority

  1. Add SRI integrity checks for all external resources
  2. Pin specific versions instead of using @latest
  3. Implement comprehensive error handling with user-friendly messages
  4. Add input validation and command length limits
  5. Implement buffer size limits to prevent memory issues

Medium Priority

  1. Add loading timeouts for emulator initialization
  2. Provide offline fallbacks or error recovery
  3. Add CSP headers when hosting this page
  4. Consider adding a simple test suite for UI functionality

Code Example - Security Fix

<script src="https://cdn.jsdelivr.net/npm/v86@1.3.0/build/libv86.js" 
        integrity="sha384-[hash]" 
        crossorigin="anonymous"></script>

📋 Test Coverage

  • ❌ No automated tests present
  • ❌ No manual testing documentation
  • Recommendation: Add basic UI tests for command execution flow

🏆 Overall Assessment

This is a well-crafted implementation that successfully creates a functional Linux emulator interface. The code quality is high with excellent UI design, but security improvements are essential before production use. The functionality works as intended, but error handling and reliability need strengthening.

Score: 7/10 - Good implementation that needs security and reliability improvements.


@claude
Copy link
Contributor

claude bot commented Jan 6, 2026

Claude finished @simonw's task —— View job


PR Review: v86 Linux Emulator

  • Read and analyze v86.html implementation
  • Evaluate code quality and best practices
  • Check for potential bugs and issues
  • Assess performance considerations
  • Review security concerns
  • Evaluate test coverage
  • Provide comprehensive feedback

Code Review Summary

This PR introduces a well-implemented web-based Linux emulator using v86. The code demonstrates good attention to UI/UX design and functionality, but there are several areas that need attention regarding security, error handling, and best practices.

Strengths

Code Quality & Design

  • Excellent responsive design with comprehensive CSS including dark mode support
  • Clean, well-organized code structure with clear separation of concerns
  • Good accessibility features including proper focus management and keyboard navigation
  • Professional UI design with terminal styling and status indicators

Functionality

  • Smart command output parsing using end markers (___CMD_END___) to detect completion
  • Proper state management with status indicators and disabled states during operations
  • Good UX patterns like auto-focus, Enter key support, and output scrolling

⚠️ Critical Issues

Security Concerns

  1. CDN Dependencies without SRI (v86.html:262, v86.html:301, v86.html:306, v86.html:309, v86.html:312)

    <script src="https://cdn.jsdelivr.net/npm/v86@latest/build/libv86.js"></script>
    • Missing Subresource Integrity (SRI) hashes
    • Using @latest tag creates supply chain vulnerability
    • External resources could be compromised without detection
  2. Cross-Origin Resource Loading (v86.html:312)

    bzimage: { url: 'https://static.simonwillison.net/static/cors-allow/2026/buildroot-bzimage68.bin' }
    • Loading kernel image from third-party domain without integrity verification
    • No fallback if external resource is unavailable

Error Handling & Reliability

  1. Insufficient Error Handling (v86.html:382-385)

    } catch (error) {
        updateStatus('', 'Error: ' + error.message);
        console.error('Failed to initialize emulator:', error);
    }
    • No recovery mechanism for initialization failures
    • No guidance for users when emulator fails to load
    • Missing timeout handling for boot process
  2. Missing Input Validation (v86.html:405, v86.html:413)

    • No command sanitization or length limits
    • Potential for command injection within the emulated environment

Performance Considerations

  1. Memory Configuration (v86.html:302-303)

    memory_size: 64 * 1024 * 1024,        // 64MB
    vga_memory_size: 2 * 1024 * 1024,     // 2MB
    • Fixed memory allocation may be insufficient for some use cases
    • No detection of device capabilities
  2. Output Buffer Management (v86.html:323)

    outputBuffer += char;
    • Unlimited buffer growth could cause memory issues with verbose commands

🔧 Recommendations

High Priority

  1. Add SRI integrity checks for all external resources
  2. Pin specific versions instead of using @latest
  3. Implement comprehensive error handling with user-friendly messages
  4. Add input validation and command length limits
  5. Implement buffer size limits to prevent memory issues

Medium Priority

  1. Add loading timeouts for emulator initialization
  2. Provide offline fallbacks or error recovery
  3. Add CSP headers when hosting this page
  4. Consider adding a simple test suite for UI functionality

Code Example - Security Fix

<script src="https://cdn.jsdelivr.net/npm/v86@1.3.0/build/libv86.js" 
        integrity="sha384-[hash]" 
        crossorigin="anonymous"></script>

📋 Test Coverage

  • ❌ No automated tests present
  • ❌ No manual testing documentation
  • Recommendation: Add basic UI tests for command execution flow

🏆 Overall Assessment

This is a well-crafted implementation that successfully creates a functional Linux emulator interface. The code quality is high with excellent UI design, but security improvements are essential before production use. The functionality works as intended, but error handling and reliability need strengthening.

Score: 7/10 - Good implementation that needs security and reliability improvements.


@claude
Copy link
Contributor

claude bot commented Jan 6, 2026

Claude finished @simonw's task —— View job


PR Review: v86 Linux Emulator

  • Read and analyze v86.html implementation
  • Evaluate code quality and best practices
  • Check for potential bugs and issues
  • Assess performance considerations
  • Review security concerns
  • Evaluate test coverage
  • Provide comprehensive feedback

Code Review Summary

This PR introduces a well-implemented web-based Linux emulator using v86. The code demonstrates good attention to UI/UX design and functionality, but there are several areas that need attention regarding security, error handling, and best practices.

Strengths

Code Quality & Design

  • Excellent responsive design with comprehensive CSS including dark mode support
  • Clean, well-organized code structure with clear separation of concerns
  • Good accessibility features including proper focus management and keyboard navigation
  • Professional UI design with terminal styling and status indicators

Functionality

  • Smart command output parsing using prompt pattern detection to identify command completion
  • Proper state management with status indicators and disabled states during operations
  • Good UX patterns like auto-focus, Enter key support, output scrolling, and command cancellation
  • ANSI color code support with proper HTML conversion (v86.html:325-380)

⚠️ Critical Issues

Security Concerns

  1. CDN Dependencies without SRI (v86.html:291, v86.html:446, v86.html:451, v86.html:454)

    <script src="https://cdn.jsdelivr.net/npm/v86@latest/build/libv86.js"></script>
    • Missing Subresource Integrity (SRI) hashes for all external resources
    • Using @latest tag creates supply chain vulnerability
    • External resources could be compromised without detection
  2. Cross-Origin Resource Loading (v86.html:457)

    bzimage: { url: 'https://static.simonwillison.net/static/cors-allow/2026/buildroot-bzimage68.bin' }
    • Loading kernel image from external domain without integrity verification
    • No fallback mechanism if external resource is unavailable

Error Handling & Reliability

  1. Insufficient Error Handling (v86.html:546-549)

    } catch (error) {
        updateStatus('', 'Error: ' + error.message);
        console.error('Failed to initialize emulator:', error);
    }
    • No recovery mechanism for initialization failures
    • No guidance for users when emulator fails to load
    • Missing timeout handling for boot process
  2. Missing Input Validation (v86.html:573, v86.html:582)

    • No command sanitization or length limits
    • Potential for extremely long commands causing issues

Performance & Memory Considerations

  1. Memory Configuration (v86.html:447-448)

    memory_size: 64 * 1024 * 1024,        // 64MB
    vga_memory_size: 2 * 1024 * 1024,     // 2MB
    • Fixed memory allocation may be insufficient for some use cases
    • No detection of device capabilities or memory constraints
  2. Output Buffer Management (v86.html:484)

    outputBuffer += char;
    • Good: Has maxOutputSize limit (50KB) with truncation
    • Good: Buffer cleanup during drain mode (v86.html:474-476)
    • Could improve: No cleanup for very long-running sessions

Code Quality Issues

  1. Complex State Management (v86.html:305-317)

    • Multiple global state variables could lead to race conditions
    • Missing state validation in some transitions
  2. Magic Numbers (v86.html:317, v86.html:428)

    • Hard-coded timeouts and buffer sizes without clear rationale
    • Could benefit from named constants

🔧 Recommendations

High Priority

  1. Add SRI integrity checks for all external resources
  2. Pin specific versions instead of using @latest
  3. Implement comprehensive error handling with user-friendly messages and retry mechanisms
  4. Add input validation with command length limits and basic sanitization
  5. Add timeout handling for emulator initialization

Medium Priority

  1. Improve state management - consider using a state machine or reducer pattern
  2. Add CSP headers when hosting this page
  3. Implement better error recovery for network failures
  4. Add configuration options for memory sizes based on device capabilities

Low Priority

  1. Extract constants for magic numbers and timeouts
  2. Add keyboard shortcuts documentation
  3. Consider adding command history with up/down arrow keys

Security Fix Example

<script src="https://cdn.jsdelivr.net/npm/v86@1.3.0/build/libv86.js" 
        integrity="sha384-[calculated-hash]" 
        crossorigin="anonymous"></script>

📋 Test Coverage

  • ❌ No automated tests present
  • ❌ No manual testing documentation
  • Recommendation: Add basic UI tests for command execution flow and error scenarios

🏆 Overall Assessment

This is a well-crafted implementation that successfully creates a functional Linux emulator interface. The code quality is high with excellent UI design and thoughtful UX considerations. The command parsing logic is sophisticated and handles edge cases well. However, security improvements are essential before production use, and error handling needs strengthening for reliability.

Score: 7.5/10 - Good implementation with strong functionality that needs security and reliability improvements.


@simonw simonw merged commit 14c9cf5 into main Jan 6, 2026
1 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