Skip to content

feat(conversations): expose disconnect method for clean process exit#340

Open
dsuresh-ap wants to merge 1 commit intomainfrom
feat/conversations-disconnect
Open

feat(conversations): expose disconnect method for clean process exit#340
dsuresh-ap wants to merge 1 commit intomainfrom
feat/conversations-disconnect

Conversation

@dsuresh-ap
Copy link
Copy Markdown
Member

Summary

  • Exposes disconnect() on ConversationService, delegating to the existing SessionManager.disconnect() method
  • Without this, CLI consumers using startSession/endSession have no way to close the underlying WebSocket, causing the process to hang indefinitely due to socket.io reconnection timers keeping the event loop alive
  • Bumps version from 1.2.1 → 1.3.0 (new public API surface)

Test plan

  • Verified cas chat single-message mode exits cleanly (exit code 0) against the built binary
  • Verified interactive mode /quit exits cleanly (exit code 0)
  • Verified SIGINT exits cleanly (exit code 130)
  • All 64 cas-tool unit tests pass

🤖 Generated with Claude Code

The SessionManager already has a disconnect() method but it was not
exposed through the public ConversationService API. CLI consumers that
use startSession/endSession had no way to close the underlying WebSocket,
causing the process to hang indefinitely due to socket.io reconnection
timers keeping the event loop alive.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@dsuresh-ap dsuresh-ap requested a review from a team April 1, 2026 19:58
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 1, 2026

@dsuresh-ap dsuresh-ap requested review from maxduu and vnaren23 April 1, 2026 19:59
Copy link
Copy Markdown

@maxduu maxduu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me but I'll let @vnaren23 's team give final approval

* conversationalAgent.conversations.disconnect();
* ```
*/
disconnect(): void {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Please add this method in the ConversationServiceModel as well.
  2. Add a test case here -

Comment thread package.json
{
"name": "@uipath/uipath-typescript",
"version": "1.2.1",
"version": "1.3.0",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not bump up the version with this change. We might have a few other changes we want to ship with the next version. We'll raise a separate PR for the version change.

* Disconnects the WebSocket and releases all session resources.
*
* Immediately closes the WebSocket connection and clears all per-conversation
* socket tracking. Call this after ending all sessions to allow the process to exit.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Call this after ending all sessions" implies endSession() is a required prerequisite. It isn't,disconnect closes all sockets directly without needing prior endSession calls.
better add: "Call this to shut down the WebSocket connection entirely."

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have the same description in models as well when you add, because in public docs, comments from models get picked up.

* Disconnects the WebSocket and releases all session resources.
*
* Immediately closes the WebSocket connection and clears all per-conversation
* socket tracking. Call this after ending all sessions to allow the process to exit.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also add a line somehting like this: "In Node.js, the WebSocket keeps the event loop alive until disconnected, call this to allow the process to exit cleanly." because In a browser, the runtime handles socket cleanup on page unload, so this is a no-op there.

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.

4 participants