2026-07-13-wiki-upload-lifecycle.md 3 KB

Wiki Upload Lifecycle Implementation Plan

For agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (- [ ]) syntax for tracking.

Goal: Make Wiki file upload return as soon as the file is stored, and move parsing/preview generation into separate states and actions.

Architecture: Keep upload, ingest, and preview as separate lifecycle concerns. Backend exposes a single Wiki file status contract and explicit preview readiness; frontend treats upload queue status separately from database ingest status.

Tech Stack: FastAPI, SQLAlchemy async sessions, Next.js React client, Python unittest/static tests.

Global Constraints

  • Answer and UI-facing behavior should use Chinese wording where existing UI does.
  • Do not run PDF VLM parsing from upload endpoints.
  • Do not generate PPT/PPTX preview PDFs from the GET preview endpoint.
  • Keep changes scoped to Wiki file upload/preview plus minimal shared status typing.

Task 1: Backend Upload Contract

Files:

  • Modify: src/api/routes/files.py
  • Test: tests/api/test_upload_word_count_static.py

Interfaces:

  • Produces: /upload/{file_id} returns after disk save with status: "success" and file status Pending.

  • Write a failing test proving upload_file_chunk does not call extract_text_from_file.

  • Run the test and verify it fails on current code.

  • Remove upload-time text extraction and keep word_count at 0.

  • Run the test and verify it passes.

Task 2: PPT Preview Readiness

Files:

  • Modify: src/api/routes/files.py
  • Modify: src/tools/document_parser.py
  • Test: tests/api/test_files_preview.py

Interfaces:

  • Produces: GET /files/view/{file_id} returns an existing PPT/PPTX preview PDF only when cache is ready.
  • Produces: Missing PPT/PPTX preview returns HTTP 202 with JSON detail instead of blocking conversion.

  • Write a failing test proving missing PPT cache returns a non-blocking status and does not call conversion.

  • Run the test and verify it fails on current code.

  • Add cache lookup helper and change view_file to avoid conversion.

  • Run the test and verify it passes.

Task 3: Frontend Preview and Upload UX

Files:

  • Modify: frontend/src/app/page.tsx
  • Test: tests/frontend/test_wiki_upload_preview_static.py

Interfaces:

  • Produces: upload modal uses saved/upload failed wording for disk save.
  • Produces: PPT/PPTX preview uses controlled fetch state and user-facing message when preview PDF is not ready.

  • Write static tests for upload wording and iframe gating.

  • Run the tests and verify they fail on current code.

  • Update frontend state handling and preview rendering.

  • Run the tests and verify they pass.

Task 4: Verification

Files:

  • Test: targeted backend/frontend static tests.

  • Run all targeted tests.

  • Run a broader test subset if imports are healthy.

  • Report exact commands and outcomes.