Skip to content

fix: drop stale turn-end approvals and nil-panic guards - #81

Merged
cursor[bot] merged 1 commit into
mainfrom
cursor/fix-stale-approvals-and-nil-panics-7291
Sep 5, 2026
Merged

cursor[bot] merged 1 commit into
mainfrom
cursor/fix-stale-approvals-and-nil-panics-7291

Conversation

@jkyberneees

@jkyberneees jkyberneees commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

What

Three crash/stuck-UI bugs found in a self-improvement pass, validated with a reviewer, pinned RED-first, then fixed.

  1. tokens.Open panics on JSON null. encoding/json unmarshals null into a nil map. Set then panics (assignment to entry in nil map). Corrupt JSON was already tolerated; null is valid JSON so that path never ran. Open now re-inits an empty map and keeps the persist path.

  2. Reconnect give-up panics on (nil, nil). Success already requires a live client (err == nil && cl != nil). A hook that returns neither a client nor an error exhausted the retry budget, then msg.err.Error() nil-deref'd. The give-up note now uses a "no client" fallback.

  3. done / error leave the approval form armed. Disconnect already drops pending approvals so they cannot capture the keyboard after the socket dies. Turn-end did not: after the engine finishes (timeout, cancel, success) the dead form still owned Enter/Esc, answer() would SendApproval for an abandoned id, and a queued prompt could start while the gate still captured keys. done and error now clear the queue the same way disconnect does.

Tests

RED-first, then green:

  • TestOpenWithJSONNull — Set after Open of null must not panic; value persists
  • TestReconnectNilClientNoPanic — last-attempt (nil, nil) must not panic; status disconnected
  • TestTurnEndClearsStaleApprovals — done / error / cancel-as-error drop the form, deadlines, and A/D footer hints

make fmt / vet / lint 0 issues. make test race green across all packages. GitHub CI (8 checks) green.

Expert review of the production diffs: APPROVE.

Release

Shipped as v1.4.1 (GoReleaser succeeded). Squash-merge into main when ready — this token cannot merge protected main.

Open in Web Open in Cursor 

JSON-null session stores no longer panic on Set, a reconnect hook
that returns (nil, nil) no longer crashes the give-up path, and
done/error drop the approval form the same way disconnect already
does so a dead gate cannot capture the keyboard.

Co-authored-by: admin <admin@21no.de>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bodek 02aabc9 Commit Preview URL

Branch Preview URL
Sep 05 2026, 05:16 PM

@jkyberneees
jkyberneees marked this pull request as ready for review September 5, 2026 17:19
@cursor
cursor Bot merged commit 02aabc9 into main Sep 5, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants