silverbulletmd / silverbullet

The knowledge hacker's notebook
https://silverbullet.md
MIT License
2.29k stars 167 forks source link

Object decorators not working in sync mode #1002

Closed meain closed 1 month ago

meain commented 1 month ago

objectDecorators defined in settings does not seem to apply when in sync mode. The ones defined in the page's frontmatter does work.

meain commented 1 month ago

I see the following in the JS console:

Screenshot 2024-07-30 at 12 40 10โ€ฏPM

meain commented 1 month ago

It just started working in sync mode on desktop browser, but not on mobile. I'm starting to think it is possible that it is some syncing issue. The settings page in mobile does have the new content, I also ran a "Sync now" and "Reload" and a page refresh just in case, but still the same issue.

zefhemel commented 1 month ago

This does sound like perhaps the new versions of the builtin plugs haven't synced locally yet. Can you let it do a full sync (just keep the page open for some time, 20-30s at least) to make sure this all synced and then reload? For me it works. You can also try on https://silverbullet.md.

meain commented 1 month ago

I kept it open for over a minute. There was a point at which I got the toc decoration to work, but all the others include decorations defined within the page not working. I also did another round of plug/library update, sync and reload as well.

The logs in the server was relatively silent with it requesting the index page once in a while. I did however see the following error in the logs. The silverbullet-ai plugin was throwing an error (cc @justyns), but then again it is running in a separate worker.

An exception was thrown as a result of invoking function indexEmbeddings error: Cannot read properties of undefined (reading 'generateEmbeddings')
Error dispatching event page:index to silverbullet-ai.indexEmbeddings: Cannot read properties of undefined (reading 'generateEmbeddings')
An exception was thrown as a result of invoking function parseIndexTextRepublish error: Cannot read properties of undefined (reading 'generateEmbeddings')
Error dispatching event page:index_text to index.parseIndexTextRepublish: Cannot read properties of undefined (reading 'generateEmbeddings')
Write failed Error: Cannot read properties of undefined (reading 'generateEmbeddings')
    at WorkerSandbox.onMessage (file:///Users/meain/dev/src/silverbullet/lib/plugos/sandboxes/worker_sandbox.ts:93:30)
    at Worker.worker.onmessage (file:///Users/meain/dev/src/silverbullet/lib/plugos/sandboxes/worker_sandbox.ts:59:14)
    at Worker.wrappedHandler (ext:deno_web/02_event.js:1401:12)
    at innerInvokeEventListeners (ext:deno_web/02_event.js:754:7)
    at invokeEventListeners (ext:deno_web/02_event.js:801:5)
    at dispatch (ext:deno_web/02_event.js:658:9)
    at Worker.dispatchEvent (ext:deno_web/02_event.js:1043:12)
    at Worker.#pollMessages (ext:runtime/11_workers.js:253:12)
    at eventLoopTick (ext:core/01_core.js:168:7)

EDIT: I did see the 100% thingy multiple times during this in the UI next to the sync button btw.

meain commented 1 month ago

Could it be related to https://github.com/silverbulletmd/silverbullet/issues/990 ? In case it helps justyns, here is what I have for silverbullet-ai in my SETTINGS:

ai:
  imageModels:
  - name: dall-e-3
    modelName: dall-e-3
    provider: dalle
  - name: dall-e-2
    modelName: dall-e-2
    provider: dalle
  textModels:
  - name: gpt-4o-mini
    provider: openai
    modelName: gpt-4o-mini
  - name: gpt-4o
    provider: openai
    modelName: gpt-4o
  chat:
    userInformation: >
      I'm a software developer who likes taking notes.
    userInstructions: >
      Please give short and concise responses.  When providing code, do so in golang unless requested otherwise.  If we are talking about APIs a simple just give me urls and not code to do the network request.

The ai plugin does work though.

zefhemel commented 1 month ago

Could you try uninstalling the ai plug and see if that changes anything?

justyns commented 1 month ago

Can you try setting embeddingModels: [] in the ai section of your settings and see if that error goes away?

I'll take a look at the code later today dor a better fix, but I'm assuming it's trying to read that and can't

meain commented 1 month ago

@zefhemel removing the ai plug did not seem to help , well kinda. I have 8 decorations in my SETTINGS, once of which is to hide toc for my index page. That one does seem to work, but none of the others do(not even the ones I have directly added in a page). (back to none working after another sync and system reload). I btw do see Loaded 8 object decorators in the server logs.

@justyns I am getting the error even with embeddingModels: [] added under ai:.

meain commented 1 month ago

Interestingly, after all this experimentation decorations stopped working even in online mode on my phone.

zefhemel commented 1 month ago

What decorators did you define?

meain commented 1 month ago
objectDecorators:
- where: "tags = 'person'"
  attributes:
    pageDecoration.prefix: '"๐Ÿง‘ "'
- where: "tags = 'family'"
  attributes:
    pageDecoration.prefix: '"๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ "'
- where: "tags = 'video'"
  attributes:
    pageDecoration.prefix: '"๐Ÿ“น "'
- where: "name =~ /Journal\\/Day\\/*/"
  attributes:
    pageDecoration.prefix: '"๐Ÿ—“๏ธ "'
- where: "name =~ /Backlog\\/*/"
  attributes:
    pageDecoration.prefix: '"โœ… "'
- where: "name = 'home'"
  attributes:
   pageDecoration.disableTOC: "true"
- where: 'tags = "notoc"'
  attributes:
     pageDecoration.disableTOC: "true"
- where: "tags = 'hidden'"
  attributes:
    pageDecoration.hide: "true"
justyns commented 1 month ago

I'm not sure if it was actually related to this issue or not, but the silverbullet-ai.indexEmbeddings: Cannot read properties of undefined error you were seeing should be fixed now @meain

meain commented 1 month ago

I'm not sure if it was actually related to this issue or not, but the silverbullet-ai.indexEmbeddings: Cannot read properties of undefined error you were seeing should be fixed now @meain

Yup, don't think this was the cause I was having the issue even with the PLUG removed. Thanks for fixing it though :D.

meain commented 1 month ago

This is mostly likely a sync issue. I just updated to latest SB and did a refresh and things seem to work. Closing this issue for now.

zefhemel commented 1 month ago

Ok. I couldn't replicate it and have a mix of sync and server mode clients.