summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--_selfcheck.lua54
-rw-r--r--init.lua4
3 files changed, 57 insertions, 3 deletions
diff --git a/README.md b/README.md
index d57d9f4..68876c4 100644
--- a/README.md
+++ b/README.md
@@ -60,7 +60,7 @@ the window, or turn warming off entirely.
### Timing
-Warming starts after session start or any non-warming model request, and any
+Warming starts when the UI is ready or after any non-warming model request, and any
new real activity resets both timers. A warming request never extends the
window; after each attempt (success or failure) the next one waits out a full
interval:
diff --git a/_selfcheck.lua b/_selfcheck.lua
index fa6a0e2..6cc3e4a 100644
--- a/_selfcheck.lua
+++ b/_selfcheck.lua
@@ -173,6 +173,60 @@ local entry = assert(loadfile(here .. "/init.lua"))()
assert(type(entry) == "table" and entry.name == "warming" and type(entry.activate) == "function",
"init.lua returns the warming entry")
+-- Activation binds lifecycle timing to session_ready and the banner to the
+-- render boundary; neither handler is the old session_start event.
+do
+ local handlers = {}
+ local previous_panto = package.loaded.panto
+ local previous_luv = package.loaded.luv
+ local previous_config = package.loaded["warming.config"]
+ local previous_policy = package.loaded["warming.policy"]
+ local previous_warm = package.loaded["warming.warm"]
+ package.loaded["warming.config"] = {
+ default_io = function() return {} end,
+ read = function() return { enabled = true, interval_ms = MIN, duration_ms = MIN, prompt = "OK" } end,
+ }
+ package.loaded["warming.policy"] = {
+ new = function()
+ return {
+ activity = function(self, now) self.activity_at = now end,
+ turn_started = function() end, turn_ended = function() end,
+ expired = function() return false end, due = function() return false end,
+ attempted = function() end,
+ }
+ end,
+ }
+ package.loaded["warming.warm"] = { start = function() end, poll = function() end, abandon = function() end }
+ package.loaded.panto = { agent = function() end, ext = {
+ on = function(name, handler) handlers[name] = handler end,
+ resolve_model = function() end,
+ style = function() return { dim = "", reset = "" } end,
+ } }
+ package.loaded.luv = {
+ now = function() return 123 end,
+ new_timer = function()
+ return { start = function(self) self.active = true end, is_active = function(self) return self.active end,
+ is_closing = function() return false end, stop = function(self) self.active = false end,
+ close = function() end }
+ end,
+ }
+ local active_entry = assert(loadfile(here .. "/init.lua"))()
+ active_entry.activate()
+ assert(handlers.render_header and handlers.session_ready, "new event subscriptions are installed")
+ assert(handlers.session_start == nil, "old session_start subscription is absent")
+ handlers.session_ready()
+ local inner = { render = function() return { "header" } end }
+ local event = { get_component = function() return inner end }
+ event.set_component = function(_, component) event.component = component end
+ handlers.render_header(event)
+ assert(event.component and event.component:render(80)[1] == "header", "render_header wraps the banner")
+ package.loaded.panto = previous_panto
+ package.loaded.luv = previous_luv
+ package.loaded["warming.config"] = previous_config
+ package.loaded["warming.policy"] = previous_policy
+ package.loaded["warming.warm"] = previous_warm
+end
+
-- ---------------------------------------------------------------------------
-- Tool-schema fidelity probe (report-only)
--
diff --git a/init.lua b/init.lua
index 17e0ed7..5043e60 100644
--- a/init.lua
+++ b/init.lua
@@ -48,7 +48,7 @@ end
-- money -- is visible whenever it is on. The line re-renders with live
-- status on the next repaint.
local function install_header(ext, summary)
- subscribe(ext, "session_start", function(event)
+ subscribe(ext, "render_header", function(event)
local inner = event:get_component()
event:set_component({
render = function(_, width)
@@ -149,7 +149,7 @@ local function activate()
end
end
- subscribe(ext, "session_start", function()
+ subscribe(ext, "session_ready", function()
policy:activity(uv.now())
ensure_timer()
end)