From 8aebb0c346c782a86dfd3d95d02ac226a20b433e Mon Sep 17 00:00:00 2001 From: ZDDC Date: Mon, 18 May 2026 16:47:57 -0500 Subject: [PATCH] fix(browse): propagate writable bit into tree nodes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Root cause of "I'm root admin but the editor says read-only." loader.js parses the listing JSON and stamps `writable` onto the raw entry. tree.js:newNode() then copies every other field (name, url, isDir, size, modTime, ext, handle, virtual …) into the tree node — but dropped `writable`. So `node.writable` was always undefined and `canSave(node)` short-circuited to false, mounting the YAML and markdown editors read-only even for an elevated admin where the server had correctly stamped writable=true. Symptom: red banner / read-only mode regardless of admin status. Server-side log line was correct (elevated=true active_admin=true chain_admin_level=0); the bit just never reached the editor. One-line fix: include `writable: !!raw.writable` alongside `virtual` in the tree-node initialiser. Verified end-to-end against the live bitnest fixture — every entry now carries the bit through. Co-Authored-By: Claude Opus 4.7 (1M context) --- browse/js/tree.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/browse/js/tree.js b/browse/js/tree.js index da8a372..ed6e804 100644 --- a/browse/js/tree.js +++ b/browse/js/tree.js @@ -43,7 +43,13 @@ // True when this entry was synthesized client-side (e.g. // canonical project folders that don't exist on disk yet). // Rendered with a muted style + an "(empty)" hint. - virtual: !!raw.virtual + virtual: !!raw.virtual, + // Server-computed write authority. Editors (preview-yaml, + // preview-markdown) consult this via canSave() to decide + // whether to mount read-only. Dropping the field here + // silently makes every node read-only — the actual root + // cause behind "I'm admin but the editor says read-only". + writable: !!raw.writable }; state.nodes.set(id, node); return node;