From 58ca879b017da62e77f40752d8d94fef3f315a1e Mon Sep 17 00:00:00 2001 From: Christophe Besson Date: Fri, 28 Aug 2026 10:09:38 +0200 Subject: feat(hub): group names unique per owner, shown as name@owner MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A group's identity stays its UUID. What changes is that "the name is unique" — until now an unenforced expectation — becomes real, scoped to the owner account, and the owner's username is surfaced so two groups called "photos" on different nodes can be told apart. Hub: - `groups` gains a functional unique index `uq_groups_owner_name` on `(admin_id, lower(name))` (model + migration c3d4e5f6a7b8). The migration pre-flights: if the data already clashes it aborts and lists the offending (admin_id, name) pairs rather than renaming anyone's group. meshbay.org checked clean. - `create_group` trims the name, rejects blank (422) and an owner-scoped case-insensitive clash (409), with an IntegrityError backstop for the race, and returns `owner_username`. - `owner_username` added to `/v1/groups/mine`, `GET /v1/groups` (local rows), `POST /v1/groups/{id}/join`, `GET /v1/admin/groups`. SPA: - new `static/group-name.js` — `` renders the name with the `@owner` handle on a smaller grey line under it. - used in the sidebar, the group-page header, Explore cards, the Admin groups table, and cross-group Search (via a widened `cacheGroupIndex` carrying the owner). Delete/leave confirmations show `name@owner` inline. - federated Explore rows show `@` instead of an account. Design record and the locked decisions: ~/next/groupnames.md (out of repo). MNP unchanged. Tests: test_group_name_unique.py, test_group_name_migration.py. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_018gKJ85aZyvEwarXMFzFEwi --- packages/meshbay-hub/src/meshbay_hub/static/app.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'packages/meshbay-hub/src/meshbay_hub/static/app.js') diff --git a/packages/meshbay-hub/src/meshbay_hub/static/app.js b/packages/meshbay-hub/src/meshbay_hub/static/app.js index 9164a4d..18f34fc 100644 --- a/packages/meshbay-hub/src/meshbay_hub/static/app.js +++ b/packages/meshbay-hub/src/meshbay_hub/static/app.js @@ -16,6 +16,7 @@ import { refreshAccessToken, } from './hub-client.js'; import { GroupPage } from './group-page.js'; +import { GroupName } from './group-name.js'; import { APPS } from './apps.js'; // ── Constants ──────────────────────────────────────────────────────────────── @@ -352,7 +353,9 @@ function Sidebar({ groups, presence, indexProgressPct, route, menuOpen, role, ha - ${g.name} + + <${GroupName} name=${g.name} owner=${g.owner_username} /> + `; }) @@ -699,13 +702,11 @@ function ExplorePage({ token, myGroupIds, allowPublicGroups = true }) { ${groups.map(g => html`
-

${g.name}

+

<${GroupName} name=${g.name} + owner=${g.source && g.source !== 'local' ? g.source : g.owner_username} />

${g.description && html`

${g.description}

`}
${g.join_policy} - ${g.source && g.source !== 'local' && html` - ${' '}${g.source} - `} ${' '} ${isMember(g.id) ? html`${t('explore.member')}` @@ -1331,7 +1332,7 @@ function SearchPage() { if (e.name.toLowerCase().includes(term) || (e.path && e.path.toLowerCase().includes(term))) { hits.push({ ...e, groupId: idx.groupId, groupName: idx.groupName, - syncedAt: idx.cachedAt }); + groupOwner: idx.groupOwner, syncedAt: idx.cachedAt }); } } } @@ -1376,7 +1377,9 @@ function SearchPage() { ${formatSize(r.size)} - ${r.groupName || r.groupId.slice(0, 8)} + ${r.groupName + ? html`<${GroupName} name=${r.groupName} owner=${r.groupOwner} inline=${true} />` + : r.groupId.slice(0, 8)} ${r.syncedAt && html`
${t('search.synced', { ago: formatAgo(r.syncedAt) })} @@ -2175,7 +2178,7 @@ function AdminPage({ token, role }) { ${groups.length === 0 && html`${t('admin.no_groups')}`} ${groups.map(g => html` - ${g.name} + <${GroupName} name=${g.name} owner=${g.owner_username} /> ${g.visibility} ${g.member_count} ${g.status} -- cgit v1.2.3