fix(cli): use the static spinner when starting the embedding daemon so Ctrl-C keeps working - #368
Open
Fibilisim-Tekno wants to merge 1 commit into
Conversation
The managed local-embeddings daemon started through the animated clack spinner, which takes stdin over via @clack/core's block() and calls setRawMode(true). Nothing ever restores cooked mode, and a console in raw mode does not translate Ctrl-C into a signal at all, so `ktx ingest` became impossible to interrupt for the rest of the run. clack.ts already documents this hazard directly above createStaticCliSpinner, which writes to stderr only and never touches stdin. Switch the call site to it. Fixes Kaelio#361
|
@Fibilisim-Tekno is attempting to deploy a commit to the Kaelio Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #361.
The problem
ktx ingestcannot be interrupted with Ctrl-C once the managed local-embeddings daemon has started.ensureManagedLocalEmbeddingsDaemonusedcreateCliSpinner, which returns the animated clack spinner when stdout is a TTY.@clack/core'sblock()takes stdin over throughreadline.createInterface, which callssetRawMode(true), andspinner.stop()never restores cooked mode.A console in raw mode does not translate Ctrl-C into a signal at all, so no
SIGINTis ever generated — which is why no signal handler anywhere in ktx can help. The daemon starts a few seconds into every ingest that usesscan.enrichment.embeddings.backend: sentence-transformers, so the terminal stays raw for the whole run.The fix
One call site moves to
createStaticCliSpinner, whichclack.tsalready documents for exactly this situation, directly above the function:The static spinner writes to stderr only and never touches stdin. I also left a short comment at the call site so the choice is not "cleaned up" back to the animated helper later.
Tests
Two regression tests in
packages/cli/test/managed-local-embeddings.test.ts.makeIonow takes anisTTYflag, because the existing helper had noisTTYat all — meaning every existing test already took the static path and none of them could have caught this.The assertion is
expect(io.stdout()).toBe('')withisTTY: true: the animated spinner renders its frames to stdout, the static one does not, so empty stdout on a TTY is the observable proof that stdin was never seized. The second test covers the same thing on the failure path, which also used the spinner.Trade-off
This gives up the animated frames while the daemon starts (first run downloads the model). That seemed clearly worth an interruptible ingest, and it matches what the issue suggested. If you would rather keep the animation, the alternative is restoring cooked mode after
stop()anderror()— happy to switch if you prefer that shape.Scope
The same pattern may exist at other
createCliSpinnercall sites followed by stdin readers; I did not touch them, to keep this to one logical change.Verification
I do not have the Windows console setup from the issue, so I did not reproduce the
0x0208input-mode measurement myself. What I verified is on the code path: the call site used the animated helper on a TTY,createStaticCliSpinnerexists and writes only to stderr, and the new tests fail before this change and pass after. This work was prepared with AI assistance and reviewed before submitting; the claims above are checked against the files they name.