Skip to content

Conversation

@limshyun
Copy link
Contributor

@limshyun limshyun commented Jan 7, 2026

Resolves #3686 (FR-1014)

Summary

Implement the ability to directly edit and save simple text files within the NEO File Explorer.

Background

Users frequently need to modify configuration files such as yaml, toml, and json within vfolders for model serving. Currently, this requires downloading the file → editing locally → re-uploading, which results in a poor user experience.

Implementation

Key Features

  • Edit button in More menu: Added dropdown menu with edit option in File Explorer controls
  • Text file detection: Supports .txt, .md, .json, .yaml, .yml, .xml, .csv, .js, .ts, .jsx, .tsx, .py, .sh, .bash, .html, .css, .scss, .less, .sql, .log, .env, .conf, .config, .ini, .toml
  • CodeMirror editor: Full-featured text editor with syntax highlighting
  • File operations: Download → Edit → Upload workflow using existing APIs

Components Added

  • TextFileEditorModal.tsx: Main editor modal with BAICodeEditor
  • Enhanced FileItemControls.tsx: Added More menu with Edit option
  • Enhanced BAIFileExplorer.tsx: Added enableEdit and onClickEditFile props
  • Updated FolderExplorerModal.tsx: Integration with TextFileEditorModal

Technical Details

  • File Reading: request_download_tokenfetchblob.text()
  • File Saving: Modified content → new File()FileUploadManager.uploadFiles() (overwrites)
  • Permissions: Requires write_content permission
  • Size Limit: baiClient._config.maxFileUploadSize

i18n Support

  • comp:FileExplorer.EditFile: "Edit"
  • data.explorer.EditFile: "Edit File"
  • `data.explorer.FailedToLoadFile": "Failed to load file"

Checklist:

  • Documentation (PR description)
  • Minimum required manager version (N/A - client-side feature)
  • Specific setting for review: Test with various text files in File Explorer
  • Minimum requirements: write_content permission on vfolder
  • Test cases: Edit .txt, .yaml, .json files; verify save/cancel functionality

test

2026-01-09.5.48.50.mov

@github-actions github-actions bot added area:ux UI / UX issue. area:i18n Localization size:L 100~500 LoC labels Jan 7, 2026
@cla-assistant
Copy link

cla-assistant bot commented Jan 7, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

1 similar comment
@cla-assistant
Copy link

cla-assistant bot commented Jan 7, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 2026

Coverage report for ./packages/backend.ai-ui

St.
Category Percentage Covered / Total
🟡 Statements
62.41% (-1.09% 🔻)
259/415
🔴 Branches
41.83% (-0.47% 🔻)
151/361
🔴 Functions
48.94% (-1.06% 🔻)
46/94
🟡 Lines
64.01% (-1.14% 🔻)
233/364
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟡 helper/index.ts
61.01% (-2.88% 🔻)
43.75% (-1.12% 🔻)
53.33% (-3.81% 🔻)
64.06% (-3.46% 🔻)

Test suite run success

186 tests passing in 9 suites.

Report generated by 🧪jest coverage report action from db0061c

@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 2026

Coverage report for ./react

St.
Category Percentage Covered / Total
🔴 Statements
4.9% (-0.02% 🔻)
589/12026
🔴 Branches
4.46% (-0.02% 🔻)
377/8462
🔴 Functions
2.74% (-0.01% 🔻)
101/3687
🔴 Lines
4.73% (-0.01% 🔻)
555/11744
Show new covered files 🐣
St.
File Statements Branches Functions Lines
🔴
... / TextFileEditorModal.tsx
0% 0% 0% 0%

Test suite run success

173 tests passing in 13 suites.

Report generated by 🧪jest coverage report action from db0061c

@limshyun limshyun force-pushed the feat/FR-1014/text-file-editor branch from 34bddf9 to 2029a95 Compare January 8, 2026 03:37
@limshyun
Copy link
Contributor Author

limshyun commented Jan 8, 2026

This PR continues the work from #4943, which was closed during Jira issue number correction (FR-1869FR-1014). @nowgnuesLee Could you please tag Copilot as a reviewer? The previous Copilot review comments on #4943 were very helpful and we'd like to continue addressing them here.

…ions

- Replace useEffect-based file loading with useTanQuery
- Replace manual save handling with useTanMutation
- Add useErrorMessageResolver for standardized error handling
- Replace Button with BAIButton in FileItemControls
- Add Tooltip to More options dropdown button
- Replace Typography.Text with BAIText
- Replace Alert with BAIAlert
- Make onRequestClose success parameter optional
@limshyun limshyun requested a review from nowgnuesLee January 9, 2026 03:28
Copy link
Contributor

@ironAiken2 ironAiken2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I edit one file, the editor shows the changes made to other files. And I think it would be good to include the text file editing feature in the BUI. What do you think?

…anagement

- Use BAIButton action prop for automatic loading state in download button
- Replace isEdited state with null-check pattern for cleaner content tracking
- Add user-friendly error messages with BAILogger for detailed error logging
- Add FailedToLoadFileDescription i18n key for all 21 supported languages
- Replace useMutation with useTanMutation for consistency
- Remove unnecessary Tooltip wrapper from more options dropdown
- Add tooltip to explain why file editing is disabled for unsupported formats
- Show tooltip when file is a directory or not a text file
- Add UnsupportedFileFormat i18n key to all 21 locale files
@limshyun limshyun requested a review from ironAiken2 January 9, 2026 07:24
Copy link
Contributor

@agatha197 agatha197 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screen.Recording.Jan.9.2026.from.Graphite.mov

When I edit the text file, the file browser is closed and frozen. I cannot re-open the file browser before refreshing. I made the text file by this way.

  1. In the terminal, touch test.txt
  2. Add some contents
  3. Upload that file

@limshyun
Copy link
Contributor Author

limshyun commented Jan 9, 2026

3.

Screen.Recording.Jan.9.2026.from.Graphite.mov
When I edit the text file, the file browser is closed and frozen. I cannot re-open the file browser before refreshing. I made the text file by this way.

  1. In the terminal, touch test.txt
  2. Add some contents
  3. Upload that file

This issue has been fixed in commit fc42770. The problem was that the getLanguageFromExtension function was returning raw file extensions (like txt, md, py) directly to CodeMirror, but CodeMirror doesn't recognize these as valid language names. This caused CodeMirror to fail when trying to load syntax highlighting, which froze the file browser.

The fix includes:

Created a proper extensionToLanguageMap that maps file extensions to valid CodeMirror language names (e.g., txt → markdown, py → python, sh → shell)
Added a new getCodeMirrorLanguage helper function that returns the correct CodeMirror language name
Moved this logic to the shared backend.ai-ui package for reusability
Please pull the latest changes and try again. If you still experience the issue after updating, let me know.

@limshyun limshyun requested a review from agatha197 January 9, 2026 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:i18n Localization area:ux UI / UX issue. size:L 100~500 LoC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NEO File Explorer: Edit and save text files

5 participants