Repository navigation
Fix #1992: afx cleanup finds all-digit task builders (task id via buildAgentName) - #1994
Merged
Merged
Conversation
The parser kept the leading zeros of an all-digit task short id (task-0123 -> builder-task-0123) while spawn names the terminal builder-task-123, so the Agents view filtered that builder out when its global.db row was missing. The task branch now calls buildAgentName, the function spawn names the terminal with, so the two cannot drift.
…ay in the overview Pins the issue's ids (task-S0-L, task-_-LM) through getOverview's live-terminal filter, and the all-digit leading-zero case that still drifted.
…with buildAgentName CMAP review (claude) found the same leading-zero drift in two more places: - worktreeNameToRoleId's generic-protocol branch kept the zeros of an all-digit issue-less short id (maintain-0123 -> builder-maintain-0123; terminal is builder-maintain-123). It now calls buildAgentName too. - afx cleanup -p task-0123 built builder-task-0123, missed the stored builder-task-123, and failed with 'Builder not found'. Both task lookups in cleanup now share taskBuilderId(), built on buildAgentName.
…h buildAgentName The cleanup mirror tests now normalize with cleanup.ts's own taskBuilderId rather than a hand-rolled copy, so they exercise the real derivation.
…e- asymmetry CMAP round 2 (codex, claude): - cleanup's --task / --project lookups are now exported findTaskBuilder / findProjectBuilder, which cleanup() calls, so tests drive the real lookups rather than a re-implementation (behavior unchanged). - taskBuilderId moves to utils/agent-names.ts, beside buildAgentName. - Comment the worktree- branch: spawnWorktree keeps leading zeros, so it must not go through buildAgentName.
…sk-0123); pin worktree-0123 The cleanup tests import findTaskBuilder / findProjectBuilder instead of mirroring them. worktree-0123 must stay worktree-0123.
…ctly CMAP round 3 (claude): the parser test compared against buildAgentName on both sides; add literal builder-task-123 / builder-maintain-123, and a direct taskBuilderId test including the issue's ids.
waleedkadous
marked this pull request as draft
November 26, 2026 00:27
# Conflicts: # packages/codev/src/agent-farm/__tests__/overview.test.ts # packages/codev/src/agent-farm/servers/overview.ts
PR #1993 (bugfix-1844) already routes worktreeNameToRoleId's task and issue-less protocol branches through buildAgentName, with tests for the issue's ids, leading zeros, getOverview and the worktree- carve-out. The merge took main's overview.ts and overview.test.ts; this drops my duplicate getOverview test that merged in beside main's. What remains is the afx cleanup fix (findTaskBuilder / findProjectBuilder via taskBuilderId) and its tests.
waleedkadous
marked this pull request as ready for review
November 27, 2026 04:43
waleedkadous
added a commit
that referenced
this pull request
Nov 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Reduced after PR #1993 merged. The Agents-view part of #1992 is now fully fixed on
main. v3.3.6 (PR #1848) fixed the reportedtask-S0-L/task-_-LMids. PR #1993 (bugfix-1844) then routed the remaining task and issue-less protocol role ids throughbuildAgentName, closing the leading-zero drift. This PR originally did that sameoverview.tswork. I mergedmainin, took itsoverview.tsandoverview.test.tsunchanged, and dropped my duplicates.What remains is the same drift in
afx cleanup, whichmaindoesn't have yet.Fixes #1992
Root Cause
Spawn names a task builder with
buildAgentName('task', shortId), which strips leading zeros from an all-digit id:task-0123becomesbuilder-task-123.afx cleanuprebuilt the id by hand (`builder-task-${shortId.toLowerCase()}`) and kept the zeros:afx cleanup -p task-0123looked upbuilder-task-0123and missed the storedbuilder-task-123. Its last fallback matches the builder's display name (Task: …), so it failed with "Builder not found for project: task-0123".afx cleanup --task 0123failed the same way. Its worktree-path fallback looks for/0123and can't match/task-0123. (--task task-0123was saved by that fallback.)Fix
utils/agent-names.ts: newtaskBuilderId(name). It takestask-bEPdorbEPdand returnsbuildAgentName('task', …), next to the function spawn names builders with.commands/cleanup.ts: the--taskand--projectlookups are extracted into exportedfindTaskBuilder/findProjectBuilder, whichcleanup()calls. Both normalize throughtaskBuilderId. Lookup order and fallbacks are unchanged.Test Plan
cleanup-task-builders.test.tsnow drives cleanup.ts's real lookups; before, it re-implemented them in the test file. New cases--task 0123and--project task-0123findbuilder-task-123. Both fail with the old hand-built normalization and pass with the fix.agent-names.test.ts: directtaskBuilderIdtest (task-bEPd,bEPd,task-S0-L,task-_-LM,task-0123,0123).overview.ts/overview.test.tsare identical tomain(no diff).mainThe short-id redraw for ambiguous issue-less protocol names is tracked separately in #1998.