Skip to content

fix(daemon): let move-down enter the only collapsed project below - #1304

Merged
edwin-zvs merged 1 commit into
mainfrom
fix/reorder-down-into-collapsed-project
Aug 22, 2026
Merged

fix(daemon): let move-down enter the only collapsed project below#1304
edwin-zvs merged 1 commit into
mainfrom
fix/reorder-down-into-collapsed-project

Conversation

@edwin-zvs

@edwin-zvs edwin-zvs commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

The bug

C-x C-n on session s3df84833c2dc49448a0ab9f3fcebaf90 did nothing, while C-x C-p on 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, asks region_below_skipping_collapsed for the next visible region, and all nine projects below construct-dev are collapsed — so it returns None and 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 returns false.
  • 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 test is green.

Spec

Adds specs/0209-reorder-never-dead-ends-at-a-visible-row.md and cross-references it from 0007. (Rebased onto current main, 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 single construct binary:

/Users/moon/agentd/.claude/worktrees/fix-reorder-down-collapsed/target/debug/construct

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
edwin-zvs force-pushed the fix/reorder-down-into-collapsed-project branch from 28a0a9e to 91f20bb Compare August 22, 2026 18:40
@edwin-zvs
edwin-zvs merged commit b671117 into main Aug 22, 2026
1 check passed
@edwin-zvs
edwin-zvs deleted the fix/reorder-down-into-collapsed-project branch August 22, 2026 18:49
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.

1 participant