Repository navigation
fix(journal): find journal pages by their day, not their formatted title - #13883
Open
yuxi-liu-wired wants to merge 7 commits into
Open
yuxi-liu-wired wants to merge 7 commits into
yuxi-liu-wired wants to merge 7 commits into
Conversation
1 of 2 tasks
This was referenced Oct 27, 2026
Open
yuxi-liu-wired
force-pushed
the
fix/dbtest-1046
branch
from
October 29, 2026 15:59
f456cbf to
4360309
Compare
yuxi-liu-wired
pushed a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Oct 30, 2026
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Oct 30, 2026
… formatted title (squashed: its commits conflicted one by one with the stack)
yuxi-liu-wired
force-pushed
the
fix/dbtest-1046
branch
from
October 31, 2026 11:01
edf083b to
3992f79
Compare
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Oct 31, 2026
… formatted title (squashed: its commits conflicted one by one with the stack)
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Nov 1, 2026
… formatted title (squashed: its commits conflicted one by one with the stack)
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Nov 2, 2026
… formatted title (squashed: its commits conflicted one by one with the stack)
yuxi-liu-wired
force-pushed
the
fix/dbtest-1046
branch
from
November 3, 2026 12:01
3992f79 to
f09bcc0
Compare
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Nov 3, 2026
… formatted title (squashed: its commits conflicted one by one with the stack)
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Nov 4, 2026
… formatted title (squashed: its commits conflicted one by one with the stack)
yuxi-liu-wired
force-pushed
the
fix/dbtest-1046
branch
from
November 11, 2026 17:18
f09bcc0 to
e314cbb
Compare
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Nov 11, 2026
… formatted title (squashed: its commits conflicted one by one with the stack)
yuxi-liu-wired
force-pushed
the
fix/dbtest-1046
branch
2 times, most recently
from
November 12, 2026 12:01
94d3d2b to
503cc55
Compare
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Nov 12, 2026
… formatted title (squashed: its commits conflicted one by one with the stack)
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Nov 13, 2026
… formatted title (squashed: its commits conflicted one by one with the stack)
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Nov 14, 2026
… formatted title (squashed: its commits conflicted one by one with the stack)
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Nov 15, 2026
… formatted title (squashed: its commits conflicted one by one with the stack)
yuxi-liu-wired
force-pushed
the
fix/dbtest-1046
branch
from
November 16, 2026 12:01
503cc55 to
aafcfc6
Compare
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Nov 16, 2026
… formatted title (squashed: its commits conflicted one by one with the stack)
yuxi-liu-wired
force-pushed
the
fix/dbtest-1046
branch
from
November 17, 2026 12:01
aafcfc6 to
9284d78
Compare
yuxi-liu-wired
added a commit
to yuxi-liu-wired/logseq
that referenced
this pull request
Nov 17, 2026
… formatted title (squashed: its commits conflicted one by one with the stack)
yuxi-liu-wired
force-pushed
the
fix/dbtest-1046
branch
from
November 18, 2026 12:02
9284d78 to
71dce6e
Compare
yuxi-liu-wired
force-pushed
the
fix/dbtest-1046
branch
2 times, most recently
from
November 18, 2026 14:34
f054fd8 to
015f2a8
Compare
…th any journal title format With a journal title format other than the default "MMM do, yyyy" (for example "yyyy-MM-dd"), clicking the date pill of a Deadline or Scheduled value led to no page. The pill is rendered as a page reference by name, using date/journal-name, which formats the day in the configured journal title format. A journal's :block/name is always the default-format title, so the lookup by name found no page. Add date/journal-block-name, which formats a date with the default journal title format, and use it for the Deadline/Scheduled page reference. The visible label is unchanged. Test: journal-block-name-test in frontend.date-test checks the name stays in the default format while journal-name follows the configured format. Fixes logseq/db-test#1046
…ed name With a journal title format other than the default "MMM do, yyyy", several journal shortcuts silently missed the journal page: the previous/next/tomorrow journal commands and the mobile calendar created or opened the wrong page, Quick Add found no "today" page to move blocks into, the date typed into the page-search popup did not match the existing journal, and the transaction that guards creating today's journal never recognised that today's journal existed. The Deadline/Scheduled date link was the same problem in the properties UI. A journal's :block/name is the default-format title (journals created before 69c4d36 even keep one in the user's format), while these call sites looked pages up by date/journal-name or date/today, which use the configured format. The stable key is :block/journal-day. Resolve the journal page for a date with ldb/get-journal-page-by-day (db-async/<get-journal-page-by-day on the UI side) at these sites: the Deadline/Scheduled date link, go-to-tomorrow/prev/next journal, the mobile journal calendar, Quick Add, the natural-language date in the page-search popup, and the create-today-journal guard in the worker transaction (tx-meta :today-journal-name becomes :today-journal-day). Days without a journal page keep working as before: they are created with a title in the configured format, and the date link falls back to the default-format name. Displayed titles and labels keep the configured format. Tests: journal-test (go-to-next/prev/tomorrow), quick-add-moves-blocks-to-today-journal-found-by-journal-day, transact-skips-when-today-journal-already-exists (now with a custom-format title and a default-format :block/name) and deadline-date-links-to-journal-page-by-journal-day-test. Refs logseq/db-test#884 Fixes logseq/db-test#1046
…ault format A graph whose Journal class had lost :logseq.property.journal/title-format on one client computed no journal title at all, so every date reference there rendered as an empty [[]] while other clients showed the dates. A journal's title is computed from its day and the Journal class's title-format, and logseq.common.util.date-time/format returns nil when there is no formatter. get-journal-title now falls back to the default 'MMM do, yyyy' format, the one the renderer's date-formatter lookup already defaults to. Test: deps/db logseq.db-test/journal-title-without-title-format-uses-default-format retracts the format and checks the computed title. Fixes logseq/db-test#1168
…rmat no longer renames the journal With the date format 'E, dd.MM.yyyy', /today inserted [[Fri, 25.09.2026]] and the editor then could not save the block or leave it: the write was rejected with 'journal page protected attr updated' because the ref renamed the existing journal from 'sep 25th, 2026' to 'fri, 25.09.2026'. resolve-page-ref finds no page by the ref's name (journal names stay in the default format) and calls outliner-page/create, which finds the existing journal through its day and returns only its uuid. The ref was then built from the typed title and name plus that uuid, i.e. the journal's uuid with a new name. When create returns an existing journal, resolve-page-ref now takes the title and name from that journal, as the get-page branch just above it does. Test: frontend.worker.pipeline-test/save-block-ref-to-existing-journal-keeps-journal-name-with-custom-date-format-test saves a block referencing the journal under a custom title-format; on master it throws the logged :before/:after error. Fixes logseq/db-test#1293
…s journal and date refs A journal the user deleted (recycled) kept its day: the Journals list had no live journal for it, creating today's journal was skipped because "a page exists", and a [[date]] ref (typed, /today, /tomorrow) linked to the hidden recycled node and left it recycled. `ldb/get-journal-page-by-day` returned the recycled node, so every caller that asks "does this day have a journal?" (create-today-journal!, the pipeline's template journals, the db-sync today page, the thread-api the UI asks) got a yes. `resolve-page-ref` found a journal ref by its name (`ldb/get-page`), recycled pages included, so it never reached `outliner-page/create`, where the restore lives. `get-journal-page-by-day` skips recycled journals. `resolve-page-ref` looks a journal ref up by its day instead of its name; when no live journal exists `create` runs and restores the recycled one. Tests: `logseq.db-test/get-journal-page-by-day-skips-recycled-journal`, `logseq.outliner.core-test/insert-blocks-ref-to-recycled-journal-restores-it`. Fixes logseq/db-test#921
…h does not no longer makes a plain page that owns the journal's uuid After the date format was changed on another client (or by sync) and before the editor was reloaded, a [[date]] ref typed or inserted with /today in the old format created a plain page holding the day's journal uuid. That day then never got a journal: creating it returned the plain page, and every later ref to the day linked to the plain page. The editor parses the ref with its own format and sends it as a journal with the journal's uuid. `resolve-page-ref` passed the ref's title to `outliner-page/create`, which parses titles with the graph's format, found no day and built a non-journal page with the ref's uuid. The ref was also built from the typed title and name, so a journal `create` made kept the editor's title and name. `resolve-page-ref` creates a journal ref from its day written in the default format, which `create` always parses, and takes the title and name of the journal that `create` found or made, not the ref's. Test: `logseq.outliner.core-test/insert-blocks-ref-parsed-as-journal-only-by-the-editor-makes-the-journal`. Related to logseq/db-test#1293
…th today's title in a stale editor format On a graph whose Journal class has no `:logseq.property.journal/title-format`, creating a journal (the [[ page-search create, /today) made a plain page, so the day had no journal. The same happened to today's journal when the editor's date format differed from the graph's (changed on another client, not reloaded): the editor asks for today's journal with a title the graph's format cannot parse. `outliner-page/create` parsed the title with the stored format only, which is nil without a title-format, and with a nil format a title parses to no day. For today's journal the title is the editor's, not necessarily the graph's. `create` falls back to the default format when none is stored, and for a today's-journal request whose title parses to no day it uses today's date in the default format. Tests: `logseq.outliner.core-test/create-journal-without-title-format`, `logseq.outliner.core-test/create-today-journal-with-title-in-a-stale-editor-format`. Related to logseq/db-test#1168
yuxi-liu-wired
force-pushed
the
fix/dbtest-1046
branch
from
November 18, 2026 14:38
015f2a8 to
5aa7614
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes logseq/db-test#1046.
Refs logseq/db-test#884.
What the user sees
With a journal title format other than the default "MMM do, yyyy" (for example "yyyy-MM-dd"), several places miss the journal page of a day:
Journals created before 69c4d36 keep a
:block/namein the user's format while newer ones get the default format (#884), so name lookups fail for part of a graph whatever the configured format.Cause
A journal's stable key is
:block/journal-day(a yyyyMMdd int). Its:block/nameis the default-format title, and its:block/titleis in the configured format. These call sites looked the page up by a formatted name (date/journal-name,date/today, the title), which only matches when the configured format is the default one and the journal was created after 69c4d36.Change
The journal page of a date is now resolved with
ldb/get-journal-page-by-day(db-async/<get-journal-page-by-dayfrom the UI). Days with no journal page yet behave as before: they are created with a title in the configured format, and the Deadline/Scheduled link falls back to the default-format name. Labels and titles shown to the user keep the configured format.Sites changed:
components/property/value.cljsdatetime-value(Deadline/Scheduled link){:block/name (date/journal-name date)}journal-date-linkresolves the page by:block/journal-dayand links by uuid; falls back todate/journal-block-name(default format) when the day has no pagehandler/journal.cljsgo-to-tomorrow/prev/next<get-block+<page-exists?bydate/journal-name<get-journal-page-by-day; the current day comes from the page's:block/journal-day; day arithmetic withjournal-day-plus; a missing journal is created withdate/journal-day->journal-namemobile/components/header.cljsjournal calendar<get-blockbydate/journal-name<get-journal-page-by-dayhandler/editor/quick_add.cljs(ensure + move blocks)<get-block(-with-children)by(date/today)<get-journal-page-by-daybydate/today-journal-day, then by uuidhandler/page.cljsnatural-language date in the page-search popup[:block/name (lc title)](<page-by-title)<journal-page-by-dayworker/handler/transaction.cljs+deps/outliner/.../page.cljscreate-today-journal guard:today-journal-name,ldb/get-pageby name:today-journal-day,ldb/get-journal-page-by-daydate.cljsjournal-block-name,journal-day->journal-name, aliasesms->journal-day,date->journal-day,journal-day-plusSites already using the journal day (left as is):
graph-parser/block.cljspage-name-string->map,outliner/template.cljs,outliner/op.cljs,db-sync/.../semantic.cljsensure-today-page!,worker/pipeline.cljs,worker/commands.cljs,handler/route.cljs(sidebar-journals!),handler/page.cljs<today-journal-page,components/quick_add.cljs,db/async.cljs<get-today-journal-titleand<get-journal-page-title,worker/query_dsl.cljs->journal-day-int,components/page.cljstoday?.Sites left on purpose (they build or parse a title, they don't look a page up by name):
date/journal-name,date/today,date/tomorrow,date/yesterdayused for display and for page-ref text (template.cljs,commands.cljs,datepicker.cljs,query/builder.cljs, the date picker inproperty/value.cljs): the text[[<title>]]is converted to a journal day when the block is saved (convert-page-if-journal).handler/events.cljs:page/create,handler/repo.cljs,handler/page.cljscreate-today-journal!: create by title; the outliner derives the journal day and the deterministic uuid from the title.components/scheduled_deadlines.cljsanddb/async.cljs<get-date-scheduled-or-deadlines: parse the title of today's page to its day (the page is already known to be today by its:block/journal-day). Passing the day would be a cleaner signature but is a refactor.components/right_sidebar.cljsget-page: derives a route name, no lookup.deps/outliner/.../validate.cljs,deps/graph-parser/.../exporter.cljs,deps/db/.../build.cljs,outliner/core.cljs(a rename keeps the default-format:block/name): title/name generation, not lookups.#884
The UI paths above no longer depend on the journal's
:block/name, so the mixed name formats of old and new journals no longer break navigation, links and Quick Add. Not covered: the plugin API (getPage,pushStatewith a journal title such as "2026-05-18", the case in the issue) and any other code that callsldb/get-pagewith a formatted journal title still match:block/name. Fixing those needs either a plugin-API decision (resolve a journal title by day inget-page) or a migration that rewrites old journals':block/nameto the default format. Neither is included here.Tests
Each of these fails on master and passes with the change (build without the fix: 5 failures in these namespaces; with the fix: 0 failures, and the whole unit suite passes):
frontend.handler.journal-test(new): next/prev/tomorrow with the "yyyy-MM-dd" format open the existing journal whose:block/nameis in the default format, or create the missing one with a title in the configured format.frontend.handler.editor-async-test/quick-add-moves-blocks-to-today-journal-found-by-journal-day.frontend.worker.db-core-test/transact-skips-when-today-journal-already-exists: now with a custom-format title and a default-format:block/name; it also asserts that the skipped transaction isn't applied.frontend.components.property.value-test/deadline-date-links-to-journal-page-by-journal-day-test: the Deadline/Scheduled link target is the existing journal's uuid with the "yyyy-MM-dd" format, and the default-format name when the day has no page. This one only fails on master because the function it calls doesn't exist there; the component itself isn't rendered (effects don't run in the static renderer).frontend.date-test/journal-block-name-test.deps/outlinertests (pnpm test) pass too (tx-meta key change).Added: journal refs and titles, found by a journal fuzzer
Fixes logseq/db-test#921, Fixes logseq/db-test#1168, Fixes logseq/db-test#1293.
Five commits found with a journal fuzzer (built-in and random custom date formats,
[[date]]and/todayrefs as the editor makes them, recycle/restore/GC, format changes; it checks that a ref never renames a journal, titles are never blank, a recycled journal never hides its day, one journal per day). It finds 248 violations over 250 sequences on master and 0 with these commits (700 sequences).What the user sees
:logseq.property.journal/title-format, every date reference renders as an empty[[]]; other clients show the dates. Creating a journal there also makes a plain page, so the day has no journal.E, dd.MM.yyyy,/todayinserts[[Fri, 25.09.2026]]and the editor cannot save the block or leave it (Enter and Escape do nothing) until the brackets are removed. The same family: after the date format was changed on another client and before the editor reloads, a typed[[date]]or/todaycreates a plain page that holds the day's journal uuid, so that day never gets a journal; creating today's journal with the editor's stale format makes a plain page too.[[date]]refs to that day link to the hidden node. Plausible cause of "Journal stuck on June 4th", not confirmed with the reporter.Cause
date-time-util/formatreturns nil without a formatter, soget-journal-titlereturned nil.outliner-page/createalso parsed titles with the stored format only, and with none a title parses to no day.resolve-page-reffinds no page by the ref's name (journal names stay in the default format) and callsoutliner-page/create, which finds the existing journal through its day and returns only its uuid. The ref was built from the typed title and name plus that uuid, so the existing journal was renamed fromsep 25th, 2026tofri, 25.09.2026, andensure-journal-page-protected-attrs-not-updated!rejected the write (the logged:before/:after). When the editor parses a ref as a journal and the graph's format does not,creategot the editor's title, found no day and built a non-journal page with the journal's uuid.ldb/get-journal-page-by-dayreturned recycled nodes, socreate-today-journal!and the other "does the day have a journal" checks said yes;resolve-page-reffound a journal ref by name, recycled pages included, and never reached the restore increate.Change
One commit per cause:
get-journal-titlefalls back to the defaultMMM do, yyyyformat (searching for an "existing" page and click enter tries to create it #1168).createreturns it) is fixed on master by Keep journal identity when saving custom-format date links #13441 (bb5d8b1,resolve-created-page-ref); this PR keeps master's code and its own test for it.get-journal-page-by-dayskips recycled journals (Fix find-position #921). Master's Keep journal identity when saving custom-format date links #13441 already sends a ref to a recycled journal throughcreate, which restores it; the outliner half of this commit is dropped for master's.resolve-page-refpassescreatea journal ref's day written in the default format (whichcreatealways parses) instead of the title in the editor's format, so a ref the editor parsed as a journal and the graph's format does not makes the journal, not a plain page that takes the journal's uuid (局部页面图谱不自动刷新=Local page graph does not refresh automatically. #1293 family; on master's code since 11-18).outliner-page/createfalls back to the default format when none is stored, and a today's-journal request whose title parses to no day uses today's date in the default format (searching for an "existing" page and click enter tries to create it #1168 family).Tests
Each fails on master and passes with its fix.
logseq.db-test/journal-title-without-title-format-uses-default-format(deps/db, nbb);logseq.outliner.core-test/create-journal-without-title-format,create-today-journal-with-title-in-a-stale-editor-format(deps/outliner, nbb)frontend.worker.pipeline-test/save-block-ref-to-existing-journal-keeps-journal-name-with-custom-date-format-test(master: the logged:journal-page-protected-attr-updatederror,:before "sep 25th, 2026" :after "fri, 25.09.2026");logseq.outliner.core-test/insert-blocks-ref-parsed-as-journal-only-by-the-editor-makes-the-journallogseq.db-test/get-journal-page-by-day-skips-recycled-journal;logseq.outliner.core-test/insert-blocks-ref-to-recycled-journal-restores-itdeps/dbanddeps/outlinerwhole nbb suites and the wholepnpm cljs:run-testsuite pass with the fixes. A journal fuzzer (random date formats, UI/db format mismatch, missing title-format, recycle/restore/GC, legacy-named journals,[[date]]refs throughinsert-blocks!) found 144 violations on the first three commits' state (and 248 on master) over 250 sequences, and none on this branch over 700 sequences.