Add support for cancellable operations#37
Closed
javisperez wants to merge 1 commit into
Closed
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces end-to-end cancellation support for long-running KitOps operations by wiring UI “close/cancel” actions to a new cancel IPC path, and by suppressing UI/log noise on intentional aborts.
Changes:
- Trigger
window.kitops.kit.cancelOperation()when push/pull/pack modals are closed while an operation is in-flight. - Add main-process operation tracking +
kit:stopIPC handler to callCancellablePromise.cancel(). - Treat
AbortErroras a non-error outcome in renderer/store logging paths; add SIGTERM cancellation forkitflow.
Reviewed changes
Copilot reviewed 8 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/views/ModelKitDetailView.vue | Cancels push when the push-confirm modal is closed; ignores AbortError in push flow. |
| src/views/HomeView.vue | Cancels pack when the pack modal is closed; ignores AbortError in pack flow. |
| src/stores/unpackedKitfileStore.ts | Skips error logging for AbortError during pack. |
| src/stores/kitStore.ts | Skips error logging for AbortError during push/pull. |
| src/App.vue | Cancels pull when the pull modal is closed; ignores AbortError in pull flow. |
| package.json | Dependency/devDependency version bumps and formatting changes. |
| electron/logging.js | Stops logging failures for aborted operations (rethrows AbortError). |
| electron/ipc/kit-commands.js | Tracks an “active operation” and adds kit:stop to cancel it. |
| bin/kitflow.js | Tracks active kit operations and cancels them on SIGTERM. |
Comments suppressed due to low confidence (1)
electron/ipc/kit-commands.js:46
activeOperation = kitops.<cmd>(...)isn’t guarded against synchronous throws. Ifkitops.push/pull/pack/unpackthrows before returning a promise,activeOperationwill remain pointing at the previous operation, andkit:stopcould cancel a stale operation later. Wrapping the assignment in a try/catch that resetsactiveOperation(or assigning only after the call succeeds) would avoid this.
ipcMain.handle('kit:pull', (e, options) => {
const reference = typeof options === 'string' ? options : options.reference
const flags = typeof options === 'string' ? undefined : options.flags
activeOperation = kitops.pull(reference, flags)
return withLogging('pull', { reference, flags }, () => activeOperation)
.finally(() => {
activeOperation = null
})
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+31
to
+37
| ipcMain.handle('kit:push', (e, source, destination, flags, modelkitDigest) => { | ||
| activeOperation = kitops.push(source, destination || undefined, flags) | ||
| return withLogging('push', { source, destination, flags }, () => activeOperation, modelkitDigest) | ||
| .finally(() => { | ||
| activeOperation = null | ||
| }) | ||
| }) |
Comment on lines
+69
to
+72
| ipcMain.handle('kit:stop', () => { | ||
| activeOperation?.cancel() | ||
| activeOperation = null | ||
| }) |
| activeOperation = kitops.push(source, destination || undefined, flags) | ||
| return withLogging('push', { source, destination, flags }, () => activeOperation, modelkitDigest) | ||
| .finally(() => { | ||
| activeOperation = null |
|
|
||
| return result | ||
| } catch (error) { | ||
| if (error?.name === 'AbortError') { |
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.
This PR adds support for the new
cancel()method in kitops-ts to properly cancel async operations when the action is cancelled in the UI (eg. a Push modal is closed).