docs/refactor: add AI disclosure and clean up code style
This commit is contained in:
@@ -3,19 +3,19 @@
|
||||
|
||||
local M = {}
|
||||
|
||||
local api = require("jasper.api")
|
||||
local api = require("jasper.api")
|
||||
local auth = require("jasper.auth")
|
||||
|
||||
--- Internal state (one instance per Neovim session).
|
||||
local state = {
|
||||
token = nil, ---@type string|nil
|
||||
timer_id = nil, ---@type number|nil
|
||||
attivita_id = nil, ---@type number|nil
|
||||
running = false,
|
||||
token = nil, ---@type string|nil
|
||||
timer_id = nil, ---@type number|nil
|
||||
attivita_id = nil, ---@type number|nil
|
||||
running = false,
|
||||
-- inactivity_ms: milliseconds of silence before the timer is auto-paused
|
||||
inactivity_ms = 10 * 60 * 1000,
|
||||
uv_timer = nil, ---@type uv_timer_t|nil
|
||||
augroup = nil, ---@type number|nil
|
||||
uv_timer = nil, ---@type uv.uv_timer_t|nil
|
||||
augroup = nil, ---@type number|nil
|
||||
}
|
||||
|
||||
-- ---------------------------------------------------------------------------
|
||||
@@ -128,7 +128,7 @@ end
|
||||
--- @param token string
|
||||
--- @param timer_id number
|
||||
local function begin_tracking(token, timer_id)
|
||||
state.token = token
|
||||
state.token = token
|
||||
state.timer_id = timer_id
|
||||
|
||||
-- Create the libuv timer used for inactivity detection
|
||||
@@ -170,6 +170,11 @@ local function on_token_ready(token)
|
||||
return
|
||||
end
|
||||
|
||||
if not timers then
|
||||
notify("Cannot fetch timers: empty response", vim.log.levels.ERROR)
|
||||
return
|
||||
end
|
||||
|
||||
local timer_id, terr = find_or_create_timer(token, state.attivita_id, timers)
|
||||
if not timer_id then
|
||||
notify(terr or "Cannot get timer", vim.log.levels.ERROR)
|
||||
@@ -182,7 +187,7 @@ end
|
||||
--- Entry point called on VimEnter.
|
||||
--- @param opts table { attivita_id, inactivity_timeout }
|
||||
function M.setup(opts)
|
||||
state.attivita_id = opts.attivita_id
|
||||
state.attivita_id = opts.attivita_id
|
||||
state.inactivity_ms = (opts.inactivity_timeout or 10) * 60 * 1000
|
||||
|
||||
local token = auth.get_token()
|
||||
|
||||
Reference in New Issue
Block a user