Add AI fix and rewrite to theme editor #4
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?
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
Implementation Spec for Issue #4
Objective
Add
deck.fixThemeanddeck.rewriteThememethod 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
deck.fixThememethod definition toopenrpc.jsonwith params:content(required),deck_path(optional),user_instruction(optional)deck.rewriteThememethod definition toopenrpc.jsonwith the same paramsopenrpc.client.generated.rsto include typeddeck_fix_theme()anddeck_rewrite_theme()methodsFiles to Modify
crates/hero_slides_server/openrpc.json-- Add two new method definitions following the existingdeck.fixInstructions/deck.rewriteInstructionspatterncrates/hero_slides_server/openrpc.client.generated.rs-- Regenerate or manually add two client methodsImplementation Plan
Step 1: Add
deck.fixThemeanddeck.rewriteThemeto OpenRPC specFile:
crates/hero_slides_server/openrpc.jsondeck.fixThememethod entry afterdeck.rewriteInstructions, following the same structure asdeck.fixInstructionsdeck.rewriteThememethod entry immediately after, following thedeck.rewriteInstructionspatterncontent(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.rsDeckFixThemeInput,DeckFixThemeOutput,DeckRewriteThemeInput,DeckRewriteThemeOutputstructsdeck_fix_theme()anddeck_rewrite_theme()methods on the clientStep 3: Verify compilation
cargo buildandcargo testto ensure everything compiles and passesAcceptance Criteria
deck.fixThememethod defined inopenrpc.jsonwith correct paramsdeck.rewriteThememethod defined inopenrpc.jsonwith correct paramsopenrpc.client.generated.rscontains typed methods for bothNotes
user_instructionparameter exists in the runtime implementation but is absent from the existingdeck.fixInstructionsanddeck.rewriteInstructionsOpenRPC entries as well. This is out of scope for this issue but worth noting.Implementation Spec for Issue #4 (updated)
Objective
Add
deck.fixThemeanddeck.rewriteThememethod 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
deck.fixThememethod definition toopenrpc.jsonwith params:content(required),deck_path(optional),user_instruction(optional)deck.rewriteThememethod definition toopenrpc.jsonwith the same paramsopenrpc.client.generated.rsto include typeddeck_fix_theme()anddeck_rewrite_theme()methodsuser_instructioninput, using the same recording pipeline (startRecording/stopRecording/sendAudioToServer) and visual states as the instructions editorFiles to Modify
crates/hero_slides_server/openrpc.json-- Add two new method definitions following thedeck.fixInstructions/deck.rewriteInstructionspatterncrates/hero_slides_server/openrpc.client.generated.rs-- Add typed client methodscrates/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 counterpartscrates/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 editorImplementation Plan
Step 1: Add
deck.fixThemeanddeck.rewriteThemeto OpenRPC specFile:
crates/hero_slides_server/openrpc.jsondeck.fixThemeanddeck.rewriteThememethod entries afterdeck.rewriteInstructionscontent(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.rsDeckFixThemeInput,DeckFixThemeOutput,DeckRewriteThemeInput,DeckRewriteThemeOutputstructsdeck_fix_theme()anddeck_rewrite_theme()methods on the clientStep 3: Verify and complete voice-dictation parity
Files:
crates/hero_slides_ui/templates/index.html,crates/hero_slides_ui/static/js/dashboard.jsuser_instructioninput, mirroring the instructions editor's button placement and iconsstartRecording/stopRecording/sendAudioToServerindashboard.jscorrectly branch on the active theme overlay and write transcribed text back into the right target (main textarea vs. instruct input), matching the instructions-editor behaviorStep 4: Verify compilation and tests
cargo buildandcargo testto ensure everything compiles and passesAcceptance Criteria
deck.fixThememethod defined inopenrpc.jsonwith correct paramsdeck.rewriteThememethod defined inopenrpc.jsonwith correct paramsopenrpc.client.generated.rscontains typed methods for bothuser_instructioninput, with the same UX as the instructions editorNotes
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
executeInstruct+system_instruct_slide.md+slide.instructContent*RPC family) into the theme editor.Reference: slide Instruct pattern (already implemented)
btn-instruct-slide->toggleInstructPanel()#instruct-panelwith:#instruct-inputstartInstructRecording()/stopInstructRecording()/transcribeInstructAudio()bg.listFolders->renderInstructBgList)#btn-instruct-go->executeInstruct()executeInstruct()callsslide.instructContentAsync, polls viaslide.instructContentJobStatus, retrieves viaslide.instructContentResult, using the sharedpollContentJobhelperhandle_instruct_slide_contentinagent.rs+ async job family ingenerate_job.rs, usingsystem_instruct_slide.mdRequirements
Instructbutton identical in style/placement tobtn-instruct-slide, toggling a new hidden-by-default#theme-instruct-panel.theme-instruct-paneland associated functions/handlers (which funneled auser_instructionparam intodeck.fixTheme/deck.rewriteTheme) are removed;user_instructionis no longer forwarded from Fix/Rewrite. (Fix and Rewrite remain; only the persistent instruction panel and its plumbing go.)Instructbutton and hidden panel.slide.instructContent*:deck.instructTheme,deck.instructThemeAsync,deck.instructThemeJobStatus,deck.instructThemeJobLogs,deck.instructThemeResultdeck.instructInstructions,deck.instructInstructionsAsync,deck.instructInstructionsJobStatus,deck.instructInstructionsJobLogs,deck.instructInstructionsResultsystem_instruct_theme.md,system_instruct_instructions.md, both registered inALL_TEMPLATESand embedded viainclude_str!.Files to Modify
crates/hero_slides_ui/templates/index.htmlInstructtopbar button and a new hidden#theme-instruct-panelmodeled on#instruct-panel.Instructtopbar button and a new hidden#instructions-instruct-panel.crates/hero_slides_ui/static/js/dashboard.jsstartThemeInstructRecording/stopThemeInstructRecordingand theuser_instructionbranches insidefixThemeContent/rewriteThemeContent.toggleThemeInstructPanel,loadThemeInstructBgFolders,renderThemeInstructBgList,toggleThemeInstructBgFolder,executeThemeInstruct, plus voice functions targeting the new panel.toggleInstructionsInstructPanel, etc., usinginstrDeckPath).crates/hero_slides_server/src/rpc.rscrates/hero_slides_server/src/agent.rshandle_instruct_themeandhandle_instruct_instructions, modeled onhandle_instruct_slide_content, using the two new prompts.user_instructionhandling added tohandle_fix_theme/handle_rewrite_theme(now out of scope).crates/hero_slides_server/src/generate_job.rscrates/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.rsDEFAULT_SYSTEM_INSTRUCT_THEMEandDEFAULT_SYSTEM_INSTRUCT_INSTRUCTIONSconstants and register both inALL_TEMPLATES.crates/hero_slides_server/openrpc.jsonslide.instructContent*entries.Implementation Plan
Step 1 - Prompts
Create
system_instruct_theme.mdandsystem_instruct_instructions.md, adaptingsystem_instruct_slide.mdfor theme and instructions contexts. Register both inprompts.rs.Step 2 - Backend handlers
Add
handle_instruct_themeandhandle_instruct_instructionsinagent.rs. Add async-job wrappers ingenerate_job.rs. Wire all ten RPC methods inrpc.rs.Step 3 - Cleanup
Remove
user_instructionplumbing fromhandle_fix_theme/handle_rewrite_themeand 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
Instructtopbar button and hidden#theme-instruct-panel(mirroring slide pattern). Implement the theme-scoped JS helpers andexecuteThemeInstruct.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
executeThemeInstructandexecuteInstructionsInstructcall their respective async-job RPC families and update the textarea + preview on success.system_instruct_theme.mdandsystem_instruct_instructions.mdare registered inALL_TEMPLATESand embedded viainclude_str!.openrpc.json.cargo build --workspacesucceeds;cargo test --workspacepasses.Notes
user_instructionparam; any natural-language guidance now flows through the dedicated Instruct panel.pollContentJobis reusable verbatim for both new panels.bg.listFolders,instruct-bg-list) is copied wholesale from the slide pattern; no backend changes needed on that RPC.Test Results
cargo check --workspace: clean (one pre-existing unrelated unused-imports warning inhero_slides_ui/src/routes.rs).cargo test --workspace: all suites pass.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.mdcrates/hero_slides_lib/src/prompts/system_instruct_instructions.mdcrates/hero_slides_lib/src/prompts.rs(DEFAULT_SYSTEM_INSTRUCT_THEME,DEFAULT_SYSTEM_INSTRUCT_INSTRUCTIONS, added toALL_TEMPLATES).Backend handlers
crates/hero_slides_server/src/agent.rs: addedhandle_instruct_theme,handle_instruct_instructions; removeduser_instructionplumbing fromhandle_fix_themeandhandle_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: addedinstruct_theme_contentandinstruct_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.rhaicrates/hero_slides_rhai/scripts/instruct_instructions.rhaicrates/hero_slides_rhai/src/deck_module.rs: registereddeck_instruct_themeanddeck_instruct_instructionsRhai functions.crates/hero_slides/src/main.rs: added"instruct_theme"and"instruct_instructions"arms toload_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 fivedeck.instructInstructions*equivalents.Frontend
crates/hero_slides_ui/templates/index.html:Instructbuttons and hidden instruct panels to both theme and instructions editors.crates/hero_slides_ui/static/js/dashboard.js:user_instructionplumbing fromfixThemeContent/rewriteThemeContentand the obsolete theme-instruct voice helpers.openThemeEditorandopenInstructionsEditornow reset their new instruct panels on open.instrHistoryPushso AI-applied content becomes an undoable history entry.Verification
cargo check --workspace: clean.cargo test --workspace: 62 passed, 0 failed, 1 ignored (AI-gated).Pull request opened: #14
This PR implements the changes discussed in this issue.