feat(gastown): babysit existing PR feature#3601
Conversation
…rm (#3372) Bug 1: @kilocode/cli@7.2.14 doesn't read KILO_AUTH_CONTENT, causing all kilo serve session-ingest to silently no-op. Bumped to 7.3.1 which has the feature. Verified KILO_AUTH_CONTENT present in binary strings. Bug 2: buildPrewarmEnv didn't set KILO_AUTH_CONTENT, KILO_PLATFORM, or KILO_ORG_ID, so mayor sessions (which go through prewarm) were invisible. Extracted buildKiloAuthEnv helper from buildAgentEnv and used it in both buildAgentEnv and buildPrewarmEnv. Refs #3307 Co-authored-by: John Fawcett <john@kilcoode.ai>
* perf(gastown): shorten mayor cold start path * fix(gastown): address mayor latency review feedback * fix(gastown): remove stale mayor setup parameter * fix(gastown): remove stale mayor setup comment
* feat(cloud-agent): add Gastown filter option to ChatSidebar and mobile modal * fix(cloud-agent-next): remove stale comment in default branch handling --------- Co-authored-by: John Fawcett <john@kilcoode.ai>
Make worktree creation tolerate an existing local branch with a missing worktree directory, and allow internal @kilocode package updates to bypass release-age delays.
…unk 0) (#3576) * feat(gastown): Town DO slingExistingPr method (babysit PR feature, chunk 0) * fix(gastown): address PR review feedback on slingExistingPr - Remove async from submitExternalPrToReviewQueue (no awaits inside) - Add GitLab host validation in slingExistingPr URL parsing to prevent non-GitLab URLs (e.g. Bitbucket) from matching the GitLab regex - Replace vacuous state validation tests with meaningful checkPRStatus integration tests that exercise the actual status resolution path --------- Co-authored-by: John Fawcett <john@kilcoode.ai>
Add gastown.babysitPr tRPC mutation, gastown.previewPr tRPC query, mayor-tools babysit-pr HTTP route, refinery bypass for babysat beads, and reconciler fast-track extension for babysat MR beads.
feat(web): BeadPanel babysit badge + metadata surfacing (chunk 4) - Add 'Babysat external PR' badge (cyan) when gt:babysit label present - Hide source bead link for babysit beads (no source_bead_id) - Add babysit metadata panel: head_sha (7-char, linked), force_push_allowed (Lock/Unlock icons), babysit_started_at (relative time) - Add event formatters for babysit_started, pr_feedback_detected, pr_conflict_detected, pr_auto_merge, pr_status_changed - Mirror babysit badge + metadata in BeadInspectorDashboard - Extract buildRelatedBeads and eventDescription into separate files for testability - Add unit tests for eventDescription and buildRelatedBeads babysit logic Co-authored-by: John Fawcett <john@kilcoode.ai>
…3582) * feat(gastown): gt_babysit_pr mayor tool + force-push gate (chunk 2) Add gt_babysit_pr mayor tool registration and client method, update mayor and polecat system prompts with babysit PR guidance and force-push policy, surface force_push_allowed in polecat prime context, and add corresponding unit tests. * fix(gastown): address PR review warnings on babysit PR feature - Rewrite PR Conflict Resolution Workflow in polecat-system.prompt.ts to choose strategy upfront (rebase vs merge) based on force_push_allowed, instead of rebase-then-abort which discarded conflict resolution work. - Extract resolveForcePushAllowed() from agents.ts prime() so tests exercise the actual function instead of inlining the logic. --------- Co-authored-by: John Fawcett <john@kilcoode.ai>
| const convoys = convoysQuery.data ?? []; | ||
| const relatedBeads = buildRelatedBeads(bead, allBeads, convoys); | ||
| const relatedBeads = buildRelatedBeads(bead, allBeads, convoys).filter( | ||
| r => !(r.relation === 'source' && isBabysit) |
There was a problem hiding this comment.
CRITICAL: isBabysit is used before it is declared — this will throw a ReferenceError at runtime.
The .filter() callback references isBabysit at line 242, but const isBabysit = bead.labels.includes('gt:babysit') is declared ~14 lines later (line 256). In a JavaScript function body, const bindings are in the temporal dead zone until their declaration is evaluated, so this will crash every time BeadPanel renders.
Move the isBabysit declaration above the relatedBeads computation:
| r => !(r.relation === 'source' && isBabysit) | |
| r => !(r.relation === 'source' && isBabysit) |
The fix is to hoist the declaration:
// Babysit bead detection (must come before relatedBeads filter below)
const isBabysit = bead.labels.includes('gt:babysit');
const relatedBeads = buildRelatedBeads(bead, allBeads, convoys).filter(
r => !(r.relation === 'source' && isBabysit)
);| value={bead.metadata?.force_push_allowed === true ? 'Allowed' : 'Blocked'} | ||
| /> | ||
| {typeof bead.metadata?.babysit_started_at === 'string' && ( | ||
| <MetaCell |
There was a problem hiding this comment.
WARNING: bead.metadata?.babysit_started_at is displayed here, but babysit_started_at is never written to bead metadata in submitExternalPrToReviewQueue (see services/gastown/src/dos/town/review-queue.ts). The metadata fields written are: source_agent_id, babysit, head_sha, force_push_allowed. This section will never render. Either add babysit_started_at: new Date().toISOString() to the metadata in submitExternalPrToReviewQueue, or remove this dead UI branch.
| <span className="text-red-400">Blocked</span> | ||
| </> | ||
| )} | ||
| </dd> |
There was a problem hiding this comment.
WARNING: bead.metadata.babysit_started_at is rendered here but this field is never written in submitExternalPrToReviewQueue. The section will silently never display. Same issue as in BeadPanel.tsx — add babysit_started_at to the bead metadata at creation time, or remove this block.
Code Review SummaryStatus: 3 Issues Found | Recommendation: Address before merge Executive Summary
Overview
Issue Details (click to expand)CRITICAL
WARNING
Other Observations (not blocking)
Files Reviewed (40 files)
Fix these issues in Kilo Cloud Reviewed by claude-sonnet-4.6 · 4,250,533 tokens Review guidance: REVIEW.md from base branch |
Summary
Adds the "babysit existing PR" feature to Gastown, allowing towns to adopt and manage external PRs (created manually, by other tools, or by third parties). The town polls the PR, addresses review feedback, fixes merge conflicts, and auto-merges — bypassing the refinery code review path since the user is opting into "merge this PR", not "review this PR".
Key changes across 4 chunks:
slingExistingPrandpreviewPrmethods onTownDO— validates PR URL against rig repo, checks PR status via SCM, creates amerge_requestbead withgt:babysitlabel and babysit metadata (head_sha,force_push_allowed)babysitPrandpreviewPrtRPC mutations +POST /api/mayor/:townId/tools/babysit-prHTTP handler for mayor tool accessgt_babysit_prmayor tool,force_push_allowedmetadata propagated throughpr_fixup_context/pr_conflict_contextin prime context, polecat prompt updated with force-push policy (default false for babysat PRs = merge-only, no history rewriting)SlingDialogbabysit-PR mode,BeadPanelbabysit badge and metadata display,eventDescriptionextracted to module with babysit event types,buildRelatedBeadsextracted for testability,ActivityFeedicons/colors for babysit events, Gastown platform filter in sessions UIAlso includes infrastructure improvements:
setEnvVar/deleteEnvVarfromTownContainerDOin favor of passing config through control server request protocol (/sync-config,/refresh-token,/agents/start). Eliminates stale persisted env var issues across DO evictions and container restarts.@kilocode/sdk7.2.14 → 7.3.1,@kilocode/cli7.2.14 → 7.3.1Verification
in_progressin reconcilerforce_push_allowed: falsepolecats use merge commits (no force-push)previewPrreturns correct metadata for GitHub and GitLab PRsVisual Changes
Reviewer Notes
slingExistingPrmethod inTownDOhas duplicated PR URL parsing logic withpreviewPr— this is intentional to keeppreviewPras a lightweight read-only path that can fail independentlyforce_push_allowedgate defaults totruewhen absent (backwards compat for pre-babysit beads) — only explicitfalsedisables force-pushsetEnvVar/deleteEnvVar) is a significant infra change that removes the persisted env var store in favor of always-fresh request-scoped delivery. This eliminates stale-token bugs across DO evictions