Skip to content

Commit 00adb1d

Browse files
committed
docs: add LuaDoc comments for session store
1 parent 1e81b88 commit 00adb1d

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

lua/codex/state/session_store.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ local sessions = {}
66
local active_id = nil
77
local counter = 0
88

9+
--- Create a new session from the given spec, store it, and set it as active.
910
---@param spec codex.SessionSpec
1011
---@return string id
1112
function M.create(spec)
@@ -25,12 +26,14 @@ function M.create(spec)
2526
return id
2627
end
2728

29+
--- Look up a session by its id.
2830
---@param id string
2931
---@return codex.Session|nil
3032
function M.get(id)
3133
return sessions[id]
3234
end
3335

36+
--- Return the currently active session, or nil if none is active.
3437
---@return codex.Session|nil
3538
function M.get_active()
3639
if active_id then
@@ -39,12 +42,14 @@ function M.get_active()
3942
return nil
4043
end
4144

45+
--- Set the active session id; pass nil to clear the active session.
4246
---@param id string|nil
4347
---@return nil
4448
function M.set_active(id)
4549
active_id = id
4650
end
4751

52+
--- Mark a session as no longer alive and clear it from active if it was active.
4853
---@param id string
4954
---@return nil
5055
function M.mark_dead(id)
@@ -56,6 +61,7 @@ function M.mark_dead(id)
5661
end
5762
end
5863

64+
--- Remove a session from the store entirely and clear it from active if needed.
5965
---@param id string
6066
---@return nil
6167
function M.remove(id)
@@ -65,6 +71,7 @@ function M.remove(id)
6571
end
6672
end
6773

74+
--- Return a list of all stored sessions.
6875
---@return codex.Session[]
6976
function M.list()
7077
---@type codex.Session[]
@@ -75,6 +82,7 @@ function M.list()
7582
return result
7683
end
7784

85+
--- Clear all sessions, the active id, and reset the id counter.
7886
---@return nil
7987
function M.reset()
8088
sessions = {}

0 commit comments

Comments
 (0)