Skip to content

Commit

Permalink
Merge pull request #49 from Royal-lobster/fix-images-not-loading
Browse files Browse the repository at this point in the history
Fix Images not loading
  • Loading branch information
Royal-lobster authored Nov 26, 2023
2 parents c661cb4 + 9efbfd6 commit e43e28c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/little-pigs-train.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"syncia": patch
---

Fixes screenshot tool images not loading up back to existing chat
Binary file modified artifacts/chrome.zip
Binary file not shown.
3 changes: 2 additions & 1 deletion src/components/Sidebar/chat/FilePreviewBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const FilePreviewBar = ({ files, removeFile }: FilePreviewBarProps) => {
return (
<div className="cdx-flex cdx-gap-2 cdx-m-2">
{files.map((file) => {
const imageUrl = URL.createObjectURL(file.blob)
const imageUrl = file.src

return (
<div key={file.id} className="cdx-flex cdx-relative">
<a
Expand Down
5 changes: 2 additions & 3 deletions src/hooks/useChatCompletion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ import { ChatOpenAI } from 'langchain/chat_models/openai'
import { AIMessage, HumanMessage, SystemMessage } from 'langchain/schema'
import { useMemo, useState } from 'react'
import { AvailableModels, Mode } from '../config/settings'
import { ChatRole, useCurrentChat } from './useCurrentChat'
import { getMatchedContent } from '../lib/getMatchedContent'
import { ChatRole, useCurrentChat } from './useCurrentChat'
import { MessageDraft } from './useMessageDraft'
import { convertBlobToBase64 } from '../lib/convertBlobToBase64'

interface UseChatCompletionProps {
model: AvailableModels
Expand Down Expand Up @@ -108,7 +107,7 @@ export const useChatCompletion = ({
message.files.map(async (file) => {
return {
type: 'image_url',
image_url: await convertBlobToBase64(file.blob),
image_url: file.src,
} as const
}),
)
Expand Down
7 changes: 4 additions & 3 deletions src/hooks/useMessageDraft.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { useState } from 'react'
import { getUUID } from '../lib/getUUID'
import { convertBlobToBase64 } from '../lib/convertBlobToBase64'

export interface MessageFile {
id: string
type: string
blob: Blob
src: string
}

export interface MessageDraft {
Expand All @@ -22,11 +23,11 @@ export const useMessageDraft = () => {
setMessageDraft((p) => ({ ...p, text }))
}

const addMessageDraftFile = (blob: Blob) => {
const addMessageDraftFile = async (blob: Blob) => {
const file = {
id: getUUID(),
type: blob.type,
blob,
src: await convertBlobToBase64(blob),
}
setMessageDraft((p) => ({ ...p, files: [...p.files, file] }))
}
Expand Down

0 comments on commit e43e28c

Please sign in to comment.