Agent Zero AI framework
clean error msgs in file browser
3clyp506af489904971
diff --git a/python/api/edit_work_dir_file.py b/python/api/edit_work_dir_file.pyindex 379064295..a23e19b39 100644--- a/python/api/edit_work_dir_file.py+++ b/python/api/edit_work_dir_file.py@@ -14,6 +14,13 @@ class EditWorkDirFile(ApiHandler):def get_methods(cls):return ["GET", "POST"]+ def _extract_error_message(self, error_str: str) -> str:+ """Extract user-friendly error message from exception string."""+ for line in reversed(error_str.split('\n')):+ if ': ' in line and ('Exception' in line or 'Error' in line):+ return line.split(': ', 1)[1].strip()+ return error_str.strip()+async def process(self, input: Input, request: Request) -> Output:try:if request.method == "GET":@@ -46,7 +53,9 @@ class EditWorkDirFile(ApiHandler):return {"ok": True}except Exception as e:- return {"error": str(e)}+ # Extract clean error message from exception+ # RPC calls may return full tracebacks in exception strings+ return {"error": self._extract_error_message(str(e))}async def load_file(file_path: str) -> dict:diff --git a/webui/components/modals/file-editor/file-editor-store.js b/webui/components/modals/file-editor/file-editor-store.jsindex 9508b355d..d8aff4b89 100644--- a/webui/components/modals/file-editor/file-editor-store.js+++ b/webui/components/modals/file-editor/file-editor-store.js@@ -71,7 +71,8 @@ const model = {this.isEditLoading = false;this.scheduleEditorInit();} catch (error) {- const message = error?.message || "Failed to load file";+ let message = error?.message || "Failed to load file";+ message = this._extractErrorMessage(message);this.editError = message;this.isEditLoading = false;window.toastFrontendError(message, "File Edit Error");@@ -197,6 +198,19 @@ const model = {// --- Helpers -------------------------------------------------------------+ _extractErrorMessage(msg) {+ if (typeof msg !== 'string') return msg;+ // Extract clean error from traceback strings+ const lines = msg.split('\n');+ for (let i = lines.length - 1; i >= 0; i--) {+ const line = lines[i].trim();+ if (line.includes(': ') && /Exception|Error/.test(line)) {+ return line.split(': ').slice(1).join(': ').trim();+ }+ }+ return msg;+ },+resetEditState() {if (this.editor?.destroy) {this.editor.destroy();