feat(fetch): add --live flag to bypass the cache - #52
Conversation
The API already supports live=true on /v1/fetch; expose it in the CLI. The flag threads through DaemonRequest (serde default keeps old/new client-daemon pairs interoperable) and the direct HTTP fallback path. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
PR Summary by QodoAdd --live flag to fetch to bypass cache
AI Description
Diagram
High-Level Assessment
Files changed (5)
|
Code Review by Qodo
1. Old daemon ignores --live
|
| /// Fetch only: request live content instead of the cached copy. | ||
| #[serde(default)] | ||
| pub live: bool, |
There was a problem hiding this comment.
1. Old daemon ignores --live 🐞 Bug ≡ Correctness
The CLI reuses any already-running daemon without checking capabilities, so after an upgrade an older daemon can keep serving fetch requests but cannot forward live=true, causing `fetch --live to return cached content until the daemon restarts. Because execute()` returns immediately on successful daemon responses, there is no opportunity to fall back to the direct HTTP path for --live freshness semantics.
Agent Prompt
### Issue description
`fetch --live` depends on daemon support to append `live=true`, but the CLI will reuse an already-running daemon process without any version/feature negotiation. If the user upgrades the CLI while an older daemon is still running, the request can succeed yet not be “live” (cached content returned) until the daemon exits/restarts.
### Issue Context
- The CLI tries the daemon first and returns the daemon’s successful response immediately.
- The daemon only appends the `live=true` query param when it understands/implements `req.live`.
- There’s explicit precedent in the codebase that older daemons can remain running and behave differently (see comments in `kill_daemon`).
### Fix Focus Areas
- src/commands/search.rs[96-170]
- src/commands/search.rs[388-420]
- src/daemon.rs[383-420]
- src/daemon.rs[260-314]
- src/daemon.rs[316-339]
### Suggested fix
Choose one (or combine):
1) **Bypass daemon when `req.live == true`**: in `execute()`, skip the daemon fast-path for fetch-live so the direct HTTP request always includes `live=true`.
2) **Force daemon refresh on `--live`**: if `req.live` is true and a daemon is running, call `kill_daemon()` then `ensure_daemon()` to guarantee a daemon with live support.
3) **Add a capability handshake**: extend `ping` to return a version/feature set; when `--live` is requested, only use daemon if it advertises support, otherwise fall back to direct HTTP.
(Option 1 is the simplest/least invasive and makes `--live` semantics reliable immediately after an upgrade.)
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
Summary
--livetokeenable fetch— requests live page content instead of the cached copy, mapping to thelive=truequery param the API (and the MCPfetch_page_contenttool) already supports.livethroughDaemonRequestwith#[serde(default)]so old/new client-daemon pairs stay interoperable (same skew precedent as the fetch POST→GET change in Fix fetch command using POST instead of GET #15), and through the direct HTTP fallback path.after_helpexamples, README, and addtest_fetch_liveto the e2e suite.Testing
cargo fmt/cargo clippy --all-targets -- -D warnings/cargo testall clean.live=trueagainst the real API (public endpoint) with curl before wiring.fetch --livesucceeds both through a running daemon (isolatedKEENABLE_HOME, socket confirmed) and via the direct path.pytest tests/e2e/test_fetch.py— 8/8 pass, including the newtest_fetch_live.Note: nightly e2e CI tests the released binary, so
test_fetch_livewill fail there until the next release is tagged.🤖 Generated with Claude Code