Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lua/patch/core/workflow.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ local active_workflow

---@param message string
local function warn(message)
notify.send("patch: " .. message, vim.log.levels.WARN)
notify.send(message, vim.log.levels.WARN)
end

---@param message string
local function report_error(message)
notify.send("patch: " .. message, vim.log.levels.ERROR)
notify.send(message, vim.log.levels.ERROR)
end

---@param message string
local function report_info(message)
notify.send("patch: " .. message, vim.log.levels.INFO)
notify.send(message, vim.log.levels.INFO)
end

---@param err string|nil
Expand Down
5 changes: 4 additions & 1 deletion lua/patch/ui/notify.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ end
---@param level integer
---@param opts? table
function M.send(message, level, opts)
opts = vim.tbl_extend("keep", opts or {}, { title = "patch.nvim" })
opts = vim.tbl_extend("keep", opts or {}, {
title = "patch.nvim",
render = "compact",
})
local notifier = provider or vim.notify
notifier(message, level, opts)
end
Expand Down
4 changes: 2 additions & 2 deletions tests/patch/test_notify.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ T["uses vim.notify with the default title"] = function()

eq(received[1], "message")
eq(received[2], vim.log.levels.INFO)
eq(received[3], { title = "patch.nvim" })
eq(received[3], { title = "patch.nvim", render = "compact" })
end

T["uses a configured callable provider and preserves options"] = function()
Expand All @@ -39,7 +39,7 @@ T["uses a configured callable provider and preserves options"] = function()

eq(received[1], "warning")
eq(received[2], vim.log.levels.WARN)
eq(received[3], { title = "custom", timeout = 10 })
eq(received[3], { title = "custom", timeout = 10, render = "compact" })
end

return T
34 changes: 17 additions & 17 deletions tests/patch/test_workflow.lua
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,17 @@ test("runs capture, generation, review, and acceptance", function()
start_and_submit()

eq(requests[1].message, "built:change it")
assert(notification("patch: generating...", vim.log.levels.INFO))
assert(notification("generating...", vim.log.levels.INFO))

complete_generation("replacement", nil)
eq(mocks.replacement.applied, { location, "replacement" })
assert(notification("patch: complete", vim.log.levels.INFO))
assert(notification("complete", vim.log.levels.INFO))

patch.accept()
eq(mocks.replacement.accepted, proposal)

patch.accept()
assert(notification("patch: no active proposal to accept", vim.log.levels.WARN))
assert(notification("no active proposal to accept", vim.log.levels.WARN))
end)

test("rejects a reviewed proposal", function()
Expand All @@ -176,7 +176,7 @@ test("rejects a reviewed proposal", function()

eq(mocks.replacement.rejected, proposal)
patch.reject()
assert(notification("patch: no active proposal to reject", vim.log.levels.WARN))
assert(notification("no active proposal to reject", vim.log.levels.WARN))
end)

test("retries a proposal and applies the new response", function()
Expand All @@ -189,7 +189,7 @@ test("retries a proposal and applies the new response", function()

complete_generation("second", nil)
eq(mocks.replacement.retry_completed, { proposal, "second" })
assert(notification("patch: complete", vim.log.levels.INFO))
assert(notification("complete", vim.log.levels.INFO))
end)

test("aborts a failed retry and reports the error", function()
Expand All @@ -200,19 +200,19 @@ test("aborts a failed retry and reports the error", function()
complete_generation(nil, "request failed")

eq(mocks.replacement.retry_aborted, proposal)
assert(notification("patch: request failed", vim.log.levels.ERROR))
assert(notification("request failed", vim.log.levels.ERROR))
end)

test("cancels an active request and suppresses the cancellation error", function()
start_and_submit()

patch.cancel()
eq(requests[1].cancelled, true)
assert(notification("patch: cancelled", vim.log.levels.INFO))
assert(notification("cancelled", vim.log.levels.INFO))

complete_generation(nil, "cancelled")
eq(mocks.selection.cleared, location)
eq(notification("patch: cancelled", vim.log.levels.ERROR), nil)
eq(notification("cancelled", vim.log.levels.ERROR), nil)
end)

test("cleans up when input closes or generation fails", function()
Expand All @@ -224,21 +224,21 @@ test("cleans up when input closes or generation fails", function()
start_and_submit()
complete_generation(nil, "failed")
eq(mocks.selection.cleared, location)
assert(notification("patch: failed", vim.log.levels.ERROR))
assert(notification("failed", vim.log.levels.ERROR))
end)

test("blocks overlapping workflows", function()
patch.start()
patch.start()
assert(notification("patch: submit or close the active instruction first", vim.log.levels.WARN))
assert(notification("submit or close the active instruction first", vim.log.levels.WARN))

input.submit("change")
patch.start()
assert(notification("patch: a replacement is already being generated", vim.log.levels.WARN))
assert(notification("a replacement is already being generated", vim.log.levels.WARN))

complete_generation("replacement", nil)
patch.start()
assert(notification("patch: accept or reject the active proposal first", vim.log.levels.WARN))
assert(notification("accept or reject the active proposal first", vim.log.levels.WARN))
end)

test("ignores stale completion callbacks", function()
Expand All @@ -262,7 +262,7 @@ test("opens the model menu and records a selection", function()
eq(mocks.ui.menu.models[1].id, "model")
mocks.ui.menu.submit(mocks.ui.menu.models[1])

assert(notification("patch: using provider/model", vim.log.levels.INFO))
assert(notification("using provider/model", vim.log.levels.INFO))
end)

test("warns when actions have no active workflow", function()
Expand All @@ -271,9 +271,9 @@ test("warns when actions have no active workflow", function()
patch.retry()
patch.cancel()

assert(notification("patch: no active proposal to accept", vim.log.levels.WARN))
assert(notification("patch: no active proposal to reject", vim.log.levels.WARN))
assert(notification("patch: no active proposal to retry", vim.log.levels.WARN))
assert(notification("patch: nothing to cancel", vim.log.levels.WARN))
assert(notification("no active proposal to accept", vim.log.levels.WARN))
assert(notification("no active proposal to reject", vim.log.levels.WARN))
assert(notification("no active proposal to retry", vim.log.levels.WARN))
assert(notification("nothing to cancel", vim.log.levels.WARN))
end)
return T