Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
client/content manager: add an overview treemap
Adorian Doran2e0028912eb5
diff --git a/apps/client/package.json b/apps/client/package.jsonindex 55ea6d8611..1835b4d2f9 100644--- a/apps/client/package.json+++ b/apps/client/package.json@@ -48,6 +48,7 @@"boxicons": "2.1.4","clsx": "2.1.1","color": "5.0.3",+ "d3-hierarchy": "3.1.2","diff": "9.0.0","dompurify": "3.4.12","draggabilly": "3.0.0",@@ -82,6 +83,7 @@"@codecov/vite-plugin": "2.0.1","@prefresh/vite": "3.0.1","@types/bootstrap": "5.2.11",+ "@types/d3-hierarchy": "3.1.7","@types/jquery": "4.0.1","@types/leaflet": "1.9.21","@types/leaflet-gpx": "1.3.8",diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex a656785079..6c93c16fd4 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -2664,7 +2664,11 @@"section_space_usage": "Space Usage"},"space_usage": {- "coming_soon": "Space Usage is coming soon."+ "loading": "Measuring space usage...",+ "other_notes": "Other notes",+ "deleted_notes": "Deleted notes",+ "status_total": "Total: {{size}}",+ "status_deleted": "Deleted notes: {{size}}"},"note_language": {"not_set": "No language set",diff --git a/apps/client/src/widgets/react/charts/Treemap.css b/apps/client/src/widgets/react/charts/Treemap.cssnew file mode 100644index 0000000000..4839243efa--- /dev/null+++ b/apps/client/src/widgets/react/charts/Treemap.css@@ -0,0 +1,29 @@+.treemap {+ position: relative;+ width: 100%;+ height: 100%;+ overflow: hidden;++ .treemap-cell {+ position: absolute;+ border-radius: 4px;+ background: var(--accented-background-color);+ cursor: pointer;+ }++ /* The group tint stays a mix into the theme's own surface, so the map keeps a coherent look+ under light and dark themes alike. */+ .treemap-cell.treemap-colored {+ background: color-mix(+ in srgb,+ var(--accented-background-color) 55%,+ hsl(var(--treemap-hue) 65% 55%) 45%+ );+ }++ .treemap-cell:hover {+ outline: 2px solid var(--main-text-color);+ outline-offset: -1px;+ z-index: 1;+ }+}diff --git a/apps/client/src/widgets/react/charts/Treemap.tsx b/apps/client/src/widgets/react/charts/Treemap.tsxnew file mode 100644index 0000000000..61f6240f44--- /dev/null+++ b/apps/client/src/widgets/react/charts/Treemap.tsx@@ -0,0 +1,107 @@+import "./Treemap.css";++import clsx from "clsx";+import { hierarchy, treemap, treemapSquarify } from "d3-hierarchy";+import { useMemo, useRef } from "preact/hooks";++import { useElementSize } from "../hooks";++export interface TreemapItem<T = unknown> {+ /** Stable identity for reconciliation; unique across the whole tree. */+ id: string;+ /** Weight of a leaf. Branch items derive their weight from their children and leave this unset. */+ value?: number;+ children?: TreemapItem<T>[];+ /**+ * Categorical tint (0–359): cells belonging together share the hue. Absent = plain surface,+ * for cells that stand apart from every group.+ */+ hue?: number;+ /** Extra classes on the cell, for special entries the consumer styles itself. */+ className?: string;+ /**+ * Attributes sprinkled onto the cell element — the cells carry no text of their own, so this+ * is where identity comes from: `data-href` opts into the note tooltip, `title` gives plain+ * cells a native one.+ */+ attributes?: Record<string, string>;+ /** The consumer's payload, handed back on click. */+ data?: T;+}++interface TreemapProps<T> {+ root: TreemapItem<T>;+ onItemClick?: (item: TreemapItem<T>) => void;+ className?: string;+}++const CELL_GAP = 3;++/**+ * A treemap over an arbitrary {@link TreemapItem} hierarchy, sized to fill its container and+ * re-laid out whenever the container resizes.+ *+ * Only the leaves are drawn, and each cell is nothing but its color: branch items shape the layout+ * — their leaves stay clustered — and lend their group a shared {@link TreemapItem.hue}, but paint+ * no cell of their own, so nothing sits between the pointer and the leaf it is over. Identity is+ * explored by hovering, via the {@link TreemapItem.attributes} tooltips.+ *+ * d3 computes the geometry only; the cells are plain absolutely-positioned divs so hover and+ * tooltips behave like everywhere else in the app. The hue tint is mixed into the theme's own+ * surface color, which keeps the map coherent under any user theme.+ */+export default function Treemap<T>({ root, onItemClick, className }: TreemapProps<T>) {+ const containerRef = useRef<HTMLDivElement>(null);+ const size = useElementSize(containerRef);+ const width = Math.floor(size?.width ?? 0);+ const height = Math.floor(size?.height ?? 0);++ const cells = useMemo(() => {+ if (width < 10 || height < 10) {+ return [];+ }++ const weighted = hierarchy(root)+ .sum((item) => item.children?.length ? 0 : Math.max(item.value ?? 0, 0))+ // Larger cells first within each group; the hierarchy itself keeps related notes together.+ .sort((a, b) => (b.value ?? 0) - (a.value ?? 0));++ const layout = treemap<TreemapItem<T>>()+ .tile(treemapSquarify)+ .size([ width, height ])+ .paddingInner(CELL_GAP);++ return layout(weighted).leaves().filter((leaf) => leaf.depth > 0);+ }, [ root, width, height ]);++ return (+ <div ref={containerRef} className={clsx("treemap", className)}>+ {cells.map((cell) => {+ const item = cell.data;+ const cellWidth = cell.x1 - cell.x0;+ const cellHeight = cell.y1 - cell.y0;++ if (cellWidth < 1 || cellHeight < 1) {+ return null;+ }++ return (+ <div+ key={item.id}+ className={clsx("treemap-cell", item.hue !== undefined && "treemap-colored", item.className)}+ // Geometry and tint are computed per layout run, so they cannot live in a stylesheet.+ style={{+ left: cell.x0,+ top: cell.y0,+ width: cellWidth,+ height: cellHeight,+ ...(item.hue !== undefined && { "--treemap-hue": String(item.hue) })+ }}+ onClick={onItemClick && (() => onItemClick(item))}+ {...item.attributes}+ />+ );+ })}+ </div>+ );+}diff --git a/apps/client/src/widgets/type_widgets/options/content_manager/space_usage.tsx b/apps/client/src/widgets/type_widgets/options/content_manager/space_usage.tsxdeleted file mode 100644index d6ef429b53..0000000000--- a/apps/client/src/widgets/type_widgets/options/content_manager/space_usage.tsx+++ /dev/null@@ -1,14 +0,0 @@-import { t } from "../../../../services/i18n";-import NoItems from "../../../react/NoItems";-import OptionsPageHeader from "../components/OptionsPageHeader";-import type { ContentManagerSectionProps } from "./index";--/** Placeholder section until the Space Usage views (overview treemap, browse charts) land. */-export default function SpaceUsage({ sectionSwitcher }: ContentManagerSectionProps) {- return (- <>- <OptionsPageHeader actions={sectionSwitcher} />- <NoItems icon="bx bx-pie-chart-alt-2" text={t("space_usage.coming_soon")} />- </>- );-}diff --git a/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/index.css b/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/index.cssnew file mode 100644index 0000000000..af99987246--- /dev/null+++ b/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/index.css@@ -0,0 +1,64 @@+/* The section replaces the page's scrolling with a viewport-filling layout: flex chains from the+ scroll container down to the section, in a tab (.scrolling-container) and in the settings dialog+ (.modal-body) alike. Active Content keeps the default scrolling page — these rules only bite+ while the Space Usage section is mounted. */+.scrolling-container:has(.space-usage-section),+.options-dialog .modal-body:has(.space-usage-section) {+ display: flex;+ flex-direction: column;+ overflow: hidden;+}++.note-detail:has(.space-usage-section),+.note-detail:has(.space-usage-section) .note-detail-content-widget,+.note-detail:has(.space-usage-section) .note-detail-content-widget-content {+ display: flex;+ flex: 1 1 auto;+ flex-direction: column;+ min-height: 0;+}++.space-usage-section {+ display: flex;+ flex: 1 1 auto;+ flex-direction: column;+ min-height: 0;++ .space-usage-overview {+ flex: 1 1 auto;+ min-height: 0;+ padding-block: 8px;+ }++ .space-usage-status {+ display: flex;+ flex: 0 0 auto;+ gap: 2em;+ border-top: 1px solid var(--main-border-color);+ padding-block: 6px;+ font-size: 0.85em;+ }++ .space-usage-loading {+ opacity: 0.7;+ }+}++/* The bucket cells stand for no single note: identity comes from the border and texture rather+ than a hue (user themes make any fixed palette unreliable), and they respond to nothing. */+.space-usage-overview {+ .treemap-cell-other,+ .treemap-cell-deleted {+ border: 1px dashed var(--main-border-color);+ background: transparent;+ cursor: default;+ }++ .treemap-cell-deleted {+ background: repeating-linear-gradient(+ -45deg,+ var(--accented-background-color) 0 5px,+ transparent 5px 10px+ );+ }+}diff --git a/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/index.tsx b/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/index.tsxnew file mode 100644index 0000000000..8d404e1739--- /dev/null+++ b/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/index.tsx@@ -0,0 +1,73 @@+import "./index.css";++import type { SpaceUsageOverviewResponse } from "@triliumnext/commons";+import { useCallback, useEffect, useMemo, useRef, useState } from "preact/hooks";++import debounce from "../../../../../services/debounce";+import { t } from "../../../../../services/i18n";+import server from "../../../../../services/server";+import { formatSize } from "../../../../../services/utils";+import { useTriliumEvent } from "../../../../react/hooks";+import OptionsPageHeader from "../../components/OptionsPageHeader";+import type { ContentManagerSectionProps } from "../index";+import Overview from "./overview";++/** Matches the server default; the treemap could not label more cells anyway. */+const OVERVIEW_LIMIT = 500;++/** One reload per burst — a subtree delete floods entity changes. */+const REFRESH_DEBOUNCE_MS = 1000;++export default function SpaceUsage({ sectionSwitcher }: ContentManagerSectionProps) {+ const overview = useOverview();++ return (+ <div className="space-usage-section">+ <OptionsPageHeader actions={sectionSwitcher} />+ {overview ? (+ <>+ <Overview overview={overview} />+ <footer className="space-usage-status">+ <span>{t("space_usage.status_total", { size: formatSize(overview.total.size) })}</span>+ <span>{t("space_usage.status_deleted", { size: formatSize(overview.deletedNotes.size) })}</span>+ </footer>+ </>+ ) : (+ <p className="space-usage-loading">{t("space_usage.loading")}</p>+ )}+ </div>+ );+}++/**+ * Fetches the overview and keeps it current: content changes anywhere — deletes, moves, uploads —+ * shift the sizes, so any note/branch/attachment change schedules one debounced reload. `null`+ * until the first response, so the loading state is distinguishable from an empty database.+ */+function useOverview() {+ const [ overview, setOverview ] = useState<SpaceUsageOverviewResponse | null>(null);+ const latestRequest = useRef(0);++ const refresh = useCallback(async () => {+ const requestId = ++latestRequest.current;+ const response = await server.get<SpaceUsageOverviewResponse>(`space-usage/overview?limit=${OVERVIEW_LIMIT}`);++ // A stale response must not repaint over a newer one.+ if (requestId === latestRequest.current) {+ setOverview(response);+ }+ }, []);++ useEffect(() => { void refresh(); }, [ refresh ]);++ const delayedRefresh = useMemo(() => debounce(() => void refresh(), REFRESH_DEBOUNCE_MS), [ refresh ]);+ useEffect(() => () => delayedRefresh.clear(), [ delayedRefresh ]);++ useTriliumEvent("entitiesReloaded", ({ loadResults }) => {+ if (loadResults.getNoteIds().length || loadResults.getBranchRows().length || loadResults.getAttachmentRows().length) {+ delayedRefresh();+ }+ });++ return overview;+}diff --git a/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/overview.tsx b/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/overview.tsxnew file mode 100644index 0000000000..9da188d498--- /dev/null+++ b/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/overview.tsx@@ -0,0 +1,39 @@+import type { SpaceUsageOverviewResponse } from "@triliumnext/commons";+import { useMemo } from "preact/hooks";++import appContext from "../../../../../components/app_context";+import { t } from "../../../../../services/i18n";+import Treemap, { type TreemapItem } from "../../../../react/charts/Treemap";+import { buildOverviewModel, type OverviewCell } from "./overview_model";++/** The treemap over the whole database: every large note at its tree location. */+export default function Overview({ overview }: { overview: SpaceUsageOverviewResponse }) {+ const model = useMemo(() => buildOverviewModel(overview, {+ otherNotesLabel: t("space_usage.other_notes"),+ deletedNotesLabel: t("space_usage.deleted_notes"),+ includeRevisions: false+ }), [ overview ]);++ return (+ <div className="space-usage-overview">+ <Treemap<OverviewCell> root={model} onItemClick={openCellNote} />+ </div>+ );+}++/**+ * Opens the clicked note in a new tab, leaving the settings page in place. The bucket cells carry+ * no note and do nothing.+ */+function openCellNote(item: TreemapItem<OverviewCell>) {+ const noteId = item.data?.noteId;++ if (!noteId) {+ return;+ }++ void appContext.tabManager.openContextWithNote(noteId, {+ activate: true,+ hoistedNoteId: appContext.tabManager.getActiveContext()?.hoistedNoteId ?? null+ });+}diff --git a/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/overview_model.spec.ts b/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/overview_model.spec.tsnew file mode 100644index 0000000000..76824441b6--- /dev/null+++ b/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/overview_model.spec.ts@@ -0,0 +1,139 @@+import type { SpaceUsageOverviewNote, SpaceUsageOverviewResponse } from "@triliumnext/commons";+import { describe, expect, it } from "vitest";++import type { TreemapItem } from "../../../../react/charts/Treemap";+import { buildOverviewModel, hueOf, type OverviewCell } from "./overview_model";++function entry(noteId: string, notePath: string[], sizes: Partial<SpaceUsageOverviewNote> = {}): SpaceUsageOverviewNote {+ return { noteId, notePath, ownSize: 0, attachmentsSize: 0, revisionsSize: 0, ...sizes };+}++function response(notes: SpaceUsageOverviewNote[], overrides: Partial<SpaceUsageOverviewResponse> = {}): SpaceUsageOverviewResponse {+ return {+ notes,+ otherNotes: { size: 0, revisionsSize: 0, noteCount: 0 },+ hiddenNotes: { size: 0, revisionsSize: 0, noteCount: 0 },+ deletedNotes: { size: 0, noteCount: 0 },+ total: { size: 0, revisionsSize: 0, noteCount: 0 },+ ...overrides+ };+}++function build(overview: SpaceUsageOverviewResponse, includeRevisions = false) {+ return buildOverviewModel(overview, {+ otherNotesLabel: "Other notes",+ deletedNotesLabel: "Deleted notes",+ includeRevisions+ });+}++function childById(parent: TreemapItem<OverviewCell>, id: string) {+ const child = (parent.children ?? []).find((candidate) => candidate.id === id);+ if (!child) throw new Error(`No child '${id}' under '${parent.id}'`);+ return child;+}++describe("buildOverviewModel", () => {+ it("nests entries at their tree location; ancestors shape the layout but carry nothing", () => {+ const model = build(response([+ entry("leaf", [ "folder", "leaf" ], { ownSize: 100, attachmentsSize: 20 })+ ]));++ const folder = childById(model, "folder");+ expect(folder.value).toBeUndefined();+ expect(folder.attributes).toBeUndefined();+ expect(folder.data).toBeUndefined();++ const leaf = childById(folder, "leaf");+ expect(leaf.value).toBe(120);+ expect(leaf.data).toEqual({ noteId: "leaf" });+ expect(leaf.attributes).toEqual({ "data-href": "#root/folder/leaf" });+ });++ it("colors cells by their parent: siblings share a hue, other groups get their own", () => {+ const model = build(response([+ entry("a1", [ "parentA", "a1" ], { ownSize: 1 }),+ entry("a2", [ "parentA", "a2" ], { ownSize: 1 }),+ entry("b1", [ "parentB", "b1" ], { ownSize: 1 }),+ entry("top", [ "top" ], { ownSize: 1 })+ ]));++ const parentA = childById(model, "parentA");+ expect(childById(parentA, "a1").hue).toBe(hueOf("parentA"));+ expect(childById(parentA, "a2").hue).toBe(hueOf("parentA"));+ expect(childById(childById(model, "parentB"), "b1").hue).toBe(hueOf("parentB"));+ expect(childById(model, "top").hue).toBe(hueOf("root"));+ });++ it("gives an entry that is also an ancestor a nested self-cell wearing its children's hue", () => {+ const model = build(response([+ entry("parent", [ "parent" ], { ownSize: 50 }),+ entry("child", [ "parent", "child" ], { ownSize: 10 })+ ]));++ const parent = childById(model, "parent");+ expect(parent.value).toBeUndefined();++ const selfCell = childById(parent, "parent/own");+ expect(selfCell.value).toBe(50);+ expect(selfCell.hue).toBe(hueOf("parent"));+ expect(selfCell.data).toEqual({ noteId: "parent" });+ expect(selfCell.attributes).toEqual({ "data-href": "#root/parent" });+ expect(childById(parent, "child").value).toBe(10);+ });++ it("counts revisions into the weights only when asked to", () => {+ const notes = [ entry("a", [ "a" ], { ownSize: 5, revisionsSize: 7 }) ];+ const buckets = { otherNotes: { size: 30, revisionsSize: 4, noteCount: 9 } };++ const without = build(response(notes, buckets));+ expect(childById(without, "a").value).toBe(5);+ expect(childById(without, "/other-notes").value).toBe(30);++ const withRevisions = build(response(notes, buckets), true);+ expect(childById(withRevisions, "a").value).toBe(12);+ expect(childById(withRevisions, "/other-notes").value).toBe(34);+ });++ it("appends inert bucket cells, identified by a plain title rather than a note tooltip", () => {+ const model = build(response([], {+ otherNotes: { size: 11, revisionsSize: 0, noteCount: 3 },+ deletedNotes: { size: 22, noteCount: 2 }+ }));++ const other = childById(model, "/other-notes");+ expect(other.value).toBe(11);+ expect(other.hue).toBeUndefined();+ expect(other.data).toEqual({});+ expect(other.attributes).toEqual({ title: "Other notes" });++ const deleted = childById(model, "/deleted-notes");+ expect(deleted.value).toBe(22);+ expect(deleted.className).toBe("treemap-cell-deleted");+ expect(deleted.attributes).toEqual({ title: "Deleted notes" });+ });++ it("places an entry for the root itself as a top-level cell", () => {+ const model = build(response([ entry("root", [], { ownSize: 9 }) ]));++ expect(childById(model, "root").value).toBe(9);+ });++ it("leaves a zero-weight entry as an empty cell rather than a zero-sized one", () => {+ const model = build(response([ entry("empty", [ "empty" ]) ]));++ const empty = childById(model, "empty");+ expect(empty.value).toBeUndefined();+ expect(empty.attributes).toBeUndefined();+ });+});++describe("hueOf", () => {+ it("is stable and stays within the hue circle", () => {+ expect(hueOf("someNoteId")).toBe(hueOf("someNoteId"));+ for (const id of [ "", "root", "a", "0123456789abcdef" ]) {+ expect(hueOf(id)).toBeGreaterThanOrEqual(0);+ expect(hueOf(id)).toBeLessThan(360);+ }+ });+});diff --git a/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/overview_model.ts b/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/overview_model.tsnew file mode 100644index 0000000000..9c4d097874--- /dev/null+++ b/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/overview_model.ts@@ -0,0 +1,129 @@+import type { SpaceUsageOverviewNote, SpaceUsageOverviewResponse } from "@triliumnext/commons";++import type { TreemapItem } from "../../../../react/charts/Treemap";++/** What a treemap cell stands for; the bucket cells ("other", "deleted") name no note at all. */+export interface OverviewCell {+ noteId?: string;+}++interface OverviewModelOptions {+ otherNotesLabel: string;+ deletedNotesLabel: string;+ /** Folds revision sizes into each cell's weight. */+ includeRevisions: boolean;+}++/**+ * Arranges the overview entries into the treemap hierarchy: every entry sits at its canonical tree+ * location, pass-through ancestors shaping the layout without drawing anything, so large notes+ * appear near their siblings and share their parent's hue. An entry that is itself an ancestor of+ * other entries keeps its own weight as a nested self-cell inside its area. The "other notes" and+ * "deleted notes" buckets join at the top level as inert cells.+ *+ * The cells carry no text — identity comes from hovering: note cells get the note preview tooltip+ * via `data-href`, the bucket cells a plain `title`.+ */+export function buildOverviewModel(+ overview: SpaceUsageOverviewResponse,+ { otherNotesLabel, deletedNotesLabel, includeRevisions }: OverviewModelOptions+): TreemapItem<OverviewCell> {+ const root: TreemapItem<OverviewCell> = { id: "root", children: [] };+ const nodesByNoteId = new Map<string, TreemapItem<OverviewCell>>();++ const ensureNode = (noteId: string, parent: TreemapItem<OverviewCell>) => {+ const existing = nodesByNoteId.get(noteId);++ if (existing) {+ return existing;+ }++ const node: TreemapItem<OverviewCell> = { id: noteId };+ (parent.children ??= []).push(node);+ nodesByNoteId.set(noteId, node);++ return node;+ };++ const entries: { node: TreemapItem<OverviewCell>, entry: SpaceUsageOverviewNote, path: string[] }[] = [];++ for (const entry of overview.notes) {+ const path = pathOf(entry);+ let parent = root;++ for (const noteId of path) {+ parent = ensureNode(noteId, parent);+ }++ entries.push({ node: parent, entry, path });+ }++ // Weights and looks are assigned only after all entries are placed: whether a note needs a+ // nested self-cell depends on whether some later entry turned it into a group.+ for (const { node, entry, path } of entries) {+ const weight = weightOf(entry, includeRevisions);+ const attributes = { "data-href": `#root/${path.join("/")}` };++ if (weight <= 0) {+ continue;+ }++ if (node.children?.length) {+ node.children.push({+ id: `${entry.noteId}/own`,+ value: weight,+ // The self-cell sits among the note's own children, so it wears their group hue.+ hue: hueOf(entry.noteId),+ data: { noteId: entry.noteId },+ attributes+ });+ } else {+ node.value = weight;+ node.hue = hueOf(path.at(-2) ?? "root");+ node.data = { noteId: entry.noteId };+ node.attributes = attributes;+ }+ }++ root.children?.push(+ {+ id: "/other-notes",+ value: overview.otherNotes.size + (includeRevisions ? overview.otherNotes.revisionsSize : 0),+ className: "treemap-cell-other",+ attributes: { title: otherNotesLabel },+ data: {}+ },+ {+ id: "/deleted-notes",+ value: overview.deletedNotes.size,+ className: "treemap-cell-deleted",+ attributes: { title: deletedNotesLabel },+ data: {}+ }+ );++ return root;+}++/**+ * The tint shared by all cells under one parent: an arbitrary but stable hue hashed from the+ * parent's ID, so the coloring survives reloads and refreshes unchanged.+ */+export function hueOf(noteId: string): number {+ let hash = 5381;++ for (let i = 0; i < noteId.length; i++) {+ hash = ((hash << 5) + hash + noteId.charCodeAt(i)) | 0;+ }++ return Math.abs(hash) % 360;+}++/** The server omits the root from paths, so an entry for the root itself arrives with an empty one. */+function pathOf(entry: SpaceUsageOverviewNote): string[] {+ return entry.notePath.length ? entry.notePath : [ entry.noteId ];+}++function weightOf(entry: SpaceUsageOverviewNote, includeRevisions: boolean) {+ return entry.ownSize + entry.attachmentsSize + (includeRevisions ? entry.revisionsSize : 0);+}diff --git a/packages/trilium-core/src/services/space_usage.ts b/packages/trilium-core/src/services/space_usage.tsindex b1d4f52312..b56166ac6b 100644--- a/packages/trilium-core/src/services/space_usage.ts+++ b/packages/trilium-core/src/services/space_usage.ts@@ -28,7 +28,7 @@ import { getSql } from "./sql/index.js";* exception — it only counts blobs no live entity still uses, i.e. what erasing would reclaim.*/-export const DEFAULT_OVERVIEW_LIMIT = 250;+export const DEFAULT_OVERVIEW_LIMIT = 500;export const MAX_OVERVIEW_LIMIT = 1000;const ROOT_NOTE_ID = "root";diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 9abc44a098..d6fe14fd1c 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -287,6 +287,9 @@ importers:color:specifier: 5.0.3version: 5.0.3+ d3-hierarchy:+ specifier: 3.1.2+ version: 3.1.2diff:specifier: 9.0.0version: 9.0.0@@ -384,6 +387,9 @@ importers:'@types/bootstrap':specifier: 5.2.11version: 5.2.11+ '@types/d3-hierarchy':+ specifier: 3.1.7+ version: 3.1.7'@types/jquery':specifier: 4.0.1version: 4.0.1