jobs.svelte.ts

view source

Declarations
#

4 declarations

Jobs
#

jobs.svelte.ts view source

import {Jobs} from '@fuzdev/zzz/jobs.svelte.js';

App-level collection of the account's jobs, mirroring the backend's: jobs live in the daemon's memory, so this holds nothing of its own. job_changed notifications keep it current (receive_changed), and each session snapshot replaces it (reconcile) — after a daemon restart that's empty.

inheritance

extends: Cell<typeof JobsJson>

items

type IndexedCollection<Job>

readonly

newest_first

Jobs newest first, by when they were queued.

type Job[]

readonly $derived

unfinished

Jobs that are queued or running.

type Job[]

readonly $derived

constructor

type new (options: JobsOptions): Jobs

options

get_by_job_id

type (job_id: string & $brand<"Uuid">): Job | undefined

job_id

type Uuid
returns Job | undefined

latest_for_input

The newest job working on the file at path, if any — the one whose state a view of that file shows.

type (path: string & $brand<"DiskfilePath">): Job | undefined

path

returns Job | undefined

receive_changed

Applies a job_changed notification: adds the job, or updates it in place.

type (snapshot: { job_id: string & $brand<"Uuid">; kind: "transcription"; status: "failed" | "queued" | "running" | "succeeded" | "cancelled"; progress: number | null; input_path: string & $brand<...>; ... 6 more ...; stderr: string; }): Job

snapshot

returns Job

receive_transcription_progress

Applies a transcription_progress notification: appends the segments to the job's preview. Segments for a job this app hasn't heard of are dropped — its job_changed always comes first.

type (job_id: string & $brand<"Uuid">, segments: readonly { start_ms: number | null; end_ms: number | null; text: string; words?: { start_ms: number; end_ms: number; text: string; p: number; }[] | undefined; }[]): void

job_id

type Uuid

segments

type readonly TranscriptSegment[]
returns void

reconcile

Replaces the collection with a session snapshot's jobs: listed jobs are added or updated, and ones the backend no longer has — it restarted, or dropped them from its history — are removed.

type (snapshots: readonly { job_id: string & $brand<"Uuid">; kind: "transcription"; status: "failed" | "queued" | "running" | "succeeded" | "cancelled"; progress: number | null; input_path: string & $brand<...>; ... 6 more ...; stderr: string; }[]): void

snapshots

type readonly JobSnapshot[]
returns void

transcribe

Queues a transcription of the audio file at path (transcription_create). The job arrives through job_changed.

type (path: string & $brand<"DiskfilePath">, language?: string | undefined): Promise<Result<{ value: { job_id: string & $brand<"Uuid">; }; }, { error: { [x: string]: unknown; code: -32700 | ... 4 more ... | (number & $brand<...>); message: string; data?: unknown; }; }>>

path

the audio file

language?

a language code, or omitted to detect it

type string
optional
returns Promise<Result>

the job's id, or the RPC error

cancel

Cancels a job (job_cancel). Its job_changed carries the outcome.

type (job: Job): Promise<Result<{ value: null; }, { error: { [x: string]: unknown; code: -32700 | -32600 | -32601 | -32602 | -32603 | (number & $brand<"JsonrpcServerErrorCode">); message: string; data?: unknown; }; }>>

job

type Job
returns Promise<Result>

the RPC result — not_found when the backend no longer has it

JobsJson
#

jobs.svelte.ts view source

value + type

{ id: string & $brand<"Uuid">; created: string & $brand<"Datetime">; updated: string & $brand<"Datetime">; } import {JobsJson} from '@fuzdev/zzz/jobs.svelte.js';

id

type string & $brand<"Uuid">

created

type string & $brand<"Datetime">

updated

Required and initially equal to created.

type string & $brand<"Datetime">

JobsJsonInput
#

jobs.svelte.ts view source

{ id?: string | undefined; created?: string | undefined; updated?: string | undefined; } import type {JobsJsonInput} from '@fuzdev/zzz/jobs.svelte.js';

id?

type string

created?

type string

updated?

Required and initially equal to created.

type string

JobsOptions
#

jobs.svelte.ts view source

JobsOptions import type {JobsOptions} from '@fuzdev/zzz/jobs.svelte.js';

inheritance

extends: CellOptions<typeof JobsJson>

Depends on
#

Imported by
#