Skip to content

Commit 6deb4f1

Browse files
committed
fix: git_diff not returning value
1 parent f145622 commit 6deb4f1

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

lua/opencode/context.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ ContextInstance.get_git_diff = Promise.async(function(self)
388388
return nil
389389
end
390390

391-
Promise.system({ 'git', 'diff', '--cached' })
391+
return Promise.system({ 'git', 'diff', '--cached' })
392392
end)
393393

394394
---@param opts? OpencodeContextConfig
@@ -779,6 +779,7 @@ M.format_message_quick_chat = Promise.async(function(prompt, context_instance)
779779
end
780780

781781
local diff_text = context_instance:get_git_diff():await()
782+
vim.print('⭕ ❱ context.lua:781 ❱ ƒ(diff_text) ❱ diff_text =', diff_text)
782783
if diff_text and diff_text ~= '' then
783784
table.insert(parts, format_git_diff_part(diff_text))
784785
end

lua/opencode/quick_chat.lua

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ local on_done = Promise.async(function(session_obj)
298298
cleanup_session(session_info, session_obj.id, 'Failed to update file with quick chat response') -- Error cleanup
299299
end
300300

301+
--@TODO: enable session deletion after testing
301302
-- Always delete ephemeral session
302303
-- state.api_client:delete_session(session_obj.id):catch(function(err)
303304
-- vim.notify('Error deleting ephemeral session: ' .. vim.inspect(err), vim.log.levels.WARN)
@@ -349,8 +350,8 @@ end
349350
---@param context_instance table Context instance
350351
---@param options table Options including model and agent
351352
---@return table params Message parameters
352-
local function create_message_params(message, context_instance, options)
353-
local quick_chat_config = config.values.quick_chat or {}
353+
local create_message = Promise.async(function(message, context_instance, options)
354+
local quick_chat_config = config.quick_chat or {}
354355
local instructions = quick_chat_config.instructions
355356
or {
356357
'You are an expert code assistant helping with code and text editing tasks.',
@@ -402,7 +403,7 @@ local function create_message_params(message, context_instance, options)
402403
end
403404

404405
return params
405-
end
406+
end)
406407

407408
--- Unified quick chat function
408409
---@param message string Optional custom message to use instead of default prompts
@@ -428,7 +429,6 @@ M.quick_chat = Promise.async(function(message, options, range)
428429
-- Setup context
429430
local context_config = vim.tbl_deep_extend('force', create_context_config(range ~= nil), options.context_config or {})
430431
local context_instance = setup_quick_chat_context(buf, context_config, range)
431-
432432
-- Check prompt guard
433433
local allowed, err_msg = util.check_prompt_allowed(config.values.prompt_guard, context_instance:get_mentioned_files())
434434
if not allowed then
@@ -456,7 +456,8 @@ M.quick_chat = Promise.async(function(message, options, range)
456456
}
457457

458458
-- Create and send message
459-
local params = create_message_params(message, context_instance, options)
459+
local params = create_message(message, context_instance, options):await()
460+
spinner:stop()
460461

461462
local success, err = pcall(function()
462463
state.api_client:create_message(quick_chat_session.id, params):await()

0 commit comments

Comments
 (0)