Skip to content

fix: Windows/Linux cross-platform compatibility#7

Merged
nmbrthirteen merged 3 commits into
mainfrom
fix/windows-linux-compat
Jun 10, 2026
Merged

fix: Windows/Linux cross-platform compatibility#7
nmbrthirteen merged 3 commits into
mainfrom
fix/windows-linux-compat

Conversation

@nmbrthirteen

@nmbrthirteen nmbrthirteen commented Jun 10, 2026

Copy link
Copy Markdown
Owner

Summary

podcli ran cleanly on macOS but had several Windows-breaking issues (a couple also affect non-UTF-8 Linux locales). This makes it work on Windows and Linux without changing macOS behavior — every edit is either platform-conditional or purely additive.

Fixes

  1. Python interpreter discovery on Windowssrc/config/paths.ts
    detectPython() now branches on process.platform === "win32": looks for venv\Scripts\python.exe and falls back to python (not python3). This was the hard blocker — the MCP server and web UI spawn this interpreter for every backend task, so on Windows nothing could run.

  2. UTF-8 encoding — 40 text-mode open() calls across 17 backend files
    Added encoding="utf-8" to every text-mode open()/json target. Windows defaults text mode to cp1252, which silently corrupts UTF-8 transcripts on read and raises UnicodeEncodeError when writing JSON containing emoji/non-Latin text. Binary opens, wave.open, urlopen, os.fdopen, and the os.devnull→subprocess fd were deliberately left untouched.

  3. Thumbnail fontsbackend/services/thumbnail_generator.py
    Added C:/Windows/Fonts/arial*.ttf to the TTC face list and standalone fallbacks (mirrors the existing pattern in caption_renderer.py). Previously Windows fell back to PIL's bitmap default font.

  4. Reveal-in-folderbackend/cli.py
    Added one _reveal_in_os() helper (open / os.startfile / xdg-open per platform, best-effort) and routed all 4 former call sites through it. Previously these ran xdg-open on Windows, which doesn't exist.

  5. UI basename helperssrc/ui/client/lib.ts, src/ui/web-server.ts
    Split on /[/\\]/ so Windows backslash paths render the filename rather than the whole path.

  6. npm/npx/.cmd shim execution on Windowsbackend/cli.py, backend/services/thumbnail_html.py
    On Windows npm/npx are .cmd batch files that Python's subprocess can't run without a shell. The webui menu's npm run build/ui:prod now pass shell=True on Windows; the Playwright thumbnail fallback prefers the playwright.cmd shim and runs npx/.cmd candidates with shell=True on Windows. shell=True is Windows-only (it would break the arg list on POSIX). Node detection itself (shutil.which("node") → invoked by absolute path) was already correct.

  7. Native file dialog on Windowssrc/ui/web-server.ts
    /api/browse-file had only osascript (mac) / zenity (Linux). Added a Windows branch using a PowerShell OpenFileDialog (base64 -EncodedCommand to avoid quoting issues, -STA for WinForms).

Verification

  • vitest run: 47/47 pass
  • tsc --noEmit: clean
  • python3 -m compileall backend: OK
  • Re-audit: no remaining unencoded text open() except the intentional os.devnull (subprocess fd, encoding irrelevant).

Not included (follow-ups)

  • ffmpeg concat backslash paths (video_cut.py:77, video_processor.py:1793): writes file '<abspath>' with backslashes on Windows. ffmpeg generally accepts these, so left as-is; normalizing to / would be a safe future hardening.
  • No setup.ps1 / podcli.cmd: a native Windows installer/launcher is a larger, separate piece. The MCP server still runs via node dist/index.js + npm scripts.

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@nmbrthirteen, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 10 minutes and 13 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, 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 include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7b1204a9-e829-41d4-8b11-90e55634b250

📥 Commits

Reviewing files that changed from the base of the PR and between ded1120 and a8ab102.

📒 Files selected for processing (22)
  • README.md
  • backend/cli.py
  • backend/presets.py
  • backend/services/asset_store.py
  • backend/services/claude_suggest.py
  • backend/services/clip_generator.py
  • backend/services/clips_history.py
  • backend/services/content_generator.py
  • backend/services/corrections.py
  • backend/services/encoder.py
  • backend/services/integrations/youtube/client.py
  • backend/services/integrations/youtube/learnings.py
  • backend/services/thumbnail_ai.py
  • backend/services/thumbnail_generator.py
  • backend/services/thumbnail_html.py
  • backend/services/transcript_packer.py
  • backend/services/video_cut.py
  • backend/services/video_processor.py
  • podcli.cmd
  • setup.ps1
  • src/ui/client/lib.ts
  • src/ui/web-server.ts
📝 Walkthrough

Walkthrough

This PR standardizes file I/O across the full stack to use explicit UTF-8 encoding, adds a cross-platform file/folder opening helper to replace platform-specific subprocess calls, and improves Windows compatibility by handling backslash path separators in TypeScript and supporting Windows Python venv and font paths.

Changes

Cross-platform file I/O and encoding

Layer / File(s) Summary
Cross-platform file/folder opening helper and CLI integration
backend/cli.py
Introduces _reveal_in_os(path: str) helper that uses platform-native commands (open on macOS, os.startfile on Windows, xdg-open elsewhere) to open files and folders, replacing four separate inline subprocess invocations during clip review, rerender preview, post-render preview, and output folder access.
UTF-8 encoding for CLI file operations
backend/cli.py
Standardizes all file reads and writes in the CLI layer to use explicit UTF-8 encoding: transcript loading, thumbnail config reading, content markdown writing, knowledge-base preview/read/write operations, UI state persistence, cache transcript reads, and .env access for HF_TOKEN and environment setup.
UTF-8 encoding standardization across backend services
backend/presets.py, backend/services/{asset_store,clip_generator,clips_history,content_generator,corrections,encoder,claude_suggest,transcript_packer,thumbnail_ai,thumbnail_html,video_cut,video_processor}.py, backend/services/integrations/youtube/{client,learnings}.py
Updates preset persistence, asset registry, clip generation, clips history, content generation, corrections, encoder cache, Claude suggestion, transcript packing, thumbnail configuration, video processing, and YouTube integration modules to open all JSON and markdown files with explicit encoding="utf-8" for deterministic behavior across platforms.
Windows platform support: venv paths, path parsing, and font resolution
src/config/paths.ts, src/ui/client/lib.ts, src/ui/web-server.ts, backend/services/thumbnail_generator.py
Adds platform-aware Python venv detection (Windows: venv/Scripts/python.exe, others: venv/bin/python3), updates TypeScript path utilities and prompt generation to split on both / and \ separators, adds UTF-8 encoding for thumbnail config reads, and extends font-file resolution in thumbnail generation to include Windows system fonts (C:/Windows/Fonts/{arial,arialbd}.ttf, .ttc files).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • nmbrthirteen/podcli#5: Both PRs update backend/services/clips_history.py's load_clips_history() and save_clips_history() functions (this PR adds UTF-8 encoding, while PR #5 extends clips-history deletion and persistence behavior).

Poem

🐰 Encoding all the files in UTF today,
Cross-platform paths now leading the way,
Windows fonts and venvs, a bunny's delight,
From bash to backslash, everything's right!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: Windows/Linux cross-platform compatibility' accurately summarizes the main objective of the PR, which is to fix cross-platform compatibility issues between Windows and Linux while preserving macOS behavior.
Docstring Coverage ✅ Passed Docstring coverage is 85.37% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/windows-linux-compat

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.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@backend/cli.py`:
- Around line 56-57: The except Exception: pass is silently swallowing
reveal/open failures; replace it with an except Exception as e that emits a
minimal warning to stderr (e.g., sys.stderr.write or logging.warning) including
a short context like "Failed to reveal/open path:" and the exception message so
users get feedback when the desktop integration or opener fails; update the
block where the code currently uses "except Exception: pass" (the reveal/open
error handler) to log the error instead of suppressing it.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e399e53d-0d39-47bc-a1f0-c6fbc6f7c74c

📥 Commits

Reviewing files that changed from the base of the PR and between 3cb1875 and ded1120.

📒 Files selected for processing (20)
  • backend/cli.py
  • backend/presets.py
  • backend/services/asset_store.py
  • backend/services/claude_suggest.py
  • backend/services/clip_generator.py
  • backend/services/clips_history.py
  • backend/services/content_generator.py
  • backend/services/corrections.py
  • backend/services/encoder.py
  • backend/services/integrations/youtube/client.py
  • backend/services/integrations/youtube/learnings.py
  • backend/services/thumbnail_ai.py
  • backend/services/thumbnail_generator.py
  • backend/services/thumbnail_html.py
  • backend/services/transcript_packer.py
  • backend/services/video_cut.py
  • backend/services/video_processor.py
  • src/config/paths.ts
  • src/ui/client/lib.ts
  • src/ui/web-server.ts

Comment thread backend/cli.py Outdated
- detectPython: use venv\Scripts\python.exe + `python` on Windows
- add encoding="utf-8" to 40 text-mode open() calls (cp1252 crashes/corruption)
- thumbnail fonts: add Windows Arial fallbacks
- reveal-in-folder: cross-platform _reveal_in_os() helper (os.startfile on Windows)
- UI basename: split on both / and \ separators
- cli.py webui menu: shell=True on Windows so npm.cmd runs
- thumbnail_html: prefer playwright.cmd shim, shell=True on Windows for npx/.cmd
- web-server browse-file: add Windows PowerShell OpenFileDialog branch
- setup.ps1 mirrors setup.sh: deps check, dirs, face model, venv,
  pip/npm install, tsc build, .env PYTHON_PATH wiring, MCP config
- podcli.cmd: venv-python detection, PodStack-command notice, cli.py passthrough
- README: Windows Quick Start section
- cli.py: log reveal/open failures to stderr instead of swallowing them
@nmbrthirteen nmbrthirteen force-pushed the fix/windows-linux-compat branch from 249bae0 to a8ab102 Compare June 10, 2026 08:37
@nmbrthirteen nmbrthirteen merged commit f02fb07 into main Jun 10, 2026
5 checks passed
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