Skip to content

feat(PRO-547): bidirectional comment sync between the CLI and GitHub#70

Open
dastratakos wants to merge 17 commits into
mainfrom
dean/pro-547-bidirectional-comment-sync-between-the-cli-and-github
Open

feat(PRO-547): bidirectional comment sync between the CLI and GitHub#70
dastratakos wants to merge 17 commits into
mainfrom
dean/pro-547-bidirectional-comment-sync-between-the-cli-and-github

Conversation

@dastratakos

@dastratakos dastratakos commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements PRO-547: the CLI now works with a PR's GitHub review live instead of keeping a local mirror, surfacing three clearly-labeled comment states — Local (CLI-only, offline), Pending (your unsubmitted GitHub review draft, only you see it), and Submitted (published) — faithful to GitHub's own review model.

Changes

  • Added a live GitHub review layer over gh api graphql (github/review.ts): one paginated query loads pending + submitted threads, plus mutations to create/reply/edit/delete pending comments, submit a review (Comment / Approve / Request changes), discard it, and resolve/reopen threads.
  • Added a merged read model + routes (runs/review.ts, routes/review.ts, GET /api/runs/:id/review) that combine local DB threads with the PR's live GitHub threads, degrading to local-only when gh is offline or the run isn't a PR.
  • Rebuilt the comment UI (vendored from hosted Stage): per-state badges, a review tray (submit popover with a pending-comments list, own-PR guard, Cmd⏎), and "Comment on the PR" / "Start a review" composer toggles; GitHub comments link to their permalink and render GitHub's server HTML.
  • Local comments stay CLI-only and work offline; no GitHub state is mirrored, so there is no DB schema change.

Testing

pnpm typecheck, pnpm lint, pnpm test (385 tests, including new route-integration tests for the review API against a faked gh), and pnpm build all pass. Not yet exercised against a live PR.


Open in Stage

Summary by cubic

Bidirectional comment sync between the CLI and GitHub PR reviews, implementing PRO-547. The CLI shows Local, Pending, and Submitted states with draft/submit/resolve/discard flows that stay in sync with GitHub.

  • New Features

    • Live GitHub review layer via gh api graphql: load pending/submitted threads; create/reply/edit/delete pending comments; submit (Comment/Approve/Request changes) or discard; resolve/reopen.
    • Merged review API GET /api/runs/:runId/review combines local threads with live GitHub threads; degrades to local-only when gh is unavailable, the PR is unresolvable, the run isn’t a PR, or the run’s diff isn’t at the PR head.
    • Rebuilt UI: badges for Local/Pending/Submitted, review tray with pending list and submit flow, “Comment on the PR” / “Start a review” toggles, own-PR guard; GitHub comments link to permalinks and render GitHub’s HTML.
    • Guardrails and hardening: require a clean working tree and matching PR head before pushing; gate GitHub review reads to runs at PR head; enforce committed-scope only; guard submit/reply with an assert-pushable check; atomic and serialized promote of local threads to a pending review; discard an empty pending review on comment-create failure; reject empty “Comment” review submissions at the API boundary; count drafts on anchorless threads to avoid false empty-review rejects; preserve unposted replies when promote fails; guard read-path git errors; clearer error messages; refresh PR queries after review writes scoped to the current run; fix GraphQL variable passing by keeping string vars as -f.
  • Migration

    • Routes: resolve/reopen for local threads moved to PATCH /api/comment-threads/:threadId; new review routes under /api/runs/:runId/review.
    • Web: replace comment threads context/hooks with ReviewProvider and useReview; remove legacy comment thread components.
    • Types: @stagereview/types adds review models; no DB schema changes.

Written for commit 6b25131. Summary will update on new commits.

Review in cubic

@stage-review

stage-review Bot commented Jun 22, 2026

Copy link
Copy Markdown

Ready to review this PR? Stage has broken it down into 7 individual chapters for you:

Title
1 Define review and comment types
2 Implement GitHub GraphQL review layer
3 Build merged review logic and API
4 Refactor web state to use ReviewProvider
5 Rebuild comment UI for GitHub sync
6 Integrate review state into diff viewer
7 Add tests and fix existing test types
Open in Stage

Chapters generated by Stage for commit 6b25131 on Jun 22, 2026 9:40pm UTC.

@dastratakos dastratakos marked this pull request as ready for review June 22, 2026 18:40
Comment thread packages/cli/src/runs/review.ts
Comment thread packages/cli/src/runs/review.ts
Comment thread packages/cli/src/routes/comments.ts Outdated

@cubic-dev-ai cubic-dev-ai 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.

cubic analysis

8 issues found across 29 files

Linked issue analysis

Linked issue: PRO-547: Bidirectional comment sync between the CLI and GitHub

Status Acceptance criteria Notes
Pull existing PR review comments into the local/merged review view (load pending + submitted GitHub threads and merge with local threads). New GitHub read layer, merged read model, and a review route are added; the UI switches to the new ReviewProvider. These changes show the PR fetches and surfaces pending/submitted GitHub threads alongside local threads.
Push locally-authored comments back to the PR (create/reply/edit/delete pending comments, submit or discard a review). The diff adds write mutations and server handlers for creating/replying/editing/deleting pending comments and submitting/discarding reviews, plus UI for drafting/submitting reviews — indicating the PR implements push paths to GitHub.
Guardrails before pushing: ensure the working tree is clean and the local state matches the PR head (prevent mis-anchored/stale pushes, only push committed-scope comments). New git helper functions to read HEAD SHA and check working-tree cleanliness are added, and the runs/review layer and summary mention scope-key/commit-scope checks and push guardrails, indicating these safety checks are implemented server-side before writes to GitHub.
⚠️ Surface a clear result of what was pushed / skipped / failed to the user. The code adds a ReviewResponse model and routing plus UI feedback (toasts, submit popover), suggesting structured results are produced and surfaced. The diff provides some evidence but the exact shape and completeness of a per-comment pushed/skipped/failed report is not fully verifiable from the shown diffs (and the PR hasn’t been exercised against a live PR).
Mirror and sync thread resolution state (resolve/reopen threads mirrored between CLI and GitHub). Resolve/reopen flows are routed and wired into the GitHub review layer and the merged run review API, indicating thread resolution is synced.

Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.

Re-trigger cubic

Comment thread packages/cli/src/runs/review.ts
Comment thread packages/cli/src/runs/review.ts
Comment thread packages/cli/src/runs/review.ts
Comment thread packages/web/src/lib/use-view-state.ts Outdated
Comment thread packages/web/src/components/pull-request/review-panel.tsx
Comment thread packages/cli/src/runs/review.ts
Comment thread packages/cli/src/runs/review.ts
Comment thread packages/cli/src/routes/comments.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: aaf624e93f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/cli/src/runs/review.ts
Comment thread packages/cli/src/github/review.ts
Comment thread packages/cli/src/runs/review.ts
Comment thread packages/cli/src/github/review.ts
Comment thread packages/cli/src/runs/review.ts Outdated
Comment thread packages/cli/src/runs/review.ts

@cubic-dev-ai cubic-dev-ai 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.

2 issues found across 11 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread packages/cli/src/runs/review.ts Outdated
Comment thread packages/cli/src/runs/review.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 105f8ac7a0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/cli/src/runs/review.ts Outdated
Comment thread packages/cli/src/runs/review.ts Outdated
Comment thread packages/cli/src/runs/review.ts
Comment thread packages/cli/src/github/review.ts

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d2654445bf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/cli/src/runs/review.ts
Comment thread packages/web/src/lib/use-review.ts
Comment thread packages/cli/src/runs/review.ts
Comment thread packages/cli/src/runs/review.ts
Comment thread packages/cli/src/runs/review.ts

@cubic-dev-ai cubic-dev-ai 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.

1 issue found across 4 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread packages/web/src/lib/use-review.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 545fcf6f27

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/cli/src/runs/review.ts
Comment thread packages/cli/src/runs/review.ts
Comment thread packages/cli/src/runs/review.ts
@dastratakos dastratakos enabled auto-merge (squash) June 22, 2026 21:00
@dastratakos dastratakos disabled auto-merge June 22, 2026 21:00

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9c4afec41d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/cli/src/runs/review.ts
Comment thread packages/cli/src/github/review.ts Outdated
Comment thread packages/cli/src/runs/review.ts

@cursor cursor 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.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b828070. Configure here.

Comment thread packages/cli/src/runs/review.ts

@cubic-dev-ai cubic-dev-ai 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.

1 issue found across 2 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread packages/cli/src/runs/review.ts Outdated

@cubic-dev-ai cubic-dev-ai 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.

1 issue found across 3 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/cli/src/github/review.ts">

<violation number="1" location="packages/cli/src/github/review.ts:200">
P2: Pending-comment counting relies on `comments(first: 100)` per review thread without pagination, so threads with more than 100 comments undercount pending drafts. This can cause the empty-review guard and UI tray to falsely treat a non-empty pending review as empty.</violation>
</file>

Comment thread packages/cli/src/github/review.ts

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6b251314c5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/cli/src/runs/review.ts
Comment thread packages/cli/src/github/review.ts
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