debanjandhar12 / logseq-chatgpt-plugin

A tightly integrated ChatGPT plugin for Logseq.
GNU Affero General Public License v3.0
108 stars 10 forks source link

Problem with Graphs Stored in iCloud #17

Open nkdem opened 1 year ago

nkdem commented 1 year ago

Hi there, I noticed that whenever I create a new ChatGPT page, I cannot quit Logseq becasue of the message Logseq is syncing internal status, please wait for several seconds as shown in the image below image

After some dabbling, I realise this has to do with because my Graph is stored in an iCloud folder. However, I noticed that when removing the property chatgpt-flow:: alternating, I can quit after all

So I thought I'd modify https://github.com/debanjandhar12/logseq-chatgpt-plugin/blob/6c81eb8ac1fc8abbabfcaaffe1967ca9c64eae5f/src/core/ChatgptPageFromPrompt.ts#L67

to instead be

  public static async createChatGPTPageAndGoToIt(pageName: string = "", additionalPageProps= {}, firstBlockContent = "") {
        pageName = pageName || "chatgpt__" + moment().format('YYYY-MM-DD HH:mm:ss');
        const pageProperties = {
            'type': 'ChatGPT',
            'chatgpt-flow': 'alternating',
            ...additionalPageProps
        }
        const page = await logseq.Editor.createPage(pageName, {},  {format: "markdown"});
        // change page propertiesq
        const blocks = await logseq.Editor.getPageBlocksTree(pageName);
        for (const [key, value] of Object.entries(pageProperties)) {
            await logseq.Editor.upsertBlockProperty(blocks[0].uuid, key, value);
        }

        if (firstBlockContent != "") 
        await logseq.Editor.insertBlock(pageName, `speaker:: [[user]]\n${firstBlockContent}`);
    }

While it resolves the quitting, I seem to have broken other functionality. So I thought I'd give you a headstart on this since I don't know enough about the Logseq API as of yet to be able to do a full PR.

STEPS TO REPRODUCE: Create a Graph in iCloud Create a new ChatGPT page Quitting should result in Logseq is syncing internal status, please wait for several seconds

debanjandhar12 commented 1 year ago

This is most likely a bug in logseq. I created a issue for it https://github.com/logseq/logseq/issues/9106#issue-1669317227.