Skip to content

Commit 7c36cad

Browse files
committed
Revert "Merge pull request #47 from editor-code-assistant/select-model-and-behavior"
This reverts commit 9c90bad, reversing changes made to 8ae1e0a.
1 parent 9c90bad commit 7c36cad

File tree

10 files changed

+7
-347
lines changed

10 files changed

+7
-347
lines changed

lua/eca/commands.lua

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -343,50 +343,6 @@ function M.setup()
343343
desc = "Emergency fix for treesitter issues in ECA chat",
344344
})
345345

346-
vim.api.nvim_create_user_command("EcaChatSelectModel", function()
347-
local eca = require("eca")
348-
349-
if not eca or not eca.current or not eca.current.sidebar then
350-
Logger.notify("No active ECA sidebar found", vim.log.levels.WARN)
351-
return
352-
end
353-
354-
local chat = eca.current.sidebar
355-
local models = chat.mediator:models()
356-
357-
vim.ui.select(models, {
358-
prompt = "Select ECA Chat Model:",
359-
}, function(choice)
360-
if choice then
361-
chat.mediator:update_selected_model(choice)
362-
end
363-
end)
364-
end, {
365-
desc = "Select current ECA Chat model",
366-
})
367-
368-
vim.api.nvim_create_user_command("EcaChatSelectBehavior", function()
369-
local eca = require("eca")
370-
371-
if not eca or not eca.current or not eca.current.sidebar then
372-
Logger.notify("No active ECA sidebar found", vim.log.levels.WARN)
373-
return
374-
end
375-
376-
local chat = eca.current.sidebar
377-
local behaviors = chat.mediator:behaviors()
378-
379-
vim.ui.select(behaviors, {
380-
prompt = "Select ECA Chat Behavior:",
381-
}, function(choice)
382-
if choice then
383-
chat.mediator:update_selected_behavior(choice)
384-
end
385-
end)
386-
end, {
387-
desc = "Select current ECA Chat behavior",
388-
})
389-
390346
Logger.debug("ECA commands registered")
391347
end
392348

lua/eca/mediator.lua

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,30 +26,14 @@ function mediator:send(method, params, callback)
2626
self.server:send_request(method, params, callback)
2727
end
2828

29-
function mediator:behaviors()
30-
return self.state.config.behaviors.list
31-
end
32-
3329
function mediator:selected_behavior()
3430
return self.state.config.behaviors.selected
3531
end
3632

37-
function mediator:update_selected_behavior(behavior)
38-
self.state:update_selected_behavior(behavior)
39-
end
40-
41-
function mediator:models()
42-
return self.state.config.models.list
43-
end
44-
4533
function mediator:selected_model()
4634
return self.state.config.models.selected
4735
end
4836

49-
function mediator:update_selected_model(model)
50-
self.state:update_selected_model(model)
51-
end
52-
5337
function mediator:tokens_session()
5438
return self.state.usage.tokens.session
5539
end

lua/eca/server.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ end
9898
---in testing
9999
---@param opts? eca.ServerStartOpts
100100
function M:start(opts)
101-
opts = vim.tbl_deep_extend("force", { initialize = true }, opts or {})
101+
opts = opts or { initialize = true }
102102

103103
local this_file = debug.getinfo(1, "S").source:sub(2)
104104
local proj_root = vim.fn.fnamemodify(this_file, ":p:h:h:h")
@@ -112,7 +112,7 @@ function M:start(opts)
112112

113113
local lua_cmd = string.format("lua ServerPath.run(%s)", Utils.lua_quote(Config.server_path or ""))
114114

115-
local cmd = { nvim_exe, "--headless", "--noplugin", (opts.clean and " --clean" or ""), "-u", script_path, "-c", lua_cmd }
115+
local cmd = { nvim_exe, "--headless", "--noplugin", "-u", script_path, "-c", lua_cmd }
116116

117117
vim.system(cmd, { text = true }, function(out)
118118
if out.code ~= 0 then

lua/eca/sidebar.lua

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,8 +1279,6 @@ function M:_send_message(message)
12791279
requestId = tostring(os.time()),
12801280
message = message,
12811281
contexts = contexts or {},
1282-
model = self.mediator:selected_model(),
1283-
behavior = self.mediator:selected_behavior(),
12841282
}, function(err, result)
12851283
if err then
12861284
print("err is " .. err)

lua/eca/state.lua

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ end
168168
function State:_update_usage(usage)
169169
self.usage = {
170170
tokens = {
171-
limit = (usage.limit and usage.limit.context) or self.usage.tokens.limit,
171+
limit = (usage.limit and usage.limit.output) or self.usage.tokens.limit,
172172
session = usage.sessionTokens or self.usage.tokens.session,
173173
},
174174
costs = {
@@ -198,28 +198,4 @@ function State:_update_tools(tool)
198198
end)
199199
end
200200

201-
function State:update_selected_model(model)
202-
if not model or type(model) ~= "string" then
203-
return
204-
end
205-
206-
self.config.models.selected = model
207-
208-
vim.schedule(function()
209-
require("eca.observer").notify({ type = "state/updated", content = { config = vim.deepcopy(self.config) } })
210-
end)
211-
end
212-
213-
function State:update_selected_behavior(behavior)
214-
if not behavior or type(behavior) ~= "string" then
215-
return
216-
end
217-
218-
self.config.behaviors.selected = behavior
219-
220-
vim.schedule(function()
221-
require("eca.observer").notify({ type = "state/updated", content = { config = vim.deepcopy(self.config) } })
222-
end)
223-
end
224-
225201
return State

scripts/server_path.lua

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,9 @@ local ServerPath = {}
33
-- Setup if headless
44
if #vim.api.nvim_list_uis() == 0 then
55
_G.ServerPath = ServerPath
6-
7-
-- hijack to make server tests work on CI using --clean mode
8-
local eca_available = pcall(require, "eca")
9-
if not eca_available then
10-
vim.cmd([[let &rtp.=','.getcwd()]])
11-
vim.cmd('set rtp+=deps/nui.nvim')
12-
vim.cmd('set rtp+=deps/eca-nvim')
13-
end
14-
156
vim.o.swapfile = false
167
vim.o.backup = false
178
vim.o.writebackup = false
18-
199
require("eca").setup({})
2010
end
2111

tests/test_select_commands.lua

Lines changed: 0 additions & 175 deletions
This file was deleted.

tests/test_server_integration.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ end
4040
T["server"] = MiniTest.new_set()
4141

4242
T["server"]["start"] = function()
43-
child.lua("_G.server:start({ clean = true })")
43+
child.lua("_G.server:start()")
4444
child.lua([[
4545
_G.server_started = vim.wait(10000, function()
4646
return _G.server and _G.server:is_running()
@@ -52,7 +52,7 @@ T["server"]["start"] = function()
5252
end
5353

5454
T["server"]["start without initialize"] = function()
55-
child.lua("_G.server:start({ clean = true, initialize = false })")
55+
child.lua("_G.server:start({ initialize = false })")
5656
child.lua([[
5757
_G.server_started = vim.wait(10000, function()
5858
return _G.server and _G.server:is_running()
@@ -67,7 +67,7 @@ T["server"]["start with inexistent path"] = function()
6767
child.lua([[
6868
Config = require("eca.config")
6969
Config.setup({ server_path = "non-existing-path" } )
70-
_G.server:start({ clean = true })
70+
_G.server:start()
7171
]])
7272
child.lua([[
7373
_G.server_started = vim.wait(1000, function()

tests/test_server_path.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ local function setup_test_environment()
99
"nvim",
1010
"--headless",
1111
"--noplugin",
12-
"--clean",
1312
"--cmd",
1413
[[lua package.preload["eca.path_finder"] = function()
1514
local M = {}

0 commit comments

Comments
 (0)