Repository navigation
feat(storage): adopt the NanoKVM Go file-manager UI - #982
Merged
Merged
Conversation
possiblyneal
pushed a commit
to possiblyneal/NanoKVM-OS
that referenced
this pull request
Nov 6, 2026
The user disk file manager in Settings > USB uploads a whole folder, from the folder picker or dropped onto the file list, and dropped files too. Folders are created shallowest first, empty ones included, then each file goes into its own folder. A name that already exists or that FAT32 rejects is skipped and listed at the end, so uploading the same folder again after an interruption continues where it stopped; disk-level errors still stop the upload. The current path is now clickable breadcrumbs. The server's mkdir takes existsOk=1: an existing folder of that name is success, a file of that name is still an error. Idea from sipeed/NanoKVM#982 (its file manager for the shared folder); the code is ours, on our separate FAT32 user disk. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The storage entry becomes a picker with two windows: disk mounting and a file manager for the shared folder, the way NanoKVM Go lays them out. The cards stay openable while the virtual disk is switched off: that switch is how the data partition is handed back for writing, so it is the state an image upload starts from, and disabling the cards there would leave a new device with no way to add its first image. Only the attach actions inside the window depend on the disk. The file manager gains list and icon views, sorting by name, size, type and modified time, search, inline folder expansion, folder creation and drag-and-drop uploads. It also uploads a whole folder, from the picker or dropped onto the list: the folders are created shallowest first and every file lands in its own directory, which is more than NanoKVM Go offers. A dropped folder the browser cannot read is reported once instead of being silently ignored. A name that is already taken is answered with its own error code, so the UI says "the file exists" in the user's language instead of showing the server's English sentence, and the failed media job behind it is hidden once the user has been told. The mount window keeps the mode picker and the add media actions and lists images only: NanoKVM Go can keep its shared disk always attached because it is a second LUN, while this device has one, so the shared folder is attached and released by the virtual disk switch. Disabled write actions say what to do about it - eject the virtual USB drive on the target machine, then turn off the Virtual Disk switch - the same wording the NanoKVM Go build uses instead of a one-line refusal. "The target machine is writing" is reported for the whole medium, so only a zero-length entry touched in the last few seconds is labelled as an upload in progress: an empty file from an hour ago is empty, not busy. The same rule drives the list and the icon view. The listing polls while the target machine owns the partition and the account has no console socket to receive the storage push on, which is the fallback the NanoKVM Go build uses for the same reason. The file manager tells the watcher every directory it is showing - the one being listed and every folder expanded - as a JSON list, so a folder name may contain a comma. Because that set changes as the user navigates, the watcher re-baselines without treating the new set as a write: counting it kept the write quiet window alive forever, and zero-length files stayed labelled as uploads that never finished. When the quiet window does end, the watcher notifies once more for the same reason. An image listing leaves the set alone; another browser may still be showing the shared folder. The media job is polled and shown by the file manager alone: it reports a file being written into the shared folder, so the mount window used to show a transfer it had not started. Image transfers keep their own row. The server grows POST /api/storage/media/files/mkdir, which the new folder action and the folder upload need; it refuses names that exist (unless the caller recreates a tree and says so) and refuses to create through a symlinked parent. A name taken by a file is reported as such instead of being mistaken for an existing folder. A /data left read-only while nothing is attached - a release whose remount failed, or the kernel remounting on an exFAT error - used to turn every upload, download and folder into an EROFS failure with no explanation. The media state now carries localWritable, the state poll takes the partition back when no medium owns it, and a writable open or transfer retries the remount. A heal that keeps failing is reported at most once a minute, since the poll would otherwise repeat it every few seconds. Static files are labelled for the first time: the entry document revalidates on every load and hashed assets are immutable - but only while the file exists, so a 404 is never pinned for a year. The keyboard forwarding skips events aimed at an input, textarea, select or contenteditable, as the NanoKVM Go build does: cancelling the default action is what kept a pasted URL out of the storage dialogs, and the new file manager's search field needs the same. A key that was already forwarded is still released when focus moves into such a field, and focus entering one releases whatever the target machine was holding, so a modifier cannot stay pressed over there. MenuItem gains closeRequest, so a picker that opens a window closes without collapsing the menu bar. Verified with pnpm build, go vet and go test.
liangzhuohua
force-pushed
the
feat/storage-file-manager-ui
branch
from
November 6, 2026 10:41
9f33949 to
af8c0c4
Compare
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
Reworks the storage surface to match NanoKVM Go: the menu entry is a picker with
two cards, "Disk mount" and "File sharing", that open their own windows, and file
sharing becomes a real file manager for the shared folder.
What changed
Storage menu
how the data partition is handed back for writing, so it is exactly the state an
image upload starts from. Only the attach actions inside a window depend on the
disk.
File manager (File sharing)
modified time, search in the current folder, breadcrumbs and parent navigation.
or dropped): directories are created shallowest first and each file lands in its
own directory. Empty folders are preserved on drop.
machine, then turn off the Virtual Disk switch in Settings > Device.
it, a 3 s poll otherwise while the target machine owns the partition.
Disk mount
shared folder is attached and released through the virtual disk switch.
manager, so the mount window no longer reports transfers it did not start.
Server
POST /api/storage/media/files/mkdirwithexistsOkfor recreating a tree, thesame permission model as upload/delete, path validation, a symlinked-parent
check, and a distinct error when the name is taken by a file.
localWritablein the media state. A/dataleft read-only while nothing isattached (a release whose remount failed, or the kernel remounting on an exFAT
error) is now healed on the state poll and retried before any writable open or
transfer; a heal that keeps failing is logged at most once a minute.
index.htmlrevalidates on every load and hashed assets areimmutable — but only while the file exists, so a 404 is never pinned for a year.
An update can no longer be hidden by a cached document.
contenteditable, so typing and pasting work in the new dialogs (same as NanoKVM
Go).
MenuItemgainscloseRequest, so a picker that opens a window closes withoutcollapsing the menu bar.
Notes
server messages stay English, as in NanoKVM Go.
folder only.
ca,pt_br,seandtrstrings for the new keys were written by thecontributor; a native check would be welcome.
Testing
tsc --noEmit,eslint(0 errors),vite build.go vet ./...,go test ./service/storage/... ./webcache/(mkdir pathand symlink cases, cache-header cases).
upload with nested directories, create/delete, read-only state while the shared
disk is attached, pasting into the URL and search fields.
Screenshots