From a763a00bad9982dba7b3b755c6ced2169c99393a Mon Sep 17 00:00:00 2001 From: theprimeagain Date: Sat, 28 Feb 2026 11:52:49 -0700 Subject: fixed the small bug, updated the comments, added test --- lua/99/init.lua | 4 ++-- lua/99/logger/logger.lua | 3 ++- lua/99/test/open_spec.lua | 39 ++++++++++++++++++++++++++++++++++----- 3 files changed, 38 insertions(+), 8 deletions(-) (limited to 'lua') diff --git a/lua/99/init.lua b/lua/99/init.lua index 393c427..035ee16 100644 --- a/lua/99/init.lua +++ b/lua/99/init.lua @@ -199,8 +199,8 @@ local _99_state --- takes your current selection and sends that along with the prompt provided and replaces --- your visual selection with the results --- @field view_logs fun(): nil ---- views the most recent logs. we dont have a way to view older logs in a reasonable right now ---- I want to rework the log viewing +--- view_logs allows you to select the request you want to see and then you +--- get to see the logs. --- @field stop_all_requests fun(): nil --- stops all in flight requests. this means that the underlying process will --- be killed (OpenCode) and any result will be discared diff --git a/lua/99/logger/logger.lua b/lua/99/logger/logger.lua index e9a11c8..daf65fa 100644 --- a/lua/99/logger/logger.lua +++ b/lua/99/logger/logger.lua @@ -280,7 +280,8 @@ end --- @param xid number --- @return string[] | nil function Logger.logs_by_id(xid) - return logger_cache[xid] + local logs = logger_cache[xid] + return logs and logs.logs end --- @param level number diff --git a/lua/99/test/open_spec.lua b/lua/99/test/open_spec.lua index 2dff972..a463212 100644 --- a/lua/99/test/open_spec.lua +++ b/lua/99/test/open_spec.lua @@ -1,6 +1,7 @@ -- luacheck: globals describe it assert before_each after_each local _99 = require("99") local Window = require("99.window") +local Logger = require("99.logger.logger") local test_utils = require("99.test.test_utils") local QFixHelpers = require("99.ops.qfix-helpers") local eq = assert.are.same @@ -39,16 +40,22 @@ end describe("open", function() local provider local previous_capture_select_input + local previous_display_full_screen_message + local previous_logs_by_id before_each(function() provider = test_utils.TestProvider.new() _99.setup(test_utils.get_test_setup_options({}, provider)) previous_capture_select_input = Window.capture_select_input + previous_display_full_screen_message = Window.display_full_screen_message + previous_logs_by_id = Logger.logs_by_id end) after_each(function() Window.capture_select_input = previous_capture_select_input + Window.display_full_screen_message = previous_display_full_screen_message + Logger.logs_by_id = previous_logs_by_id end) --- @param term "search" | "tutorial" | "vibe" @@ -75,7 +82,6 @@ describe("open", function() local function select_content(idx) Window.capture_select_input = function(_, opts) - print("capture_select_input", vim.inspect(opts.content), idx) opts.cb(true, opts.content[idx]) end end @@ -85,10 +91,6 @@ describe("open", function() local v = vibe() local t = tutorial() - local history = _99:__get_state().tracking.history - for _, r in ipairs(history) do - print("history", r.state, r:summary()) - end select_content(1) _99.open() eq(QFixHelpers.create_qfix_entries(s), qfix_items()) @@ -101,4 +103,31 @@ describe("open", function() _99.open() some_window_has(t) end) + + it("views logs for selected request xid", function() + search() + vibe() + + local history = _99:__get_state().tracking.history + local logs_by_xid = { + [history[1].xid] = { "search log" }, + [history[2].xid] = { "vibe log" }, + } + Logger.logs_by_id = function(xid) + return logs_by_xid[xid] + end + + local shown = nil + Window.display_full_screen_message = function(lines) + shown = lines + end + + select_content(1) + _99.view_logs() + eq({ "search log" }, shown) + + select_content(2) + _99.view_logs() + eq({ "vibe log" }, shown) + end) end) -- cgit v1.3-3-g829e