fix(app): raise the window a repository already has - #47
Merged
Conversation
…ond one The handoff routed the second invocation's path to the live process correctly and that process opened another window for it every time. `add_or_activate` dedupes the persisted project list, which has nothing to do with what is on screen. A map from canonical root to `WindowHandle`, consulted before opening. Both sides already agree on the key: `resolve_repository_root` canonicalises before the path goes into the socket, which is what makes `/tmp/x` and `/private/tmp/x` one entry rather than two. No window-close hook. `WindowHandle::update` fails once its window is gone, so raising doubles as the liveness check and a closed window's entry is dropped the next time that repository is asked for. Watching for closes to prune eagerly would buy back one map entry per repository opened in this process — a leak worth less than the code that plugs it, and a close hook that missed a case would be the worse failure: an entry that outlives its window and stops the repository ever opening again. Verified by driving the real handoff: same repository raises, a different one opens, the first raises again. The stale-handle path is not exercised, since closing a window from the command line is not something this can do.
LeadcodeDev
force-pushed
the
fix/focus-open-repo
branch
from
August 22, 2026 08:53
61b52e0 to
e3cf42c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #45.
gitr <path>for a repository already open added a second window for it. The handoff wasnever the problem — it routes the path correctly — and
ProjectList::add_or_activatededupes the persisted list, which has nothing to do with what is on screen.
The key is already canonical
A
HashMap<PathBuf, WindowHandle<Root>>, consulted before opening. Both sides agree on thekey without any new normalisation:
resolve_repository_rootcanonicalises before the pathgoes into the socket, which is what makes
/tmp/xand/private/tmp/xone entry ratherthan two. The transcript below shows that happening.
No window-close hook
The issue's sketch says "populated when open_window succeeds and cleared when that window
closes". The second half is not needed and is the riskier half.
WindowHandle::updatereturnsErronce its window is gone, so raising is the livenesscheck: a closed window's entry is detected and dropped the next time that repository is
asked for, and the request that found it stale is the one that opens the replacement.
Pruning eagerly would buy back one map entry per repository opened in this process. That
leak is worth less than the code that plugs it — and a close hook that missed a case would
fail in the worse direction, leaving an entry that outlives its window and stops the
repository ever opening again.
Verified on the real handoff
No UI automation involved — these are four command-line invocations against one running
instance, with the decision logged at each request:
The
/private/tmpline is the canonicalisation doing its job.Not exercised: the stale-handle path. Closing a window needs the UI, which this cannot
drive. What needs a human: close a repository's window, then run
gitrfor it again — itshould open fresh rather than do nothing.
cargo test --workspacegreen;cargo clippy --workspace --all-targets -- -D warnings;cargo fmt --all --check.