Skip to content

[Bug]: Diff panel renders GBK / GB18030 / GB2312 files as mojibake (hardcoded UTF-8 decoding) #42723

Done

Description

@ethan-blue

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. Initialize a Git repository containing a source file encoded in GBK / GB18030 / GB2312 (common in legacy C/C++ embedded projects and Windows codebases) without .gitattributes working-tree-encoding:
    git init gbk-repro && cd gbk-repro
    python -c 'open("main.c", "wb").write("// 初始中文注释\nint a = 1;\n".encode("gbk"))'
    git add main.c && git commit -m "init"
    python -c 'open("main.c", "wb").write("// 修改后的中文注释\nint a = 2;\n".encode("gbk"))'
  2. Open this repository as a project in T3 Code.
  3. Open the Review / Diff panel for the working tree changes (and optionally expand unchanged context lines or inspect a commit diff).

Expected behavior

Chinese / non-ASCII text in GBK / GB18030 / GB2312 files should be readable in the Diff panel (e.g., via fallback decoding such as gb18030 when UTF-8 decoding produces U+FFFD replacement characters, or a per-file/panel encoding selector).

Note: Adding working-tree-encoding=GBK in .gitattributes is often not viable on existing GBK repositories because it changes how Git stores blobs on future commits rather than just how diffs are decoded for display.

Actual behavior

All non-ASCII GBK characters render as replacement characters (\uFFFD / mojibake) in both the diff hunks and expanded unchanged context.

Looking at apps/server/src/vcs/GitVcsDriverCore.ts on main:

  • collectOutput (line 943, used by executeGit for git diff --patch and git show in getReviewDiffPreview / readReviewFileAtRevision) hardcodes new TextDecoder("utf-8", { ignoreBOM: true }).
  • readWorkingTreeReviewFile (line 5187, used when expanding unchanged working-tree context) also hardcodes new TextDecoder("utf-8", { ignoreBOM: true }).

Impact

Major degradation or frequent failure

Version or commit

0.1.11 (also verified on main: apps/server/src/vcs/GitVcsDriverCore.ts)

Environment

Windows 11, T3 Code Desktop 0.1.11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions