Add AI fix and rewrite to theme editor #4

Closed
opened 2026-04-13 17:51:59 +00:00 by casper-stevens · 6 comments
Member

Context

The instructions editor already supports AI-powered fix and rewrite actions, but the theme editor lacks these capabilities. Users should be able to apply the same AI workflows when editing themes.

Goals

  • Add "Fix with AI" button to the theme editor that corrects syntax and formatting issues
  • Add "Rewrite with AI" button that accepts a prompt and rewrites the theme content
  • Match the same UX pattern used in the instructions editor (button placement, loading states, prompt modal)
## Context The instructions editor already supports AI-powered fix and rewrite actions, but the theme editor lacks these capabilities. Users should be able to apply the same AI workflows when editing themes. ## Goals - Add "Fix with AI" button to the theme editor that corrects syntax and formatting issues - Add "Rewrite with AI" button that accepts a prompt and rewrites the theme content - Match the same UX pattern used in the instructions editor (button placement, loading states, prompt modal)
Author
Member

Implementation Spec for Issue #4

Objective

Add deck.fixTheme and deck.rewriteTheme method definitions to the OpenRPC specification and regenerate the typed client, completing the SDK documentation for the already-implemented AI theme editing feature.

Current State

After thorough codebase exploration, the core feature (UI buttons, JS handlers, Rust RPC routing, agent handlers, AI prompt templates) has already been fully implemented in commit 1f5c1af. The only remaining gap is the OpenRPC specification and typed client.

Requirements

  • Add deck.fixTheme method definition to openrpc.json with params: content (required), deck_path (optional), user_instruction (optional)
  • Add deck.rewriteTheme method definition to openrpc.json with the same params
  • Regenerate openrpc.client.generated.rs to include typed deck_fix_theme() and deck_rewrite_theme() methods

Files to Modify

  • crates/hero_slides_server/openrpc.json -- Add two new method definitions following the existing deck.fixInstructions / deck.rewriteInstructions pattern
  • crates/hero_slides_server/openrpc.client.generated.rs -- Regenerate or manually add two client methods

Implementation Plan

Step 1: Add deck.fixTheme and deck.rewriteTheme to OpenRPC spec

File: crates/hero_slides_server/openrpc.json

  • Insert deck.fixTheme method entry after deck.rewriteInstructions, following the same structure as deck.fixInstructions
  • Insert deck.rewriteTheme method entry immediately after, following the deck.rewriteInstructions pattern
  • Both methods take: content (required, string), deck_path (optional, string), user_instruction (optional, string)

Step 2: Update the typed OpenRPC client

File: crates/hero_slides_server/openrpc.client.generated.rs

  • Add DeckFixThemeInput, DeckFixThemeOutput, DeckRewriteThemeInput, DeckRewriteThemeOutput structs
  • Add deck_fix_theme() and deck_rewrite_theme() methods on the client

Step 3: Verify compilation

  • Run cargo build and cargo test to ensure everything compiles and passes

Acceptance Criteria

  • deck.fixTheme method defined in openrpc.json with correct params
  • deck.rewriteTheme method defined in openrpc.json with correct params
  • openrpc.client.generated.rs contains typed methods for both
  • Project compiles without errors
  • Existing tests pass

Notes

  • The user_instruction parameter exists in the runtime implementation but is absent from the existing deck.fixInstructions and deck.rewriteInstructions OpenRPC entries as well. This is out of scope for this issue but worth noting.
  • The frontend uses generic JSON-RPC calls, so the OpenRPC gap has zero impact on UI functionality -- it only affects typed SDK consumers.
## Implementation Spec for Issue #4 ### Objective Add `deck.fixTheme` and `deck.rewriteTheme` method definitions to the OpenRPC specification and regenerate the typed client, completing the SDK documentation for the already-implemented AI theme editing feature. ### Current State After thorough codebase exploration, the core feature (UI buttons, JS handlers, Rust RPC routing, agent handlers, AI prompt templates) has already been fully implemented in commit 1f5c1af. The only remaining gap is the OpenRPC specification and typed client. ### Requirements - Add `deck.fixTheme` method definition to `openrpc.json` with params: `content` (required), `deck_path` (optional), `user_instruction` (optional) - Add `deck.rewriteTheme` method definition to `openrpc.json` with the same params - Regenerate `openrpc.client.generated.rs` to include typed `deck_fix_theme()` and `deck_rewrite_theme()` methods ### Files to Modify - `crates/hero_slides_server/openrpc.json` -- Add two new method definitions following the existing `deck.fixInstructions` / `deck.rewriteInstructions` pattern - `crates/hero_slides_server/openrpc.client.generated.rs` -- Regenerate or manually add two client methods ### Implementation Plan #### Step 1: Add `deck.fixTheme` and `deck.rewriteTheme` to OpenRPC spec File: `crates/hero_slides_server/openrpc.json` - Insert `deck.fixTheme` method entry after `deck.rewriteInstructions`, following the same structure as `deck.fixInstructions` - Insert `deck.rewriteTheme` method entry immediately after, following the `deck.rewriteInstructions` pattern - Both methods take: `content` (required, string), `deck_path` (optional, string), `user_instruction` (optional, string) #### Step 2: Update the typed OpenRPC client File: `crates/hero_slides_server/openrpc.client.generated.rs` - Add `DeckFixThemeInput`, `DeckFixThemeOutput`, `DeckRewriteThemeInput`, `DeckRewriteThemeOutput` structs - Add `deck_fix_theme()` and `deck_rewrite_theme()` methods on the client #### Step 3: Verify compilation - Run `cargo build` and `cargo test` to ensure everything compiles and passes ### Acceptance Criteria - [ ] `deck.fixTheme` method defined in `openrpc.json` with correct params - [ ] `deck.rewriteTheme` method defined in `openrpc.json` with correct params - [ ] `openrpc.client.generated.rs` contains typed methods for both - [ ] Project compiles without errors - [ ] Existing tests pass ### Notes - The `user_instruction` parameter exists in the runtime implementation but is absent from the existing `deck.fixInstructions` and `deck.rewriteInstructions` OpenRPC entries as well. This is out of scope for this issue but worth noting. - The frontend uses generic JSON-RPC calls, so the OpenRPC gap has zero impact on UI functionality -- it only affects typed SDK consumers.
Author
Member

Implementation Spec for Issue #4 (updated)

Objective

Add deck.fixTheme and deck.rewriteTheme method definitions to the OpenRPC specification, regenerate/update the typed client, and ensure the theme editor's Fix/Rewrite UX includes the same voice-dictation capability as the instructions editor.

Current State

The core feature (UI buttons, JS handlers, Rust RPC routing, agent handlers, AI prompt templates) was implemented in commit 1f5c1af. The remaining gaps are: (1) the two new methods are not documented in the OpenRPC spec, and (2) voice dictation parity with the instructions editor needs to be verified and wired where missing.

Requirements

  • Add deck.fixTheme method definition to openrpc.json with params: content (required), deck_path (optional), user_instruction (optional)
  • Add deck.rewriteTheme method definition to openrpc.json with the same params
  • Update openrpc.client.generated.rs to include typed deck_fix_theme() and deck_rewrite_theme() methods
  • Voice dictation parity: the theme editor must offer the same dictation capability as the instructions editor -- microphone record/stop buttons on both the main theme textarea and the optional user_instruction input, using the same recording pipeline (startRecording / stopRecording / sendAudioToServer) and visual states as the instructions editor

Files to Modify

  • crates/hero_slides_server/openrpc.json -- Add two new method definitions following the deck.fixInstructions / deck.rewriteInstructions pattern
  • crates/hero_slides_server/openrpc.client.generated.rs -- Add typed client methods
  • crates/hero_slides_ui/templates/index.html -- Verify/add the theme-editor dictation buttons (btn-theme-record-start, btn-theme-record-stop, btn-theme-instruct-record, btn-theme-instruct-record-stop) match the instructions-editor counterparts
  • crates/hero_slides_ui/static/js/dashboard.js -- Ensure the shared recording handlers route theme audio back into the theme textarea / instruct input identically to the instructions editor

Implementation Plan

Step 1: Add deck.fixTheme and deck.rewriteTheme to OpenRPC spec

File: crates/hero_slides_server/openrpc.json

  • Insert deck.fixTheme and deck.rewriteTheme method entries after deck.rewriteInstructions
  • Both take content (required, string), deck_path (optional, string), user_instruction (optional, string)

Step 2: Update the typed OpenRPC client

File: crates/hero_slides_server/openrpc.client.generated.rs

  • Add DeckFixThemeInput, DeckFixThemeOutput, DeckRewriteThemeInput, DeckRewriteThemeOutput structs
  • Add deck_fix_theme() and deck_rewrite_theme() methods on the client

Step 3: Verify and complete voice-dictation parity

Files: crates/hero_slides_ui/templates/index.html, crates/hero_slides_ui/static/js/dashboard.js

  • Confirm the theme editor exposes record/stop buttons for both the main textarea and the user_instruction input, mirroring the instructions editor's button placement and icons
  • Confirm startRecording / stopRecording / sendAudioToServer in dashboard.js correctly branch on the active theme overlay and write transcribed text back into the right target (main textarea vs. instruct input), matching the instructions-editor behavior
  • Fill any gaps found during verification

Step 4: Verify compilation and tests

  • Run cargo build and cargo test to ensure everything compiles and passes

Acceptance Criteria

  • deck.fixTheme method defined in openrpc.json with correct params
  • deck.rewriteTheme method defined in openrpc.json with correct params
  • openrpc.client.generated.rs contains typed methods for both
  • Theme editor supports voice dictation into both the main textarea and the user_instruction input, with the same UX as the instructions editor
  • Project compiles without errors
  • Existing tests pass

Notes

  • The frontend uses generic JSON-RPC calls, so the OpenRPC gap has zero impact on UI functionality -- it only affects typed SDK consumers.
  • Dictation is a first-class requirement here: users editing themes should be able to speak their fix/rewrite instructions just like they can when editing instructions.
## Implementation Spec for Issue #4 (updated) ### Objective Add `deck.fixTheme` and `deck.rewriteTheme` method definitions to the OpenRPC specification, regenerate/update the typed client, and ensure the theme editor's Fix/Rewrite UX includes the same voice-dictation capability as the instructions editor. ### Current State The core feature (UI buttons, JS handlers, Rust RPC routing, agent handlers, AI prompt templates) was implemented in commit 1f5c1af. The remaining gaps are: (1) the two new methods are not documented in the OpenRPC spec, and (2) voice dictation parity with the instructions editor needs to be verified and wired where missing. ### Requirements - Add `deck.fixTheme` method definition to `openrpc.json` with params: `content` (required), `deck_path` (optional), `user_instruction` (optional) - Add `deck.rewriteTheme` method definition to `openrpc.json` with the same params - Update `openrpc.client.generated.rs` to include typed `deck_fix_theme()` and `deck_rewrite_theme()` methods - **Voice dictation parity**: the theme editor must offer the same dictation capability as the instructions editor -- microphone record/stop buttons on both the main theme textarea and the optional `user_instruction` input, using the same recording pipeline (`startRecording` / `stopRecording` / `sendAudioToServer`) and visual states as the instructions editor ### Files to Modify - `crates/hero_slides_server/openrpc.json` -- Add two new method definitions following the `deck.fixInstructions` / `deck.rewriteInstructions` pattern - `crates/hero_slides_server/openrpc.client.generated.rs` -- Add typed client methods - `crates/hero_slides_ui/templates/index.html` -- Verify/add the theme-editor dictation buttons (`btn-theme-record-start`, `btn-theme-record-stop`, `btn-theme-instruct-record`, `btn-theme-instruct-record-stop`) match the instructions-editor counterparts - `crates/hero_slides_ui/static/js/dashboard.js` -- Ensure the shared recording handlers route theme audio back into the theme textarea / instruct input identically to the instructions editor ### Implementation Plan #### Step 1: Add `deck.fixTheme` and `deck.rewriteTheme` to OpenRPC spec File: `crates/hero_slides_server/openrpc.json` - Insert `deck.fixTheme` and `deck.rewriteTheme` method entries after `deck.rewriteInstructions` - Both take `content` (required, string), `deck_path` (optional, string), `user_instruction` (optional, string) #### Step 2: Update the typed OpenRPC client File: `crates/hero_slides_server/openrpc.client.generated.rs` - Add `DeckFixThemeInput`, `DeckFixThemeOutput`, `DeckRewriteThemeInput`, `DeckRewriteThemeOutput` structs - Add `deck_fix_theme()` and `deck_rewrite_theme()` methods on the client #### Step 3: Verify and complete voice-dictation parity Files: `crates/hero_slides_ui/templates/index.html`, `crates/hero_slides_ui/static/js/dashboard.js` - Confirm the theme editor exposes record/stop buttons for both the main textarea and the `user_instruction` input, mirroring the instructions editor's button placement and icons - Confirm `startRecording` / `stopRecording` / `sendAudioToServer` in `dashboard.js` correctly branch on the active theme overlay and write transcribed text back into the right target (main textarea vs. instruct input), matching the instructions-editor behavior - Fill any gaps found during verification #### Step 4: Verify compilation and tests - Run `cargo build` and `cargo test` to ensure everything compiles and passes ### Acceptance Criteria - [ ] `deck.fixTheme` method defined in `openrpc.json` with correct params - [ ] `deck.rewriteTheme` method defined in `openrpc.json` with correct params - [ ] `openrpc.client.generated.rs` contains typed methods for both - [ ] Theme editor supports voice dictation into both the main textarea and the `user_instruction` input, with the same UX as the instructions editor - [ ] Project compiles without errors - [ ] Existing tests pass ### Notes - The frontend uses generic JSON-RPC calls, so the OpenRPC gap has zero impact on UI functionality -- it only affects typed SDK consumers. - Dictation is a first-class requirement here: users editing themes should be able to speak their fix/rewrite instructions just like they can when editing instructions.
Author
Member

Implementation Spec for Issue #4 (revised)

Objective

Make the theme editor layout match the instructions editor, and port the slide-level Instruct feature into both the theme editor and the instructions editor so users can apply a natural-language instruction (with optional background-folder context and voice dictation) to theme.md and instructions.md.

Scope

  1. Remove the always-visible "AI Instruction" panel from the theme editor so its layout matches the instructions editor.
  2. Port the slide-level Instruct feature (executeInstruct + system_instruct_slide.md + slide.instructContent* RPC family) into the theme editor.
  3. Port the same Instruct feature into the instructions editor.

Reference: slide Instruct pattern (already implemented)

  • Topbar button btn-instruct-slide -> toggleInstructPanel()
  • Hidden-by-default panel #instruct-panel with:
    • Instruction textarea #instruct-input
    • Voice record/stop buttons wired to startInstructRecording() / stopInstructRecording() / transcribeInstructAudio()
    • Optional background-folders checklist (bg.listFolders -> renderInstructBgList)
    • Apply button #btn-instruct-go -> executeInstruct()
  • executeInstruct() calls slide.instructContentAsync, polls via slide.instructContentJobStatus, retrieves via slide.instructContentResult, using the shared pollContentJob helper
  • Backend: handle_instruct_slide_content in agent.rs + async job family in generate_job.rs, using system_instruct_slide.md

Requirements

  • Theme editor topbar gains an Instruct button identical in style/placement to btn-instruct-slide, toggling a new hidden-by-default #theme-instruct-panel.
  • The existing always-visible theme-instruct-panel and associated functions/handlers (which funneled a user_instruction param into deck.fixTheme / deck.rewriteTheme) are removed; user_instruction is no longer forwarded from Fix/Rewrite. (Fix and Rewrite remain; only the persistent instruction panel and its plumbing go.)
  • Instructions editor topbar gains the same Instruct button and hidden panel.
  • Both new panels include: instruction textarea, voice record/stop with transcription, optional background-folders checklist, Apply button.
  • Both editors call new async-job RPC families mirroring slide.instructContent*:
    • deck.instructTheme, deck.instructThemeAsync, deck.instructThemeJobStatus, deck.instructThemeJobLogs, deck.instructThemeResult
    • deck.instructInstructions, deck.instructInstructionsAsync, deck.instructInstructionsJobStatus, deck.instructInstructionsJobLogs, deck.instructInstructionsResult
  • Two new prompt files: system_instruct_theme.md, system_instruct_instructions.md, both registered in ALL_TEMPLATES and embedded via include_str!.
  • Loading states, error toasts, and textarea-grayed-out UX match the slide Instruct pattern exactly.

Files to Modify

  • crates/hero_slides_ui/templates/index.html
    • Theme editor (~lines 569-624): remove the always-visible AI Instruction panel; add an Instruct topbar button and a new hidden #theme-instruct-panel modeled on #instruct-panel.
    • Instructions editor (~lines 651-698): add an Instruct topbar button and a new hidden #instructions-instruct-panel.
  • crates/hero_slides_ui/static/js/dashboard.js
    • Remove existing startThemeInstructRecording / stopThemeInstructRecording and the user_instruction branches inside fixThemeContent / rewriteThemeContent.
    • Add toggleThemeInstructPanel, loadThemeInstructBgFolders, renderThemeInstructBgList, toggleThemeInstructBgFolder, executeThemeInstruct, plus voice functions targeting the new panel.
    • Add the analogous set for the instructions editor (toggleInstructionsInstructPanel, etc., using instrDeckPath).
    • Reset both panels (hidden, cleared input) on editor open.
  • crates/hero_slides_server/src/rpc.rs
    • Register new dispatch arms for the ten new method names listed above.
  • crates/hero_slides_server/src/agent.rs
    • Add handle_instruct_theme and handle_instruct_instructions, modeled on handle_instruct_slide_content, using the two new prompts.
    • Clean up: drop the user_instruction handling added to handle_fix_theme / handle_rewrite_theme (now out of scope).
  • crates/hero_slides_server/src/generate_job.rs
    • Add async-job wrappers for both theme and instructions Instruct, mirroring the slide async-job family.
  • crates/hero_slides_lib/src/prompts/system_instruct_theme.md (new)
  • crates/hero_slides_lib/src/prompts/system_instruct_instructions.md (new)
  • crates/hero_slides_lib/src/prompts.rs
    • Add DEFAULT_SYSTEM_INSTRUCT_THEME and DEFAULT_SYSTEM_INSTRUCT_INSTRUCTIONS constants and register both in ALL_TEMPLATES.
  • crates/hero_slides_server/openrpc.json
    • Document the ten new RPC methods following the slide.instructContent* entries.

Implementation Plan

Step 1 - Prompts

Create system_instruct_theme.md and system_instruct_instructions.md, adapting system_instruct_slide.md for theme and instructions contexts. Register both in prompts.rs.

Step 2 - Backend handlers

Add handle_instruct_theme and handle_instruct_instructions in agent.rs. Add async-job wrappers in generate_job.rs. Wire all ten RPC methods in rpc.rs.

Step 3 - Cleanup

Remove user_instruction plumbing from handle_fix_theme / handle_rewrite_theme and from the JS Fix/Rewrite paths. Remove the always-visible Theme AI Instruction panel from HTML, CSS, and JS.

Step 4 - Theme editor UI

Add Instruct topbar button and hidden #theme-instruct-panel (mirroring slide pattern). Implement the theme-scoped JS helpers and executeThemeInstruct.

Step 5 - Instructions editor UI

Same as Step 4 but scoped to the instructions editor, using instrDeckPath.

Step 6 - OpenRPC spec

Add the ten new method entries to openrpc.json.

Step 7 - Verify

cargo build --workspace + cargo test --workspace + manual UI test of both new Instruct flows with and without background folders, with and without voice input.

Acceptance Criteria

  • Theme editor has no always-visible "AI Instruction" panel; its topbar has Fix, Rewrite, and a new Instruct button that toggles a hidden panel matching the slide editor pattern.
  • Instructions editor topbar has an Instruct button that toggles a hidden panel matching the slide editor pattern.
  • executeThemeInstruct and executeInstructionsInstruct call their respective async-job RPC families and update the textarea + preview on success.
  • Voice dictation works in both new panels.
  • Background-folder checklist appears when the deck has background folders and is forwarded to the backend.
  • system_instruct_theme.md and system_instruct_instructions.md are registered in ALL_TEMPLATES and embedded via include_str!.
  • All ten new RPC methods are documented in openrpc.json.
  • cargo build --workspace succeeds; cargo test --workspace passes.

Notes

  • Fix and Rewrite keep their existing behavior but lose the user_instruction param; any natural-language guidance now flows through the dedicated Instruct panel.
  • The existing async-job polling helper pollContentJob is reusable verbatim for both new panels.
  • The background-folders integration (bg.listFolders, instruct-bg-list) is copied wholesale from the slide pattern; no backend changes needed on that RPC.
## Implementation Spec for Issue #4 (revised) ### Objective Make the theme editor layout match the instructions editor, and port the slide-level Instruct feature into both the theme editor and the instructions editor so users can apply a natural-language instruction (with optional background-folder context and voice dictation) to theme.md and instructions.md. ### Scope 1. Remove the always-visible "AI Instruction" panel from the theme editor so its layout matches the instructions editor. 2. Port the slide-level Instruct feature (`executeInstruct` + `system_instruct_slide.md` + `slide.instructContent*` RPC family) into the theme editor. 3. Port the same Instruct feature into the instructions editor. ### Reference: slide Instruct pattern (already implemented) - Topbar button `btn-instruct-slide` -> `toggleInstructPanel()` - Hidden-by-default panel `#instruct-panel` with: - Instruction textarea `#instruct-input` - Voice record/stop buttons wired to `startInstructRecording()` / `stopInstructRecording()` / `transcribeInstructAudio()` - Optional background-folders checklist (`bg.listFolders` -> `renderInstructBgList`) - Apply button `#btn-instruct-go` -> `executeInstruct()` - `executeInstruct()` calls `slide.instructContentAsync`, polls via `slide.instructContentJobStatus`, retrieves via `slide.instructContentResult`, using the shared `pollContentJob` helper - Backend: `handle_instruct_slide_content` in `agent.rs` + async job family in `generate_job.rs`, using `system_instruct_slide.md` ### Requirements - Theme editor topbar gains an `Instruct` button identical in style/placement to `btn-instruct-slide`, toggling a new hidden-by-default `#theme-instruct-panel`. - The existing always-visible `theme-instruct-panel` and associated functions/handlers (which funneled a `user_instruction` param into `deck.fixTheme` / `deck.rewriteTheme`) are removed; `user_instruction` is no longer forwarded from Fix/Rewrite. (Fix and Rewrite remain; only the persistent instruction panel and its plumbing go.) - Instructions editor topbar gains the same `Instruct` button and hidden panel. - Both new panels include: instruction textarea, voice record/stop with transcription, optional background-folders checklist, Apply button. - Both editors call new async-job RPC families mirroring `slide.instructContent*`: - `deck.instructTheme`, `deck.instructThemeAsync`, `deck.instructThemeJobStatus`, `deck.instructThemeJobLogs`, `deck.instructThemeResult` - `deck.instructInstructions`, `deck.instructInstructionsAsync`, `deck.instructInstructionsJobStatus`, `deck.instructInstructionsJobLogs`, `deck.instructInstructionsResult` - Two new prompt files: `system_instruct_theme.md`, `system_instruct_instructions.md`, both registered in `ALL_TEMPLATES` and embedded via `include_str!`. - Loading states, error toasts, and textarea-grayed-out UX match the slide Instruct pattern exactly. ### Files to Modify - `crates/hero_slides_ui/templates/index.html` - Theme editor (~lines 569-624): remove the always-visible AI Instruction panel; add an `Instruct` topbar button and a new hidden `#theme-instruct-panel` modeled on `#instruct-panel`. - Instructions editor (~lines 651-698): add an `Instruct` topbar button and a new hidden `#instructions-instruct-panel`. - `crates/hero_slides_ui/static/js/dashboard.js` - Remove existing `startThemeInstructRecording` / `stopThemeInstructRecording` and the `user_instruction` branches inside `fixThemeContent` / `rewriteThemeContent`. - Add `toggleThemeInstructPanel`, `loadThemeInstructBgFolders`, `renderThemeInstructBgList`, `toggleThemeInstructBgFolder`, `executeThemeInstruct`, plus voice functions targeting the new panel. - Add the analogous set for the instructions editor (`toggleInstructionsInstructPanel`, etc., using `instrDeckPath`). - Reset both panels (hidden, cleared input) on editor open. - `crates/hero_slides_server/src/rpc.rs` - Register new dispatch arms for the ten new method names listed above. - `crates/hero_slides_server/src/agent.rs` - Add `handle_instruct_theme` and `handle_instruct_instructions`, modeled on `handle_instruct_slide_content`, using the two new prompts. - Clean up: drop the `user_instruction` handling added to `handle_fix_theme` / `handle_rewrite_theme` (now out of scope). - `crates/hero_slides_server/src/generate_job.rs` - Add async-job wrappers for both theme and instructions Instruct, mirroring the slide async-job family. - `crates/hero_slides_lib/src/prompts/system_instruct_theme.md` (new) - `crates/hero_slides_lib/src/prompts/system_instruct_instructions.md` (new) - `crates/hero_slides_lib/src/prompts.rs` - Add `DEFAULT_SYSTEM_INSTRUCT_THEME` and `DEFAULT_SYSTEM_INSTRUCT_INSTRUCTIONS` constants and register both in `ALL_TEMPLATES`. - `crates/hero_slides_server/openrpc.json` - Document the ten new RPC methods following the `slide.instructContent*` entries. ### Implementation Plan #### Step 1 - Prompts Create `system_instruct_theme.md` and `system_instruct_instructions.md`, adapting `system_instruct_slide.md` for theme and instructions contexts. Register both in `prompts.rs`. #### Step 2 - Backend handlers Add `handle_instruct_theme` and `handle_instruct_instructions` in `agent.rs`. Add async-job wrappers in `generate_job.rs`. Wire all ten RPC methods in `rpc.rs`. #### Step 3 - Cleanup Remove `user_instruction` plumbing from `handle_fix_theme` / `handle_rewrite_theme` and from the JS Fix/Rewrite paths. Remove the always-visible Theme AI Instruction panel from HTML, CSS, and JS. #### Step 4 - Theme editor UI Add `Instruct` topbar button and hidden `#theme-instruct-panel` (mirroring slide pattern). Implement the theme-scoped JS helpers and `executeThemeInstruct`. #### Step 5 - Instructions editor UI Same as Step 4 but scoped to the instructions editor, using `instrDeckPath`. #### Step 6 - OpenRPC spec Add the ten new method entries to `openrpc.json`. #### Step 7 - Verify `cargo build --workspace` + `cargo test --workspace` + manual UI test of both new Instruct flows with and without background folders, with and without voice input. ### Acceptance Criteria - [ ] Theme editor has no always-visible "AI Instruction" panel; its topbar has Fix, Rewrite, and a new Instruct button that toggles a hidden panel matching the slide editor pattern. - [ ] Instructions editor topbar has an Instruct button that toggles a hidden panel matching the slide editor pattern. - [ ] `executeThemeInstruct` and `executeInstructionsInstruct` call their respective async-job RPC families and update the textarea + preview on success. - [ ] Voice dictation works in both new panels. - [ ] Background-folder checklist appears when the deck has background folders and is forwarded to the backend. - [ ] `system_instruct_theme.md` and `system_instruct_instructions.md` are registered in `ALL_TEMPLATES` and embedded via `include_str!`. - [ ] All ten new RPC methods are documented in `openrpc.json`. - [ ] `cargo build --workspace` succeeds; `cargo test --workspace` passes. ### Notes - Fix and Rewrite keep their existing behavior but lose the `user_instruction` param; any natural-language guidance now flows through the dedicated Instruct panel. - The existing async-job polling helper `pollContentJob` is reusable verbatim for both new panels. - The background-folders integration (`bg.listFolders`, `instruct-bg-list`) is copied wholesale from the slide pattern; no backend changes needed on that RPC.
Author
Member

Test Results

  • Total: 62
  • Passed: 62
  • Failed: 0
  • Ignored: 1 (AI integration test gated on OPENROUTER_API_KEY)

cargo check --workspace: clean (one pre-existing unrelated unused-imports warning in hero_slides_ui/src/routes.rs).
cargo test --workspace: all suites pass.

## Test Results - Total: 62 - Passed: 62 - Failed: 0 - Ignored: 1 (AI integration test gated on OPENROUTER_API_KEY) `cargo check --workspace`: clean (one pre-existing unrelated unused-imports warning in `hero_slides_ui/src/routes.rs`). `cargo test --workspace`: all suites pass.
Author
Member

Implementation Summary

Theme editor now matches the instructions editor layout and both editors gained the slide-level Instruct feature.

Changes

Prompts (new)

  • crates/hero_slides_lib/src/prompts/system_instruct_theme.md
  • crates/hero_slides_lib/src/prompts/system_instruct_instructions.md
  • Registered in crates/hero_slides_lib/src/prompts.rs (DEFAULT_SYSTEM_INSTRUCT_THEME, DEFAULT_SYSTEM_INSTRUCT_INSTRUCTIONS, added to ALL_TEMPLATES).

Backend handlers

  • crates/hero_slides_server/src/agent.rs: added handle_instruct_theme, handle_instruct_instructions; removed user_instruction plumbing from handle_fix_theme and handle_rewrite_theme.
  • crates/hero_slides_server/src/generate_job.rs: added async-job helpers and handlers for both theme and instructions Instruct flows.
  • crates/hero_slides_server/src/rpc.rs: wired ten new RPC methods.
  • crates/hero_slides_lib/src/generator.rs: added instruct_theme_content and instruct_instructions_content.
  • crates/hero_slides_lib/src/lib.rs: re-exports for the two new generator helpers.

Rhai scripts and CLI

  • crates/hero_slides_rhai/scripts/instruct_theme.rhai
  • crates/hero_slides_rhai/scripts/instruct_instructions.rhai
  • crates/hero_slides_rhai/src/deck_module.rs: registered deck_instruct_theme and deck_instruct_instructions Rhai functions.
  • crates/hero_slides/src/main.rs: added "instruct_theme" and "instruct_instructions" arms to load_builtin.

OpenRPC spec

  • crates/hero_slides_server/openrpc.json: documented ten new methods: deck.instructTheme, deck.instructThemeAsync, deck.instructThemeJobStatus, deck.instructThemeJobLogs, deck.instructThemeResult, plus the five deck.instructInstructions* equivalents.

Frontend

  • crates/hero_slides_ui/templates/index.html:
    • Removed the always-visible "AI Instruction" panel from the theme editor.
    • Added topbar Instruct buttons and hidden instruct panels to both theme and instructions editors.
  • crates/hero_slides_ui/static/js/dashboard.js:
    • Removed user_instruction plumbing from fixThemeContent / rewriteThemeContent and the obsolete theme-instruct voice helpers.
    • Added 16 new functions covering panel toggle, background-folder loading, execute, and voice dictation for both editors.
    • Both openThemeEditor and openInstructionsEditor now reset their new instruct panels on open.
    • Instructions editor's Instruct flow integrates with the existing instrHistoryPush so AI-applied content becomes an undoable history entry.

Verification

  • cargo check --workspace: clean.
  • cargo test --workspace: 62 passed, 0 failed, 1 ignored (AI-gated).
  • UI follows the slide editor's Instruct pattern exactly: Instruct button → hidden panel toggle → instruction textarea with voice dictation → optional background-folders checklist → Apply → async job polling → textarea update.
## Implementation Summary Theme editor now matches the instructions editor layout and both editors gained the slide-level Instruct feature. ### Changes **Prompts (new)** - `crates/hero_slides_lib/src/prompts/system_instruct_theme.md` - `crates/hero_slides_lib/src/prompts/system_instruct_instructions.md` - Registered in `crates/hero_slides_lib/src/prompts.rs` (`DEFAULT_SYSTEM_INSTRUCT_THEME`, `DEFAULT_SYSTEM_INSTRUCT_INSTRUCTIONS`, added to `ALL_TEMPLATES`). **Backend handlers** - `crates/hero_slides_server/src/agent.rs`: added `handle_instruct_theme`, `handle_instruct_instructions`; removed `user_instruction` plumbing from `handle_fix_theme` and `handle_rewrite_theme`. - `crates/hero_slides_server/src/generate_job.rs`: added async-job helpers and handlers for both theme and instructions Instruct flows. - `crates/hero_slides_server/src/rpc.rs`: wired ten new RPC methods. - `crates/hero_slides_lib/src/generator.rs`: added `instruct_theme_content` and `instruct_instructions_content`. - `crates/hero_slides_lib/src/lib.rs`: re-exports for the two new generator helpers. **Rhai scripts and CLI** - `crates/hero_slides_rhai/scripts/instruct_theme.rhai` - `crates/hero_slides_rhai/scripts/instruct_instructions.rhai` - `crates/hero_slides_rhai/src/deck_module.rs`: registered `deck_instruct_theme` and `deck_instruct_instructions` Rhai functions. - `crates/hero_slides/src/main.rs`: added `"instruct_theme"` and `"instruct_instructions"` arms to `load_builtin`. **OpenRPC spec** - `crates/hero_slides_server/openrpc.json`: documented ten new methods: `deck.instructTheme`, `deck.instructThemeAsync`, `deck.instructThemeJobStatus`, `deck.instructThemeJobLogs`, `deck.instructThemeResult`, plus the five `deck.instructInstructions*` equivalents. **Frontend** - `crates/hero_slides_ui/templates/index.html`: - Removed the always-visible "AI Instruction" panel from the theme editor. - Added topbar `Instruct` buttons and hidden instruct panels to both theme and instructions editors. - `crates/hero_slides_ui/static/js/dashboard.js`: - Removed `user_instruction` plumbing from `fixThemeContent` / `rewriteThemeContent` and the obsolete theme-instruct voice helpers. - Added 16 new functions covering panel toggle, background-folder loading, execute, and voice dictation for both editors. - Both `openThemeEditor` and `openInstructionsEditor` now reset their new instruct panels on open. - Instructions editor's Instruct flow integrates with the existing `instrHistoryPush` so AI-applied content becomes an undoable history entry. ### Verification - `cargo check --workspace`: clean. - `cargo test --workspace`: 62 passed, 0 failed, 1 ignored (AI-gated). - UI follows the slide editor's Instruct pattern exactly: Instruct button → hidden panel toggle → instruction textarea with voice dictation → optional background-folders checklist → Apply → async job polling → textarea update.
Author
Member

Pull request opened: #14

This PR implements the changes discussed in this issue.

Pull request opened: https://forge.ourworld.tf/lhumina_code/hero_slides/pulls/14 This PR implements the changes discussed in this issue.
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#4
No description provided.