fix(checkpoint): honor cancellation and show progress in push + import loops - #1933
fix(checkpoint): honor cancellation and show progress in push + import loops#1933gtrrz-victor wants to merge 5 commits into
Conversation
…t loops The git-refs checkpoint push drain and the agent-history import loop each iterate an unbounded, user-scaled collection (checkpoint refs / imported sessions) doing per-item work, but never observed context cancellation and gave no per-item progress. With many items a Ctrl-C during the user's git push (or a large `entire enable` import) was ignored, and the divergence push path showed only a spinner with no sense of how much was left. - flushCheckpointRefsQueue: add a per-ref "k/N" progress counter in the divergence recovery loop, a cancellation short-circuit right after the batch push fails (a cancelled batch is not a divergence), and a ctx.Err() break inside the per-ref loop for a cancel that lands mid-recovery. Only confirmed-pushed refs leave the queue, so the remainder is retried next push. - agentimport.Run: check ctx.Err() at the top of the session loop so a large import stops cleanly between sessions. Already-written checkpoints stay put (idempotent by deterministic ID), so a re-run resumes where it left off. Regression tests cover both cancellation paths.
There was a problem hiding this comment.
Pull request overview
Improves long-running checkpoint-related loops (git-refs push drain and agent transcript import) by honoring context cancellation and surfacing clearer per-item progress, so users can reliably interrupt large operations and understand forward progress during divergence recovery.
Changes:
- Add cancellation short-circuits and in-loop
ctx.Err()checks to stop cleanly on Ctrl-C while preserving retry semantics. - Improve stderr progress output during per-ref divergence recovery with
k/Ncounters and per-ref spinners plus a final synced summary. - Add regression tests covering pre-cancelled contexts for both the push drain and import loop.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| cmd/entire/cli/strategy/manual_commit_push.go | Adds cancellation handling and clearer per-ref progress output in flushCheckpointRefsQueue divergence recovery. |
| cmd/entire/cli/strategy/refs_push_test.go | Adds a regression test ensuring cancelled contexts stop cleanly and leave refs queued/unpushed. |
| cmd/entire/cli/agentimport/agentimport.go | Adds a ctx.Err() guard at the top of the per-session loop to stop imports cleanly between sessions. |
| cmd/entire/cli/agentimport/agentimport_test.go | Adds a regression test verifying cancelled imports do not scan sessions or write checkpoints. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 4e6e57e. Configure here.
runSelectedImports treated context.Canceled from agentimport.Run like any soft per-agent failure and continued to the next agent — re-running Discover per remaining agent and printing a 'context canceled' note for each. Stop the whole phase on the first cancellation instead, printing a single 'Import cancelled.' note. Already-written checkpoints stay put (idempotent on re-run).
…mport-cancellation # Conflicts: # cmd/entire/cli/strategy/manual_commit_push.go
When Ctrl-C aborts the auto-import phase, an earlier agent in the loop may already have imported local-only history. The early return skipped the logged-out not-synced notice, so the user silently lost the warning that their imported history won't reach the dashboard. Emit warnIfImportNotSynced before returning on the cancellation path. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
In the per-ref checkpoint push recovery loop, the mid-loop context.Err() check overwrote firstErr unconditionally. If an earlier ref failed for a genuine reason (auth, conflict) and the context was then cancelled, callers like PushQueuedCheckpointRefs surfaced context.Canceled and hid the real failure. Guard with `if firstErr == nil`, matching the per-ref push guard below. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Duplicated -> #1925 |

https://entire.io/gh/entireio/cli/trails/993
Summary
The git-refs checkpoint push drain and the agent-history import loop each iterate an unbounded, user-scaled collection (checkpoint refs / imported sessions) doing per-item work, but never observed context cancellation and gave no per-item progress. Surfaced while looking into auto-import on
entire enable:git pushwas ignored.What Changed
flushCheckpointRefsQueue(strategy/manual_commit_push.go)k/Nprogress counter in the divergence recovery loop (was a single spinner over the whole loop).ctx.Err()break inside the per-ref loop for a cancel that lands mid-recovery.agentimport.Run(agentimport/agentimport.go)ctx.Err()check at the top of the session loop so a large import stops cleanly between sessions. Already-written checkpoints stay put (idempotent by deterministic ID), so a re-run resumes where it left off.runSelectedImports(setup_import.go) — from PR reviewcontext.Canceledfromagentimport.Runas an abort of the whole enable auto-import phase: prints a singleImport cancelled.note and returns, instead of continuing to the next agent (which would re-runDiscoverand emit another "context canceled" note per remaining agent).Reaction to cancel is uniform: stop, keep only what actually landed, leave the rest for a retry, surface
context.Canceled. Callers already handle it (pre-push logs and never blocks the user's push;doctor_migrateexits silently viaerrors.Is).Deferred (not in this PR)
Issue 3's structural fix — parsing
git push --porcelainoutput so a single diverged ref among thousands triggers one recovery instead of demoting the whole batch to per-ref recovery. Discussed but intentionally left for a follow-up.Verification
go test ./cmd/entire/cli/agentimport/... ./cmd/entire/cli/strategy/... ./cmd/entire/cli/— pass (incl. after mergingmain).TestFlushCheckpointRefsQueue_CancelledContextStopsCleanly(push),TestRun_CancelledContextStopsBeforeScanning(import),TestRunSelectedImports_CancelStopsImportPhase(enable phase abort — asserts the second agent is never processed).golangci-lint runon the touched packages — 0 issues.gofmtclean.mainand resolved themanual_commit_push.goconflict (adopted main's reworded, cause-agnostic failure message anddest.targetpush-destination refactor while keeping the per-ref progress + cancellation handling).