Skip to content

fix(web): keep sidebar thread order across restarts and make new rows draggable - #7

Merged
JTBroad merged 1 commit into
mainfrom
sidebar-drag-fixes
Jul 28, 2026
Merged

JTBroad merged 1 commit into
mainfrom
sidebar-drag-fixes

Conversation

@JTBroad

@JTBroad JTBroad commented Jul 28, 2026

Copy link
Copy Markdown
Owner

Fixes two separate defects in the v2 sidebar's drag-to-reorder.

1. Persisted order was wiped on every restart

The prune effect only gated on "is an environment connected". On a cold start the environment descriptor arrives before the thread snapshot does, leaving a window where every environment looks connected with zero live threads. pruneThreadOrder then dropped every persisted key and the list fell back to the default created-date sort.

Gated the effect on useAllEnvironmentShellsBootstrapped() so an absence of threads is only trusted once the snapshots have actually landed.

2. New threads snapped back when dragged

reorderThreads can only splice keys already present in threadOrder, and unranked threads are absent from it by design — orderThreadsByPreferredKeys deliberately floats never-dragged threads to the top, outside the order array. So removed.length === 0 and the reducer returned state unchanged.

The existing seed-from-rendered-list fallback only applied when threadOrder was entirely empty, so it never helped once the user had dragged anything.

Now the drag baseline folds unranked rendered keys in at their displayed position, so any visible row is draggable. This also covers dragging a thread that is actively working, since that is usually a recently created one.

New threads still appear at the top by default — the unknown-first ordering is untouched; the first drag simply pins them into the order. No change was needed at the thread-creation site.

Reviewer notes

  • Single file changed: apps/web/src/components/SidebarV2.tsx.
  • tsc --noEmit clean; existing uiStateStore.test.ts (15 tests) passes.
  • No new tests. The drag baseline is easy to cover in uiStateStore.test.ts; the prune race needs a component-level test. Happy to add both if wanted.
  • Not verified against the running app. Both fixes are reasoned from the code, not observed end-to-end — the restart fix especially deserves a manual close/reopen before merging.

🤖 Generated with Claude Code

… draggable

Two separate defects in the v2 sidebar's drag-to-reorder.

The persisted order was wiped on every app start. The prune effect only
gated on "is an environment connected", but on a cold start the
environment descriptor arrives before the thread snapshot does — leaving
a window where every environment looks connected with zero live threads.
pruneThreadOrder then dropped every persisted key, and the list fell back
to the default created-date sort. Gate the effect on
useAllEnvironmentShellsBootstrapped() so an absence of threads is only
trusted once the snapshots have actually landed.

Dragging a freshly created thread did nothing — the row moved and snapped
back. reorderThreads can only splice keys already present in the order,
and unranked threads (every new one, which render at the top per
orderThreadsByPreferredKeys) are absent from it by design. The existing
seed only applied when threadOrder was entirely empty, so it never helped
once the user had dragged anything. Build the drag baseline by folding
unranked rendered keys in at their displayed position, making any visible
row draggable — including a thread that is actively working, which is
usually a recently created one.

Co-Authored-By: Claude <noreply@anthropic.com>
@JTBroad
JTBroad merged commit f236b90 into main Jul 28, 2026
6 of 10 checks passed
@JTBroad
JTBroad deleted the sidebar-drag-fixes branch July 28, 2026 17:28
@github-actions github-actions Bot added the vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. label Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant