fix(native-chat): keep known sessions loading until flush (#11032)

This commit is contained in:
Neil 2026-07-27 19:04:35 -07:00 committed by GitHub
parent dbbeae3512
commit e4b113b11d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 2 deletions

View File

@ -36,7 +36,7 @@ export type NativeChatLiveMergeInput = {
* provider lifecycle records reconcile a dropped final hook.
*
* Precedence:
* - errors win outright; live work wins over transcript loading.
* - errors win outright; known sessions stay loading until transcript content resolves.
* - hook 'working' stays authoritative until the hook exits that state OR an
* explicit terminal marker for this turn lands.
* - design is hook-first: lifecycle is a terminal suppressor for dropped
@ -65,7 +65,7 @@ export function mergeNativeChatLiveSession(input: NativeChatLiveMergeInput): Nat
transcriptLifecycle,
hookHasWorkingSubagents ?? false
)
if (loading && status !== 'working') {
if (loading && (sessionId !== null || status !== 'working')) {
return assembleNativeChatSession({ sources, sessionId, agent, status: 'loading' })
}
return assembleNativeChatSession({

View File

@ -256,6 +256,15 @@ describe('mergeNativeChatLiveSession', () => {
loading: true
}).status
).toBe('working')
expect(
mergeNativeChatLiveSession({
sources: { transcript: [] },
sessionId: 'sess',
agent: 'claude',
hookState: 'working',
loading: true
}).status
).toBe('loading')
const errored = mergeNativeChatLiveSession({
sources: { transcript: [] },