zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
50.56k stars 3.13k forks source link

Inconsistent Commit Message Retention: .git/COMMIT_EDITMSG Stuck After Multiple Commits #18701

Open alexanderjeurissen opened 1 month ago

alexanderjeurissen commented 1 month ago

Check for existing issues

Describe the bug / provide steps to reproduce it

Issue Description:

When using Zed as the default Git editor for commits, the .git/COMMIT_EDITMSG file can get stuck, preventing the editor from loading the current commit message and diff. Instead, it reopens the old message and diff from a previous commit, making it impossible to proceed with the new commit.

Steps to Reproduce:

  1. Install Zed CLI.
  2. Set zed --wait as the Git editor:
    git config --global core.editor "zed --wait"
  3. Open a terminal inside Zed.
  4. Run a Git commit operation with changes staged:
    git commit
  5. Use Zed’s inline assistant to generate a commit message based on the diff.
  6. Use :x to save and close the buffer.
  7. Make another change to the codebase.
  8. Attempt to commit the new change with:
    git commit
  9. When Zed opens the Git editor, you will notice that it still contains the previous commit message and diff instead of the current one.

Observed Behavior:

Expected Behavior:

When performing a Git commit, Zed should open the fresh commit message and diff in .git/COMMIT_EDITMSG relevant to the latest changes.

Impact:

This issue creates confusion and hinders smooth Git commit workflows when using Zed, especially when dealing with successive commits in quick succession.

Environment

Zed: v0.155.2 (Zed) OS: macOS 14.7.0 Memory: 32 GiB Architecture: aarch64

If applicable, add mockups / screenshots to help explain present your vision of the feature

https://github.com/user-attachments/assets/ca96f18a-4807-4af9-8e5d-a5cdcb672eac

If applicable, attach your Zed.log file to this issue.

Not sure if relevant:

2024-10-03T17:33:25.665187+02:00 [INFO] open paths ["/Users/alexander/Development/hackerone/core/.git/COMMIT_EDITMSG"]
2024-10-03T17:33:41.677606+02:00 [INFO] open paths ["/Users/alexander/Development/hackerone/core/.git/COMMIT_EDITMSG"]
2024-10-03T17:33:47.71309+02:00 [ERROR] Io(Custom { kind: NotFound, error: SendInvalidDest })
2024-10-03T17:34:06.509027+02:00 [INFO] open paths ["/Users/alexander/Development/hackerone/core/.git/COMMIT_EDITMSG"]
2024-10-03T17:34:11.555083+02:00 [ERROR] Io(Custom { kind: NotFound, error: SendInvalidDest })
2024-10-03T17:34:43.948992+02:00 [INFO] open paths ["/Users/alexander/Development/hackerone/core/.git/COMMIT_EDITMSG"]
2024-10-03T17:34:50.754999+02:00 [INFO] open paths ["/Users/alexander/Development/hackerone/core/.git/COMMIT_EDITMSG"]
2024-10-03T17:34:54.926566+02:00 [INFO] open paths ["/Users/alexander/Development/hackerone/core/.git/COMMIT_EDITMSG"]
2024-10-03T17:34:57.913225+02:00 [INFO] Summarizing updated entries took 5.625µs
2024-10-03T17:34:58.025996+02:00 [ERROR] failed to fetch cached embeddings via cloud model

Caused by:
    RPC request GetCachedEmbeddings failed: permission denied
2024-10-03T17:35:04.564961+02:00 [INFO] Summarizing updated entries took 5.25µs
2024-10-03T17:35:08.213007+02:00 [INFO] open paths ["/Users/alexander/Development/hackerone/core/.git/COMMIT_EDITMSG"]
2024-10-03T17:35:20.151918+02:00 [INFO] open paths ["/Users/alexander/Development/hackerone/core/.git/COMMIT_EDITMSG"]
alexanderjeurissen commented 1 month ago

This seems to be related to the following issue:

https://github.com/zed-industries/zed/issues/13212

alexanderjeurissen commented 1 month ago

I confirmed that invoking Workspace: reload actually fixes the issue, which confirms that Zed is too "lazy" in reloading files from disk when they change.