Skip to content
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

Use asExternalUri For Server Url #196

Conversation

williamsyang-work
Copy link
Contributor

@williamsyang-work williamsyang-work commented Jan 30, 2024

Refactors TspClientProvider to use VSCode.asExternalUri method to generate a dynamic
uri. This will automatically detect if we are using remote-ssh, initialize port forwarding
to the server's port, and change the provided url to a web-worker that is managing
port-forwarding to the VSCode backend.

Removes the TraceServerUrlManager class. The functionality to generate new TspClients
when the Uri is changed is moved into this repo's TspClientProvider implementation.

Removes the tspClient.ts file. This functionality did not work with the async nature of
asExternalUri, and was not designed to handle Uri changes. Most functionality was already
implemented in TspClientProviderImpl.ts.

Creates VSCodeBackendTspClientProvider class. This is a child class of TspClientProviderImpl
with expanded functionality that should only be used on the extension's backend.

Signed-off-by: Will Yang [email protected]

@williamsyang-work
Copy link
Contributor Author

I'm re-submitting this PR. I attempted to make this change before, but multiple bugs were brought up for the remote use-case.
You can view the old PR here: PR #173.

I would like for this change to be merged in, and to address the concerns in PR #173 as separate feature additions / merge requests. The changes that I tried to implement before were way out of scope of the base change.

Comment on lines 135 to 146
case VSCODE_MESSAGES.EXPERIMENT_SELECTED:
// Need to block scope the variable 'experiment'...
if (true) {
let experiment: Experiment | undefined;
if (message.data && message.data.wrapper) {
experiment = convertSignalExperiment(JSONBig.parse(message.data.wrapper));
} else {
experiment = undefined;
}
signalManager().fireExperimentSelectedSignal(experiment);
}
signalManager().fireExperimentSelectedSignal(experiment);
}
return;
Copy link
Contributor Author

@williamsyang-work williamsyang-work Jan 30, 2024

Choose a reason for hiding this comment

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

The variable name experiment is also used above in line 107 of this code.

I was getting an error for "'experiment' has already been declared". So, I block-scoped the code to appease the typescript compiler. Otherwise, it would not build.

No logic changed here.

Copy link
Contributor

@hriday-panchasara hriday-panchasara Feb 2, 2024

Choose a reason for hiding this comment

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

No need of an if(true) statement, just wrap both switch cases with braces so that any variable declared within that block is only visible within the block.

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 just removed this code from the PR.

@williamsyang-work williamsyang-work force-pushed the as-external-uri-remote-fix branch from 7b3f2ec to 48f7b23 Compare January 31, 2024 20:34
@marcdumais-work
Copy link
Contributor

@williamsyang-work Please ignore the 3PP license check CI job failing ATM - it's nothing related to your PR and will not prevent merging. FYI, IP check tickets are opened for the baseline dependencies reported as errors (unapproved), and they should be approved soon, letting the job pass. But until then, no worries.

@hriday-panchasara hriday-panchasara self-requested a review February 1, 2024 23:53
@williamsyang-work williamsyang-work force-pushed the as-external-uri-remote-fix branch 2 times, most recently from c4bfc0c to c61d1d9 Compare February 5, 2024 19:14
@bhufmann
Copy link
Collaborator

bhufmann commented Feb 6, 2024

I'm re-submitting this PR. I attempted to make this change before, but multiple bugs were brought up for the remote use-case. You can view the old PR here: PR #173.

I would like for this change to be merged in, and to address the concerns in PR #173 as separate feature additions / merge requests. The changes that I tried to implement before were way out of scope of the base change.

The issue of pending back-end calls reported here #173 (review), that causes the application not to function until the port forwarding manually removed, is still an issue. Could you please describe what's the plan to address them?

Copy link
Collaborator

@bhufmann bhufmann left a comment

Choose a reason for hiding this comment

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

It looks like that this update breaks the local case. When testing it for a local use case I noticed some issues when opening a trace. The trace explorer on the left with the 3 webviews disappear, as well as the status bar indicates that the server is down (while the trace panel is opened in the middle).

vscode-open-externalUrl

const analysisProvider = new AnalysisProvider();
// TODO: For now, a different command opens traces from file explorer. Remove when we have a proper trace finder
const fileOpenHandler = fileHandler(analysisProvider);
context.subscriptions.push(
vscode.commands.registerCommand('traces.openTraceFile', async (file: vscode.Uri) => {
await startTraceServerIfAvailable(file.fsPath);
await updateUris();
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we should call it at every open. updateUris() will each webview (e.g. open traces) with the new url and the tspclient instance is refreshed. This will require a refressh of each webview which doesn't exist. I think the URLs should be only updated when changed.

@@ -162,6 +168,7 @@ export function activate(context: vscode.ExtensionContext): ExternalAPI {
return;
}
await startTraceServerIfAvailable(traceUri.fsPath);
await updateUris();
Copy link
Collaborator

Choose a reason for hiding this comment

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

same comment here. The URL should not be updated everytime a trace is opened. It should be only be done if necessary.

@williamsyang-work williamsyang-work force-pushed the as-external-uri-remote-fix branch from b3142da to cc4d9e5 Compare February 6, 2024 22:57
Copy link
Collaborator

@bhufmann bhufmann left a comment

Choose a reason for hiding this comment

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

Is this still a draft? There are compilation errors as well linting error. Ignore the license check, that error will go away once license check by Eclipse is finished.

@williamsyang-work williamsyang-work force-pushed the as-external-uri-remote-fix branch 2 times, most recently from 287bc2a to 4dd1784 Compare February 14, 2024 17:40
Refactors TspClientProvider to use VSCode.asExternalUri method to generate a dynamic
uri.  This will automatically detect if we are using remote-ssh, initialize port forwarding
to the server's port, and change the provided url to a web-worker that is managing
port-forwarding to the VSCode backend.

Removes the TraceServerUrlManager class.  The functionality to generate new TspClients
when the Uri is changed is moved into this repo's TspClientProvider implementation.

Removes the tspClient.ts file.  This functionality did not work with the async nature of
asExternalUri, and was not designed to handle Uri changes.  Most functionality was already
implemented in TspClientProviderImpl.ts.

Creates VSCodeBackendTspClientProvider class.  This is a child class of TspClientProviderImpl
with expanded functionality that should only be used on the extension's backend.

Signed-off-by: Will Yang <[email protected]>
@williamsyang-work williamsyang-work force-pushed the as-external-uri-remote-fix branch from 4dd1784 to dc685dc Compare February 14, 2024 17:42
@williamsyang-work
Copy link
Contributor Author

Is this still a draft? There are compilation errors as well linting error. Ignore the license check, that error will go away once license check by Eclipse is finished.

I just fixed the linting errors, build errors, and rebased with the current master. It's now ready to continue the review process!

@williamsyang-work
Copy link
Contributor Author

It looks like that this update breaks the local case. When testing it for a local use case I noticed some issues when opening a trace. The trace explorer on the left with the 3 webviews disappear, as well as the status bar indicates that the server is down (while the trace panel is opened in the middle).

vscode-open-externalUrl vscode-open-externalUrl

I'm not getting this behavior when I am running the local version. But it seems Neel is also running into this error with the current code: #204 (comment).

@bhufmann
Copy link
Collaborator

bhufmann commented Feb 20, 2024

It looks like that this update breaks the local case. When testing it for a local use case I noticed some issues when opening a trace. The trace explorer on the left with the 3 webviews disappear, as well as the status bar indicates that the server is down (while the trace panel is opened in the middle).

I'm not getting this behavior when I am running the local version. But it seems Neel is also running into this error with the current code: #204 (comment).

When using the latest update, I didn't get the issue for the local case anymore. So, I focused on the remote case, which there seems to be differences when running in vscodium vs vscode. I need investigate more to be able to pinpoint what's going on.

I'm trying the local case as well again.

@ngondalia
Copy link
Contributor

url-change-fix-not-working.mp4

@ngondalia
Copy link
Contributor

url-change-fix-not-working.mp4

Hope this helps in being able to reproduce it!

@williamsyang-work williamsyang-work marked this pull request as draft February 27, 2024 22:47
@williamsyang-work
Copy link
Contributor Author

Closing this PR.

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.

5 participants