-
Notifications
You must be signed in to change notification settings - Fork 12
feat: configurable auto-close and enhanced terminal architecture #31
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
Conversation
- Extended :ClaudeCode and :ClaudeCodeOpen commands to accept arguments - Arguments are appended to the configured terminal_cmd when launching Claude - Updated terminal module to support cmd_args parameter in open() and toggle() - Added comprehensive test coverage for argument handling and edge cases - Maintained full backward compatibility with existing usage Usage examples: - :ClaudeCode --resume - :ClaudeCodeOpen --help --verbose - :ClaudeCode (works as before with no arguments) Change-Id: I5ff2867e884f234a6b4fbaac065a39aa59cbf533 Signed-off-by: Thomas Kosiewski <[email protected]>
- Add <leader>ar for :ClaudeCode --resume - Add <leader>aC for :ClaudeCode --continue - Document new command argument support in Commands section - Maintain existing <leader>ac keybind for basic :ClaudeCode toggle Change-Id: I1ac31cb81750f420aef682aaccfa9068c67808b9 Signed-off-by: Thomas Kosiewski <[email protected]>
- Add my personal config for dev Change-Id: I68160a8c011cc46c2a954e11701217be649443bd Signed-off-by: Thomas Kosiewski <[email protected]>
…e management - Add auto_close configuration option (default: true) to control terminal lifecycle - Refactor terminal.lua into modular provider architecture with separate snacks and native providers - Simplify terminal state management using :buf_valid() instead of complex state tracking - Remove Snacks.terminal.get() usage to avoid invalid instance caching bugs - Add comprehensive error reporting with detailed context for terminal creation failures - Update README.md with auto_close documentation and usage examples - Add vim.v type definitions to eliminate LSP warnings - Update dev-config.lua with auto_close example - Maintain 100% API compatibility while improving reliability Change-Id: Iabc80707bf5f23890075c20d0f2abbdfa443e34e Signed-off-by: Thomas Kosiewski <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the terminal module to introduce a configurable auto-close behavior, a modular provider system supporting both snacks and native implementations, and enhanced command argument support. Key changes include adjusting tests to reflect the new provider API, updating command registrations and documentation, and simplifying state management in terminal operations.
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
tests/unit/terminal_spec.lua | Updated tests to use the new provider interface and verify command argument handling. |
tests/unit/init_spec.lua | Added tests for command registration and argument parsing for ClaudeCode commands. |
tests/integration/command_args_spec.lua | Integration tests ensuring proper appending of command arguments and native terminal fallback. |
lua/claudecode/terminal/snacks.lua | Redesigned snacks provider with auto-close and error handling improvements. |
lua/claudecode/terminal/native.lua | Introduced native terminal provider with command argument support and state recovery logic. |
lua/claudecode/meta/vim.lua | Added vim.v typing to support LSP type hints. |
lua/claudecode/init.lua | Updated command registrations to pass along command arguments. |
dev-config.lua | Provided updated development configuration examples. |
README.md | Documentation updated with new command usage examples and auto_close behavior details. |
Comments suppressed due to low confidence (1)
tests/unit/terminal_spec.lua:460
- [nitpick] Consider updating the test case description to clearly reflect the expected behavior of focusing an existing terminal and invoking provider open accordingly for clarity and maintainability.
it("should call provider open twice when terminal exists", function()
local current_mode = vim.fn.mode() | ||
if current_mode == "v" or current_mode == "V" or current_mode == "\22" then | ||
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<Esc>", true, false, true), "n", false) | ||
end | ||
terminal.toggle({}) | ||
local cmd_args = opts.args and opts.args ~= "" and opts.args or nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider extracting the command argument parsing logic into a helper function to improve readability and maintainability of the command registration code.
local cmd_args = opts.args and opts.args ~= "" and opts.args or nil | |
local cmd_args = parse_command_args(opts) |
Copilot uses AI. Check for mistakes.
…ally - Add scripts/run_integration_tests_individually.sh to run each integration test file separately - Update GitHub Actions workflow to use the new script instead of plenary test_directory - Fix terminal lifecycle mocking in command_args_spec.lua to properly simulate exit callbacks - Add cleanup of global deferred responses in server stop() function - Skip command_args_spec.lua in CI as it consistently hangs with plenary test_directory This is a workaround for plenary.test_harness.test_directory() hanging in headless mode when running integration tests that load claudecode. Individual test_file() calls work properly and allow all tests to complete successfully. Change-Id: Iec21e0db276d478c403a6dc703bdd1e8ef540ac8 Signed-off-by: Thomas Kosiewski <[email protected]>
Summary
auto_close
option (default: true) to control terminal lifecycle behavior:buf_valid()
approach instead of complex state tracking--continue
and--resume
command argumentsKey Features
Command Arguments Support (Fixes #17)
:ClaudeCode --resume
: Resume a specific Claude session as requested in [FEATURE] Open Claude code with --continue or --resume option #17:ClaudeCode --continue
: Continue previous work when restarting Neovim or PC as requested in [FEATURE] Open Claude code with --continue or --resume option #17:ClaudeCode [any arguments]
: Pass any arguments directly to the claude command:ClaudeCode
usage works exactly as beforeConfigurable Auto-Close Behavior
auto_close = true
(default): Terminal automatically closes after command completion with error notifications for failed commandsauto_close = false
: Terminal stays open for output review, useful for debugging and seeing detailed command resultsEnhanced Terminal Architecture
open()
andtoggle()
use consistent terminal creation logic throughM.open()
:buf_valid()
for terminal validity checks instead of complex state variablesDeveloper Experience Improvements
vim.v
definitions to eliminate LSP warningsTechnical Changes
Snacks.terminal.get()
calls that returned invalid cached instancesterminal_state
complexity in favor of simple buffer validity checksTest Results
Files Changed
lua/claudecode/terminal.lua
: Refactored to provider dispatcher with command argument supportlua/claudecode/terminal/snacks.lua
: Clean snacks provider implementationlua/claudecode/terminal/native.lua
: Clean native provider implementationlua/claudecode/init.lua
: Updated command registration to support argumentsREADME.md
: Added auto_close documentation and command argument examplesdev-config.lua
: Added development configuration templatelua/claudecode/meta/vim.lua
: Added vim.v type definitionsThis refactoring significantly improves terminal reliability while adding user-requested configurability for terminal lifecycle management and command argument support.