fix(sidechat): restore thread bindings after page reload
This commit is contained in:
1 parent
23a2b61f33
commit
dcafe7d2dc
2 files changed
+12
-2
No files matched your search
@@ -889,14 +889,14 @@ export function SideChatView(props: {
|
|||||||
// loadLastThreads) reattaches to the thread the session was last in instead
|
// loadLastThreads) reattaches to the thread the session was last in instead
|
||||||
// of leaving yet another orphan "Side: New thread" session behind.
|
// of leaving yet another orphan "Side: New thread" session behind.
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (threadId !== undefined || !autoCreate || !visible) return
|
if (threadId !== undefined || !visible) return
|
||||||
const reattach = reattachTarget()
|
const reattach = reattachTarget()
|
||||||
if (reattach !== undefined) {
|
if (reattach !== undefined) {
|
||||||
// Name the seat session: the same native id names a tab in every session.
|
// Name the seat session: the same native id names a tab in every session.
|
||||||
ctx.get('betterSidebar')?.updateTab(tab.id, { meta: { threadId: reattach } }, scope.sessionId)
|
ctx.get('betterSidebar')?.updateTab(tab.id, { meta: { threadId: reattach } }, scope.sessionId)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
void startThread()
|
if (autoCreate) void startThread()
|
||||||
}, [threadId, autoCreate, visible, startThread, reattachTarget, ctx, tab.id, scope.sessionId])
|
}, [threadId, autoCreate, visible, startThread, reattachTarget, ctx, tab.id, scope.sessionId])
|
||||||
|
|
||||||
// Remember the thread this tab holds, so reopening the panel (or a restart)
|
// Remember the thread this tab holds, so reopening the panel (or a restart)
|
||||||
|
|||||||
@@ -133,6 +133,16 @@ describe('sidechat image composer', () => {
|
|||||||
expect(calls).toHaveLength(1)
|
expect(calls).toHaveLength(1)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('reattaches a restored native tab to the remembered thread without sending again', async () => {
|
||||||
|
await harness.flush()
|
||||||
|
const snapshot = { byId: { root: { id: 'root', displayTitle: 'root', running: false }, t1: { id: 't1', displayTitle: 'Side: thread', origin: 'subagent', parentId: 'root', running: false } } }
|
||||||
|
const ctx = { get: (key: string) => key === 'betterSidebar' ? harness.host : undefined, sessions: { list: { subscribe: () => () => {}, getSnapshot: () => snapshot } } } as unknown as Context
|
||||||
|
mounted.rerender(createElement(SideChatView, { ctx, scope: { sessionId: 'root', cwd: '/p' }, tab: { id: 'restored', type: 'sidechat', title: 'Side Chat' }, visible: true }))
|
||||||
|
await harness.flush()
|
||||||
|
expect(harness.host.updateTab).toHaveBeenCalledWith('restored', { meta: { threadId: 't1' } }, 'root')
|
||||||
|
expect(calls).toEqual([])
|
||||||
|
})
|
||||||
|
|
||||||
it('renders saved and cold pending images by occurrence, disables cold dequeue and cleans loaded URLs', async () => {
|
it('renders saved and cold pending images by occurrence, disables cold dequeue and cleans loaded URLs', async () => {
|
||||||
harness.wire.events = [{ type: 'user/message', seq: 1, time: 1, data: { id: 'saved', source: { kind: 'user' }, content: [{ type: 'image', attachment: { mediaType: 'image/png', bytes: 3, width: 1, height: 1, name: 'saved.png' } }] } }]
|
harness.wire.events = [{ type: 'user/message', seq: 1, time: 1, data: { id: 'saved', source: { kind: 'user' }, content: [{ type: 'image', attachment: { mediaType: 'image/png', bytes: 3, width: 1, height: 1, name: 'saved.png' } }] } }]
|
||||||
harness.wire.pending = [{ id: 'queued', target: 'next-turn', text: '', removable: false, images: [{ blockIndex: 0, mediaType: 'image/png', bytes: 3, width: 1, height: 1, name: 'queued.png' }] }]
|
harness.wire.pending = [{ id: 'queued', target: 'next-turn', text: '', removable: false, images: [{ blockIndex: 0, mediaType: 'image/png', bytes: 3, width: 1, height: 1, name: 'queued.png' }] }]
|
||||||
|
|||||||
Reference in new issue
Block a user