Skip to content

Conversation

@danvk
Copy link
Owner

@danvk danvk commented Jun 1, 2025

Fixes #89

This has been a long-standing pet peeve of mine. If you have a few git webdiff tabs live, you lose most of your terminals! Thanks to #223, webdiff reliably terminates when you close the tab. This means it's safe to detach.

There are two complications here:

  • To "detach," we have to re-run the same command in a subprocess (see this question). I distinguish the parent/child processes through an environment variable.
  • git difftool cleans up after itself when the parent process terminates (makes sense!). This means that the child process tries to diff non-existent directories. To make that work, we have to make a copy of the directories before detaching. Fortunately, this can be a shallow copy. We don't need to resolve symlinks.

This seems to work great, but I'll have to try it out locally for a bit to feel confident.

@danvk danvk requested a review from Copilot June 1, 2025 13:51
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements a detach feature so that git webdiff can return control to the terminal while the diff server continues running. It introduces environment-variable–driven parent/child detection, shallow copies of diff directories to work around git difftool cleanup, and updates documentation accordingly.

  • Detect subprocess via WEBDIFF_* env vars and re-invoke in detached mode
  • Copy directories (with optional symlink resolution) before detaching
  • Update CLI parsing, core logic, and README to support detachment

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
webdiff/toy.py Prototype for subprocess detachment
webdiff/gitwebdiff.py Export WEBDIFF_FROM_GIT_DIFFTOOL before calling difftool
webdiff/github_fetcher.py Reordered imports and added raw string to ssh_push_re
webdiff/dirdiff.py Added follow_symlinks flag and propagated to copies
webdiff/argparser.py Single-line imports, load dirs from env in detached mode
webdiff/app.py Spawn detached child, log once, shallow copy before detach
README.md Updated install command and documented detach behavior
Comments suppressed due to low confidence (1)

webdiff/app.py:351

  • The new detach and shallow-copy logic under this branch isn’t covered by existing tests; add unit tests to verify that directories are copied and the subprocess is spawned correctly.
if os.environ.get('WEBDIFF_FROM_GIT_DIFFTOOL'):

@danvk danvk merged commit 4911c46 into main Jun 1, 2025
2 checks passed
@danvk danvk deleted the detach-process branch June 1, 2025 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

webdiff process should detach

2 participants