Skip to content

Comments

add code reviews for the cloud next#321

Open
Sureshkumars wants to merge 3 commits intomainfrom
feat/add-code-review-for-cloud-next
Open

add code reviews for the cloud next#321
Sureshkumars wants to merge 3 commits intomainfrom
feat/add-code-review-for-cloud-next

Conversation

@Sureshkumars
Copy link
Member

No description provided.

@kiloconnect
Copy link
Contributor

kiloconnect bot commented Feb 18, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Notes

Both previously flagged issues have been resolved in the latest commits:

  1. normalizePayload doesn't map cloudAgentSessionIdsessionId — Fixed at route.ts: raw.sessionId ?? ('cloudAgentSessionId' in raw ? raw.cloudAgentSessionId : undefined) now correctly falls back to cloudAgentSessionId.

  2. Green badge + CheckCircle icon shown for failed/cancelled reviews — Fixed at CodeReviewStreamView.tsx: The component now renders distinct badges for failed (destructive + XCircle), cancelled (secondary + XCircle), and completed (emerald + CheckCircle2).

The PR cleanly implements dual-mode code review orchestration (cloud-agent SSE vs cloud-agent-next WebSocket) behind a PostHog feature flag. Key observations:

  • Feature flag evaluation is server-side only (PostHog isFeatureFlagEnabled), with the result persisted to DB at dispatch time — no client-side flag checks
  • The normalizePayload function correctly maps cloud-agent-next callback fields (interruptedcancelled, kiloSessionIdcliSessionId, cloudAgentSessionIdsessionId)
  • Error handling in runWithCloudAgentNext correctly marks all failures as failed since the callback won't fire if the session never started
  • Authorization checks in the new getReviewStreamInfo endpoint mirror the existing getReviewEvents pattern
  • The interruptCloudAgentSession method correctly routes to the appropriate backend based on the useCloudAgentNext flag
Files Reviewed (16 files)
  • cloudflare-code-review-infra/src/code-review-orchestrator.ts - New runWithCloudAgentNext flow, updated interrupt routing
  • cloudflare-code-review-infra/src/index.ts - Updated comments for dual-mode support
  • cloudflare-code-review-infra/src/types.ts - Added useCloudAgentNext to CodeReview, CodeReviewRequest, Env
  • cloudflare-code-review-infra/wrangler.jsonc - Added CLOUD_AGENT_NEXT_URL env var
  • src/app/api/internal/code-review-status/[reviewId]/route.ts - Payload normalization for dual callback formats
  • src/components/code-reviews/CodeReviewJobsCard.tsx - Removed session_id requirement for stream view
  • src/components/code-reviews/CodeReviewStreamView.tsx - Dual-mode streaming (WebSocket + polling), fixed status badges
  • src/db/migrations/0021_loving_red_hulk.sql - Migration for use_cloud_agent_next column
  • src/db/migrations/meta/0021_snapshot.json - Migration snapshot (generated)
  • src/db/migrations/meta/_journal.json - Migration journal (generated)
  • src/db/schema.ts - Added use_cloud_agent_next column
  • src/lib/code-reviews/client/code-review-worker-client.ts - interfacetype, updated comments
  • src/lib/code-reviews/db/code-reviews.ts - Added useCloudAgentNext to update function
  • src/lib/code-reviews/dispatch/dispatch-pending-reviews.ts - Feature flag evaluation + dispatch
  • src/lib/code-reviews/triggers/prepare-review-payload.ts - Added useCloudAgentNext to payload type
  • src/routers/code-reviews/code-reviews-router.ts - New getReviewStreamInfo endpoint

@Sureshkumars Sureshkumars force-pushed the feat/add-code-review-for-cloud-next branch from 0ddfdee to 2bb6bf7 Compare February 19, 2026 18:24
Comment on lines +463 to +467
const prepareResponse = await fetch(`${this.env.CLOUD_AGENT_NEXT_URL}/trpc/prepareSession`, {
method: 'POST',
headers,
body: JSON.stringify(prepareInput),
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Lets use src/lib/cloud-agent-next/cloud-agent-client.ts, it should have all methods

Comment on lines +45 to +56
/**
* Payload from cloud-agent-next callback (ExecutionCallbackPayload).
*/
type CloudAgentNextCallbackPayload = {
sessionId?: string;
cloudAgentSessionId?: string;
executionId?: string;
kiloSessionId?: string;
status: 'completed' | 'failed' | 'interrupted';
errorMessage?: string;
lastSeenBranch?: string;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a type in cloud agent that we can re-use here?

const manager = createWebSocketManager({
url: url.toString(),
ticket,
onEvent: handleEvent,
Copy link
Contributor

Choose a reason for hiding this comment

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

cloud agent next has event processor that can aggregate cli events etc and will send a callback when there is an update
may be handy to use here

@@ -0,0 +1 @@
ALTER TABLE "cloud_agent_code_reviews" ADD COLUMN "use_cloud_agent_next" boolean DEFAULT false; No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

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

wonder if we want "version" or something to future proof a bit?


// 2. Prepare complete payload for cloud agent
// 2. Evaluate feature flag: use cloud-agent-next?
const flagDistinctId = owner.type === 'org' ? owner.id : owner.userId;
Copy link
Contributor

Choose a reason for hiding this comment

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

is owner.id an org id? Do we not always feature flag based on user?

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.

2 participants