Skip to content

fix (desktop): git status to not locking anymore#739

Merged
AviPeltz merged 3 commits into
mainfrom
lock-git-status
Jan 13, 2026
Merged

fix (desktop): git status to not locking anymore#739
AviPeltz merged 3 commits into
mainfrom
lock-git-status

Conversation

@AviPeltz
Copy link
Copy Markdown
Collaborator

@AviPeltz AviPeltz commented Jan 13, 2026

Description

Related Issues

Type of Change

  • Bug fix
  • New feature
  • Documentation
  • Refactor
  • Other (please describe):

Testing

Screenshots (if applicable)

Additional Notes

Summary by CodeRabbit

  • Bug Fixes

    • Improved repository status checks to avoid lock conflicts during concurrent operations.
    • Enhanced detection of uncommitted changes and branch checkout safety to reduce false positives and failures.
  • Chores

    • More robust error handling and remote state refresh during safety checks for more reliable operations.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 13, 2026

Warning

Rate limit exceeded

@AviPeltz has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 1 minutes and 28 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 9ff2728 and 025ed8c.

📒 Files selected for processing (1)
  • apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts
📝 Walkthrough

Walkthrough

Adds a new getStatusNoLock function that runs git status with --no-optional-locks and porcelain parsing, replaces git.status() calls with it, updates safety checks and uncommitted-change detection, enhances error handling, and runs a fetch --prune during branch checkout safety validation.

Changes

Cohort / File(s) Summary
Status Endpoint Update
apps/desktop/src/lib/trpc/routers/changes/status.ts
Replaced git.status() with getStatusNoLock(input.worktreePath) import; now retrieves status via the no-locks parser.
Git Utilities Refactor
apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts
Added getStatusNoLock(repoPath: string) that invokes git status --no-optional-locks -z --porcelain=v1 -b -M, parses branch and file info into a StatusResult-like shape; updated hasUncommittedChanges and checkBranchCheckoutSafety to use it; improved error handling and added fetch --prune in safety flow.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰
A nibble of code, no locks in sight,
I hop through branches in morning light.
Porcelain whispers, status all clear,
Fetch and prune — the branches cheer! ✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description contains only template headings with no substantive content filled in; the Type of Change checkbox is marked but all descriptive sections are empty. Fill in the Description section explaining the lock issue and solution, add Related Issues if applicable, and provide Testing details on how the no-lock changes were verified.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: replacing git status to use no-lock mode, which matches the core objective of the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts:
- Around line 193-207: The code pushes the same path into the modified array
twice when indexStatus === "M" and workingStatus === "M"; change the logic in
the block handling indexStatus and workingStatus (the branches that push to
modified, staged, deleted, conflicted — e.g., where indexStatus is checked and
where workingStatus is checked) to avoid duplicate pushes by checking whether
the path is already present before pushing (or use a temporary Set for
modified/staged/deleted/conflicted and convert back to arrays at the end),
ensuring staged still gets its push for indexStatus === "M" but modified is only
added once.
🧹 Nitpick comments (2)
apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts (2)

213-231: Consider using empty array for ignored to match StatusResult type.

The StatusResult type from simple-git defines ignored as string[]. Setting it to undefined may cause type mismatches in consuming code that expects an array.

♻️ Suggested change
 	return {
 		not_added,
 		conflicted,
 		created,
 		deleted,
-		ignored: undefined,
+		ignored: [],
 		modified,

105-105: Typo in function name: "Portelain" should be "Porcelain".

♻️ Suggested fix
-function parsePortelainStatus(stdout: string): StatusResult {
+function parsePorcelainStatus(stdout: string): StatusResult {

Also update the call site at line 82:

-		return parsePortelainStatus(stdout);
+		return parsePorcelainStatus(stdout);
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9b697a3 and 9ff2728.

📒 Files selected for processing (1)
  • apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts
🧰 Additional context used
📓 Path-based instructions (4)
apps/desktop/**/*.{ts,tsx}

📄 CodeRabbit inference engine (apps/desktop/AGENTS.md)

apps/desktop/**/*.{ts,tsx}: For Electron interprocess communication, ALWAYS use tRPC as defined in src/lib/trpc
Use alias as defined in tsconfig.json when possible
Prefer zustand for state management if it makes sense. Do not use effect unless absolutely necessary.
For tRPC subscriptions with trpc-electron, ALWAYS use the observable pattern from @trpc/server/observable instead of async generators, as the library explicitly checks isObservable(result) and throws an error otherwise

Files:

  • apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use object parameters for functions with 2+ parameters instead of positional arguments
Functions with 2+ parameters should accept a single params object with named properties for self-documentation and extensibility
Use prefixed console logging with context pattern: [domain/operation] message
Extract magic numbers and hardcoded values to named constants at module top
Use lookup objects/maps instead of repeated if (type === ...) conditionals
Avoid using any type - maintain type safety in TypeScript code
Never swallow errors silently - at minimum log them with context
Import from concrete files directly when possible - avoid barrel file abuse that creates circular dependencies
Avoid deep nesting (4+ levels) - use early returns, extract functions, and invert conditions
Use named properties in options objects instead of boolean parameters to avoid boolean blindness

Files:

  • apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts
apps/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use Drizzle ORM for all database operations - never use raw SQL

Files:

  • apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use Biome for formatting and linting - run at root level with bun run lint:fix or biome check --write

Files:

  • apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build
🔇 Additional comments (4)
apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts (4)

6-6: LGTM!

The type-only import of StatusResult is correctly added to support the new getStatusNoLock function's return type.


54-98: LGTM!

The getStatusNoLock function is well-designed:

  • Uses --no-optional-locks to prevent blocking other git operations
  • Porcelain v1 with -z ensures reliable parsing of filenames with special characters
  • -M enables rename detection for accurate status
  • Good error handling with descriptive messages for common failure modes

581-586: LGTM!

The update to use getStatusNoLock aligns with the PR objective to prevent git locking during status checks.


893-949: LGTM!

The safety check function now correctly uses getStatusNoLock to avoid blocking other git operations while checking for uncommitted changes before branch checkout. The separate simpleGit instance for the fetch operation is appropriate since it's a distinct, best-effort network operation.

Comment thread apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts Outdated
@AviPeltz AviPeltz merged commit 7ab29c5 into main Jan 13, 2026
5 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ⚠️ Neon database branch
  • ⚠️ Electric Fly.io app

Thank you for your contribution! 🎉

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