Icons/Unicode characters cause file editing failures #1911

Open
opened 2026-02-16 17:33:12 -05:00 by yindo · 3 comments
Owner

Originally created by @av1155 on GitHub (Oct 1, 2025).

Originally assigned to: @thdxr on GitHub.

Description

OpenCode fails to properly handle Unicode icons and special characters when editing files, even when directly copying and pasting the exact text. This makes it impossible to work with configuration files that contain icons, which are common in modern development setups (like Neovim configs with icon decorations).

Steps to Reproduce

  1. Have a file containing Unicode icons (e.g., Neovim config with Which-Key icons)
  2. Ask OpenCode to edit a section containing these icons
  3. OpenCode attempts to edit but fails with various errors
  4. OR - OpenCode succeeds, but the icons are not there, just blank strings.

Expected Behavior

OpenCode should be able to:

  • Correctly identify and match text containing Unicode characters
  • Edit files with multi-byte characters without issues
  • Preserve Unicode icons when making edits

Actual Behavior

Multiple failure modes occur:

  1. Invalid arguments for edit_file - undefined newText when icons are present
  2. Could not find exact match for edit - cannot match text containing Unicode characters
  3. Even when trying to copy/paste exact text with icons, the matching fails

Error Examples

Error: Invalid arguments for edit_file: [
  {
    "code": "invalid_type",
    "expected": "string",
    "received": "undefined",
    "path": ["edits", 0, "newText"]
  }
]
Error: Could not find exact match for edit:
{ "<leader>ou", group = "Utility", icon = { icon = " ", color = "cyan" } },

Environment

  • File type: Lua configuration file (Neovim plugin config)
  • Unicode characters present: Various icons (, , 󰈆, , etc.)
  • The file contains valid UTF-8 encoded text

Impact

This issue prevents OpenCode from being used with:

  • Modern Neovim configurations that use icon fonts
  • Any configuration files with Unicode decorations
  • Projects that use emoji or special characters in their codebase

Workaround Attempts

The AI tried multiple approaches that all failed:

  1. Direct editing with the icons
  2. Escaping special characters
  3. Reading the file to get exact formatting
  4. Using bash commands to inspect the file encoding
  5. Eventually had to rewrite the entire file instead of editing

Suggested Fix

OpenCode's file editing functionality needs to:

  1. Properly handle UTF-8 encoded text with multi-byte characters
  2. Use byte-aware string matching rather than character-based matching
  3. Preserve Unicode characters during edit operations
  4. Consider implementing a more robust text matching algorithm that handles Unicode normalization

Additional Context

This is a critical issue for developers using modern development environments where Unicode icons and emoji are commonly used for visual enhancement in configuration files, documentation, and even in code comments.


Example from session (the end result has the icon = " " as empty strings):

I'll add keymaps for the new commands from the commit. Based on the commit, the new features are:

1. /compact - Compact/summarize session
2. /share - Share session and get a link
3. /unshare - Unshare session
4. /undo - Undo last action
5. /redo - Redo last action

Let me add these to the opencode-nvim.lua configuration:
Build claude-sonnet-4-5-20250929 (05:51 PM)

Filesystem_edit_file [map[newString:                    { "<leader>ou", group = "Utility", icon = { icon = " ", color = "cyan" } },
                  ...

Error: Invalid arguments for edit_file: [
  {
    "code": "invalid_type",
    "expected": "string",
    "received": "undefined",
    "path": [
      "edits",
      0,
      "newText"
    ],

Let me fix the escape sequence issue:
Build claude-sonnet-4-5-20250929 (05:51 PM)

Filesystem_edit_file [map[newText:                    { "<leader>ou", group = "Utility", icon = { icon = " ", color = "cyan" } },
                    ...

Error: Could not find exact match for edit:
                    { "<leader>ou", group = "Utility", icon = { icon = " ", color = "cyan" } },
                    { "<leader>oui", "<cmd>OpencodeInit<cr>", desc = "Initialize AGENTS.md", icon = { icon = " ", color = "cyan" } },
                    { "<leader>oum", function() require("opencode.api").mcp() end, desc = "List MCP servers", icon = { icon = " ", color = "green" } },
                    { "<leader>ouc", function() require("opencode.api").run_user_command() end, desc = "Run user command", icon = { icon = " ", color =
"orange" } },
                    { "<leader>ous", function() require("opencode.api").stop() end, desc = "Stop execution", icon = { icon = "󰈆 ", color = "red" } },

Let me read the file again to get the exact formatting:
Build claude-sonnet-4-5-20250929 (05:51 PM)

Read lua/plugins/opencode-nvim.lua (limit=15, offset=80)


                    { "<leader>ou", group = "Utility", icon = { icon = " ", color = "cyan" } },
                    { "<leader>oui", "<cmd>OpencodeInit<cr>", desc = "Initialize AGENTS.md", icon = { icon = " ", color = "cyan" } },
                    { "<leader>oum", function() require("opencode.api").mcp() end, desc = "List MCP servers", icon = { icon = " ", color = "green" } },
                    { "<leader>ouc", function() require("opencode.api").run_user_command() end, desc = "Run user command", icon = { icon = " ", color =
"orange" } },
                    { "<leader>ous", function() require("opencode.api").stop() end, desc = "Stop execution", icon = { icon = "󰈆 ", color = "red" } },

Edit lua/plugins/opencode-nvim.lua

Error: oldString not found in content

Let me use bash to check the exact content:
Build claude-sonnet-4-5-20250929 (05:52 PM)

Shell Check exact characters in lines 82-86

$ sed -n '82,86p' lua/plugins/opencode-nvim.lua | cat -A
cat: illegal option -- A
usage: cat [-belnstuv] [file ...]

Shell Check exact characters with octal dump

$ sed -n '82,86p' lua/plugins/opencode-nvim.lua | od -c | head -20
0000000
0000020                    {       "   <   l   e   a   d   e   r   >   o
0000040    u   "   ,       g   r   o   u   p       =       "   U   t   i
0000060    l   i   t   y   "   ,       i   c   o   n       =       {
0000100    i   c   o   n       =       "     **  **       "   ,       c
0000120    o   l   o   r       =       "   c   y   a   n   "       }
0000140    }   ,  \n
0000160                                {       "   <   l   e   a   d   e
0000200    r   >   o   u   i   "   ,       "   <   c   m   d   >   O   p
0000220    e   n   c   o   d   e   I   n   i   t   <   c   r   >   "   ,
0000240        d   e   s   c       =       "   I   n   i   t   i   a   l
0000260    i   z   e       A   G   E   N   T   S   .   m   d   "   ,
0000300    i   c   o   n       =       {       i   c   o   n       =
0000320    "     **  **       "   ,       c   o   l   o   r       =
0000340    "   c   y   a   n   "       }       }   ,  \n
0000360
0000400    {       "   <   l   e   a   d   e   r   >   o   u   m   "   ,
0000420        f   u   n   c   t   i   o   n   (   )       r   e   q   u
0000440    i   r   e   (   "   o   p   e   n   c   o   d   e   .   a   p
0000460    i   "   )   .   m   c   p   (   )       e   n   d   ,       d

I see the icons are multi-byte characters. Let me use write to add the new keymaps:
Build claude-sonnet-4-5-20250929 (05:52 PM)

Read lua/plugins/opencode-nvim.lua

-- if true then
--     return {}
-- end

return {
    {

Write lua/plugins/opencode-nvim.lua

-- if true then
--     return {}
-- end

return {
    {
        "sudo-tee/opencode.nvim",
        dependencies = {
            "nvim-lua/plenary.nvim",
            "folke/snacks.nvim",
            "saghen/blink.cmp",
            {
                "MeanderingProgrammer/render-markdown.nvim",
                opts = {
                    anti_conceal = { enabled = false },
                    file_types = { "markdown", "opencode_output" },
                },
                ft = { "markdown", "Avante", "copilot-chat", "opencode_output" },
            },
        },
        config = function()
            require("opencode").setup({
                preferred_picker = "snacks",
                preferred_completion = "blink",
                default_global_keymaps = false,
                keymap = {
                    window = {
                        close = "q", -- Close UI windows
                        stop = "<esc>", -- Stop opencode while it is running
                        select_child_session = "<leader>osS",
                    },
                },
                ui = {
                    icons = {
                        preset = "emoji",
                    },
                    output = {
                        tools = {
                            show_output = true,
                        },
                    },
                },
            })

            local ok, wk = pcall(require, "which-key")
            if ok then
                -- stylua: ignore
                wk.add({
                    { "<leader>o", group = "opencode", mode = {"n", "v"}, icon = { icon = " ", color = "orange" } },

                    { "<leader>oo", "<cmd>Opencode<cr>", desc = "Toggle", icon = { icon = " ", color = "orange" }, mode = { "n", "v" } },
                    { "<leader>oi", function() require("opencode.api").open_input() end, desc = "Open input", icon = { icon = " ", color = "cyan" },
mode = { "n", "v" } },
                    { "<leader>oI", function() require("opencode.api").open_input_new_session() end, desc = "Open input (new session)", icon = { icon =
"󰐕 ", color = "cyan" }, mode = { "n", "v" } },
                    { "<leader>og", function() require("opencode.api").open_output() end, desc = "Open output", icon = { icon = "󰈔", color = "cyan" } },
                    { "<leader>ot", function() require("opencode.api").toggle_focus() end, desc = "Toggle focus", icon = { icon = " ", color = "blue" }
},
                    { "<leader>oq", function() require("opencode.api").close() end, desc = "Close", icon = { icon = "󰈆 ", color = "red" } },
                    { "<leader>ox", function() require("opencode.api").swap_position() end, desc = "Swap position", icon = { icon = " ", color = "blue"
} },

                    { "<leader>os", group = "Session", icon = { icon = " ", color = "azure" } },
                    { "<leader>oss", function() require("opencode.api").select_session() end, desc = "Select session", icon = { icon = " ", color =
"azure" } },
                    { "<leader>osS", function() require("opencode.api").select_child_session() end, desc = "Select child session", icon = { icon = " ",
color = "azure" } },

                    { "<leader>om", group = "Mode", icon = { icon = " ", color = "purple" } },
                    { "<leader>omb", function() require("opencode.api").agent_build() end, desc = "Build mode", icon = { icon = " ", color = "orange" }
},
                    { "<leader>omp", function() require("opencode.api").agent_plan() end, desc = "Plan mode", icon = { icon = "󱅻 ", color = "cyan" } },
                    { "<leader>oms", function() require("opencode.api").select_agent() end, desc = "Select agent", icon = { icon = " ", color = "purple"
} },

                    { "<leader>op", function() require("opencode.api").configure_provider() end, desc = "Configure provider", icon = { icon = " ", color
= "green" } },

                    { "<leader>od", group = "Diff", icon = { icon = " ", color = "blue" } },
                    { "<leader>odo", function() require("opencode.api").diff_open() end, desc = "Open diff", icon = { icon = " ", color = "blue" } },
                    { "<leader>odn", function() require("opencode.api").diff_next() end, desc = "Next file", icon = { icon = " ", color = "blue" } },
                    { "<leader>odp", function() require("opencode.api").diff_prev() end, desc = "Prev file", icon = { icon = " ", color = "blue" } },
                    { "<leader>odc", function() require("opencode.api").diff_close() end, desc = "Close diff", icon = { icon = "󰈆 ", color = "red" } },

                    { "<leader>or", group = "Revert", icon = { icon = " ", color = "red" } },
                    { "<leader>ora", function() require("opencode.api").diff_revert_all_last_prompt() end, desc = "All (last prompt)", icon = { icon = "
", color = "red" } },
                    { "<leader>ort", function() require("opencode.api").diff_revert_this_last_prompt() end, desc = "This file (last prompt)", icon = {
icon = " ", color = "red" } },
                    { "<leader>orA", function() require("opencode.api").diff_revert_all_session() end, desc = "All (session)", icon = { icon = " ",
color = "red" } },
                    { "<leader>orT", function() require("opencode.api").diff_revert_this_session() end, desc = "This file (session)", icon = { icon = "
", color = "red" } },

                    { "<leader>ou", group = "Utility", icon = { icon = " ", color = "cyan" } },
                    { "<leader>oui", "<cmd>OpencodeInit<cr>", desc = "Initialize AGENTS.md", icon = { icon = " ", color = "cyan" } },
                    { "<leader>oum", function() require("opencode.api").mcp() end, desc = "List MCP servers", icon = { icon = " ", color = "green" } },
                    { "<leader>ouc", function() require("opencode.api").run_user_command() end, desc = "Run user command", icon = { icon = " ", color =
"orange" } },
                    { "<leader>ous", function() require("opencode.api").stop() end, desc = "Stop execution", icon = { icon = "󰈆 ", color = "red" } },
                    { "<leader>ouu", function() require("opencode.api").undo() end, desc = "Undo last action", icon = { icon = " ", color = "yellow" } },
                    { "<leader>our", function() require("opencode.api").redo() end, desc = "Redo last action", icon = { icon = " ", color = "yellow" } },
                    { "<leader>ouk", function() require("opencode.api").compact_session() end, desc = "Compact session", icon = { icon = " ", color =
"blue" } },
                    { "<leader>oul", function() require("opencode.api").share() end, desc = "Share session", icon = { icon = " ", color = "green" } },
                    { "<leader>ouL", function() require("opencode.api").unshare() end, desc = "Unshare session", icon = { icon = " ", color = "red" } },

                })
            end
        end,
    },
}

Originally created by @av1155 on GitHub (Oct 1, 2025). Originally assigned to: @thdxr on GitHub. ### Description OpenCode fails to properly handle Unicode icons and special characters when editing files, even when directly copying and pasting the exact text. This makes it impossible to work with configuration files that contain icons, which are common in modern development setups (like Neovim configs with icon decorations). ### Steps to Reproduce 1. Have a file containing Unicode icons (e.g., Neovim config with Which-Key icons) 2. Ask OpenCode to edit a section containing these icons 3. OpenCode attempts to edit but fails with various errors 4. OR - OpenCode succeeds, but the icons are not there, just blank strings. ### Expected Behavior OpenCode should be able to: - Correctly identify and match text containing Unicode characters - Edit files with multi-byte characters without issues - Preserve Unicode icons when making edits ### Actual Behavior Multiple failure modes occur: 1. `Invalid arguments for edit_file` - undefined newText when icons are present 2. `Could not find exact match for edit` - cannot match text containing Unicode characters 3. Even when trying to copy/paste exact text with icons, the matching fails ### Error Examples ``` Error: Invalid arguments for edit_file: [ { "code": "invalid_type", "expected": "string", "received": "undefined", "path": ["edits", 0, "newText"] } ] ``` ``` Error: Could not find exact match for edit: { "<leader>ou", group = "Utility", icon = { icon = " ", color = "cyan" } }, ``` ### Environment - File type: Lua configuration file (Neovim plugin config) - Unicode characters present: Various icons (, , 󰈆, , etc.) - The file contains valid UTF-8 encoded text ### Impact This issue prevents OpenCode from being used with: - Modern Neovim configurations that use icon fonts - Any configuration files with Unicode decorations - Projects that use emoji or special characters in their codebase ### Workaround Attempts The AI tried multiple approaches that all failed: 1. Direct editing with the icons 2. Escaping special characters 3. Reading the file to get exact formatting 4. Using bash commands to inspect the file encoding 5. Eventually had to rewrite the entire file instead of editing ### Suggested Fix OpenCode's file editing functionality needs to: 1. Properly handle UTF-8 encoded text with multi-byte characters 2. Use byte-aware string matching rather than character-based matching 3. Preserve Unicode characters during edit operations 4. Consider implementing a more robust text matching algorithm that handles Unicode normalization ### Additional Context This is a critical issue for developers using modern development environments where Unicode icons and emoji are commonly used for visual enhancement in configuration files, documentation, and even in code comments. --- ### Example from session (the end result has the `icon = " "` as empty strings): ```` I'll add keymaps for the new commands from the commit. Based on the commit, the new features are: 1. /compact - Compact/summarize session 2. /share - Share session and get a link 3. /unshare - Unshare session 4. /undo - Undo last action 5. /redo - Redo last action Let me add these to the opencode-nvim.lua configuration: Build claude-sonnet-4-5-20250929 (05:51 PM) Filesystem_edit_file [map[newString: { "<leader>ou", group = "Utility", icon = { icon = " ", color = "cyan" } }, ... Error: Invalid arguments for edit_file: [ { "code": "invalid_type", "expected": "string", "received": "undefined", "path": [ "edits", 0, "newText" ], Let me fix the escape sequence issue: Build claude-sonnet-4-5-20250929 (05:51 PM) Filesystem_edit_file [map[newText: { "<leader>ou", group = "Utility", icon = { icon = " ", color = "cyan" } }, ... Error: Could not find exact match for edit: { "<leader>ou", group = "Utility", icon = { icon = " ", color = "cyan" } }, { "<leader>oui", "<cmd>OpencodeInit<cr>", desc = "Initialize AGENTS.md", icon = { icon = " ", color = "cyan" } }, { "<leader>oum", function() require("opencode.api").mcp() end, desc = "List MCP servers", icon = { icon = " ", color = "green" } }, { "<leader>ouc", function() require("opencode.api").run_user_command() end, desc = "Run user command", icon = { icon = " ", color = "orange" } }, { "<leader>ous", function() require("opencode.api").stop() end, desc = "Stop execution", icon = { icon = "󰈆 ", color = "red" } }, Let me read the file again to get the exact formatting: Build claude-sonnet-4-5-20250929 (05:51 PM) Read lua/plugins/opencode-nvim.lua (limit=15, offset=80) { "<leader>ou", group = "Utility", icon = { icon = " ", color = "cyan" } }, { "<leader>oui", "<cmd>OpencodeInit<cr>", desc = "Initialize AGENTS.md", icon = { icon = " ", color = "cyan" } }, { "<leader>oum", function() require("opencode.api").mcp() end, desc = "List MCP servers", icon = { icon = " ", color = "green" } }, { "<leader>ouc", function() require("opencode.api").run_user_command() end, desc = "Run user command", icon = { icon = " ", color = "orange" } }, { "<leader>ous", function() require("opencode.api").stop() end, desc = "Stop execution", icon = { icon = "󰈆 ", color = "red" } }, Edit lua/plugins/opencode-nvim.lua Error: oldString not found in content Let me use bash to check the exact content: Build claude-sonnet-4-5-20250929 (05:52 PM) Shell Check exact characters in lines 82-86 $ sed -n '82,86p' lua/plugins/opencode-nvim.lua | cat -A cat: illegal option -- A usage: cat [-belnstuv] [file ...] Shell Check exact characters with octal dump $ sed -n '82,86p' lua/plugins/opencode-nvim.lua | od -c | head -20 0000000 0000020 { " < l e a d e r > o 0000040 u " , g r o u p = " U t i 0000060 l i t y " , i c o n = { 0000100 i c o n = "  ** ** " , c 0000120 o l o r = " c y a n " } 0000140 } , \n 0000160 { " < l e a d e 0000200 r > o u i " , " < c m d > O p 0000220 e n c o d e I n i t < c r > " , 0000240 d e s c = " I n i t i a l 0000260 i z e A G E N T S . m d " , 0000300 i c o n = { i c o n = 0000320 "  ** ** " , c o l o r = 0000340 " c y a n " } } , \n 0000360 0000400 { " < l e a d e r > o u m " , 0000420 f u n c t i o n ( ) r e q u 0000440 i r e ( " o p e n c o d e . a p 0000460 i " ) . m c p ( ) e n d , d I see the icons are multi-byte characters. Let me use write to add the new keymaps: Build claude-sonnet-4-5-20250929 (05:52 PM) Read lua/plugins/opencode-nvim.lua -- if true then -- return {} -- end return { { Write lua/plugins/opencode-nvim.lua -- if true then -- return {} -- end return { { "sudo-tee/opencode.nvim", dependencies = { "nvim-lua/plenary.nvim", "folke/snacks.nvim", "saghen/blink.cmp", { "MeanderingProgrammer/render-markdown.nvim", opts = { anti_conceal = { enabled = false }, file_types = { "markdown", "opencode_output" }, }, ft = { "markdown", "Avante", "copilot-chat", "opencode_output" }, }, }, config = function() require("opencode").setup({ preferred_picker = "snacks", preferred_completion = "blink", default_global_keymaps = false, keymap = { window = { close = "q", -- Close UI windows stop = "<esc>", -- Stop opencode while it is running select_child_session = "<leader>osS", }, }, ui = { icons = { preset = "emoji", }, output = { tools = { show_output = true, }, }, }, }) local ok, wk = pcall(require, "which-key") if ok then -- stylua: ignore wk.add({ { "<leader>o", group = "opencode", mode = {"n", "v"}, icon = { icon = " ", color = "orange" } }, { "<leader>oo", "<cmd>Opencode<cr>", desc = "Toggle", icon = { icon = " ", color = "orange" }, mode = { "n", "v" } }, { "<leader>oi", function() require("opencode.api").open_input() end, desc = "Open input", icon = { icon = " ", color = "cyan" }, mode = { "n", "v" } }, { "<leader>oI", function() require("opencode.api").open_input_new_session() end, desc = "Open input (new session)", icon = { icon = "󰐕 ", color = "cyan" }, mode = { "n", "v" } }, { "<leader>og", function() require("opencode.api").open_output() end, desc = "Open output", icon = { icon = "󰈔", color = "cyan" } }, { "<leader>ot", function() require("opencode.api").toggle_focus() end, desc = "Toggle focus", icon = { icon = " ", color = "blue" } }, { "<leader>oq", function() require("opencode.api").close() end, desc = "Close", icon = { icon = "󰈆 ", color = "red" } }, { "<leader>ox", function() require("opencode.api").swap_position() end, desc = "Swap position", icon = { icon = " ", color = "blue" } }, { "<leader>os", group = "Session", icon = { icon = " ", color = "azure" } }, { "<leader>oss", function() require("opencode.api").select_session() end, desc = "Select session", icon = { icon = " ", color = "azure" } }, { "<leader>osS", function() require("opencode.api").select_child_session() end, desc = "Select child session", icon = { icon = " ", color = "azure" } }, { "<leader>om", group = "Mode", icon = { icon = " ", color = "purple" } }, { "<leader>omb", function() require("opencode.api").agent_build() end, desc = "Build mode", icon = { icon = " ", color = "orange" } }, { "<leader>omp", function() require("opencode.api").agent_plan() end, desc = "Plan mode", icon = { icon = "󱅻 ", color = "cyan" } }, { "<leader>oms", function() require("opencode.api").select_agent() end, desc = "Select agent", icon = { icon = " ", color = "purple" } }, { "<leader>op", function() require("opencode.api").configure_provider() end, desc = "Configure provider", icon = { icon = " ", color = "green" } }, { "<leader>od", group = "Diff", icon = { icon = " ", color = "blue" } }, { "<leader>odo", function() require("opencode.api").diff_open() end, desc = "Open diff", icon = { icon = " ", color = "blue" } }, { "<leader>odn", function() require("opencode.api").diff_next() end, desc = "Next file", icon = { icon = " ", color = "blue" } }, { "<leader>odp", function() require("opencode.api").diff_prev() end, desc = "Prev file", icon = { icon = " ", color = "blue" } }, { "<leader>odc", function() require("opencode.api").diff_close() end, desc = "Close diff", icon = { icon = "󰈆 ", color = "red" } }, { "<leader>or", group = "Revert", icon = { icon = " ", color = "red" } }, { "<leader>ora", function() require("opencode.api").diff_revert_all_last_prompt() end, desc = "All (last prompt)", icon = { icon = " ", color = "red" } }, { "<leader>ort", function() require("opencode.api").diff_revert_this_last_prompt() end, desc = "This file (last prompt)", icon = { icon = " ", color = "red" } }, { "<leader>orA", function() require("opencode.api").diff_revert_all_session() end, desc = "All (session)", icon = { icon = " ", color = "red" } }, { "<leader>orT", function() require("opencode.api").diff_revert_this_session() end, desc = "This file (session)", icon = { icon = " ", color = "red" } }, { "<leader>ou", group = "Utility", icon = { icon = " ", color = "cyan" } }, { "<leader>oui", "<cmd>OpencodeInit<cr>", desc = "Initialize AGENTS.md", icon = { icon = " ", color = "cyan" } }, { "<leader>oum", function() require("opencode.api").mcp() end, desc = "List MCP servers", icon = { icon = " ", color = "green" } }, { "<leader>ouc", function() require("opencode.api").run_user_command() end, desc = "Run user command", icon = { icon = " ", color = "orange" } }, { "<leader>ous", function() require("opencode.api").stop() end, desc = "Stop execution", icon = { icon = "󰈆 ", color = "red" } }, { "<leader>ouu", function() require("opencode.api").undo() end, desc = "Undo last action", icon = { icon = " ", color = "yellow" } }, { "<leader>our", function() require("opencode.api").redo() end, desc = "Redo last action", icon = { icon = " ", color = "yellow" } }, { "<leader>ouk", function() require("opencode.api").compact_session() end, desc = "Compact session", icon = { icon = " ", color = "blue" } }, { "<leader>oul", function() require("opencode.api").share() end, desc = "Share session", icon = { icon = " ", color = "green" } }, { "<leader>ouL", function() require("opencode.api").unshare() end, desc = "Unshare session", icon = { icon = " ", color = "red" } }, }) end end, }, } ````
Author
Owner

@github-actions[bot] commented on GitHub (Oct 1, 2025):

This issue might be a duplicate of existing issues. Please check:

  • #36: Specifically addresses handling multibyte/Unicode characters in file operations
  • #10: Deals with multi-byte emoji handling which could cause similar edit failures
  • #1575: Reports that emoji support does not work, which aligns with the icon editing failures described
  • #4137: Directly mentions Unicode character issues in UTF-8 text content

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Oct 1, 2025): This issue might be a duplicate of existing issues. Please check: - #36: Specifically addresses handling multibyte/Unicode characters in file operations - #10: Deals with multi-byte emoji handling which could cause similar edit failures - #1575: Reports that emoji support does not work, which aligns with the icon editing failures described - #4137: Directly mentions Unicode character issues in UTF-8 text content Feel free to ignore if none of these address your specific case.
Author
Owner

@acramsay commented on GitHub (Jan 27, 2026):

Any progress on this issue? It's been causing me trouble for weeks now

@acramsay commented on GitHub (Jan 27, 2026): Any progress on this issue? It's been causing me trouble for weeks now
Author
Owner

@zrpxx commented on GitHub (Feb 12, 2026):

I encountered a very similar issue regarding character encoding (garbled text in .tex files containing Chinese characters) in a Windows PowerShell environment. It seems highly likely that this issue shares the same root cause described in other Bun-based applications on Windows: The mismatch between the runtime's default UTF-8 output stream and the Windows Console's active code page (usually CP936 or CP437).

When opencode communicates via standard I/O (stdio), if the terminal encoding is not explicitly set to UTF-8, can be misinterpreted or split during the stream transmission. This causes two failures:

  • JSON Corruption: The JSON payload containing the newText might be malformed upon receipt, leading to the received: "undefined" error.

  • Matching Failure: Even if the JSON is parsed, the byte sequence of the icon in memory differs from what is read from the disk, causing the "Could not find exact match" error because the diff/patch algorithm requires strict string equality.

For Windows/PowerShell users:

Before starting the agent or editor, force the PowerShell session to use UTF-8 for both input and output streams. You can add this to your PowerShell $PROFILE or run it in the terminal before starting opencode:

[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
$OutputEncoding = [System.Text.Encoding]::UTF8

This ensures that the pipe between the tool and the interface correctly handles the multi-byte Unicode characters.

For the Maintainers:

It might be beneficial to explicitly set the stdio encoding to UTF-8 within the application entry point to ensure consistency across different OS locales, preventing the application from inheriting the legacy Windows code page.

@zrpxx commented on GitHub (Feb 12, 2026): I encountered a very similar issue regarding character encoding (garbled text in .tex files containing Chinese characters) in a Windows PowerShell environment. It seems highly likely that this issue shares the same root cause described in other Bun-based applications on Windows: The mismatch between the runtime's default UTF-8 output stream and the Windows Console's active code page (usually CP936 or CP437). When opencode communicates via standard I/O (stdio), if the terminal encoding is not explicitly set to UTF-8, can be misinterpreted or split during the stream transmission. This causes two failures: - JSON Corruption: The JSON payload containing the newText might be malformed upon receipt, leading to the received: "undefined" error. - Matching Failure: Even if the JSON is parsed, the byte sequence of the icon in memory differs from what is read from the disk, causing the "Could not find exact match" error because the diff/patch algorithm requires strict string equality. ## For Windows/PowerShell users: Before starting the agent or editor, force the PowerShell session to use UTF-8 for both input and output streams. You can add this to your PowerShell $PROFILE or run it in the terminal before starting opencode: ```PowerShell [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 $OutputEncoding = [System.Text.Encoding]::UTF8 ``` This ensures that the pipe between the tool and the interface correctly handles the multi-byte Unicode characters. ## For the Maintainers: It might be beneficial to explicitly set the stdio encoding to UTF-8 within the application entry point to ensure consistency across different OS locales, preventing the application from inheriting the legacy Windows code page.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1911