enhance batch process with phase tracking#3906
enhance batch process with phase tracking#3906ComputelessComputer wants to merge 1 commit intofeat/ai-note-enhancement-flowfrom
Conversation
| }); | ||
| }), | ||
| ), | ||
| Effect.tap(() => Effect.sync(() => clearBatchSession(sessionId))), | ||
| Effect.flatMap(() => Effect.promise(() => runBatch(path))), | ||
| Effect.flatMap(() => | ||
| Effect.tryPromise({ | ||
| try: () => runBatch(path), | ||
| catch: (error) => | ||
| error instanceof Error ? error : new Error(String(error)), | ||
| }), | ||
| ), |
There was a problem hiding this comment.
🔴 Removal of clearBatchSession before runBatch causes batch transcription to silently abort
The audio upload + batch transcription flow is broken. When uploading an audio file, handleBatchStarted(sessionId, "importing") is called at options-menu.tsx:247, which sets batch[sessionId] in the store. Then after the audio import succeeds, runBatch(path) is called at line 268. This eventually invokes general.ts:runBatch, which at line 461 checks getSessionMode(sessionId). Because batch[sessionId] already exists (set by the earlier handleBatchStarted), getSessionMode returns "running_batch" (see general.ts:595). The guard at general.ts:469 then triggers: if (mode === "running_batch") { return; }, silently aborting the transcription.
Root Cause
The old code had a clearBatchSession(sessionId) call between the audio import and runBatch that cleared the batch state, allowing runBatch to proceed:
Effect.tap(() => Effect.sync(() => clearBatchSession(sessionId))),
Effect.flatMap(() => Effect.promise(() => runBatch(path))),
This PR removed the clearBatchSession call and clearBatchSession from the component entirely. The new code calls handleBatchStarted(sessionId, "importing") to show the importing phase, but never clears it before calling runBatch. Inside general.ts:runBatch at line 469, the running_batch mode guard causes an immediate return, so the actual batch transcription command (listener2Commands.runBatch) is never executed.
Impact: Every audio file upload will import the file but never transcribe it. The user sees the "importing" progress indicator, then the flow silently fails without any error message shown to the user (only a console.warn).
(Refers to lines 246-272)
Prompt for agents
The batch state set by handleBatchStarted(sessionId, "importing") at line 247 needs to be cleared before runBatch is called, so the running_batch guard in general.ts:469 does not abort the transcription. There are two possible approaches:
1. Re-add clearBatchSession: Add back the clearBatchSession selector from useListener at the top of the component (it was removed in this PR), and insert an Effect.tap step that calls clearBatchSession(sessionId) between the audio import step (around line 264) and the Effect.flatMap that calls runBatch (line 266). This restores the old behavior while keeping the new importing phase.
2. Modify general.ts:runBatch: Change the running_batch guard in general.ts around line 469 to allow re-entry when the batch is in the importing phase, e.g. check state.batch[sessionId]?.phase === "importing" and allow proceeding in that case. This is more nuanced and changes the semantics of the guard.
Approach 1 is simpler and safer. Add clearBatchSession back and insert it before runBatch in the Effect pipeline.
Was this helpful? React with 👍 or 👎 to provide feedback.
This is part 3 of 3 in a stack made with GitButler: