Skip to content

Commit

Permalink
fix: resolve out of sync inferencing and isStreaming by referencing d…
Browse files Browse the repository at this point in the history
…irectly from modelStore
  • Loading branch information
a-ghorbani committed Dec 6, 2024
1 parent 150bbf4 commit a6f62f8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 0 additions & 2 deletions src/hooks/useChatSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,5 @@ export const useChatSession = (
handleSendPress,
handleResetConversation,
handleStopPress,
inferencing: modelStore.inferencing,
isStreaming: modelStore.isStreaming,
};
};
14 changes: 9 additions & 5 deletions src/screens/ChatScreen/ChatScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,15 @@ export const ChatScreen: React.FC = observer(() => {
const l10n = React.useContext(L10nContext);
const messages = chatSessionStore.currentSessionMessages;

const {handleSendPress, handleStopPress, inferencing, isStreaming} =
useChatSession(currentMessageInfo, messages, user, assistant);
const {handleSendPress, handleStopPress} = useChatSession(
currentMessageInfo,
messages,
user,
assistant,
);

// Show loading bubble only during the thinking phase (inferencing but not streaming)
const isThinking = inferencing && !isStreaming;
const isThinking = modelStore.inferencing && !modelStore.isStreaming;

return (
<SafeAreaProvider>
Expand All @@ -60,9 +64,9 @@ export const ChatScreen: React.FC = observer(() => {
onSendPress={handleSendPress}
onStopPress={handleStopPress}
user={user}
isStopVisible={inferencing}
isStopVisible={modelStore.inferencing}
isThinking={isThinking}
isStreaming={isStreaming}
isStreaming={modelStore.isStreaming}
sendButtonVisibilityMode="editing"
textInputProps={{
editable: !!modelStore.context,
Expand Down

0 comments on commit a6f62f8

Please sign in to comment.