Summary
/clear creates a fresh session and clears the transcript, side panel, and diagram registry, but the TUI keeps the previous session's swarm_plan_items, swarm_plan_version, and swarm_plan_swarm_id. The new session therefore shows the old swarm plan as its todo list, often as a permanently blocked Plan 0/N panel.
The server also migrates the cleared session's swarm member and plan participant to the new session ID, so the stale plan can remain associated with the fresh session beyond the immediate client-side leak.
Live reproduction
Observed repeatedly, most recently on Jcode v0.68.0 in /home/joseph/git/work/devops-k8s-apps:
- Session
session_lion_1785967431956_42df39dbb0476edf had a deep swarm plan.
- Run
/clear.
- Server creates
session_horse_1785968588509_87dbde0c4153d4ec (SESSION_LIFECYCLE phase=clear_done, swarm_id_updated=true).
- The fresh
horse session still renders Plan 0/68, with all 68 nodes queued or blocked.
- Persisted workspace swarm state confirms the plan is version 19 with 68 queued items, while its coordinator remains the old
lion session.
This has been observed at least twice.
Root cause
Client-side full-discard paths clear the transcript but intentionally leave swarm plan snapshot fields intact:
crates/jcode-tui/src/tui/app/commands_review.rs::reset_current_session
crates/jcode-tui/src/tui/app/remote/key_handling.rs /clear branch
info_widget_data() substitutes swarm_plan_items for session todos whenever the vector is non-empty, so the old plan becomes the new session's Plan panel.
Existing tests explicitly pin the buggy behavior:
test_local_clear_command_clears_active_diagrams_but_keeps_swarm_plan_state
test_remote_clear_command_clears_active_diagrams_but_keeps_swarm_plan_state
Server-side, handle_clear_session() moves the old member to the new ID and calls rename_plan_participant(), which can prolong the association with the plan.
Expected behavior
A full /clear must not make the fresh session inherit or render the prior session's Plan panel. Full-discard paths should reset all client swarm-plan snapshot fields. Server lifecycle behavior should avoid reattaching an abandoned plan solely because the cleared session ID was replaced, while preserving genuinely live swarm work where required.
Acceptance criteria
- Local and remote
/clear clear swarm_plan_items, swarm_plan_version, and swarm_plan_swarm_id.
- The fresh session's info widget falls back to its own todo state and does not show the old
Plan 0/N.
- A regression test covers a real clear transition with an existing swarm plan.
- The server cannot immediately reintroduce an abandoned plan solely because it migrated the cleared session ID.
- Existing active-swarm continuity semantics are documented and tested.
Summary
/clearcreates a fresh session and clears the transcript, side panel, and diagram registry, but the TUI keeps the previous session'sswarm_plan_items,swarm_plan_version, andswarm_plan_swarm_id. The new session therefore shows the old swarm plan as its todo list, often as a permanently blockedPlan 0/Npanel.The server also migrates the cleared session's swarm member and plan participant to the new session ID, so the stale plan can remain associated with the fresh session beyond the immediate client-side leak.
Live reproduction
Observed repeatedly, most recently on Jcode v0.68.0 in
/home/joseph/git/work/devops-k8s-apps:session_lion_1785967431956_42df39dbb0476edfhad a deep swarm plan./clear.session_horse_1785968588509_87dbde0c4153d4ec(SESSION_LIFECYCLE phase=clear_done,swarm_id_updated=true).horsesession still rendersPlan 0/68, with all 68 nodes queued or blocked.lionsession.This has been observed at least twice.
Root cause
Client-side full-discard paths clear the transcript but intentionally leave swarm plan snapshot fields intact:
crates/jcode-tui/src/tui/app/commands_review.rs::reset_current_sessioncrates/jcode-tui/src/tui/app/remote/key_handling.rs/clearbranchinfo_widget_data()substitutesswarm_plan_itemsfor session todos whenever the vector is non-empty, so the old plan becomes the new session's Plan panel.Existing tests explicitly pin the buggy behavior:
test_local_clear_command_clears_active_diagrams_but_keeps_swarm_plan_statetest_remote_clear_command_clears_active_diagrams_but_keeps_swarm_plan_stateServer-side,
handle_clear_session()moves the old member to the new ID and callsrename_plan_participant(), which can prolong the association with the plan.Expected behavior
A full
/clearmust not make the fresh session inherit or render the prior session's Plan panel. Full-discard paths should reset all client swarm-plan snapshot fields. Server lifecycle behavior should avoid reattaching an abandoned plan solely because the cleared session ID was replaced, while preserving genuinely live swarm work where required.Acceptance criteria
/clearclearswarm_plan_items,swarm_plan_version, andswarm_plan_swarm_id.Plan 0/N.