-
Start the server:
go run main.go
-
Open browser to http://127.0.0.1:7777
-
Run the interactive test:
./test_shell.sh
- Type:
echo 'Hello World' - Expected: Text appears in terminal normally
- On refresh: Text is replayed from buffer
- Type:
lsh - Expected in terminal: Blue clickable link "View HTML Output #1"
- Expected in HTML pane: File listing with sort buttons automatically appears
- Behavior: Link appears AND HTML auto-displays
- Action: Refresh browser (Cmd+R)
- Expected: Link "View HTML Output #1" visible in terminal history
- Expected: HTML pane is hidden/empty (no auto-display on replay)
- Action: Click "View HTML Output #1"
- Expected: HTML pane appears with file listing
- Behavior: Same HTML as before
- Action: Click "Date" sort button in HTML pane
- Expected: New link appears "View HTML Output #2"
- Expected: HTML pane updates with re-sorted listing
- Behavior: Each click creates new HTML widget
- Type:
vimthen:q - Expected: vim works normally
- Expected: After exit, buffer is cleared (no vim escape sequences)
- Action: Refresh page after running vim
- Expected: No VT100 junk in replay
- Expected: Only prompt and normal output
- Run
lshmultiple times - Expected: Links numbered sequentially (#1, #2, #3...)
- Expected: Each link displays its own HTML content
- Expected: HTML content is clean (no escape sequences)
PTY Stream Processing:
1. Read PTY output
2. extractAndStoreHTML(data) -> (processedData, widgetIDs)
- Finds HTML_START...HTML_END blocks
- Extracts clean HTML content
- Stores in htmlWidgets map with unique ID
- Replaces with OSC 8 hyperlink in data
3. Add processedData to buffer (for replay)
4. Broadcast processedData to all clients (terminal output with links)
5. Broadcast HTML notification to live clients (auto-display)
Messages to Clients:
- Binary: Terminal output (with HTML replaced by links)
- JSON:
{"kind":"status", "state":"waiting|running"} - JSON:
{"kind":"html", "widget_id":123}(live clients only)
Message Handling:
- Binary: Write to xterm.js terminal
- JSON status: Update status indicator
- JSON html: Auto-fetch and display HTML widget (live only)
Link Clicking:
- xterm.js WebLinksAddon detects
htmlwidget:NURLs - Fetches
/htmlwidget/N - Displays in HTML panel
- Run
lsh - Right-click HTML panel → Inspect Element
- Look for escape sequences like
\x1bor[1m - Should only see clean HTML/CSS
- Run
vim, then:q - Refresh browser
- Check terminal output
- Should not see
^[[?1049hor similar escape sequences
- Run
lsh3 times - Should see 3 links with IDs #1, #2, #3
- Click each link
- Each should display different content (if directory changed)