Real-Time Scanning #618
Replies: 8 comments 15 replies
-
|
Hi @MrDaisyBates ! Thank you for bringing this up. Because, recently even I was thinking on this topic and also I think I havent spoke on this topic before, but an overview is present in the docs : https://tu2-atmanand.github.io/task-board-docs/docs/Features/Auto_Scanning_Files/#real-time-scanning Now, your concern is valid here. While designing this plugin, I keep a note of this case. Becuase Obsidian works on simple text files which lies on your system. The data is not stored inside any database or custom file formats like other note-taking apps. So, for any user its very easy to edit the files outside Obsidian. And this will likely going to create a lot of conflicts when a plugin within Obsidian environment is trying to make operations on the same file simultaneously. For example, this kind of situation is very likely during sync operation, specially if user is using an external sync service like apple cloud, dropbox, etc. As you have correctly mentioned, to handle this case, I implemented the "Auto scan the vault on Obsidian startup" feature. But this feature only works when you open the Obsidian application after the changes was made to the note in the vault. Possible SolutionsNow, to address the case which you have mentioned. That is, when the Obsidian application is open and you are making changes the files from the vault through an external application. I have two solutions for this. But these below solutions will only work, if Obsidian itself will be able to detect the file changes through this external application. Can you please test this :
All plugins depends on the APIs provided by Obsidian, so if Obsidian itself can able to detect these changes in real-time, then it will be very easy for Task Board to detect them. Please confirm this, to get better understanding. An indicator approachAn easiest solution will be and I think this will be implemented anyways in the future is to provide an indicator on the "Refresh" button whenever a file has been updated, either through Obsidian or through any external service. Advantages :
Disadvantages :
A True Real-Time Scanning approachNow, just to give an overview of why Task Board's Real-time scanning was designed the way it is now, is because, whenever a user is making any changes to the note, a trigger is fired continuously. For example, if user is typing something in the Obsidian editor, a trigger is fired every 1 second to indicate that a particular file has been updated. The problem is, Task Board cannot know, for sure, when user has stopped making the changes to the note. So Task Board also has to depend on this trigger to update its cache. And, if say, we make Task Board to work in "True Real-time" mode, it will continuously be scanning the file every one second and if the view is opened, it will be continuously be refreshing the view every 1 second. Now, even though it looks very minimal processing operations and with latest hardware, these operations looks insignificant. But still these operations are consuming power. And I have this ADHD (or I dont know if I am too optimist), it doesnt feel right to me. I feel like these are unnecessary power consumptions and a better approach can be used. Hence, I came up with this case where, even though user will be typing continuously in the note, Task Board will scan the file and update the view only after user has switched their focus from that editor. But, I also have noticed that (rarely), sometimes these event of user switching the focus from the editor to other tabs is not detected properly and it misses to update the view, which can lead to conflicts, but this is very rare. (I guess the indicator will be able to help users to take a note of this in future) Coming back to this "True Real-time" scanning mode approach, then its simple to implement, but I will still need to think more on a better approach. You will also see this approach being used by the CardBoard plugin. Let me know if CardBoard plugin is able to scan the changes made through external application in real-time. This information will help to get more understanding on this mechanism of Obsidian. Advantages :
Disadvantages :
|
Beta Was this translation helpful? Give feedback.
-
|
Hello again, @tu2-atmanand ! Yes, so, I basically did exactly as you suggested. I:
I'm certainly not a programmer at this point in my life (though I've been pondering over the years how essential of a skill it is and I'd like to make time to learn some basics in the future. Maybe next year). Rationally, I have a general sense as to why this situation is so complicated even if I don't fully grasp the challenge of implementation. In my mind, I almost imagine a long term solution being kind of like git in the fact that, unless designated otherwise, any changes within the Obsidian vault folder would start being "tracked" automatically in this case, and if a task's text formatting appeared, it would populate it into Task Board. I assume this is something that maybe you are restricted from doing for some reason (maybe there's a privilege restriction, or maybe there's huge performance restrictions, etc. Again, it's over my head, for sure). I am very sympathetic about the ethics/morality of purposely making an incredibly inefficient plugin that is scanning every 1 second as you described. That's kind of why I'm talking from a perspective I understand, even if it's limited in this case. Git is def the thing that keeps coming to mind for me because it's the closest thing I can think of. I'm guessing git tracking a folder is implemented how you described? Git is so old and I'd assume it'd have a more effective and efficient approach than that, but I can't know. I will also take your advice and try the CardBoard plugin and see what result I get in that context and I'll update you on the status following. It may be a few hours before I get a chance to try, but soon enough. I saw the plugin when I found yours but I hadn't tried it (I mainly avoided it because it appeared as if it hadn't been maintained for a while). Anyways, thanks again for your consideration on this matter. I'm optimistic we can find a solution that works for my case as well as is far more efficient than your worst case scenario of scanning every second, for example. |
Beta Was this translation helpful? Give feedback.
-
|
I know I wasn't explicitly asked to, @tu2-atmanand , but I'm in regular contact with the developer of Tangent, so I've actually reached out to him directly and he seemed welcoming to being able to potentially have his brain picked on the topic. I've stated the general nature of the issue in the Discord and I've also linked our discussion. I'm not sure if he will prefer to come here directly himself or if I'll just relay it from the Discord. He's quite familiar with the context and he's incredibly experienced, which is why I asked him in the first place. I'm sure you don't mind and you're more than welcoming of it. I just wanted to give a headsup so it's not out of the blue. |
Beta Was this translation helpful? Give feedback.
-
|
After talking to Tangent's creator, while he's not an Obsidian Plugin developer, he seems quite confident that this command would do the job at detecting changes to any file, even if it was changed via Tangent. My understanding is it also wouldn't require it to scan the vault every second, for example, as you were originally concerned about. https://docs.obsidian.md/Reference/TypeScript+API/Vault/on('modify') |
Beta Was this translation helpful? Give feedback.
-
|
Also, the reason why I am researching on finding an optimized approach for detecting file updates when user is continuously typing inside a note which is triggering the 'file modified' event is because. Few months back, this topic caught my attention : https://forum.obsidian.md/t/disable-auto-save-or-change-frequency/14230 |
Beta Was this translation helpful? Give feedback.
-
|
Alright! Now, just to revise everything again, here is a problem we are trying to solve : If a user is continuously typing inside a note, may it be within Obsidian or may it be an external application like tangent. The thing which matters is when this data is being stored to the disk. For example, below is the demo, with both Obsidian and Tangent software : With ObsidianSo, on the left you may see the events triggered whenever the file is being saved to the disk. What this means is, Obsidian saves your changes every 2 seconds to the disk. The software is designed this way, so user never looses their data. But, the problem here is that, all the plugins relies on this event to find out if any file has been updated or not. And since, Obsidian is triggering this event, even when the user is continuously typing in the note. As a plugin developer, I found this approach very inefficient. But as a user this is a very powerful approach, since user will never going to loose their data. In events like the system suddenly shuts down and all. With TangentMy first impression of this software, I am really impressed. Because, this software has used the same approach which I used while developing Task Board. Because, as you can see Tangent software is not saving your changes to the disk in real-time. It only saves them, when user changes their focus from either that file to another file or switches to a different application itself. Thats why in this case, the event is only triggered when I switched to a different window after making this changes. Further thoughtsSo, its definitely possible to upgrade Task Board with this third mode, where, when user will make any changes in external applications and switches to Task Board, their changes will be instantly refreshed. But to show what a "True Real Time" mode is, which is how the CardBoard plugin works by default. Here is an Gif : Here you may see that, whenever a user is making changes to their note, their whole focus should be inside the note, but since Obsidian triggers the event every two seconds, the CardBoard view is getting refreshed every 2 seconds. According to me, this is both inefficient as well as unnecessary, since if user is typing in their notes, their whole focus is in the editor, so the CardBoard view need not have to update in real-time. It should only refresh after user has stopped typing or basically when user switches to the CardBoard tab. And the reason why this is inefficient is because, even todays mid-range systems wont show any performance lag with this real-time operations, still there is a power consumption going on. A "True Real Time" mode in Task Board will look something like this. But, now that I have used Tangent, I will also make sure that :
|
Beta Was this translation helpful? Give feedback.
-
Development UpdateOkay, So I have implemented the feature I have explained in the following ticket : #619 Here is how its going to work... Setting
User can select the mode in which Task Board should work for scanning their updated/modified files. Rea-time modeThis is a true real-time scanning mode, just like how its in the CardBoard plugin. And to be honest, because there are so many additional features implemented in Task Board, I thought this feature will consume a little more CPU while user is contineously typing in the note. But, its exactly same CPU usage as it is in the CardBoard plugin. Again, I personally will not going to use this mode ever. It looks good and all. But practically speaking, I dont think, users will ever want it, even if they are on their multi-monitor setup. Or I dont know, maybe it will have a very important use-case if users are syncing in real-time, etc.. For now, I have simply implemented it as a feature and also in an attempt to implement/solve the functionality discussed by @MrDaisyBates in this discussion topic. But there is a good news, this functionality of "refreshing the board when changes have been made from external source/application", is now possible with the default "Balanced" mode itself, as explained below... Balanced modeThis is basically the default mode, which is available in older version with the name "Real-time scanning" setting. The name earlier was a little confusing, as it wasnt exactly a "real-time" mode earlier. In this mode, the plugin only detects which files has been modified. And when user switches their focus from one tab to another or from one window to another, it proceeds with the scanning process for these files and updates the content on the board. Thats, why its a balanced version, where nothing is running in the background when user is typing in their note and the board only refreshes when user is actually focused on the board. In this mode itself, I implemented an additional event listener, where, when user will make any changes in any external software => the file will be updated on the disk => Obsidian will then pick up this changes => And as soon as Obsidian will reads this changes it will notify Task Board => Task Board will scan the files and update the content on the Board. So, in this mode itself, I hope I have implemented the requested feature. But, there are various other cases like some files updates in background, maybe in case of external syncing or something and if Obsidian didnt pick this changes. Then this will be the limitation of Obsidian and a plugin wont able to do anything in here. I am also brainstorming on handling part of this situation, but not sure if a plugin will able to do this. Read the forum topic here : https://forum.obsidian.md/t/fr-maintain-a-registry-of-all-the-files-which-has-been-modified-when-obsidian-was-closed/110122?u=tu2_atmanand Manual modeIn this mode, Task Board will only know which files have been updated by the user and it will keep a note of those files. But it will not do any background work, until user manually clicks on the refresh button and fetches the latest changes. In the Balanced mode and Manual mode, I have provide an indicator on the refresh button, which tells the user that, some files has been modified and they should click on this button before making any changes through the board. I have kept this feature in the Balanced mode because sometimes, Obsidian or Task Board doesnt able to capture the event when user switches from one tab to another or from one window to another. In this case, the indicator will be a sign that some modified changes has not been scanned yet. Will improve this feature moving forward. Testing with TangentThis has been tested in both "Real-time" and "Balanced" mode. As soon as user will switch away from the Tangent application or when the Tangent application will write the changes to the disk, these changes are picked up by Obsidian and are notified to the Task Board. And rest scanning happens as usual. So latest changes will be present on the Board. |
Beta Was this translation helpful? Give feedback.
-
Auto detect modified files when Obsidian was inactiveWhile working on this "Scanning modes" feature, I realized there was another very serious problem which I should handle now. (And which still going to need a lot of attention in the future.). For now, I have handled this case as explained in the following ticket : #641 . This looks related to the current discussion hence sharing it here. |
Beta Was this translation helpful? Give feedback.








Uh oh!
There was an error while loading. Please reload this page.
-
I'm guessing the real-time scanning only detects changes to the markdown file if it was done inside of Obsidian?
I'm a bit of an outlier. I tend to use Tangent to type, create, etc my notes, and I primarily use Obsidian just to interact with my notes (bases, graph view, etc).
Tangent is pretty "pure" in the fact that any changes to files (regardless of where they come from), they just show up in Tangent in real time. So, I was kind of surprised when (while Obsidian was open), I tampered with something that was on my to do list (in Tangent), and then I tried to mark it completed in Task Board, and it prompted me with a conflict. Kind of "git" styled.
I see there's a scan upon opening of Obsidian option, but I suppose the way the plugin is made, a true real-time experience is out of the question? I'm likely to create these conflicts frequently as I tend to keep Tangent and Obsidian open simultaneously and dance back and forth between them depending on what I'm doing.
Beta Was this translation helpful? Give feedback.
All reactions