-
Notifications
You must be signed in to change notification settings - Fork 81
feat(cli): add session selection and resume functionality #223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sei40kr
wants to merge
12
commits into
folke:main
Choose a base branch
from
sei40kr:feat/cli-session-selection
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Add session discovery for Claude CLI - Implement session picker UI with snacks - Add resume session functionality - Path mapping: both / and . replaced with - - Optimize: sort by mtime, read only top N files - Sessions sorted ascending (for snacks picker display) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Replace all non-alphanumeric characters (except -) with - - Example: test_with.symbols+chars@123 -> test-with-symbols-chars-123 - Matches Claude Code's actual path sanitization behavior 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Author
Naming Conflict IssueThe current implementation uses Current naming:
Possible alternatives for AI conversation history:
Feedback welcome on which naming would be clearest. |
…ve timestamps - Add humanize_time function for relative time display (e.g., "2 hours ago") - Implement column padding for CLI names and timestamps - Update M.format to support padded columns for better readability - Calculate max widths for CLI names and time strings for alignment
- Implement discover_sessions with git project and global support - Use vim.iter for functional-style data processing - Add resume configuration with -s flag - Support both project-specific and global session directories
Replace vim.fn functions with modern vim.uv and vim.fs equivalents for better performance and consistency. This includes fs_scandir for directory traversal, fs_stat for file metadata, fs_open/read/close for file reading, and json.decode for JSON parsing.
When resuming a session: - Close existing sessions of the same CLI tool - Hide terminals of different CLI tools that are currently open - Show new session normally if no conflicts
Add <leader>ar keybinding for session resume to match README
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Implements session (conversation history) selection and resume functionality for AI CLI tools in sidekick.nvim.
Users can now:
[CLI] [relative time] Session Title:Sidekick cli resumecommand or<leader>arkeybinding to select and resume a sessionImplementation Status
Phase 1: Core Infrastructure & Claude Code support ✅
-) replaced with-type: "summary"session filesrequire("sidekick.cli").select_session():Sidekick cli resumePhase 2: Multi-CLI Support ✅
~/.local/share/opencode/storage/session/{global|<projectID>}/ses_*.jsonworktreefield to project IDopencode -s <session_id>~/.codex/sessions/**/rollout-*.jsonl(recursive search)type: "session_meta"with session metadatacodex resume <session_id>Phase 3: Additional CLIs ✅
~/.gemini/tmp/<project_hash>/chats/session-*.jsonvim.fn.sha256)gemini --resume <session_id>UI Improvements ✅
Code Quality ✅
vim.uvandvim.fsAPIs instead ofvim.fnUsage
Via Command
Via Keybinding (Example)
{ "<leader>ar", function() require("sidekick.cli").select_session() end, desc = "Resume CLI Session", }Via Lua API
Technical Details
Data Model
Discovery Function Signature
---@field discover_sessions? fun(cwd: string, limit: number): sidekick.cli.session.Info[]Resume Implementation
Builds command:
<cli_cmd> <resume_args> <session_id>claude --resume <session_id>opencode -s <session_id>codex resume <session_id>gemini --resume <session_id>Session Discovery Details
Claude:
~/.claude/projects/<project>/<uuid>.jsonl-) replaced with-{"type": "summary", "summary": "..."}OpenCode:
~/.local/share/opencode/storage/session/{global|<projectID>}/ses_*.json~/.local/share/opencode/storage/project/*.jsonworktreefield in project metadataglobal/directory withdirectoryfield filterCodex:
~/.codex/sessions/**/rollout-*.jsonl(recursive){"type": "session_meta", "payload": {"id": "...", "cwd": "..."}}payload.cwdmatching current directoryGemini:
~/.gemini/tmp/<project_hash>/chats/session-*.jsonvim.fn.sha256(cwd))sessionId,messagesarrayTest Plan
:Sidekick cli resumecommand