Skip to content

fix(sidebar): attach subagent children to sessions rendered inside slug groups - #134

Merged
devsuitup merged 3 commits into
mainfrom
fix/slug-group-subagent-nesting
Aug 23, 2026
Merged

fix(sidebar): attach subagent children to sessions rendered inside slug groups#134
devsuitup merged 3 commits into
mainfrom
fix/slug-group-subagent-nesting

Conversation

@JeanBaptisteRenard

Copy link
Copy Markdown
Collaborator

Summary

  • buildSlugGroup() appended its sessions via the raw buildSessionItem(session), never through appendSubagentChildren — only the ungrouped top-level render path called that helper. Any session rendered inside a slug group (e.g. a schedule rerun sharing a slug with an earlier run — the only real producer of grouped top-level sessions, see schedule-runner.js:createScheduleSession()) silently lost its subagent caret/children.
  • Knock-on bug: a slug-group <div> carries no dataset.sessionId of its own, so the "orphan subagents" pass in buildSessionsList never counted a grouped session's id as accounted-for either — its subagents were duplicated into the project's "Orphan subagents" bucket.
  • Fix: appendSubagentChildren() is hoisted from a closure inside renderProjects() to module scope (it never captured any of that function's locals) so buildSlugGroup(slug, sessions, subagentIndex) can call it per rendered session, and a new collectTopLevelSessionIds(el) walks into a group element for the orphan-detection pass.
  • Design notes and rationale live in .ai/contexts/subagent-observability.md (new section); the code carries only one-line pointers to it.

This is PR 2 of the slug-grouping rehab plan (.work-files/switchboard/slug-grouping-investigation/rehab-plan.md, Option A: A3 nesting fix + A4 first real test of schedule-rerun grouping). PR 1 (A1+A2, dead plan-accept detection cleanup) is separate.

Test plan

  • New test/dom-slug-group-subagent-nesting.test.js: seeds two top-level sessions sharing a slug in the exact session_cache row shape schedule-runner.js:createScheduleSession() produces for two reruns of the same schedule, plus a subagent parented to one of them.
    • Confirmed failing on both assertions (missing caret, duplicated orphan bucket) against the unfixed code before applying the fix — pins the bug per rehab-plan.md A4.
    • All 3 assertions pass after the fix: caret/children attached inside the group, no orphan-bucket duplication, group dot lights up while the nested session's PTY is active.
  • The two existing Fix1 morphdom fixtures in test/dom-sidebar-perf.test.js that use buildSlugGroup's output as a stateful-DOM fixture still pass unmodified (only the internal signature changed; they exercise it through renderProjects, not directly).
  • task check (lint + full suite): 580 passed, 1 pre-existing skip, 0 failures.

Refs #128 (Part 2 of the cleanup plan)

JeanBaptisteRenard added a commit that referenced this pull request Aug 21, 2026
Review finding F1 on PR #134 (reviewer-r1-deliverable.md): nesting the
subagent's caret/children as DOM siblings inside a slug group means
group.querySelectorAll('.session-item') in the "Archive all sessions in
group" handler now also matches the nested subagent item (its className
includes session-item for shared styling), so archiveSession/stopSession
were reached with a subagent id. Apply the same :not([data-subagent])
guard already used elsewhere in this file.

Adds a 4th test to dom-slug-group-subagent-nesting.test.js pinning the
fix (archive-all on a group with an attached subagent only reaches the
two top-level ids) — confirmed failing without the guard, restored.
@JeanBaptisteRenard
JeanBaptisteRenard enabled auto-merge (squash) August 21, 2026 14:07
…ug groups

buildSlugGroup() appended its sessions via the raw buildSessionItem(session),
never through appendSubagentChildren — only the ungrouped top-level render
path called that helper. Any session rendered inside a slug group (e.g. a
schedule rerun sharing a slug with an earlier run, the only real producer of
grouped top-level sessions) silently lost its subagent caret/children, and
because the group <div> carries no dataset.sessionId, the orphan-subagents
pass in buildSessionsList didn't recognize the grouped session as accounted
for either, duplicating its subagents into the "Orphan subagents" bucket.

appendSubagentChildren() is hoisted to module scope so buildSlugGroup can
call it per session, and a new collectTopLevelSessionIds() walks into a
group element for the orphan-detection pass.

Adds test/dom-slug-group-subagent-nesting.test.js, seeded with the exact
session_cache row shape schedule-runner.js:createScheduleSession() produces
for two reruns of the same schedule — confirmed failing on both assertions
before the fix, per rehab-plan.md A3+A4.

Refs #128 (Part 2 of the cleanup plan)
Review finding F1 on PR #134 (reviewer-r1-deliverable.md): nesting the
subagent's caret/children as DOM siblings inside a slug group means
group.querySelectorAll('.session-item') in the "Archive all sessions in
group" handler now also matches the nested subagent item (its className
includes session-item for shared styling), so archiveSession/stopSession
were reached with a subagent id. Apply the same :not([data-subagent])
guard already used elsewhere in this file.

Adds a 4th test to dom-slug-group-subagent-nesting.test.js pinning the
fix (archive-all on a group with an attached subagent only reaches the
two top-level ids) — confirmed failing without the guard, restored.
@devsuitup
devsuitup force-pushed the fix/slug-group-subagent-nesting branch from 97e639b to 4e80273 Compare August 23, 2026 20:25
…subagent nesting

Adversarial review of #134 found appendSubagentChildren called from three
sites in buildSlugGroup (promoted / rest-under-more / no-active-session),
with only the promoted branch actually exercised by a test with a subagent
child. Add the two missing fixtures; mutation-tested by removing each call
in turn (restored afterward).
@devsuitup
devsuitup merged commit 3c2ccc0 into main Aug 23, 2026
7 checks passed
@devsuitup
devsuitup deleted the fix/slug-group-subagent-nesting branch August 23, 2026 20:45
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