Feature/improve asset panel - #235
Conversation
Load assets from persistent state (topic) instead of using Lua functions each time the panel is opened (~3-5x speedup) Add "Show in explorer" for asset paths Update `CopyToClipboardButton` for additional use-case - `Menu.Item`
# Conflicts: # public/locales/en/panel-assets.json # src/panels/AssetsPanel/AssetEntry/AssetEntryMenu.tsx
These are the same rules used in the OpenSpace-docs repository
There was a problem hiding this comment.
🟡 Changes recommended
The asset-state type mismatch blocks type checking, and asset-tree updates can leave navigation stale.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Improves asset-panel loading by using the new asset-tree topic and centralized Redux state.
Changes:
- Adds asset-tree subscriptions, state management, rescanning, and folder construction.
- Adds file-explorer actions and refactors asset/copy controls.
- Updates API dependency, documentation, localization, and formatting configuration.
File summaries
| File | Description |
|---|---|
src/redux/store.ts |
Registers asset-tree state. |
src/redux/listenerMiddleware.ts |
Registers asset-tree listeners. |
src/redux/assettree/assetTreeSlice.ts |
Stores asset paths and loading states. |
src/redux/assettree/assetTreeMiddleware.ts |
Manages topic subscriptions and rescans. |
src/panels/LogPanel/ScriptLogPanel.tsx |
Adopts the copy-button mode API. |
src/panels/AssetsPanel/util.ts |
Builds folder trees from paths. |
src/panels/AssetsPanel/types.ts |
Uses generated asset-state types. |
src/panels/AssetsPanel/hooks.ts |
Builds folders from Redux data. |
src/panels/AssetsPanel/AssetsPanel.tsx |
Adds subscription and rescan UI. |
src/panels/AssetsPanel/AssetEntry/AssetsEntry.tsx |
Removes the former entry implementation. |
src/panels/AssetsPanel/AssetEntry/AssetLoadingStateIcon.tsx |
Handles generated state values. |
src/panels/AssetsPanel/AssetEntry/AssetEntryMenu.tsx |
Adds file-explorer and updated menu actions. |
src/panels/AssetsPanel/AssetEntry/AssetEntry.tsx |
Adds the Redux-backed entry implementation. |
src/hooks/topicSubscriptions.ts |
Adds an asset-tree subscription hook. |
src/components/Property/Types/NumericProperty.tsx |
Reformats value validation. |
src/components/CopyToClipboardButton/CopyToClipboardButton.tsx |
Supports button, menu-item, and icon modes. |
README.md |
Updates API generation and publishing guidance. |
public/locales/en/panel-assets.json |
Adds labels for new asset actions. |
package.json |
Updates the OpenSpace API dependency. |
package-lock.json |
Locks the updated API package. |
.prettierignore |
Updates excluded files. |
.markdownlint.json |
Adds Markdown lint configuration. |
Review details
- Files reviewed: 21/22 changed files
- Comments generated: 7
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| const states = useAppSelector((state) => state.assetTree.states); | ||
| const assetLoadingState = states[asset.path] ?? 'Unloaded'; |
| const navigatedFolder = useMemo( | ||
| () => (rootFolder ? findNavigatedFolder(rootFolder, currentPath) : null), | ||
| [rootFolder, currentPath] | ||
| ); |
There was a problem hiding this comment.
Love it :) Did some testing, but not a lot.
The only issue I ran into is that the refresh button freezes my application, as the regular loading did before. Would be nice if it was made a bit smaller or something to signal that it's not something we suggest people do frequently. See suggestions.
Also tested loading an asset in another location, and found it a bit confusing that the resulting folder looks so similar to the built-in and user assets. Would be nice to distinguish it from the actual folders somehow, maybe using another icon, if possible. Or just see suggestion on alternative folder name
This PR improves the asset panel load times, adds a new Topic (assettreetopic) and adds a new button to the
...menu to show the asset in Windows Explorer (should work on Linux as well, but I have not tested it).Also in the process of updating the README so that it's clearer how to generate new topics/types and linking stuff both to the openspace-api-js repository and a new docs page (will be created)
To be used with Openspace version: