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

Apply vscode Timeline Plugin API #7997

Merged
merged 1 commit into from
Sep 8, 2020
Merged

Apply vscode Timeline Plugin API #7997

merged 1 commit into from
Sep 8, 2020

Conversation

vinokurig
Copy link
Contributor

@vinokurig vinokurig commented Jun 11, 2020

What it does

Add Timeline Plugin API that controls the Timeline view.
video-convert

fixes #7577

How to test

  1. Remove "@theia/git": "^1.2.0" from examples/browser/package.json file
  2. Download vscode-git-1.44.2 extension which requires the Timeline API and copy it to the plugins folder
  3. Compile and start theia with a project cloned from github.

After closing and reopening the widget, TimeLine widget exists as single object:
video-convert (1)

Review checklist

Reminder for reviewers

@vinokurig vinokurig added plug-in system issues related to the plug-in system vscode issues related to VSCode compatibility labels Jun 11, 2020
@vinokurig vinokurig requested review from akosyakov, azatsarynnyy and paul-marechal and removed request for akosyakov and azatsarynnyy June 11, 2020 10:26
@@ -48,6 +48,7 @@
"@theia/search-in-workspace": "^1.2.0",
"@theia/task": "^1.2.0",
"@theia/terminal": "^1.2.0",
"@theia/timeline": "^1.2.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's keep the browser app in sync with the electron one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@akosyakov
Copy link
Member

Is it somehow based on the current git history implementation or there is no sense in reusing it?

Copy link
Member

@akosyakov akosyakov left a comment

Choose a reason for hiding this comment

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

I did the first round of code review.

packages/timeline/src/browser/timeline-widget.tsx Outdated Show resolved Hide resolved
this.containerLayout.addWidget(this.timelineEmptyWidget);

this.refresh();
this.timelineService.onDidChangeTimeline(event => {
Copy link
Member

@akosyakov akosyakov Jun 13, 2020

Choose a reason for hiding this comment

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

always collect all listeners into this.toDispose

Please profile and check that when you close the widget that it does not leak. Please add it to How to test section for reviewers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, updated the description. It is interesting that TimelineTreeWidget still duplicates:
Screenshot from 2020-07-07 15-14-32
I don't have any ideas why it happens because scmTreeWidget binded in the same way but it doesn't have this problem. Do you have any ideas?

packages/timeline/src/browser/timeline-service.ts Outdated Show resolved Hide resolved
packages/timeline/src/browser/timeline-service.ts Outdated Show resolved Hide resolved
packages/timeline/src/browser/timeline-service.ts Outdated Show resolved Hide resolved
packages/timeline/src/browser/timeline-tree-widget.tsx Outdated Show resolved Hide resolved
packages/timeline/src/browser/timeline-empty-widget.tsx Outdated Show resolved Hide resolved
export class TimelineContribution implements FrontendApplicationContribution {

@inject(FileNavigatorContribution)
protected readonly explorer: FileNavigatorContribution;
Copy link
Member

Choose a reason for hiding this comment

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

not used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is used to add the timeline widget to explorer:

explorer.addWidget(timeline, { initiallyCollapsed: true });

Copy link
Member

@akosyakov akosyakov Aug 21, 2020

Choose a reason for hiding this comment

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

I could not find any usages, please check again. Please do it by using find references, not find in text.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed the leftovers

protected readonly timelineService: TimelineService;

async onDidInitializeLayout?(app: FrontendApplication): Promise<void> {
const explorer = await this.widgetManager.getWidget(EXPLORER_VIEW_CONTAINER_ID);
Copy link
Member

Choose a reason for hiding this comment

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

We should instead listen when widgetManager fires onWillCreate event and if a new widget is explorer then we shoudl participate and add the timeline, otherwise we eagerly create a widget even if a user does not see it.

See PluginViewRegistry how we add views on demand.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now, the timeline widget is created only when timeline provider is registered:

this.timelineService.onDidChangeProviders( async event => {
if (explorer instanceof ViewContainer) {
if (event.added && event.added.length > 0 && explorer.getTrackableWidgets().indexOf(timeline) === -1) {
timeline = await this.widgetManager.getOrCreateWidget(TimelineWidget.ID);
explorer.addWidget(timeline, { initiallyCollapsed: true });

Copy link
Member

Choose a reason for hiding this comment

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

getWidget creates a new widget eagerly, so timeline is only added once in onDidInitializeLayout.

We should instead participate in creation of the explorer view container and add the timline widget each time via widgetManager.onWillCreate event. Try to completely close and open the explorer tab.

@vinokurig
Copy link
Contributor Author

@akosyakov @kittaakos Thank you for your review. I will be able to answer all your comments after 30-th june, because I am on PTO right now.

@akosyakov
Copy link
Member

@vinokurig enjoy your time off, there is no hurry!

@akosyakov akosyakov requested a review from westbury June 29, 2020 07:46
@akosyakov
Copy link
Member

akosyakov commented Jun 29, 2020

@westbury I would like to have your look at it. I think you had ideas how to incorporate git history view in the timeline according to #8084. Do you see why it should not be necessary?

@azatsarynnyy
Copy link
Member

I've done all the steps as described in How to test section but I don't see Timeline panel
image

git extension is present
image

I've just removed @theia/git and added the provided vsix. Are there some additional steps required?

@vinokurig
Copy link
Contributor Author

@azatsarynnyy

I've done all the steps as described in How to test section but I don't see Timeline panel

I've fixed the plugin link, please download the the patched plugin and replace it.

@azatsarynnyy
Copy link
Member

I rebuilt the sources, re-downloaded the git vsix. But Timeline panel is still not present 🤷

@westbury
Copy link
Contributor

westbury commented Jul 1, 2020

Thanks for doing the initial contribution of the timeline. I have a couple of questions.

  1. I would expect there to be a ViewContribution so that the view appears in the Open View etc.
  2. It appears you have used ScmWidget as the template for TimelineWidget, so you have ended up with TimelineTreeWidget. However the timeline is inherently flat, not a tree. I would have used ScmHistoryWidget as the template. The history is the principal use for the timeline, perhaps for a while the only use. I am interested to know your reasons for using ScmWidget as the template.

@vinokurig
Copy link
Contributor Author

@azatsarynnyy

I rebuilt the sources, re-downloaded the git vsix. But Timeline panel is still not present

Sorry, updated the link again, now it should work

@westbury
Copy link
Contributor

westbury commented Jul 2, 2020

I think you had ideas how to incorporate git history view in the timeline according to #8084. Do you see why it should not be necessary?

I had assumed that the git history view would be updated to use the timeline view. However I have now realized that the timeline view is designed to show items for a single file only, so perhaps using the same view is not a good idea (though our git package will need to contribute to the timeline). Also we have more flexibility if git history is a different view. For example I experimented with adding a graph of branches to the history view (though I had not got it into a state good enough for a PR).

@akosyakov
Copy link
Member

akosyakov commented Jul 2, 2020

Timeline will need to support folders eventually as well: microsoft/vscode#95332 Not sure why we need to support double code doing the same and giving different UX.

@westbury
Copy link
Contributor

westbury commented Jul 2, 2020

Not sure why we need to support double code doing the same

We would use the same base code

and giving different UX

When I am looking at file or folder history, I am typically looking into understanding the details of the code in that file or folder. When I am looking at repository history I am more likely to be managing commits (rebasing, merging etc). Different work, different UX. Maybe it can all be shoehorned into the timeline.

@azatsarynnyy
Copy link
Member

@azatsarynnyy

I rebuilt the sources, re-downloaded the git vsix. But Timeline panel is still not present

Sorry, updated the link again, now it should work

Thanks @vinokurig! It works now )

When I'm calling Open Changes command, it says:
image

Is it expected?

@westbury
Copy link
Contributor

westbury commented Jul 2, 2020

When I'm calling Open Changes command, it says:

Is it expected?

That's a known issue, not related to this PR. I thought there was an issue for it but I could not find it so I will create one.

Comment on lines 6 to 8
"@theia/core": "^1.2.0",
"@theia/editor": "^1.2.0",
"@theia/navigator": "^1.2.0"
Copy link
Member

Choose a reason for hiding this comment

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

should be ^1.3.0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@vinokurig
Copy link
Contributor Author

@akosyakov @westbury Looks like I have answered all your comments, could you please review the PR again?

@vinokurig vinokurig force-pushed the theia-7577 branch 6 times, most recently from d38a9a3 to 3d594e2 Compare August 26, 2020 09:33
@akosyakov
Copy link
Member

Could someone test and approve it if it is fine? Rather than that it is fine with me.

Copy link
Contributor

@westbury westbury left a comment

Choose a reason for hiding this comment

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

I have tested this and I have noticed the following:

  1. The 'load-more' does not really work very well. I have to repeatedly press it to get another 20 items. I have a portrait oriented screen that shows 150 lines so this takes a few presses. Then when my timeline section is full, I scroll down. However as soon as I try to scroll it resets and shows only 20 items again. So I can't see the bottom items.

  2. The view is missing a few things which are shown is vs-code. That is ok as we don't need to implement everything in the first commit. However two things that would be good to get in fairly soon, preferably before the 1.6 release, are a) put the file name in the title and b) show the timestamp for each item.

  3. I still think this should not be based on TreeWidget. A timeline is not a tree and never can be (unless one lives in Winden). @akosyakov mentioned Timeline support for folders microsoft/vscode#95332 but, even if Microsoft were to accept that request, the timeline will still be a chronological list of commits that affect a folder, not a tree. Furthermore a timeline may have branches. I know that neither the timeline API nor Theia's history view currently support branches but I don't want to preclude supporting branches. Also there are over 1400 lines in TreeWidget that support trees yet all we use is selection and cursor up and down. The tree widget causes problems, for example cursor-left does nothing while cursor-right moves down, not a major bug and easily fixed but indicative of problems that can occur.

Overall though this is good and we need to get it merged. The only significant problem is the load-more action mentioned above. Ultimately I think this would work better if we used react-virtualized, so more items are fetched as the user scrolls, as is done in Theia's history view. I therefore don't think we need to spend too much effort perfecting this now. Most of the load-more problems are not visible to the user if PAGE_SIZE is increased, 200 should be plenty enough for most users' screen sizes. So I am happy to approve this with PAGE_SIZE at 200 and, of course, rebased and squashed.

@vinokurig vinokurig force-pushed the theia-7577 branch 3 times, most recently from 3987218 to e30056a Compare September 1, 2020 10:09
@vinokurig
Copy link
Contributor Author

@westbury

  1. The 'load-more' does not really work very well. I have to repeatedly press it to get another 20 items. I have a portrait oriented screen that shows 150 lines so this takes a few presses. Then when my timeline section is full, I scroll down. However as soon as I try to scroll it resets and shows only 20 items again. So I can't see the bottom items.

I've fixed it and other issues in the latest commit.

  1. The view is missing a few things which are shown is vs-code. That is ok as we don't need to implement everything in the first commit. However two things that would be good to get in fairly soon, preferably before the 1.6 release, are a) put the file name in the title and b) show the timestamp for each item.

I'll file an issue with this improvements when it is merged.

  1. I still think this should not be based on TreeWidget. A timeline is not a tree and never can be (unless one lives in Winden). @akosyakov mentioned Timeline support for folders microsoft/vscode#95332 but, even if Microsoft were to accept that request, the timeline will still be a chronological list of commits that affect a folder, not a tree. Furthermore a timeline may have branches. I know that neither the timeline API nor Theia's history view currently support branches but I don't want to preclude supporting branches. Also there are over 1400 lines in TreeWidget that support trees yet all we use is selection and cursor up and down. The tree widget causes problems, for example cursor-left does nothing while cursor-right moves down, not a major bug and easily fixed but indicative of problems that can occur.

I prefer to keep it as a tree because in this case we just extend the basic tree widget, so the implementation is simpler. Otherwise it would require a new widget from scratch or moving the git-history widget to some common place and extending it which can produce even more bugs. The problems that you described are fixed in the latest commit.

@vinokurig
Copy link
Contributor Author

@westbury any updates on this?

@westbury
Copy link
Contributor

westbury commented Sep 4, 2020

I've tested it again and I have found the following issues:

  1. I cannot get the 'Load-More' action to work. For me nothing happens when I click on it. Actually, I have now figured out how to get it to work: It works only if one clicks on it before anything else in the timeline. If one clicks on an item then clicks on 'Load-More' then it does not work.

  2. When I select a file in explorer, the timeline is not updated. I have to then click in the editor. It was not obvious to me that I needed to click in the editor to update the timeline. The timeline in the explorer should match the file selection in the explorer, like it does in vscode.

  3. If I cursor down to 'Load-More' and press the Enter key, nothing happens.

  4. If, immediately after the timeline is updated to another file, I select an item then I see both the item and the 'Load-More' rows selected. This may be related to 1. above because the 'Load-More' action does not work once in this state.

@vinokurig
Copy link
Contributor Author

@westbury I've fixed it again, so your cases are fixed now except the last one. The load more node is selected by default:


so I think it is a bug in the tree widget. I can file an issue about the default selection is not lost after selecting other nodes after merging it to be able to provide a use-case in the issue. WDYT?

@westbury
Copy link
Contributor

westbury commented Sep 7, 2020

Thanks for fixing those issues.

I think it is a bug in the tree widget

I think the tree widget is working as designed. The problem is that the Load-More item has the selected flag set but is not registered in the selection service. If you look at the transiteTo function in tree-selection-impl.ts then you will see where the old selection is deselected. The Load-More item should appear in oldNodes on line 79, at which point it would be deselected.

}

this.providers.delete(id);
this.providerSubscriptions.delete(id);
Copy link
Contributor

Choose a reason for hiding this comment

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

Surely you should be disposing the listener here? You make the effort to keep the listener disposables in this.providerSubscriptions but you don't do anything with them.

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've fixed that by disposing the provider directly instead of storing disposables in a map.

@vinokurig
Copy link
Contributor Author

@westbury
Thank you for the advice with the selection-service. I've registered the load-more node in the selection service and it doesn't keep the selection any more if another node is selected. Could you please review it again?

Copy link
Contributor

@westbury westbury left a comment

Choose a reason for hiding this comment

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

Great. It tests well and I did not see any memory leaks. Thanks for fixing that last issue. Just remove the unnecessary inject and I will be happy for this to be merged.

@@ -30,6 +30,8 @@ export interface TimelineNode extends SelectableTreeNode {
@injectable()
export class TimelineTreeModel extends TreeModelImpl {

@inject(TreeSelectionService) protected readonly selectionService: TreeSelectionService;
Copy link
Contributor

Choose a reason for hiding this comment

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

Not necessary. This is injected into TreeModelImpl.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Signed-off-by: Igor Vinokur <ivinokur@redhat.com>
@vinokurig vinokurig merged commit 35d4780 into master Sep 8, 2020
@vinokurig vinokurig deleted the theia-7577 branch September 8, 2020 09:18
@vinokurig vinokurig mentioned this pull request Sep 8, 2020
3 tasks
NexediGitlab pushed a commit to SlapOS/slapos that referenced this pull request Aug 20, 2021
See theia's [changelog](https://github.com/eclipse-theia/theia/blob/v1.16.0/CHANGELOG.md#v1160---7292021), we update from 1.13.0 to 1.16.0.

Changes specific to slapos port:
 * We set `warnOnPotentiallyInsecureHostPattern` because the new warning is very intrusive ... but it might actually be very insecure. For now we don't have solution. We are tracking this in https://erp5js.nexedi.net/#/bug_module/20210819-20614EE
 * New libsecret component that is now required by theia
 * Switch to using vscode git instead of theia git, to use timeline ( see eclipse-theia/theia#7997 )
 * globally version up slapos.core to https://pypi.org/project/slapos.core/1.6.18/

See merge request nexedi/slapos!1039
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CQ Required (deprecated) issues requiring a CQ (contributor questionnaire) plug-in system issues related to the plug-in system vscode issues related to VSCode compatibility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Timeline API
5 participants