summaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/src/meshbay_hub/static
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-09-07 00:18:54 +0200
committerChristophe Besson <cbesson@gmail.com>2026-09-07 00:18:54 +0200
commit80ca7dd0765a6c08fa5ea54c2e14972bba6fa564 (patch)
tree29586935c58e870277d95f9f082a9abe941f3958 /packages/meshbay-hub/src/meshbay_hub/static
parent920284009d634cb568f95b3e93b93012c4b803bb (diff)
downloadmeshbay-80ca7dd0765a6c08fa5ea54c2e14972bba6fa564.tar.gz
fix(client): New folder did nothing — prompt() throws in the desktop client
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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011pvMdvLBG92jyhvD5pD6us
Diffstat (limited to 'packages/meshbay-hub/src/meshbay_hub/static')
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/files-app.js65
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/locales/de.js3
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/locales/en.js3
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/locales/es.js3
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/locales/fr.js3
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/locales/it.js3
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/locales/ja.js3
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/locales/nl.js3
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/locales/pl.js3
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/locales/pt-BR.js3
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/locales/zh-CN.js3
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/style.css12
12 files changed, 90 insertions, 17 deletions
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`
- <button class="tb-btn tb-btn-icon" onClick=${makeDirectory}
+ ${canCreateDir && newDirName === null && html`
+ <button class="tb-btn tb-btn-icon" onClick=${() => setNewDirName('')}
title=${t('group.mkdir')} aria-label=${t('group.mkdir')}>
<${Icon} name="folder-plus" />
</button>
`}
+ ${canCreateDir && newDirName !== null && html`
+ <span class="tb-mkdir">
+ <input type="text" class="tb-mkdir-input" autofocus
+ value=${newDirName} disabled=${creatingDir}
+ placeholder=${t('group.mkdir_prompt')}
+ aria-label=${t('group.mkdir')}
+ onInput=${(e) => setNewDirName(e.target.value)}
+ onKeyDown=${(e) => {
+ if (e.key === 'Enter') makeDirectory(newDirName);
+ if (e.key === 'Escape') setNewDirName(null);
+ }} />
+ <button class="tb-btn tb-btn-icon" title=${t('group.mkdir')}
+ disabled=${creatingDir || !newDirName.trim()}
+ onClick=${() => makeDirectory(newDirName)}>
+ <${Icon} name="check" />
+ </button>
+ <button class="tb-btn tb-btn-icon" title=${t('settings.cancel')}
+ disabled=${creatingDir}
+ onClick=${() => setNewDirName(null)}>
+ <${Icon} name="close" />
+ </button>
+ </span>
+ `}
</div>
<div class="breadcrumbs">
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/locales/de.js b/packages/meshbay-hub/src/meshbay_hub/static/locales/de.js
index 2e7d3c5..c6d0331 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/locales/de.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/locales/de.js
@@ -154,7 +154,8 @@ export default {
+ 'diese Gruppe hostet.',
'group.upload': 'Hochladen',
'group.mkdir': 'Neuer Ordner',
- 'group.mkdir_prompt': 'Name des neuen Ordners:',
+ 'group.mkdir_prompt': 'Name des neuen Ordners',
+ 'group.mkdir_offline': 'Nicht mit dem Node verbunden.',
'device.add_title': 'This browser is not linked to this node yet',
'device.add_hint': 'Your account is known here, but this browser holds a different key. Approve it from a device already linked — no operator needed.',
'device.add_btn': 'Get a linking code',
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/locales/en.js b/packages/meshbay-hub/src/meshbay_hub/static/locales/en.js
index 350a597..0831aa3 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/locales/en.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/locales/en.js
@@ -154,7 +154,8 @@ export default {
'group.offline_hint': 'Files will appear when a node hosting this group connects.',
'group.upload': 'Upload',
'group.mkdir': 'New folder',
- 'group.mkdir_prompt': 'Name of the new folder:',
+ 'group.mkdir_prompt': 'New folder name',
+ 'group.mkdir_offline': 'Not connected to the node.',
'device.add_title': 'This browser is not linked to this node yet',
'device.add_hint': 'Your account is known here, but this browser holds a different key. Approve it from a device already linked — no operator needed.',
'device.add_btn': 'Get a linking code',
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/locales/es.js b/packages/meshbay-hub/src/meshbay_hub/static/locales/es.js
index 22a9461..18570cc 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/locales/es.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/locales/es.js
@@ -152,7 +152,8 @@ export default {
+ 'este grupo.',
'group.upload': 'Subir',
'group.mkdir': 'Nueva carpeta',
- 'group.mkdir_prompt': 'Nombre de la nueva carpeta:',
+ 'group.mkdir_prompt': 'Nombre de la nueva carpeta',
+ 'group.mkdir_offline': 'Sin conexión con el nodo.',
'device.add_title': 'This browser is not linked to this node yet',
'device.add_hint': 'Your account is known here, but this browser holds a different key. Approve it from a device already linked — no operator needed.',
'device.add_btn': 'Get a linking code',
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/locales/fr.js b/packages/meshbay-hub/src/meshbay_hub/static/locales/fr.js
index 3da68b2..65021e3 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/locales/fr.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/locales/fr.js
@@ -153,7 +153,8 @@ export default {
+ 'groupe se connectera.',
'group.upload': 'Envoyer',
'group.mkdir': 'Nouveau dossier',
- 'group.mkdir_prompt': 'Nom du nouveau dossier :',
+ 'group.mkdir_prompt': 'Nom du nouveau dossier',
+ 'group.mkdir_offline': 'Non connecté au nœud.',
'device.add_title': 'Ce navigateur n’est pas encore lié à ce nœud',
'device.add_hint': 'Votre compte est connu ici, mais ce navigateur détient une autre clé. Approuvez-le depuis un appareil déjà lié — sans passer par l’opérateur.',
'device.add_btn': 'Obtenir un code de liaison',
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/locales/it.js b/packages/meshbay-hub/src/meshbay_hub/static/locales/it.js
index 335ed68..7f58764 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/locales/it.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/locales/it.js
@@ -153,7 +153,8 @@ export default {
+ 'questo gruppo.',
'group.upload': 'Carica',
'group.mkdir': 'Nuova cartella',
- 'group.mkdir_prompt': 'Nome della nuova cartella:',
+ 'group.mkdir_prompt': 'Nome della nuova cartella',
+ 'group.mkdir_offline': 'Non connesso al nodo.',
'device.add_title': 'This browser is not linked to this node yet',
'device.add_hint': 'Your account is known here, but this browser holds a different key. Approve it from a device already linked — no operator needed.',
'device.add_btn': 'Get a linking code',
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/locales/ja.js b/packages/meshbay-hub/src/meshbay_hub/static/locales/ja.js
index 4dd2f30..0e2dd42 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/locales/ja.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/locales/ja.js
@@ -151,7 +151,8 @@ export default {
+ 'ファイルが表示されます。',
'group.upload': 'アップロード',
'group.mkdir': '新しいフォルダー',
- 'group.mkdir_prompt': '新しいフォルダーの名前:',
+ 'group.mkdir_prompt': '新しいフォルダー名',
+ 'group.mkdir_offline': 'ノードに接続していません。',
'device.add_title': 'This browser is not linked to this node yet',
'device.add_hint': 'Your account is known here, but this browser holds a different key. Approve it from a device already linked — no operator needed.',
'device.add_btn': 'Get a linking code',
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/locales/nl.js b/packages/meshbay-hub/src/meshbay_hub/static/locales/nl.js
index cb36d38..9f74e19 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/locales/nl.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/locales/nl.js
@@ -154,7 +154,8 @@ export default {
+ 'die deze groep host.',
'group.upload': 'Uploaden',
'group.mkdir': 'Nieuwe map',
- 'group.mkdir_prompt': 'Naam van de nieuwe map:',
+ 'group.mkdir_prompt': 'Naam van de nieuwe map',
+ 'group.mkdir_offline': 'Niet verbonden met de node.',
'device.add_title': 'This browser is not linked to this node yet',
'device.add_hint': 'Your account is known here, but this browser holds a different key. Approve it from a device already linked — no operator needed.',
'device.add_btn': 'Get a linking code',
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/locales/pl.js b/packages/meshbay-hub/src/meshbay_hub/static/locales/pl.js
index 91d0d90..083d72d 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/locales/pl.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/locales/pl.js
@@ -157,7 +157,8 @@ export default {
'group.offline_hint': 'Pliki pojawią się, gdy połączy się node hostujący tę grupę.',
'group.upload': 'Wyślij',
'group.mkdir': 'Nowy folder',
- 'group.mkdir_prompt': 'Nazwa nowego folderu:',
+ 'group.mkdir_prompt': 'Nazwa nowego folderu',
+ 'group.mkdir_offline': 'Brak połączenia z węzłem.',
'device.add_title': 'This browser is not linked to this node yet',
'device.add_hint': 'Your account is known here, but this browser holds a different key. Approve it from a device already linked — no operator needed.',
'device.add_btn': 'Get a linking code',
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/locales/pt-BR.js b/packages/meshbay-hub/src/meshbay_hub/static/locales/pt-BR.js
index 2b26a0b..bdc6c3b 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/locales/pt-BR.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/locales/pt-BR.js
@@ -154,7 +154,8 @@ export default {
+ 'se conectar.',
'group.upload': 'Enviar',
'group.mkdir': 'Nova pasta',
- 'group.mkdir_prompt': 'Nome da nova pasta:',
+ 'group.mkdir_prompt': 'Nome da nova pasta',
+ 'group.mkdir_offline': 'Sem conexão com o nó.',
'device.add_title': 'This browser is not linked to this node yet',
'device.add_hint': 'Your account is known here, but this browser holds a different key. Approve it from a device already linked — no operator needed.',
'device.add_btn': 'Get a linking code',
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/locales/zh-CN.js b/packages/meshbay-hub/src/meshbay_hub/static/locales/zh-CN.js
index f1d7f9c..0a1fe1a 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/locales/zh-CN.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/locales/zh-CN.js
@@ -150,7 +150,8 @@ export default {
'group.offline_hint': '当托管此群组的 node 连接后,文件就会出现。',
'group.upload': '上传',
'group.mkdir': '新建文件夹',
- 'group.mkdir_prompt': '新文件夹的名称:',
+ 'group.mkdir_prompt': '新文件夹名称',
+ 'group.mkdir_offline': '未连接到节点。',
'device.add_title': 'This browser is not linked to this node yet',
'device.add_hint': 'Your account is known here, but this browser holds a different key. Approve it from a device already linked — no operator needed.',
'device.add_btn': 'Get a linking code',
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/style.css b/packages/meshbay-hub/src/meshbay_hub/static/style.css
index 4647209..c5d5ce3 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/style.css
+++ b/packages/meshbay-hub/src/meshbay_hub/static/style.css
@@ -837,6 +837,18 @@ button:disabled { opacity: 0.5; cursor: not-allowed; }
beside it. The horizontal padding goes; the height does not, so it lines up
with the labelled buttons next to it. */
.tb-btn-icon { padding: 0; width: 32px; justify-content: center; gap: 0; }
+
+/* Naming a new folder, in the toolbar. Not `window.prompt`, which throws in
+ Electron — and an inline field can put the node's refusal next to the input
+ rather than after a dialog has closed. */
+.tb-mkdir { display: inline-flex; align-items: center; gap: 6px; }
+.tb-mkdir-input {
+ height: 32px; width: 170px; padding: 0 9px;
+ border: 1px solid var(--border-focus); border-radius: 6px;
+ background: var(--bg-surface); color: var(--text);
+ font-family: inherit; font-size: 0.83em;
+}
+.tb-mkdir-input:focus { outline: none; }
.tb-btn.primary {
background: var(--accent);
border-color: var(--accent);