Repository navigation
feat(sess)!: stabilize attach identity and endpoint contract - #1764
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
|
Thanks for supporting the downstream applications. This might be another bug for native R terminals. When VS Code is reloaded, R process survives, but Here is a small demo. R.restore.mp4 |
|
@Fred-Wu I believe I've fixed the bug you pointed out, so could you please check it again? |
|
Connections are now correctly restored automatically after VS Code reload. But Remove or fix in the next release? |
Thanks for pointing that out! |
…1837) Fixes #1836. #1764 introduced the public session API with pseudoterminal downstream clients in mind. #1805 made Workspace actions execute in their owning session, but terminal dispatch only resolves native PID associations, leaving extension-owned pseudoterminals without an execution target. Add backward-compatible `session.activate(sessionId, { terminal })` to explicitly bind a terminal. Interactive execution retains priority; terminal execution uses the session's current explicit or native association. Unassociated background sessions still reject terminal execution. Execution, readiness and terminal selection share a registry with at most one terminal per session and one session per terminal. Explicit binding replaces either endpoint's previous association, so a superseded native terminal cannot return as a fallback when the explicit terminal closes. Live explicit bindings take priority over native attach. Close and connection replacement invalidate associations; queued sends validate the exact association, and delayed native discovery cannot overwrite intervening ownership changes or a newer connection. Reconnect refreshes the selected session's connection even after same-session reselection, while preserving a newer selection of a different session; old Workspace nodes still reject execution. **Downstream follow-up:** vscode-R-console needs to pass its VS Code Terminal when activating a sess session, and repeat registration after reconnecting. Older vscode-R implementations ignore the extra argument, so downstream can retain compatibility with their existing activation API. No vscode-R-console sources or sess wire protocol are changed here.
Summary
On master, sess identity and discovery depend on local PIDs and
~/.vscode-R/sessions/<PID>.json. Reloading VS Code leaves surviving R processes disconnected, and restoring one terminal can prevent manual recovery of another. This PR establishes the session contract before the first stable 3.x release (#1763).session_id. Use socket ownership for cleanup so a late close cannot remove a replacement connection; defer workspace and plot notifications until task callbacks return, with generation guards across disconnects.sess::connect(endpoint = ...),SESS_ENDPOINT, andSESS_DISCOVERY_FILE. Store managed discovery files and attach scripts in extension storage, without making its directory layout part of the contract.versionandendpoint, ignores unknown fields, and permits optional backend fields such asjgdSocketwithout a version bump.Breaking pre-release changes: replace
pipe_path,SESS_PIPE, thepipediscovery field, and the PID-based home-directory fallback. Transport remains local Unix-domain sockets / Windows named pipes.