Skip to content

fix: sanitize terminal app accessibility context to prevent garbled transcription#99

Open
MundusCaeli wants to merge 4 commits intoamicalhq:mainfrom
MundusCaeli:fix/terminal-context-sanitization
Open

fix: sanitize terminal app accessibility context to prevent garbled transcription#99
MundusCaeli wants to merge 4 commits intoamicalhq:mainfrom
MundusCaeli:fix/terminal-context-sanitization

Conversation

@MundusCaeli
Copy link

@MundusCaeli MundusCaeli commented Feb 14, 2026

Problem

When dictating into terminal emulators (iTerm2, Ghostty, Terminal.app, Warp, etc.), the transcription output is garbled — the text in Amical's own history is also corrupted, not just the pasted result. However, when Amical is the frontmost app, transcription works correctly.

Root cause: macOS Accessibility API exposes terminal content (command output, ANSI escape sequences, shell prompts) as preSelectionText/postSelectionText. This raw text is sent to the cloud transcription endpoint as sharedContext.beforeText/afterText, and used as initial_prompt for local Whisper. The noisy context degrades recognition quality, especially for non-English languages like Japanese.

Solution

  1. Add "terminal" AppType with bundle identifiers for 8 common terminal apps: Terminal.app, iTerm2, Ghostty, Warp, kitty, WezTerm, Alacritty, Hyper

  2. Sanitize cloud API context (amical-cloud-provider.ts): When the active app is a terminal, strip selectedText, beforeText, and afterText from sharedContext while still sending appType, appBundleId, and appName

  3. Skip noisy initial_prompt (whisper-provider.ts): For terminal apps, skip using accessibility preSelectionText as Whisper's initial_prompt to prevent local transcription degradation

  4. Terminal-specific formatting rules (formatter-prompt.ts): Add formatting rules and examples appropriate for terminal context (preserve technical terminology, plain text output)

Testing

  • Tested by dictating Japanese text while iTerm2 and Ghostty were the active apps
  • Verified that transcription quality is restored to the same level as when Amical is the frontmost app
  • Non-terminal apps are unaffected (same code paths as before)

Related

Summary by CodeRabbit

  • New Features

    • Added explicit support for terminal applications: terminal-specific detection, formatting, and examples to preserve literal command text and plain-text output.
  • Bug Fixes / Reliability

    • Strip ANSI escape sequences from terminal text to reduce noisy context and improve transcription and prompt quality.
    • Improved transcription reliability with normalized prompts, enhanced network/error handling, retry on auth failure, and clearer logging for cloud requests.

@coderabbitai
Copy link

coderabbitai bot commented Feb 14, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a "terminal" AppType and terminal bundle mappings; strips ANSI escape sequences from accessibility text in transcription paths; maps terminal apps to "default" in cloud payloads; improves cloud fetch error handling and auth-retry; and normalizes pre-selection text for Whisper by removing ANSI codes.

Changes

Cohort / File(s) Summary
Formatter — AppType & prompts
apps/desktop/src/pipeline/providers/formatting/formatter-prompt.ts
Added "terminal" to AppType; added terminal entries in APP_TYPE_RULES and APP_TYPE_EXAMPLES; expanded BUNDLE_TO_TYPE to map common terminal bundle IDs to terminal.
Cloud transcription payload & networking
apps/desktop/src/pipeline/providers/transcription/amical-cloud-provider.ts
Builds sharedContext via IIFE that detects appType, maps terminal"default" for payload, strips ANSI sequences from accessibility fields for terminal apps, preserves app metadata and surroundingContext; added ANSI stripper, enhanced fetch error handling (NETWORK_ERROR), parses server error bodies, and retries once on 401 after token refresh.
Local transcription normalization
apps/desktop/src/pipeline/providers/transcription/whisper-provider.ts
Introduced rawBeforeText and normalize step that strips ANSI escape sequences from preSelectionText before using it in generateInitialPrompt to remove terminal control codes.

Sequence Diagram(s)

sequenceDiagram
  participant App as Desktop App
  participant Formatter as formatter-prompt
  participant Whisper as whisper-provider
  participant Cloud as Amical Cloud

  App->>Formatter: send bundleId / accessibilityContext
  Formatter-->>App: return appType (e.g., "terminal")
  App->>Whisper: request initial prompt with accessibilityContext
  alt appType == "terminal"
    Whisper-->>App: strip ANSI from preSelectionText -> normalized prompt
  else
    Whisper-->>App: generate prompt (raw text)
  end
  App->>Cloud: build sharedContext (IIFE: map terminal->"default", strip ANSI where needed)
  App->>Cloud: POST transcription request
  Cloud-->>App: 200 / transcription or error
  alt 401
    App->>Cloud: refresh token + retry (once)
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 I hopped through bundles, found a terminal shell,
Stripped ANSI noise where the control codes dwell.
I mapped types, trimmed prompts, sent clean text on a cloud,
Whisper hums clearer, the payloads stand proud.
Hop, nibble, ship — a tidy little sound. 🥕

🚥 Pre-merge checks | ✅ 3 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding ANSI sequence sanitization for terminal app accessibility context to fix garbled transcriptions.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@haritabh-z01
Copy link
Contributor

@MundusCaeli, I have been using iterm2 (plus oh my zsh) pretty extensively with Amical, and never ran into this. Have also used warp extensively and never ran into this issue. Would you be able to provide a minimal example of what your terminal contents were when you ran into this issue.
I would prefer to just strip of unknown character sequences rather than the entire surrounding context since while writing prompts in agentic cli the previous text does help.

MundusCaeli and others added 2 commits February 14, 2026 17:20
…ranscription

Terminal emulators (iTerm2, Ghostty, Terminal.app, Warp, kitty, etc.) expose
command output, ANSI escape sequences, and shell prompt strings through the
macOS Accessibility API.  When this raw text is sent as sharedContext
(beforeText/afterText) to the cloud transcription endpoint or used as
initial_prompt for local Whisper, it degrades recognition quality -- causing
garbled output especially for non-English (e.g. Japanese) dictation.

Changes:
- Add 'terminal' AppType with 8 common terminal bundle identifiers
- Strip selectedText/beforeText/afterText from sharedContext for terminal apps
  in AmicalCloudProvider
- Skip noisy accessibility context in WhisperProvider.generateInitialPrompt()
  for terminal apps
- Add terminal-specific formatting rules and examples

Fixes garbled transcription when dictating into terminal applications.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
…dation error

The cloud API does not yet recognize 'terminal' as a valid appType,
returning 400 INVALID_REQUEST. Map terminal appType to 'default' in
the request while still stripping noisy accessibility context fields.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
@MundusCaeli MundusCaeli force-pushed the fix/terminal-context-sanitization branch from 90a7763 to 38d0498 Compare February 14, 2026 08:21
@MundusCaeli
Copy link
Author

Reproduction

The issue occurs when the terminal has large amounts of output — specifically from agentic CLI tools (e.g., Factory Droid, Claude Code) that produce thousands of lines of mixed content (ASCII art, escape sequences, code snippets, conversation logs). A normal shell session with short commands and output does not trigger it, which explains why you have not seen it with regular iTerm2/Warp usage.

Minimal reproduction:

  1. Run any tool that fills the terminal with several thousand characters of mixed content (long cat of a file, git log --stat, or an agentic CLI session)
  2. With that terminal window as the frontmost app, start an Amical dictation in Japanese (or another non-English language)
  3. The transcription fails or returns garbled output

Root Cause Discovery

During debugging, we found the problem is actually two-fold:

  1. Context pollution (the original hypothesis): The accessibility API exposes the full terminal buffer as preSelectionText/postSelectionText, which gets sent as sharedContext.beforeText/afterText. For large terminal sessions this can be tens of thousands of characters of noisy content.

  2. Server validation error (the real blocker): When we added appType: "terminal", the cloud API returned 400 INVALID_REQUEST because "terminal" is not a recognized appType on the server side. This was the actual cause of the complete transcription failure — not just degraded quality.

Current Fix

The current PR:

  • Strips selectedText, beforeText, afterText for terminal apps (addressing issue 1)
  • Sends appType: "default" instead of "terminal" to avoid the server validation error (addressing issue 2)

Your Suggestion

I agree that stripping the entire surrounding context is too aggressive — for agentic CLIs the previous text genuinely helps with context. A better approach would be:

  • Truncate beforeText/afterText to a reasonable length limit (e.g., last 2000 chars) instead of removing entirely
  • Strip ANSI escape sequences and control characters while preserving readable text
  • Add "terminal" as a recognized appType on the server side so we can send it properly

Happy to update the PR with a more selective sanitization approach if you prefer. Would a length-limited + ANSI-stripped version work for you?

@haritabh-z01
Copy link
Contributor

@MundusCaeli Thanks for this. I think we can just strip out the ANSI characters across the board for now and leave the app type as the default since no special prompt instructions need be applied.
We already trim the context (both locally and on the cloud) before using it as prompt. So just stripping out ANSI control sequences should do the job.
Tokens reduction / preselection text length reduction all across the board I will take up as a separate thing if need be.

@MundusCaeli
Copy link
Author

Thanks for the guidance @haritabh-z01!

One concern I want to flag: in our case, the terminal accessibility context was tens of thousands of characters (from an agentic CLI session like Factory Droid). Even after stripping ANSI sequences, the remaining plain text is still very large. If the existing trimming on the cloud/local side handles that volume well, then ANSI stripping alone should be sufficient — but I wanted to mention it in case there are edge cases with extremely long terminal buffers.

I will update the PR to:

  1. Strip ANSI control sequences from beforeText/afterText (across the board, not just for terminals)
  2. Remove the terminal-specific formatting rules and examples
  3. Keep appType as "default" for terminals

Will test with the same reproduction scenario (large agentic CLI output in Ghostty/iTerm2, Japanese dictation) and report back.

…ntext

Per reviewer feedback, replace the full context stripping for terminal
apps with ANSI escape sequence removal applied across the board.
Terminal-specific formatting rules and examples are removed since the
default rules apply.  The terminal AppType and bundle ID detection are
kept so appType can be sent as 'default' to avoid server validation
errors until the server recognizes 'terminal'.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
@MundusCaeli
Copy link
Author

Updated the PR per your suggestion:

  • Replaced full context stripping with ANSI escape sequence removal applied to beforeText/afterText (both in cloud provider and whisper provider)
  • Removed terminal-specific formatting rules and examples (empty strings now, default rules apply)
  • Kept terminal bundle ID detection + appType: "default" mapping

Tested with Ghostty as frontmost app running a large agentic CLI session (Factory Droid), Japanese dictation — transcription works correctly now. Your approach was right, ANSI stripping alone is sufficient.

Copy link

@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: 2

🤖 Fix all issues with AI agents
In `@apps/desktop/src/pipeline/providers/formatting/formatter-prompt.ts`:
- Around line 41-42: APP_TYPE_RULES.terminal and APP_TYPE_EXAMPLES.terminal are
set to empty strings which prevents the nullish-coalescing (??) in the template
from falling back to defaults; either change those terminal values to undefined
(so APP_TYPE_RULES[appType] ?? APP_TYPE_RULES.default works as intended) or
update the template to use logical OR (||) instead of ?? to treat empty string
as falsy; if empty string is intentional (meaning no app-specific
rules/examples), add a clarifying comment next to
APP_TYPE_RULES.terminal/APP_TYPE_EXAMPLES.terminal indicating that behavior.

In `@apps/desktop/src/pipeline/providers/transcription/amical-cloud-provider.ts`:
- Around line 297-325: The selectedText in the sharedContext closure is not
sanitized like beforeText/afterText; update the closure where sharedContext is
built (inside the currentAccessibilityContext check that calls
detectApplicationType) to pass the selectedText through stripAnsiSequences as
well (same way preSelectionText/postSelectionText are handled), i.e. replace the
direct use of currentAccessibilityContext!.context?.textSelection?.selectedText
with a stripped version using stripAnsiSequences so selectedText, beforeText and
afterText are consistently sanitized.
🧹 Nitpick comments (3)
apps/desktop/src/pipeline/providers/transcription/whisper-provider.ts (1)

281-287: Duplicated ANSI-stripping regex — extract a shared utility.

The same regex and stripping logic is duplicated here and in amical-cloud-provider.ts (lines 21-28). Consider extracting a shared stripAnsiSequences helper (e.g., in a text-utils.ts module) to keep a single source of truth and make future regex improvements apply everywhere.

Also, while the eslint-disable comment silences ESLint, Biome still flags the control characters (\u001b, \u009b). You may want to add a Biome-specific suppression comment (// biome-ignore lint/suspicious/noControlCharactersInRegex: intentional ANSI matching) or configure this rule in biome.json for the shared module.

Proposed shared utility

Create a new file (e.g., apps/desktop/src/pipeline/utils/text-sanitize.ts):

// Strip ANSI escape sequences and control characters commonly found in
// terminal accessibility output.
const ANSI_REGEX =
  // biome-ignore lint/suspicious/noControlCharactersInRegex: intentional – matching terminal escape codes
  // eslint-disable-next-line no-control-regex
  /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><~]/g;

export function stripAnsiSequences(
  text: string | undefined | null,
): string | undefined {
  if (!text) return undefined;
  return text.replace(ANSI_REGEX, "");
}

Then import and use it in both providers.

apps/desktop/src/pipeline/providers/transcription/amical-cloud-provider.ts (2)

298-325: Consider extracting the IIFE into a named method for readability.

The inline IIFE that builds sharedContext makes the JSON.stringify payload harder to scan. A small private method like buildSharedContext() would improve readability and make the non-null assertions unnecessary (the method can accept the context as a parameter with a non-nullable type).

Sketch
+  private buildSharedContext(
+    accessibilityContext: GetAccessibilityContextResult,
+  ) {
+    const appType = detectApplicationType(accessibilityContext);
+    const sel = accessibilityContext.context?.textSelection;
+    const app = accessibilityContext.context?.application;
+    return {
+      selectedText: stripAnsiSequences(sel?.selectedText),
+      beforeText: stripAnsiSequences(sel?.preSelectionText),
+      afterText: stripAnsiSequences(sel?.postSelectionText),
+      appType: appType === "terminal" ? "default" : appType,
+      appBundleId: app?.bundleIdentifier,
+      appName: app?.name,
+      appUrl: accessibilityContext.context?.windowInfo?.url,
+      surroundingContext: "",
+    };
+  }

Then in the payload:

-          sharedContext: this.currentAccessibilityContext
-            ? (() => { ... })()
-            : undefined,
+          sharedContext: this.currentAccessibilityContext
+            ? this.buildSharedContext(this.currentAccessibilityContext)
+            : undefined,

18-28: Biome lint suppression needed for intentional control characters.

Same as noted in whisper-provider.ts — the eslint-disable comment doesn't suppress Biome's noControlCharactersInRegex rule. Once the regex is extracted to a shared utility (as suggested in the other file), a single Biome suppression comment there will cover both call sites.

Comment on lines +41 to 42
terminal: "",
default: "",
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Empty-string entries silently suppress default rules/examples for terminal apps.

APP_TYPE_RULES.terminal and APP_TYPE_EXAMPLES.terminal are "". Because ?? only falls through on null/undefined (not empty string), the template on lines 226 and 231 will inject an empty string rather than the default rules/examples:

${APP_TYPE_RULES[appType] ?? APP_TYPE_RULES.default ?? ""}
//                 ""     → "" (not null, so ?? doesn't trigger)

If the intent is for terminal apps to use no app-specific rules (relying on universal rules only), this is fine but worth a brief comment. If the intent is to fall back to default rules, change the values to undefined or use || instead of ??.

Also applies to: 110-111

🤖 Prompt for AI Agents
In `@apps/desktop/src/pipeline/providers/formatting/formatter-prompt.ts` around
lines 41 - 42, APP_TYPE_RULES.terminal and APP_TYPE_EXAMPLES.terminal are set to
empty strings which prevents the nullish-coalescing (??) in the template from
falling back to defaults; either change those terminal values to undefined (so
APP_TYPE_RULES[appType] ?? APP_TYPE_RULES.default works as intended) or update
the template to use logical OR (||) instead of ?? to treat empty string as
falsy; if empty string is intentional (meaning no app-specific rules/examples),
add a clarifying comment next to
APP_TYPE_RULES.terminal/APP_TYPE_EXAMPLES.terminal indicating that behavior.

@MundusCaeli
Copy link
Author

Update: Additional findings from further testing

ANSI stripping alone is not sufficient

After more extensive testing, I found that the root cause is not ANSI escape sequences specifically, but the sheer volume of accessibility context text from terminal sessions.

Reproduction:

  1. Use any agentic CLI tool (Factory Droid, Claude Code, OpenCraw TUI) that produces thousands of lines of output
  2. With that terminal as the frontmost app, dictate in Japanese
  3. Result: garbled transcription (e.g., 稀───── christian minute lighting and weso berger...)
  4. Close the terminal, open a fresh one, start the same CLI tool → dictation works fine

This confirms the issue is the size of the terminal buffer being sent as sharedContext.beforeText/afterText, not the ANSI codes themselves. After stripping ANSI, the remaining plain text can still be tens of thousands of characters, which overwhelms the transcription pipeline.

The existing server-side trimming may not be handling these extreme cases (50,000+ characters of mixed multilingual content).

Suggestion

In addition to ANSI stripping (which is still a good improvement), a client-side length limit on beforeText/afterText (e.g., last 2000-4000 characters) would prevent this class of issues entirely. Happy to add this to the PR if you agree.

The ANSI stripping changes in this PR are still valid

Even though they don't fully solve the large-context problem, stripping ANSI sequences is a genuine improvement for any terminal accessibility context. I'll keep the PR as-is for the ANSI fix, and the length limiting can be addressed separately if preferred.

…ents

- Apply stripAnsiSequences to selectedText for consistency
- Add clarifying comments on intentionally empty terminal entries
- Remove extra blank line in whisper-provider.ts

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Copy link

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/desktop/src/pipeline/providers/formatting/formatter-prompt.ts (1)

262-265: ⚠️ Potential issue | 🟠 Major

ANSI sequences are not stripped from beforeText/afterText in the formatting prompt path for terminal applications.

constructFormatterPrompt reads preSelectionText/postSelectionText directly without ANSI stripping. The amical-cloud-provider.ts transcription provider strips these sequences (lines 304, 308, 312) with the note that "Terminal apps expose raw terminal output via the accessibility API which contains escape codes." Since formatter-prompt.ts explicitly supports terminal app types (lines 291–298), ANSI codes could leak into the LLM formatting prompt if terminal apps provide accessibility context.

Extract stripAnsiSequences to a shared utility and apply it here for consistency, or document that ANSI stripping is guaranteed upstream.

🤖 Fix all issues with AI agents
In `@apps/desktop/src/pipeline/providers/transcription/amical-cloud-provider.ts`:
- Around line 25-28: The current stripAnsiSequences function treats empty string
as absent because it uses a truthy check; change the guard to only return
undefined for null/undefined (e.g., check text == null or text === undefined ||
text === null) so that stripAnsiSequences("") returns "" and non-null empty
strings are preserved, then continue to call text.replace(ANSI_REGEX, "") for
other inputs; reference the stripAnsiSequences function and ANSI_REGEX when
making this change.
🧹 Nitpick comments (1)
apps/desktop/src/pipeline/providers/transcription/whisper-provider.ts (1)

280-286: Extract the ANSI-stripping regex into a shared utility to avoid duplication.

The same regex pattern and stripping logic is duplicated here (inline) and in amical-cloud-provider.ts (as ANSI_REGEX + stripAnsiSequences). Consider extracting a shared stripAnsiSequences helper (e.g., in a text-utils.ts module) and reusing it in both providers.

♻️ Suggested approach

Create a shared utility, e.g. apps/desktop/src/pipeline/utils/text-sanitize.ts:

// eslint-disable-next-line no-control-regex
const ANSI_REGEX = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><~]/g;

export function stripAnsiSequences(text: string | undefined | null): string | undefined {
  if (!text) return undefined;
  return text.replace(ANSI_REGEX, "");
}

Then in this file:

-    const rawBeforeText =
-      accessibilityContext?.context?.textSelection?.preSelectionText;
-    // Strip ANSI escape sequences that terminal apps expose via accessibility
-    // context — they degrade Whisper recognition quality.
-    const beforeText = rawBeforeText
-      // eslint-disable-next-line no-control-regex
-      ?.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><~]/g, "");
+    // Strip ANSI escape sequences that terminal apps expose via accessibility
+    // context — they degrade Whisper recognition quality.
+    const beforeText = stripAnsiSequences(
+      accessibilityContext?.context?.textSelection?.preSelectionText,
+    );

Comment on lines +25 to +28
function stripAnsiSequences(text: string | undefined | null): string | undefined {
if (!text) return undefined;
return text.replace(ANSI_REGEX, "");
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

stripAnsiSequences("") returns undefined instead of "".

The !text guard is true for empty strings, so an input of "" is coerced to undefined. If the server or any downstream consumer distinguishes between an absent field and an empty string, this could cause subtle differences in behavior.

If this is intentional (empty and absent are equivalent), this is fine. Otherwise, a narrower null-check would preserve empty strings:

♻️ Suggested fix
 function stripAnsiSequences(text: string | undefined | null): string | undefined {
-  if (!text) return undefined;
+  if (text == null) return undefined;
   return text.replace(ANSI_REGEX, "");
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
function stripAnsiSequences(text: string | undefined | null): string | undefined {
if (!text) return undefined;
return text.replace(ANSI_REGEX, "");
}
function stripAnsiSequences(text: string | undefined | null): string | undefined {
if (text == null) return undefined;
return text.replace(ANSI_REGEX, "");
}
🤖 Prompt for AI Agents
In `@apps/desktop/src/pipeline/providers/transcription/amical-cloud-provider.ts`
around lines 25 - 28, The current stripAnsiSequences function treats empty
string as absent because it uses a truthy check; change the guard to only return
undefined for null/undefined (e.g., check text == null or text === undefined ||
text === null) so that stripAnsiSequences("") returns "" and non-null empty
strings are preserved, then continue to call text.replace(ANSI_REGEX, "") for
other inputs; reference the stripAnsiSequences function and ANSI_REGEX when
making this change.

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.

2 participants