Skip to content

Commit

Permalink
patch: fakePort stop
Browse files Browse the repository at this point in the history
  • Loading branch information
josStorer committed Sep 23, 2023
1 parent 711e0d3 commit 40ae457
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
5 changes: 2 additions & 3 deletions src/components/ConversationCard/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ function ConversationCard(props) {
const lastRecord = session.conversationRecords[session.conversationRecords.length - 1]
if (
conversationItemData[conversationItemData.length - 1].done &&
conversationItemData.length > 1 &&
lastRecord.question === conversationItemData[conversationItemData.length - 2].content
) {
session.conversationRecords.pop()
Expand Down Expand Up @@ -484,15 +485,13 @@ function ConversationCard(props) {
key={idx}
type={data.type}
session={session}
done={data.done}
port={port}
onRetry={idx === conversationItemData.length - 1 ? getRetryFn(session) : null}
/>
))}
</div>
<InputBox
enabled={isReady}
port={port}
postMessage={postMessage}
reverseResizeDir={props.pageMode}
onSubmit={async (question) => {
const newQuestion = new ConversationItemData('question', question)
Expand Down
4 changes: 1 addition & 3 deletions src/components/ConversationItem/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { isUsingCustomModel } from '../../config/index.mjs'
import { useConfig } from '../../hooks/use-config.mjs'

// eslint-disable-next-line
export function ConversationItem({ type, content, session, done, port, onRetry }) {
export function ConversationItem({ type, content, session, onRetry }) {
const { t } = useTranslation()
const [collapsed, setCollapsed] = useState(false)
const config = useConfig()
Expand Down Expand Up @@ -129,8 +129,6 @@ ConversationItem.propTypes = {
type: PropTypes.oneOf(['question', 'answer', 'error']).isRequired,
content: PropTypes.string.isRequired,
session: PropTypes.object.isRequired,
done: PropTypes.bool.isRequired,
port: PropTypes.object.isRequired,
onRetry: PropTypes.func,
}

Expand Down
6 changes: 3 additions & 3 deletions src/components/InputBox/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { isFirefox, isMobile, isSafari, updateRefHeight } from '../../utils'
import { useTranslation } from 'react-i18next'
import { getUserConfig } from '../../config/index.mjs'

export function InputBox({ onSubmit, enabled, port, reverseResizeDir }) {
export function InputBox({ onSubmit, enabled, postMessage, reverseResizeDir }) {
const { t } = useTranslation()
const [value, setValue] = useState('')
const reverseDivRef = useRef(null)
Expand Down Expand Up @@ -62,7 +62,7 @@ export function InputBox({ onSubmit, enabled, port, reverseResizeDir }) {
onSubmit(value)
setValue('')
} else {
port.postMessage({ stop: true })
postMessage({ stop: true })
}
}
}
Expand Down Expand Up @@ -117,7 +117,7 @@ InputBox.propTypes = {
onSubmit: PropTypes.func.isRequired,
enabled: PropTypes.bool.isRequired,
reverseResizeDir: PropTypes.bool,
port: PropTypes.object.isRequired,
postMessage: PropTypes.func.isRequired,
}

export default InputBox

0 comments on commit 40ae457

Please sign in to comment.