From 80ca7dd0765a6c08fa5ea54c2e14972bba6fa564 Mon Sep 17 00:00:00 2001 From: Christophe Besson Date: Mon, 7 Sep 2026 00:18:54 +0200 Subject: fix(client): New folder did nothing — prompt() throws in the desktop client MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The same `static/` tree is the web page and the application, and Electron does not implement `window.prompt`: Chromium leaves it to the embedder and Electron declines. It does not return null — it **throws**. The call sat above its own try, so clicking produced no folder, no error and nothing on screen to react to. A dead button, which is exactly how it was reported. Measured against this repo's own Electron 44 rather than assumed, because the first two diagnoses this session were reasoned and wrong: prompt('name?') -> Error: prompt() is not supported. confirm('sure?') -> opens a real modal alert('hi') -> opens a real modal So `confirm` and `alert` stay — a dozen call sites depend on them — and only `prompt` is banned. `test_no_prompt_in_the_spa.py` holds the whole tree to it, with the near-misses it must not flag (`mkdir_prompt`, `promptForName`). The name now comes from a field in the toolbar, which works in both clients and can show the node's refusal beside the input instead of after a dialog has closed. Navigating away drops a half-typed name: it would otherwise create the folder somewhere the person is no longer looking. The rest of the chain was verified end to end and was sound: `dir_create` {dir,name} → the node's handler → `dir_create_ack`, and `list_dirs` walks the filesystem rather than the index, so a folder with nothing in it appears on the very fetch that follows. The field itself was then driven inside a real Electron window — typing, Enter, the click, and the icon rendering. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_011pvMdvLBG92jyhvD5pD6us --- .../src/meshbay_hub/static/files-app.js | 65 ++++++++++++++-- .../src/meshbay_hub/static/locales/de.js | 3 +- .../src/meshbay_hub/static/locales/en.js | 3 +- .../src/meshbay_hub/static/locales/es.js | 3 +- .../src/meshbay_hub/static/locales/fr.js | 3 +- .../src/meshbay_hub/static/locales/it.js | 3 +- .../src/meshbay_hub/static/locales/ja.js | 3 +- .../src/meshbay_hub/static/locales/nl.js | 3 +- .../src/meshbay_hub/static/locales/pl.js | 3 +- .../src/meshbay_hub/static/locales/pt-BR.js | 3 +- .../src/meshbay_hub/static/locales/zh-CN.js | 3 +- .../meshbay-hub/src/meshbay_hub/static/style.css | 12 +++ .../meshbay-hub/tests/test_no_prompt_in_the_spa.py | 90 ++++++++++++++++++++++ .../tests/test_upload_controls_hidden.py | 17 ++-- 14 files changed, 192 insertions(+), 22 deletions(-) create mode 100644 packages/meshbay-hub/tests/test_no_prompt_in_the_spa.py diff --git a/packages/meshbay-hub/src/meshbay_hub/static/files-app.js b/packages/meshbay-hub/src/meshbay_hub/static/files-app.js index fb57a0f..4947f8c 100644 --- a/packages/meshbay-hub/src/meshbay_hub/static/files-app.js +++ b/packages/meshbay-hub/src/meshbay_hub/static/files-app.js @@ -104,19 +104,47 @@ function FilesPanel({ } }, [applyIndex, currentPath]); - const makeDirectory = useCallback(async () => { + // `null` while not creating one; a draft string while the field is open. + const [newDirName, setNewDirName] = useState(null); + const [creatingDir, setCreatingDir] = useState(false); + + /** + * Create a folder in the directory being browsed. + * + * The name comes from a field in the toolbar rather than `window.prompt`, + * which **throws** in Electron — "prompt() is not supported" — and threw + * outside this function's try, so clicking the button did nothing at all: + * no folder, no error, nothing in the interface to react to. `confirm()` and + * `alert()` do work there and are used elsewhere; `prompt` is the one + * Chromium leaves to the embedder and Electron declines to implement. + * + * An inline field is better anyway — it can show the refusal next to the + * input instead of after the dialog has closed. + */ + useEffect(() => { setNewDirName(null); }, [currentPath]); + + const makeDirectory = useCallback(async (rawName) => { const transport = transportRef.current; - if (!transport || !transport.connected) return; - const name = prompt(t('group.mkdir_prompt')); - if (!name || !name.trim()) return; + const name = (rawName || '').trim(); + if (!name) return; + if (!transport || !transport.connected) { + setError(t('group.mkdir_offline')); + return; + } + setCreatingDir(true); try { - await transport.createDirectory(currentPath, name.trim()); + await transport.createDirectory(currentPath, name); + // `list_dirs` walks the filesystem rather than the index, so a folder + // with nothing in it is here on this very fetch. const indexMsg = await transport.fetchIndex(); if (indexMsg.entries) setEntries(indexMsg.entries); if (indexMsg.dirs) setNodeDirs(indexMsg.dirs); if (indexMsg.roots) setNodeRoots(indexMsg.roots); + setNewDirName(null); } catch (err) { setError(err.message); + } finally { + setCreatingDir(false); } }, [currentPath]); @@ -374,12 +402,35 @@ function FilesPanel({ width a breadcrumb trail needs. The name lives in the tooltip and in aria-label, so it is not lost to anyone reading with something other than their eyes. */''} - ${canCreateDir && html` - `} + ${canCreateDir && newDirName !== null && html` + + setNewDirName(e.target.value)} + onKeyDown=${(e) => { + if (e.key === 'Enter') makeDirectory(newDirName); + if (e.key === 'Escape') setNewDirName(null); + }} /> + + + + `}