Add OnelinerState::Manual variant
This commit introduces a new `Manual` variant to the `OnelinerState` enum, allowing for manual overrides of the oneliner text. This change affects the client and server components to handle and display this new state. A `OnelinerOverrideRequest` struct is also added for API requests to set manual oneliners. New tests are included to ensure the `Manual` variant serializes and deserializes correctly. The `compute_oneliner_display` function in `server/src/routes/user_web.rs` is updated to treat `Manual` states the same as `Ready` states for display purposes. The `cases_needing_oneliner_in` function in `server/src/transcribe/recovery.rs` is updated to not retry cases that are in a `Manual` state.
This commit is contained in:
@@ -83,6 +83,21 @@ pub async fn read_oneliner_state(
|
||||
(Some(state), mtime)
|
||||
}
|
||||
|
||||
/// Write `state` atomically to `case_dir/oneliner.json` via
|
||||
/// `write(tmp) + rename(tmp, final)`. Rename is atomic within a single
|
||||
/// filesystem, so concurrent readers never see a half-serialized JSON
|
||||
/// document.
|
||||
pub async fn write_oneliner_state(
|
||||
case_dir: &Path,
|
||||
state: &OnelinerState,
|
||||
) -> std::io::Result<()> {
|
||||
let final_path = case_dir.join(ONELINER_FILENAME);
|
||||
let tmp_path = case_dir.join(format!("{ONELINER_FILENAME}.tmp"));
|
||||
let payload = serde_json::to_vec(state).expect("OnelinerState is infallibly serializable");
|
||||
tokio::fs::write(&tmp_path, &payload).await?;
|
||||
tokio::fs::rename(&tmp_path, &final_path).await
|
||||
}
|
||||
|
||||
/// Load the `.transcript.txt` sidecar for a recording as a
|
||||
/// [`TranscriptState`].
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user