Skip to content

feat(gastown): add mayor edit tools and manual editing UI#1076

Merged
jrf0110 merged 8 commits intomainfrom
996-mayor-edit-capabilities
Mar 13, 2026
Merged

feat(gastown): add mayor edit tools and manual editing UI#1076
jrf0110 merged 8 commits intomainfrom
996-mayor-edit-capabilities

Conversation

@jrf0110
Copy link
Copy Markdown
Contributor

@jrf0110 jrf0110 commented Mar 12, 2026

Summary

  • Adds 7 new mayor edit tools: gt_bead_update (status, title, body, priority), gt_bead_reassign, gt_agent_reset, gt_convoy_close, gt_bead_delete, gt_escalation_acknowledge, and gt_bead_fail
  • Adds PATCH endpoints in gastown.worker.ts for bead fields, agent status, and convoy metadata with user auth (not agent-scoped)
  • Implements updateBead, resetAgent, and updateConvoy methods on TownDO
  • Adds dashboard UI edit controls: status dropdowns, editable bead fields, agent unhook/reset buttons
  • Updates mayor system prompt with a "Surgical Editing" section documenting the new capabilities

Closes #996

Verification

  • Code review of diff against fork branch — all patches applied cleanly to origin/main
  • Mayor tools test file updated with new tool registrations

Visual Changes

Adds an edit button to bead drawer:

image image

Reviewer Notes

  • The new PATCH endpoints use user auth rather than agent-scoped auth, enabling both the Mayor and dashboard UI to edit state
  • gt_bead_delete is a hard delete — consider whether soft delete (archive) would be safer for production
  • The mayor tool registration in the Kilo plugin registers all 7 tools; ensure the container has the matching handler routes

jrf0110 added 2 commits March 12, 2026 16:54
…oy editing

Adds 7 new mayor edit tools (gt_bead_update, gt_bead_reassign, gt_agent_reset,
gt_convoy_close, gt_bead_delete, gt_escalation_acknowledge, gt_bead_fail) with
corresponding PATCH endpoints. Adds dashboard UI edit controls (status dropdowns,
editable fields, unhook/reset buttons). Updates mayor system prompt with
Surgical Editing section documenting the new capabilities.

Closes #996
… API

Expand the PATCH /beads/:id endpoint to accept type, rig_id, and
parent_bead_id in addition to existing fields. Add corresponding
updateBeadFields support. Dashboard UI gains: labels input (comma-
separated), metadata textarea (JSON), type/rig/parent dropdowns,
in_review status option, Load button to populate the form from an
existing bead, and an Edit button in the beads table for one-click
editing. Also adds priority column to the beads table and failed
badge style.
Comment thread cloudflare-gastown/src/handlers/mayor-tools.handler.ts Outdated
Comment thread cloudflare-gastown/src/handlers/mayor-tools.handler.ts Outdated
Comment thread cloudflare-gastown/src/handlers/mayor-tools.handler.ts Outdated
@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot Bot commented Mar 13, 2026

Code Review Summary

Status: 2 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 2
SUGGESTION 0

Fix these issues in Kilo Cloud

Issue Details (click to expand)

WARNING

File Line Issue
cloudflare-gastown/src/trpc/router.ts 312 parent_bead_id accepts self/cyclic references that make deleteBead() recurse forever
cloudflare-gastown/src/ui/dashboard.ui.ts 622 Mayor Unhook button calls an unregistered endpoint and always 404s
Other Observations (not in diff)

None.

Files Reviewed (12 files)
  • cloudflare-gastown/container/plugin/client.ts - 0 issues
  • cloudflare-gastown/container/plugin/mayor-tools.test.ts - 0 issues
  • cloudflare-gastown/container/plugin/mayor-tools.ts - 0 issues
  • cloudflare-gastown/src/db/tables/bead-events.table.ts - 0 issues
  • cloudflare-gastown/src/dos/Town.do.ts - 0 issues
  • cloudflare-gastown/src/dos/town/beads.ts - 0 issues
  • cloudflare-gastown/src/gastown.worker.ts - 0 issues
  • cloudflare-gastown/src/handlers/mayor-tools.handler.ts - 0 issues
  • cloudflare-gastown/src/prompts/mayor-system.prompt.ts - 0 issues
  • cloudflare-gastown/src/trpc/router.ts - 1 issue
  • cloudflare-gastown/src/ui/dashboard.ui.ts - 1 issue
  • src/components/gastown/drawer-panels/BeadPanel.tsx - 0 issues

Reviewed by gpt-5.4-20260305 · 2,413,594 tokens

Add updateBead tRPC mutation to the gastown worker router accepting all
editable bead fields (title, body, status, priority, type, labels,
metadata, rig_id, parent_bead_id). The BeadPanel drawer now has a pencil
icon toggle that switches to edit mode: title becomes an input, status/
type/priority become selects, and labels/body/metadata/rig_id/parent
fields appear as additional inputs. Save computes a diff against the
original bead and only sends changed fields. Regenerated router.d.ts
type declarations.
Comment thread cloudflare-gastown/src/handlers/mayor-tools.handler.ts
Comment thread cloudflare-gastown/src/handlers/mayor-tools.handler.ts
Comment thread cloudflare-gastown/src/ui/dashboard.ui.ts
jrf0110 added 2 commits March 13, 2026 10:45
The Save button was at the bottom of the edit fields section, making
it hard to find when only changing status/type/priority. Moved it
inline with the status/type/priority selects so it's always visible
at the top of the edit form. Removed the duplicate Save/Cancel bar
from the bottom.
…ting

- Remove bead type from editable fields to prevent inconsistent state
  (type changes require satellite metadata tables that aren't created)
- Add rig ownership check in handleMayorBeadUpdate matching the pattern
  in handleMayorBeadDelete — rejects updates to beads in other rigs
- Fix reassign atomicity: hook new agent before unhooking old one so
  failures don't leave beads unassigned
- Fix reassign unhook safety: verify old agent is still hooked to this
  specific bead before unhooking (stale assignee_agent_bead_id)
- Fix reassign response: return updated bead instead of { reassigned }
  to match client contract
- Fix ESLint: void floating promises, destructure useMutation result
- Fix Prettier formatting in 5 files
- Regenerate router.d.ts type declarations
Comment thread cloudflare-gastown/src/handlers/mayor-tools.handler.ts
Comment thread cloudflare-gastown/src/handlers/mayor-tools.handler.ts
Comment thread cloudflare-gastown/src/trpc/router.ts
…Bead

- Reassign: validate target agent belongs to the specified rig and
  verify bead belongs to the rig before allowing reassignment
- Agent reset: verify agent belongs to the specified rig before
  allowing reset (prevents cross-rig reset via any valid rig ID)
- tRPC updateBead: verify bead belongs to the specified rig before
  allowing mutation (mirrors the HTTP handler fix)
Comment thread cloudflare-gastown/src/dos/town/beads.ts
Comment thread cloudflare-gastown/container/plugin/mayor-tools.ts Outdated
Comment thread cloudflare-gastown/src/ui/dashboard.ui.ts Outdated
- Fix pre-existing type errors: use sql.exec() directly for dynamic
  SET clause queries where query() can't statically verify param count
- Clear closed_at when reopening a previously-closed bead (status
  transition away from 'closed' now nulls out the stale timestamp)
- Add in_review to gt_bead_update tool status enum and client type
- Remove Type dropdown from debug dashboard (API no longer accepts it)
Comment thread cloudflare-gastown/src/ui/dashboard.ui.ts Outdated
Comment thread cloudflare-gastown/src/ui/dashboard.ui.ts Outdated
Comment thread src/components/gastown/drawer-panels/BeadPanel.tsx
- Dashboard unhook: use mayorApi() with mayor route instead of api()
  with the rig route, so the bearer token is sent correctly
- Dashboard bead table: use b.bead_id (the actual PK) instead of b.id
  (undefined), and b.assignee_agent_bead_id for the assignee column
- BeadPanel metadata: reject save with inline error when metadata JSON
  is invalid instead of silently dropping the field. Error clears on
  edit and displays with red border on the textarea.
labels: z.array(z.string()).optional(),
metadata: z.record(z.string(), z.unknown()).optional(),
rig_id: z.string().min(1).nullable().optional(),
parent_bead_id: z.string().min(1).nullable().optional(),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

WARNING: parent_bead_id can create an undeletable cycle

This accepts any non-empty string, including the bead's own ID. deleteBead() recursively walks child beads by parent_bead_id with no cycle detection, so a self-reference or two-bead loop will recurse forever and make cleanup fail.

const rId = el('editAgentRigId').value.trim();
const aId = el('editAgentId').value.trim();
if (!tId || !rId || !aId) { toast('Fill in Town ID, Rig ID, and Agent ID', true); return; }
const r = await mayorApi('DELETE', '/api/mayor/' + tId + '/tools/rigs/' + rId + '/agents/' + aId + '/hook');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

WARNING: This mayor endpoint is not registered

gastown.worker.ts adds a mayor reset route, but there is no matching DELETE /api/mayor/:townId/tools/rigs/:rigId/agents/:agentId/hook route or handler. Clicking the new Unhook button will 404 every time.

@jrf0110 jrf0110 merged commit dc756e5 into main Mar 13, 2026
18 checks passed
@jrf0110 jrf0110 deleted the 996-mayor-edit-capabilities branch March 13, 2026 17:39
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.

Mayor edit capabilities + manual bead/agent/convoy editing

2 participants