Skip to content

Commit 9c74ead

Browse files
authored
feat: add Claude Haiku model and update type annotations (#110)
# Update Claude model options and improve type annotations This PR updates the available Claude models to include: - Renamed "Claude Opus 4" to "Claude Opus 4.1 (Latest)" - Added "Claude Haiku 3.5 (Latest)" as a new model option Additionally, improves type safety throughout the codebase by: - Adding proper type annotations for configuration parameters - Adding explicit types for global variables - Fixing function parameter types to use `ClaudeCodeConfig` where appropriate - Properly documenting the `active_diffs` table with type information - Removing an unnecessary timeout parameter in a callback function
1 parent d73a464 commit 9c74ead

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

lua/claudecode/config.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ M.defaults = {
2626
keep_terminal_focus = false, -- If true, moves focus back to terminal after diff opens
2727
},
2828
models = {
29-
{ name = "Claude Opus 4 (Latest)", value = "opus" },
29+
{ name = "Claude Opus 4.1 (Latest)", value = "opus" },
3030
{ name = "Claude Sonnet 4 (Latest)", value = "sonnet" },
31+
{ name = "Claude Haiku 3.5 (Latest)", value = "haiku" },
3132
},
3233
terminal = nil, -- Will be lazy-loaded to avoid circular dependency
3334
}

lua/claudecode/diff.lua

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ local logger = require("claudecode.logger")
66

77
-- Global state management for active diffs
88

9-
local active_diffs = {}
10-
local autocmd_group
9+
---@type ClaudeCodeConfig
1110
local config
1211

12+
---@type number
13+
local autocmd_group
1314
---Get or create the autocmd group
1415
local function get_autocmd_group()
1516
if not autocmd_group then
@@ -112,7 +113,7 @@ local function is_buffer_dirty(file_path)
112113
end
113114

114115
---Setup the diff module
115-
---@param user_config table? The configuration passed from init.lua
116+
---@param user_config ClaudeCodeConfig? The configuration passed from init.lua
116117
function M.setup(user_config)
117118
-- Store the configuration for later use
118119
config = user_config or {}
@@ -336,6 +337,9 @@ function M._open_native_diff(old_file_path, new_file_path, new_file_contents, ta
336337
}
337338
end
338339

340+
---@type table<string, table>
341+
local active_diffs = {}
342+
339343
---Register diff state for tracking
340344
---@param tab_name string Unique identifier for the diff
341345
---@param diff_data table Diff state data
@@ -638,7 +642,7 @@ function M._create_diff_view_from_window(target_window, old_file_path, new_buffe
638642
if terminal_win then
639643
vim.api.nvim_set_current_win(terminal_win)
640644
end
641-
end, 0)
645+
end)
642646
end
643647

644648
-- Return window information for later storage

lua/claudecode/server/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ M.state = {
2525
}
2626

2727
---Initialize the WebSocket server
28-
---@param config table Configuration options
28+
---@param config ClaudeCodeConfig Configuration options
2929
---@param auth_token string|nil The authentication token for validating connections
3030
---@return boolean success Whether server started successfully
3131
---@return number|string port_or_error Port number or error message

lua/claudecode/server/tcp.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function M.find_available_port(min_port, max_port)
4949
end
5050

5151
---Create and start a TCP server
52-
---@param config table Server configuration
52+
---@param config ClaudeCodeConfig Server configuration
5353
---@param callbacks table Callback functions
5454
---@param auth_token string|nil Authentication token for validating connections
5555
---@return TCPServer|nil server The server object, or nil on error

0 commit comments

Comments
 (0)