diff options
| author | ThePrimeAgain <theprimeagain@theprimeagain.com> | 2025-12-26 15:25:30 -0700 |
|---|---|---|
| committer | ThePrimeAgain <theprimeagain@theprimeagain.com> | 2025-12-26 15:25:30 -0700 |
| commit | 6da68cdb8edea79f721479561ddc8d79e91981fe (patch) | |
| tree | e7e64edd62a76759ba891346a9b7bb3a3670d93d /lua/99/request/init.lua | |
| parent | 9f82332f402a51c17bb69ca5937d4ba7d8cf004a (diff) | |
| download | a4-6da68cdb8edea79f721479561ddc8d79e91981fe.tar.xz a4-6da68cdb8edea79f721479561ddc8d79e91981fe.zip | |
mid way through refactor when i realize i have another refactor
Diffstat (limited to 'lua/99/request/init.lua')
| -rw-r--r-- | lua/99/request/init.lua | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/lua/99/request/init.lua b/lua/99/request/init.lua index 408cc87..d154e93 100644 --- a/lua/99/request/init.lua +++ b/lua/99/request/init.lua @@ -1,19 +1,11 @@ local Logger = require("99.logger.logger") -local _id = 1 ---- no, i am not going to use a uuid, in case of collision, call the police ---- @return string -local function get_id() - local id = _id - _id = _id + 1 - return tostring(id) -end - --- @param opts _99.Request.Opts local function validate_opts(opts) assert(opts.model, "you must provide a model for hange requests to work") assert(opts.tmp_file, "you must provide context") assert(opts.provider, "you must provide a model provider") + assert(opts.xid, "you must provide a request id") end --- @alias _99.Request.State "ready" | "calling-model" | "parsing-result" | "updating-file" | "cancelled" @@ -60,7 +52,7 @@ function OpenCodeProvider:make_request(query, request, observer) observer.on_complete(status, text) end) - local id = get_id() + local id = request.config.xid Logger:debug("make_request", "tmp_file", request.config.tmp_file, "id", id) vim.system( { "opencode", "run", "-m", request.config.model, query }, @@ -155,11 +147,13 @@ end --- @field model string --- @field tmp_file string --- @field provider _99.Provider? +--- @field xid number --- @class _99.Request.Config --- @field model string --- @field tmp_file string --- @field provider _99.Provider +--- @field xid number --- @class _99.Request --- @field config _99.Request.Config @@ -184,6 +178,7 @@ function Request.new(opts) end function Request:cancel() + Logger:debug("Request#cancel", "id", self.config.xid) self.state = "cancelled" end |
