Add generate_slide RPC with AI and context UI #1
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Current State
deck_read_background, file management) but no UI for selecting backgrounds
when creating/generating slides
dictation and AI-assisted editing
Goals
1. Background Context Selection (UI + RPC)
content
selected backgrounds
2. Theme Dictation & AI Assistance
editing):
3. Unified AI Editing Pattern
Implementation Spec for Issue #1
Objective
Extend hero_slides2 with three sets of features that apply the same AI editing pattern (Fix / Rewrite / Generate / Dictation) consistently across the three main editable artefacts — Instructions, Theme, and Slide Content:
slide.generateContentand the Create Slide modal. No new backend code is required for Goal 1.Requirements
deck.fixThemeRPC: grammar/clarity fixes on theme content via AI, returns{ content }.deck.rewriteThemeRPC: restructure/improve theme via AI, returns{ content }.deck.generateThemeRPC: AI-generate a theme from a description, returns{ content }.{ content, deck_path }(generateTheme accepts{ description, deck_path }).system_fix_theme.md,system_rewrite_theme.md,system_generate_theme.md.prompts.rsALL_TEMPLATESand seeded on disk.voice.transcribe, appends to the theme textarea.AiClient::from_env().with_tracking()pattern withModel::Gemini3ProPreview.Files to Modify / Create
crates/hero_slides_lib/src/prompts/system_fix_theme.mdcrates/hero_slides_lib/src/prompts/system_rewrite_theme.mdcrates/hero_slides_lib/src/prompts/system_generate_theme.mdcrates/hero_slides_lib/src/prompts.rsALL_TEMPLATEScrates/hero_slides_server/src/agent.rshandle_fix_theme,handle_rewrite_theme,handle_generate_themehandlerscrates/hero_slides_server/src/rpc.rsdeck.fixTheme,deck.rewriteTheme,deck.generateThemedispatch armscrates/hero_slides_ui/templates/index.htmlcrates/hero_slides_ui/static/js/dashboard.jsfixTheme(),rewriteTheme(),generateTheme(), voice recording helpersImplementation Plan
Step 1 — Create the three theme system-prompt template files
Files:
prompts/system_fix_theme.md,prompts/system_rewrite_theme.md,prompts/system_generate_theme.mdDependencies: none — can run in parallel with nothing
Step 2 — Register new templates in
prompts.rsFiles:
crates/hero_slides_lib/src/prompts.rsDependencies: Step 1
Step 3 — Add RPC handler functions in
agent.rsFiles:
crates/hero_slides_server/src/agent.rsDependencies: Step 2
Step 4 — Wire new methods into the RPC dispatcher
Files:
crates/hero_slides_server/src/rpc.rsDependencies: Step 3
Step 5 — Update the theme editor HTML overlay
Files:
crates/hero_slides_ui/templates/index.htmlDependencies: none (parallel with Step 6)
Step 6 — Add theme AI and dictation functions to
dashboard.jsFiles:
crates/hero_slides_ui/static/js/dashboard.jsDependencies: none (parallel with Step 5)
Acceptance Criteria
deck.fixTheme,deck.rewriteTheme,deck.generateThemeRPCs exist and return{ content }.include_str!inprompts.rs.seed_prompts_dirwrites the three new templates.deck.generateTheme, replaces textarea content.cargo build --workspacesucceeds with no errors.Notes
agent.rsexactly:AiClient::from_env().with_tracking(),with_context(deck_name, deck_path),spawn_blocking, provider guard,println!debug blocks,json!({ "content": result }).Model::Gemini3ProPreview.deck.generateThemeacceptsdescription(notcontent) as the user is describing what they want, not editing existing content.deck.generateAsyncis already fully implemented — no new wiring needed for Goal 1.Implementation Spec for Issue #1 (updated)
Objective
Extend hero_slides2 with two sets of features:
deck.runAgentso the AI Agent has access to background files when running on a deck (currently missing; the Instruct panel and Create Slide modal already work correctly).The background panel upload/folder/PDF-extraction UI is complete. The Create Slide modal and the Instruct panel (single-slide) both have working background selection. The only missing piece for Goal 1 is the Agent runner.
Requirements
Goal 1 — Background in Agent Flow
deck.runAgentRPC must accept an optionalbackground_foldersarray parameter.background_foldersis non-empty,handle_run_agentmust callread_background_content()and inject the result into the agent prompt under a## Background Contextsection.agent_build_deck.mdprompt template must include a{{background_context}}placeholder.runAgentOnDeck()indashboard.jsmust pass the selected background folders to the RPC.Goal 2 — Theme AI Assistance
deck.fixThemeRPC: grammar/clarity fixes on theme content via AI, returns{ content }.deck.rewriteThemeRPC: restructure/improve theme via AI, returns{ content }.deck.generateThemeRPC: AI-generate theme from a description ({ description, deck_path }), returns{ content }.system_fix_theme.md,system_rewrite_theme.md,system_generate_theme.md.prompts.rsALL_TEMPLATESand seeded on disk.voice.transcribe, appends to the theme textarea.AiClient::from_env().with_tracking()withModel::Gemini3ProPreview.Files to Modify / Create
crates/hero_slides_lib/src/prompts/agent_build_deck.md{{background_context}}placeholdercrates/hero_slides_lib/src/prompts/system_fix_theme.mdcrates/hero_slides_lib/src/prompts/system_rewrite_theme.mdcrates/hero_slides_lib/src/prompts/system_generate_theme.mdcrates/hero_slides_lib/src/prompts.rsALL_TEMPLATEScrates/hero_slides_server/src/agent.rsbackground_foldersintohandle_run_agent; addhandle_fix_theme,handle_rewrite_theme,handle_generate_themecrates/hero_slides_server/src/rpc.rsbackground_foldersextraction todeck.runAgentarm; register three newdeck.*Themearmscrates/hero_slides_ui/templates/index.htmlcrates/hero_slides_ui/static/js/dashboard.jsbackground_foldersfrom Instructions panel inrunAgentOnDeck(); addfixTheme(),rewriteTheme(),generateTheme(), theme voice helpersImplementation Plan
Step 1 — Create the three theme prompt templates
Files:
prompts/system_fix_theme.md,prompts/system_rewrite_theme.md,prompts/system_generate_theme.mdDependencies: none — parallel-safe
Step 2 — Register new theme templates in
prompts.rsFiles:
crates/hero_slides_lib/src/prompts.rsDependencies: Step 1
Step 3 — Update
agent_build_deck.mdwith background_context placeholderFiles:
crates/hero_slides_lib/src/prompts/agent_build_deck.mdDependencies: none — parallel-safe with Steps 1–2
Step 4 — Wire background_folders into
handle_run_agentinagent.rs; add three theme handlersFiles:
crates/hero_slides_server/src/agent.rsDependencies: Steps 2 and 3
Step 5 — Register new RPC dispatch arms in
rpc.rsFiles:
crates/hero_slides_server/src/rpc.rsDependencies: Step 4
Step 6 — Update Instructions panel HTML + theme editor HTML
Files:
crates/hero_slides_ui/templates/index.htmlDependencies: none (parallel with Step 7)
Step 7 — Update
dashboard.js: background selection in agent runner + theme AI functionsFiles:
crates/hero_slides_ui/static/js/dashboard.jsDependencies: none (parallel with Step 6)
Acceptance Criteria
agent_build_deck.mdrenders background context under a## Background Contextsection when folders are selected.deck.fixTheme,deck.rewriteTheme,deck.generateThemeRPCs exist and return{ content }.include_str!inprompts.rs.deck.generateTheme, replaces textarea.cargo build --workspacesucceeds with no errors.Notes
handle_run_agentis inagent.rsaround line 129. Currently it reads instructions.md and callsbuild_prompt()with only{{instructions}}. The fix is to also callread_background_content()for the selected folders and pass the result as a second template variable.runAgentOnDeck()is indashboard.jsaround line 3477. It currently callsrpc('deck.runAgent', { deck_path: instrDeckPath }). It needs to also passbackground_folders.instruct-bg-list/loadInstructBgFolders()/renderInstructBgList()(dashboard.js lines 3311–3359).AiClient::from_env().with_tracking(),with_context(deck_name, deck_path),spawn_blocking, provider guard,println!debug blocks.deck.generateThemeacceptsdescription(notcontent) as the input field name.Test Results
Build: pass
Tests: 60 total, 59 passed, 0 failed (1 ignored)
Details
hero_slides_libunit tests: 42 passed, 0 failedhero_slides_libintegration tests: 12 passed, 0 failed, 1 ignored (test_generate_single_slide_ai— skipped, likely requires live AI credentials)hero_slides_libdoc tests: 2 passed, 0 failedhero_slides_rhaidoc tests: 1 passed, 0 failedhero_slides,hero_slides_rhai,hero_slides_sdk,hero_slides_server,hero_slides_ui: 0 tests each (no test suite defined)One warning: unused variable
specincrates/hero_slides_examples/examples/basic_usage.rs:18.Implementation Summary
Changes Made
Goal 1 — Background Context in Agent Flow
crates/hero_slides_lib/src/prompts/agent_build_deck.md— Added{{background_context}}placeholder between the instructions block and the "Your Tasks" heading.crates/hero_slides_server/src/agent.rs(handle_deck_run_agent) — Extractsbackground_foldersfrom RPC params, callsread_background_content(), and injects the result under a## Background Contextsection into the agent prompt.crates/hero_slides_ui/templates/index.html— Added background checkbox tree (agent-bg-list) to the Instructions panel overlay, hidden when no backgrounds exist.crates/hero_slides_ui/static/js/dashboard.js— AddedloadAgentBgFolders(),renderAgentBgList(),toggleAgentBgFolder()(mirrors the Instruct panel pattern);runAgentOnDeck()now passesbackground_folders: selectedAgentBgFolders.Goal 2 — Theme AI Assistance
crates/hero_slides_lib/src/prompts/system_fix_theme.md— New system prompt for grammar/clarity fixes on theme content.crates/hero_slides_lib/src/prompts/system_rewrite_theme.md— New system prompt for structured theme rewrite with explicit sections.crates/hero_slides_lib/src/prompts/system_generate_theme.md— New system prompt for generating a complete theme from a description.crates/hero_slides_lib/src/prompts.rs— Registered all three templates inALL_TEMPLATESwithinclude_str!constants;seed_prompts_dirwrites them automatically.crates/hero_slides_server/src/agent.rs— Addedhandle_fix_theme,handle_rewrite_theme,handle_generate_themehandlers following the existing AI handler pattern (AiClient::from_env().with_tracking(),Model::Gemini3ProPreview,spawn_blocking).crates/hero_slides_server/src/rpc.rs— Registereddeck.fixTheme,deck.rewriteTheme,deck.generateThemedispatch arms.crates/hero_slides_ui/templates/index.html— Added Fix, Rewrite, Generate, and Mic buttons to the theme editor overlay; addedtheme-voice-statusspan; addedgenerateThemeModal.crates/hero_slides_ui/static/js/dashboard.js— AddedfixTheme(),rewriteTheme(),openGenerateThemeModal(),doGenerateTheme(),startThemeRecording(),stopThemeRecording(),sendThemeAudioToServer().Test Results