Commit graph

26 commits

Author SHA1 Message Date
ab67270472 fix: expand language IDs, fix AtCoder submit, normalize logging
Problem: AtCoder submit used a cookie fast-path that silently failed on
stale sessions; `_LANGUAGE_ID_EXTENSION` only covered 2 of 116 languages;
`LANGUAGE_VERSIONS` was incomplete for AtCoder, CF, and Kattis; AtCoder
`prolog` and `racket` entries had wrong IDs. Raw `vim.notify` calls
throughout bypassed `logger.log`, producing inconsistent or missing
`[cp.nvim]:` prefixes.

Solution: Remove cookie persistence from AtCoder login/submit — always
use a fresh login within a single session. Increase
`BROWSER_SUBMIT_NAV_TIMEOUT["atcoder"]` to 40s and switch to in-memory
buffer upload with the correct per-language extension. Expand
`LANGUAGE_VERSIONS` with all 116 AtCoder languages, 15 new CF languages
with full version variants (java8/21, kotlin 1.7/1.9/2.2, rust 2021/2024,
etc.), and 50+ Kattis languages. Fix AtCoder `prolog` ID (`6079`→`6081`,
was Pony) and remove non-existent `racket` entry. Replace all raw
`vim.notify` calls with `logger.log`.
2026-03-06 21:28:21 -05:00
Barrett Ruth
a202725cc5
fix(submit): use file path over stdin; fix CF CodeMirror textarea (#305)
## Problem

After the initial submit hardening, two issues remained: source code was
read in Lua and piped as stdin to the scraper (unnecessary roundtrip
since
the file exists on disk), and CF's `page.fill()` timed out on the hidden
`textarea[name="source"]` because CodeMirror owns the editor state.

## Solution

Pass the source file path as a CLI arg instead — AtCoder calls
`page.set_input_files(file_path)` directly, CF reads it with
`Path(file_path).read_text()`. Fix CF source injection via
`page.evaluate()`
into the CodeMirror instance. Extract `BROWSER_SUBMIT_NAV_TIMEOUT` as a
per-platform `defaultdict` (CF defaults to 2× nav timeout). Save the
buffer
with `vim.cmd.update()` before submitting.
2026-03-05 14:34:14 -05:00
Barrett Ruth
c194f12eee
feat(atcoder): extract submit helpers; add live status notifications (#294)
## Problem

`_submit_sync` was a 170-line nested closure with `_solve_turnstile` and
the browser-install block further nested inside it. Status events went
to
stderr, which `run_scraper()` silently discards, leaving the user with a
10–30s silent hang after credential entry. The NDJSON spawn path also
lacked stdin support, so submit had no streaming path at all.

## Solution

Extract `_TURNSTILE_JS`, `_solve_turnstile`, `_ensure_browser`, and
`_submit_headless` to module level in `atcoder.py`; status events
(`installing_browser`, `checking_login`, `logging_in`, `submitting`) now
print to stdout as NDJSON. Add stdin pipe support to the NDJSON spawn
path in `scraper.lua` and switch `M.submit` to streaming with an
`on_status` callback. Wire `on_status` in `submit.lua` to fire
`vim.notify` for each phase transition.
2026-03-04 19:27:29 -05:00
0e88e0f182 fix(utils): skip uv python setup on NixOS
Problem: uv downloads glibc-linked Python binaries that NixOS cannot
run, causing setup_python_env to fail with exit status 127.

Solution: detect NixOS via /etc/NIXOS and bypass the uv sync path,
falling through directly to nix-based Python discovery.
2026-03-03 00:46:59 -05:00
3cb872a65f fix: replace deprecated vim.loop with vim.uv
Problem: vim.loop is deprecated since Neovim 0.10 in favour of vim.uv.
Five call sites across scraper.lua, setup.lua, utils.lua, and health.lua
still referenced the old alias.

Solution: replace every vim.loop reference with vim.uv directly.
2026-02-26 22:45:07 -05:00
760e7d7731 fix(ci): format 2026-02-20 17:49:34 -05:00
49e4233b3f fix: decouple python env setup from config init
Problem: setup_python_env() is called from check_required_runtime()
during config.setup(), which runs on the very first :CP command. The
uv sync and nix build calls use vim.system():wait(), blocking the
Neovim event loop. During the block the UI is frozen and
vim.schedule-based log messages never render, so the user sees an
unresponsive editor with no feedback.

Solution: remove setup_python_env() from check_required_runtime() so
config init is instant. Call it lazily from run_scraper() instead,
only when a scraper subprocess is actually needed. Use vim.notify +
vim.cmd.redraw() before blocking calls so the notification renders
immediately via a forced screen repaint, rather than being queued
behind vim.schedule.
2026-02-18 17:49:04 -05:00
622620f6d0 feat: add debug logging to python env, scraper, and runner
Problem: with debug = true, there is not enough diagnostic output to
troubleshoot environment or execution issues. The resolved python path,
scraper commands, and compile/run shell commands are not logged.

Solution: add logger.log calls at key decision points: python env
resolution (nix vs uv vs discovery), uv sync stderr output, scraper
subprocess commands, and compile/run shell strings. All gated behind
the existing debug flag so they only appear when debug = true.
2026-02-18 17:40:06 -05:00
976838d981 fix: always run uv sync to recover from partial installs
Problem: setup_python_env() skips uv sync when .venv/ exists. If a
previous sync was interrupted (e.g. network timeout), the directory
exists but is broken, and every subsequent session silently uses a
corrupt environment.

Solution: remove the isdirectory guard and always run uv sync. It is
idempotent and near-instant when dependencies are already installed,
so the only cost is one subprocess call per session.
2026-02-18 17:32:12 -05:00
6045042dfb fix: surface runtime check failures as clean notifications
Problem: when required dependencies (GNU time/timeout, Python env) are
missing, config.setup() throws a raw error() that surfaces as a Lua
traceback. On macOS without coreutils the message is also redundant
("GNU time not found: GNU time not found") and offers no install hint.

Solution: wrap config.setup() in pcall inside ensure_initialized(),
strip the Lua source-location prefix, and emit a vim.notify at ERROR
level. Add Darwin-specific install guidance to the GNU time/timeout
not-found messages. Pass capability reasons directly instead of
wrapping them in a redundant outer message.
2026-02-18 17:25:50 -05:00
0f9715298e fix(ci): remove deprecated setups 2026-02-18 14:13:37 -05:00
2148d9bd07 feat(nix): add health 2026-02-18 14:13:37 -05:00
1162e7046b try to fix the setup 2026-02-18 14:13:37 -05:00
c8f735617a misc bugfixes 2026-02-02 13:13:08 -05:00
fa45d912b8 close out other bufs on source buf close 2025-12-31 13:06:25 -06:00
Barrett Ruth
bbe04589b8 fix: fix uv conflict 2025-11-28 23:45:17 -05:00
Barrett Ruth
13d931ed19 feat: update 2025-11-05 12:47:38 -05:00
Barrett Ruth
dc6f2fd5b6 fix: cleanup logs 2025-10-23 18:29:20 -04:00
c0e175d84b feat(config): open url option 2025-10-12 16:19:02 -04:00
41a8d1a75b feat: interactive mode 2025-10-05 15:36:28 -04:00
fea9835436 fix(utils): cleanup timeout reason 2025-10-03 13:20:42 -04:00
c9ba8281b0 fix(runner): proper timeout 2025-10-03 09:16:38 -04:00
cddd61f061 config hard fail 2025-10-02 23:20:51 -04:00
d9537e72ba many fixes 2025-10-02 22:35:30 -04:00
a827d4f67c fix(picker): use consisten messaging 2025-09-21 12:21:40 -04:00
58f9be5f9a fix: refactor 2025-09-21 11:19:00 -04:00