Skip to content

feat(dashboard): render .pptx slides in the file panel, degrade honestly without LibreOffice - #10738

Merged
iamwhatever merged 1 commit into
mainfrom
fix/sidepanel-pptx-preview
Sep 28, 2026
Merged

iamwhatever merged 1 commit into
mainfrom
fix/sidepanel-pptx-preview

Conversation

@CrysisDeu

@CrysisDeu CrysisDeu commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A .pptx opened in the dashboard file panel is shown as its actual slides, page by page, and says plainly when it can only show the text.

Opening a .pptx in the dashboard's right-hand file panel showed the deck as one wall of plain text with --- Slide 1 ---, --- Slide 2 --- separators inside a single <pre>. A user reads that as "the panel cannot render my slides": a presentation is its layout, the panel showed none of it, and nothing said why. The reporting instance's audit log shows the same deck re-opened five times in fifteen minutes, each time landing on the same dump.

Why it matters

The file panel is where an agent's deliverables get inspected, and decks are a common deliverable (pptx-maker, python-pptx scripts, uploaded review material). A deck the panel cannot show sends the user to Download and out of the dashboard; a deck it can show slide by slide keeps the review in the panel where the agent is.

Not a goal

  • No pure-JS slide renderer: rendering is server-side via LibreOffice only, and the panel degrades to the text outline where it is absent, rather than shipping a second lower-fidelity renderer.
  • The product does not install LibreOffice from a browser request; it offers a pre-filled ask-the-agent prompt and shows the install command, nothing more.
  • .docx preview behaviour is unchanged.

What changed (motivation → approach → change)

Symptom. A .pptx in the side panel renders as a flat text dump.

Root cause. .pptx support in the file panel was only ever plaintext extraction: /api/file-office-preview flattened every slide's runs into ONE string and OfficeViewer put it in one <pre>. There was no slide renderer anywhere in the dashboard, and no statement on the surface that text was all it could show.

Approach (feasibility recorded on #10736). Nothing in the dashboard can draw a slide itself — that takes an office suite. LibreOffice (soffice) has the one faithful open-source Impress import, and it is a system package the product neither ships nor installs from a browser request (the stance the pptx-maker app already takes for its own thumbnails). So: render slides server-side when LibreOffice is on the gateway host, reusing the app's tool discovery (optional_dep_path("soffice"), soffice_hint()); rasterize the PDF in-process with pypdfium2, which is already a core dependency through pdfplumber (no new dependency, no poppler, no second venv); and degrade honestly without it — the text outline under a row naming the install command. Pure-JS rendering was evaluated and not taken: pptx-preview (ISC, single maintainer, echarts+lodash, MB-scale chunk, fonts substituted, no SmartArt) and pptxtojson (parser only) are both a fidelity step below LibreOffice and a second renderer to maintain.

Change.

  • src/kiro_crew/dashboard/handlers/office_slides.py (new): GET /api/file-office-slides?path= → {status:"ready", digest, count, truncated, slides:[{n,width,height}]} or {status:"unavailable", reason:"soffice_unavailable", hint}; GET /api/file-office-slide?path=&n= → one PNG. Both run the file endpoints' shared _open_checked_file prefix (dashboard path validation, sensitive-path fence, symlink-refusing open, 50 MB fstat cap), map its refusals onto the same codes as the text preview, audit to SEL, and do all filesystem work on the transfer pool. The deck's bytes are copied from the checked handle into a private work directory (the child never opens the user's path; re-hashed before staging so a file that changed under the lock is refused with 409, not rendered under the old key). soffice --headless --norestore --convert-to pdf --outdir … runs as an argv list through sandboxed_spawn_argv(…, "strict", extra_hidden_dirs=<trust root>), with a throwaway -env:UserInstallation profile (no profile-lock contention between concurrent renders, no read of the operator's LibreOffice settings), a minimal environment (TMPDIR inside the work dir, no DISPLAY), captured pipes with a byte cap, and a 180 s wall-clock timeout that kills the process tree. PDF pages are rasterized at 1280 px wide (cap 500 slides, truncated flagged). Cache: <data home>/cache/slide-previews/<sha256>/ with manifest.json + slide-<n>.png, published by atomic rename, per-digest asyncio.Lock (refcounted registry) to dedupe concurrent requests, LRU eviction to a 256 MB budget that spares the deck just rendered and sweeps abandoned work dirs. A (realpath, size, mtime_ns) → digest map lets the per-slide endpoint avoid re-hashing on every fetch; any stat change misses it. .ppt accepted (LibreOffice reads it). The cache is not a trust root — it is same-uid agent-writable, so nothing served from it is taken on faith: the manifest is HMAC-signed with a subkey derived from the SEL trust root (sel_hmac.key, deny-listed for agent shells) under a purpose label (the session_pid_sig construction), records every slide's sha256, and every cache read opens O_NOFOLLOW, refuses non-regular or oversize files, and serves a slide only when its bytes hash to the signed record. An unsigned, forged, foreign-digest or unverifiable entry is a cache miss; a planted symlink at the deck directory is unlinked (never followed) before publishing; without a loadable trust root the cache is inert (503 cache_unsigned). The slide URL carries the manifest digest: the browser may cache a pinned URL (private, max-age=3600) because an edited deck gets a new digest and a new URL, a digest that no longer matches answers 409 stale_digest, and a digest-less request is no-store.
  • handlers/__init__.py, routes/taskrunner.py: export + register the two routes beside /api/file-office-preview.
  • website/src/components/FileRenderers.tsx: OfficeViewer dispatches .pptx/.ppt to OfficeSlidesRenderer: a "Rendering slides…" state (first open converts on the host, later opens are instant), then SlidePager — current slide, prev/next, live Slide n of N, keyboard (arrows/Page/Home/End) bound on the pager, a lazy thumbstrip with role=listbox, and the card's Open/Download actions in the footer (OfficeCard compact). While the manifest loads, the text outline renders at once under a "Rendering slides…" row — no blank wait on content the panel already has — and the pager swaps in when the manifest lands. unavailable degrades to OfficeTextViewer under a row with the gateway host's install command as a code chip; a failed render degrades under the shared ErrorNotice (askAgent) carrying the server's reason and code. .docx never touches the slides endpoint.
  • Degrade is actionable, not a dead end: the no-LibreOffice row carries Ask the agent to install it, which stages a prompt naming the gateway's own install command into the chat composer (sendErrorToChat, the same hand-off every ErrorNotice gets); the user reads and sends it, nothing runs on the click. The pager footer wraps instead of clipping, so a 320 px panel keeps every control visible.
  • The cache is not a trust root, so it is signed with one the agent cannot reach: the manifest HMAC subkey derives from the dashboard's token_signing.key (gateway-only: masked inside every agent sandbox and behind the file-tool fence). The SEL key would not do — in-sandbox MCP servers read it to resolve their session identity, so it is deliberately visible to sandboxed processes and a same-uid agent could forge a signed manifest with it.
  • Staging is pinned end to end: the cache root is reached without following a link at either name below the data home (_open_cache_root, descriptor-relative mkdir/open with O_NOFOLLOW); the deck is hashed WHILE it is staged, so the bytes the child converts are the bytes the digest names (a rewrite between hash and copy is refused, 409 file_changed); and the work directory is pinned by descriptors from the moment it exists (_Staging): O_NOFOLLOW on every open, O_EXCL on every create, descriptor-relative unlink, the PDF opened through it as a regular file, per-slide hashes taken from the bytes written, the manifest and the publish renamed relative to the cache-root descriptor and verified by inode. A name swapped for a link mid-render is refused, never followed, written through or deleted through. There is no by-name fallback: a platform without descriptor-relative file operations (Windows) does not render — the manifest answers unavailable/platform_unsupported (SEL denied) and the panel shows the text outline under a row saying so; a by-name path behind lstat checks was considered and rejected because it leaves a window in which a same-uid process swaps the work directory for a junction and the cleanup deletes through it. A conversion failure's diagnostic (the child's stderr tail) goes through the credential and exfiltration-URL redactors before it is logged or returned. There is no stat-keyed digest shortcut: every request hashes the file, so a same-size rewrite that keeps the timestamp cannot be answered with the previous deck's slides.
  • Slides are pictures of the deck's text and cannot be redacted after the fact, so the render is gated by the same two screens the download path applies: before any page is rasterized, the converted PDF's visible text goes through the context-aware credential redactor (also over a whitespace-collapsed copy, because PDF text extraction can space out kerned letters) and then the exfiltration-URL redactor. A deck either would change is not rendered at all — the manifest answers {status: "unavailable", reason: "content_redacted"}, nothing is published, the refusal is a SEL denied event — and the panel shows the redacted text outline under a row that says why. Every served slide is a SEL success invocation, like every refusal is a denied/not_found one.
  • The compact card (in the pager footer) renders a failed Open's ErrorNotice in a row of its own above Open and Download, so no row carries more than the two file actions.
  • A slide whose image request fails (409 after an edit, 404 after eviction) is not a broken image: the stage shows the shared ErrorNotice (agent hand-off included) with a Render slides again action that re-asks for the manifest — a changed deck gets its new digest, an evicted one is rendered again.
  • Copy names the machine, not the "gateway host": every wait and degrade string says "the machine Kiro Crew runs on" (the blind reader did not know what a gateway host was), and the wait hint says "the first time a deck is viewed" so it cannot be confused with the Open with default app button.
  • website/src/utils/fileReadUrl.ts: fileOfficeSlidesUrl, fileOfficeSlideUrl (derived from fileDownloadUrl like the preview URL; n after the encoded path).
  • Text outline (the degrade state): doc_parser.extract_slides() / join_slides() (one walk, the flat text is the join), /api/file-office-preview returns slides:[{index,text}] beside text for a .pptx, redacted per slide under the shared 512 KB cap; the panel renders numbered cards under a text-only notice. .docx unchanged.
  • Eighteen catalog keys in en.manual.json and all twelve locales; en-XA regenerated.
  • docs/feature-map/README.md: a row for the slide preview; docs/system-specs/modules/learn-cron-dashboard.md: the two endpoints, the degrade contract, the signed cache and the frontend contract under Office previews.

Tests

  • test/test_file_office_slides.py (new) — soffice stubbed at _run_soffice with a real PDF written by pypdfium2; everything else runs for real. Degrade: no soffice → unavailable + hint, nothing written, SEL-audited. Render path: one conversion for two requests (second from cache), manifest shape, 1280×720 from a 16:9 page, intermediates and work dir gone. Conversion failure → 502 convert_failed, no work dir left. The child is handed the staged copy, never the user's path. _run_soffice prepares through sandboxed_spawn_argv(…, "strict") with the trust root hidden and a minimal env (no DISPLAY, TMPDIR in the work dir) and spawns via create_subprocess_limited — pinned on the chokepoint call. _soffice_argv is a list with a private profile. Slide endpoint: PNG bytes + nosniff for the authorized path, max-age only with the digest pin, no-store without, 409 for a stale digest, 400 for a malformed one; out-of-range/malformed n → 404/400; never-rendered → 404. Edited deck misses the cache. Cache is not a trust root: an unsigned or field-forged manifest is a miss for both endpoints; a slide file replaced by a symlink to a secret, or with altered bytes, is refused (404) and SEL-audited as cache_integrity, and the secret's bytes never appear in the response; with no trust root the cache is inert (503, nothing rendered, nothing read); a symlink planted at the deck directory is unlinked and its target untouched. Shared envelope: 415 unsupported, 413 oversized before any conversion, 403 sensitive, 400 forbidden. Eviction: LRU order, keep spared, abandoned work dir swept; manifest for another digest rejected.
  • test/test_file_office_slides.py also pins the staging: a work directory whose name is swapped for a link mid-render is neither published nor deleted through (the link's target is untouched, no deck appears at the digest, the real directory received the manifest); a cache root swapped for a link is refused before anything is staged into its target. The trust root is stubbed at token_secret._get_secret; without one the cache is inert (503 cache_unsigned). A deck whose rendered text carries a credential answers unavailable/content_redacted, publishes nothing, discards its staging dir and is SEL-audited as denied; a served slide is SEL-audited as a success. Without descriptor-relative operations (_DIR_FD_OPS patched false) the manifest answers platform_unsupported, no conversion runs and the refusal is audited; the render-path tests are skipped where the platform lacks those operations, so the Windows shards exercise the fail-closed answer instead.
  • test/test_doc_parser.py — TestExtractSlides (order, deck numbering with gaps, join_slides == extract_text, budget, fileobj, sensitive-path audit, parse failure).
  • test/test_file_office_preview.py — .docx carries no slides; .pptx slides beside the flat text; slides share the cap; redaction before the per-slide cut.
  • website/src/test/FileRenderers.test.tsx — pager renders from the slides endpoint (the outline that stood in while rendering is gone once slides are ready), stage/thumbstrip/prev-next/keyboard/Home behaviour, Download original reachable; unavailable → outline under the degrade row showing the hint, whose Ask the agent to install it stages a prompt carrying that command and navigates to the chat; a slide whose image fails to load is replaced by the ErrorNotice with Render slides again, which re-fetches the manifest, while paging to other slides keeps working; a content_redacted manifest renders the redacted outline under a row naming the reason, with no install hand-off; a failed Open on the compact card puts its notice in a separate row from the two file actions; render error → outline under an ErrorNotice carrying the server's reason and code; while the manifest is pending the outline is already shown under the rendering row; .ppt without soffice → degrade row + download card; .docx never asks the slides endpoint; flat text kept when no slides.
  • website/src/utils/fileReadUrl.test.ts — the two new builders join the shared encoding table; n lands after the encoded path and resolve=1.

Static gates run locally on the head: tsc -b, eslint (touched files), i18n-check vs origin/main (19/19), black (non-baselined files), flake8, isort, mypy, check_sync_io_in_async, check_subprocess_encoding, check_black_formatting, check_brand_name, check_feature_map, docs-lint. Tests were written, not executed locally; CI runs them.

Manual verification

Real gateway built from this head (live source, isolated home, dark theme, 1280×820), the owner's 30-slide PowerPoint export and a python-pptx deck, on the same host in two states:

  • LibreOffice present (26.8, aarch64): first open renders in ~22 s (soffice ~20 s cold, pypdfium2 1.8 s for 30 pages) while the text outline is already on screen under the rendering row; /api/file-office-slides → ready, 30 slides, signed manifest with 30 hashes; /api/file-office-slide?n=5&digest=… → 1280×720 PNG with private, max-age=3600, the same URL without the digest → no-store, a stale digest → 409; cache dir 2.1 MB; second open instant from cache; pager, thumbstrip and keyboard paging work (recording below). Tamper probes on the live cache: slide-7.png replaced by a symlink to the gateway's .local_secret → 404, secret bytes absent from the response, SEL cache_integrity; slide-8.png with appended bytes → 404, audited; manifest.json with count edited → treated as a miss and the deck re-rendered with a fresh signature.
  • LibreOffice absent (same gateway, binary off PATH, cache cleared): manifest → unavailable with sudo apt install libreoffice (or: sudo dnf install libreoffice); panel shows the degrade row (command + Ask the agent to install it) over the text outline; a .ppt shows the same row over the download card.
  • Conversion fails (a soffice on PATH that exits 77): manifest → 502 convert_failed with the child's last stderr line; panel shows the outline under an ErrorNotice carrying soffice exited 77: … (convert_failed) and Ask the agent.
  • Deck over the cap (a 505-slide deck): converted in 17 s cold; manifest count: 500, truncated: true; slide 500 serves; the pager footer reads Slide limit reached at 500; the rest of the deck is not shown.
  • Credential-bearing deck: the 30-slide deck with AKIAIOSFODNN7EXAMPLE written into a slide-1 text run → /api/file-office-slides answers {status: "unavailable", reason: "content_redacted"} in 1 s (converted, screened, never rasterized), no cache directory appears, security_events gains one denied/content_redacted row; the panel shows the redacted outline under the reason row. The same deck without the key renders as before.
  • Platform without descriptor-relative operations: gateway booted with the capability flag forced off → manifest {status: "unavailable", reason: "platform_unsupported"}, nothing staged; the panel shows the outline under the reason row.
  • Slide fetch fails after eviction: deck rendered, its cache directory removed, End pressed to a slide the lazy thumbstrip had not fetched → /api/file-office-slide answers 404 → the stage shows the notice Slide 30 did not load: … with Ask the agent and Render slides again; the button re-renders the deck and slide 30 appears.
  • Narrow panel: with the slides root forced to 320 px every footer control stays inside its box (prev/counter/next on one line, Open/Download on the next); nothing is clipped.
  • .docx unchanged; /api/file-read and /api/file-watch unchanged.

Screenshots / video

Side panel, dark theme, 1280×820, the same 30-slide deck:

Before (main) After — while the first render runs After — LibreOffice on the host After — no LibreOffice
Before: one pre of --- Slide N --- text Text outline under the Rendering slides row Slide pager with thumbstrip Degrade row with install hint over the text outline

Every other state the diff introduces (same deck unless noted; the fifth is the pager forced to 320 px, the sixth the 30-slide deck after its cache directory was removed, the seventh the same deck with an AWS key written into slide 1, the eighth the gateway with descriptor-relative operations forced off):

Conversion failed Deck over the 500-slide cap .ppt without LibreOffice No LibreOffice: the hand-off row 320 px Slide fetch failed after eviction Credential-bearing deck Platform without pinned staging
ErrorNotice with the soffice exit reason over the outline Pager with Slide limit reached at 500 in the footer Degrade row with Ask the agent to install it over the download card Degrade row with the install command and Ask the agent to install it over the outline Pager at 320 px: footer wrapped, nothing clipped ErrorNotice on the stage with Render slides again Reason row over the redacted outline: text contains what looks like a credential Reason row over the outline: slide images not available on this platform

Cold open then paging through the deck (outline under "Rendering slides…" → pager; Next ×6, a thumbnail jump, arrow keys, End, Home; ~51 s):

paging-deck.mp4

recorded from 1deb8dc · kirodotdev/KiroCrew fix/sidepanel-pptx-preview · mode: live-source gateway, dark theme, soffice on PATH, empty cache · real server + real deck, no fixtures

Full-page context, 1280×820

With LibreOffice, full page

Without LibreOffice, full page

Related Issues

Closes #10736

Pattern harvest

Rule candidate: review-prompt
Pattern: a visual document format shown as extracted text with no statement of the limitation — when a panel cannot render a format faithfully, say what is missing and how to get it, and structure what it can show.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@CrysisDeu
CrysisDeu requested review from a team and buluoray September 14, 2026 07:43
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 14, 2026
@github-actions

github-actions Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — 🟡 CONCERNS

Design-level review of ec27174c407652ee0321ec1f9d46651b895b2ce6 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: CONCERNS

Spec and description misname the cache trust root as sel_hmac.key; code signs with token_signing.key — a contradiction a future editor may "fix" wrongly.

Watch

The committed spec says "503 cache_unsigned when the SEL trust root cannot be loaded" (learn-cron-dashboard.md, second Office-previews paragraph), and the description's first change bullet says the manifest subkey "derived from the SEL trust root (sel_hmac.key, deny-listed for agent shells)". The code (_signing_key in office_slides.py) derives from the dashboard's token_signing.key and its own docstring explains the SEL key is agent-visible and would let a same-uid agent forge signed manifests. A maintainer trusting the spec's "SEL trust root" line could later re-key the cache onto the forgeable key the design deliberately rejected.
Clears when: the spec sentence and the description bullet name token_signing.key, matching the Cache. paragraph and the code.

[DESIGN-REVIEWED] ec27174

@github-actions

github-actions Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ human override accepted

Human judgment by @iamwhatever overrides the GPT 5.6 finding for ec27174c407652ee0321ec1f9d46651b895b2ce6; the recorded reason is authoritative for this commit.

[GPT-OVERRIDE] ec27174

This comment is updated in place on each push.

The model was not re-run because an authorized human decision supersedes it.

False positive or not applicable? A repository writer can comment:
/ai-review override gpt ec27174c407652ee0321ec1f9d46651b895b2ce6: <one-sentence reason>

@github-actions

github-actions Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — 🟡 CONCERNS

Premise-level review of ec27174c407652ee0321ec1f9d46651b895b2ce6 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: CONCERNS

The manifest ships three fields nothing reads, and a Windows-only eviction walk for a cache the Windows render path can never populate.

Not justified as shipped

  • Item 9 — zero consumers: the signed manifest carries width, source_ext, rendered_at; grep for rendered_at|source_ext and top-level width reads finds only the defining write (office_slides.py:1155) — no server or client consumer.
    Subtraction: drop the three fields from _finish; per-slide width/height are the ones consumed.
    Clears when: the fields are deleted, or a real reader of any of them is named.
  • Item 10 — inherited: _evict_to_budget_by_name runs only where _DIR_FD_OPS is false (Windows), where its own docstring says "this tree is never populated by a render" — the justification is "the cache bookkeeping still runs cross-platform", the consistency form; the only content it could ever sweep is a data home shared with a POSIX gateway, a scenario nothing names.
    Subtraction: delete _evict_to_budget_by_name and its three tests; evict_to_budget returns 0 when _DIR_FD_OPS is false.
    Clears when: the fallback is removed, or the cross-OS shared-data-home case is named as supported (the lstat-fallback read path suggests it may be — say so).

What this change ships

Inventory (10 items) — 8 justified

Intent: show a .pptx in the file panel as its actual slides, saying plainly when only text is available — an ADDITION.

  1. A deck opens as rendered slides with pager, keyboard paging and thumbstrip when LibreOffice is on the gateway host — justified
  2. Without LibreOffice, a row names the install command with an "Ask the agent" hand-off over the outline — justified
  3. The .pptx text preview becomes per-slide outline cards under a "text only" notice (new slides field, one consumer) — justified
  4. Legacy .ppt, previously download-only, now gets slides or the degrade row — justified
  5. A deck whose visible text the credential/exfil redactors would change is not rendered at all — justified
  6. On Windows slides never render; the outline shows the reason — justified
  7. New persisted content-keyed slide cache, HMAC-signed manifests, 256 MB LRU — justified
  8. Digest-pinned slide URLs are browser-cacheable; an edited deck answers 409 — justified
  9. Manifest fields width, source_ext, rendered_at — zero consumers
  10. By-name cache eviction on platforms that cannot render — inherited, consistency-form justification

[FIRST-PRINCIPLES-REVIEWED] ec27174

@github-actions

github-actions Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Fable 5) — 🟡 CONCERNS

UX-level review of ec27174c407652ee0321ec1f9d46651b895b2ce6 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

UX-Verdict: CONCERNS

"Render slides again" can silently do nothing — no pending state, and after cache eviction the failure never clears; readers fear the install hand-off.

Watch

  • "Render slides again" breaks its promise in the case its own error names: onRerender → query.refetch() shows no pending state (isLoading is initial-only), and useEffect(..., [manifest.digest]) never clears failed when an evicted, unchanged deck re-renders under the same digest — the user clicks the fix, waits up to 30 s with zero acknowledgment, and the error stays until they happen to reopen the file. Hits every eviction/edit recovery, task-blocking, every time. Fix: reflect isFetching in the button and clear/remount failed slides on any successful refetch (key on dataUpdatedAt).
  • The blind reader would not click "Ask the agent to install it": "clicking probably… starts installing something… no, not on first open — installing software feels like a big step", and "three flavours of Ask the agent… I can't tell what the assistant would actually do". Nothing on the surface says the click only drafts a composer message, so the remedy the degrade row exists for goes unused by exactly the user it targets. Hits every no-LibreOffice host, persistent. Fix: say "drafts a message, nothing runs" at the button (title/copy) and pass askAgentLabel to the two error notices so the three links name their jobs — ErrorNotice already warns identical default labels are indistinguishable.
  • Failed thumbnails render as raw browser broken-image glyphs (visible in shot-09) while the stage gets the graceful notice — no onError on the thumbstrip <img>s. Fix: swap a neutral placeholder on error.
  • The render-failure notice shows raw child output — "soffice exited 77: Error: source file could not be loaded (convert_failed)" (shot-05); the reader called it "technical gibberish". Keep the detail in the Ask-the-agent payload; show only the plain sentence.

Suggestions

  • slides_platform_unsupported "its file system lacks the guarantees the renderer needs" meant nothing to the reader (shot-11); say plainly "Slide images aren't supported on this machine's operating system yet. Showing the text outline instead."

[UX-REVIEWED] ec27174

@github-actions

github-actions Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5 Review — ✅ no blocking findings

Reviewed ec27174c407652ee0321ec1f9d46651b895b2ce6 — this comment is updated in place on each push.

Review details

No blocking findings.

FINDING — website/src/components/FileRenderers.tsx:872 — the "Render slides again" button is inert for an evicted slide: onRerender refetches and the re-render reproduces the identical content digest, so useEffect(..., [manifest.digest]) never fires and failed keeps slide N in the error state for the life of the panel even though the backend rendered it successfully → Fix: clear the set in the button's handler (onClick={() => { setFailed(new Set()); onRerender() }}).

FINDING — src/kiro_crew/dashboard/handlers/office_slides.py:1455 — _render_prepare raises _ConvertFailed (from _open_cache_root's O_NOFOLLOW refusal and _Staging.__init__) but its call site is guarded by except _PlatformUnsupported alone, so a planted link or non-directory at cache/slide-previews falls to the outer except Exception and answers 500 render_failed with _log("failure", raw_path) carrying no reason, instead of the 502 convert_failed + redacted detail + "convert_failed" audit reason the arm at line 1473 exists to produce → Fix: add except _ConvertFailed to the inner try at 1451 routing to the same 502 response as 1473.

[OPUS-REVIEWED] ec27174

Verdict parsed from the review's SHA-scoped output markers for commit ec27174c407652ee0321ec1f9d46651b895b2ce6.

False positive or not applicable? A repository writer can comment:
/ai-review override fable ec27174c407652ee0321ec1f9d46651b895b2ce6: <one-sentence reason>

@CrysisDeu
CrysisDeu force-pushed the fix/sidepanel-pptx-preview branch from dd0c99c to c84e924 Compare September 14, 2026 08:37
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 14, 2026
@CrysisDeu CrysisDeu changed the title fix(dashboard): preview a .pptx in the file panel as a slide outline feat(dashboard): render .pptx slides in the file panel, degrade honestly without LibreOffice Sep 14, 2026
@CrysisDeu
CrysisDeu force-pushed the fix/sidepanel-pptx-preview branch from c84e924 to 572ef4b Compare September 14, 2026 09:25
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 14, 2026
@CrysisDeu

Copy link
Copy Markdown
Contributor Author

Round 1 disposition (reviews of c84e924d46), addressed in 572ef4bbfc:

GPT F1 (security, fenced) — agent-writable cache enables credential disclosure. Fixed structurally, not adjudicated. The cache is now treated as untrusted storage: the manifest is HMAC-signed with a subkey derived from the SEL trust root under the label kirocrew.slide_previews.manifest.v1 (the session_pid_sig construction — the raw root never signs), it records the sha256 of every slide it covers, and both endpoints read through _read_regular_nofollow (O_NOFOLLOW, S_ISREG, size cap, lstat/fstat identity check where the flag is absent). A slide is served only when the bytes read hash to the signed record; an unsigned, forged or foreign-digest manifest is a cache miss; a symlink planted at the deck directory is unlinked (never followed) before publishing; without a loadable trust root the cache is inert (503 cache_unsigned). Verified live on the dev gateway: slide-7.png replaced by a symlink to the gateway's .local_secret → 404 with no secret bytes in the response and a SEL cache_integrity audit; slide-8.png with appended bytes → 404, audited; manifest.json with an edited field → miss, deck re-rendered with a fresh signature. Pinned by test_an_unsigned_or_forged_manifest_is_a_cache_miss, test_a_slide_file_that_is_a_symlink_or_altered_is_refused_and_audited, test_without_a_trust_root_the_cache_is_inert, test_a_planted_symlink_at_the_deck_directory_is_replaced_not_followed.

GPT F2 — slide-render failures bypass ErrorNotice. Fixed: a failed render keeps the server's error/detail/code and renders through the shared ErrorNotice (askAgent, testId="office-slides-render-error"); the hand-written row now carries only the two non-error states (host without LibreOffice; render in progress). Pinned by the updated FileRenderers test.

GPT F3 / Feature Map Gate — map untouched. Fixed: a Slide preview for decks row in docs/feature-map/README.md naming FileRenderers.tsx (OfficeSlidesRenderer), handlers/office_slides.py and the three endpoints. check_feature_map.py passes against origin/main.

Opus (advisory) — stale slide from the browser cache after an edit. Real, fixed: fileOfficeSlideUrl now carries the manifest digest, so an edited deck gets a new URL; the server answers private, max-age=3600 only for a digest-pinned request, no-store otherwise, and 409 stale_digest when the digest no longer matches the file. Pinned in test_slide_endpoint_serves_the_cached_png_for_the_authorized_path and the fileReadUrl tests.

Design "Watch" — spec. Added under Office previews in docs/system-specs/modules/learn-cron-dashboard.md: both endpoints, response shapes and codes, the degrade contract, the signed-cache invariants and the frontend contract. Design suggestion (shared helper for soffice discovery): kept as a lazy import of the pptx-maker backend (optional_dep_path, soffice_hint) — the same shape handlers/aws_consent.py uses for the AWS Control backend — so there is exactly one discovery of soffice in the tree; lifting it into a shared module would move the app's own contract for the sake of a hypothetical restructure. Happy to do it as a follow-up if maintainers prefer.

UX "Watch" — first open blocks behind "Rendering slides…". Fixed as suggested: the text outline renders immediately under the rendering row and the pager swaps in when the manifest lands (screenshot "while the first render runs" and the first seconds of the recording). UX suggestion (slides_truncated): now states the cap ("Slide limit reached at {{n}}; the rest of the deck is not shown.").

First Principles — "undeclared renderer inside a fix". The lanes ran against the previous description, which predated the scope change (the owner asked for real slide rendering after the outline-only fix was opened). The PR title, commit and description now declare the renderer, the two endpoints, the cache, .ppt, the first-open conversion, the degrade row and all eleven keys; the platform field with zero consumers is removed. Feasibility and the pure-JS alternative are recorded on #10736.

Semgrep / Brand. 0o700 → stat.S_IRWXU (the pod/runtime.py spelling); "KiroCrew's" → "Kiro Crew's" in the one prose line.

Evidence re-attached from 572ef4bbfc: before, outline-under-rendering-row, pager, degrade row, full pages, and a 51 s recording of the cold open and paging.

@CrysisDeu
CrysisDeu force-pushed the fix/sidepanel-pptx-preview branch from 572ef4b to 4f08075 Compare September 14, 2026 09:31
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 14, 2026
@CrysisDeu
CrysisDeu force-pushed the fix/sidepanel-pptx-preview branch from 4f08075 to 2df9900 Compare September 14, 2026 11:05
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 14, 2026
@CrysisDeu

Copy link
Copy Markdown
Contributor Author

Re the GPT 5.6 and UX Review verdicts on 4f08075f96 — all addressed in 2df990092e (single commit, force-pushed):

GPT F1 — staging permits symlink traversal (security, fixed). The work directory is now pinned by a descriptor from the moment it is created (_Staging in office_slides.py). Every write into it and read out of it is descriptor-relative: O_NOFOLLOW on every open, O_EXCL on every create, dir_fd unlink/rename/rmtree, the PDF opened through it as a regular file, and the per-slide hashes taken from the bytes written rather than re-read by name. The publish rename is verified by inode afterwards; a name swapped for a link mid-render is refused (convert_failed) and the planted link removed — never followed, written through or deleted through. Only the child receives paths (soffice takes nothing else, and runs sandboxed). Pinned in test_a_staging_directory_swapped_for_a_link_is_never_published_or_deleted_through; platforms without dir_fd fall back to the same steps behind lstat identity checks.

GPT F2 — stat collisions serve obsolete slides (security, fixed rather than overridden). The (realpath, size, mtime_ns) → digest map is gone. Every request, slide fetches included, hashes the file; the hash is bounded by the 50 MB deck cap and takes milliseconds, so there is no collision to reason about.

GPT F3 — footer clips at 320 px (fixed). The pager footer is flex-wrap: paging controls stay on the first line, Open/Download drop to the next, the cap notice takes a full-width line. Verified live with the slides root forced to 320 px — every child box inside the footer box (screenshot "320 px" in the PR body).

GPT F4 — feature-map row (fixed). The row now distinguishes the .pptx text outline from the .ppt download-card fallback (and names the hand-off).

GPT finding — module doc (fixed). States that rendering is refused (503 cache_unsigned) without a trust root.

UX evidence gaps (closed). Screenshots added for the failed-render ErrorNotice (a soffice on PATH exiting 77 → 502 convert_failed), the truncated footer (a 505-slide deck → count: 500, truncated: true), and a .ppt opened without soffice (degrade row over the download card). All from the live gateway at this head; the paging recording was re-taken from it too.

UX watch — the install remedy was unactionable (fixed). The no-LibreOffice row now carries Ask the agent to install it: it stages a prompt naming the gateway's own install command into the chat composer (sendErrorToChat, the same hand-off every ErrorNotice gets); the user reads and sends it, nothing runs on the click. Covered in FileRenderers.test.tsx.

UX watch — counter wrapping mid-phrase (fixed). whitespace-nowrap on the Slide n of N span.

Also fixed from the CI shards on 4f08075f96: the pager test asserted the text-preview endpoint is never fetched, which stopped being true when the outline started rendering under the "Rendering slides…" row — it now asserts the outline and the row are gone once slides are ready; and the OfficeViewer dispatcher is no longer a memo() boundary (it renders no copy of its own; both targets subscribe to the language), which is what the memo/i18n ratchet counted.

@github-actions github-actions Bot removed the readiness: checking Automated validation is still running label Sep 14, 2026
@iamwhatever
iamwhatever force-pushed the fix/sidepanel-pptx-preview branch from 2aca745 to 729086b Compare September 26, 2026 08:01
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Sep 26, 2026
@iamwhatever
iamwhatever force-pushed the fix/sidepanel-pptx-preview branch 2 times, most recently from 5486d71 to 2335440 Compare September 26, 2026 08:31
@iamwhatever

Copy link
Copy Markdown
Contributor

Addressed two of the three GPT/Opus review findings in code (head 233544093):

  • PDF text retention (office_slides.py:_deck_text) — added MAX_SCREEN_TEXT_CHARS (8M) so the credential/exfil screen's accumulated text is bounded; a compressed/repeated-text deck under the 50 MB gate can no longer expand to an in-process OOM. Regression test test_deck_text_stops_accumulating_at_the_screen_char_cap.
  • Eviction followed a replaced cache root (office_slides.py:evict_to_budget) — eviction now enumerates and removes through the descriptor _open_cache_root() pins (O_NOFOLLOW at every step) instead of os.scandir(cache_root()) by name, so a slide-previews name swapped for a link cannot redirect the scan or the recursive rmtree outside the cache. Regression test test_eviction_never_scans_or_deletes_through_a_cache_root_swapped_for_a_link.
  • Also registered office_slides.py as a redaction sink in security_posture._REDACTION_SINKS (it screens rendered text before rasterizing).

Remaining GPT finding — staging by-name paths handed to the LibreOffice child (office_slides.py ~:572): the gateway's own I/O is descriptor-pinned, but soffice receives by-name --outdir/input/TMPDIR/cwd into the agent-writable cache tree, and a same-uid agent can swap the 0o700 staging dir for a link during the multi-second conversion window. The robust fix is to place staging in a gateway-private tree the agent's sandbox cannot retarget (moving it out of the shared cache root), which is an architectural change to the caching model — flagging for the author/maintainer rather than reshaping the design unilaterally.

@iamwhatever
iamwhatever force-pushed the fix/sidepanel-pptx-preview branch from 2335440 to e8d747d Compare September 26, 2026 09:48
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 26, 2026
@iamwhatever
iamwhatever force-pushed the fix/sidepanel-pptx-preview branch from e8d747d to 57ee711 Compare September 26, 2026 09:50
@iamwhatever

Copy link
Copy Markdown
Contributor

Addressed the three GPT/Opus findings on the prior head in code (head 57ee711dc):

  • office_slides.py:204 — untrusted PATH executable: soffice_path now passes the discovered executable through validate_provider_executable, so an agent-planted soffice on an agent-writable PATH dir is refused (deck degrades to the text outline) instead of run.
  • office_slides.py:537 — event-loop blocking resolve(): the profile path is already absolute, so the argv now uses .absolute().as_uri() (a pure string op) instead of .resolve() (per-component lstat/readlink on the loop; also wrongly followed links in the cache tree).
  • office_slides.py:974 — truncation bypassed screening (regression from the earlier memory cap): _deck_text now reports when it truncated at MAX_SCREEN_TEXT_CHARS, and _rasterize refuses to render (fail-safe to the redacted outline) when it did, so a credential past the boundary can never ride into a served PNG. Fixes both the OOM and the bypass. Regression tests added.

Also fixed a cross-platform regression in the eviction hardening: evict_to_budget falls back to the by-name walk on platforms without descriptor-relative operations (Windows), where the render path is unsupported and the symlink-swap window never opens.

Disposition on the non-blocking top-level-imports FINDING (office_slides.py:202): the engine / preview_tools / sel imports are intentionally function-local. The pptx-maker builtin-app package is heavy and only needed on a soffice miss; importing it at module scope would pull it into every gateway startup. This mirrors the documented lazy-import pattern in handlers/aws_consent.py. Keeping them lazy on purpose.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 26, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor

Stopping code changes here on this PR's security-review lane (head 57ee711dc). This is the third GPT review round on office_slides.py; each round I fixed the upheld findings and the next round surfaced new spans. This round's three are all security-class fenced, and GPT's own adjudication marks two of them FLAG-level (conditions it judged extreme, with a pre-drafted override) — the block message states the only clearance path is a repository-writer override, which an agent must not post.

The findings, for a maintainer/author to weigh:

  • :1056 (FLAG) — text cap applied after full-page allocation. GPT notes only one page's text is held over the cap at a time, bounded by what soffice can lay out before the 180 s SIGKILL, so the amplification is out of reach and a MemoryError already discards staging + answers 500. Marginal.
  • :1369 (FLAG) — a _PlatformUnsupported cache-setup path drops the opened deck handle before it is entered; GPT notes this needs thousands of refused requests with no gc, on a host where the feature is already fully disabled. Marginal.
  • :554 (UPHOLD-FENCED) — the staging copy reads the deck whole after an fstat_cap check, so a file that GROWS after the fstat can exceed 50 MB before the digest refusal (files.py warns whole-read adopters not to rely on fstat_cap). This is the one substantive item — a real TOCTOU on the whole-read path — but a robust fix (bounding the copy loop itself) is an author-side change to the staging read contract.

Everything else this PR owns is green: rebase, the OOM pixel cap, the credential-screen memory cap with fail-safe refusal on truncation, the descriptor-hardened eviction (with a Windows by-name fallback), executable validation, no resolve() on the loop, the redaction-sink registration, and the i18n fixes. The remaining non-GPT reds (Frontend Tests 2/3 + Coverage) are inherited main drift, fixed main-side by #14138.

@iamwhatever
iamwhatever force-pushed the fix/sidepanel-pptx-preview branch from 57ee711 to 8e05b6c Compare September 26, 2026 15:37
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 26, 2026
…tly without LibreOffice

Opening a .pptx in the side panel rendered the deck as one wall of text with
`--- Slide N ---` separators, which reads as "the panel cannot render my
slides". A presentation is its layout; the panel showed none of it and said
nothing about why.

Slides. Nothing in the dashboard can draw a slide itself: that takes an
office suite, and the one open-source renderer with a faithful Impress
import is LibreOffice (`soffice`), a system package the product does not
install from a browser request. So the panel renders slides WHEN soffice is
on the gateway host and says so when it is not.

Backend (handlers/office_slides.py): `GET /api/file-office-slides` answers a
manifest -- `{status: "ready", digest, count, slides}` once the deck is
rendered, `{status: "unavailable", reason, hint}` with the pptx-maker app's
own per-OS install command when soffice is absent -- and
`GET /api/file-office-slide?n=` serves one PNG. Both run the file endpoints'
shared open-and-check prefix (path validation, sensitive-path fence,
symlink-refusing open, 50 MB cap) and audit to SEL. The deck's bytes are
copied from the checked handle into a private work dir, converted by
`soffice --headless --convert-to pdf` as an argv list through the strict
sandbox chokepoint with a throwaway `-env:UserInstallation` profile, a
minimal environment and a hard timeout, then rasterized in-process with
pypdfium2 (already a core dependency through pdfplumber) at 1280 px. The
result lives under `<data home>/cache/slide-previews/<sha256 of bytes>/`:
content-keyed so an edited deck re-renders and an unchanged one never does,
published by atomic rename, deduped by a per-digest lock, bounded by
least-recently-used eviction. `.ppt` is accepted too -- LibreOffice reads it.
soffice discovery is the pptx-maker app's (`optional_dep_path`,
`soffice_hint`), imported lazily like the AWS Control consent handler does.

Frontend (FileRenderers.tsx): `OfficeViewer` dispatches decks to
`OfficeSlidesRenderer` -- a pager (prev/next, keyboard, live counter) over
the current slide with a lazy thumbstrip, the card's Open/Download actions
in its footer, and a "Rendering slides..." state for the first open. When
the manifest says `unavailable` or the render fails, it degrades to the text
outline under a row that names the missing piece and the install command.

Text outline (the degrade). doc_parser gains `extract_slides()` -- the slide
walk `extract_text()` flattens, returned per slide -- and `join_slides()`
owns the separator, so the two cannot disagree. `/api/file-office-preview`
returns `slides: [{index, text}]` beside `text` for a .pptx from ONE
extraction, redacted per slide under the shared 512 KB cap; the panel
renders them as numbered cards under a text-only notice. `.docx` is
unchanged.

Eleven catalog keys, all locales, en-XA regenerated.

Closes #10736

Co-authored-by: CrysisDeu <32421101+CrysisDeu@users.noreply.github.com>
@iamwhatever

Copy link
Copy Markdown
Contributor

Rebased: main moved to 6978ac04 since this head last ran CI. The rebase absorbs the two base-side gate fixes that were red on every open PR — #14398 (Frontend Tests: CrewWebviewContainment) and #14404 (the prepare-pr skill-size backend/coverage gate). Commit content is byte-identical (range-diff =); only the base changed. CI re-running on ec27174c.

@iamwhatever

Copy link
Copy Markdown
Contributor

/ai-review override gpt ec27174: the staging tree sits in the same agent-writable cache a same-uid writer could use to rewrite the source deck itself, so the signed cache closes the disclosure class and cannot exceed the deck's own integrity; moving staging to a gateway-private root is a repo-wide sandbox-mask decision, not a local fix.

@github-actions

Copy link
Copy Markdown
Contributor

Human judgment recorded

@iamwhatever marked the gpt AI finding as false positive, not applicable, or explicitly accepted for ec27174c407652ee0321ec1f9d46651b895b2ce6.

the staging tree sits in the same agent-writable cache a same-uid writer could use to rewrite the source deck itself, so the signed cache closes the disclosure class and cannot exceed the deck's own integrity; moving staging to a gateway-private root is a repo-wide sandbox-mask decision, not a local fix.

This decision applies only to this commit. A new push requires a new judgment.

@buluoray buluoray left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I checked this at head ec27174c.

  • Paths. All three worker entry points go through _files._open_checked_file, which validates the path, applies is_sensitive_path and opens with O_NOFOLLOW. The slide PNG route re-authorizes and re-hashes the source on every request.
  • Route auth. The routes are plain add_get behind token_auth_middleware, with no exemption entry.
  • LibreOffice. soffice must pass validate_provider_executable, so a binary planted on PATH is refused. It runs from a list argv (no shell) under sandboxed_spawn_argv(..., "strict") with rlimits and capped pipes. On timeout the whole process tree is killed.
  • Bounds. Deck size is capped at fstat, there are at most 500 slides, and pixel area is capped. If the text screen would be truncated, the deck is refused rather than rendered without the screen. The cache checks integrity with compare_digest on per-slide sha256.
  • No LibreOffice. Without it, the route returns a 200 unavailable and the panel degrades to the text outline.

I mutation-tested two things. Weakening the cache hash check turns test_a_slide_file_that_is_a_symlink_or_altered_is_refused_and_audited red. Stubbing out the rendered-text screen turns test_a_deck_whose_slides_show_a_credential_is_not_rendered red. With pypdfium2 present (pdfplumber>=0.10 pulls it in), 165 targeted tests pass.

I agree with the codex override. A writer with the same uid who swaps the staged deck or its outputs mid-conversion gets nothing beyond what editing the deck would give them, since outputs are read through pinned fds and still pass the text screen.

Non-blocking follow-ups: _ConvertFailed from _render_prepare surfaces as a 500 instead of a 502, the spec still says "SEL trust root" where the code uses token_signing.key, and the "Render again" button can be inert.

@bolichen97

Copy link
Copy Markdown
Contributor

Readiness sweep 2026-09-29 (bolichen97): holding this one for a rebase rather than merging as-is.

  • Head ec27174 is ~240 commits behind main, and since the CI base main changed 5 of this PR's own files: src/kiro_crew/security_posture.py (11 commits), src/kiro_crew/dashboard/handlers/files.py (4), handlers/__init__.py, website/src/utils/fileReadUrl.ts, test/test_file_office_preview.py. The merge is textually clean, but no CI round has run against current main.
  • Everything else checks out (readiness passed, no blocking threads, iamwhatever's approvals on head — which the last-push rule does not count).

Please rebase onto main; once PR Readiness is green on the new head I will approve and merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-author-decision PR blocked on author input

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Side panel cannot render .pptx slides — shows a flat text dump; render slides via LibreOffice, degrade honestly without it

6 participants