pdf/image to instructions #67
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?
Implementation Spec: Issue #67 — PDF/Image to Instructions
Objective
Extend the "Extract from image / PDF" feature so it targets the instructions.md file (not just theme.md), adds clipboard paste as an input method, wraps the operation in a trackable background job (via the existing
pollAiJob/JobManagerinfrastructure), improves the AI prompt for instructions extraction, and exposessystem_extract_instructions_from_image.mdas a user-editable prompt template.Current State Summary
bgExtractThemeFromFile()indashboard.jsopens a file picker, reads base64, callsbg.extractThemeAsyncviapollAiJob. This saves totheme.md.bg.extractThemeAsynchandler ingenerate_job.rscallsresolve_extract_theme_source()(accepts{data, mime_type}for inline base64 OR{folder, file}for on-disk files), then submits a CLI job viasubmit_extract_theme_job().hero_slides theme extract <unc> --from <file>, which callsextract_theme_from_image()/extract_theme_from_pdf()ingenerator.rs, backed bysystem_extract_theme.mdprompt.system_extract_theme.mdprompt is inALL_TEMPLATESand editable via the Templates tab.pollAiJobpollsagent.aiJobResultat 800ms intervals; ondoneit returnsstatus.resultcontaining{ content }.instruct_instructionsmodifies existing instructions but there is no "extract instructions from visual reference" path.Requirements
instructions.mdpollAiJob/JobManager— same pattern asbg.extractThemeAsyncsystem_extract_instructions_from_image.mdmust produce well-structuredinstructions.mdcontent (audience, tone, structure, key messages, slide outline, goals) from slide imagesALL_TEMPLATESinprompts.rsandTEMPLATE_TO_PROMPT_KEYindashboard.js)Files to Modify or Create
crates/hero_slides_lib/src/prompts/system_extract_instructions_from_image.mdcrates/hero_slides_lib/src/prompts.rscrates/hero_slides_lib/src/generator.rsextract_instructions_from_image()andextract_instructions_from_pdf()crates/hero_slides_server/src/generate_job.rsbg.extractInstructionsAsynccrates/hero_slides_server/src/rpc.rsbg.extractInstructionsAsyncto the new handlercrates/hero_slides_admin/static/js/dashboard.jsbgExtractInstructionsFromFile(), clipboard paste handler, template keycrates/hero_slides_admin/templates/index.htmlImplementation Plan
Step 1: Create the AI prompt template
File:
crates/hero_slides_lib/src/prompts/system_extract_instructions_from_image.mdDependencies: none
Create the prompt instructing the AI to analyze slide images/PDFs and produce a structured
instructions.mdcovering: audience, tone, key messages, slide structure/outline, and goals. Output must begin with# Deck Instructionsand use##subheadings. No explanations, no code fences, no preamble — only the instructions.md content.Step 2: Register the template in
prompts.rsFile:
crates/hero_slides_lib/src/prompts.rsDependencies: Step 1
Add
pub const DEFAULT_SYSTEM_EXTRACT_INSTRUCTIONS_FROM_IMAGEconstant and add it toALL_TEMPLATES.Step 3: Add extraction functions to
generator.rsFile:
crates/hero_slides_lib/src/generator.rsDependencies: Step 2
Add
extract_instructions_from_image()andextract_instructions_from_pdf()mirroring the existing theme extraction functions, using the new prompt keysystem_extract_instructions_from_image.md.Step 4: Add the CLI subcommand
File:
crates/hero_slides/src/main.rs+ relevant rhai moduleDependencies: Step 3
Add
hero_slides instructions extract <unc> --from <file>CLI command mirroringtheme extract, calling the new generator functions and writing result toinstructions.md.Step 5: Add backend job submission and handler
File:
crates/hero_slides_server/src/generate_job.rsDependencies: Step 4
Add
submit_extract_instructions_job()andhandle_bg_extract_instructions_async()(plus status/logs handlers) mirroring the theme extraction job pattern. AddJobKind::ExtractInstructionsvariant.Step 6: Route the new RPC method
File:
crates/hero_slides_server/src/rpc.rsDependencies: Step 5
Route
bg.extractInstructionsAsync,bg.extractInstructionsJobStatus,bg.extractInstructionsJobLogsto the new handlers.Step 7: Add clipboard paste support +
bgExtractInstructionsFromFiletodashboard.jsFile:
crates/hero_slides_admin/static/js/dashboard.jsDependencies: Steps 5–6
Add
bgExtractInstructionsFromFile()callingpollAiJob('bg.extractInstructionsAsync', ...), add a globalpasteevent listener that detects image clipboard data and routes to instructions or theme extraction based on which editor is active, and register the new template key inTEMPLATE_TO_PROMPT_KEY.Step 8: Add UI button to
index.htmlFile:
crates/hero_slides_admin/templates/index.htmlDependencies: Step 7
Add "Extract from image / PDF" button in the Instructions editor section and a paste hint (Ctrl+V).
Acceptance Criteria
Notes
pollAiJobpattern already provides job tracking; the new method just needs the sameregister_with_manager_inputscall with a temp output file ingenerate_job.rs.resolve_extract_theme_sourceis reusable for the instructions extraction since the input shape (base64 inline or folder/file) is identical.ExtractInstructionstoJobKindrequires updating bothas_str()anddefault_timeout()injobs/types.rs.Implementation Spec: Issue #67 — PDF/Image to Instructions
Objective
Extend the "Extract from image / PDF" feature so it targets the instructions.md file (not just theme.md), adds clipboard paste as an input method, wraps the operation in a trackable background job (via the existing
pollAiJob/JobManagerinfrastructure), improves the AI prompt for instructions extraction, and exposessystem_extract_instructions_from_image.mdas a user-editable prompt template.Current State Summary
bgExtractThemeFromFile()indashboard.jsopens a file picker, reads base64, callsbg.extractThemeAsyncviapollAiJob. This saves totheme.md.bg.extractThemeAsynchandler ingenerate_job.rscallsresolve_extract_theme_source()(accepts{data, mime_type}for inline base64 OR{folder, file}for on-disk files), then submits a CLI job viasubmit_extract_theme_job().hero_slides theme extract <unc> --from <file>, which callsextract_theme_from_image()/extract_theme_from_pdf()ingenerator.rs, backed bysystem_extract_theme.mdprompt.system_extract_theme.mdprompt is inALL_TEMPLATESand editable via the Templates tab.pollAiJobpollsagent.aiJobResultat 800ms intervals; ondoneit returnsstatus.resultcontaining{ content }.instruct_instructionsmodifies existing instructions but there is no "extract instructions from visual reference" path.Requirements
instructions.mdpollAiJob/JobManager— same pattern asbg.extractThemeAsyncsystem_extract_instructions_from_image.mdmust produce well-structuredinstructions.mdcontent (audience, tone, structure, key messages, slide outline, goals) from slide imagesALL_TEMPLATESinprompts.rsandTEMPLATE_TO_PROMPT_KEYindashboard.js)Files to Modify or Create
crates/hero_slides_lib/src/prompts/system_extract_instructions_from_image.mdcrates/hero_slides_lib/src/prompts.rscrates/hero_slides_lib/src/generator.rsextract_instructions_from_image()andextract_instructions_from_pdf()crates/hero_slides_server/src/generate_job.rsbg.extractInstructionsAsynccrates/hero_slides_server/src/rpc.rsbg.extractInstructionsAsyncto the new handlercrates/hero_slides_admin/static/js/dashboard.jsbgExtractInstructionsFromFile(), clipboard paste handler, template keycrates/hero_slides_admin/templates/index.htmlImplementation Plan
Step 1: Create the AI prompt template
File:
crates/hero_slides_lib/src/prompts/system_extract_instructions_from_image.mdDependencies: none
Create the prompt instructing the AI to analyze slide images/PDFs and produce a structured
instructions.mdcovering: audience, tone, key messages, slide structure/outline, and goals. Output must begin with# Deck Instructionsand use##subheadings. No explanations, no code fences, no preamble — only the instructions.md content.Step 2: Register the template in
prompts.rsFile:
crates/hero_slides_lib/src/prompts.rsDependencies: Step 1
Add
pub const DEFAULT_SYSTEM_EXTRACT_INSTRUCTIONS_FROM_IMAGEconstant and add it toALL_TEMPLATES.Step 3: Add extraction functions to
generator.rsFile:
crates/hero_slides_lib/src/generator.rsDependencies: Step 2
Add
extract_instructions_from_image()andextract_instructions_from_pdf()mirroring the existing theme extraction functions, using the new prompt keysystem_extract_instructions_from_image.md.Step 4: Add the CLI subcommand
File:
crates/hero_slides/src/main.rs+ relevant rhai moduleDependencies: Step 3
Add
hero_slides instructions extract <unc> --from <file>CLI command mirroringtheme extract, calling the new generator functions and writing result toinstructions.md.Step 5: Add backend job submission and handler
File:
crates/hero_slides_server/src/generate_job.rsDependencies: Step 4
Add
submit_extract_instructions_job()andhandle_bg_extract_instructions_async()(plus status/logs handlers) mirroring the theme extraction job pattern. AddJobKind::ExtractInstructionsvariant.Step 6: Route the new RPC method
File:
crates/hero_slides_server/src/rpc.rsDependencies: Step 5
Route
bg.extractInstructionsAsync,bg.extractInstructionsJobStatus,bg.extractInstructionsJobLogsto the new handlers.Step 7: Add clipboard paste support +
bgExtractInstructionsFromFiletodashboard.jsFile:
crates/hero_slides_admin/static/js/dashboard.jsDependencies: Steps 5–6
Add
bgExtractInstructionsFromFile()callingpollAiJob('bg.extractInstructionsAsync', ...), add a globalpasteevent listener that detects image clipboard data and routes to instructions or theme extraction based on which editor is active, and register the new template key inTEMPLATE_TO_PROMPT_KEY.Step 8: Add UI button to
index.htmlFile:
crates/hero_slides_admin/templates/index.htmlDependencies: Step 7
Add "Extract from image / PDF" button in the Instructions editor section and a paste hint (Ctrl+V).
Acceptance Criteria
Notes
pollAiJobpattern already provides job tracking; the new method just needs the sameregister_with_manager_inputscall with a temp output file ingenerate_job.rs.resolve_extract_theme_sourceis reusable for the instructions extraction since the input shape (base64 inline or folder/file) is identical.ExtractInstructionstoJobKindrequires updating bothas_str()anddefault_timeout()injobs/types.rs.Implementation Spec: Issue #67 — PDF/Image to Instructions
Objective
Extend the "Extract from image / PDF" feature so it targets the instructions.md file (not just theme.md), adds clipboard paste as an input method, wraps the operation in a trackable background job (via the existing
pollAiJob/JobManagerinfrastructure), improves the AI prompt for instructions extraction, and exposessystem_extract_instructions_from_image.mdas a user-editable prompt template.Current State Summary
bgExtractThemeFromFile()indashboard.jsopens a file picker, reads base64, callsbg.extractThemeAsyncviapollAiJob. This saves totheme.md.bg.extractThemeAsynchandler ingenerate_job.rscallsresolve_extract_theme_source()(accepts{data, mime_type}for inline base64 OR{folder, file}for on-disk files), then submits a CLI job viasubmit_extract_theme_job().hero_slides theme extract <unc> --from <file>, which callsextract_theme_from_image()/extract_theme_from_pdf()ingenerator.rs, backed bysystem_extract_theme.mdprompt.system_extract_theme.mdprompt is inALL_TEMPLATESand editable via the Templates tab.pollAiJobpollsagent.aiJobResultat 800ms intervals; ondoneit returnsstatus.resultcontaining{ content }.instruct_instructionsmodifies existing instructions but there is no "extract instructions from visual reference" path.Requirements
instructions.mdpollAiJob/JobManager— same pattern asbg.extractThemeAsyncsystem_extract_instructions_from_image.mdmust produce well-structuredinstructions.mdcontent (audience, tone, structure, key messages, slide outline, goals) from slide imagesALL_TEMPLATESinprompts.rsandTEMPLATE_TO_PROMPT_KEYindashboard.js)Files to Modify or Create
crates/hero_slides_lib/src/prompts/system_extract_instructions_from_image.mdcrates/hero_slides_lib/src/prompts.rscrates/hero_slides_lib/src/generator.rsextract_instructions_from_image()andextract_instructions_from_pdf()crates/hero_slides_server/src/generate_job.rsbg.extractInstructionsAsynccrates/hero_slides_server/src/rpc.rsbg.extractInstructionsAsyncto the new handlercrates/hero_slides_admin/static/js/dashboard.jsbgExtractInstructionsFromFile(), clipboard paste handler, template keycrates/hero_slides_admin/templates/index.htmlImplementation Plan
Step 1: Create the AI prompt template
File:
crates/hero_slides_lib/src/prompts/system_extract_instructions_from_image.mdDependencies: none
Create the prompt instructing the AI to analyze slide images/PDFs and produce a structured
instructions.mdcovering: audience, tone, key messages, slide structure/outline, and goals. Output must begin with# Deck Instructionsand use##subheadings. No explanations, no code fences, no preamble — only the instructions.md content.Step 2: Register the template in
prompts.rsFile:
crates/hero_slides_lib/src/prompts.rsDependencies: Step 1
Add
pub const DEFAULT_SYSTEM_EXTRACT_INSTRUCTIONS_FROM_IMAGEconstant and add it toALL_TEMPLATES.Step 3: Add extraction functions to
generator.rsFile:
crates/hero_slides_lib/src/generator.rsDependencies: Step 2
Add
extract_instructions_from_image()andextract_instructions_from_pdf()mirroring the existing theme extraction functions, using the new prompt keysystem_extract_instructions_from_image.md.Step 4: Add the CLI subcommand
File:
crates/hero_slides/src/main.rs+ relevant rhai moduleDependencies: Step 3
Add
hero_slides instructions extract <unc> --from <file>CLI command mirroringtheme extract, calling the new generator functions and writing result toinstructions.md.Step 5: Add backend job submission and handler
File:
crates/hero_slides_server/src/generate_job.rsDependencies: Step 4
Add
submit_extract_instructions_job()andhandle_bg_extract_instructions_async()(plus status/logs handlers) mirroring the theme extraction job pattern. AddJobKind::ExtractInstructionsvariant.Step 6: Route the new RPC method
File:
crates/hero_slides_server/src/rpc.rsDependencies: Step 5
Route
bg.extractInstructionsAsync,bg.extractInstructionsJobStatus,bg.extractInstructionsJobLogsto the new handlers.Step 7: Add clipboard paste support +
bgExtractInstructionsFromFiletodashboard.jsFile:
crates/hero_slides_admin/static/js/dashboard.jsDependencies: Steps 5–6
Add
bgExtractInstructionsFromFile()callingpollAiJob('bg.extractInstructionsAsync', ...), add a globalpasteevent listener that detects image clipboard data and routes to instructions or theme extraction based on which editor is active, and register the new template key inTEMPLATE_TO_PROMPT_KEY.Step 8: Add UI button to
index.htmlFile:
crates/hero_slides_admin/templates/index.htmlDependencies: Step 7
Add "Extract from image / PDF" button in the Instructions editor section and a paste hint (Ctrl+V).
Acceptance Criteria
Notes
pollAiJobpattern already provides job tracking; the new method just needs the sameregister_with_manager_inputscall with a temp output file ingenerate_job.rs.resolve_extract_theme_sourceis reusable for the instructions extraction since the input shape (base64 inline or folder/file) is identical.ExtractInstructionstoJobKindrequires updating bothas_str()anddefault_timeout()injobs/types.rs.Implementation Spec: Issue #67 — PDF/Image to Instructions
Objective
Extend the "Extract from image / PDF" feature so it targets the instructions.md file (not just theme.md), adds clipboard paste as an input method, wraps the operation in a trackable background job (via the existing
pollAiJob/JobManagerinfrastructure), improves the AI prompt for instructions extraction, and exposessystem_extract_instructions_from_image.mdas a user-editable prompt template.Current State Summary
bgExtractThemeFromFile()indashboard.jsopens a file picker, reads base64, callsbg.extractThemeAsyncviapollAiJob. This saves totheme.md.bg.extractThemeAsynchandler ingenerate_job.rscallsresolve_extract_theme_source()(accepts{data, mime_type}for inline base64 OR{folder, file}for on-disk files), then submits a CLI job viasubmit_extract_theme_job().hero_slides theme extract <unc> --from <file>, which callsextract_theme_from_image()/extract_theme_from_pdf()ingenerator.rs, backed bysystem_extract_theme.mdprompt.system_extract_theme.mdprompt is inALL_TEMPLATESand editable via the Templates tab.pollAiJobpollsagent.aiJobResultat 800ms intervals; ondoneit returnsstatus.resultcontaining{ content }.instruct_instructionsmodifies existing instructions but there is no "extract instructions from visual reference" path.Requirements
instructions.mdpollAiJob/JobManager— same pattern asbg.extractThemeAsyncsystem_extract_instructions_from_image.mdmust produce well-structuredinstructions.mdcontent (audience, tone, structure, key messages, slide outline, goals) from slide imagesALL_TEMPLATESinprompts.rsandTEMPLATE_TO_PROMPT_KEYindashboard.js)Files to Modify or Create
crates/hero_slides_lib/src/prompts/system_extract_instructions_from_image.mdcrates/hero_slides_lib/src/prompts.rscrates/hero_slides_lib/src/generator.rsextract_instructions_from_image()andextract_instructions_from_pdf()crates/hero_slides_server/src/generate_job.rsbg.extractInstructionsAsynccrates/hero_slides_server/src/rpc.rsbg.extractInstructionsAsyncto the new handlercrates/hero_slides_admin/static/js/dashboard.jsbgExtractInstructionsFromFile(), clipboard paste handler, template keycrates/hero_slides_admin/templates/index.htmlImplementation Plan
Step 1: Create the AI prompt template
File:
crates/hero_slides_lib/src/prompts/system_extract_instructions_from_image.mdDependencies: none
Create the prompt instructing the AI to analyze slide images/PDFs and produce a structured
instructions.mdcovering: audience, tone, key messages, slide structure/outline, and goals. Output must begin with# Deck Instructionsand use##subheadings. No explanations, no code fences, no preamble — only the instructions.md content.Step 2: Register the template in
prompts.rsFile:
crates/hero_slides_lib/src/prompts.rsDependencies: Step 1
Add
pub const DEFAULT_SYSTEM_EXTRACT_INSTRUCTIONS_FROM_IMAGEconstant and add it toALL_TEMPLATES.Step 3: Add extraction functions to
generator.rsFile:
crates/hero_slides_lib/src/generator.rsDependencies: Step 2
Add
extract_instructions_from_image()andextract_instructions_from_pdf()mirroring the existing theme extraction functions, using the new prompt keysystem_extract_instructions_from_image.md.Step 4: Add the CLI subcommand
File:
crates/hero_slides/src/main.rs+ relevant rhai moduleDependencies: Step 3
Add
hero_slides instructions extract <unc> --from <file>CLI command mirroringtheme extract, calling the new generator functions and writing result toinstructions.md.Step 5: Add backend job submission and handler
File:
crates/hero_slides_server/src/generate_job.rsDependencies: Step 4
Add
submit_extract_instructions_job()andhandle_bg_extract_instructions_async()(plus status/logs handlers) mirroring the theme extraction job pattern. AddJobKind::ExtractInstructionsvariant.Step 6: Route the new RPC method
File:
crates/hero_slides_server/src/rpc.rsDependencies: Step 5
Route
bg.extractInstructionsAsync,bg.extractInstructionsJobStatus,bg.extractInstructionsJobLogsto the new handlers.Step 7: Add clipboard paste support +
bgExtractInstructionsFromFiletodashboard.jsFile:
crates/hero_slides_admin/static/js/dashboard.jsDependencies: Steps 5–6
Add
bgExtractInstructionsFromFile()callingpollAiJob('bg.extractInstructionsAsync', ...), add a globalpasteevent listener that detects image clipboard data and routes to instructions or theme extraction based on which editor is active, and register the new template key inTEMPLATE_TO_PROMPT_KEY.Step 8: Add UI button to
index.htmlFile:
crates/hero_slides_admin/templates/index.htmlDependencies: Step 7
Add "Extract from image / PDF" button in the Instructions editor section and a paste hint (Ctrl+V).
Acceptance Criteria
Notes
pollAiJobpattern already provides job tracking; the new method just needs the sameregister_with_manager_inputscall with a temp output file ingenerate_job.rs.resolve_extract_theme_sourceis reusable for the instructions extraction since the input shape (base64 inline or folder/file) is identical.ExtractInstructionstoJobKindrequires updating bothas_str()anddefault_timeout()injobs/types.rs.Implementation Spec: Issue #67 — PDF/Image to Instructions
Objective
Extend the "Extract from image / PDF" feature so it targets the instructions.md file (not just theme.md), adds clipboard paste as an input method, wraps the operation in a trackable background job (via the existing
pollAiJob/JobManagerinfrastructure), improves the AI prompt for instructions extraction, and exposessystem_extract_instructions_from_image.mdas a user-editable prompt template.Current State Summary
bgExtractThemeFromFile()indashboard.jsopens a file picker, reads base64, callsbg.extractThemeAsyncviapollAiJob. This saves totheme.md.bg.extractThemeAsynchandler ingenerate_job.rscallsresolve_extract_theme_source()(accepts{data, mime_type}for inline base64 OR{folder, file}for on-disk files), then submits a CLI job viasubmit_extract_theme_job().hero_slides theme extract <unc> --from <file>, which callsextract_theme_from_image()/extract_theme_from_pdf()ingenerator.rs, backed bysystem_extract_theme.mdprompt.system_extract_theme.mdprompt is inALL_TEMPLATESand editable via the Templates tab.pollAiJobpollsagent.aiJobResultat 800ms intervals; ondoneit returnsstatus.resultcontaining{ content }.instruct_instructionsmodifies existing instructions but there is no "extract instructions from visual reference" path.Requirements
instructions.mdpollAiJob/JobManager— same pattern asbg.extractThemeAsyncsystem_extract_instructions_from_image.mdmust produce well-structuredinstructions.mdcontent (audience, tone, structure, key messages, slide outline, goals) from slide imagesALL_TEMPLATESinprompts.rsandTEMPLATE_TO_PROMPT_KEYindashboard.js)Files to Modify or Create
crates/hero_slides_lib/src/prompts/system_extract_instructions_from_image.mdcrates/hero_slides_lib/src/prompts.rscrates/hero_slides_lib/src/generator.rsextract_instructions_from_image()andextract_instructions_from_pdf()crates/hero_slides_server/src/generate_job.rsbg.extractInstructionsAsynccrates/hero_slides_server/src/rpc.rsbg.extractInstructionsAsyncto the new handlercrates/hero_slides_admin/static/js/dashboard.jsbgExtractInstructionsFromFile(), clipboard paste handler, template keycrates/hero_slides_admin/templates/index.htmlImplementation Plan
Step 1: Create the AI prompt template
File:
crates/hero_slides_lib/src/prompts/system_extract_instructions_from_image.mdDependencies: none
Create the prompt instructing the AI to analyze slide images/PDFs and produce a structured
instructions.mdcovering: audience, tone, key messages, slide structure/outline, and goals. Output must begin with# Deck Instructionsand use##subheadings. No explanations, no code fences, no preamble — only the instructions.md content.Step 2: Register the template in
prompts.rsFile:
crates/hero_slides_lib/src/prompts.rsDependencies: Step 1
Add
pub const DEFAULT_SYSTEM_EXTRACT_INSTRUCTIONS_FROM_IMAGEconstant and add it toALL_TEMPLATES.Step 3: Add extraction functions to
generator.rsFile:
crates/hero_slides_lib/src/generator.rsDependencies: Step 2
Add
extract_instructions_from_image()andextract_instructions_from_pdf()mirroring the existing theme extraction functions, using the new prompt keysystem_extract_instructions_from_image.md.Step 4: Add the CLI subcommand
File:
crates/hero_slides/src/main.rs+ relevant rhai moduleDependencies: Step 3
Add
hero_slides instructions extract <unc> --from <file>CLI command mirroringtheme extract, calling the new generator functions and writing result toinstructions.md.Step 5: Add backend job submission and handler
File:
crates/hero_slides_server/src/generate_job.rsDependencies: Step 4
Add
submit_extract_instructions_job()andhandle_bg_extract_instructions_async()(plus status/logs handlers) mirroring the theme extraction job pattern. AddJobKind::ExtractInstructionsvariant.Step 6: Route the new RPC method
File:
crates/hero_slides_server/src/rpc.rsDependencies: Step 5
Route
bg.extractInstructionsAsync,bg.extractInstructionsJobStatus,bg.extractInstructionsJobLogsto the new handlers.Step 7: Add clipboard paste support +
bgExtractInstructionsFromFiletodashboard.jsFile:
crates/hero_slides_admin/static/js/dashboard.jsDependencies: Steps 5–6
Add
bgExtractInstructionsFromFile()callingpollAiJob('bg.extractInstructionsAsync', ...), add a globalpasteevent listener that detects image clipboard data and routes to instructions or theme extraction based on which editor is active, and register the new template key inTEMPLATE_TO_PROMPT_KEY.Step 8: Add UI button to
index.htmlFile:
crates/hero_slides_admin/templates/index.htmlDependencies: Step 7
Add "Extract from image / PDF" button in the Instructions editor section and a paste hint (Ctrl+V).
Acceptance Criteria
Notes
pollAiJobpattern already provides job tracking; the new method just needs the sameregister_with_manager_inputscall with a temp output file ingenerate_job.rs.resolve_extract_theme_sourceis reusable for the instructions extraction since the input shape (base64 inline or folder/file) is identical.ExtractInstructionstoJobKindrequires updating bothas_str()anddefault_timeout()injobs/types.rs.Implementation Spec (rev 2) — Issue #67: PDF/Image to Theme Instructions
Objective
Enhance the theme editor's "Extract from image / PDF" workflow:
system_extract_theme_from_image.mdproducing actionable AI-ready theme instructionsALL_TEMPLATES/TEMPLATE_TO_PROMPT_KEYand user-editable via Templates tabRequirements
system_extract_theme_from_image.mdwith improved prompt focused on producing actionable theme instructions (color palette with hex codes, typography, layout, imagery, AI image generation directives)system_extract_theme_from_image.mdregistered inALL_TEMPLATESand editable in the Templates tabextract_theme_from_imageandextract_theme_from_pdfingenerator.rsswitched to use new templateFiles to Modify / Create
crates/hero_slides_lib/src/prompts/system_extract_theme_from_image.mdcrates/hero_slides_lib/src/prompts.rsDEFAULT_SYSTEM_EXTRACT_THEME_FROM_IMAGEconst + ALL_TEMPLATES entrycrates/hero_slides_lib/src/generator.rsextract_theme_from_image/extract_theme_from_pdfto new template namecrates/hero_slides_admin/templates/index.htmlid="btn-extract-theme-file"to Extract buttoncrates/hero_slides_admin/static/js/dashboard.jsImplementation Plan
Step 1: New prompt file
File:
crates/hero_slides_lib/src/prompts/system_extract_theme_from_image.mdDependencies: none
Create an improved prompt instructing the AI to analyze a visual reference and produce actionable theme instructions covering: color palette (exact hex codes), typography, layout rules, imagery style, mood/brand voice, and an
## AI Image Generation Instructionssection with bullet-pointed directives. Output starts with# Visual Theme, uses##sub-sections, no code fences, no preamble.Step 2: Register in
prompts.rsFile:
crates/hero_slides_lib/src/prompts.rsDependencies: Step 1
Add
pub const DEFAULT_SYSTEM_EXTRACT_THEME_FROM_IMAGE: &str = include_str!("prompts/system_extract_theme_from_image.md");and add("system_extract_theme_from_image.md", DEFAULT_SYSTEM_EXTRACT_THEME_FROM_IMAGE)toALL_TEMPLATES.Step 3: Switch generator to new template
File:
crates/hero_slides_lib/src/generator.rsDependencies: Step 2
In
extract_theme_from_imageandextract_theme_from_pdf, change the template name from"system_extract_theme.md"to"system_extract_theme_from_image.md". Oldsystem_extract_theme.mdstays registered in ALL_TEMPLATES.Step 4: Add
idto Extract buttonFile:
crates/hero_slides_admin/templates/index.htmlDependencies: none (independent)
Add
id="btn-extract-theme-file"to the existing Extract button. Check for Fix, Rewrite, Instruct button IDs and add them if missing.Step 5: Refactor
dashboard.js— lockout helpers + non-blocking extract + clipboard pasteFile:
crates/hero_slides_admin/static/js/dashboard.jsDependencies: Step 4
_lockThemeAiButtons(label)helper: disables Fix/Rewrite/Instruct/Extract buttons, shows spinner label on Extract button_unlockThemeAiButtons()helper: re-enables all, restores Extract button label_runExtractThemeJob(mimeType, base64Data): calls lock, runspollAiJob('bg.extractThemeAsync', ...), on success appends/replaces textarea content, calls_unlockThemeAiButtons()in finallybgExtractThemeFromFile()to read file and call_runExtractThemeJobbgExtractTheme(folder, file)context-menu path to also use lock/unlock + append-or-replacedocument.addEventListener('paste', ...)handler: fires only when theme editor overlay is active, extracts image from clipboard, calls_runExtractThemeJob'system_extract_theme_from_image.md': 'extract_theme'toTEMPLATE_TO_PROMPT_KEYAcceptance Criteria
system_extract_theme_from_image.mdappears in Templates tab and is user-editable/resettablecargo buildpasses with no errorsbgExtractTheme(folder, file)flow still worksNotes
bg.extractThemeAsyncalready accepts{ data, mime_type }base64 payloads. Clipboard path reuses the exact same code path as the file-picker.system_extract_theme.mdis not removed — stays in ALL_TEMPLATES for users who customized it.theme-editor-overlayhavingactiveclass before firing — prevents accidental extraction when pasting text elsewhere in the UI.Test Results
All tests passed. One test (test_generate_single_slide_ai) was skipped as it requires a live AI backend.
Note: hero_slides_examples failed to compile due to missing tokio dependency in its examples (health.rs, basic_usage.rs). All other crates compiled and tested successfully.
Implementation Summary
Changes Made
crates/hero_slides_lib/src/prompts/system_extract_theme_from_image.md(created)New AI prompt for image/PDF-to-theme-instructions extraction. Instructs the AI to produce a structured
# Visual Themedocument covering exact hex color palette, typography, layout rules, imagery style, mood/brand voice, and a dedicated## AI Image Generation Instructionssection with bullet-pointed directives ready for an image generator.crates/hero_slides_lib/src/prompts.rs(modified)Added
DEFAULT_SYSTEM_EXTRACT_THEME_FROM_IMAGEconstant and registeredsystem_extract_theme_from_image.mdinALL_TEMPLATESso it appears in the Templates tab and is user-editable/resettable.crates/hero_slides_lib/src/generator.rs(modified)extract_theme_from_imageandextract_theme_from_pdfnow use the newsystem_extract_theme_from_image.mdtemplate instead ofsystem_extract_theme.md. The old template stays registered for users who customized it.crates/hero_slides_admin/templates/index.html(modified)Added
id="btn-extract-theme-file"to the Extract button (Fix/Rewrite/Instruct already had ids).crates/hero_slides_admin/static/js/dashboard.js(modified)_lockThemeAiButtons(label)/_unlockThemeAiButtons(): helpers that disable Fix, Rewrite, Instruct, and Extract buttons during a job run; Extract button shows a hourglass spinner_runExtractThemeJob(mimeType, base64Data): shared extraction job runner — locks buttons, runspollAiJob('bg.extractThemeAsync', ...), appends result to theme textarea (or replaces if empty), unlocks on complete/failbgExtractThemeFromFile()refactored to delegate to_runExtractThemeJobbgExtractTheme(folder, file)updated to use the same lock/unlock and append-or-replace behaviorTEMPLATE_TO_PROMPT_KEYupdated withsystem_extract_theme_from_image.mdentryTest Results
169 tests passed, 0 failed, 1 ignored (live AI test).