Create a journal tiddler on startup

Hello,
Having the same need as raised in this thread as a user coming from Logseq/Obsidian, I would like to have a journal tiddler created as soon as I open Tiddlywiki (or opened if it already exists, which is easy to do with the StartupTiddlers configuration), so that I can type any notes in children stream tiddlers.
I have therefore tried to copy $:/core/ui/Actions/new-journal , make my own version of “Auto journal on startup”:

<$action-createtiddler $basetitle=<<now "YYYY-0MM-0DD, ddd">> tags="Journal" />

or even hard-coded the tiddler’s title

<$action-createtiddler $basetitle="2025-02-12, Wed" />

and tagged them with $:/tags/StartupAction, but when I reload the wiki all of these options give me a red screen of death showing Uncaught TypeError: Cannot read properties of undefined (reading 'getString'), regardless whether or not I include \import [subfilter{$:/core/config/GlobalImportFilter}] before the createtiddler widget.
Same if I use $action-sendmessage instead of createtiddler:

<$action-sendmessage $message="tm-new-tiddler"  title="2025-02-12, Wed" />

Is there some kind of conflict between the creation of a journal tiddler specifically and TW’S startup sequence? Or am I making an obvious mistake somewhere?

1 Like

I created a github issue for this bug here: [Bug] RSOE When Using a StartupAction with the now macro · Issue #8946 · TiddlyWiki/TiddlyWiki5 · GitHub

I think I managed to narrow the source of the error to this snippet of wikitext:

<$transclude $variable='now'  />

It looks like the now macro is failing because $tw.utils.formatDateString is trying to access something that is undefined.

I’ve found a workaround , create a tiddler with the tag $:/tags/StartupAction/PostRender (using $:/tags/StartupAction will produce a RSOE) and this content:

{{$:/core/ui/KeyboardShortcuts/new-journal}}

demo

I don’t know why this work, but it does … my guess is that somehow, enough delay is added to allow $tw.utils.formatDateString to work properly.

Great, thanks for your answer @telumire!

I didn’t want to reuse the new-journal action so I simplified it a bit to this:

<$let journalTitleTemplate={{$:/config/NewJournal/Title}} >
<$wikify name="journalTitle" text="<$transclude $variable='now' format=<<journalTitleTemplate>>/>">

<$list filter="[<journalTitle>!is[tiddler]]" >
<$action-createtiddler $basetitle=<<journalTitle>> $template="$:/zig/JournalTemplate" tags="Journal" /> 
</$list>
</$wikify>

and that works wonderfully to have a daily journal tiddler as soon as I start up TW.
However, it seems to be created after processing the $:/DefaultTiddlers, so that I had to replace my initial [<now "YYYY-0MM-0DD, ddd">is[tiddler]else[Good day!]] with [<now "YYYY-0MM-0DD, ddd">]: Good day! is a welcome tiddler with a button to create a new journal if it does not exist yet, but is being put in the story just before the daily journal tiddler is automatically created.

Now, with that solved, I was trying to do something similar to create a tiddler in edit mode on startup (mostly to parse the URL when sharing content with TW as a PWA app on Android), but I can’t figure it out:

  • <$action-sendmessage $message="tm-new-tiddler" ...> does not seem to do anything when triggered by StartupAction/PostRender
  • <$action-createtiddler> successfully creates a tiddler, but does not put any focus on it
  • a subsequent <$action-sendmessage $message="tm-edit-tiddler" ...> also does not put the new tiddler in edit mode.
  • <$action-navigate $to=<<createTiddler-title>>/> does put the tiddler in the story line, but also not in edit mode.
  • all these options work properly when triggered by a button!

So it seems that $action-sendmessage widgets don’t work (yet?) on StartupAction - am I missing something, or is there any other way to put a tiddler in edit mode on startup?
(I also couldn’t figure out how to use the deprecated $savedrafttitle attribute for action-createtiddler)

Try wrapping your actions in a navigator widget:

<$navigator story="$:/StoryList" history="$:/HistoryList">
actions here
</$navigator>

Certain messages need to be handled by a navigator widget and none is available in startup actions unless you provide one.

Oh wow, that did it!
For future reference, in the end my tiddler looks like this:

\define content(title,text,url)
<<< 
$text$
<<<
from $title$, $url$
[ext[$title$|$url$]] // this does not work, WIP
\end

<$list filter="[[$:/info/url/search]get[text]split[&]first[]regexp[source_title=.*]]">
  <$let source_title={{{ [[$:/info/url/search]get[text]split[&]regexp[source_title=]split[=]last[]] }}}
            source_text={{{ [[$:/info/url/search]get[text]split[&]regexp[source_text=]split[=]last[]] }}}
            source_url={{{ [[$:/info/url/search]get[text]split[&]regexp[source_url=]split[=]last[]] }}} 
            tiddlerTitleTemplate={{$:/language/DefaultNewTiddlerTitle}} >
    <$wikify name="tidTitle" text="<$transclude $variable='now' format=<<tiddlerTitleTemplate>>/>">
      <$wikify name="tidcontent" text="<$transclude $variable='content' title=<<source_title>> text=<<source_text>> url=<<source_url>> />" >
        <$navigator story="$:/StoryList" history="$:/HistoryList">
          <$action-sendmessage $message="tm-new-tiddler" title=<<tidTitle>> text=<<tidcontent>> tags="new_on_start" />
        </$navigator>
      </$wikify>
    </$wikify>
  </$let>
</$list>

Certain messages need to be handled by a navigator widget and none is available in startup actions unless you provide one.

Do you know if there is any documentation about this?

I believe there is about how the messages are handled but not about navigator not being available in startup actions.

https://tiddlywiki.com/#WidgetMessage%3A%20tm-new-tiddler

Thanks! What does “handled” actually mean?

and is handled by the NavigatorWidget.