mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-31 00:10:22 +08:00
fix(useSession): provide default empty array for messages when undefined
Make messages field optional in GetAgentSessionResponseSchema to match actual API behavior and prevent potential undefined access
This commit is contained in:
parent
798126d39c
commit
7fc676bbc3
@ -31,7 +31,7 @@ export const useSession = (agentId: string, sessionId: string) => {
|
||||
|
||||
return {
|
||||
session: data,
|
||||
messages: data?.messages,
|
||||
messages: data?.messages ?? [],
|
||||
error,
|
||||
isLoading,
|
||||
updateSession
|
||||
|
||||
@ -194,7 +194,7 @@ export interface UpdateSessionRequest extends Partial<AgentBase> {}
|
||||
|
||||
export const GetAgentSessionResponseSchema = AgentSessionEntitySchema.extend({
|
||||
built_in_tools: z.array(ToolSchema).optional(), // Built-in tools available to the agent
|
||||
messages: z.array(AgentSessionMessageEntitySchema) // Messages in the session
|
||||
messages: z.array(AgentSessionMessageEntitySchema).optional() // Messages in the session
|
||||
})
|
||||
|
||||
export type GetAgentSessionResponse = z.infer<typeof GetAgentSessionResponseSchema>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user