'counter' attribute of the $list widget not working?

Since 5.2.0, the counter attribute of the $list widget can, according to the documentation, provide the index of the current element in the list when set to the name of a variable to hold this information.

However, in my wiki running version 5.2.7, it doesn’t appear to actually do anything. I modified the example given in the docs very slightly, changing only the filter to hard-code three elements:

<$list filter="[[foo]] [[bar]] [[baz]]" counter="counter">
<div>
<<counter>>: ''<$text text=<<currentTiddler>>/>'' (is first: <<counter-first>>, is last: <<counter-last>>)
</div>
</$list>

And I just get:
image

Am I missing something?

image

Above is the output I get using your code on tiddlywiki.com/empty.html

Is there any chance that your wiki has overwritten the $:/core/modules/widgets/list.js tiddler?

Hmm, you’re right, that works for me. $:/core/modules/widgets/list.js is not overridden, however. Here’s the output of [is[shadow]]; not immediately seeing the culprit:

$:/config/AnimationDuration
$:/config/codemirror/keyMap
$:/config/codemirror/theme
$:/config/DefaultSidebarTab
$:/config/DownloadSaver/AutoSave
$:/config/EditTabIndex
$:/config/Manager/Filter
$:/config/Manager/Show
$:/config/Manager/Sort
$:/config/Manager/System
$:/config/Manager/Tag
$:/config/NewJournal/Title
$:/config/PageControlButtons/Visibility/$:/core/ui/Buttons/advanced-search
$:/config/PageControlButtons/Visibility/$:/core/ui/Buttons/close-all
$:/config/PageControlButtons/Visibility/$:/core/ui/Buttons/full-screen
$:/config/PageControlButtons/Visibility/$:/core/ui/Buttons/home
$:/config/PageControlButtons/Visibility/$:/core/ui/Buttons/import
$:/config/PageControlButtons/Visibility/$:/core/ui/Buttons/more-page-actions
$:/config/PageControlButtons/Visibility/$:/core/ui/Buttons/new-journal
$:/config/PageControlButtons/Visibility/$:/core/ui/Buttons/permaview
$:/config/PageControlButtons/Visibility/$:/core/ui/Buttons/tag-manager
$:/config/PageControlButtons/Visibility/$:/core/ui/Buttons/timestamp
$:/config/Performance/Instrumentation
$:/config/shortcuts/cancel-edit-tiddler
$:/config/shortcuts/save-tiddler
$:/config/SyncFilter
$:/config/TiddlerInfo/Mode
$:/config/Tiddlers/TitleLinks
$:/config/TiddlyRemember/TagMapping
$:/config/Toolbar/ButtonClass
$:/config/Toolbar/Text
$:/config/ViewToolbarButtons/Visibility/$:/core/ui/Buttons/clone
$:/config/ViewToolbarButtons/Visibility/$:/core/ui/Buttons/close-others
$:/config/ViewToolbarButtons/Visibility/$:/core/ui/Buttons/export-tiddler
$:/config/ViewToolbarButtons/Visibility/$:/core/ui/Buttons/fold-bar
$:/config/ViewToolbarButtons/Visibility/$:/core/ui/Buttons/info
$:/config/ViewToolbarButtons/Visibility/$:/core/ui/Buttons/new-here
$:/config/ViewToolbarButtons/Visibility/$:/core/ui/Buttons/new-journal-here
$:/config/ViewToolbarButtons/Visibility/$:/core/ui/Buttons/permalink
$:/core/Filters/AllTags
$:/core/macros/tag-picker
$:/core/templates/canonical-uri-external-image
$:/core/ui/EditorToolbar/linkify
$:/core/ui/EditorToolbar/transcludify
$:/core/ui/MoreSideBar/Recent
$:/core/ui/SideBar/Open
$:/core/ui/SideBarSegments/tabs
$:/core/ui/ViewTemplate/subtitle
$:/core/ui/ViewTemplate/title
$:/DefaultTiddlers
$:/palette
$:/plugins/bimlas/locator/edit-template/locator-references
$:/plugins/sobjornstad/TiddlyRemember/toolbar/remembercz
$:/plugins/sobjornstad/TiddlyStretch/macros/stretch
$:/plugins/telmiger/details/colours.css
$:/plugins/tiddlywiki/codemirror/mode/tw5/tw5.css
$:/plugins/tobibeer/preview/defaults/delay
$:/plugins/tobibeer/preview/defaults/exclude
$:/plugins/tobibeer/preview/defaults/keys
$:/plugins/tobibeer/preview/template
$:/SiteSubtitle
$:/SiteTitle
$:/tags/EditorToolbar
$:/tags/EditTemplate
$:/tags/PageTemplate
$:/tags/SideBar
$:/tags/ViewTemplate
$:/themes/tiddlywiki/vanilla/metrics/bodyfontsize
$:/themes/tiddlywiki/vanilla/metrics/sidebarbreakpoint
$:/themes/tiddlywiki/vanilla/metrics/sidebarwidth
$:/themes/tiddlywiki/vanilla/metrics/storyright
$:/themes/tiddlywiki/vanilla/metrics/storywidth
$:/themes/tiddlywiki/vanilla/metrics/tiddlerwidth
$:/themes/tiddlywiki/vanilla/options/sidebarlayout
$:/themes/tiddlywiki/vanilla/options/stickytitles
$:/themes/tiddlywiki/vanilla/settings/codefontfamily
$:/themes/tiddlywiki/vanilla/settings/fontfamily
$:/themes/tiddlywiki/vanilla/sticky
$:/temp/search
$:/temp/advancedsearch
$:/config/Navigation/UpdateAddressBar
$:/state/showeditpreview
1 Like

Even weirder: there’s no issue on the public version of this wiki (zettelkasten.sorenbjornstad.com), which is odd because basically all system tiddlers are the same between the private and public versions.

Check if the variables are defined by inserting a $log call inside the list widget:

<$log $$filter="counter counter-last counter-first"/>

Wow, that’s cool, didn’t know about $action-log! They are not defined (but currentTiddler is, of course).

This definitely points to an issue with the $list widget definition somehow being overriden.

Check the output of this filter to see if another plugin overrides the list widget:
[[$:/core/modules/widgets/list.js]shadowsource[]]

I should have actually recommended the counterpart to $action-log in this context, $log.

1 Like

I disabled all of my plugins and the issue persists.

image

I also deleted all overridden shadow tiddlers and the issue persists :confused:

OK, I think I found the issue – my $:/core is still at version 5.1.23 even though version 5.2.7 is shown on the tools tab of the sidebar, maybe because it got overridden somehow?

However, I can’t seem to fix it. This is a Node.js wiki and, if I try deleting $:/core either from within the wiki or from the filesystem, the wiki won’t load anymore. Surely it’s supposed to load $:/core automatically without having it in the directory?

What is the output when you run tiddlywiki --version on the command line?

It should not even exist on the filesystem. Does it exist as a file in your filesystem for this wiki?

It should not even exist on the filesystem. Does it exist as a file in your filesystem for this wiki?

Yeah, I agree. It did (in tiddlers/_system/core.json{,.meta} due to my custom pathing config); if it’s there it’s the wrong version, and if I delete it, the wiki doesn’t load (it just stays infinitely on the loading spinner without putting anything in the console, presumably because the JS that loads the wiki doesn’t exist and won’t start running).

Either running with npx tiddlywiki or $(npm bin)/tiddlywiki from my wiki folder gives 5.2.7, as it should.

The presence of the core.json file is very bizarre. How was this wiki created? Was it by any chance converted from a single file wiki to a folder wiki? Trying to think how this scenario could have arisen.

What are the contents of the tiddlywiki.info file for this wiki?

How was this wiki created? Was it by any chance converted from a single file wiki to a folder wiki?

Possibly? I can’t remember at this point, it goes back to before COVID, and to a time when I didn’t know much about TW :slight_smile:.

I think converting it to a single-file wiki and then back again (after having deleted $:/core) fixed the problem. Here are the files that are different in the new folder wiki structure (binary compare on all files, left side broken wiki, right side working wiki):

https://drive.google.com/file/d/11VGpig7rbROSu--aciqT0JF6RtmA52vJ/view?usp=sharing

I don’t see anything that odd, except that a number of plugins appear to have been included in the filesystem for some reason and removed when doing this, and a bunch of files had an extra .js extension in the old one (probably there was a bug in my file pathing filter and I fixed it at some point, but the tiddlers weren’t updated in the meantime?).

What are the contents of the tiddlywiki.info file for this wiki?

{
    "description": "Basic client-server edition",
    "plugins": [
        "tiddlywiki/codemirror",
        "tiddlywiki/codemirror-autocomplete",
        "tiddlywiki/codemirror-closebrackets",
        "tiddlywiki/codemirror-keymap-vim",
        "tiddlywiki/codemirror-search-replace",
        "tiddlywiki/filesystem",
        "tiddlywiki/highlight",
        "tiddlywiki/katex",
        "tiddlywiki/tiddlyweb"
    ],
    "themes": [
        "tiddlywiki/vanilla",
        "tiddlywiki/snowwhite"
    ],
    "build": {
        "index": [
            "--rendertiddler",
            "$:/plugins/tiddlywiki/tiddlyweb/save/offline",
            "index.html",
            "text/plain"
        ],
        "externalimages": [
            "--savetiddlers",
            "[is[image]]",
            "images",
            "--setfield",
            "[is[image]]",
            "_canonical_uri",
            "$:/core/templates/canonical-uri-external-image",
            "text/plain",
            "--setfield",
            "[is[image]]",
            "text",
            "",
            "text/plain",
            "--rendertiddler",
            "$:/plugins/tiddlywiki/tiddlyweb/save/offline",
            "externalimages.html",
            "text/plain"
        ],
        "static": [
            "--rendertiddler",
            "$:/core/templates/static.template.html",
            "static.html",
            "text/plain",
            "--rendertiddler",
            "$:/core/templates/alltiddlers.template.html",
            "alltiddlers.html",
            "text/plain",
            "--rendertiddlers",
            "[!is[system]]",
            "$:/core/templates/static.tiddler.html",
            "static",
            "text/plain",
            "--rendertiddler",
            "$:/core/templates/static.template.css",
            "static/static.css",
            "text/plain"
        ]
    }
}

Diff from broken to working:

I will have a peek in the git history and see if that happens to reveal anything about when the core tiddler got introduced into the filesystem.

Ah, this is very suspicious:

commit 05f1b5f3aa80cb90ba8f739d20b043604fb7f071
Author: Soren I. Bjornstad <contact@sorenbjornstad.com>
Date:   Mon Jun 14 19:59:54 2021 -0500

    force move of all tiddlers to new locations

Can’t remember exactly what I did here (this was after updating a pathing filter, presumably; I’m guessing I found some hack somewhere that caused a rewrite everywhere without updating the modified timestamps).

I see relevant things in my bash history from that time, but nothing that would enlighten us as to what specifically I did.

I think this is probably the hack I used – it’s in a tiddler I added in this bad commit and then deleted in the next commit:

<$button>
    Do The Thing
    <$list filter="[is[tiddler]]">
      <$action-deletefield afieldthatdoesntexist="" />
    </$list>
</$button>

Something seems to have forced tiddlers to be saved that are otherwise excluded by the syncFilter, such as boot.js and boot.css. I don’t see how $action-deletefield could trigger that.
What are the contents of $:/config/SyncFilter ?

It also seems strange that you weren’t able to delete the core.json file and have a working wiki.

[is[tiddler]] -[[$:/HistoryList]] -[[$:/Import]] -[[$:/isEncrypted]] -[prefix[$:/status/]] -[prefix[$:/state/]] -[prefix[$:/temp/]] -[[$:/StoryList]]

I see this was last updated in mid-2020 and isn’t there by default?

That explains it! That in combination with the snippet of the wikitext you posted would have forced the core amongst other things to be saved. The default syncFilter excludes the core and associated tiddlers that should not be synced:

[is[tiddler]] -[[$:/core]] -[[$:/library/sjcl.js]] -[prefix[$:/boot/]] -[prefix[$:/HistoryList]] -[status[pending]plugin-type[import]] -[[$:/isEncrypted]] -[prefix[$:/status/]] -[prefix[$:/state/]] -[prefix[$:/temp/]]
1 Like

Now the million-dollar question is, why in the world would I have changed the SyncFilter? I didn’t make any other changes to the wiki on that day…I guess I’ll just delete it and see if anything breaks.