recappi 0.1.51 → 0.1.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1899,7 +1899,7 @@ var init_RecordSetupView = __esm({
1899
1899
  });
1900
1900
 
1901
1901
  // src/tui/AppShell.tsx
1902
- import { useCallback, useEffect as useEffect4, useState as useState7 } from "react";
1902
+ import { useCallback, useEffect as useEffect4, useRef as useRef3, useState as useState7 } from "react";
1903
1903
  import { Box as Box16, Text as Text16, useApp, useInput as useInput7 } from "ink";
1904
1904
  import { Fragment as Fragment6, jsx as jsx18, jsxs as jsxs15 } from "react/jsx-runtime";
1905
1905
  function recordErrorCopy(code, message) {
@@ -2099,6 +2099,7 @@ function AppShell({
2099
2099
  bySourceId: {},
2100
2100
  byMicrophoneId: {}
2101
2101
  });
2102
+ const autoTranscribeStartedSessionIds = useRef3(/* @__PURE__ */ new Set());
2102
2103
  const recordSetupModel = {
2103
2104
  sources: recordSetupInputs.sources.length > 0 ? recordSetupInputs.sources : DEFAULT_RECORDING_SOURCES,
2104
2105
  microphones: recordSetupInputs.microphones ?? [],
@@ -2398,6 +2399,17 @@ function AppShell({
2398
2399
  setNotice("Transcription failed. Press enter to retry.");
2399
2400
  }
2400
2401
  }, [liveRecord, refresh, transcribeRecordingArtifact]);
2402
+ useEffect4(() => {
2403
+ if (liveRecord?.kind !== "stopped") return;
2404
+ const artifact = liveRecord.artifact;
2405
+ if (!artifact?.audioPath || !transcribeRecordingArtifact) return;
2406
+ if (artifact.uploadStatus !== "local_only" || artifact.transcriptionStatus !== "not_started") {
2407
+ return;
2408
+ }
2409
+ if (autoTranscribeStartedSessionIds.current.has(artifact.sessionId)) return;
2410
+ autoTranscribeStartedSessionIds.current.add(artifact.sessionId);
2411
+ void transcribeStoppedRecording();
2412
+ }, [liveRecord, transcribeRecordingArtifact, transcribeStoppedRecording]);
2401
2413
  const loadMoreRecordings = useCallback(async () => {
2402
2414
  if (!fetchRecordings || !recordingsNextCursor || loadingMoreRecordings) return;
2403
2415
  setLoadingMoreRecordings(true);
@@ -17791,6 +17803,9 @@ var recordCommandDataSchema = external_exports.object({
17791
17803
  sessionId: external_exports.string(),
17792
17804
  state: sidecarRecordingStateSchema,
17793
17805
  recordingId: external_exports.string().optional(),
17806
+ jobId: external_exports.string().optional(),
17807
+ transcriptId: external_exports.string().optional(),
17808
+ cloudHandoffError: cliErrorDescriptorSchema.optional(),
17794
17809
  localSessionRef: external_exports.string().optional(),
17795
17810
  sidecar: sidecarInfoSchema.optional(),
17796
17811
  artifacts: external_exports.array(sidecarLocalArtifactSchema)
@@ -20080,6 +20095,12 @@ Next:
20080
20095
  opts.stdout("Recording complete\n");
20081
20096
  if (typeof data.recordingId === "string") opts.stdout(` recordingId: ${data.recordingId}
20082
20097
  `);
20098
+ if (typeof data.jobId === "string") opts.stdout(` jobId: ${data.jobId}
20099
+ `);
20100
+ if (typeof data.transcriptId === "string") {
20101
+ opts.stdout(` transcriptId: ${data.transcriptId}
20102
+ `);
20103
+ }
20083
20104
  if (typeof data.sessionId === "string") opts.stdout(` sessionId: ${data.sessionId}
20084
20105
  `);
20085
20106
  if (typeof data.localSessionRef === "string") {
@@ -20096,7 +20117,24 @@ Next:
20096
20117
  `);
20097
20118
  }
20098
20119
  }
20099
- if (typeof data.recordingId === "string") {
20120
+ const cloudHandoffError = isRecord4(data.cloudHandoffError) ? data.cloudHandoffError : void 0;
20121
+ if (cloudHandoffError && typeof cloudHandoffError.message === "string") {
20122
+ opts.stderr(`Cloud handoff failed: ${cloudHandoffError.message}
20123
+ `);
20124
+ if (typeof cloudHandoffError.hint === "string") opts.stderr(`${cloudHandoffError.hint}
20125
+ `);
20126
+ }
20127
+ if (typeof data.transcriptId === "string") {
20128
+ opts.stdout(`
20129
+ Next:
20130
+ recappi transcript get ${data.transcriptId}
20131
+ `);
20132
+ } else if (typeof data.jobId === "string") {
20133
+ opts.stdout(`
20134
+ Next:
20135
+ recappi jobs wait ${data.jobId}
20136
+ `);
20137
+ } else if (typeof data.recordingId === "string") {
20100
20138
  opts.stdout(`
20101
20139
  Next:
20102
20140
  recappi recordings get ${data.recordingId}
@@ -21447,7 +21485,50 @@ function RecordingHeroLive({
21447
21485
  }
21448
21486
 
21449
21487
  // src/cli.ts
21488
+ init_recordingCore();
21450
21489
  var DASHBOARD_RECORDINGS_PAGE_SIZE = 50;
21490
+ async function uploadRecordedSessionAfterStop(client, data, opts = {}) {
21491
+ const artifact = recordingArtifactFromRecordData(data);
21492
+ if (!artifact.audioPath) return data;
21493
+ try {
21494
+ const upload = await client.uploadPathBatch({
21495
+ inputPath: artifact.audioPath,
21496
+ transcribe: true,
21497
+ wait: false,
21498
+ ...opts.title ? { title: opts.title } : {},
21499
+ ...opts.language ? { language: opts.language } : {},
21500
+ onEvent: opts.onEvent
21501
+ });
21502
+ if (upload.failures.length > 0) {
21503
+ const failure = upload.failures[0];
21504
+ return recordCommandDataSchema.parse({
21505
+ ...data,
21506
+ cloudHandoffError: failure.error
21507
+ });
21508
+ }
21509
+ const success2 = upload.successes[0];
21510
+ if (!success2) {
21511
+ return recordCommandDataSchema.parse({
21512
+ ...data,
21513
+ cloudHandoffError: cliError(
21514
+ "input.unsupported_audio",
21515
+ "No supported local audio file was uploaded."
21516
+ ).descriptor
21517
+ });
21518
+ }
21519
+ return recordCommandDataSchema.parse({
21520
+ ...data,
21521
+ recordingId: success2.recordingId,
21522
+ ...success2.jobId ? { jobId: success2.jobId } : {},
21523
+ ...success2.transcriptId ? { transcriptId: success2.transcriptId } : {}
21524
+ });
21525
+ } catch (error51) {
21526
+ return recordCommandDataSchema.parse({
21527
+ ...data,
21528
+ cloudHandoffError: toCliError(error51).descriptor
21529
+ });
21530
+ }
21531
+ }
21451
21532
  async function runCli(deps = {}) {
21452
21533
  const argv = deps.argv ?? process.argv.slice(2);
21453
21534
  const stdout = deps.stdout ?? ((text) => process.stdout.write(text));
@@ -21660,7 +21741,7 @@ async function runCli(deps = {}) {
21660
21741
  });
21661
21742
  }
21662
21743
  const translationLanguage = parsed.translationLanguage ?? (mode === "human" && isTTY ? "zh" : void 0);
21663
- const data = await recordViaSidecar({
21744
+ const captured = await recordViaSidecar({
21664
21745
  account: {
21665
21746
  backendOrigin: auth.origin,
21666
21747
  userId: status.userId,
@@ -21682,6 +21763,11 @@ async function runCli(deps = {}) {
21682
21763
  requireLiveCaptions: parsed.live === true,
21683
21764
  runtime: deps.recordRuntime
21684
21765
  });
21766
+ const data = await uploadRecordedSessionAfterStop(client, captured, {
21767
+ title: parsed.title,
21768
+ language: parsed.transcriptionLanguage,
21769
+ onEvent: (event) => renderEvent(event, render3)
21770
+ });
21685
21771
  renderSuccess("record", data, render3);
21686
21772
  return 0;
21687
21773
  }