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

Invoking traces.openTraceFile to open a trace programmatically doesn't effectively refresh the list of open traces #265

Closed
GregSavin opened this issue Aug 21, 2024 · 3 comments

Comments

@GregSavin
Copy link
Contributor

GregSavin commented Aug 21, 2024

Steps to replicate issue:

  1. Create/install a vscode extension that implements a command that, when invoked from Command Palette, will, in turn, call traces.openTraceFile (passing in a URI argument that refers to a valid existent trace folder).
  2. Ensure that no traces are currently open.
  3. Invoke the command (from step 1) via Command Palette.
  4. Observe that an editor pane appears, with the loaded trace's Overview graph.
  5. Observe that "There are currently no opened traces" is still shown in the Trace Viewer pane.
  6. Exit and re-start vscode; now observe that the trace that was loaded in the previous vscode lifetime is reflected in the Opened Traces list.
@GregSavin
Copy link
Contributor Author

This patch seems to at least work around the issue; not sure if it is a true fix though:

diff --git a/vscode-trace-extension/src/extension.ts b/vscode-trace-extension/src/extension.ts
index afa7363..90182b3 100644
--- a/vscode-trace-extension/src/extension.ts
+++ b/vscode-trace-extension/src/extension.ts
@@ -67,7 +67,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<Extern
         vscode.commands.registerCommand('traces.openTraceFile', async (file: vscode.Uri) => {
             await startTraceServerIfAvailable(file.fsPath);
             if (await isTraceServerUp()) {
-                fileOpenHandler(context, file);
+                await fileOpenHandler(context, file);
                 vscode.commands.executeCommand('trace-explorer.refreshContext');
             }
         })
diff --git a/vscode-trace-extension/src/trace-explorer/trace-utils.ts b/vscode-trace-extension/src/trace-explorer/trace-utils.ts
index e896564..f398a20 100644
--- a/vscode-trace-extension/src/trace-explorer/trace-utils.ts
+++ b/vscode-trace-extension/src/trace-explorer/trace-utils.ts
@@ -55,7 +55,7 @@ export const fileHandler =
     async (context: vscode.ExtensionContext, traceUri: vscode.Uri): Promise<void> => {
         const resolvedTraceURI: vscode.Uri = traceUri;
         const { traceManager, experimentManager } = getManagers();
-        vscode.window.withProgress(
+        return vscode.window.withProgress(
             {
                 location: vscode.ProgressLocation.Notification,
                 title: getProgressBarTitle(resolvedTraceURI),

@bhufmann
Copy link
Collaborator

Thanks for reporting this and making a suggestion for a fix.

This can be also reproduced without a separate vscode extension and command. Just have no traces on the server and open one from the file explorer with right mouse click and select Open with Trace Viewer. Then the trace viewer widget is opened, but the Opened Traces view is not refreshed. Your code suggestion makes sense and I think it was originally indented like that.

Would you be able to provide a PR to fix it? Please let me know.

@GregSavin
Copy link
Contributor Author

Thanks, helpful info. I'll see about submitting a PR.

GregSavin added a commit to GregSavin/vscode-trace-extension that referenced this issue Aug 26, 2024
GregSavin added a commit to GregSavin/vscode-trace-extension that referenced this issue Aug 26, 2024
Wait for fileOpenHandler to finish, before refreshing the trace explorer
context.

Signed-off-by: Greg Savin <[email protected]>
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

No branches or pull requests

2 participants