Skip to content

fix: auto-download URL-sourced documents on view/crop with notice and progress - #177

Merged
yuanwen-tian merged 3 commits into
mainfrom
fix/auto-download-url-sources
Aug 6, 2026
Merged

fix: auto-download URL-sourced documents on view/crop with notice and progress#177
yuanwen-tian merged 3 commits into
mainfrom
fix/auto-download-url-sources

Conversation

@yuanwen-tian

Copy link
Copy Markdown
Contributor

Why

QA follow-up on the v1.0.2 "[STG-PROD][ADE][ADE-CLI] doc preview doesn't load after parsing with document URL" ticket: the --download flag added in #169's follow-up fixed the preview, but only opt-in — a plain ade view <id> on a URL-sourced parse still reported pages_embedded: 0, and a user who didn't know the flag saw an empty preview. Decision: the download becomes the default, said out loud rather than silent.

What changes

  • ade view auto-fetches: a URL-sourced item with no attached copy downloads on first view — a stderr notice explains why and names the opt-out, and the body streams behind the shared progress line (percent + elapsed rewriting in place on a tty, one line per 10% piped, silent under --json):

    note: job item 01fd4532c57f9b28 was parsed from a URL and no local copy is attached — downloading it so page imagery can render (skip with --no-download)
    downloading document.pdf 45% · 1s
    Viewer for job item 01fd4532c57f9b28 (parse) -> ~/.ade/jobs/…/view.html (built)
      download: fetched document.pdf (662 bytes) into job item 01fd4532c57f9b28
    
  • Failure degrades, never breaks: pre-signed URLs expire, so a failed auto-fetch logs the error (downloaded: false + download_error in the payload) and the viewer still builds with the honest empty-preview note — a view that worked yesterday never starts exiting non-zero. Explicit --download keeps the strict contract: failed fetch and non-URL items stay errors.

  • --no-download suppresses the fetch on both commands; previews then stay empty with the existing remediation note (reworded as a retry action, since the flag no longer needs discovering).

  • ade crop gets the same flow: detect → notice → fetch before rendering. A failed fetch is the crop's failure (no empty-imagery fallback exists), exactly as the no-copy state already was.

  • Contract restated in attach.py: a URL fetch is never silent — either asked for at parse time (--keep-copy) or announced before it starts. README, --keep-copy/view/crop help text, payload reference, and remediation hints updated to match.

Verification

  • 701 tests pass (new coverage: auto-fetch success/failure/skip for view, stderr notice + progress assertions, crop auto-fetch success/failure, --download strictness on both commands); ruff and ty check src clean; help reference regenerated.
  • Verified end-to-end against a seeded store with a throttled localhost server under a real pty: notice renders, progress ticks 0→100%, previews embed in the same run, second run fetches nothing.

🤖 Generated with Claude Code

… progress

A plain `ade view <id>` on a URL-sourced parse reported pages_embedded: 0
unless the user knew to add --download — an empty preview was a worse
surprise than an implicit fetch (QA follow-up on the v1.0.2 doc-preview
ticket). `view` and `crop` now detect a URL-sourced item with no attached
copy and fetch it by default: a stderr notice says why the network is
being touched and how to skip it (--no-download), and the download
streams behind the guarantee progress line (percent + elapsed on a tty,
decade lines piped, silent under --json).

The fetch is never load-bearing unless asked: in auto mode an expired
pre-signed URL degrades to the existing empty-preview note (payload
records downloaded: false + download_error) so yesterday's working view
never starts exiting non-zero; explicit --download keeps the strict
erroring contract. crop hard-fails on a failed fetch as the no-copy
state always did — a crop has no empty-imagery fallback.

attach.py's consent contract is restated: a URL fetch is either asked
for at parse time (--keep-copy) or said out loud before it starts.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

Copilot AI 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.

Pull request overview

Makes URL-sourced documents download automatically when first viewed or cropped, with notices, progress, opt-out behavior, and graceful view failures.

Changes:

  • Adds shared announced download and progress handling.
  • Integrates automatic fetching into view and crop.
  • Updates tests, help, and user documentation.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/ade_cli/attach.py Adds shared download notice and progress reporting.
src/ade_cli/view.py Enables automatic fetching with graceful failure handling.
src/ade_cli/crop.py Enables automatic fetching before cropping.
src/ade_cli/parse.py Updates --keep-copy guidance.
src/ade_cli/help.py Updates view payload and artifact documentation.
tests/test_view.py Covers view download modes and failures.
tests/test_crop.py Covers crop download modes and failures.
tests/test_serve.py Prevents unrelated server tests from auto-fetching.
README.md Documents automatic download behavior.
docs/reference/help.json Regenerates command help reference.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ade_cli/crop.py
Comment thread src/ade_cli/help.py Outdated
yuanwen-tian and others added 2 commits August 6, 2026 12:11
…eview)

The crop payload reference was missing the new `downloaded` member, and
view's description implied `false` covers the already-attached case —
auto mode omits the key entirely there; false means a failed automatic
fetch or explicit --download finding an existing copy.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@yuanwen-tian
yuanwen-tian merged commit 2597bb1 into main Aug 6, 2026
1 check passed
@yuanwen-tian
yuanwen-tian deleted the fix/auto-download-url-sources branch August 6, 2026 07:07
yuanwen-tian added a commit that referenced this pull request Aug 6, 2026
Bumps `pyproject.toml` and `uv.lock` to 1.0.4 (minimal two-line diff;
the lockfile edit is validated by `uv sync --locked`, full suite green,
`ade version` reports 1.0.4).

## ⚠️ Merge order

**Merge #177 first, then this PR** — v1.0.4 is intended to include:

- #177 — fix: auto-download URL-sourced documents on view/crop with
notice and progress
- #176 — feat: live production integration suite gates the release
(already on main)

Once both are in, cut the release via **Actions → Release → "Run
workflow"** on `main`. The pipeline will run the live integration suite
(macOS + Windows, against production) before tagging `v1.0.4` — first
exercised green on run
[31072130505](https://github.com/landing-ai/ade-cli/actions/runs/31072130505).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants