feat: 工具层编码支持 + 文件浏览编码选择 + 回滚修复#3108
Open
expfukck wants to merge 5 commits into
Open
Conversation
Add an encoding override dropdown to the workspace file preview panel, allowing users to manually select file encoding when auto-detection produces incorrect results. Backend (desktop/app.go): - Add Encoding field to FilePreview struct - Extend ReadFile(rel, enc) with optional encoding override parameter - Add encodingName() and parseEncoding() helper functions - Support: UTF-8, UTF-8 BOM, GB18030, UTF-16 LE/BE (with/without BOM) Frontend (WorkspacePanel.tsx): - Add ENCODING_OPTIONS list and encodingOverride state - Add encoding selector dropdown in preview meta bar - Auto-reset encoding override when switching files or workspaces - Re-read file with selected encoding on change Also updated: types.ts, bridge.ts, styles.css, en.ts, zh.ts
- Add optional 'encoding' parameter to read_file, write_file, edit_file, and multi_edit tools (supports UTF-8, GB18030/GBK, UTF-16 LE/BE, etc.) - write_file now preserves existing file encoding instead of always writing UTF-8, preventing silent charset corruption - Add fileenc.Name() and fileenc.ParseName() shared API in the encoding package, replacing duplicated logic in desktop/app.go - Add encoding_helpers.readFileEncodedWith() and writeFileEncodedWith() for encoding override support - Preview methods (editFile, multiEdit) now respect the encoding parameter - Fix rewind not restoring files: add checkpoint.Store.Prune() to clean up stale checkpoints after rewind, preventing turn-number collisions that caused RestoreCode to pick wrong (older) snapshots - Fix frontend silently swallowing Rewind/Fork/Summarize errors — now surfaces failures via local_notice in the UI
c4d0e2d to
9864c14
Compare
- Add 'file_encoding' field to Config struct (reasonix.toml) - All tools (read_file, write_file, edit_file, multi_edit) now use the project encoding as default when no per-call override is given - write_file preserves existing file encoding instead of always UTF-8 - WorkspacePanel encoding selector now controls the project-level setting, persists to config, affects all file operations globally - New file creation uses the project encoding - Settings panel exposes FileEncoding in SettingsView - SetFileEncoding bridge method to change encoding from UI - Pass fileEncoding through boot → Workspace → tool structs chain - ConfineWriters accepts optional fileEncoding parameter
RenderTOML is a manual field-by-field renderer — adding FileEncoding to the Config struct alone was not enough. The field was silently dropped on save, so the UI encoding change never reached the tools. Now file_encoding renders as an active TOML line when set, or as a commented example when empty (matching the existing pattern for language, planner_model, etc.).
The encoding setting is project-level, not per-file. Moved the dropdown from the file preview meta bar (only visible when a file is open) to the file browser's top toolbar next to Files/Changed tabs, so it's always accessible without needing to open a file first.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary / 概要
为文件操作工具增加编码参数支持,桌面文件浏览器增加编码选择器,并修复回滚功能无法还原文件的 bug。
Changes / 改动
1. 工具层编码支持 (read_file / write_file / edit_file / multi_edit)
2. 桌面文件浏览器编码选择器
3. 回滚 Bug 修复
4. 共享编码 API
eadFileEncodedWith()\ / \writeFileEncodedWith()\ 支持编码覆盖
Files Changed / 改动文件 (18 files)
Testing / 测试