Skip to content

feat: add incremental segment cleanup controls#19

Merged
ElbertePlinio merged 1 commit into
mainfrom
feat/segment-cleanup
Jul 7, 2026
Merged

feat: add incremental segment cleanup controls#19
ElbertePlinio merged 1 commit into
mainfrom
feat/segment-cleanup

Conversation

@ElbertePlinio

Copy link
Copy Markdown
Member

Changed

  • Added Settings toggles for incremental transcription and opt-in segment cleanup.
  • Added CLI --incremental-cleanup / PICKSCRIBE_INCREMENTAL_CLEANUP=1, gated to output-only or no-paste worker starts.
  • Queued segment cleanup off the raw transcription path, with CLI cancel-safe cleanup helper termination.
  • Updated README, SECURITY, env helper, and release notes.

Refs #14

Tested

  • cargo test --workspace --locked --all-targets
  • bun run check
  • bun run test
  • bun run test:coverage
  • git diff --check
  • rustfmt --edition 2024 src/bin/pickscribe.rs src/bin/pickscribe-cleanup.rs src-tauri/src/engine.rs
  • mocked CLI smokes for enabled segment cleanup, unsafe-mode gating, and slow cleanup cancel/nonblocking behavior

Not tested

  • cargo fmt --all --check is blocked here because this toolchain is missing cargo-fmt.

Risks

  • App-side HTTP cleanup requests still run through the shared blocking cleanup client, so an in-flight request may run until its configured timeout after stop/cancel. Raw segment emission and final output are no longer blocked by that path.

@ElbertePlinio

Copy link
Copy Markdown
Member Author

@codex review

@ElbertePlinio

Copy link
Copy Markdown
Member Author

@codex review

@ElbertePlinio ElbertePlinio force-pushed the feat/segment-cleanup branch from 13bae1a to dffb23b Compare July 7, 2026 20:20
@ElbertePlinio

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 13bae1ab03

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +410 to +414
if args.local_only && !is_local_endpoint(&endpoint) {
return Err(anyhow!(
"local-only mode blocks remote endpoint {endpoint}; use Ollama or disable cleanup"
));
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Prefer local provider for auto in local-only cleanup

When incremental segment cleanup invokes this helper with --local-only and the cleanup provider is left at the default auto, resolve_llm_config has already preferred DeepSeek/OpenAI above whenever an API key is present. This new check then rejects that remote endpoint instead of resolving auto to Ollama like the app config path does, so users with local-only enabled and a remote API key get raw/no segment cleanup even when a local Ollama endpoint is available. Resolve auto to the local provider before applying the endpoint block.

Useful? React with 👍 / 👎.

Comment thread src/bin/pickscribe.rs Outdated
Comment on lines +2076 to +2080
let status = wait_for_cancellable_child(&mut child, process_group, is_cancelled)
.context("failed to wait for cleanup command")?;
let mut stdout = String::new();
if let Some(mut child_stdout) = child.stdout.take() {
child_stdout

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 Badge Drain cleanup stdout while the child runs

When incremental segment cleanup uses a custom or verbose cleanup helper that writes more than the OS pipe buffer to stdout, the child can block on its write because this path waits for process exit before reading from the piped stdout. In that case the segment cleanup worker stops producing cleaned live segments until the recording is stopped or cancelled; read stdout concurrently with the cancellable wait or otherwise avoid waiting on a full pipe.

Useful? React with 👍 / 👎.

Comment thread src-tauri/src/engine.rs
break;
}

let outcome = cleanup::clean(&cfg, &raw.raw_text);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 Badge Cancel orphaned segment cleanup on finish

When a recording finishes normally while a raw segment is queued, dropping SegmentCleanupWorker only drops the channels; it never cancels or joins this spawned thread. If the session is still current while the final cleanup/paste pipeline is running, the thread can still execute this extra cleanup::clean even though the result receiver is gone, causing a redundant LLM request for a partial segment after stop. Cancel the worker token or otherwise shut the thread down before returning.

Useful? React with 👍 / 👎.

@ElbertePlinio ElbertePlinio force-pushed the feat/segment-cleanup branch from dffb23b to 35b1b6d Compare July 7, 2026 20:24
@ElbertePlinio

Copy link
Copy Markdown
Member Author

Addressed the Codex findings from the previous head:

  • Local-only auto in pickscribe-cleanup now resolves to Ollama before endpoint blocking.
  • CLI segment cleanup now drains stdout concurrently while waiting/cancelling the helper process.
  • App segment cleanup workers now receive a cancellation signal on drop so queued partial cleanup work does not continue after finish.

Also added regressions for local-only auto and large cleanup stdout, and reran the Rust coverage gate locally.

@ElbertePlinio

Copy link
Copy Markdown
Member Author

@codex review

@ElbertePlinio ElbertePlinio force-pushed the feat/segment-cleanup branch from 35b1b6d to f503513 Compare July 7, 2026 20:32
@ElbertePlinio

Copy link
Copy Markdown
Member Author

@codex review

@ElbertePlinio

Copy link
Copy Markdown
Member Author

Removed the signal-heavy unit test that was killing cargo llvm-cov in CI with exit 130. The same cancel/nonblocking behavior remains covered by the mocked CLI smoke, and the exact Rust coverage command passes locally after the change.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: f50351362a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ElbertePlinio ElbertePlinio merged commit f739d6e into main Jul 7, 2026
1 check passed
@ElbertePlinio ElbertePlinio deleted the feat/segment-cleanup branch July 7, 2026 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant