Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(mail): 修复恢复邮件侧栏后一直加载
Dash7d21ab251f03
diff --git a/apps/desktop/src/renderer/features/right-sidebar/plugins/mail-preview/MailPreview.test.tsx b/apps/desktop/src/renderer/features/right-sidebar/plugins/mail-preview/MailPreview.test.tsxindex a6b2a08699..fc616f08ab 100644--- a/apps/desktop/src/renderer/features/right-sidebar/plugins/mail-preview/MailPreview.test.tsx+++ b/apps/desktop/src/renderer/features/right-sidebar/plugins/mail-preview/MailPreview.test.tsx@@ -111,6 +111,25 @@ it.each(['inactive', 'hidden'])('does not mark a restored %s tab read until it i});afterEach(() => { cleanup(); vi.clearAllMocks(); vi.unstubAllGlobals(); h.owner = 1; });+// Unit regression: existing tests start with a resolved device. During sidebar+// restoration undefined (unresolved) becomes null (local); JSON array keys used+// to collapse those states, leaving the real reader on loading indefinitely.+it('loads a restored mail when its device resolves and hides it while unresolved', async () => {+ h.read.mockResolvedValue({ message: mail('Restored mail') });+ const state = { url: 'https://mail.example/a' };+ const unresolved = { ...ctx, deviceLinkDeviceId: undefined };+ const view = render(<MailPreviewBody state={state} ctx={unresolved} />);+ await act(async () => {});+ expect(h.read).not.toHaveBeenCalled();+ view.rerender(<MailPreviewBody state={state} ctx={ctx} />);+ await act(async () => {});+ expect(screen.getByText('Restored mail')).toBeTruthy();+ expect(h.read).toHaveBeenCalledExactlyOnceWith('a', state.url, true, null, true, undefined);+ view.rerender(<MailPreviewBody state={state} ctx={unresolved} />);+ expect(screen.queryByText('Restored mail')).toBeNull();+ expect(screen.getByText('mailReader.loading')).toBeTruthy();+});+// Restored tabs (or plugin removal after a click) previously misreported a// missing reader as a mailbox failure. Unit: expose the original URL, no retry loop.it.each([diff --git a/apps/desktop/src/renderer/features/right-sidebar/plugins/mail-preview/index.tsx b/apps/desktop/src/renderer/features/right-sidebar/plugins/mail-preview/index.tsxindex 8435386c70..21171e20dd 100644--- a/apps/desktop/src/renderer/features/right-sidebar/plugins/mail-preview/index.tsx+++ b/apps/desktop/src/renderer/features/right-sidebar/plugins/mail-preview/index.tsx@@ -17,7 +17,9 @@ export function MailPreviewBody({ state, ctx, active: tabActive = true, shellVisconst [attempt, setAttempt] = useState(0);const [result, setResult] = useState<{ binding: string; message?: MailMessage; draftCallId?: string; error?: boolean; unavailable?: 'unavailable' | 'notReady'; providerId?: string; providers?: MailReaderChoice[] }>();const owner = getDataOwnerGeneration();- const scope = JSON.stringify([owner, ctx.sessionId, ctx.deviceLinkDeviceId, state.url]);+ // Object fields preserve unresolved (omitted) versus confirmed-local (null).+ // Array serialization turns both into null and skips the first local read.+ const scope = JSON.stringify({ owner, sessionId: ctx.sessionId, deviceId: ctx.deviceLinkDeviceId, url: state.url });const [selection, setSelection] = useState<{ scope: string; id: string }>();const selected = selection?.scope === scope ? selection.id : undefined;const binding = JSON.stringify([scope, attempt, selected]);