obsidian-git icon indicating copy to clipboard operation
obsidian-git copied to clipboard

Line-wise author info (resolves #77)

Open GollyTicker opened this issue 3 years ago • 12 comments

This is a work in progress PR!


@Vinzent03 Could you take a look at the first two commits only?

For working with the plugin, I've added a dockerized environment to reproducibly setup the node packages. I also added a test-vault as a submodule.

If you think, they are useful, I can extract them into separate branches and have them merged into the plugin for reproducability and makiing it easier for others to contribute. Otherwise, I can simply remove them from the branch and keep them just to me for development purposes.

What do you think?


Regarding the actual implementation, I will ping in actual issue, when I have a relevant working state to disucss.

GollyTicker avatar Aug 27 '22 22:08 GollyTicker

Hey thanks for working in this feature, but I really don't get why you are using docker. May you explain this further?

Vinzent03 avatar Aug 28 '22 14:08 Vinzent03

I am using docker for a reproducible development environment. I use this in most larger projects everywhere, because then I don't need to deal with any OS-level global installations which can create a dependency hell. If you don't like it, I can also remove it from the branch and keep it private only. However, for new developers it's always useful to have such dev-infrastructure. I can add more explanations and a README for that, if necessary.

Furthermore, I've a working basic prototype for the line authoring view. This is how it looks like right now: demo-1

Again. This is totally not finished. The UI can be improved. And the delay between chaning the lines in the editor and the line author view being updated is because Obsidian saves the changes to the filesystem only about 2 seconds after the last keystroke. So the git blame is delayed by that amount. I have ideas to work around that, but will implement them when the time is right.

Would you like to take an early look into the code and discuss any things there? the code is not finished, but most of the moving parts are set - i.e. the basic architecture and structure. Documentaiton, extensive testing and co is still remaining though. And all the variations such as the colorbar without the author etc. and copying the revision are also to be done.

What do you think?


FYI: I used the dockerized setup and the test-vault to make the above gif.

GollyTicker avatar Aug 28 '22 16:08 GollyTicker

@GollyTicker Your GIF looks nice to me! 🙂 How does it combine with the linenumbers column if you turn that on in the editor settings (Show line number)?

Perhaps I'd suggest to make the author information to be visually separated from the content, i.e. by making the column to have a different background color (maybe the same as the linenumber column). Anyway, this is just tweaking, the main thing is that the actual information is there and it works really well. Good job! 🌞

Taitava avatar Aug 29 '22 06:08 Taitava

@Taitava Currently it's simply displayed side by side to the line number. I'm planning to improve it in the way, that the condenced version (pure color withouth hash, date and author) should simply color the line numbers, if they exists, or just a blank area if they don't exist.

Regarding the UI of the line authoring. I haven't optimised the UI at all yet. Just wanted to show, that I've completed most fo the "hard work" of parsing the git-blame and integrating it into the view. I'll try out different styles and post a few of them when the time is right to get further feedback.

GollyTicker avatar Aug 29 '22 18:08 GollyTicker

Update: Date and time is now configurable

Date defaults

date-defaults and its settings date-defaults-settings

Date and time

Uses local timezone by default date-time and its settings date-time-settings

Date and time with explicit UTC timezone

date-time-utc and its settings date-time-utc-settings

Settings

The settings are only shown, when the line author info is active. There are a couple of options for everything. The date formatting has a live preview as well. demo-2-date-settings

GollyTicker avatar Sep 10 '22 17:09 GollyTicker

Update: Improved visuals and colorbar only option New improved styling colorbar-visuals

Only the colorbar colorbar-only-visuals

Also works in submodules now! submodule

GollyTicker avatar Sep 11 '22 10:09 GollyTicker

The screenshots look really nice! 🌞

Taitava avatar Sep 11 '22 13:09 Taitava

@Vinzent03 I've implemented all must-features and would like to go through the code with you once. I'm currently writing the documentation and architecture to improve the understand-ability of the code. However, perhaps it makes sense, that we also talk before I write the complete documentation - so that we can discuss some architectural from your perspective. I also have a few questions on a few small occasions where I'm not sure what's the correct obsidian-plugin-like way to implement things. Finally, there are no tests yet and I want to add tests for at least the most complex logic stuff.

What do you think?

If you want to play around with the current status, just run scripts/restart-dev.sh, check that the build watcher succeded and open test-vault as a vault in Obsidian.

GollyTicker avatar Sep 12 '22 11:09 GollyTicker

Sure that's a great idea. Do you have a Discord account so we can discuss this further? If so, you can reach me at @Vinadon#0410

Vinzent03 avatar Sep 12 '22 12:09 Vinzent03

Cool. I contacted you on Discord ✅

GollyTicker avatar Sep 12 '22 13:09 GollyTicker

Dark and Light mode

dark-light-mode

Copy Commit Hash

clipboard

Adaptive Color and Unintrusive Text Filler until result is ready

Before adaptive-color-and-text-before

After adaptive-color-and-text-after

It was quite some effort to make this adaptive coloring work. It was important to me, that the update of the UI when the result is ready is as unintrusive as possible. Opening a new file is done very often, so the UI update should be not distracting.

GollyTicker avatar Sep 19 '22 20:09 GollyTicker

Nice looking, again! 👍

Taitava avatar Sep 20 '22 14:09 Taitava

@Vinzent03 I'm finally ready for the feature review. :partying_face: :partying_face: :partying_face: Would you like to take a look at all of the changes? We can have a call sometime again on the general procedure.

I'd next ask of beta-testers in the original issues. And when the feature is working robustly, I we can then integrate it into master.

Before that, however, I would also like to finish the feature set docs for the public containing quick examples and GIFs.

Before the merge, I'd also rebase all into just a few commits and also put it ontop of all the upstream master changes.

GollyTicker avatar Sep 24 '22 22:09 GollyTicker

Be a beta tester for this feature!

We are happy, if a few people are willing to install this version of the plugin and give some early feedback. I want to make sure, that the feature is working reliably before we publish it.

How to install

  1. Make sure, that you are currently using the most updated obsidian-git plugin.
  2. Make a commit with your current state and remember it's revision in case you want to return there.
  3. Close Obsidian
  4. Open the folder .obsidian/plugins/obsidian-git and replace the existing main.js and styles.css with the files from v9.zip (~~v8.zip, v7.zip, v6.zip, v5.zip, v4.zip, v3.zip, v2.zip, v1.zip~~)
    • If there are important changes, then you can find newer versions of this feature (named v2, v3, etc.) in subsequent comments. Please always use the most recent beta testing version, when beta testing.
    • If you already were using v1: With v2/v3 please check your settings again and manually pick you time-zone option, because the settings for it have changed.
  5. Re-open Obsidian
  6. Activate the Line Author Feature in Settings > Obsidian Git > Line author information.
  7. Play around with everything :tada:

If you want to revert your installation - you can simply replace main.js and styles.css with the files from step 2. Note, that updating your obsidian-git will overwrite these files and the line author feature will not be there then.

How to use

The usage of the plugin should be mostly self-explanatory. A quick summary of example usages is being written now here: https://github.com/GollyTicker/obsidian-git/wiki/Line-Author-Feature

You are encouraged to simply use it in your normal workflows. If you find something, then please make a new issue here (with [Line Author] prefix in the title) or simply comment in this pull request. I'm also using the beta version in everyday usage now to see how it all feels like.

My priority is to have the most relevant bugs fixed before publish.

You can also write enhancements, but they'll be implemented after the merge (unless they are very important).

Allright then! Looking forward to your feedback! :partying_face: :muscle:

GollyTicker avatar Sep 25 '22 18:09 GollyTicker

:information_source: I've done a few small fixes and minor improvements in v2.zip. Please use this zip from now on.

If you already had v1 running locally, then (after installing v2) you need to go to the Obsidian-Git Line Author Information settings and set the time-zone config explicitly again as it's values have changed.

Also, the feature guide for users is done: https://github.com/GollyTicker/obsidian-git/wiki/Line-Author-Feature

@Vinzent03 Would you also like to review the feature guide? How could we merge the feature guide into the main repository?

GollyTicker avatar Sep 26 '22 21:09 GollyTicker

@Vinzent03 The registerLastClickedGutterHandler works perfectly fine with me. I had it installed by a few friends and we havent had any issues until now. However, I didn't ask them to specifically test this. I'm on Linux/Ubuntu and Obsidian v0.15.9. But I didn't test it myself on any other OS or version - since I don't have them

Regarding the submodule. I suggest you to consider actually leaving the test-vault inside. The dataview plugin also does this, for instance. (Though it's simply a directory there and not a submodule.)

I used the text-vault a lot for testing purposes, and I think that it can simplify all kinds of dev processes. The images for the user guide were all generated with the test-vault. Making it a submodule allows one to not have it forcefully cloned, when people are only interested in the code. However, making it a submodule allows one to synchronize the specific stage of development with it's submodule. After all, the test-vault is also part of the development process, so it makes sense to include it.

I'd also like to have a call with you on the general next steps before the final merge and release. We can talk about that then as well.

GollyTicker avatar Sep 29 '22 15:09 GollyTicker

  • [X] Bugfix: Sometimes, it takes longer to compute the line authoring. During that time the % placeholders are shown. It is however possible to R-click and copy the commit hash - which shouldn't be. It currently returns dummy-commit.

GollyTicker avatar Oct 03 '22 10:10 GollyTicker

  • [x] ~~with line author info being active, I sometimes have the feeling that the UI is slightly slower. Scrolling to rendered blocks and typing seems to be slightly slower. Maybe this is just placebo, but we should measure this and also adapt the code to be more responsive and performant if necessary. This might be related to the "render on every stroke" problem I had identified in the code.~~
    • I hit a blocker where I think that it's not possible to futher reduce scripting and improve lag as we would need a change in @codemirror/view. I created an issue to discuss that at codemirror. However, for now I'll just let it be. The work in progress i available on this branch.

GollyTicker avatar Oct 06 '22 15:10 GollyTicker

v3.zip is out with minor improvements

GollyTicker avatar Oct 09 '22 19:10 GollyTicker

I could resolve the problem mentioned in https://github.com/denolehov/obsidian-git/pull/288#issuecomment-1270286575. The performance is not better when actively working with the document.

GollyTicker avatar Oct 12 '22 21:10 GollyTicker

Obsidian v1.0 was just released. The many UI changes however resulted in a few things that don't work anymore. I've added todos in the code where these problems needs to be resolved. Probably this feature should be right release with the next update of the plugin to the v1.0 release.

GollyTicker avatar Oct 13 '22 14:10 GollyTicker

v4.zip was added with Obsidian v1.0 support

It also contains some performance improvements.

@Vinzent03 I had the same bug as you had with the context menu on v1.0. I had to use a hack to resolve it. An obsidian team member confirmed the bug on discord and it'll be released in the next release.

GollyTicker avatar Oct 14 '22 00:10 GollyTicker

I suspect a bug with Obsidian v1.0 which leads to the UI being messed up and obscuring parts of the editor text when line numbers are not also shown. See the corresponding bug report I'll attempt a quick-fix for that for now.

GollyTicker avatar Oct 15 '22 22:10 GollyTicker

looking forward to it. NIce work so far!

MateusMolina avatar Oct 16 '22 09:10 MateusMolina

:information_source: v5.zip with a Obsidian v1.0 UI fix

GollyTicker avatar Oct 16 '22 18:10 GollyTicker

Beta testing v5

1. My name does not appear completely.

Author name display setting:

  • First name: Shows correctly my first name, Jarkko.
  • Initials: Shows J, but should show JL.
  • Last name: Shows my first name, not last name.
  • Full name: Shows my first name only. Example screenshot below: kuva

Here you can see in terminal that I have configured my name correctly: kuva

2. +++ shown on wrong line when adding lines to the bottom of the file

kuva

  • Line If a link between hotkeys and shell commands work ok. is old, already commited. The only thing is that a linebreak chracter is added at the end of it.
  • Line new line is new an uncommitted. it's annotated correctly.

If I add a line in the middle of the file, it works correctly: kuva Only the another new line is annotated as new, which is correct. 🙂

3. Takes a bit of time for annotations to update when editing files

If I remember correctly, you mentioned this delay already. When a line is edited (or new line added), can you make the annotation to show the %%%%%% for the edited line until the annotation is ready? It would give me a visual hint that ok, the status of the line will be updated after a while. 🙂


These are my thoughts so far.

Thank you for making this awesome feature! You've put a lot of effort to this! You have made well customisable settings (I like it when there are a lot of settings to tweak 🙂 ). And the way you comment about your progress is really good! Easy to follow up in this pull request what is the next thing you will be concentrating on and what issues you've run into. 👍 Nice to see someone spending time to deliver good quality. 😎👍

Taitava avatar Oct 20 '22 16:10 Taitava

@Taitava Thanks a lot for the detailed beta feedback! I highly appriciate that

v6.zip with fixes of 1&2 named here

Concretely, I fixed the full and last name bug - and also added a new option to ignore whitespace and newlines in the settings. Since, people might actually be interested in indentation changes, I decided to not ignore whitespace by default. (Also, this is the default by git anyways.)

@Taitava Regarding 3. This will take a quite more effort, as we would need to add corresponding logic in the CodeMirror section ans continously update the gutter view. I by delaying the gutter view update, I could strongly reduce the implementation complexity at the cost, that the UI is shortly inconsistent. A good point you mentioned. Depending on how long the review takes, I might implement this before the merge - or later afterwards.

Nice to see someone spending time to deliver good quality. :sunglasses: :+1:

Thanks :blush:

GollyTicker avatar Oct 21 '22 01:10 GollyTicker

Hi,

I've been testing it since last week and found no bugs besides the ones mentioned by @Taitava. This feature is really helpful to check whether a file is old or not and how much work you put into it.

From my side, I miss a way to 'collapse' the bar in a way that only a color strip is shown. Furthermore, when the user hovers the cursor on the strip it could expand revealing the date and committer. In my opinion, this is as helpful and less intrusive as the current implementation - especially, when you have many files opened at the same time.

Another helpful feature would be to be able to see the git diff when clicking a particular date.

All in all, I really appreciate the effort you put into this feature! Amazing job! :)

MateusMolina avatar Oct 22 '22 10:10 MateusMolina

v7.zip with quick update of gutter while editing

@Taitava I think displaying % is a good idea. So I went ahead and implemented it. This is how it looks like :wink:

It's also explained in the wiki (not merged yet).

@MateusMolina Thanks for the feedback and your responses :smiley: Regarding the colorbar. That part is aleady possible. You can right-click and hide the hash/author/date to only show the colorbar.

Your other suggestions are already in this list of potential future improvements. I've not yet decided when and how to tackle them. Ideally, I'd have the feature out and published first before diving into them.

GollyTicker avatar Oct 23 '22 19:10 GollyTicker

v8.zip with quick gutter update fixes

  • when actively typing in larger vaults (like mine), sometimes the gutters were messed up. fixed.
  • when wroking with empty files, the quick gutter update was also leading to errors.

However, I also found a new bug which I haven't yet been able to fix:

  • [ ] when opening the vault directly inside an empty and tracked file, the gutter spacing during typing is wrong and leads to distracting ui updates.

GollyTicker avatar Oct 26 '22 20:10 GollyTicker