Skip to content

Release v0.1.1#21

Merged
linletian merged 37 commits intomainfrom
chore/v0.1.1-release-prep
Mar 14, 2026
Merged

Release v0.1.1#21
linletian merged 37 commits intomainfrom
chore/v0.1.1-release-prep

Conversation

@linletian
Copy link
Owner

Summary

  • prepare release-facing docs for v0.1.1 based on the current develop branch
  • document that v0.1.0 release assets were withdrawn after severe post-release issues, while the tag remains the comparison baseline
  • update release download examples and add a v0.1.1 changelog section covering the terminal/TTY stability fixes since v0.1.0

Validation

  • gofmt -l .
  • go test ./...
  • go build -o myworktree ./cmd/myworktree
  • go build -o mw ./cmd/mw

linletian and others added 30 commits March 11, 2026 20:07
When a worktree directory is deleted externally (e.g., user runs rm -rf),
the Delete operation now:
1. Checks if the worktree path exists using os.Stat
2. If not exists: runs git worktree prune --expire now to clean git metadata
3. If exists: uses existing logic (check dirty, then git worktree remove)

Also adds integration test TestDeleteMissingWorktreeRemovesState to verify
the cleanup behavior.

This fixes the state inconsistency where worktree record remains in
state.json and git metadata after external deletion.
fix: handle worktree deletion when directory is already removed
- Add comprehensive AGENTS.md with project overview, build/test commands,
  code style guidelines, and architectural notes for AI coding assistants
- Implement auto-focus terminal cursor in Web UI: focuses terminal automatically
  when opening an instance, when window gains focus, and after closing dialogs
- Use alternate buffer (CSI ?1049h/l) for clean TUI state instead of full terminal reset
- Skip term.reset() for running instances in loadLog to preserve TUI state
- Trigger term.resize() after first WebSocket message to force TUI redraw

This fixes display issues with TUI programs (vim, htop, less, etc.) when
switching between instances in the web terminal.
fix(ui): improve TUI display when switching running instances
Conflicts:
- internal/ui/static/index.html: resolved with both features preserved
- Use pty.Start() instead of script command to enable true PTY
- Add Resize method to Manager for handling cols/rows updates
- Parse resize messages in WebSocket handler
- Frontend sends resize events with debouncing (100ms)

This enables interactive programs (vim, less, etc.) to respond
correctly when users resize the terminal in the Web UI.
Add three test cases:
- TestResize_InvalidParams: validates empty/whitespace id and invalid cols/rows
- TestResize_NotFound: validates error for nonexistent instance
- TestResize_Success: creates real PTY and verifies resize works correctly
Ubuntu CI doesn't have zsh installed, causing TestResize_Success to fail.
feat(instance): pass terminal window size from Web UI to PTY
- Server sends {"type":"ready"} after WebSocket connection
- Client waits for ready message before sending resize
- Add 5s handshake timeout with SSE fallback
- Update PRD/API/ARCHITECTURE docs to document the protocol
feat(instance): add WebSocket TTY handshake protocol
…e config

- Add scrollback: 10000 to xterm.js terminal initialization
- Document that terminal parameters (scrollback, theme, font) are
  client-side configurable in ARCHITECTURE.md and PRD
- Add note in API.md that client-side terminal settings are not
  part of the backend API
feat(ui): increase terminal scrollback buffer and document client-side config
- Add Ctrl+C/Z/\ support in SendInput to properly signal processes
- Remove terminal control sequence remnants from log output (e.g.,
  mouse events from TUI programs like top, cursor position reports)
- Add unit tests for control sequence redaction
- Fix regex for control sequence redaction to avoid false positives
  on normal text like [1;2;3] array notation
- Write control characters to stdin in addition to sending signals,
  matching v0.1.0 behavior as fallback
The regex now handles mouse event sequences where the ESC [ prefix was
stripped (e.g., '35;107;1M' instead of '[<35;107;1M'). This can happen
in certain terminal configurations.

Changes:
- Make leading [ optional in the regex
- Allow 1+ digit button codes (was requiring 2+)
- Add test cases for sequences without leading [
- Update comments to clarify the pattern
fix: improve terminal control handling and sanitize TUI output
- TERMINAL_IO_ANALYSIS.md: Detailed analysis of all terminal input/output scenarios
  - Input: normal chars, control chars, special keys, mouse input
  - Output: normal text, escape sequences, mouse event residues
  - Filtering logic with heuristics to avoid false positives
  - Architecture flow and implementation details

- TERMINAL_TEST_CASES.md: Exhaustive test case catalog
  - 74 test cases across 9 categories
  - Mouse events (22 cases)
  - Cursor reports (4 cases)
  - False positives (14 cases)
  - Legitimate escape sequences (15 cases)
  - Secret redaction, environment vars, input handling

Covers all edge cases including:
- SGR mouse events with/without brackets
- Single-digit button codes (0-9)
- Cursor position reports
- Array notation preservation
- Small terminal edge cases
docs: add comprehensive terminal I/O analysis and test cases
- Add DISCONNECTING state to match documented state machine (§5.1)
- Add ttyStateCheckInterval to track polling timer
- Clear polling timer in disconnectTTY() to prevent leaks
- Add max retries (10) with timeout protection for state transitions
- Force transition to IDLE after max retries as recovery mechanism
- Remove redundant local variable isReady, use ttyState uniformly
- Document terminal protocol timing in ARCHITECTURE.md §5

This ensures robust state management during instance switching
and prevents race conditions when connectTTY() is called rapidly.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
…iltering

Problem: When switching terminal windows or after TUI programs exit,
xterm.js sends terminal query responses that appear as garbage text
in the shell (e.g., ;1R, rgb:0b0b/1010/2020, ?2027;0$y).

Root cause: xterm.js generates responses to terminal queries and
forwards them via term.onData() callback, which then get sent back
to PTY and displayed.

Changes:
- Add ttyState state machine (IDLE→CONNECTING→HANDSHAKING→READY)
- Prevent terminal focus until WebSocket is READY
- Add isTerminalQueryResponse() filter in term.onData()
- Fix ttyState reset on instance stop
- Prevent WebSocket reconnection for stopped instances

Documentation:
- Add §5.9 Terminal Query Response Filtering to ARCHITECTURE.md
- Add detailed code comments linking to TERMINAL_FILTER_REVIEW.md
- TERMINAL_FILTER_REVIEW.md documents known limitations and risks

Known limitations (see docs/TERMINAL_FILTER_REVIEW.md):
- Cannot distinguish user-intentional ESC sequences from auto responses
- Regex may have edge cases or false positives
- Some response types not explicitly covered
fix: prevent terminal query response leakage
… merge

After merging develop branch, two critical issues appeared:
1. TUI programs (opencode, etc.) displayed incorrectly
2. Anomalous strings appeared when switching instances

Root causes:
- Backend control sequence filtering broke TUI programs
- Frontend input filter was disabled, allowing query responses to PTY
- Query responses in logs were not filtered

Solution:
- Disable backend filtering (redact.go) to preserve TUI sequences
- Re-enable frontend input filter (term.onData) to catch xterm.js responses
- Add frontend log filter (loadLog/loadLogSince/WebSocket) for historical data
- Keep state machine (ttyState) to prevent early focus

Key findings:
- xterm.js DOES send query responses through term.onData() (contrary to earlier assumption)
- Backend filtering removes legitimate TUI control sequences
- Query responses come from multiple sources: input, logs, real-time data

Updated documentation:
- TERMINAL_FILTER_REVIEW.md: Complete rewrite with correct understanding
- TERMINAL_IO_ANALYSIS.md: Updated architecture and data flow
- TERMINAL_TEST_CASES.md: Simplified test case listing

Tested: TUI programs display correctly, no anomalous strings on instance switch
Backend control sequence filtering was disabled to preserve TUI program
output. Control sequences are now filtered in the frontend (index.html)
only for stopped instances.

Updated TestControlSequenceRemnants to expect no filtering on the
backend path (input == output). Renamed test cases to clarify they
test the NOT FILTERED state with '(backend disabled)' suffix.
Merge develop into fix/refresh-prob-1 and fix terminal issues
linletian and others added 7 commits March 13, 2026 23:01
- Add sanitizeTerminalOutput() to centralize response filtering
- Add decodeTTYOutputChunk() with persistent TextDecoder for stream-safe UTF-8 decoding
- Route SSE fallback through same sanitization as WebSocket path
- Reset decoder state on disconnect to prevent state leakage

Fixes two defects in PR #18:
1. UTF-8 multibyte characters could be corrupted when split across WebSocket frames
2. SSE fallback bypassed response filtering, allowing garbage strings to leak

No behavioral changes to terminal protocol or filtering rules.

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
fix(ui): refactor terminal output handling for UTF-8 and SSE consistency
PR13 added scrollback: 10000 to xterm.js Terminal configuration and
documented it in ARCHITECTURE.md. This documentation line was
accidentally removed when the Terminal Protocol Timing Specification
was added in later commits.

This restores the client-side config documentation while preserving
all TUI and anomalous string fixes from the current branch.
When a TUI program (like opencode) enables mouse tracking mode and the user
switches to another instance, xterm.js continues generating mouse event
sequences. These were being sent to the new instance's PTY and displayed
as garbage text like "35;29;1M35;29;2M...".

Root cause: Terminal modes (including mouse tracking) leak between instances
because the same xterm.js terminal is reused across instance switches.

Fix: Explicitly disable common mouse tracking modes when switching instances:
- ?1000l: Disable mouse button press/release
- ?1002l: Disable mouse drag tracking
- ?1003l: Disable mouse all motion tracking
- ?1006l: Disable SGR extended mouse mode

This ensures each instance starts with a clean terminal state, preventing
mode leakage from previous TUI programs.
Architecture updates (ARCHITECTURE.md §5.3):
- Document mouse tracking mode reset in instance switch protocol
- Add Step 1.3 for terminal mode reset before buffer clearing
- Document that TUI programs re-initialize on SIGWINCH

Test case updates (TERMINAL_TEST_CASES.md):
- Add §7 ESC Key Handling test cases (6 cases)
- Add §8 Instance Switch Terminal Reset test cases (5 cases)
- Add §9 UTF-8 Multi-byte Handling test cases (4 cases)
- Update test statistics from 27 to 42 cases
- Expand manual testing section with instance switch scenarios

Related: Fixes mouse event leakage when switching from TUI to shell instance
fix: refresh probability improvements and instance switch fixes
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@linletian linletian merged commit 235b266 into main Mar 14, 2026
2 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.

1 participant