mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-02 18:39:06 +08:00
feat(sessions): make session creation async and set active session
Dispatch active session id after successful creation to ensure UI reflects current state
This commit is contained in:
parent
1e9a811065
commit
42dbc6555c
@ -34,14 +34,17 @@ const Sessions: React.FC<SessionsProps> = ({ agentId }) => {
|
||||
[dispatch]
|
||||
)
|
||||
|
||||
const handleCreateSession = useCallback(() => {
|
||||
const handleCreateSession = useCallback(async () => {
|
||||
if (!agent) return
|
||||
const session = {
|
||||
...agent,
|
||||
id: undefined
|
||||
} satisfies CreateSessionForm
|
||||
createSession(session)
|
||||
}, [agent, createSession])
|
||||
const created = await createSession(session)
|
||||
if (created) {
|
||||
dispatch(setActiveSessionIdAction({ agentId, sessionId: created.id }))
|
||||
}
|
||||
}, [agent, agentId, createSession, dispatch])
|
||||
|
||||
const currentActiveSessionId = activeSessionId[agentId]
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user