Add generate_slide RPC with AI and context UI #1

Closed
opened 2026-04-13 07:29:19 +00:00 by casper-stevens · 4 comments
Member

Current State

  • RPC Methods: Basic slide/deck management exists (generate, pdf, list, etc.)
  • AI Capabilities: herolib_ai is integrated for instruction fixing/rewriting
  • Background Feature: Partially implemented in server (deck_list_background,
    deck_read_background, file management) but no UI for selecting backgrounds
    when creating/generating slides
  • Theme Editing: deck.getTheme / deck.saveTheme exist but lack UI for voice
    dictation and AI-assisted editing

Goals

1. Background Context Selection (UI + RPC)

  • Add UI form controls to select background folders when generating slide
    content
  • Wire up background folder selection in the slide creation workflow
  • Ensure slide.generateContent and slide.generateContentAsync accept and use
    selected backgrounds
  • Display available background context to AI when generating slides

2. Theme Dictation & AI Assistance

  • Add voice input (dictation) UI for editing deck theme
  • Implement three RPC methods for theme editing (mirroring instruction
    editing):
    • deck.fixTheme — grammatical/clarity fixes via AI
    • deck.rewriteTheme — restructure/improve via AI
    • deck.generateTheme — AI-generate theme from description
  • Add UI buttons/workflows for: Fix, Rewrite, Generate, Voice Dictation
  • Use herolib_ai with appropriate system prompts

3. Unified AI Editing Pattern

  • Apply consistent pattern across Instructions, Theme, and Slide Content:
    • Fix — correct grammar, clarity, formatting
    • Rewrite — restructure, improve flow, enhance detail
    • Generate — create from scratch or substantial revision
    • Dictation — voice input with auto-fix/cleanup
  • Ensure all use the same herolib_ai client and tracking
# Current State - RPC Methods: Basic slide/deck management exists (generate, pdf, list, etc.) - AI Capabilities: herolib_ai is integrated for instruction fixing/rewriting - Background Feature: Partially implemented in server (deck_list_background, deck_read_background, file management) but no UI for selecting backgrounds when creating/generating slides - Theme Editing: deck.getTheme / deck.saveTheme exist but lack UI for voice dictation and AI-assisted editing # Goals ## 1. Background Context Selection (UI + RPC) - Add UI form controls to select background folders when generating slide content - Wire up background folder selection in the slide creation workflow - Ensure slide.generateContent and slide.generateContentAsync accept and use selected backgrounds - Display available background context to AI when generating slides ## 2. Theme Dictation & AI Assistance - Add voice input (dictation) UI for editing deck theme - Implement three RPC methods for theme editing (mirroring instruction editing): - deck.fixTheme — grammatical/clarity fixes via AI - deck.rewriteTheme — restructure/improve via AI - deck.generateTheme — AI-generate theme from description - Add UI buttons/workflows for: Fix, Rewrite, Generate, Voice Dictation - Use herolib_ai with appropriate system prompts ## 3. Unified AI Editing Pattern - Apply consistent pattern across Instructions, Theme, and Slide Content: - Fix — correct grammar, clarity, formatting - Rewrite — restructure, improve flow, enhance detail - Generate — create from scratch or substantial revision - Dictation — voice input with auto-fix/cleanup - Ensure all use the same herolib_ai client and tracking
Author
Member

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:

  1. Background Context Selection — the existing background folder infrastructure is already fully wired into slide.generateContent and the Create Slide modal. No new backend code is required for Goal 1.
  2. Theme Dictation and AI Assistance — add Fix, Rewrite, and Generate RPC methods for the theme editor, plus a voice dictation button mirroring the instructions editor pattern.
  3. Unified AI Editing Pattern — ensure Instructions, Theme, and Slide Content all share Fix / Rewrite / Generate / Dictation.

Requirements

  • deck.fixTheme RPC: grammar/clarity fixes on theme content via AI, returns { content }.
  • deck.rewriteTheme RPC: restructure/improve theme via AI, returns { content }.
  • deck.generateTheme RPC: AI-generate a theme from a description, returns { content }.
  • All three theme RPCs accept { content, deck_path } (generateTheme accepts { description, deck_path }).
  • Three new system-prompt templates: system_fix_theme.md, system_rewrite_theme.md, system_generate_theme.md.
  • Templates registered in prompts.rs ALL_TEMPLATES and seeded on disk.
  • Theme editor overlay gains: Fix, Rewrite, Generate, and Mic/Dictation buttons.
  • Voice dictation in theme editor routes audio through voice.transcribe, appends to the theme textarea.
  • All AI calls follow the existing AiClient::from_env().with_tracking() pattern with Model::Gemini3ProPreview.

Files to Modify / Create

File Action Description
crates/hero_slides_lib/src/prompts/system_fix_theme.md Create System prompt for Fix Theme AI operation
crates/hero_slides_lib/src/prompts/system_rewrite_theme.md Create System prompt for Rewrite Theme AI operation
crates/hero_slides_lib/src/prompts/system_generate_theme.md Create System prompt for Generate Theme AI operation
crates/hero_slides_lib/src/prompts.rs Modify Register the three new templates in ALL_TEMPLATES
crates/hero_slides_server/src/agent.rs Modify Add handle_fix_theme, handle_rewrite_theme, handle_generate_theme handlers
crates/hero_slides_server/src/rpc.rs Modify Register deck.fixTheme, deck.rewriteTheme, deck.generateTheme dispatch arms
crates/hero_slides_ui/templates/index.html Modify Add Fix/Rewrite/Generate/Mic buttons to theme editor overlay
crates/hero_slides_ui/static/js/dashboard.js Modify Add fixTheme(), rewriteTheme(), generateTheme(), voice recording helpers

Implementation 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.md
Dependencies: none — can run in parallel with nothing

Step 2 — Register new templates in prompts.rs

Files: crates/hero_slides_lib/src/prompts.rs
Dependencies: Step 1

Step 3 — Add RPC handler functions in agent.rs

Files: crates/hero_slides_server/src/agent.rs
Dependencies: Step 2

Step 4 — Wire new methods into the RPC dispatcher

Files: crates/hero_slides_server/src/rpc.rs
Dependencies: Step 3

Step 5 — Update the theme editor HTML overlay

Files: crates/hero_slides_ui/templates/index.html
Dependencies: none (parallel with Step 6)

Step 6 — Add theme AI and dictation functions to dashboard.js

Files: crates/hero_slides_ui/static/js/dashboard.js
Dependencies: none (parallel with Step 5)


Acceptance Criteria

  • deck.fixTheme, deck.rewriteTheme, deck.generateTheme RPCs exist and return { content }.
  • Three new prompt templates exist on disk and are embedded via include_str! in prompts.rs.
  • seed_prompts_dir writes the three new templates.
  • Theme editor overlay shows Fix, Rewrite, Generate, and Mic buttons.
  • Fix and Rewrite update the textarea, mark the editor dirty, and show a toast.
  • Generate opens a modal, takes a description, calls deck.generateTheme, replaces textarea content.
  • Mic button starts audio recording; transcription is appended to the theme textarea.
  • All AI handlers guard against empty providers and return a clear error.
  • cargo build --workspace succeeds with no errors.

Notes

  • Follow the existing handler pattern in agent.rs exactly: AiClient::from_env().with_tracking(), with_context(deck_name, deck_path), spawn_blocking, provider guard, println! debug blocks, json!({ "content": result }).
  • All three theme operations use Model::Gemini3ProPreview.
  • deck.generateTheme accepts description (not content) as the user is describing what they want, not editing existing content.
  • Background context in deck.generateAsync is already fully implemented — no new wiring needed for Goal 1.
## 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: 1. **Background Context Selection** — the existing background folder infrastructure is already fully wired into `slide.generateContent` and the Create Slide modal. No new backend code is required for Goal 1. 2. **Theme Dictation and AI Assistance** — add Fix, Rewrite, and Generate RPC methods for the theme editor, plus a voice dictation button mirroring the instructions editor pattern. 3. **Unified AI Editing Pattern** — ensure Instructions, Theme, and Slide Content all share Fix / Rewrite / Generate / Dictation. --- ### Requirements - `deck.fixTheme` RPC: grammar/clarity fixes on theme content via AI, returns `{ content }`. - `deck.rewriteTheme` RPC: restructure/improve theme via AI, returns `{ content }`. - `deck.generateTheme` RPC: AI-generate a theme from a description, returns `{ content }`. - All three theme RPCs accept `{ content, deck_path }` (generateTheme accepts `{ description, deck_path }`). - Three new system-prompt templates: `system_fix_theme.md`, `system_rewrite_theme.md`, `system_generate_theme.md`. - Templates registered in `prompts.rs` `ALL_TEMPLATES` and seeded on disk. - Theme editor overlay gains: Fix, Rewrite, Generate, and Mic/Dictation buttons. - Voice dictation in theme editor routes audio through `voice.transcribe`, appends to the theme textarea. - All AI calls follow the existing `AiClient::from_env().with_tracking()` pattern with `Model::Gemini3ProPreview`. --- ### Files to Modify / Create | File | Action | Description | |---|---|---| | `crates/hero_slides_lib/src/prompts/system_fix_theme.md` | Create | System prompt for Fix Theme AI operation | | `crates/hero_slides_lib/src/prompts/system_rewrite_theme.md` | Create | System prompt for Rewrite Theme AI operation | | `crates/hero_slides_lib/src/prompts/system_generate_theme.md` | Create | System prompt for Generate Theme AI operation | | `crates/hero_slides_lib/src/prompts.rs` | Modify | Register the three new templates in `ALL_TEMPLATES` | | `crates/hero_slides_server/src/agent.rs` | Modify | Add `handle_fix_theme`, `handle_rewrite_theme`, `handle_generate_theme` handlers | | `crates/hero_slides_server/src/rpc.rs` | Modify | Register `deck.fixTheme`, `deck.rewriteTheme`, `deck.generateTheme` dispatch arms | | `crates/hero_slides_ui/templates/index.html` | Modify | Add Fix/Rewrite/Generate/Mic buttons to theme editor overlay | | `crates/hero_slides_ui/static/js/dashboard.js` | Modify | Add `fixTheme()`, `rewriteTheme()`, `generateTheme()`, voice recording helpers | --- ### Implementation 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.md` Dependencies: none — can run in parallel with nothing #### Step 2 — Register new templates in `prompts.rs` Files: `crates/hero_slides_lib/src/prompts.rs` Dependencies: Step 1 #### Step 3 — Add RPC handler functions in `agent.rs` Files: `crates/hero_slides_server/src/agent.rs` Dependencies: Step 2 #### Step 4 — Wire new methods into the RPC dispatcher Files: `crates/hero_slides_server/src/rpc.rs` Dependencies: Step 3 #### Step 5 — Update the theme editor HTML overlay Files: `crates/hero_slides_ui/templates/index.html` Dependencies: none (parallel with Step 6) #### Step 6 — Add theme AI and dictation functions to `dashboard.js` Files: `crates/hero_slides_ui/static/js/dashboard.js` Dependencies: none (parallel with Step 5) --- ### Acceptance Criteria - [ ] `deck.fixTheme`, `deck.rewriteTheme`, `deck.generateTheme` RPCs exist and return `{ content }`. - [ ] Three new prompt templates exist on disk and are embedded via `include_str!` in `prompts.rs`. - [ ] `seed_prompts_dir` writes the three new templates. - [ ] Theme editor overlay shows Fix, Rewrite, Generate, and Mic buttons. - [ ] Fix and Rewrite update the textarea, mark the editor dirty, and show a toast. - [ ] Generate opens a modal, takes a description, calls `deck.generateTheme`, replaces textarea content. - [ ] Mic button starts audio recording; transcription is appended to the theme textarea. - [ ] All AI handlers guard against empty providers and return a clear error. - [ ] `cargo build --workspace` succeeds with no errors. --- ### Notes - Follow the existing handler pattern in `agent.rs` exactly: `AiClient::from_env().with_tracking()`, `with_context(deck_name, deck_path)`, `spawn_blocking`, provider guard, `println!` debug blocks, `json!({ "content": result })`. - All three theme operations use `Model::Gemini3ProPreview`. - `deck.generateTheme` accepts `description` (not `content`) as the user is describing what they want, not editing existing content. - Background context in `deck.generateAsync` is already fully implemented — no new wiring needed for Goal 1.
Author
Member

Implementation Spec for Issue #1 (updated)

Objective

Extend hero_slides2 with two sets of features:

  1. Background Context in Agent Flow — wire background context into deck.runAgent so 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).
  2. Theme Dictation and AI Assistance — add Fix, Rewrite, and Generate RPC methods for the theme editor, plus a voice dictation button, mirroring the pattern already in place for the instructions editor.

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.runAgent RPC must accept an optional background_folders array parameter.
  • When background_folders is non-empty, handle_run_agent must call read_background_content() and inject the result into the agent prompt under a ## Background Context section.
  • The agent_build_deck.md prompt template must include a {{background_context}} placeholder.
  • The Instructions panel must show the same background checkbox tree already present in the Instruct panel, pre-selected by default.
  • runAgentOnDeck() in dashboard.js must pass the selected background folders to the RPC.
  • When no backgrounds exist for the deck, the UI section stays hidden (same pattern as Instruct panel).

Goal 2 — Theme AI Assistance

  • deck.fixTheme RPC: grammar/clarity fixes on theme content via AI, returns { content }.
  • deck.rewriteTheme RPC: restructure/improve theme via AI, returns { content }.
  • deck.generateTheme RPC: AI-generate theme from a description ({ description, deck_path }), returns { content }.
  • Three new system-prompt templates: system_fix_theme.md, system_rewrite_theme.md, system_generate_theme.md.
  • Templates registered in prompts.rs ALL_TEMPLATES and seeded on disk.
  • Theme editor overlay gains: Fix, Rewrite, Generate, and Mic/Dictation buttons.
  • Voice dictation routes audio through voice.transcribe, appends to the theme textarea.
  • All AI calls use AiClient::from_env().with_tracking() with Model::Gemini3ProPreview.

Files to Modify / Create

File Action Description
crates/hero_slides_lib/src/prompts/agent_build_deck.md Modify Add {{background_context}} placeholder
crates/hero_slides_lib/src/prompts/system_fix_theme.md Create System prompt for Fix Theme
crates/hero_slides_lib/src/prompts/system_rewrite_theme.md Create System prompt for Rewrite Theme
crates/hero_slides_lib/src/prompts/system_generate_theme.md Create System prompt for Generate Theme
crates/hero_slides_lib/src/prompts.rs Modify Register three new theme templates in ALL_TEMPLATES
crates/hero_slides_server/src/agent.rs Modify Wire background_folders into handle_run_agent; add handle_fix_theme, handle_rewrite_theme, handle_generate_theme
crates/hero_slides_server/src/rpc.rs Modify Add background_folders extraction to deck.runAgent arm; register three new deck.*Theme arms
crates/hero_slides_ui/templates/index.html Modify Add background checkbox tree to Instructions panel; add Fix/Rewrite/Generate/Mic to theme editor overlay
crates/hero_slides_ui/static/js/dashboard.js Modify Pass background_folders from Instructions panel in runAgentOnDeck(); add fixTheme(), rewriteTheme(), generateTheme(), theme voice helpers

Implementation Plan

Step 1 — Create the three theme prompt templates

Files: prompts/system_fix_theme.md, prompts/system_rewrite_theme.md, prompts/system_generate_theme.md
Dependencies: none — parallel-safe

Step 2 — Register new theme templates in prompts.rs

Files: crates/hero_slides_lib/src/prompts.rs
Dependencies: Step 1

Step 3 — Update agent_build_deck.md with background_context placeholder

Files: crates/hero_slides_lib/src/prompts/agent_build_deck.md
Dependencies: none — parallel-safe with Steps 1–2

Step 4 — Wire background_folders into handle_run_agent in agent.rs; add three theme handlers

Files: crates/hero_slides_server/src/agent.rs
Dependencies: Steps 2 and 3

Step 5 — Register new RPC dispatch arms in rpc.rs

Files: crates/hero_slides_server/src/rpc.rs
Dependencies: Step 4

Step 6 — Update Instructions panel HTML + theme editor HTML

Files: crates/hero_slides_ui/templates/index.html
Dependencies: none (parallel with Step 7)

Step 7 — Update dashboard.js: background selection in agent runner + theme AI functions

Files: crates/hero_slides_ui/static/js/dashboard.js
Dependencies: none (parallel with Step 6)


Acceptance Criteria

  • Running the AI Agent on a deck with backgrounds passes those files as context to the AI.
  • The Instructions panel shows a background selection checkbox tree (hidden when no backgrounds exist).
  • agent_build_deck.md renders background context under a ## Background Context section when folders are selected.
  • deck.fixTheme, deck.rewriteTheme, deck.generateTheme RPCs exist and return { content }.
  • Three new prompt templates exist on disk and are embedded via include_str! in prompts.rs.
  • Theme editor overlay shows Fix, Rewrite, Generate, and Mic buttons.
  • Fix and Rewrite update the textarea, mark the editor dirty, and show a toast.
  • Generate opens a modal, takes a description, calls deck.generateTheme, replaces textarea.
  • Mic button records audio and appends transcription to the theme textarea.
  • cargo build --workspace succeeds with no errors.

Notes

  • handle_run_agent is in agent.rs around line 129. Currently it reads instructions.md and calls build_prompt() with only {{instructions}}. The fix is to also call read_background_content() for the selected folders and pass the result as a second template variable.
  • runAgentOnDeck() is in dashboard.js around line 3477. It currently calls rpc('deck.runAgent', { deck_path: instrDeckPath }). It needs to also pass background_folders.
  • The Instructions panel background list should follow the exact same pattern as instruct-bg-list / loadInstructBgFolders() / renderInstructBgList() (dashboard.js lines 3311–3359).
  • All three theme handlers follow the existing handler pattern exactly: AiClient::from_env().with_tracking(), with_context(deck_name, deck_path), spawn_blocking, provider guard, println! debug blocks.
  • deck.generateTheme accepts description (not content) as the input field name.
## Implementation Spec for Issue #1 (updated) ### Objective Extend hero_slides2 with two sets of features: 1. **Background Context in Agent Flow** — wire background context into `deck.runAgent` so 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). 2. **Theme Dictation and AI Assistance** — add Fix, Rewrite, and Generate RPC methods for the theme editor, plus a voice dictation button, mirroring the pattern already in place for the instructions editor. 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.runAgent` RPC must accept an optional `background_folders` array parameter. - When `background_folders` is non-empty, `handle_run_agent` must call `read_background_content()` and inject the result into the agent prompt under a `## Background Context` section. - The `agent_build_deck.md` prompt template must include a `{{background_context}}` placeholder. - The Instructions panel must show the same background checkbox tree already present in the Instruct panel, pre-selected by default. - `runAgentOnDeck()` in `dashboard.js` must pass the selected background folders to the RPC. - When no backgrounds exist for the deck, the UI section stays hidden (same pattern as Instruct panel). **Goal 2 — Theme AI Assistance** - `deck.fixTheme` RPC: grammar/clarity fixes on theme content via AI, returns `{ content }`. - `deck.rewriteTheme` RPC: restructure/improve theme via AI, returns `{ content }`. - `deck.generateTheme` RPC: AI-generate theme from a description (`{ description, deck_path }`), returns `{ content }`. - Three new system-prompt templates: `system_fix_theme.md`, `system_rewrite_theme.md`, `system_generate_theme.md`. - Templates registered in `prompts.rs` `ALL_TEMPLATES` and seeded on disk. - Theme editor overlay gains: Fix, Rewrite, Generate, and Mic/Dictation buttons. - Voice dictation routes audio through `voice.transcribe`, appends to the theme textarea. - All AI calls use `AiClient::from_env().with_tracking()` with `Model::Gemini3ProPreview`. --- ### Files to Modify / Create | File | Action | Description | |---|---|---| | `crates/hero_slides_lib/src/prompts/agent_build_deck.md` | Modify | Add `{{background_context}}` placeholder | | `crates/hero_slides_lib/src/prompts/system_fix_theme.md` | Create | System prompt for Fix Theme | | `crates/hero_slides_lib/src/prompts/system_rewrite_theme.md` | Create | System prompt for Rewrite Theme | | `crates/hero_slides_lib/src/prompts/system_generate_theme.md` | Create | System prompt for Generate Theme | | `crates/hero_slides_lib/src/prompts.rs` | Modify | Register three new theme templates in `ALL_TEMPLATES` | | `crates/hero_slides_server/src/agent.rs` | Modify | Wire `background_folders` into `handle_run_agent`; add `handle_fix_theme`, `handle_rewrite_theme`, `handle_generate_theme` | | `crates/hero_slides_server/src/rpc.rs` | Modify | Add `background_folders` extraction to `deck.runAgent` arm; register three new `deck.*Theme` arms | | `crates/hero_slides_ui/templates/index.html` | Modify | Add background checkbox tree to Instructions panel; add Fix/Rewrite/Generate/Mic to theme editor overlay | | `crates/hero_slides_ui/static/js/dashboard.js` | Modify | Pass `background_folders` from Instructions panel in `runAgentOnDeck()`; add `fixTheme()`, `rewriteTheme()`, `generateTheme()`, theme voice helpers | --- ### Implementation Plan #### Step 1 — Create the three theme prompt templates Files: `prompts/system_fix_theme.md`, `prompts/system_rewrite_theme.md`, `prompts/system_generate_theme.md` Dependencies: none — parallel-safe #### Step 2 — Register new theme templates in `prompts.rs` Files: `crates/hero_slides_lib/src/prompts.rs` Dependencies: Step 1 #### Step 3 — Update `agent_build_deck.md` with background_context placeholder Files: `crates/hero_slides_lib/src/prompts/agent_build_deck.md` Dependencies: none — parallel-safe with Steps 1–2 #### Step 4 — Wire background_folders into `handle_run_agent` in `agent.rs`; add three theme handlers Files: `crates/hero_slides_server/src/agent.rs` Dependencies: Steps 2 and 3 #### Step 5 — Register new RPC dispatch arms in `rpc.rs` Files: `crates/hero_slides_server/src/rpc.rs` Dependencies: Step 4 #### Step 6 — Update Instructions panel HTML + theme editor HTML Files: `crates/hero_slides_ui/templates/index.html` Dependencies: none (parallel with Step 7) #### Step 7 — Update `dashboard.js`: background selection in agent runner + theme AI functions Files: `crates/hero_slides_ui/static/js/dashboard.js` Dependencies: none (parallel with Step 6) --- ### Acceptance Criteria - [ ] Running the AI Agent on a deck with backgrounds passes those files as context to the AI. - [ ] The Instructions panel shows a background selection checkbox tree (hidden when no backgrounds exist). - [ ] `agent_build_deck.md` renders background context under a `## Background Context` section when folders are selected. - [ ] `deck.fixTheme`, `deck.rewriteTheme`, `deck.generateTheme` RPCs exist and return `{ content }`. - [ ] Three new prompt templates exist on disk and are embedded via `include_str!` in `prompts.rs`. - [ ] Theme editor overlay shows Fix, Rewrite, Generate, and Mic buttons. - [ ] Fix and Rewrite update the textarea, mark the editor dirty, and show a toast. - [ ] Generate opens a modal, takes a description, calls `deck.generateTheme`, replaces textarea. - [ ] Mic button records audio and appends transcription to the theme textarea. - [ ] `cargo build --workspace` succeeds with no errors. --- ### Notes - `handle_run_agent` is in `agent.rs` around line 129. Currently it reads instructions.md and calls `build_prompt()` with only `{{instructions}}`. The fix is to also call `read_background_content()` for the selected folders and pass the result as a second template variable. - `runAgentOnDeck()` is in `dashboard.js` around line 3477. It currently calls `rpc('deck.runAgent', { deck_path: instrDeckPath })`. It needs to also pass `background_folders`. - The Instructions panel background list should follow the exact same pattern as `instruct-bg-list` / `loadInstructBgFolders()` / `renderInstructBgList()` (dashboard.js lines 3311–3359). - All three theme handlers follow the existing handler pattern exactly: `AiClient::from_env().with_tracking()`, `with_context(deck_name, deck_path)`, `spawn_blocking`, provider guard, `println!` debug blocks. - `deck.generateTheme` accepts `description` (not `content`) as the input field name.
Author
Member

Test Results

Build: pass
Tests: 60 total, 59 passed, 0 failed (1 ignored)

Details

  • hero_slides_lib unit tests: 42 passed, 0 failed
  • hero_slides_lib integration tests: 12 passed, 0 failed, 1 ignored (test_generate_single_slide_ai — skipped, likely requires live AI credentials)
  • hero_slides_lib doc tests: 2 passed, 0 failed
  • hero_slides_rhai doc tests: 1 passed, 0 failed
  • hero_slides, hero_slides_rhai, hero_slides_sdk, hero_slides_server, hero_slides_ui: 0 tests each (no test suite defined)

One warning: unused variable spec in crates/hero_slides_examples/examples/basic_usage.rs:18.

## Test Results **Build:** pass **Tests:** 60 total, 59 passed, 0 failed (1 ignored) ### Details - `hero_slides_lib` unit tests: 42 passed, 0 failed - `hero_slides_lib` integration tests: 12 passed, 0 failed, 1 ignored (`test_generate_single_slide_ai` — skipped, likely requires live AI credentials) - `hero_slides_lib` doc tests: 2 passed, 0 failed - `hero_slides_rhai` doc tests: 1 passed, 0 failed - `hero_slides`, `hero_slides_rhai`, `hero_slides_sdk`, `hero_slides_server`, `hero_slides_ui`: 0 tests each (no test suite defined) One warning: unused variable `spec` in `crates/hero_slides_examples/examples/basic_usage.rs:18`.
Author
Member

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) — Extracts background_folders from RPC params, calls read_background_content(), and injects the result under a ## Background Context section 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 — Added loadAgentBgFolders(), renderAgentBgList(), toggleAgentBgFolder() (mirrors the Instruct panel pattern); runAgentOnDeck() now passes background_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 in ALL_TEMPLATES with include_str! constants; seed_prompts_dir writes them automatically.
  • crates/hero_slides_server/src/agent.rs — Added handle_fix_theme, handle_rewrite_theme, handle_generate_theme handlers following the existing AI handler pattern (AiClient::from_env().with_tracking(), Model::Gemini3ProPreview, spawn_blocking).
  • crates/hero_slides_server/src/rpc.rs — Registered deck.fixTheme, deck.rewriteTheme, deck.generateTheme dispatch arms.
  • crates/hero_slides_ui/templates/index.html — Added Fix, Rewrite, Generate, and Mic buttons to the theme editor overlay; added theme-voice-status span; added generateThemeModal.
  • crates/hero_slides_ui/static/js/dashboard.js — Added fixTheme(), rewriteTheme(), openGenerateThemeModal(), doGenerateTheme(), startThemeRecording(), stopThemeRecording(), sendThemeAudioToServer().

Test Results

  • Build: pass
  • Tests: 60 total, 59 passed, 0 failed, 1 ignored (AI integration test skipped without live credentials)
## 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`) — Extracts `background_folders` from RPC params, calls `read_background_content()`, and injects the result under a `## Background Context` section 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` — Added `loadAgentBgFolders()`, `renderAgentBgList()`, `toggleAgentBgFolder()` (mirrors the Instruct panel pattern); `runAgentOnDeck()` now passes `background_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 in `ALL_TEMPLATES` with `include_str!` constants; `seed_prompts_dir` writes them automatically. - `crates/hero_slides_server/src/agent.rs` — Added `handle_fix_theme`, `handle_rewrite_theme`, `handle_generate_theme` handlers following the existing AI handler pattern (`AiClient::from_env().with_tracking()`, `Model::Gemini3ProPreview`, `spawn_blocking`). - `crates/hero_slides_server/src/rpc.rs` — Registered `deck.fixTheme`, `deck.rewriteTheme`, `deck.generateTheme` dispatch arms. - `crates/hero_slides_ui/templates/index.html` — Added Fix, Rewrite, Generate, and Mic buttons to the theme editor overlay; added `theme-voice-status` span; added `generateThemeModal`. - `crates/hero_slides_ui/static/js/dashboard.js` — Added `fixTheme()`, `rewriteTheme()`, `openGenerateThemeModal()`, `doGenerateTheme()`, `startThemeRecording()`, `stopThemeRecording()`, `sendThemeAudioToServer()`. ### Test Results - Build: pass - Tests: 60 total, 59 passed, 0 failed, 1 ignored (AI integration test skipped without live credentials)
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_slides#1
No description provided.