diff --git a/docs/commons-files-desk.md b/docs/commons-files-desk.md index 20ad243e..d9152065 100644 --- a/docs/commons-files-desk.md +++ b/docs/commons-files-desk.md @@ -118,9 +118,9 @@ Under A the paused service is not built, and most of its list disappears: ## Cuts under A -Status 2026-11-14 (dev da822e9e plus the size-refusal cut): built: folders by album title path with navigation and breadcrumb (#147), pagination (#148), version folding (#149), add-to-album with named refusals (#150), Stop for a send in flight, replaces loops shown, freshest last event on add (#151), and the pre-send size refusal: a file larger than the server's `m.upload.size` is named and left unsent before any upload or album root, and a server stating no cap refuses nothing. The Commons entry row is built (item 1): `useCommons` in `MediaRow.tsx` finds the room by the carried id `@rooms.file_zones.commons` in the root Space's stewardships, else by the alias `#commons:`, through `lookupZoneRoom` (the one lookup `lookupMediaRoom` also uses); `EstateNavigator` shows it above the tiers as a Commons link when joined, a join row when invited or not joined, and nothing when the room is absent, the lookup failed or is out. It is gated on the existing `fileZoneShare.enabled`, not a new `filesDesk.enabled` flag. `isFileZone` also accepts the room holding `#commons:` as its alias, so the album view and ShareSet work there without a `fileZoneRooms` entry or the create type. +Status 2026-11-14 (dev da822e9e plus the size-refusal cut): built: folders by album title path with navigation and breadcrumb (#147), pagination (#148), version folding (#149), add-to-album with named refusals (#150), Stop for a send in flight, replaces loops shown, freshest last event on add (#151), and the pre-send size refusal: a file larger than the server's `m.upload.size` is named and left unsent before any upload or album root, and a server stating no cap refuses nothing. The Commons entry row is built (item 1): `useCommons` in `MediaRow.tsx` finds the room by the alias `#commons:` (provisioning records no id for it), through `lookupZoneRoom` (the one lookup `lookupMediaRoom` also uses); `EstateNavigator` shows it above the tiers as a Commons link when joined, a join row when invited or not joined, and nothing when the room is absent, the lookup failed or is out. It is gated on the existing `fileZoneShare.enabled`, not a new `filesDesk.enabled` flag. The album view and ShareSet work there because provisioning creates the Commons with the `org.gamecult.file_zone` create type. Members can share only once the room's power levels let them post: provisioning gives the poster level to the Minds alone. -1. **Commons entry**: a Commons row in the navigator (like `MediaRow`, found by alias or carried id), opening the room's album view. Flagged, no new data layer. +1. **Commons entry**: a Commons row in the navigator (like `MediaRow`, found by alias), opening the room's album view. Flagged, no new data layer. 2. **Pagination** of albums and files in `useAlbums` (done, PR #148). 3. **Folders by title path** and the album list grouped by it. 4. **Versions**: read `org.gamecult.publish.replaces`, show the latest of a chain with the earlier versions folded under it (done, PR #149). diff --git a/src/app/features/albums/isFileZone.test.ts b/src/app/features/albums/isFileZone.test.ts index 23cdef21..0e55269f 100644 --- a/src/app/features/albums/isFileZone.test.ts +++ b/src/app/features/albums/isFileZone.test.ts @@ -21,10 +21,4 @@ describe('isFileZone', () => { it('is false when only another room is configured', () => { expect(isFileZone(room, { fileZoneRooms: ['!g:x', '#g:x'] })).toBe(false); }); - it('is true for the Commons alias on the home server, and only there', () => { - const c = { roomId: '!c:x', aliases: ['#commons:x'] }; - expect(isFileZone({ ...c, server: 'x' }, {})).toBe(true); - expect(isFileZone({ ...c, server: 'y' }, {})).toBe(false); - expect(isFileZone(c, {})).toBe(false); - }); }); diff --git a/src/app/features/albums/isFileZone.ts b/src/app/features/albums/isFileZone.ts index fec253ab..071ef17b 100644 --- a/src/app/features/albums/isFileZone.ts +++ b/src/app/features/albums/isFileZone.ts @@ -1,21 +1,14 @@ export const FILE_ZONE_TYPE = 'org.gamecult.file_zone'; -/** The shared Commons room's key in the carried `file_zones` map, and its alias on the home server. */ -export const COMMONS_KEY = 'commons'; -export const commonsAlias = (server: string): string => `#${COMMONS_KEY}:${server}`; - export type FileZoneRoom = { roomId: string; /** Canonical and alternative aliases. */ aliases?: string[]; /** The `type` of the room's m.room.create content. */ createType?: string; - /** The home server name; the Commons alias on it makes the room a file zone. */ - server?: string; }; -/** A room is the file zone when its create type says so, it holds the Commons alias on the home server, or the client config lists it. */ +/** A room is the file zone when its create type says so or the client config lists it. */ export const isFileZone = (room: FileZoneRoom, config: { fileZoneRooms?: string[] }): boolean => room.createType === FILE_ZONE_TYPE || - (!!room.server && !!room.aliases?.includes(commonsAlias(room.server))) || !!config.fileZoneRooms?.some((r) => r === room.roomId || room.aliases?.includes(r)); diff --git a/src/app/features/albums/useAlbums.ts b/src/app/features/albums/useAlbums.ts index 514b6c19..13c199ec 100644 --- a/src/app/features/albums/useAlbums.ts +++ b/src/app/features/albums/useAlbums.ts @@ -15,7 +15,6 @@ const REFRESH_MS = 30_000; /** True when the room is the file zone: by its create type, or listed in the client config. */ export const useIsFileZone = (room: Room): boolean => { const config = useClientConfig(); - const server = useMatrixClient().getDomain() ?? undefined; // Subscribes to alias changes (alt aliases live in the same event). useStateEvent(room, StateEvent.RoomCanonicalAlias); const createType = room.currentState.getStateEvents('m.room.create', '')?.getContent().type; @@ -24,7 +23,6 @@ export const useIsFileZone = (room: Room): boolean => { roomId: room.roomId, aliases: [room.getCanonicalAlias(), ...room.getAltAliases()].filter((a): a is string => !!a), createType, - server, }, config ); diff --git a/src/app/features/estate/MediaRow.tsx b/src/app/features/estate/MediaRow.tsx index 2672fc16..7d64497a 100644 --- a/src/app/features/estate/MediaRow.tsx +++ b/src/app/features/estate/MediaRow.tsx @@ -5,7 +5,7 @@ import { Avatar, Box, Icon, Icons, Text } from 'folds'; import { NavGutter, NavItem, NavItemContent, NavLink } from '../../components/nav'; import { NAV_ROOM_ICON_REST_OPACITY, NavLabel } from '../../components/nav/styles.css'; import { EstateRoom } from './buildEstate'; -import { COMMONS_KEY, commonsAlias, isFileZone } from '../albums/isFileZone'; +import { isFileZone } from '../albums/isFileZone'; import { useClientConfig } from '../../hooks/useClientConfig'; import { MINDS } from '../../components/message/pose/poses'; import { useMatrixClient } from '../../hooks/useMatrixClient'; @@ -15,6 +15,7 @@ import { useEstateRootId } from './useEstate'; import { STEWARDSHIPS_KEY, MediaRow as MediaRowState, + commonsAlias, commonsRow, lookupMediaRoom, lookupZoneRoom, @@ -111,20 +112,14 @@ export const useMindMedia = (mind: string, rooms: readonly EstateRoom[]): MediaR /** The shared Commons room as the navigator sees it right now: undefined means no row. Dark unless fileZoneShare.enabled. */ export const useCommons = (): EstateRoom | undefined => { const mx = useMatrixClient(); - const { rootId } = useEstateRootId(); const joined = useAtomValue(allRoomsAtom); const invited = useAtomValue(allInvitesAtom); const enabled = !!useClientConfig().fileZoneShare?.enabled; const server = mx.getDomain() ?? ''; - const carried = mediaRoomIdFromStewardships( - rootId - ? mx.getRoom(rootId)?.currentState.getStateEvents(STEWARDSHIPS_KEY, '')?.getContent() - : undefined, - COMMONS_KEY - ); + // Provisioning records no id for the Commons (only per-Mind zones under @rooms.file_zones): the alias is the one way in. const lookup = useQuery({ - queryKey: ['commons-room', server, carried], - queryFn: () => lookupZoneRoom(mx, commonsAlias(server), server, carried), + queryKey: ['commons-room', server], + queryFn: () => lookupZoneRoom(mx, commonsAlias(server), server), staleTime: 60_000, enabled, }); diff --git a/src/app/features/estate/mediaRoom.test.ts b/src/app/features/estate/mediaRoom.test.ts index 6f259e38..45e912e0 100644 --- a/src/app/features/estate/mediaRoom.test.ts +++ b/src/app/features/estate/mediaRoom.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest'; -import { commonsAlias, COMMONS_KEY } from '../albums/isFileZone'; import { + commonsAlias, commonsRow, lookupMediaRoom, lookupZoneRoom, @@ -151,19 +151,6 @@ describe('the Commons row', () => { }); }); - it('is found by a carried id under file_zones.commons, asking nobody', async () => { - const { mx, asked } = clientFor(async () => { - throw new Error('must not be asked'); - }); - const carried = mediaRoomIdFromStewardships( - { '@rooms': { file_zones: { [COMMONS_KEY]: '!c:gamecult.org' } } }, - COMMONS_KEY - ); - const lookup = await lookupZoneRoom(mx, commonsAlias('gamecult.org'), 'gamecult.org', carried); - expect(asked).toEqual([]); - expect(commonsRow(true, lookup, none)).toMatchObject({ roomId: '!c:gamecult.org' }); - }); - it('shows no row when the room is absent, the lookup failed or is still out', async () => { const missing = await lookupZoneRoom( clientFor(async () => { diff --git a/src/app/features/estate/mediaRoom.ts b/src/app/features/estate/mediaRoom.ts index 69acd560..2e60fe3a 100644 --- a/src/app/features/estate/mediaRoom.ts +++ b/src/app/features/estate/mediaRoom.ts @@ -13,6 +13,9 @@ export const ROOMS_KEY = '@rooms'; export const mediaAlias = (mind: string, server: string): string => `#${mind}-files:${server}`; +/** The shared Commons room's alias (gamecult-ops synapse-accounts-hand-managed.py COMMONS_ALIAS). */ +export const commonsAlias = (server: string): string => `#commons:${server}`; + /** * The room id the stewardships state names for a Mind's media room, under `@rooms.file_zones[]`. * The state's mind-to-repos lists are not read here.