feat: add MCP session reset endpoint with terminal improvements#280
Merged
2mawi2 merged 6 commits into2mawi2:mainfrom Jan 31, 2026
Merged
feat: add MCP session reset endpoint with terminal improvements#2802mawi2 merged 6 commits into2mawi2:mainfrom
2mawi2 merged 6 commits into2mawi2:mainfrom
Conversation
added 5 commits
January 28, 2026 16:56
Expose POST /api/sessions/{name}/reset to force-restart the session
agent from external tooling. Allow optional agent type/skip flags and
propagate a prompt override so the session's initial prompt stays in
sync.
Persist session agent settings during reset and launch orchestrator with prompt in the command to avoid TUI glitches. Drop mouse tracking input for agent terminals so control sequences don't pollute output.
Emit sessions refresh after MCP resets so agent labels update. Block TUI mouse tracking enable in xterm for agent terminals to avoid garbage sequences while keeping normal mouse interactions.
Add setMouseTrackingAllowed mock method needed after Terminal.tsx now gates mouse tracking for agent terminals. Fix wheel scroll test by setting baseY > 0 so the scrollLines path is taken (with baseY=0, PageUp/PageDown sequences are sent instead).
Contributor
Author
|
@2mawi2 can you please review this PR? thanks. |
marius-kilocode
approved these changes
Jan 31, 2026
2mawi2
approved these changes
Jan 31, 2026
| const multiplier = event.deltaMode === 1 ? 1 : 3; | ||
| const lines = Math.sign(delta) * Math.max(1, Math.ceil(Math.abs(delta) / 100) * multiplier); | ||
| terminal.current.scrollLines(lines); | ||
| logScrollChange('wheel'); |
| } | ||
| instance.setUiMode(isTuiAgent(agentTypeRef.current) ? 'tui' : 'standard'); | ||
| instance.setMouseTrackingAllowed(!isAgentTopTerminal); | ||
| shouldCaptureWheelRef.current = agentTypeRef.current === 'opencode' && isAgentTopTerminal; |
Owner
There was a problem hiding this comment.
Is this really only opencode specific?
Owner
|
@shawnsw tested this. Looks good, thanks! |
3 tasks
Owner
Owner
|
To reproduce: Start opencode or any cli with alternate scrolling, then scroll up -> observe no scrolling but last commands changing as if you press arrow up or down. |
Contributor
Author
|
Hmm that's weird. I had the exact issue you described while working on the PR, I thought I had it fixed as the issue was resolved locally. FYI I was using opencode and shell is Zsh. |
shawnsw
pushed a commit
to shawnsw/schaltwerk
that referenced
this pull request
Feb 3, 2026
Re-adds the session reset functionality from PR 2mawi2#280 without the terminal mouse tracking changes that caused wheel scroll issues. Endpoints: - POST /api/reset - Reset orchestrator or session with selection - POST /api/sessions/{name}/reset - Reset specific session Supports: - Agent type switching - Prompt override for fresh starts - Skip prompt/permissions flags
6 tasks
shawnsw
pushed a commit
to shawnsw/schaltwerk
that referenced
this pull request
Feb 3, 2026
Re-adds the session reset functionality from PR 2mawi2#280 without the terminal mouse tracking changes that caused wheel scroll issues. Endpoints: - POST /api/reset - Reset orchestrator or session with selection - POST /api/sessions/{name}/reset - Reset specific session Supports: - Agent type switching - Prompt override for fresh starts - Skip prompt/permissions flags
2mawi2
added a commit
that referenced
this pull request
Feb 5, 2026
* feat: add MCP session reset endpoint (isolated from terminal changes) Re-adds the session reset functionality from PR #280 without the terminal mouse tracking changes that caused wheel scroll issues. Endpoints: - POST /api/reset - Reset orchestrator or session with selection - POST /api/sessions/{name}/reset - Reset specific session Supports: - Agent type switching - Prompt override for fresh starts - Skip prompt/permissions flags * fix(ci): remove target-cpu=native from Linux targets The native flag causes SIGILL on CI runners with different CPU features. Replace with strip=debuginfo which is CI-safe. * fix: downgrade tauri to 2.9.5 to match NPM packages (2.9.1) * ci: add Tauri version sync checks to prevent NPM/Rust mismatch Dependabot bumped Rust tauri to 2.10.1, but NPM packages are still at 2.9.x, causing build failures. This adds two safeguards: 1. CI check that fails if Rust tauri and NPM @tauri-apps/api major.minor versions don't match 2. Dependabot ignore rules to prevent bumping tauri beyond 2.9.x until NPM packages catch up This prevents the version mismatch from happening again. * fix: filter -i flag for agent terminals to prevent job control conflicts Agent terminals (top terminals running Claude, Codex, OpenCode, etc.) call setRawMode() on the TTY, which conflicts with bash's job control enabled by the -i (interactive) flag. This resulted in errno 5 (EIO) errors. Changes: - Pass terminal_id to resolve_app_program_and_args() - Add filter_interactive_flag() to remove -i from shell args - Agent terminals: Remove -i flag even if user has it in settings - Non-agent terminals: Keep -i flag for interactive behavior This allows agents to work without requiring users to manually remove -i from their shell settings. Also improved CI version check to use cargo tree instead of grep/awk. * fix: source .zshrc/.bashrc for agents with 'set +m' to disable job control Previous approach removed -i flag to prevent job control conflicts, but this prevented .zshrc/.bashrc from being sourced, losing env vars like NVM, PYENV. New approach: - Keep -i flag so .zshrc/.bashrc are sourced (provides full environment) - Add 'set +m;' before agent command to explicitly disable job control - This prevents conflicts with setRawMode() while keeping full env Command now looks like: /bin/zsh -i -l -c 'set +m; exec claude <args>' This gives agents: - .zprofile env (from -l login flag) - .zshrc env (from -i interactive flag) - No job control conflicts (from 'set +m') * fix: bump @tauri-apps/api to 2.10.x to match Rust tauri crate --------- Co-authored-by: Shawn <[email protected]> Co-authored-by: 2mawi2 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds an MCP API endpoint for resetting sessions and includes several terminal improvements:
New Feature
POST /api/sessions/{name}/resetendpoint to restart session agents from external tooling with optional agent type and prompt overridesTerminal Improvements
Fixes
Test plan
curl -X POST http://localhost:PORT/api/sessions/NAME/reset