Skip to content

perf: reduce shell and worktree discovery process churn - #1762

Merged
wsp1911 merged 3 commits into
GCWing:mainfrom
wsp1911:dev2
Jul 25, 2026
Merged

perf: reduce shell and worktree discovery process churn#1762
wsp1911 merged 3 commits into
GCWing:mainfrom
wsp1911:dev2

Conversation

@wsp1911

@wsp1911 wsp1911 commented Jul 25, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Cache selected shell validation and successful Node.js availability probes with runtime invalidation.
  • Add a repository-scoped worktree topology cache shared across workspace and hook consumers.
  • Avoid redundant worktree metadata refreshes during normal dialog activity.
  • Harden worktree creation and frontend error reporting.
  • Add a Windows process-event diagnostic probe.

Type and Areas

Type:

Performance / bug fix / test

Areas:

Rust core, terminal services, Git services, workspace services, desktop/Tauri, web UI, diagnostics

Motivation / Impact

Shell discovery, Node.js availability checks, and Git worktree topology queries could repeatedly create short-lived processes on Windows. This added unnecessary startup overhead and process noise during agent commands and workspace activity.

This PR makes shell and Node discovery lazy and reusable, coalesces concurrent probes, and invalidates cached results when the runtime changes or a process fails to spawn.

Worktree topology is now cached by the common Git directory with metadata-based freshness checks and explicit invalidation after mutations. Routine dialog activity only updates workspace activity timestamps instead of reloading Git metadata.

Worktree creation now rejects repositories without an initial commit before creating .worktrees, excludes the managed directory from Git tracking, resolves the newly created checkout directly, and distinguishes creation failures from workspace-opening failures in the UI.

Verification

Manual Windows checks:

  • Started new agent sessions and ran echo 123 and ls with Git Bash, PowerShell 7, and Windows PowerShell.
  • Repeated commands without changing the selected shell and confirmed cached discovery results were reused.
  • Switched between Git Bash and PowerShell and confirmed the selected-shell cache refreshed as expected.
  • Created and opened a linked worktree from an initialized repository successfully.
  • Attempted worktree creation in an empty repository and confirmed it was rejected before creating .worktrees.
  • Used scripts/diagnostics/probe-bitfun-process-events.ps1 to capture process start/stop events and verify BitFun process lineage.

Coverage added for:

  • Shell cache reuse, invalidation, retries, and concurrent probes.
  • Node.js availability cache refresh.
  • Worktree topology cache sharing, metadata refresh, explicit invalidation, and concurrent requests.
  • Worktree creation and unborn-repository rejection.
  • Frontend create-stage and open-stage error classification.

Reviewer Notes

  • Worktree topology entries use a five-minute TTL, metadata fingerprints, mutation invalidation, and a maximum of 64 cached repositories.
  • Main and linked worktrees share one cache entry through their common Git directory.
  • Explicit worktree listing requests force a refresh, while workspace and hook consumers use cached topology.
  • Git worktrees remain unsupported for remote SSH workspaces.
  • The process-event probe is Windows-only and intended for diagnostics.
  • No new user-facing strings were introduced; existing localized error messages are reused.

Checklist

  • This PR is focused and does not include secrets, temporary prompts, generated scratch files, or unrelated artifacts.
  • Relevant verification is recorded above, or skipped checks are explained.
  • User-facing strings, docs, and locales are updated where applicable.

wsp1911 added 2 commits July 25, 2026 22:38
- Resolve the selected local shell lazily instead of scanning the full shell inventory
- Cache shell validation and version probes with fingerprint-based invalidation and single-flight execution
- Invalidate cached shell results after process spawn failures
- Cache successful Node.js availability probes and refresh them during explicit source discovery
- Add coverage for cache reuse, invalidation, failure retries, and concurrent probes
- Cache repository-scoped worktree topology with metadata-based refresh, request coalescing, and explicit invalidation.
- Avoid redundant Git queries during workspace activity tracking and reuse resolved worktree metadata across consumers.
- Reject worktree creation in unborn repositories, exclude managed worktree directories, and resolve new checkouts directly.
- Distinguish worktree creation failures from workspace opening failures in the frontend.
- Add coverage for topology caching, invalidation, worktree creation, and error reporting.
- Add a Windows process-event probe for diagnosing BitFun child process activity.
@wsp1911
wsp1911 merged commit e124723 into GCWing:main Jul 25, 2026
5 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.

1 participant