Skip to content

Add manual Agent project ordering#637

Merged
marksftw merged 2 commits into
masterfrom
codex/agent-project-ordering
Jul 16, 2026
Merged

Add manual Agent project ordering#637
marksftw merged 2 commits into
masterfrom
codex/agent-project-ordering

Conversation

@marksftw

@marksftw marksftw commented Jul 16, 2026

Copy link
Copy Markdown
Contributor
project-drag-and-drop.mov

Closes #633

What

  • Make Agent Mode project order user-controlled instead of activity-based.
  • Add whole-project drag-and-drop with an insertion marker, click/drag threshold, cancellation, edge scrolling, and the existing settling animation.
  • Persist order locally per account through a new Tauri command.
  • Optimistically update the sidebar, rolling back and surfacing an error if persistence fails.
  • Preserve automatic newest-first ordering for sessions within each project.

Why

Project order was previously changed in two places: native recent-root persistence promoted projects during runtime and session activity, while the sidebar sorted projects by lastUsedMs. Selecting a project or session could therefore move its project unexpectedly.

Impact

  • Selecting, starting, or opening Agent sessions no longer moves projects.
  • Newly added projects appear at the top without disturbing the existing order.
  • Manual order survives relaunches for the same account and device.
  • Persisted paths are validated and deduplicated, and stale requests cannot erase known roots.
  • Chat Mode and task-session ordering remain unchanged.
  • Reduced-motion behavior, row actions, disabled states, indicators, compact layouts, and scrolling remain supported.

Checks

  • just format
  • just lint — 0 errors; 12 pre-existing warnings
  • just build
  • cd frontend && bun test — 119 passed, 0 failed
  • just rust-lint — passed with existing Tao dependency warnings
  • cd frontend/src-tauri && cargo test --all-targets --locked — 123 passed, 0 failed
  • git diff --check
  • Local debug Tauri app built and launched successfully

Summary by CodeRabbit

  • New Features
    • Added drag-and-drop reordering for project roots in the Agent sidebar, with live insertion/ghost feedback.
    • Persist project-root ordering and restore it across sessions and restarts.
    • Updated session grouping to reflect the selected project-root order and sort sessions newest-first.
  • Bug Fixes
    • Prevent starting/restarting runtimes and creating sessions from reordering or mutating saved project-root history.
    • Improved resilience to legacy, stale, or corrupted stored project-root data.
  • Tests
    • Added coverage for queued operation blocking and project-ordering merge/reorder/persistence behaviors.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0229ea78-e8c0-45be-985f-8c4718b9d3d7

📥 Commits

Reviewing files that changed from the base of the PR and between 7dcdfe2 and b22853e.

📒 Files selected for processing (3)
  • frontend/src/components/AgentMode.tsx
  • frontend/src/services/agentProjectOrdering.test.ts
  • frontend/src/services/agentProjectOrdering.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • frontend/src/services/agentProjectOrdering.test.ts
  • frontend/src/services/agentProjectOrdering.ts
  • frontend/src/components/AgentMode.tsx

📝 Walkthrough

Walkthrough

Agent Mode now maintains manually ordered project roots separately from session recency. The backend validates and persists explicit orders, while the frontend provides optimistic reducer state, serialized mutations, and drag-and-drop ordering with insertion feedback.

Changes

Agent project ordering

Layer / File(s) Summary
Backend project-root persistence
frontend/src-tauri/src/agent.rs, frontend/src-tauri/src/lib.rs
Recent roots are sanitized and explicitly registered, runtime/session flows no longer reorder them, and a validated Tauri command persists manual ordering.
Ordering state and pure helpers
frontend/src/services/agentProjectOrdering.ts, frontend/src/services/agentProjectOrdering.test.ts
Reducer state, root merging, session grouping, drag calculations, and optimistic confirmation/rejection behavior are implemented and tested.
Agent Mode persistence integration
frontend/src/components/AgentMode.tsx, frontend/src/services/agentRuntimeService.ts, frontend/src/services/agentOperationFence.test.ts
Agent Mode hydrates and persists ordered roots through serialized mutations, while selected-root persistence remains separate from project registration.
Sidebar drag-and-drop UI
frontend/src/components/AgentMode.tsx
Project groups support drag measurement, insertion markers, ghost rendering, cancellation, and session-aware animations while preserving the ordered root model.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant AgentSidebarContent
  participant AgentMode
  participant AgentRuntimeService
  participant TauriBackend
  AgentSidebarContent->>AgentMode: report reordered project roots
  AgentMode->>AgentRuntimeService: saveProjectRootOrder(userId, paths)
  AgentRuntimeService->>TauriBackend: invoke agent_save_project_root_order
  TauriBackend-->>AgentRuntimeService: return persisted roots
  AgentRuntimeService-->>AgentMode: confirm or reject order
  AgentMode-->>AgentSidebarContent: render confirmed visible order
Loading

Poem

I’m a bunny with roots in a row,
Drag one gently, watch it go.
Orders save beneath the moon,
Sessions sort by newest tune.
Ghosts and markers guide the way—
Hop, reorder, done today!

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately summarizes the main change: manual Agent project ordering.
Linked Issues check ✅ Passed The changes implement draggable manual ordering, stable project positions, local persistence, and unchanged task-session ordering, matching issue #633.
Out of Scope Changes check ✅ Passed No clear unrelated code changes are indicated; the refactors and tests support the manual project-ordering work.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/agent-project-ordering

Comment @coderabbitai help to get the list of available commands.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 16, 2026

Copy link
Copy Markdown

Deploying maple with  Cloudflare Pages  Cloudflare Pages

Latest commit: b22853e
Status: ✅  Deploy successful!
Preview URL: https://4dea08b6.maple-ca8.pages.dev
Branch Preview URL: https://codex-agent-project-ordering.maple-ca8.pages.dev

View logs

@marksftw

Copy link
Copy Markdown
Contributor Author

Future Projects UX opportunities

These are follow-up opportunities rather than blockers for this Agent Mode change.

1. Drag-ordering performance

The current implementation is deliberately correctness-first and should be fast for ordinary project lists. During a drag, however, each native pointer update measures every project header and updates React state, which rerenders the project/session subtree. If profiling shows jank as lists grow, the highest-value improvements would be:

  • coalesce pointer movement through one requestAnimationFrame update;
  • cache header/group geometry at drag start, refreshing it only after scrolling, resizing, or another layout change;
  • isolate the drag ghost and insertion marker so their movement does not rerender every project and session row; and
  • apply will-change: transform only around reorder animation instead of permanently.

The persistence algorithm itself is already appropriate: validating and writing one complete ordered list is linear, simple, and reliable for this data size.

2. Extending this UX to Chat Projects

The pure ordering pieces are a good foundation, but the current implementation is not a drop-in Chat Mode feature. Before adding a second consumer:

  1. Extract generic ordering primitives from agentProjectOrdering.ts, keyed through getId(item) rather than the Agent-specific path property. Keep filesystem-root merging and Agent session grouping in an Agent-only module.
  2. Extract the pointer threshold, capture/cancellation, row measurement, insertion marker, ghost, auto-scroll, and FLIP behavior from AgentSidebarContent into a shared hook/component. It should accept an explicit scroll-container ref and an onCommit(order) callback, leaving persistence outside the UI primitive.
  3. Decide Chat persistence semantics first. Chat Projects are cloud entities, so server-synced ordering is preferable. That likely means a position/rank field plus a reorder endpoint with version or stale-set protection. If ordering is intentionally local-only, use user-scoped browser/app storage rather than the Agent Tauri path store.
  4. Centralize the Chat reorder mutation in the shared React Query project cache so ChatHistoryList, project pickers, and project detail views all see the same canonical order and can optimistically update/rollback together.
  5. Apply ordering before search filtering. During a filtered search, either disable dragging or merge the visible reorder back into the full list while preserving hidden projects. Also coordinate drag with Chat's pull-to-refresh, selection mode, mobile menus, expanded conversations, and project create/delete refetches.
  6. Add DOM interaction and accessibility coverage, including a keyboard-accessible way to move projects.

This keeps the current PR focused while giving Chat Mode a shared interaction primitive and the persistence model appropriate for cloud-backed projects.

@AnthonyRonning

AnthonyRonning commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

This is probably fine for now, I will need to consider where settings / preferences like this live long term.

I'm also not sure how this would behave on mobile but we don't expose agent mode on mobile yet so it's also fine for now probably.

@marksftw
marksftw marked this pull request as ready for review July 16, 2026 18:17

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

coderabbitai[bot]

This comment was marked as resolved.

@AnthonyRonning AnthonyRonning left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll likely change the entire "backend" architecture here around projects but this doesn't introduce too much that didn't already exist, and the frontend looks good, so merge whenever it's ready.

@marksftw
marksftw merged commit f073f64 into master Jul 16, 2026
18 checks passed
@marksftw
marksftw deleted the codex/agent-project-ordering branch July 16, 2026 20:04
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.

Agent Mode: Add manual project ordering

2 participants