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

Feature. Advanced Commit View: Filter files text field. #669

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

lolgear
Copy link
Contributor

@lolgear lolgear commented Apr 12, 2020

  • Live repository file pattern variable has been added.
  • Advanced commit view search text field has been added.

Well, I would like to introduce another missing feature: File filtering. It is especially use in large commits.

I would like to have a feedback about this PR and feedback about roadmap of this feature.

Why it is not a final release?
I would like to add filtering functionality to each view ( view controller ) that requires it. Most of view controllers are consists of DiffFiles and DiffContents view controllers. However, it is not very simple to add this functionality into these small controllers.

So, I would like to add this functionality via inheritance from GIViewController or GIComposedViewController ( new entity ).

  • Add new entity GIComposedViewController.
  • Inherit all "final" controllers from this new entity.
  • Add filtering functionality into base class.
  • Add flags to enable/disable filtering functionality.
  • Add key bindings ( like alt + F or nothing + F ).

Fixes:

Further improvements:
We could add this functionality to GIDiffFilesViewController. If we do this, we could add search text field on every view that uses GIDiffFilesViewController. However, we should add also flag to indicate if we need this searchField or not.

@lolgear
Copy link
Contributor Author

lolgear commented Apr 12, 2020

@lucasderraugh Lets discuss!

@lolgear
Copy link
Contributor Author

lolgear commented Apr 13, 2020

@lucasderraugh What do you think about it?

@lucasderraugh
Copy link
Collaborator

I’ll check it out on Tuesday.

@lucasderraugh
Copy link
Collaborator

lucasderraugh commented Apr 15, 2020

Very cool! Here's some of my thoughts on it:

  • I think we should try to mirror the Xcode behavior where the search is in the bottom left of the section it represents not across the entire view.

Screen Shot 2020-04-14 at 4 58 32 PM

  • I think we need some protection from committing while filtering. If you accidentally have filtering on it can look like you're not committing what you think you're committing. Perhaps we should have a warning if we're hiding content that would be added to the commit.

Overall, this is pretty exciting.

@lolgear
Copy link
Contributor Author

lolgear commented Apr 15, 2020

@lucasderraugh Could you draw an example of what you want?
Since file pattern is applied to live repository, all controllers on advanced commit view will be affected and will get updates.
So, filtering is applying to all controllers.
Left bottom corner will be confusing for user, no?

Also, we should not forget to reset search on window disappearing, because other controllers should not know about filtering.

@lucasderraugh
Copy link
Collaborator

lucasderraugh commented Apr 15, 2020

Something like this, similar to how Xcode filters the content on the left pane:

ScreenShot

I don't think the other filter buttons are necessary though, just the text field.

@lolgear
Copy link
Contributor Author

lolgear commented Apr 15, 2020

@lucasderraugh
I embedded search text field after index view, so, now I can't reach message text view on tab. However, if I set focus on message text view and press shift + tab, everything works fine and focus jumps from message to search text field and up to index and finish at working directory.

How could I set nextKeyView / firstResponder for search text field? ( Yes, I set both in setup method ).

@lolgear
Copy link
Contributor Author

lolgear commented Apr 18, 2020

@lucasderraugh
Could you help with these two bugs:

  1. I can't set any nextKeyView/firstResponder to make everything works fine, searchTextField has nextKeyView as WorkDirectory no matter what I set.

  2. How to filter textDidChange:(NSNotification *)notification for concrete NSSearchTextField? I see that notification.object is not equal to self.searchTextField and I could check it only for following: [[self.searchTextField subviews].firstObject subviews] == notification.object

@lolgear
Copy link
Contributor Author

lolgear commented Apr 18, 2020

@lucasderraugh
Haha, I just change text handling from notification center to delegate and...
Everything works fine now :D

Could you check it?

@lucasderraugh
Copy link
Collaborator

lucasderraugh commented Apr 23, 2020

  1. How to filter textDidChange:(NSNotification *)notification for concrete NSSearchTextField? I see that notification.object is not equal to self.searchTextField and I could check it only for following: [[self.searchTextField subviews].firstObject subviews] == notification.object

Not sure about the first issue, but the second is because the object sending out the change is probably coming from the field editor (NSTextView). You should just query the current string value on searchField when receiving that update most likely.

@lolgear
Copy link
Contributor Author

lolgear commented Apr 23, 2020

@lucasderraugh I solved it by adopting protocol and set delegate, it isn't an issue anymore :)

@lolgear
Copy link
Contributor Author

lolgear commented Apr 24, 2020

@lucasderraugh Could we merge it?

@lolgear
Copy link
Contributor Author

lolgear commented May 27, 2020

@lucasderraugh Any updates?

@lucasderraugh
Copy link
Collaborator

Sorry @lolgear, I have been trying to finish a project whose deadline is at the end of the month. I’ll have more time in June to work on GitUp again.

@lolgear
Copy link
Contributor Author

lolgear commented Jul 6, 2020

@lucasderraugh
I hope that you finished project before deadline and everything is smooth now :)
Do you have time to check PR and merge it if it is ok?
Also, I hope #573 could be merged too.

@lucasderraugh
Copy link
Collaborator

lucasderraugh commented Jul 6, 2020

Yup, I started looking at some PRs last night. I’ll go through some of yours later this week.

@lucasderraugh
Copy link
Collaborator

Alrighty, I’ll go through your stuff today :)

Copy link
Collaborator

@lucasderraugh lucasderraugh left a comment

Choose a reason for hiding this comment

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

I'm trying to figure out if it should avoid being first responder or not. I generally like to hit tab to get down to the commit text at the bottom.

My biggest thing with this though is that it takes too long to do the diff on the commit. If I understand this correctly, we're only filtering by filenames, we aren't actually searching text in these commits. If this is the case then why do we need to recompute the diffs? If we're only going to filter by filename, then we should just do that at the table view level. We've already gone through the work of diffing everything.

<rect key="frame" x="0.0" y="0.0" width="300" height="27"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES"/>
<subviews>
<searchField wantsLayer="YES" verticalHuggingPriority="750" textCompletion="NO" translatesAutoresizingMaskIntoConstraints="NO" id="u4y-Fx-A8g">
Copy link
Collaborator

Choose a reason for hiding this comment

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

The search field should have placeholder text "Filter". We're not really searching any of the files.

@lolgear
Copy link
Contributor Author

lolgear commented Jul 27, 2020

I guess it would be a little difficult to move to table-view level. The main problem is index path as id.
Yes, we search only by file name and it is unnecessary to compute diffs.
This technique with repository file pattern allows us not to do extra work and to keep consistency as "one point of truth".

@lolgear
Copy link
Contributor Author

lolgear commented Aug 26, 2020

@lucasderraugh Any updates?
We could merge this PR in case of great experience, but, of course, it should be more "lightweight" and "domain-level".
However, I did exactly what is suggested in #34 .

@lolgear lolgear requested a review from lucasderraugh August 26, 2020 10:43
@lolgear
Copy link
Contributor Author

lolgear commented Dec 1, 2020

@lucasderraugh
Could we move away from xibs?
It is impossible to rebase now.

@lolgear lolgear force-pushed the commit_view_filter_files branch from 1468f4b to 3eaab1c Compare December 1, 2020 21:47
@lolgear
Copy link
Contributor Author

lolgear commented Dec 1, 2020

@lucasderraugh Done.
Could you check and merge it?

@lucasderraugh
Copy link
Collaborator

@lolgear I think the last thing I ask on this PR is that this is an opt-in feature and that by default we don't show any filter bar. For 99% of cases it's not really useful for me and I don't want to clutter the interface if it's not useful to people. If you can add a user default checkbox in Preferences that will toggle whether this filter field is shown or not then I can merge this in.

@lolgear
Copy link
Contributor Author

lolgear commented Dec 2, 2020

@lucasderraugh Do I need additional tab in settings for this behavior?
Is it ok if it will be done in code rather than in xib? ( Whole layout logic ).

@lucasderraugh
Copy link
Collaborator

@lucasderraugh Do I need additional tab in settings for this behavior?
Is it ok if it will be done in code rather than in xib? ( Whole layout logic ).

Let's keep the xibs and you can add it to the "General" tab for now. I'm going to move the "Appearance" based stuff into its own tab in a bit but lets keep the changes specific for this PR.

@lolgear
Copy link
Contributor Author

lolgear commented Dec 2, 2020

@lucasderraugh Done.
Yes, for this task it was pretty simple with "data binding" through "UserDefaultsController". Nice OS X pattern.

@lolgear
Copy link
Contributor Author

lolgear commented Dec 5, 2020

@lucasderraugh
Could you merge it?

@lolgear lolgear changed the title [Feature] Advanced Commit View: Filter files text field. Feature. Advanced Commit View: Filter files text field. Oct 13, 2021
@lucasderraugh
Copy link
Collaborator

I'll resolve the conflicts here and retest. Apologies on this one.

@NikKovIos
Copy link
Contributor

@lolgear could you please attach a screenshot of result?

_commitButton.enabled = _commitButton.enabled && !self.searchInProgress;

if (self.searchInProgress) {
_commitButton.toolTip = NSLocalizedString(@"Search in progress", @"");
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: should it be localized?

@Robert-M-Muench
Copy link

Can this be finished? This is the single most important feature missing when you work with a monorepo. I have about 2700 files showing up in my worktree and it's super tedious to scroll manually.

@lucasderraugh
Copy link
Collaborator

Yes, let me work on getting this in as it's on me at this point, I just lack the time to work on GitUp much these days. The reason it hasn't landed is because I don't want to allow filtering and committing at the same time as it's important to be able to know what is being committed. I think simply blocking commit if there is an active filter is the option I'd go with. There's also a consideration of disabling the feature in Settings that I'd like to introduce.

All this is to say let me target getting it in this week and if it's not merged you can poke me again.

@Robert-M-Muench
Copy link

I don't want to allow filtering and committing at the same time as it's important to be able to know what is being committed. I think simply blocking commit if there is an active filter is the option I'd go with.

How about adding some predefined filters like staged, changed, and untracked?

Or adding a real-time updated list that always shows what a commit would include?

And this feature should be very fast. I recognized that GU takes its time to rebuild the file list. When I switch to commit view initially it takes about 10s. When switching to another application and back, the update takes about 2s every time. That's pretty disturbing.

@lucasderraugh
Copy link
Collaborator

@Robert-M-Muench This is a text filter, we already indicate staged and unstaged via the 2 lists. The text filter is fast as we’re not querying anything new. The long loading time when transitioning is another bug that I need to address separately.

@Robert-M-Muench
Copy link

@lucasderraugh Not sure I understand.

In the commit view, I see my working directory list (about 45000 files), which includes about 2700 files/uncommitted local changes (untracked, changed, etc.).

How can I filter this list to show only changed files? Or untracked files with a specific pattern?

@git-up git-up deleted a comment from kamaraj-k Aug 29, 2024
view.translatesAutoresizingMaskIntoConstraints = NO;

if (superview != nil && view != nil) {
if (@available(macOS 10.11, *)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: @lolgear think about deprecate low mac versions

Copy link
Collaborator

Choose a reason for hiding this comment

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

@NikKovIos I’ll take a pass at cleaning this up on a new branch. The original author did enough on this one for me to push it over the finish line.

@@ -25,9 +25,12 @@
#import "GIColorView.h"
#import "GIInterface.h"
#import "GIWindowController.h"

Copy link
Contributor

Choose a reason for hiding this comment

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

Not needed spaces between imports

#pragma mark - Search
- (void)setupSearch {
self.searchTextField.delegate = self;
self.searchTextField.placeholderString = NSLocalizedString(@"Filter files", nil);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: don't have localization

Copy link
Collaborator

Choose a reason for hiding this comment

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

It’s fine to go that direction anyways, perhaps even encouraged. Makes any future translation easier.

Comment on lines +161 to +164
_commitButton.enabled =
_indexStatus.modified
|| (self.repository.state == kGCRepositoryState_Merge)
|| self.amendButton.state; // Creating an empty commit is OK for a merge or when amending
Copy link
Contributor

Choose a reason for hiding this comment

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

don't commit anything that not involved into feature. code style is subjective.

@lucasderraugh
Copy link
Collaborator

Oh, forgot I left this one in a state where it’s on me. Let me resume fixing this branch up and addressing the commit concerns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants