fix: streaming diff debouncing (#2174)
This commit is contained in:
@@ -113,16 +113,15 @@ function M.func(opts, on_log, on_complete, session_ctx)
|
|||||||
|
|
||||||
local is_streaming = opts.streaming or false
|
local is_streaming = opts.streaming or false
|
||||||
|
|
||||||
|
local current_timestamp = os.time()
|
||||||
if is_streaming then
|
if is_streaming then
|
||||||
session_ctx.prev_streaming_diff_timestamp_map = session_ctx.prev_streaming_diff_timestamp_map or {}
|
session_ctx.prev_streaming_diff_timestamp_map = session_ctx.prev_streaming_diff_timestamp_map or {}
|
||||||
local prev_streaming_diff_timestamp = session_ctx.prev_streaming_diff_timestamp_map[opts.tool_use_id]
|
local prev_streaming_diff_timestamp = session_ctx.prev_streaming_diff_timestamp_map[opts.tool_use_id]
|
||||||
local current_timestamp = os.time()
|
|
||||||
if prev_streaming_diff_timestamp ~= nil then
|
if prev_streaming_diff_timestamp ~= nil then
|
||||||
if current_timestamp - prev_streaming_diff_timestamp < 2 then
|
if current_timestamp - prev_streaming_diff_timestamp < 2 then
|
||||||
return false, "Diff hasn't changed in the last 2 seconds"
|
return false, "Diff hasn't changed in the last 2 seconds"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
session_ctx.prev_streaming_diff_timestamp_map[opts.tool_use_id] = current_timestamp
|
|
||||||
local streaming_diff_lines_count = Utils.count_lines(opts.diff)
|
local streaming_diff_lines_count = Utils.count_lines(opts.diff)
|
||||||
session_ctx.streaming_diff_lines_count_history = session_ctx.streaming_diff_lines_count_history or {}
|
session_ctx.streaming_diff_lines_count_history = session_ctx.streaming_diff_lines_count_history or {}
|
||||||
local prev_streaming_diff_lines_count = session_ctx.streaming_diff_lines_count_history[opts.tool_use_id]
|
local prev_streaming_diff_lines_count = session_ctx.streaming_diff_lines_count_history[opts.tool_use_id]
|
||||||
@@ -180,6 +179,8 @@ function M.func(opts, on_log, on_complete, session_ctx)
|
|||||||
return false, "No diff blocks found"
|
return false, "No diff blocks found"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
session_ctx.prev_streaming_diff_timestamp_map[opts.tool_use_id] = current_timestamp
|
||||||
|
|
||||||
local bufnr, err = Helpers.get_bufnr(abs_path)
|
local bufnr, err = Helpers.get_bufnr(abs_path)
|
||||||
if err then return false, err end
|
if err then return false, err end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user