Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions apps/desktop/src/components/editor-area/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,10 @@ export function useEnhanceMutation({
setEnhancedContent: s.updateEnhancedNote,
}));

const getCurrentEnhancedContent = useSession(sessionId, (s) => s.session?.enhanced_memo_html ?? "");

const originalContentRef = useRef<string>("");

const enhance = useMutation({
mutationKey: ["enhance", sessionId],
mutationFn: async ({
Expand All @@ -318,6 +322,7 @@ export function useEnhanceMutation({
triggerType: "manual" | "template" | "auto";
templateId?: string | null;
} = { triggerType: "manual" }) => {
originalContentRef.current = getCurrentEnhancedContent;
const abortController = new AbortController();
setEnhanceController(abortController);

Expand Down Expand Up @@ -408,6 +413,20 @@ export function useEnhanceMutation({
},
}),
onError: (error) => {
toast({
id: "something went wrong",
title: "🚨 Something went wrong",
content: (
<div>
Please try again or contact the team.
<br />
<br />
<span className="text-xs">Error: {String(error.error)}</span>
</div>
),
dismissible: true,
duration: 5000,
});
throw error;
},
messages: [
Expand All @@ -433,10 +452,17 @@ export function useEnhanceMutation({
});

let acc = "";

for await (const chunk of fullStream) {
if (chunk.type === "text-delta") {
acc += chunk.textDelta;
}
if (chunk.type === "error") {
if (originalContentRef.current !== "" && acc === "") {
setEnhancedContent(originalContentRef.current);
}
throw new Error("Error occured right away");
}
if (chunk.type === "tool-call" && freshIsLocalLlm) {
const chunkProgress = chunk.args?.progress ?? 0;
setProgress(chunkProgress);
Expand Down
2 changes: 1 addition & 1 deletion crates/template/assets/enhance.system.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ You will be given multiple inputs from the user. Below are useful information th
- It is super important to acknowledge what the user found to be important, and raw notes show a glimpse of the important information as well as moments during the meeting. Naturally integrate raw note entries into relevant sections instead of forcefully converting them into headers.
- Preserve essential details; avoid excessive abstraction. Ensure content remains concrete and specific.
- Pay close attention to emphasized text in raw notes. Users highlight information using four styles: bold(**text**), italic(_text_), underline(<u>text</u>), strikethrough(~~text~~).
- Recognize H3 headers (### Header) in raw notes—these indicate highly important topics that the user wants to retain no matter what.
- Recognize # headings in raw notes—these indicate highly important topics that the user wants to retain no matter what.
- Below is the guideline on how many changes you should make to the original raw note, please pay close atteion:

{%- if specificity == 1 %}
Expand Down
Loading