Skip to content

Add support for cancellable operations#37

Closed
javisperez wants to merge 1 commit into
mainfrom
add-cancellable-operations
Closed

Add support for cancellable operations#37
javisperez wants to merge 1 commit into
mainfrom
add-cancellable-operations

Conversation

@javisperez

Copy link
Copy Markdown
Collaborator

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).

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:stop IPC handler to call CancellablePromise.cancel().
  • Treat AbortError as a non-error outcome in renderer/store logging paths; add SIGTERM cancellation for kitflow.

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. If kitops.push/pull/pack/unpack throws before returning a promise, activeOperation will remain pointing at the previous operation, and kit:stop could cancel a stale operation later. Wrapping the assignment in a try/catch that resets activeOperation (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
Comment thread electron/logging.js

return result
} catch (error) {
if (error?.name === 'AbortError') {
@javisperez javisperez closed this May 19, 2026
@javisperez javisperez deleted the add-cancellable-operations branch May 19, 2026 19:50
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