From 2e9490ca27047ae03e495d397abbe1aec1b2273a Mon Sep 17 00:00:00 2001 From: Christophe Besson Date: Thu, 20 Aug 2026 22:21:19 +0200 Subject: feat: unified group management, public groups, and activity-based sidebar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Create Group wizard (Electron-only) consolidates 6 steps across 4 interfaces into a single multi-step page: group creation on hub, node attachment, root selection via folder picker, GEK initialization, and auto-pairing — all in one flow. Browser SPA keeps its current behavior unchanged. Public group support (Option A — GEK for all groups): - All groups have GEK regardless of visibility; open-join groups auto-admit via TOFU when join_policy is "open" - Key rotation blocked for public groups (API guard + UI hidden) - Hub signaling allows WebRTC offers for nodes hosting open-join groups even when the caller isn't a member yet - attach_group writes join_policy to node.toml - Daemon loads GEK for all groups, not just private ones - Known-device path in join_request now auto-admits to open-join groups Node loopback API bridge (Electron IPC): - node:detect, node:call, node:pairing-code IPC handlers in main process - Renderer never sees tokens, paths, or keys (session token = physical access) - platform.js node namespace for UI consumption - Loopback endpoints: roots CRUD, member-upload toggle, reload Bug fixes: - Root change detection: removed premature ctx["roots"] updates from add_root and remove_root that prevented indexer retarget on reload - Duplicate offline message: global fallback now gated on !group - Signaling membership check: fallback to open-join groups for non-members Sidebar groups sorted by last_activity_at (most recent first): - New Group.last_activity_at column with Alembic migration - POST /v1/groups/{id}/activity endpoint, called on connect and chat send - Client-side sort + throttled hub updates (1/min) Co-Authored-By: Claude Opus 4.6 --- packages/meshbay-node/tests/test_roots.py | 67 ++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) (limited to 'packages/meshbay-node/tests/test_roots.py') diff --git a/packages/meshbay-node/tests/test_roots.py b/packages/meshbay-node/tests/test_roots.py index ea4ba6a..fc5bd64 100644 --- a/packages/meshbay-node/tests/test_roots.py +++ b/packages/meshbay-node/tests/test_roots.py @@ -11,7 +11,10 @@ from pathlib import Path import pytest -from meshbay_node.roots import Root, RootError, RootSet, entry_abs_path +from meshbay_node.roots import ( + Root, RootError, RootSet, entry_abs_path, + SAFE_UPLOAD_NAME, safe_subdir, _free_name, +) from meshbay_common.protocol import IndexEntry @@ -240,3 +243,65 @@ def test_describe_reports_what_a_member_needs(tmp_path): # Deliberately no paths: a member is told what exists and whether it is # readable, not where on the operator's disk it lives. assert not any("path" in d for d in described) + + +# ── SAFE_UPLOAD_NAME ──────────────────────────────────────────────────────── + +def test_safe_name_accepts_unicode_letters(): + assert SAFE_UPLOAD_NAME.match("rapport (1).pdf") + assert SAFE_UPLOAD_NAME.match("hello.txt") + + +def test_safe_name_rejects_dotfiles(): + assert not SAFE_UPLOAD_NAME.match(".hidden") + assert not SAFE_UPLOAD_NAME.match("..secret") + + +def test_safe_name_rejects_trailing_dot_or_space(): + assert not SAFE_UPLOAD_NAME.match("file.") + assert not SAFE_UPLOAD_NAME.match("file ") + + +# ── _free_name ────────────────────────────────────────────────────────────── + +def test_free_name_returns_original_when_not_taken(tmp_path): + assert _free_name(tmp_path, "photo.jpg") == "photo.jpg" + + +def test_free_name_appends_counter_on_collision(tmp_path): + (tmp_path / "photo.jpg").write_text("x") + assert _free_name(tmp_path, "photo.jpg") == "photo (2).jpg" + + +def test_free_name_increments_past_multiple_collisions(tmp_path): + (tmp_path / "photo.jpg").write_text("x") + (tmp_path / "photo (2).jpg").write_text("x") + assert _free_name(tmp_path, "photo.jpg") == "photo (3).jpg" + + +# ── safe_subdir ───────────────────────────────────────────────────────────── + +def test_safe_subdir_resolves_valid_path(tmp_path): + (tmp_path / "Films").mkdir() + (tmp_path / "Films" / "2024").mkdir() + roots = RootSet.build([_spec(tmp_path / "Films")]) + assert safe_subdir(roots, "Films/2024") == (tmp_path / "Films" / "2024").resolve() + + +def test_safe_subdir_refuses_traversal(tmp_path): + (tmp_path / "Films").mkdir() + roots = RootSet.build([_spec(tmp_path / "Films")]) + assert safe_subdir(roots, "Films/../../etc") is None + + +def test_safe_subdir_refuses_empty_virtual_root(tmp_path): + (tmp_path / "Films").mkdir() + roots = RootSet.build([_spec(tmp_path / "Films")]) + assert safe_subdir(roots, "") is None + + +def test_safe_subdir_refuses_unavailable_root(tmp_path): + (tmp_path / "Films").mkdir() + roots = RootSet.build([_spec(tmp_path / "Films")]) + roots.roots[0].available = False + assert safe_subdir(roots, "Films/2024") is None -- cgit v1.2.3