refactor(session): route construction through Session.create

This commit is contained in:
imccyu
2026-08-04 18:41:07 +08:00
parent c7f693aa40
commit 8cbdd5b9d0
61 changed files with 305 additions and 292 deletions
@@ -61,7 +61,7 @@ describe('SessionTitleService.rename', () => {
const session = ctx.sessions.create(SessionId('rename-reject'))
expect(() => ctx.sessionTitle.rename(session, '  ')).toThrow(/visible characters/)
expect(() => ctx.sessionTitle.rename(new Session(SessionId('detached')), 'name'))
expect(() => ctx.sessionTitle.rename(Session.create(SessionId('detached')), 'name'))
.toThrow(/not live in this store/)
})
@@ -82,7 +82,7 @@ describe('SessionTitleService configuration and refresh boundaries', () => {
await expect(withProvider.sessionTitle.refresh(providerEmpty)).resolves.toBeUndefined()
expect(generate).not.toHaveBeenCalled()
await expect(withProvider.sessionTitle.refresh(new Session(SessionId('detached'))))
await expect(withProvider.sessionTitle.refresh(Session.create(SessionId('detached'))))
.rejects.toThrow(/not live in this store/)
const controller = new AbortController()
controller.abort(new Error('already cancelled'))
@@ -165,7 +165,7 @@ describe('SessionTitleService configuration and refresh boundaries', () => {
it('shares one fallback across concurrent refreshes', async () => {
const ctx = await setup()
const seed = new Session(SessionId('fallback-concurrency-seed'))
const seed = Session.create(SessionId('fallback-concurrency-seed'))
seed.append('turn/start', {
turn: 1,
trigger: { kind: 'message', source: { kind: 'user' } },
@@ -134,7 +134,7 @@ describe('SessionTitleService', () => {
})
it('folds the latest title event during replay', () => {
const seed = new Session(SessionId('source'))
const seed = Session.create(SessionId('source'))
seed.append('session/title', {
title: 'Earlier',
messageSeqs: [1],