fix(dashboard): Dashboard cards jump around during refresh (IW-175) #179

Merged
mprihoda merged 10 commits from IW-175 into main 2026-01-28 09:54:35 +00:00
mprihoda commented 2026-01-28 09:35:35 +00:00 (Migrated from github.com)

Summary

Fixes dashboard cards jumping around during auto-refresh, which caused users to accidentally click the wrong card when the UI updated mid-interaction.

Root cause: Cards were sorted by lastSeenAt timestamp, which changed on every refresh cycle.

Solution: Sort cards by Issue ID (alphabetical) for stable, predictable ordering.

Changes

Phase 1: Stable card positions during auto-refresh

  • Replaced listByActivity with listByIssueId in ServerState
  • Updated DashboardService and CaskServer to use stable Issue ID sorting
  • Added 9 unit tests for sorting behavior

Phase 2: New worktrees appear at predictable location

  • Added findPredecessor helper for positional insertion
  • Updated generateAdditionOob to use HTMX afterbegin/afterend for correct placement
  • Added 10 unit tests for positional insertion

Phase 3: Removed worktrees shift remaining cards predictably

  • Verified existing deletion logic works correctly with stable sorting
  • Added 6 unit tests confirming deletions don't trigger reorders

Test Plan

  • Unit tests pass (25 new tests added across phases)
  • Manual verification: Dashboard cards stay in place during refresh
  • Manual verification: New worktrees appear in correct sorted position
  • Manual verification: Deleted worktrees disappear without shifting others unexpectedly

Files Changed

File Change
.iw/core/model/ServerState.scala Added listByIssueId method
.iw/core/test/ServerStateTest.scala Added sorting tests
.iw/core/test/WorktreeListSyncTest.scala Added insertion and deletion tests

🤖 Generated with Claude Code

## Summary Fixes dashboard cards jumping around during auto-refresh, which caused users to accidentally click the wrong card when the UI updated mid-interaction. **Root cause**: Cards were sorted by `lastSeenAt` timestamp, which changed on every refresh cycle. **Solution**: Sort cards by Issue ID (alphabetical) for stable, predictable ordering. ## Changes ### Phase 1: Stable card positions during auto-refresh - Replaced `listByActivity` with `listByIssueId` in ServerState - Updated DashboardService and CaskServer to use stable Issue ID sorting - Added 9 unit tests for sorting behavior ### Phase 2: New worktrees appear at predictable location - Added `findPredecessor` helper for positional insertion - Updated `generateAdditionOob` to use HTMX `afterbegin`/`afterend` for correct placement - Added 10 unit tests for positional insertion ### Phase 3: Removed worktrees shift remaining cards predictably - Verified existing deletion logic works correctly with stable sorting - Added 6 unit tests confirming deletions don't trigger reorders ## Test Plan - [x] Unit tests pass (25 new tests added across phases) - [ ] Manual verification: Dashboard cards stay in place during refresh - [ ] Manual verification: New worktrees appear in correct sorted position - [ ] Manual verification: Deleted worktrees disappear without shifting others unexpectedly ## Files Changed | File | Change | |------|--------| | `.iw/core/model/ServerState.scala` | Added `listByIssueId` method | | `.iw/core/test/ServerStateTest.scala` | Added sorting tests | | `.iw/core/test/WorktreeListSyncTest.scala` | Added insertion and deletion tests | 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
No description provided.