Skip to content

Commit a56f760

Browse files
authored
fix duplicated enhanced tab & streaming UI enhancement (#1882)
* feat(enhanced-notes): normalize template id comparisons and include finalizing session mode - Use `templateId || undefined` instead of `templateId ?? undefined` to coerce empty-string values to undefined so template id normalization treats empty strings the same as missing values. Normalize existing template id value (`existingTemplateId || undefined`) before comparison to avoid false mismatches when stored values are empty strings. Treat "finalizing" sessionMode as a running state that short-circuits enhanced-note processing, preventing modification during finalization. ese changes fix incorrect equality checks and ensure enhanced note logic behaves correctly for empty template ids and during finalization. * streaming ui
1 parent 5383c6b commit a56f760

File tree

3 files changed

+24
-19
lines changed

3 files changed

+24
-19
lines changed

apps/desktop/src/components/main/body/sessions/note-input/enhanced/streaming.tsx

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Loader2Icon } from "lucide-react";
2-
import { motion } from "motion/react";
2+
import { LayoutGroup, motion } from "motion/react";
33
import { useCallback, useEffect, useRef } from "react";
44
import { Streamdown } from "streamdown";
55

@@ -20,15 +20,22 @@ export function StreamingView({ enhancedNoteId }: { enhancedNoteId: string }) {
2020

2121
return (
2222
<div ref={containerRef} className="flex flex-col pb-2 space-y-1">
23-
<Streamdown
24-
components={streamdownComponents}
25-
className={cn(["space-y-2"])}
26-
isAnimating={isGenerating}
27-
>
28-
{streamedText}
29-
</Streamdown>
30-
31-
{isGenerating ? <Status taskId={taskId} /> : null}
23+
<LayoutGroup>
24+
<motion.div layout>
25+
<Streamdown
26+
components={streamdownComponents}
27+
className={cn(["space-y-2"])}
28+
>
29+
{streamedText}
30+
</Streamdown>
31+
</motion.div>
32+
33+
{isGenerating && (
34+
<motion.div className="sticky bottom-0 pt-1">
35+
<Status taskId={taskId} />
36+
</motion.div>
37+
)}
38+
</LayoutGroup>
3239
</div>
3340
);
3441
}
@@ -129,11 +136,7 @@ function Status({ taskId }: { taskId: TaskId<"enhance"> }) {
129136
}
130137

131138
return (
132-
<motion.button
133-
layout
134-
initial={{ opacity: 0, y: 10 }}
135-
animate={{ opacity: 1, y: 0 }}
136-
transition={{ duration: 0.25, layout: { duration: 0.15 } }}
139+
<button
137140
className={cn([
138141
"group flex items-center justify-center w-[calc(100%-24px)] gap-3",
139142
"border border-neutral-200 bg-neutral-800 rounded-lg py-3 transition-colors",
@@ -153,7 +156,7 @@ function Status({ taskId }: { taskId: TaskId<"enhance"> }) {
153156
<span className="hidden text-xs text-neutral-50 group-hover:inline group-focus-visible:inline">
154157
Press to cancel
155158
</span>
156-
</motion.button>
159+
</button>
157160
);
158161
}
159162

apps/desktop/src/hooks/useEnhancedNotes.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export function useCreateEnhancedNote() {
1212
(sessionId: string, templateId?: string) => {
1313
if (!store || !indexes) return null;
1414

15-
const normalizedTemplateId = templateId ?? undefined;
15+
const normalizedTemplateId = templateId || undefined;
1616

1717
const existingNoteIds = indexes.getSliceRowIds(
1818
main.INDEXES.enhancedNotesBySession,
@@ -25,7 +25,8 @@ export function useCreateEnhancedNote() {
2525
id,
2626
"template_id",
2727
) as string | undefined;
28-
return existingTemplateId === normalizedTemplateId;
28+
const normalizedExisting = existingTemplateId || undefined;
29+
return normalizedExisting === normalizedTemplateId;
2930
});
3031

3132
if (existingId) return existingId;
@@ -143,6 +144,7 @@ export function useEnsureDefaultSummary(sessionId: string) {
143144
!hasTranscript ||
144145
sessionMode === "running_active" ||
145146
sessionMode === "running_batch" ||
147+
sessionMode === "finalizing" ||
146148
(enhancedNoteIds && enhancedNoteIds.length > 0)
147149
) {
148150
return;

apps/desktop/src/store/zustand/ai-task/task-configs/enhance-workflow.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const enhanceWorkflow: Pick<
3131
transforms: [
3232
trimBeforeMarker("#"),
3333
addMarkdownSectionSeparators(),
34-
smoothStream({ delayInMs: 350, chunking: "line" }),
34+
smoothStream({ delayInMs: 250, chunking: "line" }),
3535
],
3636
};
3737

0 commit comments

Comments
 (0)