Skip to content

Git integration, shared errors, and composer agent/branch UX - #52

Merged
soorya-u merged 5 commits into
mainfrom
error-refactor
Jul 13, 2026
Merged

soorya-u merged 5 commits into
mainfrom
error-refactor

Conversation

@soorya-u

@soorya-u soorya-u commented Jul 13, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Add git integration for thread worktrees, branch checkout, status/refs APIs, and a branch-aware diff panel.
  • Introduce @cyrus/errors with repository HOF wrappers and typed error adapters for oRPC, git, and coordinator flows.
  • Improve composer UX: load agents at composer level with skeleton/empty states, branch/workspace toolbar below the composer, and git init from the thread header.
  • Harden ACP session handling: rebind on stale resume failure, fix idle pool unhandled rejections, and use mutation callbacks for thread creation errors.

Test plan

  • bun check
  • bun check:types
  • bun test:unit
  • bun test:integration
  • Create a thread and confirm navigation without unhandled rejections
  • Initialize git on a project and verify composer branch toolbar + diff panel
  • Restart worker with an existing bound session and confirm resume rebinds instead of spamming errors
  • Switch agents on a new thread and confirm picker does not flicker

Made with Cursor

Summary by CodeRabbit

  • New Features
    • Added Git integration for repository status, patches, branch browsing, checkout, and worktree management.
    • Added branch selection and workspace controls when creating or using threads.
    • Added Git initialization for projects that are not yet repositories.
    • Updated the Diff panel to show working-tree file changes with insertion/deletion counts.
    • Added clearer loading and unavailable states when no agents are configured.
  • Bug Fixes
    • Improved error handling for thread creation, agent sessions, and background shutdown tasks.
  • Documentation
    • Added Git integration specifications and implementation guidance.

soorya-u and others added 3 commits July 13, 2026 08:38
Threads can be created from git refs with isolated worktrees, and the web UI surfaces branch context, checkout, and diff viewing against the project repo.

Co-authored-by: Cursor <cursoragent@cursor.com>
Centralize tagged errors with module-prefixed tags, derive ORPC codes on instances, map Drizzle/Zod failures in database adapters, and replace tryRepo wrappers with repo/repoArgs across repositories.

Co-authored-by: Cursor <cursoragent@cursor.com>
Move branch and workspace controls into the composer, load agents at composer level with loading states, and rebind stale sessions on resume failure instead of spamming unhandled rejections.

Co-authored-by: Cursor <cursoragent@cursor.com>
@vercel

vercel Bot commented Jul 13, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cyrus Ready Ready Preview, Comment Jul 13, 2026 5:27pm

@coderabbitai

coderabbitai Bot commented Jul 13, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

@soorya-u, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 25 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a280a7b0-7e67-415e-863f-3a3396c29948

📥 Commits

Reviewing files that changed from the base of the PR and between d339807 and f57d769.

📒 Files selected for processing (28)
  • apps/cli/src/core/threads/coordinator.ts
  • apps/cli/src/git/git.test.ts
  • apps/cli/src/git/patch.ts
  • apps/cli/src/git/paths.ts
  • apps/cli/src/git/status.ts
  • apps/cli/src/git/worktree.ts
  • apps/cli/src/handlers/controller/git.ts
  • apps/cli/src/handlers/controller/threads.ts
  • apps/web/src/components/chat/composer/agent-model-picker.tsx
  • apps/web/src/components/chat/main/thread-header.tsx
  • openspec/changes/archive/2026-07-13-git-integration/.openspec.yaml
  • openspec/changes/archive/2026-07-13-git-integration/design.md
  • openspec/changes/archive/2026-07-13-git-integration/proposal.md
  • openspec/changes/archive/2026-07-13-git-integration/specs/git-diff-panel/spec.md
  • openspec/changes/archive/2026-07-13-git-integration/specs/git-thread-context/spec.md
  • openspec/changes/archive/2026-07-13-git-integration/specs/git-worker-service/spec.md
  • openspec/changes/archive/2026-07-13-git-integration/specs/wire-schemas/spec.md
  • openspec/changes/archive/2026-07-13-git-integration/tasks.md
  • openspec/specs/git-diff-panel/spec.md
  • openspec/specs/git-thread-context/spec.md
  • openspec/specs/git-worker-service/spec.md
  • openspec/specs/wire-schemas/spec.md
  • shared/database/src/repositories/conversations.ts
  • shared/database/src/repositories/projects.ts
  • shared/database/src/utils/repo.test.ts
  • shared/hooks/src/connection/use-agent-catalog.ts
  • shared/hooks/src/stores/agent-catalog.ts
  • shared/schemas/src/rtc/git.ts
📝 Walkthrough

Walkthrough

This PR adds Git repository integration across schemas, persistence, CLI services, controller RPCs, React Query hooks, thread creation, branch/worktree controls, and a Git-backed diff panel. It also introduces shared typed error modules and repository error wrappers.

Changes

Git integration

Layer / File(s) Summary
Contracts and typed errors
shared/schemas/src/rtc/*, shared/errors/*, shared/connections/src/contracts/controller.ts
Adds Git schemas, RPC contracts, operation keys, shared repository/coordinator/Git errors, and direct ORPC error throwing.
Thread persistence and repository execution
shared/database/src/models/threads.ts, shared/database/src/repositories/*, shared/database/src/utils/*
Stores branch/worktree metadata, resolves effective Git cwd, and standardizes repository error handling.
Worker Git services
apps/cli/src/git/*
Adds status, patch, refs, checkout, initialization, and worktree operations with Git-specific results and tests.
Controller and coordinator flow
apps/cli/src/handlers/controller/*, apps/cli/src/core/threads/coordinator.ts
Registers Git RPC handlers, applies thread/project cwd resolution, and manages branch checkout and worktree cleanup.
Client hooks and catalog state
shared/hooks/src/connection/*, shared/hooks/src/stores/agent-catalog.ts
Adds Git queries/mutations and invalidation, agent loading, callback-based thread creation, and display-selection state.
Composer and diff UI
apps/web/src/components/chat/*, apps/web/src/components/sidebar/projects/*
Adds branch/workspace controls, agent loading states, Git repository initialization, and a file-based Git diff panel.
Specifications and supporting changes
openspec/changes/git-integration/*, apps/web/src/index.css, apps/web/src/hooks/auth/*
Documents the Git integration contracts and updates supporting UI, authentication guards, and development configuration.

Estimated code review effort: 5 (Critical) | ~120 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the PR’s main themes: Git integration, shared error handling, and composer UX improvements.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch error-refactor

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 9

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
shared/database/src/repositories/projects.ts (1)

45-57: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

DB write before schema validation in createProject and writeProjectName. Both functions persist to the database before running ProjectSchema.parse(), so if validation fails (e.g., empty name), the invalid row is already committed and repoArgs only catches the error after the damage is done.

  • shared/database/src/repositories/projects.ts#L45-L57: Move ProjectSchema.parse() before the connection.db.insert() call in createProject.
  • shared/database/src/repositories/projects.ts#L60-L67: Move ProjectSchema.parse() before the connection.db.update() call in writeProjectName.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@shared/database/src/repositories/projects.ts` around lines 45 - 57, In
shared/database/src/repositories/projects.ts lines 45-57, update createProject
to run ProjectSchema.parse() on the new project data before
connection.db.insert(), and persist only the validated result. In
shared/database/src/repositories/projects.ts lines 60-67, apply the same
ordering in writeProjectName by validating the updated project before
connection.db.update().

Source: Learnings

🧹 Nitpick comments (9)
shared/errors/src/orpc.ts (1)

10-11: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider whether EmptyPayload is needed in this module.

EmptyPayload is exported but not referenced in any of the provided files. If it's used elsewhere in the @cyrus/errors package or by consumers, this is fine. If not, it adds unused surface area to a new module.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@shared/errors/src/orpc.ts` around lines 10 - 11, Verify whether EmptyPayload
is referenced elsewhere in the `@cyrus/errors` package or by consumers; if no
usages exist, remove the emptyPayloadBrand declaration and exported EmptyPayload
type from this module. Retain the type only if it is part of an existing public
API contract.
apps/cli/src/handlers/controller/git.ts (1)

67-78: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Orphaned worktree if DB update fails in createGitWorktree.

If updateThreadWorktreePath fails at line 78, the worktree has already been created on disk (line 67–71) but the thread doesn't reference it. Consider cleaning up the worktree on DB update failure to avoid resource leaks.

♻️ Proposed cleanup on failure
 		const updated = await updateThreadWorktreePath(
 			input.threadId,
 			worktree.value
 		);
-		if (updated.isErr()) throwOrpc(updated.error);
+		if (updated.isErr()) {
+			await Result.tryPromise(() =>
+				removeGitWorktree(projectCwd.value, worktree.value)
+			);
+			throwOrpc(updated.error);
+		}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/cli/src/handlers/controller/git.ts` around lines 67 - 78, Update the
flow around createGitWorktree and updateThreadWorktreePath so that when the
database update fails, the newly created worktree is cleaned up before
propagating the error. Preserve the existing successful update path and error
propagation behavior.
apps/cli/src/git/worktree.ts (1)

46-60: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

No timeout on Bun.spawn for git worktree remove.

If the subprocess hangs (e.g., locked files on Windows, git deadlock), proc.exited never resolves and the promise blocks indefinitely. Consider passing an AbortSignal with a timeout to Bun.spawn so the operation fails fast instead of hanging the caller.

♻️ Suggested timeout via AbortController
 	return (
 		await Result.tryPromise(async () => {
+			const controller = new AbortController();
+			const timeout = setTimeout(() => controller.abort(), 10_000);
 			const proc = Bun.spawn(
 				["git", "worktree", "remove", worktreePath, "--force"],
 				{
 					cwd: projectCwd,
 					stdout: "pipe",
 					stderr: "pipe",
+					signal: controller.signal,
 				}
 			);
 			const exitCode = await proc.exited;
+			clearTimeout(timeout);
 			if (exitCode !== 0) {
 				const stderr = await new Response(proc.stderr).text();
 				throw new Error(stderr.trim() || "Failed to remove worktree");
 			}
 		})
 	).mapError((error) =>
 		operationFailedError(error instanceof Error ? error.message : String(error))
 	);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/cli/src/git/worktree.ts` around lines 46 - 60, Update the git worktree
removal flow in the Result.tryPromise callback to create a timed AbortController
and pass its signal to Bun.spawn. Ensure the timeout aborts the subprocess so
awaiting proc.exited fails promptly, while preserving the existing nonzero-exit
stderr handling.
apps/cli/src/git/status.ts (1)

49-52: 🚀 Performance & Scalability | 🔵 Trivial | 🏗️ Heavy lift

Avoid recomputing the diff for every file. es-git’s Delta API doesn’t expose per-file insertion/deletion counts, so this loop still does O(n) diff work. Derive the per-file counts from the single diff you already have instead of calling diffTreeToWorkdirWithIndex again for each path.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/cli/src/git/status.ts` around lines 49 - 52, Update the file-status flow
around the existing single diff computation to derive each file’s insertion and
deletion counts from that diff, rather than calling
repo.diffTreeToWorkdirWithIndex inside the per-file loop. Reuse the existing
diff entries and preserve the current per-path status output.
shared/schemas/src/rtc/git.ts (1)

52-54: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider .min(1) on threadId for consistency with other identifier fields.

refName in GitCheckoutInputSchema/GitCreateWorktreeInputSchema requires non-empty strings, but ThreadGitQueryInputSchema.threadId (the base for most Git input schemas) doesn't. Tightening this would reject malformed empty-string thread IDs at the schema boundary rather than downstream.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@shared/schemas/src/rtc/git.ts` around lines 52 - 54, Update
ThreadGitQueryInputSchema.threadId to require a non-empty string using the same
minimum-length validation applied to refName in GitCheckoutInputSchema and
GitCreateWorktreeInputSchema; leave the surrounding schema structure unchanged.
apps/web/src/components/chat/main/thread-header.tsx (1)

43-53: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Add aria-pressed to the Diffs toggle button.

The button visually toggles based on diffOpen but doesn't expose this state to assistive technology.

♿ Proposed fix
 				<button
+					aria-pressed={diffOpen}
 					className={
 						diffOpen
 							? "inline-flex h-7 items-center gap-1 rounded-md bg-primary px-2 font-medium text-primary-foreground text-xs"
 							: "inline-flex h-7 items-center gap-1 rounded-md bg-muted/70 px-2 font-medium text-foreground text-xs hover:bg-muted"
 					}
 					onClick={toggleDiffOpen}
 					type="button"
 				>
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/web/src/components/chat/main/thread-header.tsx` around lines 43 - 53,
Update the Diffs toggle button in the thread header, identified by its onClick
handler toggleDiffOpen, to include an aria-pressed attribute bound to the
diffOpen state so assistive technology receives the current toggle status.
shared/database/src/repositories/conversations.ts (1)

20-45: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Insert + parent update aren't wrapped in a transaction.

If the threads.updatedAt update fails after the conversation row insert succeeds, the two writes drift out of sync. This behavior predates this diff (only the wrapping utility changed here), but since the block is being touched, consider wrapping both writes in connection.db.transaction(...) for atomicity.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@shared/database/src/repositories/conversations.ts` around lines 20 - 45, Wrap
the insert into conversations and the parent threads.updatedAt update within a
single connection.db.transaction in appendConversation, preserving the existing
values, failure handling, and parsed return behavior while ensuring both writes
commit or roll back together.
shared/database/src/utils/repo.test.ts (1)

35-35: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Minor: z.string().uuid() is deprecated in Zod v4.

Functionally fine (still supported), but z.uuid() is the current top-level form; consider updating for consistency with newer Zod idioms.

Also applies to: 59-59, 103-103

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@shared/database/src/utils/repo.test.ts` at line 35, Update the Zod UUID
schema usages in the test cases around the `cause` declarations, including the
occurrences at the referenced lines, replacing the deprecated
`z.string().uuid()` form with the current top-level `z.uuid()` form while
preserving the existing validation behavior.
shared/hooks/src/connection/use-git.ts (1)

10-92: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Repeated conditional query pattern across 5 hooks; invalidateThreadGitQueries duplicates invalidateGitQueries.

useGitStatus, useGitPatch, useProjectGitStatus, useProjectGitRefs, and useListGitRefs all repeat the same "id present → real query, else skipToken" ternary shape. Also, invalidateThreadGitQueries (154-159) is just a same-signature pass-through of invalidateGitQueries. Could be consolidated, though not urgent.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@shared/hooks/src/connection/use-git.ts` around lines 10 - 92, Consolidate the
repeated enabled-identifier/skipToken query setup used by useGitStatus,
useGitPatch, useProjectGitStatus, useProjectGitRefs, and useListGitRefs into a
shared helper or consistent abstraction, while preserving each hook’s query keys
and inputs. Remove the redundant invalidateThreadGitQueries pass-through and use
invalidateGitQueries directly at its call sites.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/cli/src/core/threads/coordinator.ts`:
- Around line 135-138: Update the same-agent branch in the coordinator’s
session-close flow to handle the result of withRuntime instead of ignoring it.
Return or propagate a close error consistently with the other branch so
new-session creation does not proceed after a failed close, unless this cleanup
is explicitly intended to be best effort and documented accordingly.

In `@apps/cli/src/git/patch.ts`:
- Line 7: Update the diff retrieval flow around the repository-open check and
diff.print() failure handling so git operation errors are propagated or surfaced
through the established error-reporting mechanism instead of returning an
indistinguishable empty string. Preserve the empty-string result only for a
genuine no-changes diff, using the surrounding function’s existing error
contract.
- Line 9: Wrap the complete git operation in getGitPatch, including
opened.value.head().peelToTree() and diff.print(), inside the existing
Result.try so errors from unborn HEAD repositories are captured and returned
rather than becoming unhandled rejections.

In `@apps/cli/src/git/status.ts`:
- Around line 77-86: Update the `status.match` error branch to preserve and
surface the failure instead of silently returning a clean-repository result: log
the caught error there and add the requested optional error indicator to
`GitStatusOutput`, populating it from the failure while retaining the existing
status fields for compatibility.

In `@apps/cli/src/handlers/controller/git.ts`:
- Around line 83-86: Update the removeGitWorktree handler to explicitly detect a
missing thread after getThread succeeds and throw the established notFound error
via throwOrpc, matching createGitWorktree. Keep the existing worktreePath
absence behavior unchanged for threads that do exist.
- Around line 39-42: Restrict GitCreateWorktreeInputSchema and the
createGitWorktree flow to repository-relative paths: reject absolute paths and
traversal that escapes the thread repository before passing the value to mkdir
or git worktree add. Leave getGitPatch unchanged because its path is only a git
pathspec.

In `@apps/cli/src/handlers/controller/threads.ts`:
- Around line 28-42: Update createThread to inspect the Result returned by
tryCheckoutGitRef and propagate its error instead of returning success when
checkout fails. Update deleteThread to inspect the Result from removeGitWorktree
and log cleanup failures using the existing logging mechanism, while preserving
successful deletion behavior.

In `@apps/web/src/components/chat/composer/agent-model-picker.tsx`:
- Line 75: Update the trigger label expression in the agent model picker to
retain a minimal fallback when both activeModel?.name and activeAgent?.name are
unavailable. Preserve the existing preference order and ensure the button
renders a non-empty label such as the prior “Agent” fallback.

In `@shared/hooks/src/connection/use-agent-catalog.ts`:
- Around line 198-208: Reset the per-thread resume-bind request flag in the bind
mutation completion paths so failures and completed binds can be retried when
appropriate. Update the mutation error/success handling associated with
bindAgentMutation and use the existing resumeBindRequestedByThread state
helpers, while preserving the current guard and markResumeBindRequested flow.

---

Outside diff comments:
In `@shared/database/src/repositories/projects.ts`:
- Around line 45-57: In shared/database/src/repositories/projects.ts lines
45-57, update createProject to run ProjectSchema.parse() on the new project data
before connection.db.insert(), and persist only the validated result. In
shared/database/src/repositories/projects.ts lines 60-67, apply the same
ordering in writeProjectName by validating the updated project before
connection.db.update().

---

Nitpick comments:
In `@apps/cli/src/git/status.ts`:
- Around line 49-52: Update the file-status flow around the existing single diff
computation to derive each file’s insertion and deletion counts from that diff,
rather than calling repo.diffTreeToWorkdirWithIndex inside the per-file loop.
Reuse the existing diff entries and preserve the current per-path status output.

In `@apps/cli/src/git/worktree.ts`:
- Around line 46-60: Update the git worktree removal flow in the
Result.tryPromise callback to create a timed AbortController and pass its signal
to Bun.spawn. Ensure the timeout aborts the subprocess so awaiting proc.exited
fails promptly, while preserving the existing nonzero-exit stderr handling.

In `@apps/cli/src/handlers/controller/git.ts`:
- Around line 67-78: Update the flow around createGitWorktree and
updateThreadWorktreePath so that when the database update fails, the newly
created worktree is cleaned up before propagating the error. Preserve the
existing successful update path and error propagation behavior.

In `@apps/web/src/components/chat/main/thread-header.tsx`:
- Around line 43-53: Update the Diffs toggle button in the thread header,
identified by its onClick handler toggleDiffOpen, to include an aria-pressed
attribute bound to the diffOpen state so assistive technology receives the
current toggle status.

In `@shared/database/src/repositories/conversations.ts`:
- Around line 20-45: Wrap the insert into conversations and the parent
threads.updatedAt update within a single connection.db.transaction in
appendConversation, preserving the existing values, failure handling, and parsed
return behavior while ensuring both writes commit or roll back together.

In `@shared/database/src/utils/repo.test.ts`:
- Line 35: Update the Zod UUID schema usages in the test cases around the
`cause` declarations, including the occurrences at the referenced lines,
replacing the deprecated `z.string().uuid()` form with the current top-level
`z.uuid()` form while preserving the existing validation behavior.

In `@shared/errors/src/orpc.ts`:
- Around line 10-11: Verify whether EmptyPayload is referenced elsewhere in the
`@cyrus/errors` package or by consumers; if no usages exist, remove the
emptyPayloadBrand declaration and exported EmptyPayload type from this module.
Retain the type only if it is part of an existing public API contract.

In `@shared/hooks/src/connection/use-git.ts`:
- Around line 10-92: Consolidate the repeated enabled-identifier/skipToken query
setup used by useGitStatus, useGitPatch, useProjectGitStatus, useProjectGitRefs,
and useListGitRefs into a shared helper or consistent abstraction, while
preserving each hook’s query keys and inputs. Remove the redundant
invalidateThreadGitQueries pass-through and use invalidateGitQueries directly at
its call sites.

In `@shared/schemas/src/rtc/git.ts`:
- Around line 52-54: Update ThreadGitQueryInputSchema.threadId to require a
non-empty string using the same minimum-length validation applied to refName in
GitCheckoutInputSchema and GitCreateWorktreeInputSchema; leave the surrounding
schema structure unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1c9332b1-284b-4124-841d-00cd472fdb92

📥 Commits

Reviewing files that changed from the base of the PR and between 6dfd1f7 and d339807.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (78)
  • apps/cli/__tests__/integration/draft-session-lifecycle.test.ts
  • apps/cli/package.json
  • apps/cli/src/core/acp/pool.ts
  • apps/cli/src/core/agents/runtime.ts
  • apps/cli/src/core/threads/coordinator.ts
  • apps/cli/src/errors/coordinator.ts
  • apps/cli/src/git/checkout.ts
  • apps/cli/src/git/diff-options.ts
  • apps/cli/src/git/git.test.ts
  • apps/cli/src/git/init.ts
  • apps/cli/src/git/open.ts
  • apps/cli/src/git/patch.ts
  • apps/cli/src/git/paths.ts
  • apps/cli/src/git/refs.ts
  • apps/cli/src/git/status.ts
  • apps/cli/src/git/worktree.ts
  • apps/cli/src/handlers/controller/agents.ts
  • apps/cli/src/handlers/controller/catalog/effort.ts
  • apps/cli/src/handlers/controller/catalog/mode.ts
  • apps/cli/src/handlers/controller/catalog/model.ts
  • apps/cli/src/handlers/controller/catalog/persona.ts
  • apps/cli/src/handlers/controller/chat.ts
  • apps/cli/src/handlers/controller/git.ts
  • apps/cli/src/handlers/controller/index.ts
  • apps/cli/src/handlers/controller/projects.ts
  • apps/cli/src/handlers/controller/threads.ts
  • apps/cli/src/utils/error.ts
  • apps/web/src/components/chat/composer/agent-model-picker.tsx
  • apps/web/src/components/chat/composer/compact-composer-controls.tsx
  • apps/web/src/components/chat/composer/composer-branch-toolbar.tsx
  • apps/web/src/components/chat/composer/composer-skeleton.tsx
  • apps/web/src/components/chat/composer/composer-unavailable.tsx
  • apps/web/src/components/chat/composer/footer-controls.tsx
  • apps/web/src/components/chat/composer/index.tsx
  • apps/web/src/components/chat/diff/diff-panel.tsx
  • apps/web/src/components/chat/main/thread-header.tsx
  • apps/web/src/components/chat/main/thread-workspace.tsx
  • apps/web/src/components/settings/settings-section-panel.tsx
  • apps/web/src/components/sidebar/projects/project-thread-explorer.tsx
  • apps/web/src/devtools.tsx
  • apps/web/src/hooks/auth/use-error-listener.ts
  • apps/web/src/index.css
  • openspec/changes/git-integration/.openspec.yaml
  • openspec/changes/git-integration/design.md
  • openspec/changes/git-integration/proposal.md
  • openspec/changes/git-integration/specs/git-diff-panel/spec.md
  • openspec/changes/git-integration/specs/git-thread-context/spec.md
  • openspec/changes/git-integration/specs/git-worker-service/spec.md
  • openspec/changes/git-integration/specs/wire-schemas/spec.md
  • openspec/changes/git-integration/tasks.md
  • shared/connections/src/contracts/controller.ts
  • shared/constants/src/operation-keys.ts
  • shared/database/package.json
  • shared/database/src/models/threads.ts
  • shared/database/src/repositories/conversations.ts
  • shared/database/src/repositories/git.ts
  • shared/database/src/repositories/projects.ts
  • shared/database/src/repositories/threads.ts
  • shared/database/src/utils/error.ts
  • shared/database/src/utils/repo.test.ts
  • shared/database/src/utils/repo.ts
  • shared/errors/package.json
  • shared/errors/src/common.ts
  • shared/errors/src/coordinator.ts
  • shared/errors/src/git.ts
  • shared/errors/src/orpc.ts
  • shared/errors/src/repository.ts
  • shared/errors/tsconfig.json
  • shared/hooks/src/connection/use-agent-catalog.ts
  • shared/hooks/src/connection/use-controller-threads.ts
  • shared/hooks/src/connection/use-git.ts
  • shared/hooks/src/connection/use-list-agents.ts
  • shared/hooks/src/connection/use-threads.ts
  • shared/hooks/src/stores/agent-catalog.ts
  • shared/schemas/src/rtc/common.ts
  • shared/schemas/src/rtc/git.ts
  • shared/schemas/src/rtc/threads.test.ts
  • shared/schemas/src/rtc/threads.ts
💤 Files with no reviewable changes (3)
  • apps/cli/src/utils/error.ts
  • apps/cli/src/errors/coordinator.ts
  • shared/database/src/utils/error.ts

Comment thread apps/cli/src/core/threads/coordinator.ts Outdated
Comment thread apps/cli/src/git/patch.ts Outdated
Comment thread apps/cli/src/git/patch.ts Outdated
Comment thread apps/cli/src/git/status.ts Outdated
Comment thread apps/cli/src/handlers/controller/git.ts
Comment thread apps/cli/src/handlers/controller/git.ts Outdated
Comment thread apps/cli/src/handlers/controller/threads.ts
Comment thread apps/web/src/components/chat/composer/agent-model-picker.tsx Outdated
Comment thread shared/hooks/src/connection/use-agent-catalog.ts
soorya-u and others added 2 commits July 13, 2026 22:41
Move the completed change to openspec/changes/archive and add git-diff-panel, git-thread-context, and git-worker-service main specs.

Co-authored-by: Cursor <cursoragent@cursor.com>
Harden git/worker flows with typed errors and Result returns, use es-git for worktree removal, and fix session bind, schema validation, and composer edge cases raised in review.

Co-authored-by: Cursor <cursoragent@cursor.com>
@soorya-u soorya-u linked an issue Jul 13, 2026 that may be closed by this pull request
@soorya-u
soorya-u merged commit 251e758 into main Jul 13, 2026
7 checks passed
@soorya-u
soorya-u deleted the error-refactor branch July 13, 2026 17:29
soorya-u added a commit that referenced this pull request Jul 13, 2026
Reflect merged PRs #51 and #52 in OpenSpec artifacts: thread worktree cwd for attachments, composer agent-loading patterns, and feed vs git diff distinction for permissions.

Co-authored-by: Cursor <cursoragent@cursor.com>

This branch was successfully deployed

1 active deployment
Preview — f57d769e Deployed Jul 13, 2026 by vercel[bot]
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.

Integrate Git to check diffs, worktree support and branch switches

1 participant