Skip to content

git_ui: Add View File action to Git Panel - #59383

Merged
ChristopherBiscardi merged 2 commits into
zed-industries:mainfrom
ahmedash95:git-panel-view-file
Jun 16, 2026
Merged

git_ui: Add View File action to Git Panel#59383
ChristopherBiscardi merged 2 commits into
zed-industries:mainfrom
ahmedash95:git-panel-view-file

Conversation

@ahmedash95

Copy link
Copy Markdown
Contributor

Objective

When reviewing changes in the Git Panel, the only ways to open a file were through a diff view ("Open Diff" or "Open Diff (File)"). There was no way to open the file directly in the editor to inspect or edit its current contents without entering a diff.

This PR adds a View File action to the Git Panel changes list context menu.

Solution

  • Add a git::ViewFile action in crates/git/src/git.rs, alongside other per-file git actions like FileHistory.
  • Wire it into the Git Panel file context menu, between the diff actions and "View File History".
  • Implement GitPanel::view_file to resolve the selected entry's repo path to a project path and open it via workspace.open_path_preview, matching the pattern used in commit_view::open_file_at_head.
  • Document the new action in docs/src/git.md.

Related issues

Testing

  • Added three GPUI tests in git_panel.rs:
    • test_view_file_tracked — modified tracked file
    • test_view_file_untracked — untracked file
    • test_view_file_tree_view — nested file in tree view
  • Ran cargo test -p git_ui test_view_file — all three pass.
  • Ran ./script/clippy -p git_ui — clean.

Manual testing for reviewers:

  1. Open a project with changed files and open the Git Panel.
  2. Right-click a changed file and select View File.
  3. Confirm the file opens in the editor (not a diff view).
  4. Repeat for an untracked file and with tree view enabled.
  5. Confirm Open Diff and Open Diff (File) still work.

Tested on macOS only. Linux and Windows should behave the same since this is a context menu action with no platform-specific code, but I haven't verified on those platforms.

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content adheres to Zed's UI standards (UX/UI and icon guidelines)
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

Showcase

Click to view showcase

Video recoding of the Git Panel context menu showing the new View File item:

Screen.Recording.2026-06-15.at.22.10.25.mov

Release Notes:

  • Added "View File" to the Git Panel context menu to open a changed file in the editor without a diff view.

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Jun 15, 2026
@zed-community-bot zed-community-bot Bot added the first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions label Jun 15, 2026
@ChristopherBiscardi ChristopherBiscardi added the area:integrations/git Git integration feedback label Jun 16, 2026
@ChristopherBiscardi ChristopherBiscardi self-assigned this Jun 16, 2026
@zed-industries-bot

zed-industries-bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor
Messages
📖

This PR includes links to the following GitHub Issues: #- 58250
If this PR aims to close an issue, please include a Closes #ISSUE line at the top of the PR body.

Generated by 🚫 dangerJS against bb30787

@ChristopherBiscardi ChristopherBiscardi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thanks!

@ChristopherBiscardi
ChristopherBiscardi added this pull request to the merge queue Jun 16, 2026
Merged via the queue into zed-industries:main with commit c3c38c5 Jun 16, 2026
32 checks passed
@ahmedash95
ahmedash95 deleted the git-panel-view-file branch June 16, 2026 08:38
This was referenced Jun 18, 2026
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
# Objective

When reviewing changes in the Git Panel, the only ways to open a file
were through a diff view ("Open Diff" or "Open Diff (File)"). There was
no way to open the file directly in the editor to inspect or edit its
current contents without entering a diff.

This PR adds a **View File** action to the Git Panel changes list
context menu.

## Solution

- Add a `git::ViewFile` action in `crates/git/src/git.rs`, alongside
other per-file git actions like `FileHistory`.
- Wire it into the Git Panel file context menu, between the diff actions
and "View File History".
- Implement `GitPanel::view_file` to resolve the selected entry's repo
path to a project path and open it via `workspace.open_path_preview`,
matching the pattern used in `commit_view::open_file_at_head`.
- Document the new action in `docs/src/git.md`.

### Related issues
- zed-industries#58250

## Testing

- Added three GPUI tests in `git_panel.rs`:
  - `test_view_file_tracked` — modified tracked file
  - `test_view_file_untracked` — untracked file
  - `test_view_file_tree_view` — nested file in tree view
- Ran `cargo test -p git_ui test_view_file` — all three pass.
- Ran `./script/clippy -p git_ui` — clean.

**Manual testing for reviewers:**

1. Open a project with changed files and open the Git Panel.
2. Right-click a changed file and select **View File**.
3. Confirm the file opens in the editor (not a diff view).
4. Repeat for an untracked file and with tree view enabled.
5. Confirm **Open Diff** and **Open Diff (File)** still work.

Tested on macOS only. Linux and Windows should behave the same since
this is a context menu action with no platform-specific code, but I
haven't verified on those platforms.

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

## Showcase

<details>
  <summary>Click to view showcase</summary>

Video recoding of the Git Panel context menu showing the new **View
File** item:



https://github.com/user-attachments/assets/c878fd4d-9acb-4c05-bd91-b452da0a6b90



</details>

---

Release Notes:

- Added "View File" to the Git Panel context menu to open a changed file
in the editor without a diff view.

---------

Co-authored-by: Christopher Biscardi <chris@christopherbiscardi.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:integrations/git Git integration feedback cla-signed The user has signed the Contributor License Agreement first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants