Commit graph

3 commits

Author SHA1 Message Date
9f23076420 fix: cancel active process on contest switch
Problem: switching contests while a run, interactive session, or stress
test was in progress left orphaned callbacks and terminal jobs alive.
Running `:CP run` twice also allowed the first run's stale output to
overwrite the buffer after the second run completed.

Solution: replace the `io_view_running` bool in `views.lua` with a
generation counter (`_run_gen`); each `run_io_view` call increments it
and captures a local `gen`, and async callbacks bail out early when `gen
~= _run_gen`. Add `cancel_io_view`, `cancel_interactive` to `views.lua`
and `cancel` to `stress.lua` for forceful teardown without layout
restore. Call these in `setup_contest` whenever `is_new_contest` is true.
2026-03-05 17:37:13 -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
39b7b3d83f feat(stress): add stress test loop
Add stress.lua that auto-detects or accepts generator and brute solution
files, compiles C++ if needed, and launches scripts/stress.py in a
terminal buffer with session save/restore and cleanup autocmds.

Add scripts/stress.py as a standalone loop that runs generator → brute →
candidate, comparing outputs and exiting on the first mismatch.
2026-03-03 15:09:41 -05:00