Skip to content

fix(watch): refresh remote status after terminal git push - #1044

Merged
danyaberezun merged 7 commits into
JetBrains:mainfrom
OKAN-SOFTWARE:fix/1009-remote-push-refresh
Nov 11, 2026
Merged

danyaberezun merged 7 commits into
JetBrains:mainfrom
OKAN-SOFTWARE:fix/1009-remote-push-refresh

Conversation

@OKAN-SOFTWARE

Copy link
Copy Markdown
Contributor

Problem

A git push from a terminal in a linked worktree can leave the Remote indicator showing stale information until another filesystem event occurs or the window regains focus.

The existing watcher observes the worktree and its private Git directory, but push-related remote-tracking updates occur in the shared Git directory.

Approach

Add narrowly scoped watchers for shared Git metadata and the configured remote-tracking reference.

The implementation avoids recursively watching every Git reference, debounces notifications using the existing mechanism, and closes the additional watchers during workspace cleanup.

Changes

  • Detect shared Git configuration and packed-reference changes.
  • Monitor the configured remote-tracking ref for push updates.
  • Rebind the reference watcher when Git configuration or HEAD changes.
  • Add regression coverage for initial and subsequent pushes, unrelated branch updates, and watcher cleanup.
  • Update the watcher module specification.

The implementation reads standard Git branch tracking configuration directly; more unusual configurations, such as includeIf, are not covered by the new tests.

Screenshots

Not applicable — no frontend changes.

Related issues

Closes #1009.

Verification

  • Focused watcher tests: 23 passed
  • Lint and TypeScript checks passed
  • Dependency, module boundary and specification checks passed
  • Internationalization and React compiler checks passed
  • git diff --check passed
  • Reproduced the original bug on Windows
  • Full monorepo unit suite
  • Full E2E suite
  • Linux/macOS verification

The focused Windows regression tests pass. Full-suite and other-platform verification remain outstanding.

@jetbrains-air jetbrains-air Bot 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.

Approved — ready to merge.

# Conflicts:
#	packages/server/src/watch/SPEC.md
ThinkRail branches are created --no-track, so after 'git push origin HEAD' there is no upstream config and the config-parsing watch saw nothing. Watch, non-recursively, the checked-out branch name under every refs/remotes/<remote>/ in the shared git dir plus packed-refs, and re-derive the targets whenever the repo-metadata nudge fires (branch switch, pack-refs, a new remote dir). Drops the hand-written git config parser.
…helper

Keeps the remote-ref helpers next to scheduleRepoMeta, away from watchGitDir, so this composes with JetBrains#1104's git-dir watcher change with only one-line conflicts.

@jetbrains-air jetbrains-air Bot 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.

Approved — ready to merge.

Comment thread packages/server/src/watch/watch.ts Resolved
@danyaberezun

Copy link
Copy Markdown
Collaborator

Thanks for covering push -u. ThinkRail branches are created without an upstream (#237), so I reworked the watch on our side (a785118): no more config parsing — for linked worktrees it watches packed-refs plus the checked-out branch name under every refs/remotes/<remote>/ (non-recursive, exact names, re-bound on each refresh). Your tests are kept, plus a --no-track push-without-upstream case.

@jetbrains-air jetbrains-air Bot 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.

Approved — ready to merge.

The remote-ref watch set was keyed by each directory's inode so a
deleted-and-recreated dir would be re-watched. `git pack-refs --all`
deletes the emptied refs/remotes/<remote>/ and the next push recreates
it; on ext4 the new dir often reuses the old inode number, so the key
did not change and the watch stayed bound to the deleted directory,
missing every later push. Close and re-create the handful of
non-recursive ref watches on each nudge instead.

@jetbrains-air jetbrains-air Bot 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.

Approved — ready to merge.

@danyaberezun
danyaberezun added this pull request to the merge queue Nov 11, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 11, 2026
@danyaberezun
danyaberezun added this pull request to the merge queue Nov 11, 2026
Merged via the queue into JetBrains:main with commit 0bbe38a Nov 11, 2026
12 checks passed
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.

A git push from a workspace terminal leaves the topbar Remote segment stale

2 participants