Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit Preview #1767

Merged
merged 416 commits into from
Nov 20, 2018
Merged

Commit Preview #1767

merged 416 commits into from
Nov 20, 2018

Conversation

smashwilson
Copy link
Contributor

@smashwilson smashwilson commented Oct 30, 2018

🌐 Collaborative pull request to implement the first chunk of behavior described in #1753.

Demo gif

commit-preview

  • bug - funky rendering as shown in Commit Preview #1767 (comment)
  • bug - unstaging last line in CommitView does not select the next last line, instead the selection jumps to another file above (see comment with gif in multi-file-patch.js)
  • bug - cmd-right from a ChangedFileItem throws an error. Desired behavior should be to focus appropriate file in StagingView
  • bug - cmd-right from CommitPreview throws an error. Desired behavior is that "Hide All Staged Changes" button is focused
  • Remove repetitive "Staged Changes" for Commit Preview (keep in ChangedFileItem)
  • Make file name bold (ex: /path/to/ file-name.md)
  • Make symlink and mode change text look less funky (the font looks large)
  • Let's have a MultiFilePatch model that includes an ordered list of FilePatch objects.
  • We'll need to extend the parser to understand multi-file git diff output. There may be some tricky work in here in relation to the deleted-symlink-and-created-file and deleted-file-and-created-symlink edge cases. @smashwilson
  • Add a method to our git repository plumbing to get the multi-diff from all staged changes, or, preferably, find a way to get this information using existing git repository methods. @smashwilson
  • Let's have a CommitPreview component hierarchy for the React side of things: CommitPreviewItem for the workspace item stuff, CommitPreviewContainer for the loading and error logic.
  • For the rest of the components, we have a decision to make. We can either: (a) generalize the existing FilePatch classes (controller and view) to be usable in both situations, or (b) create new components that are specialized for the multi-file case. I'm leaning a little toward (a) but that might change when we get down into the code. (@annthurium and @kuychaco)
    • make it so that users can only highlight hunks or lines from one file at a time.
      • fix initial header highlighting which is real weird rn
    • Fix the styling so that we're not hard coding the height of each file.
  • do we want to support tabbing, or some other kind of keyboard nav, across hunks or files?
  • Finally, we'll need to do the addition of the "preview" button within the CommitView and the corresponding wiring for the preview action in CommitController.
    • If the preview is already showing, the button doesn't do anything. Should the button toggle the preview?
    • Toggle commit preview open/closed with button
      • update button when pane item is destroyed (eg. commit preview is closed by hitting 'x' on the tab)
  • if the "Preview Commit" button is selected, hitting "enter" doesn't actually open the preview. Seems like we should fix that.
    • Ensure that cursor is placed in editor for easy keyboard navigation
  • Rework to use a single TextEditor for all FilePatches (@smashwilson - working in a separate branch until we verify performance improvements)
    • Modify patch builder to use a single TextBuffer and MarkerLayer set for all patches in a MultiFilePatch
    • Modify FilePatchController to accept a MultiFilePatch as a prop, and require a FilePatch as an argument in its action methods
    • Modify FilePatchView to render all FilePatches in a MultiFilePatch
    • Verify improved performance
    • Catch up the tests
  • Replace getChangedFilePatch hack and find better way of getting multi file diff in ChangedFilesItem
  • clean up PropTypes
  • clicking the <> in a file header to open in file takes you to where the selection is, even if it’s not the file corresponding to the header

Metrics

  • toggling the “preview” button

Tests

Unit tests:
For each of these get the test suite to be green and check for missing coverage based on UX testing, application logic, and using coveralls.
Arranged according to component hierarchy. Not in order of what makes sense to tackle first

  • RootController
    • ChangedFileItem
      • ChangedFileContainer
    • CommitPreviewItem
      • CommitPreviewContainer
        • MultiFilePatchController
        • MultiFilePatchView
  • MultiFilePatch
    • FilePatch
      • Patch
  • Full test suite check
    • Repository
    • buildFilePatch
  • add test for "Open in File", testing multiple files

Test coverage:

  • Coveralls reports no new uncovered lines
  • Coveralls reports no uncovered existing lines

Manual test plan:

  • Make sure commit preview updates when you stage and unstage files/hunks/lines
  • When several are open (each corresponding to a different project repo
    • check commit preview functionality
    • check all file patch view behavior
  • Open in file
    • <> button for file that isn't selected
  • Discarding/undoing discard
    • Discard button in hunk header for hunk that is not selected
  • Jumping to mirrored file
  • view and unstage symlink changes from the commit preview
  • view and unstage file mode changes from the commit preview

Documentation

  • Update the component atlas

User Experience Research (Optional)

  • Verify change to button wording for discoverability.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.08%) to 84.851% when pulling cca6f09 on commit-preview into 6d18d72 on master.

@coveralls
Copy link

coveralls commented Oct 30, 2018

Coverage Status

Coverage increased (+0.6%) to 85.572% when pulling 8e5d9ee on commit-preview into f16266d on master.

styles/commit-preview-view.less Outdated Show resolved Hide resolved
styles/commit-preview-view.less Outdated Show resolved Hide resolved
Copy link
Contributor

@simurai simurai left a comment

Choose a reason for hiding this comment

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

Some questions that might already came up in Slack:

  • Should it be a pending pane? It feels like the Commit Preview is something more temporary. Or do people want to keep it open all the time, maybe in a split view?
  • Similar and maybe depends on the above, should the Commit Preview pane get automatically closed after committing? Maybe not if there are more unstaged changes since you might want to make a 2nd commit next.
  • Should the Commit Preview button be a 3-way toggle? Similar how the Git and GitHub status bar buttons work. If the Commit Preview pane is already open, but not visible (the active tab), users might just want to focus it again, and not close it altogether.
  • Should we remove the blinking cursor? And use the default mouse cursor? To not make it look like the diff is editable? Here some options: Editable diffs in FilePatchItems #1720 (comment)

@annthurium
Copy link

annthurium commented Nov 1, 2018

addressing @simurai's questions:

Should it be a pending pane? It feels like the Commit Preview is something more temporary. Or do people want to keep it open all the time, maybe in a split view?

@kuychaco brought this up too. I'm not really sure what the difference is between a pending pane and a non pending pane, tbh. I'll learn about that and come back with a more informed opinion.

Similar and maybe depends on the above, should the Commit Preview pane get automatically closed after committing? Maybe not if there are more unstaged changes since you might want to make a 2nd commit next.

Yeah, I think we should not close the preview automatically, for that reason.

Should the Commit Preview button be a 3-way toggle? Similar how the Git and GitHub status bar buttons work. If the Commit Preview pane is already open, but not visible (the active tab), users might just want to focus it again, and not close it altogether.

Is your question prompted by performance concerns? I think the API we're using hides the pane, rather than destroying it.

Should we remove the blinking cursor? And use the default mouse cursor? To not make it look like the diff is editable? Here some options: #1720 (comment)

It depends on when editable diffs are on the roadmap. If we're going to do that soon (like before the end of the year), it might not make sense to implement this. Otherwise yeah, it's confusing if the diff looks like it's editable and it's not.

@simurai
Copy link
Contributor

simurai commented Nov 2, 2018

I'm not really sure what the difference is between a pending pane and a non pending pane

Sorry, here a gif that tries to show the issue:

pending

Notice that when clicking on individual files, Atom automatically closes the tab of the previous file. But after opening the "Commit Preview" and clicking on a single file, Atom opens a new tab for that file and keeps the "Commit Preview" tab permanently opened. It's not necessarily a "bug", some people might prefer this behaviour. Ohh.. btw. "pending pane" is a core setting, that can be turned off/on:

screen shot 2018-11-02 at 11 45 59 am


Is your question prompted by performance concerns?

More a UX concern. Actually, it now works like a 3-way toggle. 👍👍👍 Just that the label of the button "Close Commit Preview" could be misleading. Example:

  1. The "Commit preview" tab is open, but not the active tab
  2. When clicking on "Close Commit Preview", it doesn't close the "Commit preview" tab, it makes it the active tab. Which is the right behaviour, just wrong button label.

toggle

Maybe "Close Commit Preview" could be renamed to "Toggle Commit Preview". Then the button label doesn't need to be updated when the "Commit Preview" tab isn't the active tab.


Re. button label. I asked about it in our design review. Some felt it's confusing that it says "Commit Preview", because it feels more like a "Show all staged changes". Curious if more people feel that way too.


Otherwise yeah, it's confusing if the diff looks like it's editable and it's not.

Ok, I might play around a bit to see if it can be made more "read-only" looking.


Anyways, since this PR is our first exploration into multi-file diffs, we don't have to iron out every little detail. 😅 It might be easier to make certain decisions after using this feature for a while.

@smashwilson
Copy link
Contributor Author

Re. button label. I asked about it in our design review. Some felt it's confusing that it says "Commit Preview", because it feels more like a "Show all staged changes". Curious if more people feel that way too.

Hmm, interesting. I can see your point about "commit preview" being unclear... but I feel like "show all staged changes" doesn't do enough to convey why you want to do that. It's also a bit wordy.

Maybe its proximity to the commit editor and commit button will be enough to signal the "why"?

kuychaco and others added 19 commits November 16, 2018 20:23
test needed to be updated to reflext new getNextSelectionRange logic 
added in 1685484

Co-Authored-By: Katrina Uychaco <katrina@github.com>
Co-Authored-By: Katrina Uychaco <katrina@github.com>
Co-Authored-By: Katrina Uychaco <katrina@github.com>
Co-Authored-By: Katrina Uychaco <katrina@github.com>
… events with no path property

Co-Authored-By: Katrina Uychaco <katrina@github.com>
Co-Authored-By: Katrina Uychaco <katrina@github.com>
Co-Authored-By: Katrina Uychaco <katrina@github.com>
Co-Authored-By: Katrina Uychaco <katrina@github.com>
Co-Authored-By: simurai <simurai@users.noreply.github.com>
Co-Authored-By: Tilde Ann Thurium <annthurium@github.com>
Copy link
Contributor

@kuychaco kuychaco left a comment

Choose a reason for hiding this comment

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

I reviewed all of the application logic changes since my last review, everything looks good!

I also reviewed a bunch of the test files, but eventually decided there are waaaay too many for me to look at and it's probably fine to merge them without looking super closely. They're for insurance, and not as important as the application logic (which can actually contain bugs and regressions). The most important thing around tests is that we have coverage for all new lines, which we do (thanks coveralls!).

Thanks everyone for your fantastic work with this PR! GO TEAM! ✨

@kuychaco kuychaco merged commit d403789 into master Nov 20, 2018
@kuychaco kuychaco deleted the commit-preview branch November 20, 2018 20:26
@simurai simurai mentioned this pull request Nov 21, 2018
@vanessayuenn vanessayuenn mentioned this pull request Nov 21, 2018
5 tasks
@cristianomarquesadmo1
Copy link

Good job guys. Congratulacions to all

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

Successfully merging this pull request may close these issues.

8 participants