From 8441cbf9732dec24871b24ba4c6ff3d5e9073fa9 Mon Sep 17 00:00:00 2001 From: alsi-lawr Date: Sat, 11 Jul 2026 12:33:35 +0100 Subject: [PATCH] fix(ui): polish native rounded float --- README.md | 5 +++-- doc/agent-term.txt | 3 +++ lua/agent_term/ui/float/native.lua | 6 +++--- tests/spec/config_spec.lua | 1 + tests/spec/ui_spec.lua | 10 ++++++---- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 3a0eb5e..36e384a 100644 --- a/README.md +++ b/README.md @@ -190,8 +190,9 @@ its terminal session. ## Float Window Hosts The built-in `native` host is the default. It uses Neovim's window API directly, has no optional UI -dependency, and provides the agent-aware title, border highlights, and responsive sizing described -by the shared float settings. +dependency, and has a rounded border with a centered, agent-aware title. Its surface and border use +the editor's base `Normal` highlight rather than the raised `NormalFloat` background. Responsive +sizing is shared by both float hosts. Set `float.host = "snacks"` to use [`Snacks.win`](https://github.com/folke/snacks.nvim/blob/main/docs/win.md) for floating views: diff --git a/doc/agent-term.txt b/doc/agent-term.txt index ee4331a..754b5b1 100644 --- a/doc/agent-term.txt +++ b/doc/agent-term.txt @@ -96,6 +96,9 @@ Float keys: `height` Proportion (0, 1] of editor height or row count; default: 0.8 `border` Neovim floating-window border; default: "rounded" +The native float has a rounded border and centered agent-aware title by +default. Its surface and border use the editor's base `Normal` highlight. + The Snacks host is optional and applies only to floats; panels always remain native. If `host = "snacks"` cannot load snacks.nvim, Agent Term warns and caches the native fallback for the current Neovim run while the configured diff --git a/lua/agent_term/ui/float/native.lua b/lua/agent_term/ui/float/native.lua index 244f211..8e0ce01 100644 --- a/lua/agent_term/ui/float/native.lua +++ b/lua/agent_term/ui/float/native.lua @@ -12,9 +12,9 @@ local winhighlight = table.concat({ }, ",") local function apply_default_highlights() - vim.api.nvim_set_hl(0, "AgentTermFloat", { default = true, link = "NormalFloat" }) - vim.api.nvim_set_hl(0, "AgentTermFloatBorder", { default = true, link = "FloatBorder" }) - vim.api.nvim_set_hl(0, "AgentTermFloatTitle", { default = true, link = "FloatTitle" }) + vim.api.nvim_set_hl(0, "AgentTermFloat", { default = true, link = "Normal" }) + vim.api.nvim_set_hl(0, "AgentTermFloatBorder", { default = true, link = "Normal" }) + vim.api.nvim_set_hl(0, "AgentTermFloatTitle", { default = true, link = "Title" }) end apply_default_highlights() diff --git a/tests/spec/config_spec.lua b/tests/spec/config_spec.lua index aa40593..de8b96f 100644 --- a/tests/spec/config_spec.lua +++ b/tests/spec/config_spec.lua @@ -50,6 +50,7 @@ describe("Given multi-agent configuration", function() assert.are.equal("codex", config.active_agent) assert.is_false(opts.agents.codex.context.hook.enabled) assert.are.equal("native", opts.float.host) + assert.are.equal("rounded", opts.float.border) assert.is_false(opts.keymaps) end) diff --git a/tests/spec/ui_spec.lua b/tests/spec/ui_spec.lua index 37488de..83e850a 100644 --- a/tests/spec/ui_spec.lua +++ b/tests/spec/ui_spec.lua @@ -75,27 +75,29 @@ describe("Given Agent Term UI views", function() assert.are.equal(gemini, state.session("gemini").float_win) end) - it("When opening the native float Then its title and highlights identify the agent", function() + it("When opening the native float Then its rounded frame and title identify the agent", function() local bufnr = track_buf(vim.api.nvim_create_buf(false, true)) local win = float.open(bufnr, "codex") local win_config = vim.api.nvim_win_get_config(win) local window_highlights = vim.api.nvim_get_option_value("winhighlight", { win = win }) + assert.are.equal("rounded", config.options.float.border) + assert.are.same({ "╭", "─", "╮", "│", "╯", "─", "╰", "│" }, win_config.border) assert.are.same({ { " Agent Term · codex ", "AgentTermFloatTitle" } }, win_config.title) assert.are.equal("center", win_config.title_pos) assert.matches("Normal:AgentTermFloat", window_highlights, 1, true) assert.matches("FloatBorder:AgentTermFloatBorder", window_highlights, 1, true) assert.matches("FloatTitle:AgentTermFloatTitle", window_highlights, 1, true) assert.are.equal( - "NormalFloat", + "Normal", vim.api.nvim_get_hl(0, { name = "AgentTermFloat", link = true }).link ) assert.are.equal( - "FloatBorder", + "Normal", vim.api.nvim_get_hl(0, { name = "AgentTermFloatBorder", link = true }).link ) assert.are.equal( - "FloatTitle", + "Title", vim.api.nvim_get_hl(0, { name = "AgentTermFloatTitle", link = true }).link ) end)