Show one directory at a time and let the app load each directory

The browser no longer takes a nested tree. The app sets path and the
current directory's entries; selecting a directory or .. emits
octopus:navigate with the requested path for the app to load.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-23 18:11:53 -07:00
co-authored by Claude Opus 5.5
parent 05db10911a
commit 13e2654415
7 changed files with 42 additions and 51 deletions
+15 -2
View File
@@ -1,6 +1,19 @@
import './demo.css';
import './octopus-file-browser.js';
import entries from 'virtual:octopus-repo-tree';
import tree from 'virtual:octopus-repo-tree';
const browser = document.querySelector('octopus-file-browser');
browser.entries = entries;
// Stands in for an app backend: returns one directory listing per request.
function list(path) {
return path.reduce((entries, name) =>
entries.find((entry) => entry.type === 'directory' && entry.name === name)?.children || [], tree)
.map(({ children, ...entry }) => entry);
}
browser.addEventListener('octopus:navigate', ({ detail }) => {
browser.path = detail.path;
browser.entries = list(detail.path);
});
browser.entries = list([]);