Skip to content

fix(container-runtime): Give container extensions access to true connected state #24826

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

WillieHabi
Copy link
Contributor

Description

This change adds a public getter to ContainerRuntime connectedToService which returns whether or not the client is connected to the service (from ContainerContext). This getter is then passed to the container ExtensionHost runtime so container extensions have access to true connected state.

This is in contrast to the get connected() getter which returns whether or not the client has the ability to send ops (i.e. connected to service and not readonly mode).

@Copilot Copilot AI review requested due to automatic review settings June 11, 2025 19:11
@github-actions github-actions bot added area: runtime Runtime related issues base: main PRs targeted against main branch labels Jun 11, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Adds a new public API to expose the service connection status separately from the existing connected getter. Container extensions will now receive the true connected state via the extension host runtime.

  • Introduce private _getConnected function and public connectedToService getter
  • Initialize _getConnected from context.connected in the constructor
  • Update extension host’s isConnected callback to use connectedToService
Comments suppressed due to low confidence (2)

packages/runtime/container-runtime/src/containerRuntime.ts:1196

  • The doc comment could clarify how connectedToService differs from the existing connected getter (which also accounts for readonly mode). Consider adding a remark to explain the distinction.
public get connectedToService(): boolean {

packages/runtime/container-runtime/src/containerRuntime.ts:1196

  • This new public getter should have accompanying unit tests to verify it correctly reflects context.connected and that the extension host’s isConnected callback behaves as expected.
public get connectedToService(): boolean {

Copy link
Member

@markfields markfields left a comment

Choose a reason for hiding this comment

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

Change makes sense, I left some suggestions, ping me when ready for final approval.

Copy link
Contributor

@jason-ha jason-ha left a comment

Choose a reason for hiding this comment

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

I think that there is an event that corresponds. If we just change extension isConnected, then those will be uncoordinated. Let's get a coordinated event too.

Comment on lines 1194 to 1195
* This reflects only the raw connection status. In contrast, connected() also checks
* that the client is not in read-only mode and is therefore able to send ops.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it checks more than read-only mode. Something somewhere also checks if incoming op stream has been processed.
We should call out that there is a difference. Perhaps, though, just link or see also to connected and let it speak for itself. (In a public API we'd put these additional comments under @remarks but I don't know what difference it makes for internal docs.)

Copy link
Contributor Author

@WillieHabi WillieHabi Jun 12, 2025

Choose a reason for hiding this comment

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

I think it checks more than read-only mode. Something somewhere also checks if incoming op stream has been processed.

Hmm I haven't seen this before -- looking at the connected() it just returns canSendOps() which is essentially just the lie that container tells containerRuntime in setConnectionState (connected && !readonly). I can just link connected for now and say there's a difference.

cc: @markfields @kian-thompson, do you guys know about additional checks for connected()?

@WillieHabi WillieHabi requested a review from jason-ha June 16, 2025 14:25
Comment on lines 2771 to 2776
// Raise connected event if we are connected to the service
if (this.isConnected()) {
this.emit("isConnected", clientId);
} else {
this.emit("isDisconnected");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't seem like the correct timing for these events. There is not a strong association between this.isConnected() changing state and being here. Maybe it is correct, but, if so, it requires lots of comments.

I think we like to name events as actions. Perhaps serviceConnected or connectedToService style naming?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also - should add tests for the changes to be even more confident we are getting this right

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added some comments, tests for the new eventing, and the name change

@github-actions github-actions bot added the area: tests Tests to add, test infrastructure improvements, etc label Jun 17, 2025
@github-actions github-actions bot removed the area: tests Tests to add, test infrastructure improvements, etc label Jun 17, 2025
@github-actions github-actions bot added the area: tests Tests to add, test infrastructure improvements, etc label Jun 17, 2025
@WillieHabi WillieHabi requested a review from jason-ha June 17, 2025 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: runtime Runtime related issues area: tests Tests to add, test infrastructure improvements, etc base: main PRs targeted against main branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants