Commit Graph

2 Commits

Author SHA1 Message Date
Haileyesus
4178ccdd5e fix(code-editor): stabilize document loading deps and replace blocking save alerts
The code editor document hook was reloading more often than necessary because
`useEffect` depended on the full `file` object (and `projectPath`, which was not
used in the effect body). Save flow also emitted verbose production debug logs
and used a blocking `alert()` for errors.

Changes:
- Refactored `useCodeEditorDocument` to derive stable file primitives:
  `fileProjectName`, `filePath`, `fileName`, `fileDiffNewString`,
  `fileDiffOldString`.
- Updated `loadFileContent` to use those stable fields while preserving existing
  diff-first loading logic (`file.diffInfo`, `new_string`, `old_string`).
- Replaced the effect dependency array with only stable primitive values used by
  the effect and removed `projectPath` from dependencies.
- Removed debug `console.log` calls in `handleSave`:
  - "Saving file:"
  - "Save response:"
  - "Save successful:"
- Kept error logging via `console.error` for failure diagnostics.
- Replaced blocking `alert()` on save failure with non-blocking UI feedback:
  - Added local `saveError` state in the hook.
  - Set `saveError` from `getErrorMessage(error)` in the save catch path.
  - Exposed `saveError` to `CodeEditor` and rendered an inline error banner.
- Preserved save lifecycle behavior:
  - `setSaving(false)` still runs in `finally`.
  - `setSaveSuccess(true)` and 2s timeout reset behavior remain unchanged.
2026-02-23 09:35:59 +03:00
Haileyesus
b63d827ccc refator(code-editor): make CodeEditor feature based component
- replaced interfaces with types from main-content types
2026-02-23 09:14:00 +03:00