Skip to content

Draft: Add progress support#581

Closed
Explosion-Scratch wants to merge 5 commits intop2r3:masterfrom
Explosion-Scratch:progress
Closed

Draft: Add progress support#581
Explosion-Scratch wants to merge 5 commits intop2r3:masterfrom
Explosion-Scratch:progress

Conversation

@Explosion-Scratch
Copy link
Contributor

@Explosion-Scratch Explosion-Scratch commented Mar 24, 2026

Draft for adding progress support and abort signal, handlers get passed in doConvert. New param for doConvert is ConvertContext:

/** Context passed to doConvert for progress/log reporting. */
export interface ConvertContext {
  /**
   * Report progress.
   * @param message - Status message to display.
   * @param value - Absolute 0–1 value, or updater `(old) => new`.
   */
  progress: (message: string, value: number | ((prev: number) => number)) => void;
  /**
   * Append a timestamped log entry.
   * @param message - The log message.
   * @param level - Log level ('log', 'error', 'debug', 'warn'). Defaults to 'log'.
   */
  log: (message: string, level?: LogLevel) => void;
  /** AbortSignal for cooperative cancellation. */
  signal: AbortSignal;
  /** Throws if the signal has been aborted. Call between async steps. */
  throwIfAborted: () => void;
}

This allows in doConvert to for instance at convenient times ctx.throwIfAborted() or ctx.progress("Transcoding...", 0.5)

@Explosion-Scratch
Copy link
Contributor Author

Note I've continued from #580

@p2r3
Copy link
Owner

p2r3 commented Mar 25, 2026

Closing, see #580

@p2r3 p2r3 closed this Mar 25, 2026
@Explosion-Scratch
Copy link
Contributor Author

But what about the progress functionality only as opposed to the UI tweaks - this is a lot of under the hood stuff.

@Explosion-Scratch
Copy link
Contributor Author

This allows progress and logs via the doConvert method which now exposes a ctx param - I think this is a good approach regardless of the frontend but once #73 is merged (if it is) then I will re-PR with the backend changes to integrate with that frontend.

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