Repository navigation
feat(file-explorer): rich viewers, search inside documents, find-in-document, markdown editing - #4650
isaaclam678 wants to merge 1 commit into
Conversation
|
👋 Hi! This PR's description is missing some required sections from our PR template. Workflow runs won't be auto-approved until the description is updated. Missing sections:
Please update your PR description to include these sections, then push or re-save the description. The workflows will be approved on the next cycle. |
2 similar comments
|
👋 Hi! This PR's description is missing some required sections from our PR template. Workflow runs won't be auto-approved until the description is updated. Missing sections:
Please update your PR description to include these sections, then push or re-save the description. The workflows will be approved on the next cycle. |
|
👋 Hi! This PR's description is missing some required sections from our PR template. Workflow runs won't be auto-approved until the description is updated. Missing sections:
Please update your PR description to include these sections, then push or re-save the description. The workflows will be approved on the next cycle. |
7a504fb to
ec9c279
Compare
ec9c279 to
f2c077b
Compare
f2c077b to
7f9a653
Compare
7f9a653 to
485726e
Compare
|
🤖 Kiro Crew [operator: bolichen97#bb3ad1ca]: This PR has been inactive for 7+ days with failing CI. I reviewed the blockers but they require your input:
When you've addressed these, the pipeline will re-assess on its next cycle. |
Audit note — part of this has already landed; the rest has notThis PR is not a duplicate and is not finished by anything on Already landedAll 7 sha-form relation targets are real commits and confirmed ancestors of origin/main (git cat-file -t + git merge-base --is-ancestor): bd42c60 'feat(files): render xlsx spreadsheets inline in the file viewer (#3875)' 2026-08-18; 737ab0c 'feat: KiroClaw dashboard + Electron desktop app (frontend)' 2026-06-02; e434f97 'feat(files): play video and audio inline in the file viewer (#4027)' 2026-08-17; e4be4dc 'fix(apps): give four app API clients a typed error instead of a bare Error' 2026-08-30; 8045234 'fix(md-notebook): retry contended saves without data loss (#4899)' 2026-08-26; 21b180f 'feat(files): file-open context menu with reveal/open + copy-path fallback (#2398)' 2026-09-01; 5e2234e 'fix(dashboard): remember side-panel document scroll across chat-slot switches (#5723)' 2026-08-24. No the initial scan 'merged' claim in the relations list turned out to be an open PR. Corrections to the initial scan's UNRESOLVED refs, now that the issue/PR reference check is populated (it was 0 bytes in the initial scan): #4648 is an ISSUE, state open ('Files app: view PDFs/Office/media in place, search inside documents, and edit markdown') -- it is the feature request this PR implements, carries no code, can never cover anything, and its still-open state corroborates that the capability is unlanded. #4649 is a PR, closed, merged_at '-' => NEVER MERGED (withdrawn), matching the body. #4377 is a PR, merged 2026-08-18T19:02:17Z, landed as 264c7d2 'test(apps): ratchet against decoded proxy-target reconstruction in backends (#4377)', and git merge-base --is-ancestor confirms it is already inside this PR's own merge base fc32364 (2026-08-19), so the body's claim checks out. #7544 is an OPEN PR (the open-PR list, merged column '-'), so it cannot cover anything. Not stacked: git log fc32364..pr/4650 is the single commit d9219c9. Which parts
|
Open PR relationship auditThis is a consolidated, point-in-time code-level audit note. It compares complete merge-base diffs and current/merged code; it does not treat a shared topic as duplication or partial coverage as completion. Relationship findings
No PR, Issue, label, branch, or review state was changed by the relationship-note portion of this audit. |
Head branch was pushed to by a user without write access
d9219c9 to
239cd09
Compare
239cd09 to
d156664
Compare
…-in-document, reading memory, markdown editing The Files app previously rendered markdown, small base64 images, and code fences; every other file type showed a dead 'Binary file' placeholder, folder search could not see inside documents, and downloading a binary file silently saved an empty blob. Backend (server.py + new hardened office_extract module): - GET /raw streams bytes with the real Content-Type (inline only for image/audio/video/PDF; everything else forced to attachment; 64 MB cap, nosniff, SEL-audited). - GET /extract returns structured Office content — docx as ordered heading/paragraph/table blocks, xlsx as per-sheet value grids with shared strings and cached formula values resolved, pptx as positioned shapes with theme-resolved colours, run formatting, embedded image references (?member= streaming, media folders only), and per-slide plain-text fallback lines. office_extract mirrors doc_parser's security posture: defusedxml only, actual-decompressed- size caps per ZIP member, bounded member counts. - /search adds a document pass finding words inside docx/xlsx/pptx/PDF with labelled previews ([slide 3], [Sheet1 r12], [p2]); pdfminer when available with doc_parser's hardened scan as fallback; results cached by (path, mtime, size); time-budgeted; never breaks plain text search. - POST /write saves markdown edits — markdown only, no create, 4 MB cap, atomic replace, SEL-audited, base_mtime returning 409 when the file changed on disk. do_POST reads the body before auth so the proxy HMAC is verified over the exact payload bytes; the signed target stays self.path verbatim per the proxy-target ratchet. - The read-only invariant test (kirodotdev#16) is sharpened rather than removed: no PUT/DELETE/PATCH, POST dispatches only /write, and /write stays markdown-only, no-create, audited. Frontend (website/src/apps/file-explorer): - Viewer type-router: PDFs and images inline via /raw, HTML in a sandboxed live preview with source toggle, CSV/TSV as tables, audio/video players, working downloads for remaining binaries. - Office documents render structurally; PowerPoint as true-aspect slide canvases (background colour, positioned shapes, cqw-scaled run colour/weight/size, embedded images, auto-contrast). - Find-in-document (⌘F when a file is open): CSS Custom Highlight API painting with graceful degradation, match count, keyboard nav. - Reading-position memory per file via localStorage (capped, debounced, retry-based restore for async layout). - Markdown editing with 1.2s debounced auto-save, dirty-flush on file switch, and 409 surfaced as 'file changed on disk'. - All new strings through i18n, translated into every locale catalog. Tests: 46 backend (synthetic in-test OOXML/PDF fixtures — no binary files checked in) and 32 frontend component/api tests; all six existing file-explorer vitest suites stay green.
|
@isaaclam678 Thanks for keeping this alive, and for the self-corrections in the body. We audited it against Only one piece of your original scope has landed: the typed API error. #7074 merged as Everything else is still absent from Please narrow and rebase before review:
Consider splitting the viewers from the markdown write path so the write posture change is off the critical path. Open #7544 edits Posted from the 2026-09-08 open-PR relationship audit (read-only, one auditor per PR); reply here if any of this is wrong. |
|
🤖 Kiro Crew [operator: iamwhatever#241cc860]: Closing this as part of a maintainer-requested stale-PR cleanup. The blocker here is scope, not merit. At +4813/-140 across 34 files this is beyond what can be reviewed and driven to green as a single change, and it has carried Three things need your decisions before it could move: the premise-level First Principles block, the GPT security-policy blockers (the PDF path fallback and the HTML-preview CSP), and the new write posture introduced by The feature itself is still wanted — #4648 stays open. The most direct path is to re-open this as two smaller PRs:
Split that way, the first should be reviewable quickly, and the second gets the focused security discussion it needs. Thank you for the contribution, and for the care that went into it. |
Problem / Motivation
In the Files app, anything that is not text or markdown is a dead end:
FileViewerrenders anEmptyStatewithapps.fileExplorer.fileViewer.binary_file. Opening a.docx,.xlsx,.pptx,.pdf, or an image shows that placeholder, folder search never looks inside those files, markdown is read-only, and the Download button builds its blob fromfileData.contentwithout checkingfileData.binary— so downloading a binary yields a corrupt, effectively empty file.This implements issue #4648.
Why it matters
The app's own manifest sells it as the way to read files on the gateway host, but the file types most work actually arrives in are exactly the ones it cannot show. A user has to leave the dashboard, and the binary download is silently broken rather than merely absent.
What changed (motivation → approach → change)
Viewers. Goal: render real documents in place. The dashboard already has viewers in
website/src/components/FileRenderers.tsx, butgit grep FileRenderers -- website/src/apps/returns zero hits: they are wired to the dashboard's own file surface, not to this app. This addswebsite/src/apps/file-explorer/viewers.tsxfor the app's surface. That is duplication of capability across two surfaces and a fair consolidation target; unifying them is a larger refactor of both call sites and is deliberately not attempted here.Office extraction — corrected rationale. An earlier revision of this description claimed the parsing libraries had been rejected as undeclared optional dependencies. That was false:
openpyxl>=3.1,<4,python-docx>=1,<2andpdfplumber>=0.10,<1are all declared insetup.cfg, and the First Principles review was right to block on it. The actual reason foroffice_extract.pyis output shape, not dependency availability:kiro_crew.doc_parseryields plain text, andapi_file_office_previewis likewise plaintext-only with xlsx explicitly unsupported. A viewer needs structure — docx blocks, an xlsx cell grid, pptx shapes with their real colours, positions, and embedded images. Extendingdoc_parserto return structured blocks was the alternative; it would change a contract other callers depend on, so the structured extractor is separate, with its own caps (MAX_XLSX_*,MAX_PPTX_SLIDES,MAX_ZIP_MEMBERS).Search inside documents.
api_file_searchis filename search for the @-mention picker, and the app's own/searchdispatches only rg/python text engines, so no existing path looks inside a document. Adds_search_documentswith a text cache and time/file caps.Markdown editing.
POST /write, markdown-only, size-capped, atomic (os.replace) under a write lock, SEL-audited, with a base-token conflict guard modelled on md-notebook's.The conflict token is a string. It carries a nanosecond mtime (~1.7×10¹⁸), past the exact-integer range of the double a JSON number parses into (2^53−1). Emitted as a number it rounded in the browser, returned changed, and the exact-match guard then rejected every save with 409 — markdown editing could never have worked in a real browser. It is now an opaque string end to end. The comparison is also a string compare: the previous
int()parse sat insidetry/except ValueError: pass, so a malformed token skipped the guard entirely.Download fix.
/raw?download=1streams real bytes with an RFC 6266Content-Dispositionbuilt by a CRLF-safe helper.Manifest and locales — declared. The manifest's
highlight_*strings described a read-only viewer, so they are rewritten, inen.jsonand all 12 other catalogs. An earlier revision of this description called the locale manifests untouched; that was the second false claim the First Principles review caught.use_case_1andconfiguration_1are retained frommain.localStorage — declared. One thing persists:
MarkdownEditor's recovery stash, which parks typed text when a switch-time flush fails so the next edit can recover it. Per-file scroll memory is deliberately in memory only, adopting the reasoning inwebsite/src/hooks/useScrollMemory.ts— a persisted pixel offset restores into whatever the file contains next time, and a file can be rewritten between visits.Changed in this revision (rebase onto
main)main(the branch was 2,355 commits behind); resolvedFileViewer.tsx,api.tsand 10 locale catalogs.FileExplorerApiErrorin favour ofmain'sApiError/toApiError(landed since inwebsite/src/api/apiError.ts), which has the same status-carrying purpose.main's sharedFilePathMenu(revealOrOpen,useRevealLabel,useCanOpenFile) and deleted this PR's ownrevealFile, removing twoalert()calls and four now-dead i18n keys.useScrollMemory→useFileScrollMemory:mainnow has a hook of that name for side-panel tabs, and two same-named hooks with different identities is a trap.pdfplumber); the HTML preview document now carries adefault-src 'none'CSP, becausesandbox=""blocks scripts but not passive subresource loads; and the symlink-escape test no longer writes outside its owntmp_path.Tests
test/test_file_explorer_viewers.py,test/test_file_explorer_proxy_auth.py,test/test_file_explorer_app.py— 172 passed, 1 skipped. New this revision: a tripwire asserting PDF search never reaches a path-based reader; the conflict token is emitted as a string and round-trips; an unmatched token returns 409 instead of failing open.website/src/test/fileExplorerViewers.test.tsx+ the api/page coverage suites — 123 passed, including four asserting the preview CSP lands inside the head, before the head's content, without disturbing the doctype, and opens nothing but inline styles anddata:images.npx tsc --noEmitclean;eslintclean on the touched tree;flake8,isort,mypyclean on the touched backend.Manual verification
Backend endpoints, extraction, the write guard and the viewers are covered by the suites above. Still outstanding: this has not been re-exercised in a running dashboard since the rebase — the merge with
main'sFilePathMenuchanged the viewer's overflow menu, so the Open/Reveal items and the CSP'd HTML preview want a click-through before merge. I would rather say that than imply verification I have not done.Screenshots / video
Outstanding, and it currently blocks two checks. This is a user-visible UI change, so the template requires media and I have not captured it. Being explicit rather than omitting it silently: the surfaces needing shots are the office/pdf/image/media viewers, the find-in-document bar, markdown edit mode and its status states, the Preview/Source and Table/Source toggles, xlsx sheet tabs, and the pptx slide canvas — each in light and dark. The dark-theme find highlight needs one specifically, since
::highlighthardcodesrgba(255,213,79,.5)with forced#1a1a1atext.The repo's own
scripts/capture-*.mjsharness is the right way to produce these (real built SPA,/api/**stubbed from fixtures). I could not run it here:website/distwill not build in this worktree becausetsc -bfails on missing storybook dev-dependencies and vite then fails on an absent@excalidraw/excalidraw/dist/prod/fonts— both localnode_modulesgaps, unrelated to this diff (tsc --noEmitand the test suites pass). Repairing that install is the next step before this section can be filled.On the edit ↔ view transition (lens 13)
Raised by the UX review, and answered here rather than left implicit. The Edit toggle deliberately swaps the rendered document for a plain textarea instead of morphing one element, because the two states are not the same object presented differently: one is rendered output, the other is the source that produced it. Every markdown editor in this class (the dashboard's own md-notebook among them) switches panes rather than animating glyphs into their source, and a crossfade between "rendered heading" and "
## heading" would suggest a continuity that does not exist.That is the stated reason the rule asks for; it is not a claim that the recording is unnecessary. The recording lens 13 requires is part of the outstanding media above.