fix(v0.5.1): 适配rc.5并修正控制室与更新提醒

This commit is contained in:
Aisland
2026-10-31 17:05:17 +08:00
parent 56ffe0cd1c
commit f98246ef0c
25 changed files with 703 additions and 237 deletions
+12 -1
View File
@@ -9,7 +9,7 @@ const { buildSync } = require('esbuild')
const code = buildSync({ entryPoints: [fileURLToPath(new URL('../01_content/src/client/sessionCompat.ts', import.meta.url))], bundle: true, write: false, platform: 'node', format: 'cjs' }).outputFiles[0].text
const module = { exports: {} }
runInNewContext(code, { module, exports: module.exports, setTimeout })
const { createSessionSnapshotAdapter, sendHostSession, childSessionIdsOf, pendingAckOf, sessionRuntimeMs } = module.exports
const { createSessionSnapshotAdapter, sendHostSession, childSessionIdsOf, pendingAckOf, sessionRuntimeMs, consoleStatusOf } = module.exports
const list = (running = false) => ({ phase: 'ready', ids: ['a'], byId: { a: { id: 'a', running, retainedBy: { mainView: 1 } } }, projectionsBySession: {} })
const source = (patch = {}) => ({ getSnapshot: () => new Map([['a', { running: false, pendingInteraction: undefined, completionUnread: false, ...patch }]]) })
@@ -58,6 +58,17 @@ test('ready removal clears run memory; transient pending list does not', () => {
adapt({ phase: 'ready', byId: {} })
assert.equal(adapt(list()).byId.a.completed, false)
})
test('console run-stop is neutral ended status even when the host reports an error', () => {
assert.equal(consoleStatusOf({ completed: true, running: false, error: { code: 'INVALID_REQUEST' } }, null), 'done')
assert.equal(consoleStatusOf({ running: false }, null, { completed: true }), 'done')
assert.equal(consoleStatusOf({ running: false }, null), 'idle')
assert.equal(consoleStatusOf(undefined, null), 'idle')
})
test('console running overrides a stale completion, while pending stays first', () => {
assert.equal(consoleStatusOf({ completed: true, running: true }, null), 'busy')
assert.equal(consoleStatusOf({ running: true }, null, { completed: true }), 'busy')
assert.equal(consoleStatusOf({ completed: true, running: true }, 'need:fixture'), 'need')
})
function sendFixture(outcome = { kind: 'success' }) {
const calls = []
const face = { prompt() { assert.fail('must not resend through prompt') } }