fix(daemon): let move-down enter the only collapsed project below - #1304
Merged
Conversation
Reordering a session down did nothing whenever every project below it was collapsed, while reordering the same session up worked. The asymmetry is structural, not incidental: the ungrouped region always renders first and can never be collapsed, so an upward skip always has somewhere to land, but a downward skip needs an *expanded* region below. In the steady state of a working fleet — one project expanded, the rest collapsed — the last session of the first project could never move down at all, with project rows sitting plainly beneath it and the TUI reporting "nothing to reorder past". When the collapsed-skip runs out of regions, fall back to the adjacent one, expand it, and land the session at its top. Expanding is what keeps the visible model honest: dropping the session into a collapsed project would look like deleting it from the list. Spec 0007's jump is untouched — whenever any visible region exists beyond a collapsed one, the collapsed project is still skipped whole and its members and collapse state are left alone. A no-op from move-down now means the true bottom of the list, so the existing status message is accurate rather than misleading. Move-up needs no counterpart; that branch is unreachable for the reason above, so it is documented in the code rather than written untestable.
edwin-zvs
force-pushed
the
fix/reorder-down-into-collapsed-project
branch
from
August 22, 2026 18:40
28a0a9e to
91f20bb
Compare
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.
The bug
C-x C-non sessions3df84833c2dc49448a0ab9f3fcebaf90did nothing, whileC-x C-pon the same session reordered it fine. Not a keybinding or TUI-dispatch problem — the daemon refuses. Calling the move directly returns{"moved": false, "ok": true}having mutated nothing.The session is the last of 10 in project
construct-dev. Moving up takes the same-region swap branch and never reaches the cross-region path. Moving down falls through to the region-bottom branch, asksregion_below_skipping_collapsedfor the next visible region, and all nine projects belowconstruct-devare collapsed — so it returnsNoneand the move is refused. The TUI then shows "nothing to reorder past" for 5s while nine project rows sit visibly below the session.The asymmetry is structural. The ungrouped region always renders above every project and can never be collapsed, so an upward skip always has somewhere to land; a downward skip needs an expanded project below. In the ordinary steady state — one project expanded, the rest collapsed — the last session of the first project can never move down at all.
The fix
When the collapsed-skip runs out of regions, fall back to the adjacent region, expand it via
set_group_collapsed, and land the session at its top. Expanding is the part that keeps the visible model honest: landing inside a still-collapsed project would look like the session was deleted from the list.Spec 0007's jump is untouched. Whenever any visible region exists beyond a collapsed one, the collapsed project is still skipped whole and its members and collapse state are left alone. Only the dead end changes.
Move-up gets no counterpart — that branch is unreachable for the reason above — so the asymmetry is documented in the code rather than written as untestable code.
A no-op from move-down now genuinely means the bottom of the list, so the existing "nothing to reorder past" status is accurate. No TUI change needed.
Tests
move_session_down_expands_the_only_collapsed_region_below— one expanded project on top, two collapsed below: the move reports a real reorder, lands the session at the top of the nearest collapsed project, expands only that project, and leaves the other collapsed.move_session_down_stops_at_the_last_project— the last member of the last project still returnsfalse.move_session_jumps_over_collapsed_project(existing, unchanged) — an expanded project beyond a collapsed one still wins the skip, and the skipped project stays collapsed with untouched members.Full unfiltered
cargo testis green.Spec
Adds
specs/0209-reorder-never-dead-ends-at-a-visible-row.mdand cross-references it from 0007. (Rebased onto currentmain, which took 0208 for the OpenRouter spec in #1303.)No recording
Daemon-side ordering rule. Demoing it in vhs would mean staging a synthetic multi-project fleet through TUI keystrokes (the CLI has no project-creation subcommand), and the behavior is fully covered by the unit-test topology. Flagging the omission rather than silently skipping it.
Binary
Code lives in
crates/daemon→ surfaced through the singleconstructbinary:/Users/moon/agentd/.claude/worktrees/fix-reorder-down-collapsed/target/debug/construct