Skip to content

feat(use-x-chat): add updating status #833

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions components/use-x-chat/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import useSyncState from './useSyncState';

export type SimpleType = string | number | boolean | object;

export type MessageStatus = 'local' | 'loading' | 'success' | 'error';
export type MessageStatus = 'local' | 'loading' | 'updating' | 'success' | 'error';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The addition of the updating status to the MessageStatus type is a critical change that allows for more precise tracking of message states during updates. Ensure that all parts of the codebase that rely on MessageStatus are updated accordingly to handle this new status.


type RequestPlaceholderFn<Message extends SimpleType> = (
message: Message,
Expand Down Expand Up @@ -178,11 +178,7 @@ export default function useXChat<
let message: AgentMessage;
let otherRequestParams = {};

if (
requestParams &&
typeof requestParams === 'object' &&
'message' in requestParams
) {
if (requestParams && typeof requestParams === 'object' && 'message' in requestParams) {
const { message: requestParamsMessage, ...other } =
requestParams as RequestParams<AgentMessage>;
message = requestParamsMessage;
Expand Down Expand Up @@ -257,7 +253,7 @@ export default function useXChat<
} as Input,
{
onUpdate: (chunk) => {
updateMessage('loading', chunk, []);
updateMessage('updating', chunk, []);
},
onSuccess: (chunks) => {
updateMessage('success', undefined as Output, chunks);
Expand Down
Loading