feat(server): wire slide.setImageModel + revertToLastGenerated + resolveContext + bg.extractTheme #53
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "development_mik"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Bucket B of #51 — 4 of 15 undispatched OpenRPC methods. Sibling of PR #52 (bucket A — wizard.* + deckjobs.*).
Summary
Adds 4 dispatch arms in
crates/hero_slides_server/src/rpc.rsplus the backing handler functions. Each method is advertised inopenrpc.jsonbut had nomatcharm, so calls returned-32000 "Method not found".slide.setImageModelhero_slides_lib::slide_set_image_modelmodelclears the override and reverts to deck default. JS dashboard's pro-toggle (onSlideImageModelChange,dashboard.js:2352) was hitting -32000.slide.revertToLastGeneratedslide_list_versions+slide_restore_version+slide_get_contenthero_slides_rhai/src/slide_module.rs:421. Returns{restored_version, content}.slide.resolveContexthero_slides_lib::resolve_contextbyte_countinstead of rawbytes(Vec would bloat the wire by megabytes per resolve). MapsResolvedContext→ JSON manually sinceResolvedContextEntryisn'tSerialize. Includes the deterministicfingerprint.bg.extractThemeextract_theme_from_image/extract_theme_from_pdf{data, mime_type}(browser upload),{folder, file}(under<deck>/content/background/<folder>/<file>), or{file}(root-level) — auto-detects PDF vs image by mime / extension, runs throughai_util::ai_client()(usesOPENROUTER_API_KEYfrom hero_proc secrets), and persists the result totheme.mdviadeck_save_theme.Verification
cargo check -p hero_slides_serverclean (no new warnings — 11 pre-existing warnings are bucket-Cparam_*helpers from PR #50).scripts/smoke_openrpc.pyMETHOD_MISSING expected to drop from 15 → 5 (only bucket C left:slide.setLink,slide.clearLink,slide.getStaleness,deck.staleness,folder.pick).slide.setImageModel) stops failing silently.Why these 4, not all 5 originally in bucket B
The original sizing folded
slide.clearLinkinto bucket B because the lib helper exists (deck_slide_link_clearreturnsOk(())). On second read, that helper is a no-op stub — wiring it up would let the dispatcher succeed but nothing would actually clear, hiding the missing implementation. Sinceslide.setLinkis also a stub (Err("slide linking not yet implemented")) and the two methods are paired, both move to the bucket-C follow-up issue together with the link-persistence design call.Out of scope
Bucket C (5 methods, all blocked on missing lib code or a missing crate dep) — fresh issue at session end.
Signed-off-by: mik-tf
Adds 4 dispatch arms in `crates/hero_slides_server/src/rpc.rs` and the backing handler functions. Each method is advertised in `openrpc.json` but had no `match` arm, so calls returned -32000 "Method not found". | Method | Handler | Notes | |---|---|---| | `slide.setImageModel` | `slide_set_image_model()` | Per-slide image-model override; empty/missing model clears it back to deck default. JS dashboard's pro-toggle (`onSlideImageModelChange`, dashboard.js:2352) was hitting -32000. | | `slide.revertToLastGenerated` | composes `slide_list_versions` + `slide_restore_version` + `slide_get_content` | Mirrors the existing Rhai binding at hero_slides_rhai/src/slide_module.rs:421. | | `slide.resolveContext` | `resolve_context()` | Returns entries with `byte_count` instead of raw `bytes` (Vec<u8> would bloat the wire by megabytes per resolve). Maps `ResolvedContext` → JSON manually since the entry type isn't `Serialize`. | | `bg.extractTheme` | `extract_theme_from_image()` / `extract_theme_from_pdf()` | Three input shapes — `{data, mime_type}` (browser upload), `{folder, file}`, or `{file}` — auto-detects PDF vs image by mime, runs through `ai_util::ai_client()`, persists result to `theme.md`. | Bucket B of #51 (4 of 15 undispatched methods). Bucket A (wizard.* + deckjobs.*) landed in PR #52 (commit1c4391e). Bucket C (slide.setLink / slide.clearLink / slide.getStaleness / deck.staleness / folder.pick — all blocked on missing lib code or a missing crate dep) gets a fresh issue at session end. Verified `cargo check -p hero_slides_server` clean (no new warnings — the 11 pre-existing warnings are bucket-C param helpers from PR #50). Signed-off-by: mik-tf