Summary
IndexCommandRunner constructs a CancellationTokenSource (IndexCommandRunner.cs:540, 612, 1532) for the index run, but nothing ties it to Console.CancelKeyPress (SIGINT). A user who hits Ctrl-C during a 30-minute index gets an abrupt Process.Exit rather than a graceful cancellation: the in-flight batch may or may not commit, no "partial progress saved" message prints, the readiness flags may be left in an intermediate state. The CTS exists; only the wiring is missing.
Where
src/CodeIndex/Cli/IndexCommandRunner.cs:540 (CTS construction)
src/CodeIndex/Cli/IndexCommandRunner.cs:612, 1532 (additional CTS sites)
Suggested approach
(1) In ProgramRunner (or a shared CLI entry helper), register a Console.CancelKeyPress += (s, e) => { e.Cancel = true; cts.Cancel(); } handler that intercepts the first Ctrl-C and triggers cooperative cancellation. (2) On second Ctrl-C, allow the default behavior (force-exit) so a stuck process can still be killed. (3) During shutdown, drain the in-flight batch's already-committed work, set readiness flags to a "interrupted" state (cross-link #1772 migration-in-progress), and print "Interrupted; partial progress saved (N files indexed)" on stderr. (4) Cover with a regression test that runs an index and sends SIGINT mid-flight, asserting graceful exit and a sensible status. (5) Cross-link with #1430 (general cancellation) and #1418 (MCP cancel).
Summary
IndexCommandRunnerconstructs aCancellationTokenSource(IndexCommandRunner.cs:540, 612, 1532) for the index run, but nothing ties it toConsole.CancelKeyPress(SIGINT). A user who hits Ctrl-C during a 30-minute index gets an abruptProcess.Exitrather than a graceful cancellation: the in-flight batch may or may not commit, no "partial progress saved" message prints, the readiness flags may be left in an intermediate state. The CTS exists; only the wiring is missing.Where
src/CodeIndex/Cli/IndexCommandRunner.cs:540(CTS construction)src/CodeIndex/Cli/IndexCommandRunner.cs:612, 1532(additional CTS sites)Suggested approach
(1) In
ProgramRunner(or a shared CLI entry helper), register aConsole.CancelKeyPress += (s, e) => { e.Cancel = true; cts.Cancel(); }handler that intercepts the first Ctrl-C and triggers cooperative cancellation. (2) On second Ctrl-C, allow the default behavior (force-exit) so a stuck process can still be killed. (3) During shutdown, drain the in-flight batch's already-committed work, set readiness flags to a "interrupted" state (cross-link #1772 migration-in-progress), and print "Interrupted; partial progress saved (N files indexed)" on stderr. (4) Cover with a regression test that runs an index and sends SIGINT mid-flight, asserting graceful exit and a sensible status. (5) Cross-link with #1430 (general cancellation) and #1418 (MCP cancel).