Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(mobile): 恢复草稿时显示已保存的创建失败原因并同步主干
Dashb1061827ba8f
diff --cc apps/mobile/app/sessions/new.tsxindex 708b2087ad,ec19ed5f79..7e712d15c8--- a/apps/mobile/app/sessions/new.tsx+++ b/apps/mobile/app/sessions/new.tsx@@@ -876,7 -871,6 +876,8 @@@ export default function NewRemoteSessiorecord.item.attachmentSlots.filter((a): a is RemoteSerializedAttachment => a !== null),{ enabled: record.creation.planModeArm, restorePermissionMode: record.creation.restorePermissionMode },record.deviceId);+ if (record.creation.notice) setAttachmentError(record.creation.notice);++ if (record.error) setError(t('session.screen.createFailedNotice', { message: record.error }));setSelectedDeviceId(record.deviceId);setSelectedDeviceName(record.creation.deviceName);releaseEditClaim = completeNewSessionDurableEdit(sid, record.deviceId);@@@ -884,7 -878,7 +885,7 @@@const unsubscribe = mobileDurableOutbox.subscribe(restore);void mobileDurableOutbox.ready().then(restore);return () => { active = false; unsubscribe(); releaseEditClaim?.(); };-- }, [params.recoverySessionId, routeDeviceId, outboxOwner, leaveForeignOutboxRecovery, restoreCreationDraft]);++ }, [params.recoverySessionId, routeDeviceId, outboxOwner, leaveForeignOutboxRecovery, restoreCreationDraft, t]);useEffect(() => {const stashed = drainStashedNewSessionDraft(readRouteString(params.editSessionId) ?? undefined, routeDeviceId);if (!stashed) return;diff --cc apps/mobile/src/__tests__/newSessionCreation.test.tsindex db1b8fdd15,bcebea61b1..219eabbe38--- a/apps/mobile/src/__tests__/newSessionCreation.test.ts+++ b/apps/mobile/src/__tests__/newSessionCreation.test.ts@@@ -648,7 -637,7 +648,7 @@@ describe('newSessionCreation pipeline'expect(record.item.text).toBe(DRAFT.firstMessage);});-- it.each(['matching', 'device', 'account', 'not-ready', 'switched-owner'])('only acknowledges durable edit recovery after the matching form restores it: %s', async scope => {++ it.each(['matching', 'matching-no-error', 'device', 'account', 'not-ready', 'switched-owner'])('only acknowledges durable edit recovery after the matching form restores it: %s', async scope => {const maker = makeMaker({ createSession: vi.fn(async () => { throw new Error('[MODEL_UNAVAILABLE] unavailable'); }) });startNewSessionCreation(makeParams('s1', maker));await flushPipeline();@@@ -656,6 -645,6 +656,8 @@@editOutbox.records.mockReturnValue([record]);await returnNewSessionToEdit({ sessionId: 's1', deviceId: 'dev-1', isCurrent: () => true, onReady: vi.fn() });const owner = getMobileAuthOwner();++ record.error = scope === 'matching-no-error' ? undefined : 'saved creation failure';++ const matching = scope === 'matching' || scope === 'matching-no-error';// Model the persisted edit-ready patch so the real form acquires a releaseable claim.record.suspended = true;record.creation!.editReady = true;@@@ -670,11 -668,13 +672,12 @@@getCurrentMobileOutboxRecords: editOutbox.records, outboxRecoveryRef: { current: null },userTouchedDeviceRef: { current: false }, restoreCreationDraft: restore,setSelectedDeviceId: vi.fn(), setSelectedDeviceName: vi.fn(), completeNewSessionDurableEdit,++ setError: vi.fn(), t: (_key: string, values: { message: string }) => `创建失败:${values.message}`,mobileDurableOutbox: { subscribe: () => () => {}, ready: async () => {} },};- const compiled = ts.transpileModule(`function run(bindings) { const { ${Object.keys(bindings).join(', ')} } = bindings; return (${effect})(); }`,- { compilerOptions: { target: ts.ScriptTarget.ES2022 } }).outputText;- const cleanup = (new Function(`${compiled}; return run;`)() as (b: typeof bindings) => () => void)(bindings);+ const cleanup = runRecoveryEffect('completeNewSessionDurableEdit(', bindings)!;await flushPipeline();-- if (scope === 'matching') {++ if (matching) {expect(restore).toHaveBeenCalledWith(DRAFT, [], { enabled: false, restorePermissionMode: null }, 'dev-1');expect(getNewSessionCreationTask('s1')).toBeNull();} else {@@@ -682,10 -682,10 +685,14 @@@if (scope === 'switched-owner') expect(getNewSessionCreationTask('s1')).toBeNull();else expect(getNewSessionCreationTask('s1')?.readyForEdit).toBe('durable');}++ // Cold/blank-form recovery has no creationError route parameter. Restore++ // the saved reason only with its matching draft; old records keep any live error.++ if (scope === 'matching') expect(bindings.setError).toHaveBeenCalledWith('创建失败:saved creation failure');++ else expect(bindings.setError).not.toHaveBeenCalled();cleanup();-- if (scope === 'matching') {++ if (matching) {expect(getNewSessionCreationTask('s1')?.readyForEdit).toBe('durable');- expect(remoteSessionStore.getSessions().some(row => row.id === 's1')).toBe(true);+ expect(remoteSessionStore.getSessions()).toEqual([]);}});