Skip to content

fix(main): backport discord transcription + windows shell detection#2732

Merged
theonlyhennygod merged 2 commits intomainfrom
backport/main-discord-transcription-wsl-shell
Mar 4, 2026
Merged

fix(main): backport discord transcription + windows shell detection#2732
theonlyhennygod merged 2 commits intomainfrom
backport/main-discord-transcription-wsl-shell

Conversation

@theonlyhennygod
Copy link
Collaborator

@theonlyhennygod theonlyhennygod commented Mar 4, 2026

Summary

  • backport Discord inbound audio attachment transcription handling to main
  • backport Windows shell detection guard to skip legacy WSL System32\\bash.exe launcher
  • wire Discord channel construction to pass [transcription] config on main

Validation

  • cargo fmt --all -- --check
  • cargo test --lib discord::tests::process_attachments_ -- --nocapture
  • cargo test --lib runtime::native::tests:: -- --nocapture
  • cargo test --lib compatible::tests::format_transport_error_ -- --nocapture
  • cargo check --package zeroclaw --lib

Notes

  • #2683 TLS transport-root-cause formatting is already present on main in src/providers/compatible.rs, so no additional code change was required here.
  • Existing dev -> main promotion PR #2713 is currently conflict-heavy; this backport PR isolates the two production bug fixes needed now.

Fixes #2686
Fixes #2684

Summary by CodeRabbit

  • New Features

    • Added configurable voice transcription for Discord audio attachments (duration checks, filename inference, injected voice markers) and improved attachment handling for audio/image content types.
  • Bug Fixes

    • Fixed Windows shell detection to skip WSL bash launcher so native PowerShell/Cmd are preferred when available.
  • Tests

    • Added tests covering transcription flows, attachment paths, and Windows shell detection.

@github-actions
Copy link

github-actions bot commented Mar 4, 2026

PR intake checks found warnings (non-blocking)

Fast safe checks found advisory issues. CI lint/test/build gates still enforce merge quality.

  • Missing required PR template sections: ## Validation Evidence (required), ## Security Impact (required), ## Privacy and Data Hygiene (required), ## Rollback Plan (required)
  • Incomplete required PR template fields: summary problem, summary why it matters, summary what changed, validation commands, security risk/mitigation, privacy status, rollback plan
  • Missing Linear issue key reference (RMN-<id>, CDV-<id>, or COM-<id>) in PR title/body (recommended for traceability, non-blocking).

Action items:

  1. Complete required PR template sections/fields.
  2. (Recommended) Link this PR to one active Linear issue key (RMN-xxx/CDV-xxx/COM-xxx) for traceability.
  3. Remove tabs, trailing whitespace, and merge conflict markers from added lines.
  4. Re-run local checks before pushing:
    • ./scripts/ci/rust_quality_gate.sh
    • ./scripts/ci/rust_strict_delta_gate.sh
    • ./scripts/ci/docs_quality_gate.sh

Detected Linear keys: none

Run logs: https://github.com/zeroclaw-labs/zeroclaw/actions/runs/22683645390

Detected blocking line issues (sample):

  • none

Detected advisory line issues (sample):

  • none

@github-actions github-actions bot added channel Auto scope: src/channels/** changed. runtime Auto scope: src/runtime/** changed. labels Mar 4, 2026
@github-actions
Copy link

github-actions bot commented Mar 4, 2026

Thanks for contributing to ZeroClaw.

For faster review, please ensure:

  • PR template sections are fully completed
  • cargo fmt --all -- --check, cargo clippy --all-targets -- -D warnings, and cargo test are included
  • If automation/agents were used heavily, add brief workflow notes
  • Scope is focused (prefer one concern per PR)

See CONTRIBUTING.md and docs/pr-workflow.md for full collaboration rules.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 4, 2026

Warning

Rate limit exceeded

@theonlyhennygod has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 2 minutes and 11 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4e70d24d-ee7a-4971-9f50-2587f67a3bf5

📥 Commits

Reviewing files that changed from the base of the PR and between 3ddbad5 and b35a7c1.

📒 Files selected for processing (3)
  • src/channels/discord.rs
  • src/channels/mod.rs
  • src/runtime/native.rs

Note

.coderabbit.yaml has unrecognized properties

CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.

⚠️ Parsing warnings (1)
Validation error: Unrecognized key(s) in object: 'tools', 'path_filters', 'review_instructions'
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
📝 Walkthrough

Walkthrough

Adds Discord audio transcription support by storing an optional TranscriptionConfig in DiscordChannel, threading it into attachment processing, and implementing audio download/duration checks and transcription invocation. Separately, enhances Windows native shell detection to skip known WSL bash launcher paths.

Changes

Cohort / File(s) Summary
Discord transcription & attachment processing
src/channels/discord.rs, src/channels/mod.rs
Adds transcription: Option<TranscriptionConfig> to DiscordChannel, with_transcription() builder, changes process_attachments(...) to accept Option<&TranscriptionConfig>, threads transcription through call sites, implements audio content-type handling, duration checks, filename inference, transcription invocation, and test updates.
Windows native shell detection
src/runtime/native.rs
Adds is_windows_wsl_bash_launcher() helper and a Windows-specific guard in detect_native_shell_with to skip System32/Sysnative WSL bash launchers; adds tests for detection and fallback behavior.

Sequence Diagram(s)

sequenceDiagram
    participant Discord as DiscordChannel
    participant HTTP as reqwest::Client
    participant Transcriber as TranscriptionService (TranscriptionConfig)
    participant Agent as MessageProcessor

    Discord->>Agent: receive message with attachments
    Agent->>Discord: call process_attachments(attachments, HTTP, transcription?)
    alt attachment is image
        Discord->>HTTP: GET image URL
        HTTP-->>Discord: image bytes
        Discord-->>Agent: inject [Image:<name>]
    else attachment is audio
        Discord->>Transcriber: check transcription config present?
        alt transcription configured
            Discord->>HTTP: GET audio URL
            HTTP-->>Discord: audio bytes
            Discord->>Transcriber: transcribe(audio bytes)
            Transcriber-->>Discord: transcript text
            Discord-->>Agent: inject [Voice:<filename>] transcript
        else no transcription
            Discord-->>Agent: skip audio or inject placeholder
        end
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested labels

bug, tool: shell

Suggested reviewers

  • chumyin
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers key areas but is missing most required template sections like risk label, size label, scope labels, module labels, change type, primary scope, linked issue numbers, and security/privacy/compatibility metadata. Complete the PR description by filling in all required template sections including labels, change metadata, linked issue closure statements, validation evidence, security impact, and side effects analysis.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main changes: backporting Discord transcription support and Windows shell detection fixes to main branch.
Linked Issues check ✅ Passed The code changes directly address both linked issues: Discord transcription is restored via new with_transcription() method and attachment audio processing, while Windows WSL bash detection is fixed via is_windows_wsl_bash_launcher() helper.
Out of Scope Changes check ✅ Passed All changes are narrowly scoped to the two production bug fixes: Discord transcription addition, Windows shell detection guard, and supporting utilities. No unrelated modifications detected.
Docstring Coverage ✅ Passed Docstring coverage is 81.82% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch backport/main-discord-transcription-wsl-shell

Comment @coderabbitai help to get the list of available commands and usage tips.

@theonlyhennygod theonlyhennygod self-assigned this Mar 4, 2026
@github-actions github-actions bot added size: M Auto size: 251-500 non-doc changed lines. risk: high Auto risk: security/runtime/gateway/tools/workflows. distinguished contributor Contributor with 50+ merged PRs. channel: discord Auto module: channel/discord changed. runtime: native Auto module: runtime/native changed. and removed channel Auto scope: src/channels/** changed. runtime Auto scope: src/runtime/** changed. labels Mar 4, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
src/channels/discord.rs (2)

2045-2047: Keep one non-ignored transcription happy-path test in the default suite.

The end-to-end success-path test is currently #[ignore], so default CI won’t catch regressions in the primary transcription flow.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/channels/discord.rs` around lines 2045 - 2047, Remove the #[ignore =
"requires local loopback TCP bind"] on the async test
process_attachments_transcribes_audio_when_enabled (or add a new non-ignored
happy-path test with the same name/behavior) so CI runs a successful
transcription end-to-end test by default; if the existing test truly requires
special networking, extract the network-dependent setup into a separate ignored
test and keep a lightweight, deterministic happy-path test (e.g., using a mocked
HTTP/TCP client or a prerecorded local file) in the main suite to validate the
primary transcription flow.

69-74: Make with_transcription overwrite semantics explicit.

Calling this with a disabled config currently leaves any prior enabled config intact; setting the field unconditionally avoids stale builder state.

♻️ Proposed refactor
 pub fn with_transcription(mut self, config: TranscriptionConfig) -> Self {
-    if config.enabled {
-        self.transcription = Some(config);
-    }
+    self.transcription = config.enabled.then_some(config);
     self
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/channels/discord.rs` around lines 69 - 74, The current with_transcription
method leaves a previous enabled transcription config in place when called with
a disabled TranscriptionConfig; change it to overwrite unconditionally by
setting the struct field transcription based on the passed config (for example
assign Some(config) when config.enabled is true and None when false) so
with_transcription always updates/clears prior builder state; update the method
referencing with_transcription, TranscriptionConfig, and the transcription
field.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/channels/discord.rs`:
- Around line 291-301: The function is_audio_attachment wrongly treats explicit
non-audio MIME types (except application/octet-stream) as non-audio, which
causes application/ogg to be skipped; update is_audio_attachment to treat
application/ogg as audio (or more generally treat any content type that
audio_extension_from_content_type maps to an audio extension as audio) so that
when normalized_content_type == "application/ogg" the function returns true (or
consult audio_extension_from_content_type within is_audio_attachment) and allow
such attachments to reach transcription; reference function is_audio_attachment
and helper audio_extension_from_content_type to locate the logic to change.

---

Nitpick comments:
In `@src/channels/discord.rs`:
- Around line 2045-2047: Remove the #[ignore = "requires local loopback TCP
bind"] on the async test process_attachments_transcribes_audio_when_enabled (or
add a new non-ignored happy-path test with the same name/behavior) so CI runs a
successful transcription end-to-end test by default; if the existing test truly
requires special networking, extract the network-dependent setup into a separate
ignored test and keep a lightweight, deterministic happy-path test (e.g., using
a mocked HTTP/TCP client or a prerecorded local file) in the main suite to
validate the primary transcription flow.
- Around line 69-74: The current with_transcription method leaves a previous
enabled transcription config in place when called with a disabled
TranscriptionConfig; change it to overwrite unconditionally by setting the
struct field transcription based on the passed config (for example assign
Some(config) when config.enabled is true and None when false) so
with_transcription always updates/clears prior builder state; update the method
referencing with_transcription, TranscriptionConfig, and the transcription
field.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d26c0ad2-7eaa-4cf4-b40a-c55d10f2197d

📥 Commits

Reviewing files that changed from the base of the PR and between f9b9e95 and 48c496f.

📒 Files selected for processing (3)
  • src/channels/discord.rs
  • src/channels/mod.rs
  • src/runtime/native.rs

@theonlyhennygod theonlyhennygod force-pushed the backport/main-discord-transcription-wsl-shell branch from 48c496f to 3ddbad5 Compare March 4, 2026 18:25
@github-actions github-actions bot added channel Auto scope: src/channels/** changed. runtime Auto scope: src/runtime/** changed. and removed channel Auto scope: src/channels/** changed. runtime Auto scope: src/runtime/** changed. labels Mar 4, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
src/channels/discord.rs (1)

291-301: ⚠️ Potential issue | 🟠 Major

Treat application/ogg as audio in the attachment gate.

At Line 295-300, is_audio_attachment rejects explicit non-audio/* MIME types (except octet-stream), so application/ogg is skipped before transcription. That conflicts with Line 346 where audio_extension_from_content_type explicitly maps application/ogg.

🐛 Proposed fix
 fn is_audio_attachment(content_type: &str, filename: &str, url: &str) -> bool {
     let normalized_content_type = normalize_content_type(content_type);

     if !normalized_content_type.is_empty() {
-        if normalized_content_type.starts_with("audio/") {
+        if normalized_content_type.starts_with("audio/")
+            || audio_extension_from_content_type(content_type).is_some()
+        {
             return true;
         }
         // Trust explicit non-audio MIME to avoid false positives from filename extensions.
         if normalized_content_type != "application/octet-stream" {
             return false;
         }
     }

     has_audio_extension(filename) || has_audio_extension(url)
 }

Also applies to: 340-347

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/channels/discord.rs` around lines 291 - 301, The is_audio_attachment
function currently rejects non-audio MIME types (except
application/octet-stream) which causes application/ogg to be skipped; update
is_audio_attachment to treat "application/ogg" as audio by allowing it to pass
the MIME check (e.g., consider "application/ogg" equivalent to audio/*) so
transcription proceeds; ensure this aligns with the existing
audio_extension_from_content_type mapping (keep
audio_extension_from_content_type as-is or confirm it maps "application/ogg" to
the correct extension) and reference is_audio_attachment and
audio_extension_from_content_type when making the change.
🧹 Nitpick comments (1)
src/channels/discord.rs (1)

2045-2047: Avoid ignoring the only success-path transcription test by default.

Line 2046 disables the one end-to-end assertion that Discord audio is actually transcribed, so regressions in the happy path can slip through CI.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/channels/discord.rs` around lines 2045 - 2047, The test function
process_attachments_transcribes_audio_when_enabled is marked #[ignore =
"requires local loopback TCP bind"] which prevents the only success-path
transcription assertion from running in CI; remove the #[ignore] attribute (or
replace it with a deterministic approach) and make the test CI-safe by either
(a) binding to an ephemeral loopback port or using the existing test helper that
allocates a free port, or (b) refactoring the test to use a mock/fake
network/audio provider so it no longer requires a local TCP bind; update the
setup inside process_attachments_transcribes_audio_when_enabled to use that
CI-safe binding or mock so the test can run unignored.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@src/channels/discord.rs`:
- Around line 291-301: The is_audio_attachment function currently rejects
non-audio MIME types (except application/octet-stream) which causes
application/ogg to be skipped; update is_audio_attachment to treat
"application/ogg" as audio by allowing it to pass the MIME check (e.g., consider
"application/ogg" equivalent to audio/*) so transcription proceeds; ensure this
aligns with the existing audio_extension_from_content_type mapping (keep
audio_extension_from_content_type as-is or confirm it maps "application/ogg" to
the correct extension) and reference is_audio_attachment and
audio_extension_from_content_type when making the change.

---

Nitpick comments:
In `@src/channels/discord.rs`:
- Around line 2045-2047: The test function
process_attachments_transcribes_audio_when_enabled is marked #[ignore =
"requires local loopback TCP bind"] which prevents the only success-path
transcription assertion from running in CI; remove the #[ignore] attribute (or
replace it with a deterministic approach) and make the test CI-safe by either
(a) binding to an ephemeral loopback port or using the existing test helper that
allocates a free port, or (b) refactoring the test to use a mock/fake
network/audio provider so it no longer requires a local TCP bind; update the
setup inside process_attachments_transcribes_audio_when_enabled to use that
CI-safe binding or mock so the test can run unignored.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 76cdc0ee-280f-4635-a0ea-c8fa01dae0c7

📥 Commits

Reviewing files that changed from the base of the PR and between 48c496f and 3ddbad5.

📒 Files selected for processing (3)
  • src/channels/discord.rs
  • src/channels/mod.rs
  • src/runtime/native.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/runtime/native.rs
  • src/channels/mod.rs

@github-actions github-actions bot added channel Auto scope: src/channels/** changed. runtime Auto scope: src/runtime/** changed. and removed channel Auto scope: src/channels/** changed. runtime Auto scope: src/runtime/** changed. labels Mar 4, 2026
@theonlyhennygod theonlyhennygod force-pushed the backport/main-discord-transcription-wsl-shell branch from bf27239 to a749fde Compare March 4, 2026 18:30
@github-actions github-actions bot added the channel Auto scope: src/channels/** changed. label Mar 4, 2026
@github-actions github-actions bot added runtime Auto scope: src/runtime/** changed. and removed channel Auto scope: src/channels/** changed. runtime Auto scope: src/runtime/** changed. labels Mar 4, 2026
@theonlyhennygod theonlyhennygod force-pushed the backport/main-discord-transcription-wsl-shell branch from a749fde to b9f65fe Compare March 4, 2026 18:34
@github-actions github-actions bot added channel Auto scope: src/channels/** changed. runtime Auto scope: src/runtime/** changed. and removed channel Auto scope: src/channels/** changed. runtime Auto scope: src/runtime/** changed. labels Mar 4, 2026
@theonlyhennygod theonlyhennygod force-pushed the backport/main-discord-transcription-wsl-shell branch from b9f65fe to b35a7c1 Compare March 4, 2026 18:35
@github-actions github-actions bot added channel Auto scope: src/channels/** changed. runtime Auto scope: src/runtime/** changed. and removed channel Auto scope: src/channels/** changed. runtime Auto scope: src/runtime/** changed. labels Mar 4, 2026
@theonlyhennygod theonlyhennygod merged commit edf43d6 into main Mar 4, 2026
4 of 5 checks passed
@theonlyhennygod theonlyhennygod deleted the backport/main-discord-transcription-wsl-shell branch March 4, 2026 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Auto module: channel/discord changed. distinguished contributor Contributor with 50+ merged PRs. risk: high Auto risk: security/runtime/gateway/tools/workflows. runtime: native Auto module: runtime/native changed. size: M Auto size: 251-500 non-doc changed lines.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant