make preview context #11
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_code#11
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?
do right mouse to preview a context, use same modal
do preview at:
when context open, then do modal, where we see full context
Implementation Spec for Issue #11 — "Make Preview Context"
Objective
Add a "Preview" action to the right-click context menu on each context item in the left-hand context list panel. When triggered, the action calls the existing
context.renderRPC method and displays the returned markdown text inside a Bootstrap modal.Architecture Notes
The UI is a server-side-rendered Askama/HTML + vanilla JavaScript application served by an Axum web server. No Rust/server-side changes are needed —
context.renderRPC already exists and returns{ text, file_count, byte_count }.Requirements
context.render({ id })and displays the result in a modal.modal.fadepattern already present in the appFiles to Modify
crates/hero_code_ui/templates/index.htmlcrates/hero_code_ui/static/js/contexts.jsctxPreviewContext(id, name)functionImplementation Plan
Step 1 — Add modal HTML to
index.htmlFile:
crates/hero_code_ui/templates/index.htmlInsert immediately after the
<!-- IDE OUTPUT MODAL -->block (around line 969), before the Bootstrap bundle script tag.Step 2 — Add
ctxPreviewContextfunction tocontexts.jsAppend after the last function in
crates/hero_code_ui/static/js/contexts.js:Step 3 — Add "Preview" to the right-click context menu in
contexts.jsInside
ctxRenderList(), in thecontextmenuevent listener, replace the items array:Before:
After:
Acceptance Criteria
ideOutputModalorjobDetailModalNotes
context.renderRPC already exists server-side — no backend changes neededwhite-space:pre-wrapon the body div renders markdown/code-fence text legibly without XSS risk (textContentnotinnerHTML)cloneNodecopy-button pattern prevents duplicate event listeners on repeated modal opensTest Results
All tests passed. Build completed with 2 warnings (unused fields in hero_code_ui) and 1 warning (unused function in hero_runner_rhai), but no errors.
Breakdown by crate/suite
No failures. 3 doc-tests ignored (expected).
Implementation Complete
Changes Made
crates/hero_code_ui/templates/index.htmlctxPreviewModal— a Bootstrap.modal.fadeelement with a title, file/byte-count badge, monospace scrollable body, and Copy buttoncrates/hero_code_ui/static/js/contexts.jsctxPreviewContext(id, name)async function: opens the modal immediately in a loading state, callscontext.renderRPC, then populates the modal body with the rendered text and updates the badge with file/byte counts. On error, shows a danger toast and closes the modal.ctxRenderList()to include a "Preview" entry (bi-eye icon) between Rename and DeleteHow it works
Right-clicking any context in the context list now shows: Rename | Preview | Delete.
Clicking "Preview" opens a large Bootstrap modal with the context name as the title. While the
context.renderRPC is in flight a "Loading..." badge is shown. Once loaded, the full rendered context text appears in a monospace scrollable pane, and a Copy button appears to copy the content to clipboard.No server-side changes were needed —
context.renderwas already implemented.Test Results
All 107 tests passed (0 failures).
Implementation Complete
Changes Made
crates/hero_code_ui/templates/index.htmlctxPreviewModal— a Bootstrap.modal.fadeelement with a title, file/byte-count badge, monospace scrollable body, and Copy buttoncrates/hero_code_ui/static/js/contexts.jsctxPreviewContext(id, name)async function: opens the modal immediately in a loading state, callscontext.renderRPC, then populates the modal body with the rendered text and updates the badge with file/byte counts. On error, shows a danger toast and closes the modal.ctxRenderList()to include a "Preview" entry (bi-eye icon) between Rename and DeleteHow it works
Right-clicking any context in the context list now shows: Rename | Preview | Delete.
Clicking "Preview" opens a large Bootstrap modal with the context name as the title. While the
context.renderRPC is in flight a "Loading..." badge is shown. Once loaded, the full rendered context text appears in a monospace scrollable pane, and a Copy button appears to copy the content to clipboard.No server-side changes were needed —
context.renderwas already implemented.Test Results
All 107 tests passed (0 failures).