Skip to content

Slug-based sidebar grouping only fires for scheduled-task reruns; plan-accept branch looks dead against current JSONL format #128

Description

@JeanBaptisteRenard

Summary

buildSlugGroup (public/sidebar.js:114-205) collapses sidebar sessions sharing session.slug once a project has 2+ top-level sessions with the same slug. On real data it never fires:

select count(*) from session_cache;                                          -- 1229
select count(*) from session_cache where parentSessionId is null or parentSessionId=''; -- 30
select slug, count(*) n from session_cache
  where (parentSessionId is null or parentSessionId='') and slug is not null and slug!=''
  group by slug having n>1;                                                  -- 0 rows

The only slug collisions are parent+subagent fan-out under a single plan (one slug shared by 1 parent + up to 292 subagents) — a different axis than what this feature groups on; subagents are excluded from the grouping input by design (sidebar.js:258).

What still legitimately uses this

schedule-runner.js's createScheduleSession() stamps the schedule's slug into every cron-triggered run (schedule-runner.js:150,176); schedule-ipc.js:99 documents grouping-by-schedule as an onboarding promise. Live and by design — just never fired twice in observed data.

What looks actually broken

The plan-accept branch in session-transitions.js:detectSessionTransitions() matches on tail.includes('ExitPlanMode') (session-transitions.js:225) — an older tool-use name. Current JSONL records plan exit as {"type":"attachment","attachment":{"type":"plan_mode_exit"}}. No file under ~/.claude/projects/**/*.jsonl contains a real "name":"ExitPlanMode" tool_use; the only matches are incidental text inside transcripts (a false-positive risk). The plan-accept branch (session-transitions.js:322-336) is likely unreachable today.

Ask

  1. Confirm whether plan-accept still splits files in current Claude Code; delete the branch + readOldSessionTail if not.
  2. If it does, fix the exit-detection string to match plan_mode_exit.
  3. Decide whether schedule-rerun grouping is worth keeping; if so add a test seeding two real createScheduleSession()-shaped rows sharing a slug.
  4. Fix the interaction bug where a session inside a rendered slug-group never gets its subagent children attached (buildSlugGroup appends via bare buildSessionItem, never appendSubagentChildren; the group wrapper has no dataset.sessionId for the outer loop to key off) — latent today, will misbehave the first time a schedule fires twice.

Evidence

  • git log --oneline --all -S 'buildSlugGroup' == same against upstream/main: upstream-original (671e69a, 2026-03-10), not fork-added.
  • Live DB counts/queries above (2026-08-19).
  • JSONL sampling: slug only appears once a plan file exists (named after the plan file), then propagates to every subsequent entry including subagent files spawned under it.

Full investigation notes: .work-files/switchboard/slug-grouping-investigation/findings.md (local).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions