Skip to content

Agent Zero AI framework

Preserve canvas listing when a file picker closes

linkliti2efde36e7d88
diff --git a/tests/test_file_browser_navigation.py b/tests/test_file_browser_navigation.py
index cea694e37..17ed6346c 100644
--- a/tests/test_file_browser_navigation.py
+++ b/tests/test_file_browser_navigation.py
@@ -255,6 +255,10 @@ def test_file_browser_dropdown_escapes_scroll_container_and_header_is_opaque() -
store = read("webui", "components", "modals", "file-browser", "file-browser-store.js")
assert '@scroll="$store.fileBrowser.closeDropdown(); $store.fileBrowser.closeNewItemsMenu()"' in html
+ # A picker opened over a live canvas surface must restore the prior listing
+ # on close instead of destroying the shared store state.
+ assert 'const surfaceActive = Boolean(document.querySelector(".file-browser-root.is-surface"));' in store
+ assert 'await this.openSurface(retainedPath);' in store
assert 'overflow: auto;' in html
assert 'x-teleport="body"' in html
assert 'class="dropdown-menu file-actions-menu"' in html
diff --git a/webui/components/modals/file-browser/AGENTS.md b/webui/components/modals/file-browser/AGENTS.md
index bc297d7ac..8cf6174e4 100644
--- a/webui/components/modals/file-browser/AGENTS.md
+++ b/webui/components/modals/file-browser/AGENTS.md
@@ -15,6 +15,7 @@
## Local Contracts
- Keep `open(path)` as the modal entry point for workflows that await browser close.
+- A picker opened while a canvas surface is mounted must restore the surface listing on close (`openSurface(retainedPath)`), never destroy the shared store state — destroy only runs when no surface is active.
- Keep `openSurface(path)` as the right-canvas entry point; it must load files without opening or awaiting a modal.
- The floating file-browser modal must use the shared surface modal chrome so it remains draggable/resizable and exposes Focus mode.
- Preserve remembered-directory behavior: explicit paths win, then remembered path, then `$WORK_DIR`.
diff --git a/webui/components/modals/file-browser/file-browser-store.js b/webui/components/modals/file-browser/file-browser-store.js
index e76d35d2c..93243cb54 100644
--- a/webui/components/modals/file-browser/file-browser-store.js
+++ b/webui/components/modals/file-browser/file-browser-store.js
@@ -389,6 +389,9 @@ const model = {
// --- Public API (called from button/link) --------------------------------
async open(path = "", options = {}) {
if (this.isLoading) return; // Prevent double-open
+ // A picker may open over a live canvas surface; its listing must survive the modal close.
+ const surfaceActive = Boolean(document.querySelector(".file-browser-root.is-surface"));
+ const retainedPath = surfaceActive ? this.browser.currentPath : "";
this.resetOpenState(options);
try {
@@ -398,7 +401,13 @@ const model = {
// await modal close
await this.closePromise;
- if (!this.isSurfaceHandoff) this.destroy();
+ if (!this.isSurfaceHandoff) {
+ if (surfaceActive) {
+ await this.openSurface(retainedPath);
+ } else {
+ this.destroy();
+ }
+ }
} catch (error) {
console.error("File browser error:", error);