This repository was archived by the owner on Jun 17, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Codex/offline caption packaging readme #685
Open
sleel-sun
wants to merge
4
commits into
siddharthvaddem:main
Choose a base branch
from
sleel-sun:codex/offline-caption-packaging-readme
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import { describe, expect, it, vi } from "vitest"; | ||
| import { CaptionJobRegistry } from "./jobs"; | ||
|
|
||
| describe("CaptionJobRegistry", () => { | ||
| it("cleans up jobs after completion", async () => { | ||
| const registry = new CaptionJobRegistry({ | ||
| generate: vi.fn(async (request) => ({ | ||
| jobId: request.jobId, | ||
| status: "success", | ||
| segments: [], | ||
| })), | ||
| }); | ||
|
|
||
| await expect(registry.start({ jobId: "job-1", videoPath: "/tmp/video.webm" })).resolves.toEqual( | ||
| { | ||
| jobId: "job-1", | ||
| status: "success", | ||
| segments: [], | ||
| }, | ||
| ); | ||
| expect(registry.has("job-1")).toBe(false); | ||
| }); | ||
|
|
||
| it("aborts an active job", async () => { | ||
| let signal: AbortSignal | undefined; | ||
| const registry = new CaptionJobRegistry({ | ||
| generate: vi.fn(async (request) => { | ||
| signal = request.signal; | ||
| return { jobId: request.jobId, status: "cancelled", segments: [] }; | ||
| }), | ||
| }); | ||
|
|
||
| const promise = registry.start({ | ||
| jobId: "job-2", | ||
| videoPath: "/tmp/video.webm", | ||
| }); | ||
| const cancelResult = registry.cancel("job-2"); | ||
| const result = await promise; | ||
|
|
||
| expect(cancelResult).toEqual({ success: true, cancelled: true }); | ||
| expect(signal?.aborted).toBe(true); | ||
| expect(result.status).toBe("cancelled"); | ||
| }); | ||
|
|
||
| it("reports missing jobs as not cancelled", () => { | ||
| const registry = new CaptionJobRegistry({ | ||
| generate: vi.fn(), | ||
| }); | ||
|
|
||
| expect(registry.cancel("missing")).toEqual({ | ||
| success: true, | ||
| cancelled: false, | ||
| }); | ||
| }); | ||
| }); |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| import type { CaptionGenerationResult } from "../../src/lib/captions"; | ||
|
|
||
| type CaptionJobStartRequest = { | ||
| jobId: string; | ||
| videoPath: string; | ||
| language?: string; | ||
| }; | ||
|
|
||
| type CaptionJobGenerateRequest = CaptionJobStartRequest & { | ||
| signal: AbortSignal; | ||
| }; | ||
|
|
||
| type CaptionJobRegistryDeps = { | ||
| generate: (request: CaptionJobGenerateRequest) => Promise<CaptionGenerationResult>; | ||
| }; | ||
|
|
||
| export class CaptionJobRegistry { | ||
| private jobs = new Map<string, AbortController>(); | ||
|
|
||
| constructor(private deps: CaptionJobRegistryDeps) {} | ||
|
|
||
| has(jobId: string) { | ||
| return this.jobs.has(jobId); | ||
| } | ||
|
|
||
| async start(request: CaptionJobStartRequest): Promise<CaptionGenerationResult> { | ||
| this.cancel(request.jobId); | ||
| const controller = new AbortController(); | ||
| this.jobs.set(request.jobId, controller); | ||
|
|
||
| try { | ||
| return await this.deps.generate({ | ||
| ...request, | ||
| signal: controller.signal, | ||
| }); | ||
| } finally { | ||
| if (this.jobs.get(request.jobId) === controller) { | ||
| this.jobs.delete(request.jobId); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| cancel(jobId: string) { | ||
| const controller = this.jobs.get(jobId); | ||
| if (!controller) { | ||
| return { success: true, cancelled: false }; | ||
| } | ||
|
|
||
| controller.abort(); | ||
| this.jobs.delete(jobId); | ||
| return { success: true, cancelled: true }; | ||
| } | ||
| } |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: siddharthvaddem/openscreen
Length of output: 2367
🏁 Script executed:
Repository: siddharthvaddem/openscreen
Length of output: 9489
🏁 Script executed:
Repository: siddharthvaddem/openscreen
Length of output: 12329
🏁 Script executed:
Repository: siddharthvaddem/openscreen
Length of output: 7171
🏁 Script executed:
Repository: siddharthvaddem/openscreen
Length of output: 10725
Flag arm64-only native/captions filters as lowkey risky for x64 runtime
electron-builder.json5hard-pins macdmgtoarm64and only includesextraResourceswithfilter: ["darwin-arm64/**/*"]for bothelectron/native/binandelectron/native/captions, even thoughscripts/build_macos.shbuilds an x64.app. so the x64 bundle won’t contain thedarwin-x64caption/native assets, andelectron/captions/whisper.tswill look for${request.platform}-${request.arch}(darwin-x64for x64) and returnLocal caption tools are not availablewhen the tools/models aren’t found (no cross-arch fallback). kinda cursed—this shows up as “captions unavailable” only on x64.🤖 Prompt for AI Agents