feat(tui): honest status 'starting agent…' until session.info arrives
Post-async-session.create, `session.create` returns in ~1ms with partial info and the real agent fires `session.info` ~1s later. Previously the status bar went straight to 'ready' right after the instant RPC return, which was misleading — `prompt.submit` would block server-side waiting for the agent to finish building. Now: - `newSession`: status = 'starting agent…' when info has no `version`, else 'ready' (covers the fast resume path too) - `session.info` event: flips status to 'ready' only if it was 'starting agent…', preserving running/interrupted/error states
This commit is contained in:
parent
a8e0a1148f
commit
04e36851b7
@ -165,6 +165,9 @@ export function createGatewayEventHandler(ctx: GatewayEventHandlerContext): (ev:
|
||||
patchUiState(state => ({
|
||||
...state,
|
||||
info: ev.payload,
|
||||
// Flip from 'starting agent…' → 'ready' when the agent is live.
|
||||
// Leave running/interrupted/error statuses alone.
|
||||
status: state.status === 'starting agent…' ? 'ready' : state.status,
|
||||
usage: ev.payload.usage ? { ...state.usage, ...ev.payload.usage } : state.usage
|
||||
}))
|
||||
// Agent init is async in session.create, so the intro message may
|
||||
|
||||
@ -104,7 +104,16 @@ export function useSessionLifecycle(opts: UseSessionLifecycleOptions) {
|
||||
|
||||
resetSession()
|
||||
setSessionStartedAt(Date.now())
|
||||
patchUiState({ info: r.info ?? null, sid: r.session_id, status: 'ready', usage: usageFrom(r.info ?? null) })
|
||||
// Python's `session.create` returns instantly with partial info (no `version`
|
||||
// field); the `session.info` event will flip status to 'ready' once the
|
||||
// agent is fully built (~1s later). Until then prompt.submit will block
|
||||
// server-side on `_wait_agent`.
|
||||
patchUiState({
|
||||
info: r.info ?? null,
|
||||
sid: r.session_id,
|
||||
status: r.info?.version ? 'ready' : 'starting agent…',
|
||||
usage: usageFrom(r.info ?? null)
|
||||
})
|
||||
|
||||
if (r.info) {
|
||||
setHistoryItems([introMsg(r.info)])
|
||||
|
||||
Loading…
Reference in New Issue
Block a user