Files
logseq/scripts
scheinriese 50b3cdfbc9 fix: asset deletion lifecycle + PR-review cleanup
Asset deletion (three independent failures stacked):
- Unlink file on asset-block retract via the existing <unlink-asset
  helper at handler/assets.cljs (modules/outliner/pipeline.cljs:74-80).
  The block was commented out; deleted-assets was computed but never
  consumed, so files leaked indefinitely.
- Reactive existence check in image-icon-cp / avatar-image-cp via
  state/sub :db/latest-transacted-entity-uuids. model/sub-block can't
  drive this — worker/react.cljs:63-67 calls (d/entity db-after id),
  which returns nil for retracted entities, so [::block id] is never
  emitted in affected-keys and subscriptions never fire on deletion.
- Force-remount Avatar root via :key on asset-missing? toggle. Radix's
  Avatar primitive tracks image-loading status in context; once
  AvatarImage reported 'loaded', the status sticks even after the image
  unmounts, so AvatarFallback stays hidden.

PR-review cleanup (no behavior change):
- Strip 17+ [DEBUG ...] console statements across icon, block, views,
  two editor handlers, and assets.
- Close content.cljs preview gap: pass :preview-target-db-id +
  :property to icon-search so the block bullet observes hover preview
  consistently with every other surface.
- Scope-correct close-fallback-menu! — use dissoc-icon-preview-field!
  instead of unconditional state/set-state! nil.
- Delete dead code: heal-dangling-asset-icon (raced lazy hydrate),
  asset-uuid->entity, rgb-string->hex, name->hex (named + css),
  format-pairs.
- Hoist icon-grid-cols / custom-tab-cols magic numbers (9 sites).
- Search inputs: add :type "search" and :aria-label (both picker +
  asset-picker).
- Replace hardcoded #6B7280 with (colors/variable :gray :09).
- Reconcile recents-cap doc drift in storage.cljc + recents-lane
  docstring (cap lives in handler/icon-color/max-recents).
- Remove orphan-asset cleanup from outliner/core save-block-inner. Root
  cause (migration 65.27's :url ref-type) is fixed by 65.28/65.29; all
  asset writers are atomic (save-image-asset!, new-asset-block,
  build-new-asset), and the cleanup ran on every save with a silent-
  retract failure mode.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-12 16:28:06 +02:00
..
2022-11-23 21:09:29 +08:00
2023-09-05 16:10:31 -04:00
2025-12-30 14:23:23 -05:00
2025-09-21 12:25:06 +08:00

Description

This is a collection of development related scripts, written as bash scripts, bb/babashka scripts and nbb scripts.

Usage

Babashka scripts

Most bb scripts live under src/ and are defined as bb tasks. See babashka tasks

Nbb scripts

Before running nbb-logseq scripts, be sure to have node >= 18.14 installed as well as a recent babashka for managing the dependencies in nbb.edn. Then yarn install to install dependencies

Create graph scripts

These scripts generate custom database graphs written with nbb-logseq. If this is your first time generating a DB graph, first try the dev:create bb task in db graph tasks as it only requires writing EDN.

Creating graphs from the commandline using scripts and a concise EDN map is possible thanks to nbb-logseq and the namespaces logseq.outliner.db-pipeline and logseq.db.sqlite.build. For example, the create_graph_with_properties.cljs script uses this ns to create a graph with a variety of properties:

$ yarn nbb-logseq src/logseq/tasks/db_graph/create_graph_with_properties.cljs woot
Generating 16 pages and 24 blocks ...
Created graph woot!

NOTE: To use this created graph, click on the three dots menu in the upper right corner and select Import. Then click on the SQLite import button and upload the generated graph.

This script creates a DB graph with blocks containing several property types for both single and many cardinality. It also includes queries for most of these properties. Read the docs in logseq.db.sqlite.build for specifics on the EDN map.

To create large graphs with varying size:

$ yarn -s nbb-logseq src/logseq/tasks/db_graph/create_graph_with_large_sizes.cljs large
Building tx ...
Built 21000 tx, 1000 pages and 20000 blocks ...
Transacting chunk 1 of 21 starting with block: #:block{:name "page-0"}
...
Created graph large with 187810 datoms!

# To see options available
$ yarn -s nbb-logseq src/logseq/tasks/db_graph/create_graph_with_large_sizes.cljs -h
Usage: $0 GRAPH-NAME [OPTIONS]
Options:
  -h, --help        Print help
  -p, --pages  1000 Number of pages to create
  -b, --blocks 20   Number of blocks to create

Another example is the create_graph_with_schema_org.cljs script which creates a graph with the https://schema.org/ ontology with as many of the classes and properties as possible:

$ yarn -s nbb-logseq src/logseq/tasks/db_graph/create_graph_with_schema_org.cljs schema
Skipping 67 superseded properties
Skipping 25 properties with unsupported data types
Renaming 1 properties due to page name conflicts
Generating 2268 pages with 900 classes and 1368 properties ...
Created graph schema!

Update graph scripts

For database graphs, it is recommended to use logseq.outliner.db-pipeline/add-listener! when updating graphs. TODO