I'm trying to use the vsls module from npm to add VSLS support to my extension. However, if my extension is activated when the VSLS session is already running, the session field of the vsls.LiveShare object is always set to
{"peerNumber":0,"user":null,"role":0,"access":0,"id":null}
I have tried this with VS Code 1.25.1 and the vsls package 0.3.426 on both Ubuntu 18.04 and Windows 10 with the same results.
@hbenl Thanks for reporting this! Just to confirm: if you start the Live Share session after your extension if activated, then can you access the session just fine? If you listen to the onDidChangeSession event, that would provide you the most reliable way of getting session information:
liveShare.onDidChangeSession((e) => {
// e.session will contain the session info
});
That said, we should confirm that the root-level session property is always up-to-date.
// CC @jasongin
if you start the Live Share session after your extension if activated, then can you access the session just fine?
Yes.
If you listen to the onDidChangeSession event, that would provide you the most reliable way of getting session information
Yes, the onDidChangeSession event gives me reliable information and after receiving the event, the root-level session property will also give me the same (correct) session info.
However, guest sessions are usually started using the link provided by the host session. That means that on the guest side, a new VS Code window will be opened and immediately attach to the session - in this case it seems impossible to ensure that my extension is activated before the guest session is started.
That does sound like a bug. I'll investigate and let you know what I find.
Are you working on your Test Explorer extension? I would love to see that working over Live Share!
OK, I understand the problem here. There was an assumption that getApiAsync() would be called by an extension that activates when VS Code starts up, so it would be before any Live Share session is joined. But that's not correct since many extensions (including the Test Explorer) do not activate until the user interacts with them.
I'll get this fixed soon. (Though I'm not sure whether it will make it into the next release planned for Monday.) Meanwhile, for development you can workaround the issue by adding "*" to your extension's activationEvents.
@hbenl FYI, this bug was also resolved in the private build I sent you. So you shouldn’t need to set the “*” activation event. Let us know if that works. If so, we’ll release this fix this week, along with the request issue you filed. Thanks!
Let us know if that works.
Well, if I activate my extension after joining the VSLS session, the session field of the vsls.LiveShare object is now set correctly. However, if I then get a service using the getSharedService() method, that service is not available (according to its isServiceAvailable field).
If I activate the extension before joining the VSLS session, it all still works (i.e. I get a session through the onDidChangeSesion event and when I use the getSharedService() method, it returns a service that is available).
I'm now working on a fix for that last problem you described above.
That should be fixed in the next update, planned for Monday.
@hbenl This has been resolved in the latest version of Live Share. If you could update your extension, and let us know if that works, that would be awesome. Thanks!
Yes, it's working now. Thanks.
@hbenl Awesome! Thanks for confirming. Have you run into any other issues with the extensibility API? I'd love to hear if things are working OK with implementing support for Test Explorer 👍
I didn't have time to work on it for the last week, but will resume working on it soon. So far, I haven't run into any more issues.