Reading disk changes

I run tiddlywiki on node.js. I start the wiki using tiddlywiki mytiddlywiki --listen --port=8090 command.

In tiddlers folder, there are several files — I guess, one for every tiddler. If I edit and save a tiddler file, the changes do not get reflected in my tiddlywiki automatically. Even if I reload the webpage using control-R or entering 127.0.0.1:8090 in the address bar, the changes do not show.

I need to terminate the tiddlywiki command and reexecute it. Then all the changes are visible.

Is there an easier alternative to make tiddlywiki read any changes made on the disk?

TiddlyWiki generally assumes that it’s the only one accessing the tiddlers store, so it never checks to see if there are changes, as you’ve seen.

Bob is a plugin that adds an extra layer of filesystem features on top of the standard Node.js server, including this one. It is a little rough around the edges, but may work well for you.

1 Like

@sobjornstad I agree Bob is a good multi-user solution, and bob.exe is really easy to install. But I think @deshmukh would like to update tiddlers in the the file and folder store and have this reflected in the wiki. I have not yet focused on this aspect of node but others have.

@deshmukh it may help if you explain why you want this to happen?, have you tried reloading the wiki, or even restarting the server? As @sobjornstad suggested this would not be an issue if you added tiddlers in the browser rather than the file system, and used bob. On tiddlywiki.com there is a range of documentation that refers to “commands”, commands relate to command line actions on node tiddlywiki’s and may contain the instructions you need to “refresh the server” after adding tiddlers in the file system.

Hi @TW_Tones, the way you worded this makes it seem that you BOTH have to use the browser and use BOB, but in-fact @sobjornstad was correct in pointing out that BOB has a “file monitor” component built in. That’s one of the reasons I like it so much. I actually have other automations on my computer (PowerAutomate, batch files etc.) that programmatically now generate tiddlers into my tiddlers folder and I see them import/reflect in real-time while using BOB which is excellent.

Maybe I just mis-interpreted what you meant, but just wanted to make sure that was clear for @deshmukh

1 Like

@stobot Thanks for that clarification, as I declared I do not use Node that way.

My comments are somewhat driven by the fact it is not clear “why this was wanted”. As you may know many technical problems that result in a question are often second degree problems, where there is an earlier problem or root cause that lead to the question.

@joshuafontany ,as I await further news about your BOB replacement like Christmas when I was a child (how many more sleeps?! :slight_smile: ), is it determined if it will have file/folder monitoring too?

@stobot Monitoring the filesystem for changes and pushing changes to the TW server is definitely possible, as shown by Bob’s implementation of the logic. TW is written to read all tidders from disk into the $tw.wiki store upon boot. One of the big challenges for a system that monitors changes to the filesystem is that $tw.syncadaptor(filesystemadaptor) is ALSO changing the filesystem. There’s a possibility of getting lost in read/write race conditions and other filesystem bugs.

The new Yjs logic will definitely help with that, as all the changed tiddlers in a wiki (browser or server) are backed up first into the “Yjs Document” (which auto-syncs to all connected clients). I can detect filesystem changes, read the file, compare it to the tiddler-values in the YDoc.Map(titles), and only update the $tw.wiki copy of the tiddler if values are different. Changes to the $tw.wiki tiddlers will be compared to the current YDoc values before updating the YDoc, and the YDoc updates will be the ones written to disk, which avoids a loop-o-doom or a memory leak reading/writing to the same filename a bunch of times in a row.

Work progresses in the tiddler-mines. :wink:

1 Like

Here are the reasons why I wanted tiddlywiki to reflect changes on the disk.

  • The editing interface on tiddlywiki is too basic compared to editors like vim and emacs. I would love to edit a tiddler in emacs if that is possible.

  • Using syncthing, I sync my tiddlywiki folder with my android mobile phone. When I am away from my computer, I use it to view and occasionally edit some tiddlers. When I get back to my computer and refer to the running tiddlywiki, those changes are not there! So, I need to restart tiddlywiki

All these things would be smooth if only tiddlywiki were to read changes from the disk.

@deshmukh Thanks for spelling out what you want.

Many have wanted what you ask for in the past so I am sure its possible. A Quick search for vim and/or emacs on Tiddlywiki.com returns some other results that may interest you.

Of course there are lots of other opportunities for using tiddlywiki on your mobile and saving on or back to your computer.

I am just testing pasting links here, but for your use as well :grinning:

## TiddlyWiki extensions for ViM

## Editing Tiddlers with Emacs

@TW_Tones Thanks for the links.

I can edit the tiddler files in emacs without difficulty. That was never a problem. In fact, I considered node js installation because it has multiple tiddler files that can be edited by an external editor.

The problem is the changes are not reflected in the wiki. That means the whole rigmarole of stopping and starting tiddlywiki.

I have gone through the solutions posted on the tiddlywiki webpage. But most of them involve using some synchronization/ backup service like Google Drive.

I have been using syncthing for quite some time now and it works pretty well. So, I am reluctant to move to another sync solution.

If there is anything I have missed out on, please let me know.

Perhaps raise it in a new thread. If the synchronisation works for you fine.

There are so many possibilities to get the same result. For some time I hosted a node wiki on my Android with the Termux app, so I used it on the phone, and when home my desktop connected to that on my mobile.

There are many variables, all I am saying is there are so many opportunities so keep and open mind because there are many ways to meet the same needs.

Enjoy tiddlywiki.

I support the idea of having the ability to modify tiddlers outside the TW interface and have TW on Node.js recognize the change. There are many advantages to this:

  • Easy tiddler lookup (without any plugin)
    • We can write complex/long tiddlers while looking at other tiddlers for references and see the change in real time.
  • Writing math tiddlers
    • I write math tiddlers a lot. Recently I discovered a KaTeX hack that allows you to write inline math with just single dollar $....$ instead of the inconvenient double dollars $$....$$. This tremendously improves the compatibility between LaTeX document and TW. By using vs code or sublime, I can use latex autocomplete and other functions to help in writing.
  • Outsource features of external editors
    • We have codemiror editor which provides extra features compared to the standard TW editor. But these cannot compare to features that text editor like vs code or sublime offer.

Now I have already tried Bob. But sometimes when I write tiddlers in external editor (sublime) and save, the server deleted the file I wrote! Luckily I still have the text buffer on sublime so I can resave (more like recreate) the file. This happens too many times that I dont think I can rely on it :frowning:

I could understand the potential issue of having the TW system messed up due to messed-up files by external factors ( sync software, simultaneous changes, etc). But perhaps we could a provide a context menu to open a single tiddler in an external editor (the node server “unlock” the file and listens to file changes on disk).

There is a sideeditor plugin which gives the ability to open and edit a tiddler in a new window. But the editor is very basic. Wishing we could open a tiddler in vs code, sublime etc…

Yes, there are many ways to do this, like extract bob.exe’s reload feature to a new plugin watch-fs, or modify filesystem adaptor plugin to add this feature.

Just need to think about which is the best way, and push it forward. Now I think bob.exe and watch-fs plugin is the wrong way, still need to directly modify fielsystem adaptor plugin for this feature.