diff --git a/package.json b/package.json index cc41fba..cc0787c 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "build:renderer": "cross-env NODE_ENV=production TS_NODE_TRANSPILE_ONLY=true webpack --config ./.erb/configs/webpack.config.renderer.prod.ts", "postinstall": "ts-node .erb/scripts/check-native-dep.js && electron-builder install-app-deps && cross-env NODE_ENV=development TS_NODE_TRANSPILE_ONLY=true webpack --config ./.erb/configs/webpack.config.renderer.dev.dll.ts", "lint": "cross-env NODE_ENV=development eslint . --ext .js,.jsx,.ts,.tsx", - "package": "ts-node ./.erb/scripts/clean.js dist && npm run build && electron-builder build --mac --win --publish never", + "package": "ts-node ./.erb/scripts/clean.js dist && npm run build && electron-builder build --mac --publish never", "rebuild": "electron-rebuild --parallel --types prod,dev,optional --module-dir release/app", "start": "ts-node ./.erb/scripts/check-port-in-use.js && npm run start:renderer", "start:main": "cross-env NODE_ENV=development electronmon -r ts-node/register/transpile-only .", diff --git a/src/renderer/pages/Pile/Editor/Attachments/Attachments.module.scss b/src/renderer/pages/Pile/Editor/Attachments/Attachments.module.scss index c38ea72..96043b3 100644 --- a/src/renderer/pages/Pile/Editor/Attachments/Attachments.module.scss +++ b/src/renderer/pages/Pile/Editor/Attachments/Attachments.module.scss @@ -7,6 +7,7 @@ img { max-height: 350px; + max-width: 100%; border-radius: 22px; transition: all ease-in-out 120ms; diff --git a/src/renderer/pages/Pile/Editor/Attachments/index.jsx b/src/renderer/pages/Pile/Editor/Attachments/index.jsx index 02f7fcd..06e93d6 100644 --- a/src/renderer/pages/Pile/Editor/Attachments/index.jsx +++ b/src/renderer/pages/Pile/Editor/Attachments/index.jsx @@ -1,7 +1,7 @@ import styles from './Attachments.module.scss'; import { useCallback, useState, useEffect } from 'react'; import { DiscIcon, PhotoIcon, TrashIcon, TagIcon } from 'renderer/icons'; -import { motion, AnimatePresence } from 'framer-motion'; +import { motion } from 'framer-motion'; import { usePilesContext } from 'renderer/context/PilesContext'; export default function Attachments({ @@ -20,17 +20,25 @@ export default function Attachments({ if (image_exts.includes(extension)) { return ( -
- {editable && ( -
onRemoveAttachment(attachment)} - > - -
- )} - -
+ +
+ {editable && ( +
onRemoveAttachment(attachment)} + > + +
+ )} + +
+
); } }); diff --git a/src/renderer/pages/Pile/Editor/index.jsx b/src/renderer/pages/Pile/Editor/index.jsx index 9ef6dc4..81ca442 100644 --- a/src/renderer/pages/Pile/Editor/index.jsx +++ b/src/renderer/pages/Pile/Editor/index.jsx @@ -20,6 +20,7 @@ import ProseMirrorStyles from './ProseMirror.scss'; import { useAIContext } from 'renderer/context/AIContext'; import useThread from 'renderer/hooks/useThread'; import LinkPreviews from './LinkPreviews'; +import { useToastsContext } from 'renderer/context/ToastsContext'; export default function Editor({ postPath = null, @@ -44,12 +45,12 @@ export default function Editor({ } = usePost(postPath, { isReply, parentPostPath, reloadParentPost, isAI }); const { getThread } = useThread(); const { ai, prompt } = useAIContext(); + const { addNotification, removeNotification } = useToastsContext(); const isNew = !postPath; const EnterSubmitExtension = Extension.create({ - name: 'customExtension', - + name: 'EnterSubmitExtension', addCommands() { return { triggerSubmit: @@ -203,11 +204,23 @@ export default function Editor({ }; }, [handleSubmit, editor]); + // This has to ensure that it only calls the AI generate function + // on entries added for the AI that are empty. const generateAiResponse = useCallback(async () => { if (!editor) return; if (isAIResponding) return; + const isEmpty = editor.state.doc.textContent.length === 0; + + // isAI makes sure AI responses are only generated for + // AI entries that are empty. if (isAI && isEmpty) { + addNotification({ + id: 'reflecting', + type: 'thinking', + message: 'talking to AI', + dismissTime: 10000, + }); setEditable(false); setIsAiResponding(true); const thread = await getThread(parentPostPath); @@ -220,6 +233,7 @@ export default function Editor({ const message = { role: 'user', content: post.content }; context.push(message); }); + context.push({ role: 'system', content: 'You can only respond in plaintext, do NOT use HTML.', @@ -238,6 +252,7 @@ export default function Editor({ const token = part.choices[0].delta.content; editor.commands.insertContent(token); } + removeNotification('reflecting'); setIsAiResponding(false); } }, [editor, isAI]); @@ -304,37 +319,39 @@ export default function Editor({ )} - - -
0 ? styles.open : '' - }`} + +
0 ? styles.open : '' + }`} > -
- +
+
+ + + +
-
-
+ - {editable && (