feat: add recent cwd path selection
Problem: Users who frequently switch between working directories had to re-enter custom paths or scroll through all session-derived projects to find their desired directory. There was no persistence of manually entered or recently used paths — they were lost after navigating away. Changes:
- New API endpoint app/api/cwd/recent/route.ts
- GET /api/cwd/recent — returns the list of recent working directories from ~/.pi/agent/recent-cwds.json
- POST /api/cwd/recent — accepts { cwd: string }, prepends it to the recent list (deduplicated), caps at 10 entries, and persists to the JSON file
- components/SessionSidebar.tsx
- On mount, fetches the recent paths list and stores it in local state
- Whenever the user selects a CWD (via project list, custom path, default directory, or worktree switch), a debounced effect records it as a recent path via POST /api/cwd/recent
- The CWD dropdown now includes a "Recent" section between the project list and the "Default directory"/"Custom path" actions
- Recent paths that already appear in the current project list are filtered out to avoid duplication
- Up to 5 recent paths are shown, each with a folder icon and left-ellipsized path label
- The "Recent" section is hidden when the project filter is active to avoid confusion
Thanks for the contribution. The current CWD selector already lists session-backed projects ordered by recent activity, with filtering for larger lists.
We’d like to keep the selector scoped to directories that have sessions, so we don’t need a separate persisted “Recent paths” list at this time. We’ll close this PR for now. Thanks for understanding.