Orkas is an open-source (MIT), local-first AI team for your desktop: a Commander turns your goal into to-dos and coordinates 16 built-in specialist agents plus Claude Code, Codex, OpenCode, OpenClaw and Hermes, with projects, scheduled automations and connectors. Free app for macOS & Windows; built-in models or your own keys.
JavaScript agent-collaborationagent-harnessagent-orchestrationagent-teamagent-workflowai-assistantai-automationai-employeeai-productivityai-teamai-workflowautonomous-agentsclaude-code-guiclaude-coworkdesktop-agentlocal-firstmulti-agentmulti-agent-systemself-evolving-agentstask-automation
同步空白演示文稿预览修复
YToolboxf1f6b27be0b6
diff --git a/src/main/util/extract-office.ts b/src/main/util/extract-office.tsindex eafe3d0c..5b8228d2 100644--- a/src/main/util/extract-office.ts+++ b/src/main/util/extract-office.ts@@ -227,7 +227,18 @@ function parsePresentationSlides(buf: Buffer): PresentationSlide[] {const zip = new AdmZip(buf);const slideEntries = parsePresentationSlideRefs(zip);- if (!slideEntries.length) throw new Error('presentation contains no slides');+ if (!slideEntries.length) {+ const presentation = readZipText(zip, 'ppt/presentation.xml');+ if (!presentation) throw new Error('empty or invalid presentation');++ // A newly-created PowerPoint file may be a valid package whose slide list+ // is empty. Treat that as an empty document, while still rejecting a deck+ // that declares slides whose relationship or XML payload is missing.+ if (tagOpenRe('sldId').test(presentation)) {+ throw new Error('presentation slide data is missing');+ }+ return [];+ }return slideEntries.map((slide) => ({number: slide.number,@@ -317,6 +328,13 @@ export function pptxBufferToMarkdown(buf: Buffer): string {export function pptxBufferToHtml(buf: Buffer): string {const slides = parsePresentationSlides(buf);+ if (!slides.length) {+ return [+ '<section class="office-slide office-slide-blank" aria-label="Blank presentation">',+ '<div class="office-slide-body"></div>',+ '</section>',+ ].join('');+ }return slides.map((slide) => {const lines = slide.texts.map((line) => `<p>${escapeHtml(line)}</p>`).join('');return [diff --git a/test/main/util/extract-office.test.ts b/test/main/util/extract-office.test.tsindex a09fb3d6..845c4002 100644--- a/test/main/util/extract-office.test.ts+++ b/test/main/util/extract-office.test.ts@@ -1,3 +1,4 @@+import AdmZip from 'adm-zip';import { describe, it, expect } from 'vitest';import {@@ -137,4 +138,18 @@ describe('extract-office › pptxBufferToHtml', () => {expect(html).toContain('<p>Roadmap</p>');expect(html).toContain('Launch <June>');});++ it('renders a valid zero-slide presentation as a blank page', () => {+ const html = pptxBufferToHtml(makeMinimalPptx({ slides: [] }));++ expect(html).toContain('class="office-slide office-slide-blank"');+ expect(html).toContain('aria-label="Blank presentation"');+ });++ it('rejects a presentation that declares a slide but has no slide data', () => {+ const zip = new AdmZip(makeMinimalPptx({ slides: [['Missing']] }));+ zip.deleteFile('ppt/slides/slide1.xml');++ expect(() => pptxBufferToHtml(zip.toBuffer())).toThrow(/slide data is missing/i);+ });});diff --git a/test/main/util/office-preview.test.ts b/test/main/util/office-preview.test.tsindex 20d894b4..1cdd4a9a 100644--- a/test/main/util/office-preview.test.ts+++ b/test/main/util/office-preview.test.ts@@ -31,4 +31,13 @@ describe('office-preview', () => {expect(preview.html).toContain('office-preview office-presentation');expect(preview.html).not.toContain('(no text)');});++ it('renders a presentation with no slides as a blank page', async () => {+ const pptx = makeMinimalPptx({ slides: [] });+ const preview = await officeBufferToPreviewHtml('presentation', 'empty.pptx', pptx);++ expect(preview.kind).toBe('presentation');+ expect(preview.html).toContain('class="office-slide office-slide-blank"');+ expect(preview.html).not.toContain('(no previewable content)');+ });});