fix(tui): preserve scrollback when branching sessions (#30162)

Keep the visible transcript mounted after /branch switches to the new session, since the backend already carries the copied history forward.
This commit is contained in:
brooklyn! 2026-05-21 21:01:04 -05:00 committed by GitHub
parent a7cd254c29
commit 9e30ef224d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 1 deletions

View file

@ -222,6 +222,21 @@ describe('createSlashHandler', () => {
expect(ctx.gateway.rpc).not.toHaveBeenCalled()
})
it('keeps visible scrollback when branching a TUI session', async () => {
patchUiState({ sid: 'sid-parent' })
const rpc = vi.fn(() => Promise.resolve({ session_id: 'sid-branch', title: 'branch title' }))
const ctx = buildCtx({ gateway: { ...buildGateway(), rpc } })
expect(createSlashHandler(ctx)('/branch branch title')).toBe(true)
expect(rpc).toHaveBeenCalledWith('session.branch', { name: 'branch title', session_id: 'sid-parent' })
await vi.waitFor(() => {
expect(getUiState().sid).toBe('sid-branch')
expect(ctx.transcript.sys).toHaveBeenCalledWith('branched → branch title')
})
expect(ctx.transcript.setHistoryItems).not.toHaveBeenCalled()
})
it('reloads skills in the live gateway and refreshes the catalog', async () => {
const rpc = vi.fn((method: string) => {
if (method === 'skills.reload') {

View file

@ -212,7 +212,6 @@ export const sessionCommands: SlashCommand[] = [
void ctx.session.closeSession(prevSid)
patchUiState({ sid: r.session_id })
ctx.session.setSessionStartedAt(Date.now())
ctx.transcript.setHistoryItems([])
ctx.transcript.sys(`branched → ${r.title ?? ''}`)
})
)