Skip to content

Commit 65de4fc

Browse files
John-Linclaude
andcommitted
feat: add show_terminal_on_at_mention configuration option
- Add new config option to control terminal visibility for @ mentions - Remove show_terminal parameter from send_at_mention function - Update config validation to include new boolean option - Simplify visual selection @ mention calls 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 76cb6fb commit 65de4fc

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ For deep technical details, see [ARCHITECTURE.md](./ARCHITECTURE.md).
151151

152152
-- Selection Tracking
153153
track_selection = true,
154+
show_terminal_on_at_mention = true, -- Whether to show terminal when sending @ mentions
154155
visual_demotion_delay_ms = 50,
155156

156157
-- Terminal Configuration

lua/claudecode/config.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ M.defaults = {
88
terminal_cmd = nil,
99
log_level = "info",
1010
track_selection = true,
11+
show_terminal_on_at_mention = true, -- Whether to show terminal when sending @ mentions
1112
visual_demotion_delay_ms = 50, -- Milliseconds to wait before demoting a visual selection
1213
connection_wait_delay = 200, -- Milliseconds to wait after connection before sending queued @ mentions
1314
connection_timeout = 10000, -- Maximum time to wait for Claude Code to connect (milliseconds)
@@ -55,6 +56,8 @@ function M.validate(config)
5556

5657
assert(type(config.track_selection) == "boolean", "track_selection must be a boolean")
5758

59+
assert(type(config.show_terminal_on_at_mention) == "boolean", "show_terminal_on_at_mention must be a boolean")
60+
5861
assert(
5962
type(config.visual_demotion_delay_ms) == "number" and config.visual_demotion_delay_ms >= 0,
6063
"visual_demotion_delay_ms must be a non-negative number"

lua/claudecode/init.lua

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ M.version = {
3838
--- @field terminal_cmd string|nil Custom terminal command to use when launching Claude.
3939
--- @field log_level "trace"|"debug"|"info"|"warn"|"error" Log level.
4040
--- @field track_selection boolean Enable sending selection updates to Claude.
41+
--- @field show_terminal_on_at_mention boolean Whether to show terminal when sending @ mentions.
4142
--- @field visual_demotion_delay_ms number Milliseconds to wait before demoting a visual selection.
4243
--- @field connection_wait_delay number Milliseconds to wait after connection before sending queued @ mentions.
4344
--- @field connection_timeout number Maximum time to wait for Claude Code to connect (milliseconds).
@@ -251,6 +252,7 @@ end
251252
---@return string|nil error Error message if failed
252253
function M.send_at_mention(file_path, start_line, end_line, context)
253254
context = context or "command"
255+
local show_terminal = M.state.config.show_terminal_on_at_mention
254256

255257
if not M.state.server then
256258
logger.error(context, "Claude Code integration is not running")
@@ -259,15 +261,15 @@ function M.send_at_mention(file_path, start_line, end_line, context)
259261

260262
-- Check if Claude Code is connected
261263
if M.is_claude_connected() then
262-
-- Claude is connected, send immediately and ensure terminal is visible
264+
-- Claude is connected, send immediately and optionally ensure terminal is visible
263265
local success, error_msg = M._broadcast_at_mention(file_path, start_line, end_line)
264-
if success then
266+
if success and show_terminal then
265267
local terminal = require("claudecode.terminal")
266268
terminal.ensure_visible()
267269
end
268270
return success, error_msg
269271
else
270-
-- Claude not connected, queue the mention and launch terminal
272+
-- Claude not connected, queue the mention and optionally launch terminal
271273
local mention_data = {
272274
file_path = file_path,
273275
start_line = start_line,
@@ -277,9 +279,11 @@ function M.send_at_mention(file_path, start_line, end_line, context)
277279

278280
queue_at_mention(mention_data)
279281

280-
-- Launch terminal with Claude Code
281-
local terminal = require("claudecode.terminal")
282-
terminal.open()
282+
if show_terminal then
283+
-- Launch terminal with Claude Code
284+
local terminal = require("claudecode.terminal")
285+
terminal.open()
286+
end
283287

284288
logger.debug(context, "Queued @ mention and launched Claude Code: " .. file_path)
285289

0 commit comments

Comments
 (0)