Skip to content

Commit

Permalink
fixme comment for tmp solution
Browse files Browse the repository at this point in the history
  • Loading branch information
wwayne committed May 24, 2024
1 parent de39118 commit 1eec0ec
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
1 change: 1 addition & 0 deletions clients/vscode/src/ChatViewProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ServerApi, ChatMessage, Context } from "tabby-chat-panel";
import { agent } from "./agent";
import { createClient } from "./chatPanel";

// FIXME(wwayne): Example code has webview removed case, not sure when it would happen, need to double check
export class ChatViewProvider implements WebviewViewProvider {
webview?: WebviewView;
client?: ServerApi;
Expand Down
1 change: 1 addition & 0 deletions clients/vscode/src/chatPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export function createThreadFromWebview<Self = Record<string, never>, Target = R
listen(data);
});

// FIXME(wwayne): double check if the connection got any edge cases
signal?.addEventListener("abort", () => {
dispose();
});
Expand Down
21 changes: 8 additions & 13 deletions ee/tabby-ui/app/chat/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { useSearchParams } from 'next/navigation'

import { nanoid } from '@/lib/utils'
import { Chat, ChatRef } from '@/components/chat/chat'
import { QuestionAnswerPair } from '@/lib/types/chat'
import Color from 'color'

import './page.css'
Expand All @@ -33,9 +32,8 @@ export default function ChatPage() {
null
)
const [activeChatId, setActiveChatId] = useState('')
const [initialMessages, setInitialMessages] = useState<QuestionAnswerPair[]>(
[]
)
let pendingMessages: ChatMessage[] = [] // FIXME(wwayne): use init message props after Chat component update

const chatRef = useRef<ChatRef>(null)
const searchParams = useSearchParams()
const maxWidth = searchParams.get('max-width') || undefined
Expand Down Expand Up @@ -71,14 +69,7 @@ export default function ChatPage() {
if (chatRef.current) {
chatRef.current.sendUserChat(message)
} else {
const newInitialMessages = [...initialMessages]
newInitialMessages.push({
user: {
...message,
id: nanoid()
}
})
setInitialMessages(newInitialMessages)
pendingMessages.push(message)
}
}

Expand All @@ -88,6 +79,11 @@ export default function ChatPage() {
setActiveChatId(nanoid())
setIsInit(true)
setFetcherOptions(request.fetcherOptions)

// FIXME(wwayne): This is no needed after Chat support initMessage
setTimeout(() => {
pendingMessages.forEach(sendMessage)
}, 1000)
},
sendMessage: (message: ChatMessage) => {
return sendMessage(message)
Expand All @@ -108,7 +104,6 @@ export default function ChatPage() {
key={activeChatId}
ref={chatRef}
headers={headers}
initialMessages={initialMessages}
onThreadUpdates={() => {}}
onNavigateToContext={onNavigateToContext}
maxWidth={maxWidth}
Expand Down

0 comments on commit 1eec0ec

Please sign in to comment.