obsidian-list-modified icon indicating copy to clipboard operation
obsidian-list-modified copied to clipboard

[BUG] Appending to wrong note

Open joh6nn opened this issue 1 year ago • 50 comments

First Steps

  • [x] I've ensured that the issue does not already exist by using the search issues feature
  • [x] I've read the documentation (see the README)
  • [x] I'm on the latest release of obsidian-list-modified
  • [ ] I've tried disabling any other plugins that may cause conflicts (recommended)
    • I don't know what other plugins might conflict, but I would be glad to try disabling them

Describe the bug

Links are consistently added to the incorrect note. I've got a vault with the following structure:

|-Entries
| \- [...Several Years of Daily Notes with the folder structure below]
| \- 2023
|    \ - 10 Oct
|        |- [Daily notes for Oct]
|        |- 18.md
|-Notes
|-Templates

Today, I enabled List Modified, with the following settings:

Instead of appending the links to the Notes heading in file Entries/2023/10 Oct/18.md , the links are being appended to Entries/2021/09 Sep/18.md

Expected behaviour

What should happen instead?

links should be appended to the Notes heading in file Entries/2023/10 Oct/18.md

Reproducing

My setup

  • Devices
    • Kubuntu 22.04
    • Android 12
    • Obsidian 14.16 (on both devices)
  • What sync service are you using? (if relevant to bug)
    • SyncThing

image

Steps to reproduce bug

Can you pinpoint when/why this bug happens?

n/a

joh6nn avatar Oct 18 '23 17:10 joh6nn

Could you please send me your output file configuration? Basically, just the rest of your settings pane works.

franciskafieh avatar Oct 18 '23 23:10 franciskafieh

image

Ignored Tags is empty.

If you need anything else, just let me know :slightly_smiling_face:

joh6nn avatar Oct 19 '23 13:10 joh6nn

Would you mind sending me this part?

image

franciskafieh avatar Oct 19 '23 13:10 franciskafieh

Unless I'm missing something, that's in the original screenshot?

Output Format is - ![[link]] Time Format is unset because I'm not using a time field Append Space After Headings is off

joh6nn avatar Oct 19 '23 14:10 joh6nn

You’re right, my bad.

franciskafieh avatar Oct 19 '23 15:10 franciskafieh

Sorry, misclick on mobile, lol. I’ll take a look in a few hours

franciskafieh avatar Oct 19 '23 15:10 franciskafieh

Alright, last thing: your Daily Notes settings pane, or your Periodic Notes settings if using that plugin

Just want to make sure that's setup properly. If it is, I will need to release a test version to help solve this. It seems to be working fine on my machine.

franciskafieh avatar Oct 19 '23 21:10 franciskafieh

image

joh6nn avatar Oct 19 '23 22:10 joh6nn

I do have a bunch of plugins, and I'm more than open to the idea that one or more of them is conflicting, I just don't know which one(s), or how to go about figuring that out (short of very tediously disabling all of them, and then turning them on one at a time. Which I'd love to not have to do)

joh6nn avatar Oct 19 '23 22:10 joh6nn

image I mirrored your daily notes and file name settings here exactly, and everything works fine for me. Could you do the following for me?

  1. open the developer console (ctrl/cmd + shift + i)
  2. type clear() in the prompt area at the bottom
  3. screenshot the output (any errors, warnings, etc, should display)

franciskafieh avatar Oct 19 '23 22:10 franciskafieh

image

I checked to see if there's any additional info if I bump the console output up to Verbose, but there's not, just the Obsidian Git plugin spamming the console with "task complete" messages.

joh6nn avatar Oct 21 '23 02:10 joh6nn

I think I’m going to add a debug mode to the plugin. I’ve been meaning to make one for awhile now. I’ll try to get it out tomorrow and we’ll see if it helps. In the mean time, you could try a different vault with just Obsidian List Modified, maybe? If it works there and not in your normal vault, it’s most likely a conflicting plugin

franciskafieh avatar Oct 21 '23 02:10 franciskafieh

Ok, so current situation is super weird:

I tried disabling plugins in this vault in a binary search (ie, I disabled half of them and tested, then disabled half of what was left and tested, and so on), and got down to the only plugin still enabled is List Modified, and I'm still seeing the incorrect behavior.

So I created a new vault, enabled Daily Notes, installed List Modified, and tried to recreate the issue by creating a note for today (2023-10-22), and also creating a note for 2021-09-22. I was able to reproduce the issue twice, but I can't reproduce it consistently. I don't know what was different about the two times I got it to happen.

If you add the debug mode, I'll try to collect more info

joh6nn avatar Oct 23 '23 00:10 joh6nn

That’s super odd.. I’ll try to get debug mode out ASAP. I’ve got a pretty bad flu right now though

By any chance, was SyncThing enabled on your second vault, too? I’m wondering if that could be the issue, but honestly, I can’t see how Sync would affect the output file’s location

franciskafieh avatar Oct 23 '23 01:10 franciskafieh

Nope, no SyncThing 🤷

Sorry to hear about the flu, hope you feel better soon!

joh6nn avatar Oct 23 '23 12:10 joh6nn

Sorry for the long delay. I'm about to publish it as a pre-release, which means you will need to use the BRAT plugin or manually install it (video here if you need help).

What you're mainly looking for is this part... image

After you've enabled the verbose mode setting, you should be able to open the dev console as you have done before. Play around with editing files, etc, until you see a message like that or "Log note not found, but should be created automatically. Creating now..."

franciskafieh avatar Oct 30 '23 21:10 franciskafieh

Link to pre-release: https://github.com/franciskafieh/obsidian-list-modified/releases/tag/2.2.1

franciskafieh avatar Oct 30 '23 21:10 franciskafieh

Ok, I made a copy of my vault, and installed 2.2.1 with BRAT:

plugin:obsidian-list-modified:938 OLM settings saved.
plugin:obsidian-list-modified:790 --- Writing tracked files ---
plugin:obsidian-list-modified:744 [Obsidian List Modified] Log note found at: Entries/1999/12/31.md

Then I created a brand new empty vault, installed only BRAT and OLM, configured Daily Note to match my real vault (as noted above), and made a Templates folder, an Entries folder, and a Notes folder. I clicked the Daily Note button in the ribbon to create a daily note from the template, and then created two files in Notes, and OLM correctly added them to today's note.

Then I created Entries/2021/09/31.md. I closed and re-opened the test vault, and created a new file in Notes, and bingo: it added the list to the incorrect note, with all 3 entries (the one from just now, and the 2 from before):

image

joh6nn avatar Oct 31 '23 21:10 joh6nn

that’s super weird.. It seems like moment.js thinks the current year is 2021, or it may be a bug in the upstream plugin I’m using to get daily notes.. I’m gonna need to add something to the debug mode. I’ll try to get it done within a few hours

On Tue, Oct 31, 2023 at 5:25 PM joh6nn @.***> wrote:

Ok, I made a copy of my vault, and installed 2.2.1 with BRAT:

plugin:obsidian-list-modified:938 OLM settings saved. plugin:obsidian-list-modified:790 --- Writing tracked files --- plugin:obsidian-list-modified:744 [Obsidian List Modified] Log note found at: Entries/1999/12/31.md

Then I created a brand new empty vault, installed only BRAT and OLM, configured Daily Note to match my real vault (as noted above), and made a Templates folder, an Entries folder, and a Notes folder. I clicked the Daily Note button in the ribbon to create a daily note from the template, and then created two files in Notes, and OLM correctly added them to today's note.

Then I created Entries/2021/09/31.md. I closed and re-opened the test vault, and created a new file in Notes, and bingo: it added the list to the incorrect note, with all 3 entries (the one from just now, and the 2 from before):

[image: image] https://user-images.githubusercontent.com/1129329/279519064-b391947a-ba7d-42c5-abc2-49c66a631f97.png

— Reply to this email directly, view it on GitHub https://github.com/franciskafieh/obsidian-list-modified/issues/87#issuecomment-1788059442, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWLR3ZU6OZVHD4U3VI5EHSLYCFUFRAVCNFSM6AAAAAA6F5AY72VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBYGA2TSNBUGI . You are receiving this because you modified the open/close state.Message ID: @.***>

franciskafieh avatar Oct 31 '23 21:10 franciskafieh

My initial guess here is that the upstream plugin has a bug, because it also incorrectly detected 1999 as the current year, and additionally it also incorrectly detects the current month. I feel like moment.js has enough users that if it was the source of the bug, someone would have noticed :slightly_smiling_face:

joh6nn avatar Oct 31 '23 22:10 joh6nn

Yup, confirmed: https://github.com/liamcain/obsidian-daily-notes-interface/issues/21

It's been broken for directory structures like YYYY/MM/DDD and similar for a long time, it seems.

joh6nn avatar Oct 31 '23 22:10 joh6nn

good detective work lol. super weird since it was working for me… since it seems like a lot of people want it fixed but nobodys taken a shot at it, I could try forking the plugin and figuring it out

On Tue, Oct 31, 2023 at 6:17 PM joh6nn @.***> wrote:

Yup, confirmed: liamcain/obsidian-daily-notes-interface#21 https://github.com/liamcain/obsidian-daily-notes-interface/issues/21

It's been broken for directory structures like YYYY/MM/DDD and similar for a long time, it seems.

— Reply to this email directly, view it on GitHub https://github.com/franciskafieh/obsidian-list-modified/issues/87#issuecomment-1788112265, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWLR3ZTWVBWABADKA5WW663YCF2G3AVCNFSM6AAAAAA6F5AY72VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBYGEYTEMRWGU . You are receiving this because you modified the open/close state.Message ID: @.***>

franciskafieh avatar Oct 31 '23 22:10 franciskafieh

It looks like there's actually a PR that claims to fix it: https://github.com/liamcain/obsidian-daily-notes-interface/pull/25

It's actually fixing a bug in one of the developer's other plugins (the Calendar plugin), but the underlying issue is the same.

I still haven't really wrapped my head around modern JS's functional stuff, but it looks reasonable to me? I think it's dynamically building a RegEx that matches whatever the Daily/Periodic note settings currently are, but I gladly defer to you here

joh6nn avatar Oct 31 '23 22:10 joh6nn

Looks good and for sure lol. Appreciate you for putting effort into the bug too. Sorry I’m not being very helpful, on mobile rn. I’ll change the plugin to depend on that fork and release it in a few hours. Hopefully that will help

On Tue, Oct 31, 2023 at 6:31 PM joh6nn @.***> wrote:

It looks like there's actually a PR that claims to fix it: liamcain/obsidian-daily-notes-interface#25 https://github.com/liamcain/obsidian-daily-notes-interface/pull/25

It's actually fixing a bug in one of the developer's other plugins (the Calendar plugin), but the underlying issue is the same.

I still haven't really wrapped my head around modern JS's functional stuff, but it looks reasonable to me? I think it's dynamically building a RegEx that matches whatever the Daily/Periodic note settings currently are, but I gladly defer to you here

— Reply to this email directly, view it on GitHub https://github.com/franciskafieh/obsidian-list-modified/issues/87#issuecomment-1788124111, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWLR3ZSTJ7PWC63EI54ECYDYCF33HAVCNFSM6AAAAAA6F5AY72VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBYGEZDIMJRGE . You are receiving this because you modified the open/close state.Message ID: @.***>

franciskafieh avatar Oct 31 '23 22:10 franciskafieh

No worries! You've been super responsive as far as I'm concerned. Also, you're working for free; I'm grateful that you shared your work to begin with! Me putting in the legwork to make a decent bug report is the least I can do :slightly_smiling_face:

joh6nn avatar Oct 31 '23 22:10 joh6nn

I'll need to work on this tomorrow as adding this fork as a dependency is way harder than it should be. Sorry for the delay

franciskafieh avatar Nov 01 '23 02:11 franciskafieh

try release 2.2.2 for me on BRAT. See if that fixes it

franciskafieh avatar Nov 01 '23 12:11 franciskafieh

Ok, one step forward, one step back:

Recounting all my steps in case it's relevant.

I usually leave Obsidian open in the background, so both my main vault and the from-scratch test vault were still running from the other night. I upgraded OLM in the from-scratch vault, closed it, and reopened it by clicking on the vault icon in the window for my main vault.

As expected, it automatically created a new daily, and OLM correctly identified the Daily Note! But: it incorrectly identified what files to list there: I had only just opened the vault, and not created or modified any other files, so there shouldn't have been any files to list. Instead, it listed all 3 files from the notes folder. Both Obsidian and my file browser show the last modified time as Oct 31 for all 3 files :shrug:

image

joh6nn avatar Nov 02 '23 15:11 joh6nn

When the console says File created in that screenshot, what file was created? Would you mind sending me your data.json as well? I don't see how this bug could occur, as the logic is pretty straightforward and shouldn't be affected by the daily note location bug

	if (!lastTrackedDate.isSame(moment(), granularity)) {
		displayNotice(
			"New day/week/month detected, writing tracked files and resetting..."
		);
		await saveSettingsAndWriteTrackedFiles();
		
		// this code resets the tracked files in data.json and saves the files
		settings.trackedFiles = [];
		
		// current date as known by moment, should not be affected by file path bug
		settings.lastTrackedDate = moment().format("YYYY-MM-DD");
		await saveSettings();
	}

franciskafieh avatar Nov 02 '23 16:11 franciskafieh

Edit: this reminds me to add some more specific things to the verbose mode

franciskafieh avatar Nov 02 '23 16:11 franciskafieh