fix: harden sync backends and fix edit recompute (#66)
* refactor(oauth): async coroutine support, pure-Lua PKCE, server hardening Problem: OAuth module shelled out to openssl for PKCE, used blocking `vim.system():wait()`, had a weak `os.time()` PRNG seed, and the TCP callback server leaked on read errors with no timeout. Solution: Add `M.system()` coroutine wrapper and `M.async()` helper, replace openssl with `vim.fn.sha256` + `vim.base64.encode`, seed from `vim.uv.hrtime()`, add `close_server()` guard with 120s timeout, and close the server on read errors. * fix(gtasks): async operations, error notifications, buffer refresh Problem: Sync operations blocked the editor, `push_pass` silently dropped delete/update/create API errors, and the buffer was not re-rendered after push/pull/sync. Solution: Wrap `push`, `pull`, `sync` in `oauth.async()`, add `vim.notify` for all `push_pass` failure paths, and re-render the pending buffer after each operation. * fix(init): edit recompute, filter predicates, sync action listing Problem: `M.edit()` skipped `_recompute_counts()` after saving, `compute_hidden_ids` lacked `done`/`pending` predicates, and `run_sync` defaulted to `sync` instead of listing available actions. Solution: Replace `s:save()` with `_save_and_notify()` in `M.edit()`, add `done` and `pending` filter predicates, and list backend actions when no action is specified. * refactor(gcal): per-category calendars, async push, error notifications Problem: gcal used a single hardcoded calendar name, ran synchronously blocking the editor, and silently dropped some API errors. Solution: Fetch all calendars and map categories to calendars (creating on demand), wrap push in `oauth.async()`, notify on individual API failures, track `_gcal_calendar_id` in `_extra`, and remove the `$` anchor from `next_day` pattern. * refactor: formatting fixes, config cleanup, health simplification Problem: Formatter disagreements in `init.lua` and `gtasks.lua`, stale `calendar` field in gcal config, and redundant health checks for data directory existence. Solution: Apply stylua formatting, remove `calendar` field from `pending.GcalConfig`, drop data-dir and no-file health messages, add `done`/`pending` to filter tab-completion candidates. * docs: update vimdoc for sync refactor, remove demo scripts Problem: Docs still referenced openssl dependency, defaulting to `sync` action, and the `calendar` config field. Demo scripts used the old singleton `store` API. Solution: Update vimdoc and README to reflect explicit actions, per- category calendars, and pure-Lua PKCE. Remove stale demo scripts and update sync specs to match new behavior. * fix(types): correct LuaLS annotations in oauth and gcal
This commit is contained in:
parent
6910bdb1be
commit
ee362f7785
13 changed files with 319 additions and 291 deletions
|
|
@ -1,30 +0,0 @@
|
|||
vim.opt.runtimepath:prepend(vim.fn.getcwd())
|
||||
local tmpdir = vim.fn.tempname()
|
||||
vim.fn.mkdir(tmpdir, 'p')
|
||||
|
||||
vim.g.pending = {
|
||||
data_path = tmpdir .. '/tasks.json',
|
||||
}
|
||||
|
||||
local store = require('pending.store')
|
||||
store.load()
|
||||
|
||||
local today = os.date('%Y-%m-%d')
|
||||
local yesterday = os.date('%Y-%m-%d', os.time() - 86400)
|
||||
local tomorrow = os.date('%Y-%m-%d', os.time() + 86400)
|
||||
|
||||
store.add({
|
||||
description = 'Finish quarterly report',
|
||||
category = 'Work',
|
||||
due = tomorrow,
|
||||
recur = 'monthly',
|
||||
priority = 1,
|
||||
})
|
||||
store.add({ description = 'Review pull requests', category = 'Work' })
|
||||
store.add({ description = 'Update deployment docs', category = 'Work', status = 'done' })
|
||||
store.add({ description = 'Buy groceries', category = 'Personal', due = today })
|
||||
store.add({ description = 'Call dentist', category = 'Personal', due = yesterday, priority = 1 })
|
||||
store.add({ description = 'Read chapter 5', category = 'Personal' })
|
||||
store.add({ description = 'Learn a new language', category = 'Someday' })
|
||||
store.add({ description = 'Plan hiking trip', category = 'Someday' })
|
||||
store.save()
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
Output assets/demo.gif
|
||||
|
||||
Require nvim
|
||||
|
||||
Set Shell "bash"
|
||||
Set FontSize 14
|
||||
Set Width 900
|
||||
Set Height 450
|
||||
|
||||
Type "nvim -u scripts/demo-init.lua -c 'autocmd VimEnter * Pending'"
|
||||
Enter
|
||||
|
||||
Sleep 2s
|
||||
|
||||
Down
|
||||
Down
|
||||
Sleep 300ms
|
||||
Down
|
||||
Sleep 300ms
|
||||
|
||||
Enter
|
||||
Sleep 500ms
|
||||
|
||||
Tab
|
||||
Sleep 1s
|
||||
|
||||
Type "q"
|
||||
Sleep 200ms
|
||||
Loading…
Add table
Add a link
Reference in a new issue