From 12dd9320ff7dd95511c0c2012d60a808210c5839 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 24 Nov 2026 08:35:52 +0000 Subject: [PATCH] :books: Separate dashboard import and viewer guidance Organize frontend notes by task and correct viewer validation and dashboard message topic details to match the current implementation. AI-assisted-by: gpt-6.1-terra --- .serena/memories/frontend/core.md | 2 +- .../frontend/dashboard-viewer-subtleties.md | 22 ------------------- .serena/memories/frontend/dashboard.md | 7 ++++++ .serena/memories/frontend/imports.md | 7 ++++++ .serena/memories/frontend/viewer.md | 7 ++++++ 5 files changed, 22 insertions(+), 23 deletions(-) delete mode 100644 .serena/memories/frontend/dashboard-viewer-subtleties.md create mode 100644 .serena/memories/frontend/dashboard.md create mode 100644 .serena/memories/frontend/imports.md create mode 100644 .serena/memories/frontend/viewer.md diff --git a/.serena/memories/frontend/core.md b/.serena/memories/frontend/core.md index 5deb00ebf5..53c343b99c 100644 --- a/.serena/memories/frontend/core.md +++ b/.serena/memories/frontend/core.md @@ -23,7 +23,7 @@ Start at `app.main.ui` for Rumext components, `app.main.data` for Potok events, - Authentication event sources and invitations: `mem:frontend/auth-events`. - Error boundary, transport errors and reports: `mem:frontend/error-reporting`. - WebSocket lifetime, membership revocation, and job progress: `mem:frontend/websocket-notifications`. -- Dashboard and viewer behavior: `mem:frontend/dashboard-viewer-subtleties`. +- Dashboard state and invitation controls: `mem:frontend/dashboard`. Import analysis and uploads: `mem:frontend/imports`. Viewer routes and bundle resolution: `mem:frontend/viewer`. ## Testing and diagnosis diff --git a/.serena/memories/frontend/dashboard-viewer-subtleties.md b/.serena/memories/frontend/dashboard-viewer-subtleties.md deleted file mode 100644 index 99b46f9ee2..0000000000 --- a/.serena/memories/frontend/dashboard-viewer-subtleties.md +++ /dev/null @@ -1,22 +0,0 @@ -# Frontend Dashboard and Viewer Subtleties - -## Dashboard - -- Dashboard initialization fetches projects and fonts for the team, then listens to websocket messages only for global topic `uuid/zero` or the current profile id. -- Project fetch replaces each project map completely instead of merging, so fields such as `deleted-at` can disappear cleanly. -- Dashboard file/project mutations are often optimistic local updates with fire-and-forget RPC watchers. Bulk permanent delete/restore paths use SSE progress and progress notifications. -- The v3 format carries no size per file: the size of one is the sum of its own entries plus the `objects/` its media and thumbnail metadata reference, the only link between a file and that shared storage. -- Those metadata entries are read one at a time on purpose: a container holds thousands and every read opens its own decompression stream, which makes Chromium fail the analysis — zip.js then masks the cause behind a `Cannot close a ERRORED writable stream` — while Firefox tolerates it. Do not turn this back into a parallel read. The read is best-effort: a reference that cannot be read leaves that file without size, never the whole package. -- The `:error` of an import entry is user-facing text, never an i18n key. The legacy SSE import stays in the backend for other clients. -- Import entries from local files or downloaded onboarding templates retain the original `File` or `Blob` through analysis. The chunked upload uses it directly rather than fetching the `blob:` URL again. Template links that supply only a URL still use the fetch path. -- File creation/duplication strips file `:data` before putting file summaries into dashboard state. -- The pending invitations are a team-admin only list (backend `:is-admin` already includes the owner). The dashboard hides the invitations entry from the header tabs and the team-options dropdown for non-admins, `invitations-section-content` keys the section on `:is-admin`, and `fetch-invitations` answers `insufficient-permissions` by emitting `invitations-fetched` with `[]`, so a demoted admin does not keep the cached emails and the header does not paint the invite button from a stale list. The organization `send-invitations` policy (`can-invite?`) does not gate the list, but it gates every action on it: inviting (header and empty-state buttons render disabled with the `dashboard.invite-profile-disabled` tooltip), the role selector (read-only label), row selection (so resend and delete never show) and copy link (`invitation-link-copyable?`). The backend enforces the same rule. - -## Viewer - -- `app.main.ui.ui` parses the viewer's `file-id` query param with `uuid/parse*`, so a missing or malformed id arrives as nil. `viewer-page*` calls `check-file-id!` (same namespace) during render, before mounting `viewer*`: it raises `ex/raise :type :not-found :code :missing-file-id`, which the error boundary turns into the not-found page. Without the guard the `dv/initialize` assertion fails on the nil file-id and the user gets an internal-error page. Test: `frontend-tests.ui.viewer-test/check-file-id-raises-not-found-for-invalid-file-id`. -- Viewer initialization sets `:current-file-id`, `:current-share-id`, and `:viewer-local`, then fetches the view-only bundle. Comment threads are fetched only for logged-in users. -- Viewer bundle fetch sends the full supported feature set because anonymous shared viewers may not know team-enabled features. -- View-only bundles can contain pointer values in `:pages-index` and file data (membership bundles; share-link bundles carry components inline and deny their fragment). Viewer resolves those fragments with `:get-file-fragment` before storing the bundle, through `app.main.features.pointer-map/resolve-pointer` (share-link scoped; the workspace and library loaders use `resolve-file`, which resolves the same two levels). Both fail loudly: a fragment that cannot be resolved rejects the stream and is logged with file id and fragment id instead of silently dropping the page. -- `bundle-fetched` indexes pages and precomputes viewer frames/all-frames, stores libraries/users/thumbnails/permissions under `:viewer`, then navigates to frame id, query index, or auto-selected frame. -- Viewer zoom and interaction mode changes update both `:viewer-local` and the `:viewer` route query params. `update-zoom-querystring` guards with a query-param comparison (`not= current expected`) and uses `::rt/replace`; without that guard the load sequence (`bundle-fetched` → `zoom-to-fill` → `update-zoom-querystring` → `rt/nav`) re-runs on every navigation and crashes with React "maximum update depth exceeded" (2.18.0-RC5 regression, fixed in `31b73460c3`; regression test: `bundle-fetched-with-zoom-fill-url-does-not-navigate`). diff --git a/.serena/memories/frontend/dashboard.md b/.serena/memories/frontend/dashboard.md new file mode 100644 index 0000000000..a28954100f --- /dev/null +++ b/.serena/memories/frontend/dashboard.md @@ -0,0 +1,7 @@ +# Frontend dashboard + +- Start at `app.main.data.dashboard`, `app.main.data.team` and `app.main.ui.dashboard.team`. Dashboard initialization fetches projects and fonts, subscribes to the team and processes WebSocket messages for the global, profile, team and present organization topics. +- Project fetch replaces each project map rather than merging, so a removed `deleted-at` does not linger. File summaries from creation or duplication omit `:data`. Mutations can be optimistic; bulk permanent deletion and restoration use SSE progress. +- Pending invitations are visible only to team admins, including owners. On `insufficient-permissions`, `fetch-invitations` clears the cached list so a demoted admin cannot keep seeing email addresses or invitation controls. +- The organization send-invitations policy does not gate listing, but gates inviting, role changes, selection, resend, deletion and link copying. Owner invitation links additionally require the team owner. Backend permission boundaries are in `mem:backend/permissions`. +- Import analysis and uploads are `mem:frontend/imports`; the separate viewer is `mem:frontend/viewer`. diff --git a/.serena/memories/frontend/imports.md b/.serena/memories/frontend/imports.md new file mode 100644 index 0000000000..99a9258450 --- /dev/null +++ b/.serena/memories/frontend/imports.md @@ -0,0 +1,7 @@ +# Frontend imports + +- Start at `app.main.data.imports`, `app.main.data.uploads` and `app.main.ui.dashboard.import`. Backend import formats, jobs and permission revalidation are in `mem:backend/binfile`. +- A v3 package has no per-file size in its manifest. Compute it from each file's entries plus the shared `objects/` referenced by its media and thumbnail metadata. A reference that cannot be read leaves that file's size unknown, not the whole package invalid. +- Read media and thumbnail metadata sequentially: each read opens a decompression stream, and parallel reads for large packages can exhaust Chromium. zip.js can mask the underlying error with `Cannot close a ERRORED writable stream`. +- Keep the original `File` or `Blob` from local imports and downloaded templates through analysis, then upload it in chunks without re-fetching the `blob:` URL. Templates with only a URL use the fetch path. +- An import entry's `:error` is already user-facing text, not an i18n key. The legacy SSE import remains on the backend for other clients. diff --git a/.serena/memories/frontend/viewer.md b/.serena/memories/frontend/viewer.md new file mode 100644 index 0000000000..646892dab6 --- /dev/null +++ b/.serena/memories/frontend/viewer.md @@ -0,0 +1,7 @@ +# Frontend viewer + +- Start at `app.main.ui` for route parsing, `app.main.ui.viewer` and `app.main.data.viewer`. The route parses `file-id` with `uuid/parse*`; `viewer-page*` raises `:not-found` / `:missing-file-id` in an effect for invalid IDs and mounts `viewer*` only for a UUID, avoiding initialization with nil. +- Viewer initialization fetches a view-only bundle and sends all supported features because an anonymous viewer may not know team-enabled features. Comment threads are fetched only for logged-in users. +- The viewer resolves pointer values in file data and `:pages-index` through `app.main.features.pointer-map/resolve-pointer` with share-link scope before storing the bundle. Membership and share-link bundles have different fragment permissions; an unresolvable fragment rejects rather than silently dropping a page. See `mem:backend/permissions`. +- `bundle-fetched` indexes pages, precomputes frames and navigates to the requested or selected frame. Zoom and interaction mode also live in route query params. `update-zoom-querystring` must compare current and expected zoom before replacing the route: otherwise loading and navigation can loop into React's maximum update depth error. +- Dashboard behavior is `mem:frontend/dashboard`; shared routing rules are `mem:frontend/routing-app-shell-subtleties`.