eclipse-cdt-cloud / theia-trace-extension

Eclipse Theia trace viewer extension using the Trace Server Protocol (TSP), through the tsp-typescript-client. Also the home for reusable JavaScript libraries: traceviewer-base, traceviewer-react-components
MIT License
49 stars 60 forks source link

Handle opening of single trace files via dialog #1053

Closed ngondalia closed 6 months ago

ngondalia commented 7 months ago

For users that primarily need to analyze single file traces, the current implementation breaks the user flow. If the user wants to add another trace, they would have to switch to explorer view and open it from there. It would be ideal if they can open single traces files in the same manner as trace folders/groups.

There are few options that I can think of to solve this (open to any other suggestions):

1) Have some sort of setting that can control the behaviour of "open trace" button at the extension level - At its core, it would control if the dialog opened will allow selecting files vs folders. I dont prefer this option as it doesnt address the issue for users that may have the need to analyze both trace folders and files.

2) "Open Trace" button handler can invoke a quick pick before showing the dialog so that users can select if they want to open file vs folder. I also am not a fan of this as it just adds more buttons to click to open a trace.

3) (My preference) We can render two buttons, "Open Trace Folder" and "Open Trace File". But additionally, ReactExplorerPlaceholderWidget can render one or both buttons based on its properties. The extension can control what button(s) get rendered based on a setting/api. I think this is a more complete solution as base extension and extending extensions can control the behaviour of what trace resource type will be handled. (Background: we only deal with single trace files and have no need for open trace folders, so i think it would be neat to not have a button for opening trace folder and only for opening trace file)

I would love get some feedback and/or suggestions!

ngondalia commented 7 months ago

Demo for Option 3:

https://github.com/eclipse-cdt-cloud/theia-trace-extension/assets/113199503/4adf34a6-93fd-46b0-8925-fb87be86b21e

Note: this is hooked to vscode trace extension

For demo purposes, I have hooked it to a setting but I dont know if it needs to be a user facing configuration. There are multiple ways to control this behavior - external API / commands that set an internal state.

bhufmann commented 6 months ago

Thanks for opening this issue. This has been a topic for this viewer as the Eclipse Trace Compass project. Both viewers support traces that are single files as well as traces that are directories, e.g. CTF (Common Trace Format).

In Eclipse Trace Compass, the approach was to support opening only a trace from the Open Trace menu option and never a trace collection. The implementation then used a File Dialog to select a file. The automatic trace type detection, then checked if that file is within a CTF directory and then opened that CTF trace, or just open the single trace file. The advantage was that both single trace files and CTF traces were supported out of the box and there was only one single button. The disadvantage was, that it was not possible to open multiple CTF trace from a parent directory, which is a common use case (see LTTng creates kernel and UST traces under the same root directory). To open both LTTng Traces a single trace set (aka. experiment), users had to create experiments manually.

When we migrated to the traceviewer in this project, we decided to open all CTF traces under a single directory to support the case above for LTTng traces. However, there is no native dialog that allows to select a directory and files. So, we had to pick the directory chooser.

Now, to allow users to open a single file trace using a dialog, there needs to be a separate button to support that since there is no existing dialog implementation that allows both. The disadvantage is that the buttons need be duplicated. Right now there is a Open Trace button in the placeholder view (which is shown when there are no traces on the server) and in view menu of the Opened Traces View.

Alternatively, we could have a single button to opens another dialog where the user has to select Open Trace File or Open Trace Directory.