Support session#11
Open
kerthcet wants to merge 4 commits into
Open
Conversation
Signed-off-by: kerthcet <kerthcet@gmail.com>
Signed-off-by: kerthcet <kerthcet@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR implements first-class interactive PTY sessions end-to-end (daemon ⇄ server ⇄ Python), renaming the previous “shell” concept to “session” across the protocol, Rust code, Python bindings, tests, and docs.
Changes:
- Replaced
Shell*protocol/messages and APIs withSession*equivalents, including a newSessionClosemessage. - Implemented PTY-backed session management in the daemon and exposed a Python
Sessionhandle withwrite/read/resize/close(+ optional interactive terminal mode). - Updated examples, docs, and tests to use
server.exec()andserver.new_session().
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
| server/src/server.rs | Forwards SessionOutput/SessionExit from daemon to Python-side session streams. |
| server/src/registry.rs | Renames shell session routing map to sessions and updates routing methods. |
| server/src/protocol.rs | Renames shell message variants to session variants and adds SessionClose. Updates protocol tests accordingly. |
| server/src/lib.rs | Renames Python binding execute_command→exec, start_shell→new_session; introduces Session pyclass and adds close(). |
| sandd/src/session.rs | Adds daemon-side PTY session implementation (start/read/write/resize/close). |
| sandd/src/protocol.rs | Mirrors protocol rename from shell messages to session messages. |
| sandd/src/main.rs | Wires SessionManager into daemon message handling for start/input/resize/close. |
| README.md | Updates project messaging and example code to exec() and “Interactive Sessions”. |
| python/tests/test_unit.py | Updates unit tests to use exec() and new_session(). |
| python/tests/test_integration.py | Updates integration tests to exec(); comments out file-transfer tests. |
| python/tests/test_e2e.py | Updates to exec() and adds E2E coverage for interactive sessions. |
| python/sandd/init.py | Updates Python wrapper API (exec, new_session) and adds interactive terminal loop. |
| pyproject.toml | Updates package description string. |
| Makefile | Renames docker helper target (docker-up) and removes test-all. |
| examples/interactive_session.py | New interactive session example script. |
| examples/install_htop.py | Updates to exec() and adjusts guidance for interactive usage. |
| examples/exec_commands.py | Updates to exec() and refreshes script description. |
| examples/agent_example.py | Removes legacy example script. |
| docs/QUICKSTART.md | Updates docs snippets from execute_command() to exec() and shell→session. |
| docs/PROTOCOL.md | Updates protocol documentation to session terminology and adds SessionClose. |
| docs/DEVELOP.md | Updates developer docs to reference session implementation and new API names. |
| docs/ARCHITECTURE.md | Updates terminology from shell output to session output. |
| .github/workflows/rust-ci.yaml | Removes E2E tests from CI, leaving make test only. |
Comments suppressed due to low confidence (4)
sandd/src/session.rs:7
reader.read(&mut buffer)relies on thestd::io::Readtrait, but onlyWriteis imported. This will fail to compile unless the reader type provides an inherentread()(portable-pty readers typically implementRead).
sandd/src/session.rs:199close_session()removes the handle but never stops the spawned reader task. Dropping theJoinHandledoes not cancel it, so the task can continue reading/sending after a session is “closed”. Abort the task when closing the session.
sandd/src/session.rs:100- The PTY reader loop performs a blocking
std::io::Read::read()insidetokio::spawn. This can block a Tokio worker thread per active session (andsend_input()/resize()also perform blockingWrite/resizecalls under async locks), which can degrade throughput or stall other async tasks under load. Consider moving PTY I/O tospawn_blocking/dedicated threads and forwarding data over async channels.
python/sandd/init.py:160 - Renaming
execute_command()→exec()(andstart_shell()→new_session()) is a breaking change for existing Python consumers. If backward compatibility matters, consider keeping the old method names as thin wrappers (deprecated) for at least one release, or bumping the major version and calling this out in release notes/docs.
def exec(
self,
daemon_id: str,
command: str,
timeout: int = 300,
env: Optional[Dict[str, str]] = None,
cwd: Optional[str] = None,
) -> CommandResult:
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+133
to
+141
| let msg = Message::StartSession { | ||
| session_id: session_id.clone(), | ||
| rows, | ||
| cols, | ||
| term, | ||
| }; | ||
|
|
||
| conn.send_message(msg) | ||
| .map_err(|e| PyRuntimeError::new_err(format!("Failed to start shell: {}", e)))?; | ||
| .map_err(|e| PyRuntimeError::new_err(format!("Failed to start session: {}", e)))?; |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
5 tasks
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.
What this PR does / why we need it
Which issue(s) this PR fixes
Fixes #
Special notes for your reviewer
Does this PR introduce a user-facing change?