Skip to content

fix: Chinese path support (issue #3), #4

Merged
Poorgramer-Zack merged 7 commits intomainfrom
fix/chinese-path-support
Jan 6, 2026
Merged

fix: Chinese path support (issue #3), #4
Poorgramer-Zack merged 7 commits intomainfrom
fix/chinese-path-support

Conversation

@Poorgramer-Zack
Copy link
Owner

@Poorgramer-Zack Poorgramer-Zack commented Jan 6, 2026

[PR] Windows PTY Encoding Fix, Shell Selection Enhancements, and Update Cleanup Overhaul

Description

This PR addresses several core issues related to terminal compatibility on Windows, platform-specific shell management, and the reliability of the application's update and cleanup mechanism.

1. 🪟 Windows PTY Encoding Fix (Fixes #3)

  • Issue: Pseudo-terminals (PTY) failed to launch on Windows when the executable or working directory paths contained non-ASCII characters (e.g., Chinese characters).
  • Solution: Refactored the native C code in flutter_pty_win.c to use the Windows MultiByteToWideChar API. Strings are now correctly converted from UTF-8 to Wide Character (UTF-16) before being passed to Windows system calls.
  • Result: Fixed the "Failed to create process" error for users with non-English usernames or file paths.

2. 🐚 Shell Selection & Reliability

  • Platform Filtering: Added zsh and bash support. Implemented isAvailableOnCurrentPlatform to hide Windows-only shells (like PowerShell/CMD/WSL) on macOS/Linux and vice-versa.
  • Runtime Fallback: Implemented a robust fallback mechanism in TerminalBloc and ShellType. On Windows, the app now dynamically checks for the existence of pwsh, falling back to powershell and finally cmd if necessary.
  • Logic Refactor: Refactored getBinaryUrl to use specialized switch (Platform.operatingSystem) statements for cleaner cross-platform asset resolution.

3. 📦 Update Mechanism & MSIX Removal

  • MSIX Removal: Due to persistent certificate trust issues (0x800B010A), the MSIX packaging and deployment steps have been completely removed from the project pubspec.yaml, GitHub workflows, and codebase).
  • Windows Strategy: The application now strictly uses standard -setup.exe installers for Windows updates.
  • Cleanup Overhaul:
    • Moved download location to the system Temp directory instead of the user's Downloads folder.
    • Pattern-based Cleanup: Replaced single-session file tracking with a "Scan-on-Startup" strategy. The app now scans the temp directory for any leftover flutter_agent_panel-* installer residues on startup and after update checks, ensuring a clean user environment even after restarts.

4. 🛠️ Miscellaneous

  • Updated pubspec.yaml versioning and resolved duplicate dependency declarations.
  • Cleaned up release.yml workflow to streamline the build process for Windows, macOS, and Linux.

Technical Details

  • Native: Modified packages/flutter_pty/src/flutter_pty_win.c.
  • Bloc: Updated TerminalBloc for runtime shell validation.
  • Service: Overhauled AppVersionService for asset selection.
  • UI: Updated UpdateSettingsContent with enhanced cleanup logic.

Verification

  • Verified Chinese path support on Windows.
  • Verified shell list filtering on Windows and macOS.
  • Verified that .exe installers are correctly identified and leftover files are cleaned from %TEMP%.
  • Ran flutter analyze - No errors found.

…rsion on Windows

- Fix PTY creation failure when executable path or working directory contains Chinese characters.
- Replace incorrect byte-by-byte WCHAR casting with proper MultiByteToWideChar API.
- Ensure command line, environment block, and working directory are correctly encoded for CreateProcessW.
- Fixes #3
- Shells:
  - Added zsh and bash support with platform-specific filtering (hiding Windows-only shells on macOS/Linux).
  - Implemented runtime fallback logic for Windows (pwsh7 > powershell > cmd) to ensure the terminal starts even if the preferred shell is missing.
- Update Mechanism:
  - Migrated downloads to the system temp directory.
  - Implemented a "Scan-on-Startup" cleanup strategy that automatically removes leftover installers based on filename patterns, ensuring a clean user environment even after app restarts.
- Removed MSIX support from dependencies, GitHub Actions workflows, and codebase due to certificate trust issues.
@Poorgramer-Zack Poorgramer-Zack self-assigned this Jan 6, 2026
Copilot AI review requested due to automatic review settings January 6, 2026 02:28
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses critical Windows PTY encoding issues for non-ASCII paths, enhances cross-platform shell selection, and overhauls the update mechanism by removing MSIX packaging in favor of standard installers.

Key Changes:

  • Implemented UTF-8 to UTF-16 conversion in native Windows PTY code to support Chinese and other non-ASCII characters in paths
  • Added zsh and bash shell support with platform-specific filtering and Windows shell fallback logic (pwsh → powershell → cmd)
  • Replaced MSIX packaging with standard installers and moved downloads to temp directory with pattern-based cleanup on startup

Reviewed changes

Copilot reviewed 18 out of 19 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
pubspec.yaml Bumped version to 0.0.7+1 and removed MSIX dependency
pubspec.lock Removed transitive dependencies for MSIX package (console, get_it)
packages/flutter_pty/src/flutter_pty_win.c Added utf8_to_wide conversion function and refactored command/environment/working_directory builders to properly handle UTF-8 strings
lib/shared/utils/settings_helpers.dart Added localized name mappings for zsh and bash shells
lib/features/workspace/widgets/shell_selection_popover.dart Removed dart:io import, updated shell filtering to use isAvailableOnCurrentPlatform
lib/features/terminal/bloc/terminal_bloc.dart Updated imports and shell resolution to use ShellType.platformDefault and resolveWindowsCommand
lib/features/settings/widgets/update_settings_content.dart Added cleanup mechanism for leftover installers in temp directory, moved download location from Downloads to temp
lib/features/settings/models/shell_type.dart Added zsh/bash shells, implemented platform availability checks, added Windows shell fallback logic
lib/features/settings/models/app_settings.dart Changed defaultShell to use platform-specific defaults
lib/features/settings/bloc/settings_state.dart Updated constructor to support nullable AppSettings
lib/features/settings/bloc/settings_bloc.dart Removed const modifier for AppSettings initialization
lib/core/services/app_version_service.dart Added caching of release JSON and asset-based URL resolution with platform-specific switch statement
lib/core/l10n/app_localizations*.dart Added zsh and bash localization strings
assets/l10n/app_*.arb Added zsh and bash translation entries
.github/workflows/release.yml Removed MSIX build and upload steps, simplified release table

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Poorgramer-Zack Poorgramer-Zack merged commit 5e1d7fc into main Jan 6, 2026
5 checks passed
@Poorgramer-Zack Poorgramer-Zack deleted the fix/chinese-path-support branch January 6, 2026 03:03
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.

Can't open terminal with chinese path

2 participants