Skip to content

Commit 22ccb92

Browse files
authored
Merge pull request #118 from techulus/develop
Improve proof reading
2 parents 0cadb75 + 8b89672 commit 22ccb92

6 files changed

Lines changed: 39 additions & 5 deletions

File tree

apps/web/components/dialogs/ai-expand-concept-prompt-dialog.component.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export default function AiExpandConceptPromptDialogComponent({
7171
leaveFrom="opacity-100 translate-y-0 sm:scale-100"
7272
leaveTo="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
7373
>
74-
<div className="inline-block align-bottom bg-white dark:bg-gray-900 rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full">
74+
<div className="inline-block align-bottom bg-white dark:bg-gray-900 rounded-lg text-left overflow-hidden shadow-xl transform transition-all w-full mx-4 sm:mx-0 sm:my-8 sm:align-middle sm:max-w-4xl sm:w-full">
7575
<div className="bg-white dark:bg-gray-900 px-4 pt-5 pb-4 sm:p-6 sm:pb-4">
7676
<div className="sm:flex sm:items-start">
7777
<div className="mt-3 text-center sm:mt-0 sm:text-left w-full">
@@ -94,7 +94,7 @@ export default function AiExpandConceptPromptDialogComponent({
9494
<div className="mt-5 w-full">
9595
<div className="mt-1 space-y-1">
9696
<dd className="mt-1 text-sm text-gray-900">
97-
<div className="rounded-md border border-gray-200 dark:border-gray-600 dark:divide-gray-600 p-4">
97+
<div className="rounded-md border border-gray-200 dark:border-gray-600 dark:divide-gray-600 p-4 max-h-[60vh] overflow-y-auto">
9898
{isLoading && !completion && <SpinnerWithSpacing />}
9999

100100
<div className="text-black dark:text-white prose dark:prose-invert prose-sm max-w-none">

apps/web/components/dialogs/ai-prood-read-dialog.component.tsx

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,17 @@ import { Fragment, useEffect, useRef } from "react";
66
import { Streamdown } from "streamdown";
77
import { notifyError } from "../core/toast.component";
88

9-
export default function AiProofReadDialogComponent({ open, setOpen, content }) {
9+
export default function AiProofReadDialogComponent({
10+
open,
11+
setOpen,
12+
content,
13+
onReplace,
14+
}: {
15+
open: boolean;
16+
setOpen: (open: boolean) => void;
17+
content: string;
18+
onReplace?: (content: string) => void;
19+
}) {
1020
const cancelButtonRef = useRef(null);
1121

1222
const { completion, complete, isLoading, setCompletion } = useCompletion({
@@ -65,7 +75,7 @@ export default function AiProofReadDialogComponent({ open, setOpen, content }) {
6575
leaveFrom="opacity-100 translate-y-0 sm:scale-100"
6676
leaveTo="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
6777
>
68-
<div className="inline-block align-bottom bg-white dark:bg-gray-900 rounded-lg text-left overflow-hidden shadow-xl transform transition-all sm:my-8 sm:align-middle sm:max-w-lg sm:w-full">
78+
<div className="inline-block align-bottom bg-white dark:bg-gray-900 rounded-lg text-left overflow-hidden shadow-xl transform transition-all w-full mx-4 sm:mx-0 sm:my-8 sm:align-middle sm:max-w-4xl sm:w-full">
6979
<div className="bg-white dark:bg-gray-900 px-4 pt-5 pb-4 sm:p-6 sm:pb-4">
7080
<div className="sm:flex sm:items-start">
7181
<div className="mt-3 text-center sm:mt-0 sm:text-left w-full">
@@ -88,7 +98,7 @@ export default function AiProofReadDialogComponent({ open, setOpen, content }) {
8898
<div className="mt-5 w-full">
8999
<div className="mt-1 space-y-1">
90100
<dd className="mt-1 text-sm text-gray-900">
91-
<div className="rounded-md border border-gray-200 dark:border-gray-600 dark:divide-gray-600 p-4">
101+
<div className="rounded-md border border-gray-200 dark:border-gray-600 dark:divide-gray-600 p-4 max-h-[60vh] overflow-y-auto">
92102
{isLoading && !completion && <SpinnerWithSpacing />}
93103

94104
<div className="text-black dark:text-white prose dark:prose-invert prose-sm max-w-none">
@@ -103,6 +113,19 @@ export default function AiProofReadDialogComponent({ open, setOpen, content }) {
103113
</div>
104114

105115
<div className="bg-gray-50 dark:bg-gray-900 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse">
116+
{onReplace && (
117+
<button
118+
type="button"
119+
disabled={isLoading || !completion}
120+
className="w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-indigo-600 text-base font-medium text-white hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 sm:ml-3 sm:w-auto sm:text-sm disabled:opacity-50 disabled:cursor-not-allowed"
121+
onClick={() => {
122+
onReplace(completion);
123+
setOpen(false);
124+
}}
125+
>
126+
Replace Content
127+
</button>
128+
)}
106129
<button
107130
type="button"
108131
className="mt-3 w-full inline-flex justify-center rounded-md border border-gray-300 dark:border-gray-700 shadow-sm px-4 py-2 text-base font-medium text-gray-700 dark:text-gray-200 bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 sm:mt-0 sm:ml-3 sm:w-auto sm:text-sm"

apps/web/components/forms/post-form.component.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,9 @@ export default function PostFormComponent({
702702
setOpen={(open: boolean) => {
703703
setPromptProofRead(open);
704704
}}
705+
onReplace={(content: string) => {
706+
formik.setFieldValue("content", content);
707+
}}
705708
/>
706709
</div>
707710
);

apps/web/pages/api/ai/free-changelog-generator.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ You are a changelog writer. Generate a well-formatted changelog based on the pro
2626
Format the output as markdown with clear sections and bullet points.
2727
Tone: ${tone === "casual" ? "Write in a casual, friendly tone" : "Write in a formal, professional tone"}
2828
${intro === "Add a short intro and outro, make sure its generic and polite." ? "Include a brief intro and outro paragraph." : "Do not add any introduction or conclusion - just the changelog content."}
29+
30+
IMPORTANT: Never remove any images, image tags, or image URLs from the input. All images must be preserved exactly as they appear in the original content.
2931
</instructions>`,
3032
prompt: `<input>
3133
${content}

apps/web/pages/api/ai/proof-read.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ const proofRead = withAuth(async (req, res) => {
1919
},
2020
prompt: `Proofread and improve the following changelog content. Fix any grammar, spelling, or clarity issues while maintaining the original meaning and tone. Return only the improved text without any explanations.
2121
22+
IMPORTANT: Never remove any images, image tags, or image URLs from the content. All images must be preserved exactly as they appear in the original.
23+
2224
Content:
2325
${content}`,
2426
});

apps/web/utils/changelog-ai.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ Example: "Created a changelog highlighting the new user authentication system wi
7777
7878
Keep it to 1-2 sentences. Be specific about the main features/changes covered.
7979
</summary-rules>
80+
81+
<media-rules>
82+
IMPORTANT: Never remove any images, videos, embeds, or other media from the content unless the user explicitly requests their removal. All media must be preserved exactly as they appear.
83+
</media-rules>
8084
</instructions>
8185
8286
${

0 commit comments

Comments
 (0)