This commit is contained in:
2025-02-21 03:02:01 -08:00
parent 9bae49fa30
commit e216dc057c
8 changed files with 147 additions and 24 deletions

View File

@@ -48,7 +48,7 @@ function M:pop_progress_handle(id)
end
function M:create_progress_handle(request)
local title = " Requesting assistance"
local title = " Requesting assistance"
.. " ("
.. request.data.strategy
.. ") from "
@@ -56,7 +56,9 @@ function M:create_progress_handle(request)
.. " using "
.. request.data.adapter.model
local idx = 1
local notification_id = notify(spinner_frames[idx] .. " In progress...", "info", { title = title, timeout = false })
local start_time = os.time()
local notification_id =
notify(spinner_frames[idx] .. " In progress (" .. "0s" .. ")...", "info", { title = title, timeout = false })
local handle = { notification_id = notification_id, title = title, finished = false }
local timer = vim.loop.new_timer()
timer:start(
@@ -67,13 +69,17 @@ function M:create_progress_handle(request)
return
end -- stop updating if finished
idx = idx % spinner_len + 1
local elapsed = os.difftime(os.time(), start_time)
local opts = { replace = handle.notification_id, title = title, timeout = false }
local ok, new_id = safe_notify(spinner_frames[idx] .. " In progress...", "info", opts)
local ok, new_id = safe_notify(spinner_frames[idx] .. " In progress (" .. elapsed .. "s)...", "info", opts)
if ok then
handle.notification_id = new_id
else
handle.notification_id =
notify(spinner_frames[idx] .. " In progress...", "info", { title = title, timeout = false })
handle.notification_id = notify(
spinner_frames[idx] .. " In progress (" .. elapsed .. "s)...",
"info",
{ title = title, timeout = false }
)
end
end)
)