Skip to content

feat: delegate manual attachment to external terminals - #1871

Open
eitsupi wants to merge 4 commits into
REditorSupport:mainfrom
eitsupi:feat/external-terminal-attachment
Open

eitsupi wants to merge 4 commits into
REditorSupport:mainfrom
eitsupi:feat/external-terminal-attachment

Conversation

@eitsupi

@eitsupi eitsupi commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

#1868 and #1870 provide managed sess preparation, connection references, and explicit terminal binding, but manual attachment still has a gap. When an external terminal has no live session binding, the status-bar attach action can send the native command to vscode-R's global endpoint. In vscode-R-console, that bypasses SessProxy and replaces the proxy-backed transport. PID discovery can also wait indefinitely on an extension-owned pseudoterminal before its frontend gets a chance to recover.

This adds session.registerTerminalIntegration(terminal, { attach(token) }) so the frontend can restore its own transport and bind the accepted connection using the existing APIs:

  • While a registered handler is pending, repeated attach requests remain busy even if a live binding already exists. Otherwise a live terminal owner is focused first, or the registered handler runs before PID discovery. Registered terminals are excluded from native PID association and use explicit binding.
  • Registration survives disconnects and connection replacement. Disposal, terminal close, and watcher shutdown revoke it and request cancellation; moving focus away also cancels a pending attempt.
  • Concurrent attach requests do not submit duplicate work. Success requires a current live terminal binding, and delayed completion preserves a newer choice of another session. A decline, exception, or cancellation never falls back to the native command.

Consumers can prepare through their proxy, observe the matching connection, and call activate(sessionId, { terminal, connectionId, select: false }) before returning true. vscode-R then verifies the binding and selects/focuses the terminal. Consumers retain responsibility for prompt readiness, submission queues, failure explanations, and R code already submitted when cancellation occurs.

This completes the third part of the external session API for the intended 3.2.0 release alongside #1868 and #1870, so consumers can adopt managed sess with a supported manual recovery path. This change is on the TypeScript side and does not change the bundled sess revision or introduce another reinstall/restart transition. External frontends must adopt the hook; pasting a copied native attach command remains outside this API and can still bypass a proxy.

@eitsupi eitsupi added this to the 3.2.0 milestone Oct 12, 2026
@eitsupi
eitsupi requested review from Fred-Wu and renkun-ken October 12, 2026 03:25
@eitsupi
eitsupi marked this pull request as draft October 12, 2026 03:25
@eitsupi
eitsupi marked this pull request as ready for review October 12, 2026 03:56
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