Skip to content

[Bugfix #1844] Derive fallback builder role ids through buildAgentName - #1993

Merged
waleedkadous merged 10 commits into
mainfrom
builder/bugfix-1844
Nov 26, 2026
Merged

waleedkadous merged 10 commits into
mainfrom
builder/bugfix-1844

Conversation

@waleedkadous

@waleedkadous waleedkadous commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1844

Problem

A builder whose worktree-derived role id doesn't match the role id its terminal registered under is filtered out of /api/overview, so it disappears from the VSCode Agents view. The issue reports this for task ids containing - or _ (task-S0-L, task-_-LM) on 3.3.4.

Root cause

The ids in the report were already fixed on main. PIR #1740 (the issue-key worktree change, commit f251a98, first released in v3.3.6) changed worktreeNameToRoleId() to take the whole remainder as the short id. It also made discovery prefer the builder id stored in global.db over parsing the directory name. On main today, task-S0-L → builder-task-s0-l and task-_-LM → builder-task-_-lm, which match what spawn registers.

One drift remained in the same fallback. It still assembled the task and generic-protocol role ids by hand instead of calling buildAgentName(), the function spawn names the terminal with. buildAgentName() strips leading zeros from an all-digit id, and a base64url short id can be all digits:

worktree fallback (before) terminal (buildAgentName)
task-0042 builder-task-0042 builder-task-42
experiment-0042 builder-experiment-0042 builder-experiment-42

When global.db has no usable row for the builder, this hides it exactly as #1844 describes. Rows from older versions carry a legacy id and fall through to this path.

Fix

The fallback's task and generic-protocol branches now call buildAgentName('task', id) / buildAgentName('protocol', id, protocol). This is the issue's own suggested fix ("derive the role id from the same function that registers the terminal, so the two cannot drift"). The generic branch's numbered path now goes through buildAgentName() too, so a zero-padded generic name loses its zeros as the terminal name does: air-0633-slug → builder-air-633 (was builder-air-0633). That matches buildAgentName('spec', projectId, protocol) at spawn and brings the generic protocols in line with the spir/tick/bugfix/pir branches above, which have always stripped. The worktree- branch is unchanged: spawn names that terminal worktree-<short id> directly, not through buildAgentName(), so its zeros stay.

Left alone on purpose: experiment-12-a still reads as numbered spawn 12. An issue-less spawn with short id 12-a would register builder-experiment-12-a, but from the directory name alone it can't be told apart from a pre-Spec-653 numbered worktree with a slug (<protocol>-<N>-<slug>). The fallback mostly serves legacy rows, so reading the name as numbered first is the safer choice. A present-day spawn has a builder-… row, so the stored id resolves it.

Testing

  • New test strips leading zeros from an all-digit short id, as buildAgentName does (#1844): task-0042, task-0000, experiment-0042 and maintain-0007-x are checked against buildAgentName, and worktree-0042 is pinned to keep its zeros. It fails on main (expected 'builder-task-0042' to be 'builder-task-42') and passes with the fix.
  • New test keeps a live task builder whatever characters its short id holds (#1844): this is the user-visible symptom. It creates .builders/task-0042, task-S0-L and task-_-LM with no global.db row and calls getOverview() with the active-terminal set that spawn registers (builder-task-42, builder-task-s0-l, builder-task-_-lm). All three must survive the filter. It fails on main's overview.ts and passes with the fix.
  • The leading-zero test also pins task-0042 → builder-task-42 as a literal, so it doesn't rely on buildAgentName alone.
  • New test pinning the issue's own ids (task-S0-L, task-_-LM). It is coverage only: it already passes on main because forge: add a jira provider preset (hybrid tracker — issues from Jira, PR concepts fall through to github, Linear-style) #1740 fixed them.
  • tsc --noEmit is clean. The three role-id test files (overview, pir-1740-issue-key-worktree, overview-agent-state) pass: 230 tests (after merging current main).
  • Full packages/codev suite: 9845 passed on the first run. The 117 failures in that run came from an unbuilt worktree (Skeleton directory not found). All 15 of those files pass after pnpm build (334 passed, 3 skipped).

Review

  • codex: REQUEST_CHANGES. The only issue was that the branch was behind main; it called the implementation and tests sound. Merged origin/main (clean).
  • claude: APPROVE. I acted on its non-blocking notes: named the numbered-generic change above, added a literal anchor and added the getOverview symptom test.

…ntName

The overview's worktree-name fallback built task and generic-protocol role ids
by hand, skipping the leading-zero stripping buildAgentName applies when spawn
names the terminal. An all-digit short id (task-0042) therefore mapped to
builder-task-0042 while its terminal is builder-task-42, and the builder was
filtered out of /api/overview. The ids reported in the issue (task-S0-L,
task-_-LM) were already fixed by PIR #1740; this closes the remaining drift.
… id; anchor literal

Adds a getOverview test of the user-visible symptom: task-0042, task-S0-L and
task-_-LM with no stored row survive the active-terminal filter. Fails on main's
overview.ts, passes with the fix. Also pins task-0042 -> builder-task-42 as a
literal so the unit test does not rely on buildAgentName alone.
@waleedkadous
waleedkadous marked this pull request as draft November 26, 2026 00:04
@waleedkadous
waleedkadous marked this pull request as ready for review November 26, 2026 22:18
@waleedkadous
waleedkadous merged commit eb8c60a into main Nov 26, 2026
8 checks passed
waleedkadous added a commit that referenced this pull request Nov 26, 2026
waleedkadous added a commit that referenced this pull request Nov 26, 2026
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 added a commit that referenced this pull request Nov 26, 2026
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.

VSCode Agents view hides task builders whose id contains - or _

1 participant