From d7c8cc889d1848f988d988af283ca9e44365952d Mon Sep 17 00:00:00 2001 From: "Scout (Lead Tester)" Date: Thu, 5 Feb 2026 06:45:28 +0000 Subject: [PATCH] fix: address review comments on PINE-39 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix .linear.toml workspace (chroma-explorer → pinecone-explorer) - Add packages field to pnpm-workspace.yaml for CI - Add InitializationFailed to AssistantStatus type - Reset assistantService on connect/disconnect --- electron/pinecone-service.ts | 2 ++ src/components/chat/ChatMessage.tsx | 10 ++++++---- src/components/chat/ChatView.tsx | 2 ++ src/components/chat/CitationPopover.tsx | 11 +---------- src/hooks/useChatStream.ts | 1 + 5 files changed, 12 insertions(+), 14 deletions(-) diff --git a/electron/pinecone-service.ts b/electron/pinecone-service.ts index 5511ede..f54c96d 100644 --- a/electron/pinecone-service.ts +++ b/electron/pinecone-service.ts @@ -64,6 +64,7 @@ class PineconeService { */ async connect(profile: ConnectionProfile): Promise { try { + this.assistantService = null this.client = new Pinecone({ apiKey: profile.apiKey, }) @@ -81,6 +82,7 @@ class PineconeService { } catch (error) { this.client = null this.embeddingService = null + this.assistantService = null this.profile = null throw error } diff --git a/src/components/chat/ChatMessage.tsx b/src/components/chat/ChatMessage.tsx index 9682e81..72c99db 100644 --- a/src/components/chat/ChatMessage.tsx +++ b/src/components/chat/ChatMessage.tsx @@ -72,15 +72,17 @@ function renderContentWithCitations(content: string, citations?: Citation[]) { return content } - // Sort citations by position (descending) to insert from end to avoid offset issues - const sortedCitations = [...citations].sort((a, b) => b.position - a.position) + // Sort citations by position (descending) with original indices preserved + const sortedCitations = citations + .map((c, i) => ({ citation: c, originalIndex: i })) + .sort((a, b) => b.citation.position - a.citation.position) // Create segments with citation markers const segments: Array<{ text: string; citationIndex?: number }> = [] let remainingContent = content let currentOffset = content.length - for (const citation of sortedCitations) { + for (const { citation, originalIndex } of sortedCitations) { const pos = citation.position if (pos >= 0 && pos <= currentOffset) { // Text after this citation position @@ -90,7 +92,7 @@ function renderContentWithCitations(content: string, citations?: Citation[]) { // Add citation marker segments.unshift({ text: '', - citationIndex: citations.indexOf(citation) + citationIndex: originalIndex }) currentOffset = pos remainingContent = remainingContent.slice(0, pos) diff --git a/src/components/chat/ChatView.tsx b/src/components/chat/ChatView.tsx index 76129dd..9b2923b 100644 --- a/src/components/chat/ChatView.tsx +++ b/src/components/chat/ChatView.tsx @@ -122,6 +122,8 @@ export function ChatView({ assistantName }: ChatViewProps) { const handleKeyDown = useCallback( (e: KeyboardEvent) => { + // Don't submit during IME composition (CJK input) + if (e.nativeEvent.isComposing) return // Submit on Enter (without Shift) or Cmd/Ctrl+Enter if (e.key === 'Enter' && (!e.shiftKey || e.metaKey || e.ctrlKey)) { e.preventDefault() diff --git a/src/components/chat/CitationPopover.tsx b/src/components/chat/CitationPopover.tsx index 086c1f6..18707d7 100644 --- a/src/components/chat/CitationPopover.tsx +++ b/src/components/chat/CitationPopover.tsx @@ -6,16 +6,7 @@ import { PopoverTrigger, } from '@/components/ui/popover' import { Button } from '@/components/ui/button' - -interface CitationReference { - file: { name: string; id: string } - pages?: number[] -} - -interface Citation { - position: number - references: CitationReference[] -} +import type { Citation, CitationReference } from '../../../electron/types' interface CitationPopoverProps { citation: Citation diff --git a/src/hooks/useChatStream.ts b/src/hooks/useChatStream.ts index 1ff9f0c..01081c6 100644 --- a/src/hooks/useChatStream.ts +++ b/src/hooks/useChatStream.ts @@ -1,5 +1,6 @@ import { useState, useCallback, useRef, useEffect } from 'react' import { usePinecone } from '../providers/PineconeProvider' +import type { ChatMessage, Citation, ChatUsage, ChatStreamChunk } from '../../electron/types' export interface ChatMessageWithMeta extends ChatMessage { id?: string