Skip to content

Refresh git metadata after git init#822

Draft
srid wants to merge 9 commits intomasterfrom
fix/git-init-refresh-code-browser
Draft

Refresh git metadata after git init#822
srid wants to merge 9 commits intomasterfrom
fix/git-init-refresh-code-browser

Conversation

@srid
Copy link
Copy Markdown
Member

@srid srid commented May 4, 2026

Kolu now notices when a terminal directory becomes a git repo after the Code tab already showed the no-repo state. A newly initialized .git directory updates terminal metadata, which in turn refreshes the Code browser and pill-tree identity without waiting for another cwd change.

The git integration now keeps a lightweight .git entry watcher active while a terminal cwd is unresolved or non-git, then hands off to the existing .git/HEAD watcher once GitInfo resolves. The follow-up review commits make the subscription mode explicit and keep HEAD-vs-entry watcher lifecycle counts separate, so future watcher changes have clearer tests.

Coverage

  • Unit coverage for external git init publishing without setCwd
  • E2E coverage for Code tab leaving Not in a git repository and pill tree switching to repo/branch labels
  • Scoped e2e run: just test-quick features/code-tab.feature features/git-context.feature

Closes #813.

Try it locally

nix run github:juspay/kolu/fix/git-init-refresh-code-browser

Generated by /do on Codex (model gpt-5).

srid added 5 commits May 4, 2026 13:41
Encode subscribeGitInfo watcher mode explicitly so GitInfo null is not the lifecycle flag.
Make subscribeGitInfo tests count HEAD and .git entry watcher events separately.
Track actual HEAD and .git entry watcher activation so probing cannot skip HEAD after repo creation.
Explain why missing cwd realpath failures intentionally become no-op watcher installs.
@srid
Copy link
Copy Markdown
Member Author

srid commented May 4, 2026

Hickey/Lowy Analysis

# Lens Finding Disposition
1 Hickey GitInfo null drives watcher mode Fixed in this PR
2 Hickey Watcher counts hide axis Fixed in this PR

Hickey rationale

The initial implementation used GitInfo | null both as the current metadata value and as the watcher-mode flag. That spread the invariant across subscribeGitInfo: null meant the .git entry watcher should be active, non-null meant HEAD watching should own repo changes. The fix introduced explicit watcher mode ownership and then tightened the implementation to track actual active watcher axes, so a no-op pre-repo HEAD watcher is not mistaken for a live watcher.

The tests also had generic installs / retires counters that only measured HEAD watcher logs. The fix renamed these to HEAD-specific counters and added .git entry watcher counters, so lifecycle assertions describe the resource being measured.

Lowy rationale

No Lowy findings. The new .git entry watcher is a narrow activity boundary for repo-appearance detection, while subscribeGitInfo remains the orchestration boundary for resolving, watching, and publishing metadata. Server and client modules continue to depend only on GitInfo | null, so the repo-appearance volatility stays inside kolu-git.

srid added 4 commits May 4, 2026 14:04
@srid
Copy link
Copy Markdown
Member Author

srid commented May 4, 2026

Evidence

Code tab refreshes after external git init

  • Started a terminal in /tmp/kolu-evidence-git-init-refresh before it was a git repository.
  • Opened the Code tab and verified the no-repo state.
  • Ran git init and checked out code-refresh from outside the browser session.
  • Verified the Code tab refreshed to the empty-changes state and the pill tree showed kolu-evidence-git-init-refresh / code-refresh.

@srid
Copy link
Copy Markdown
Member Author

srid commented May 4, 2026

/do results

Step Status Duration Verification
sync 0s git fetch ok; forge=github; noGit=false
research 3m 45s Issue #813 mapped: CodeTab uses active metadata git repoRoot, pill tree derives terminalKey from git/cwd, subscribeGitInfo only rechecks git init on same-cwd setCwd; fix belongs in packages/integrations/git/src/resolve.ts with tests in packages/integrations/git/src/index.test.ts and packages/tests/features/code-tab.feature
branch 10s Created feature branch fix/git-init-refresh-code-browser from origin/master
implement 2m 22s Added shared .git entry watcher for non-repo cwd metadata, unit coverage for external git init without setCwd, and e2e coverage for Code tab plus pill-tree refresh
check 25s just check exited 0: pnpm typecheck passed across workspace; biome lint completed with warnings but no failing diagnostics
docs 39s Updated README Git/Architecture text and packages/integrations/git/README.md for the .git entry watcher; packages/surface/README.md unchanged because no surface descriptor changed
fmt 12s just fmt completed: Biome and nixpkgs-fmt reported no file changes
commit 21s Committed 19b26e3 (fix: refresh git metadata after external init) and pushed origin/fix/git-init-refresh-code-browser
hickey+lowy 6m 45s Hickey and Lowy completed. Hickey found two fix-in-PR items, addressed by commits 37b8e83 and acc31db; Lowy reported no findings. No unactioned findings remain.
police 3m 8s code-police clean after fixes: rules found no-silent-error-swallowing comment gap fixed in 5e59202; fact-check found active watcher-axis bug fixed in 748ff8e; elegance clean. Focused kolu-git unit tests passed and just check exited 0.
test 39s just test-quick features/code-tab.feature features/git-context.feature passed: 28 scenarios, 304 steps
create-pr 52s Draft PR #822 created at #822 with title/body matching scope; Hickey/Lowy analysis comment posted with two fixed Hickey findings and no Lowy findings
ci 113m 11s CI on 4935654: all expected contexts posted; only ci/e2e@aarch64-darwin remains failing after full retry and targeted retry, both with libc++abi Napi::Error/server-crash flake in .logs/4935654/e2e@aarch64-darwin.log
evidence 0s Posted ## Evidence PR comment with screenshot proving external git init refresh: #822 (comment)
Total 134m 45s

Slowest step: ci (113m 11s)

Optimization suggestions

  • CI dominated this run. For the next attempt, resume from CI only and target CI_SYSTEM=aarch64-darwin just ci::e2e unless code changes again.
  • The repeated Darwin failure is still the known libc++abi ... Napi::Error server-crash path; hardening that test/server crash would remove most retry time for this PR class.
  • Evidence now has a direct Playwright path for this issue, so future reruns can reuse the uploaded screenshot workflow instead of manually revalidating the UI.

Workflow failed at 2026-05-04T19:48:08Z.

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.

Initializing git repo doesn't update Code browser

1 participant