Skip to content

Commit 8e269b6

Browse files
authored
Revert "Chat refactor new db final (with use chat) (#1456)" (#1475)
This reverts commit 9dc96a4.
1 parent d9b59a4 commit 8e269b6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+3267
-2969
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,4 @@ internal
1616
.turbo
1717

1818
.windsurfrules
19-
CLAUDE.md
20-
.cursor/
19+
CLAUDE.md

apps/desktop/src/components/editor-area/index.tsx

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { TemplateService } from "@/utils/template-service";
1212
import { commands as analyticsCommands } from "@hypr/plugin-analytics";
1313
import { commands as connectorCommands } from "@hypr/plugin-connector";
1414
import { commands as dbCommands } from "@hypr/plugin-db";
15-
import { events as localLlmEvents } from "@hypr/plugin-local-llm";
1615
import { commands as miscCommands } from "@hypr/plugin-misc";
1716
import { commands as templateCommands, type Grammar } from "@hypr/plugin-template";
1817
import Editor, { type TiptapEditor } from "@hypr/tiptap/editor";
@@ -362,21 +361,6 @@ export function useEnhanceMutation({
362361
const [isCancelled, setIsCancelled] = useState(false);
363362
const queryClient = useQueryClient();
364363

365-
useEffect(() => {
366-
let unlisten: () => void;
367-
localLlmEvents.llmEvent.listen(({ payload }) => {
368-
if (payload.progress) {
369-
setProgress(payload.progress);
370-
}
371-
}).then((fn) => {
372-
unlisten = fn;
373-
});
374-
375-
return () => {
376-
unlisten();
377-
};
378-
}, []);
379-
380364
// Extract H1 headers at component level (always available)
381365
const extractH1Headers = useCallback((htmlContent: string): string[] => {
382366
if (!htmlContent) {

apps/desktop/src/components/right-panel/components/chat/chat-input.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ export function ChatInput(
153153

154154
const traverseNode = (node: any) => {
155155
if (node.type === "mention" || node.type === "mention-@") {
156-
if (node.attrs && node.attrs.type !== "selection") {
156+
if (node.attrs) {
157157
mentions.push({
158158
id: node.attrs.id || node.attrs["data-id"],
159159
type: node.attrs.type || node.attrs["data-type"] || "note",
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { MessageContent } from "./message-content";
2+
import { Message } from "./types";
3+
4+
interface ChatMessageProps {
5+
message: Message;
6+
sessionTitle?: string;
7+
hasEnhancedNote?: boolean;
8+
onApplyMarkdown?: (markdownContent: string) => void;
9+
}
10+
11+
export function ChatMessage({ message, sessionTitle, hasEnhancedNote, onApplyMarkdown }: ChatMessageProps) {
12+
if (message.isUser) {
13+
return (
14+
<div className="w-full mb-4 flex justify-end">
15+
<div className="max-w-[80%]">
16+
<div className="border border-input rounded-lg overflow-clip bg-white">
17+
<div className="px-3 py-2">
18+
<MessageContent
19+
message={message}
20+
sessionTitle={sessionTitle}
21+
hasEnhancedNote={hasEnhancedNote}
22+
onApplyMarkdown={onApplyMarkdown}
23+
/>
24+
</div>
25+
</div>
26+
{/* Timestamp below the message */}
27+
<div className="text-xs text-neutral-500 mt-1 text-right">
28+
{message.timestamp.toLocaleTimeString([], {
29+
hour: "2-digit",
30+
minute: "2-digit",
31+
})}
32+
</div>
33+
</div>
34+
</div>
35+
);
36+
}
37+
38+
return (
39+
<div className="w-full mb-4">
40+
<MessageContent
41+
message={message}
42+
sessionTitle={sessionTitle}
43+
hasEnhancedNote={hasEnhancedNote}
44+
onApplyMarkdown={onApplyMarkdown}
45+
/>
46+
</div>
47+
);
48+
}

apps/desktop/src/components/right-panel/components/chat/chat-messages-view.tsx

Lines changed: 19 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
import type { UIMessage } from "@hypr/utils/ai";
21
import { useEffect, useRef, useState } from "react";
3-
import { UIMessageComponent } from "./ui-message";
2+
import { ChatMessage } from "./chat-message";
3+
import { Message } from "./types";
44

55
interface ChatMessagesViewProps {
6-
messages: UIMessage[];
6+
messages: Message[];
77
sessionTitle?: string;
88
hasEnhancedNote?: boolean;
99
onApplyMarkdown?: (markdownContent: string) => void;
10-
isSubmitted?: boolean;
11-
isStreaming?: boolean;
12-
isReady?: boolean;
13-
isError?: boolean;
10+
isGenerating?: boolean;
11+
isStreamingText?: boolean;
1412
}
1513

1614
function ThinkingIndicator() {
@@ -32,7 +30,7 @@ function ThinkingIndicator() {
3230
}
3331
`}
3432
</style>
35-
<div style={{ color: "rgb(115 115 115)", fontSize: "0.875rem", padding: "0 0 8px 0" }}>
33+
<div style={{ color: "rgb(115 115 115)", fontSize: "0.875rem", padding: "4px 0" }}>
3634
<span>Thinking</span>
3735
<span className="thinking-dot">.</span>
3836
<span className="thinking-dot">.</span>
@@ -43,45 +41,27 @@ function ThinkingIndicator() {
4341
}
4442

4543
export function ChatMessagesView(
46-
{ messages, sessionTitle, hasEnhancedNote, onApplyMarkdown, isSubmitted, isStreaming, isReady, isError }:
47-
ChatMessagesViewProps,
44+
{ messages, sessionTitle, hasEnhancedNote, onApplyMarkdown, isGenerating, isStreamingText }: ChatMessagesViewProps,
4845
) {
4946
const messagesEndRef = useRef<HTMLDivElement>(null);
5047
const [showThinking, setShowThinking] = useState(false);
5148
const thinkingTimeoutRef = useRef<NodeJS.Timeout | null>(null);
5249

5350
const shouldShowThinking = () => {
54-
// Show thinking when request is submitted but not yet streaming
55-
if (isSubmitted) {
51+
if (!isGenerating) {
52+
return false;
53+
}
54+
55+
if (messages.length === 0) {
5656
return true;
5757
}
5858

59-
// Check if we're in transition between parts (text → tool or tool → text)
60-
if (isStreaming && messages.length > 0) {
61-
const lastMessage = messages[messages.length - 1];
62-
if (lastMessage.role === "assistant" && lastMessage.parts) {
63-
const lastPart = lastMessage.parts[lastMessage.parts.length - 1];
64-
65-
// Text part finished but still streaming (tool coming)
66-
if (lastPart?.type === "text" && !(lastPart as any).state) {
67-
return true;
68-
}
69-
70-
// Tool finished but still streaming (more text/tools coming)
71-
if (lastPart?.type?.startsWith("tool-") || lastPart?.type === "dynamic-tool") {
72-
const toolPart = lastPart as any;
73-
if (
74-
toolPart.state === "output-available"
75-
|| toolPart.state === "output-error"
76-
) {
77-
return true;
78-
}
79-
}
80-
}
59+
const lastMessage = messages[messages.length - 1];
60+
if (lastMessage.isUser) {
61+
return true;
8162
}
8263

83-
// Fallback for other transition states
84-
if (!isReady && !isStreaming && !isError) {
64+
if (!lastMessage.isUser && !isStreamingText) {
8565
return true;
8666
}
8767

@@ -109,16 +89,16 @@ export function ChatMessagesView(
10989
clearTimeout(thinkingTimeoutRef.current);
11090
}
11191
};
112-
}, [isSubmitted, isStreaming, isReady, isError, messages]);
92+
}, [isGenerating, isStreamingText, messages]);
11393

11494
useEffect(() => {
11595
messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
11696
}, [messages, showThinking]);
11797

11898
return (
119-
<div className="flex-1 overflow-y-auto px-6 py-4 space-y-6 select-text">
99+
<div className="flex-1 overflow-y-auto p-4 space-y-4 select-text">
120100
{messages.map((message) => (
121-
<UIMessageComponent
101+
<ChatMessage
122102
key={message.id}
123103
message={message}
124104
sessionTitle={sessionTitle}

apps/desktop/src/components/right-panel/components/chat/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
export * from "./chat-history-item";
22
export * from "./chat-history-view";
33
export * from "./chat-input";
4+
export * from "./chat-message";
45
export * from "./chat-messages-view";
56
export * from "./empty-chat-state";
67
export * from "./floating-action-buttons";
8+
export { MarkdownCard } from "./markdown-card";
9+
export { MessageContent } from "./message-content";
710
export * from "./types";
8-
export { UIMessageComponent } from "./ui-message";

apps/desktop/src/components/right-panel/components/chat/markdown-card.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export function MarkdownCard(
110110
</style>
111111

112112
{/* Flat card with no shadow */}
113-
<div className="border border-neutral-200 rounded-lg bg-white overflow-hidden">
113+
<div className="mt-4 mb-4 border border-neutral-200 rounded-lg bg-white overflow-hidden">
114114
{/* Grey header section - Made thinner with py-1 */}
115115
<div className="bg-neutral-50 px-4 py-1 border-b border-neutral-200 flex items-center justify-between">
116116
<div className="text-sm text-neutral-600 flex items-center gap-2">

0 commit comments

Comments
 (0)