fix(server): sync pull request draft status changes#22832

merged2
main
t3/sync-pr-draft-sidebar-status
opened1d agobyYYash-Singh1
View on GitHubTwo-way sync enabledPR last imported 20h ago

Problem

The sidebar can keep showing a pull request as a draft after it becomes ready. Its saved status only refreshed when the PR changed between open, closed, or merged, so changes to isDraft were missed.

Change

Track draft status alongside the PR state when detecting changes. Refresh linked thread snapshots when draft status changes, and include draft status in reports from connected environments.

Scope and approval

This is a focused fix for an obvious stale sidebar status. The thread details menu already reads the current draft status, but the sidebar's saved snapshot did not update when only that status changed.

Verification

Ran 162 focused tests, package typechecks for the server, client runtime, and contracts, and lint on the changed files. Lint reported existing warnings. Browser verification was not run.

Checks

All checks passed

Added 2 commits

  • fix(server): sync pull request draft status changes1e4d9ce
  • Merge remote-tracking branch 'origin/main' into t3/sync-pr-draft-sidebar-statusb6f33dc
Synced from GitHub

Approvability

Verdict: Approved at 1e4d9ce

Macroscope's review found this PR approvable — This is a narrowly scoped fix to propagate pull request draft-status transitions through the existing server, routing, and synchronization paths. The contract addition is optional and backward-compatible, and the production behavior is covered by focused tests without changing defaults or static-analysis configuration.

No code changes detected at b6f33dc. Prior analysis still applies.

You can add or adjust custom eligibility rules. Learn more.

Synced from GitHub

Review in Change Stack →

No actionable comments were generated in the recent review. šŸŽ‰

ā„¹ļø Recent review info
āš™ļø Run configuration
  • Configuration used: Path: .coderabbit.config.ts
  • Review profile: CHILL
  • Plan: Team
  • Run ID: 781a0ed8-3bf7-427b-9bc7-281826f77634
šŸ“„ Commits

Reviewing files that changed from the base of the PR and between 96f09c6558b098f05ad0c027afa3846209c03d4f and b6f33dc7d0cad8ba8cf7492819f2be5940dfa12b.

šŸ“’ Files selected for processing: 8
  • apps/server/src/git/GitManager.test.ts
  • apps/server/src/git/GitManager.ts
  • apps/server/src/orchestration-v2/PullRequestSyncReactor.test.ts
  • apps/server/src/pullRequest/PullRequestService.test.ts
  • apps/server/src/pullRequest/PullRequestService.ts
  • packages/client-runtime/src/state/pullRequestRouting.ts
  • packages/client-runtime/src/state/pullRequests.test.ts
  • packages/contracts/src/pullRequest.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

šŸ“ Walkthrough

Pull request state reporting and change detection now include optional draft status. The server publishes changes when draft status changes, deduplicates reports using both state and draft status, and synchronizes updated status.

Changes: Draft-status propagation

Layer / File(s)Summary
Status contract and routed propagation
packages/contracts/src/pullRequest.ts, packages/client-runtime/src/state/pullRequestRouting.ts, packages/client-runtime/src/state/pullRequests.test.ts
The report-state contract accepts optional isDraft. Client routing forwards it when present, and detail-read tests cover absent, true, and false values.
Server-side draft change detection
apps/server/src/pullRequest/PullRequestService.ts, apps/server/src/git/GitManager.ts, apps/server/src/pullRequest/PullRequestService.test.ts, apps/server/src/git/GitManager.test.ts
Pull request detail readings and Git lookup state include draft status. The server publishes notifications when state or draft status changes. Tests cover draft transitions and stale reads.
State report deduplication and sync
apps/server/src/pullRequest/PullRequestService.ts, apps/server/src/pullRequest/PullRequestService.test.ts, apps/server/src/orchestration-v2/PullRequestSyncReactor.test.ts
The server deduplicates reports using both state and draft status. Reactor tests verify cache invalidation and synchronization with the updated draft status.

Priority: ā¬‡ļø Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

mermaid
1sequenceDiagram
2 participant ClientRuntime
3 participant PullRequestService
4 participant PullRequestSyncReactor
5 participant SyncCommand
6 ClientRuntime->>PullRequestService: Report state with optional isDraft
7 PullRequestService->>PullRequestSyncReactor: Publish state-change event
8 PullRequestSyncReactor->>PullRequestSyncReactor: Invalidate pull request cache
9 PullRequestSyncReactor->>SyncCommand: Dispatch updated isDraft value

Suggested reviewers: t3dotgg, flamboh

Merge Risk: ⚪ Minimal · up to b6f33

Draft-status propagation is mergeable after normal checks; no outstanding issue is supported by the reviewed evidence.

Pre-merge checks: Passed 4
Check nameStatusExplanation
Title checkPassedThe title is concise, uses the repository's conventional format, and clearly describes syncing pull request draft status changes.
Description checkPassedThe description includes all required sections. It explains the stale-status problem, the implementation change, the focused scope justification, and the verification performed, including limitations.
Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
✨ Finishing Touches
šŸ“ Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix Ā· Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Synced from GitHub

Thread transfer impact

āœ… Thread transfer remains within every enforced ceiling.

ProviderMetricMain baselineThis PRImpactPR ceiling
CodexTotal thread wire5.0 KiB5.0 KiB+7 B (+0.1%)6.8 KiBāœ…
CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiBāœ…
CodexLive turn WebSocket wire1.2 KiB1.2 KiB+7 B (+0.6%)2.0 KiBāœ…
CodexLive turn WebSocket decoded20.9 KiB20.9 KiB0 B (0.0%)29.3 KiBāœ…
CodexLive turn messages220 (0.0%)8āœ…
ClaudeTotal thread wire5.0 KiB5.0 KiBāˆ’7 B (āˆ’0.1%)6.8 KiBāœ…
ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiBāœ…
ClaudeLive turn WebSocket wire1.2 KiB1.2 KiBāˆ’7 B (āˆ’0.6%)2.0 KiBāœ…
ClaudeLive turn WebSocket decoded21.2 KiB21.2 KiB0 B (0.0%)29.3 KiBāœ…
ClaudeLive turn messages220 (0.0%)8āœ…

Baseline: 96f09c6 Ā· PR result: b6f33dc Ā· Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.