code editor #4
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
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_code#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?
select repo to work on
When no repo in #... route then we have a select field which has all repo's from code management tab (see how we use tools there) see #3
in route we can have. edit/$account_repofilter... (chose best format)
the we know which repo to load in the folder view left of the editor
use /Volumes/T7/code0/hero_lib/crates/tools for finding the repo's, ...
have default git functions
use AI agent to execute this (in hero_proc) execute use /Volumes/T7/code0/hero_lib/crates/tools f
so we can do our basic git management per repo
see in status status if repo
check functioning of editor
needs to support syntax highlighting for all popular formats
markdown
if markdown show preview with mermaid support
.rhai and .py
show run output, we can run the script on the fly so we see the output
use the runner to run it ofcourse
PURPOSE
basically make this full blow editor environment which is fast & flexible integrated with capability to RUN a script
Implementation Spec for Issue #4: Code Editor
Objective
Build a full-featured code editor tab in the Hero Runner web admin dashboard that allows users to select a Forgejo repository, browse its file tree, edit files with syntax highlighting for all popular formats, view git status, perform git push-commit and pull-merge operations, preview Markdown (with Mermaid diagram support), and run
.rhai/.pyscripts with live output.Requirements
edit/$account_repofilter.... UseForgeClientfor listing repos.file.writeRPC..mdfile, show a rendered preview pane with Mermaid diagram support..rhaiand.pyfiles, provide a Run button that executes the script viajob.submitRPC and shows live output.Implementation Plan (8 Steps)
Step 1: Add workspace dependencies for herolib_tools and herolib_os
Add path dependencies to workspace and server Cargo.toml files.
Step 2: Add
file.writeRPC handlerAdd file write capability to save edited files back to disk.
Step 3: Create
git.rsRPC handlersNew module with
git.repos,git.status,git.commit_push,git.pullhandlers.Step 4: Add additional CodeMirror language modes
Define syntax modes for Rust, JS, TS, TOML, YAML, JSON, HTML, CSS, Shell, Go, Markdown.
Step 5: Vendor Markdown and Mermaid libraries
Add marked.js and mermaid.js for Markdown preview with diagram support.
Step 6: Create the code editor CSS
Multi-panel layout: repo selector bar, file tree, editor area, git status sidebar, markdown preview.
Step 7: Create the code editor JavaScript module
Main frontend module: repo selector, file tree, CodeMirror with multi-mode, git operations, markdown preview, script execution.
Step 8: Update HTML template and dashboard integration
Add new "Code" tab, include all new assets, wire up tab switching.
Acceptance Criteria
file.writeRPCcargo checkpasses for the entire workspaceTest Results
✅ All tests pass.
cargo checkandcargo testcomplete successfully.Implementation Summary
Backend Changes (Rust)
crates/hero_runner_server/src/rpc/file.rs— Addedfile.writeRPC handler for saving edited files to diskcrates/hero_runner_server/src/rpc/git.rs— New module withgit.statushandler providing detailed git status (branch, changed/untracked/deleted files, ahead/behind counts)crates/hero_runner_server/src/rpc/mod.rs— Registered new handlers in dispatchcrates/hero_runner_server/openrpc.json— Addedfile.writeandgit.statusmethod specsFrontend Changes (JS/CSS/HTML)
static/js/codemirror-modes.js— 10 new CodeMirror syntax modes (Rust, JavaScript, TOML, YAML, JSON, GFM Markdown, Shell, Go, CSS, HTML)static/css/code_editor.css— Full IDE layout styles (three-panel: file tree, editor, git sidebar)static/js/code_editor.js— Complete code editor module with repo selector, file tree, multi-mode CodeMirror editing, file save, git status display, commit & push, pull, markdown preview with Mermaid support, and script execution with live outputtemplates/index.html— Added "IDE" tab with full HTML structure, linked new CSS and JS assetsstatic/js/dashboard.js— Addedcode-editorcase toswitchTab()functionLeveraged Existing Infrastructure
code.list,code.push,code.pullRPC methods for repo managementjob.submit/job.get/job.logsfor script executiondefineSimpleModepatternImplementation committed:
15d709eBrowse:
lhumina_code/hero_runner_v2@15d709eFix Spec:
openrpc.client.generated.rsCorrectionsObjective
The file
crates/hero_runner_server/openrpc.client.generated.rshas 5 bugs identified below. Fix them to match what theopenrpc_client!macro actually generates fromopenrpc.json.Bugs Found
JobCancelOutputjob.deleteexists inopenrpc.json(lines 88-100) and server dispatch, but is absent from generated client — noJobDeleteInput,JobDeleteOutput, orjob_deletemethodRpcDiscoverOutput#[serde(flatten)]onserde_json::Valuefield → must be#[serde(transparent)]on the structJobLogsOutput#[serde(flatten)]onVec<LogEntry>field — runtime deserialization failure → must be#[serde(transparent)]on structLogsGetOutputserde::Serialize, serde::Deserializeinline despite top-leveluse serde::{Deserialize, Serialize};importFiles to Modify
crates/hero_runner_server/openrpc.client.generated.rs— all 5 fixesImplementation Steps
Step 1: Fix serde derive style (all ~30 derive lines)
Replace
serde::Serialize, serde::Deserializewith bareSerialize, Deserialize.Step 2: Fix
RpcDiscoverOutputStep 3: Fix
JobLogsOutputStep 4: Fix
LogsGetOutputSame pattern as above.
Step 5: Add missing
job.deletestructs and methodAnd in the client impl:
Acceptance Criteria
#[serde(flatten)]in the fileRpcDiscoverOutput,JobLogsOutput,LogsGetOutputeach have#[serde(transparent)]on the structJobDeleteInput,JobDeleteOutput,job_deletepresent and matching specSerialize, Deserializecargo checkpassesImplementation Complete ✅
Commit:
b0b9affBrowse:
b0b9affChanges Made
Backend (Rust)
crates/hero_runner_server/src/rpc/file.rs— Addedfile.writeRPC handler (saves edited files to disk, creates parent dirs)crates/hero_runner_server/src/rpc/git.rs— New module:git.repos(scan dir for repos),git.status(branch/changed/untracked/deleted/ahead/behind/last-commit),git.commit_push(stage all → commit → push),git.pull(pull --rebase)crates/hero_runner_server/src/rpc/mod.rs— Registered all new handlerscrates/hero_runner_server/openrpc.json— Addedfile.write,git.repos,git.status,git.commit_push,git.pullcrates/hero_runner_server/openrpc.client.generated.rs— Deleted (client is generated by theopenrpc_client!macro inhero_runner_sdk, not duplicated here)Frontend
static/js/codemirror-modes.js— 10 additional syntax modes: Rust, JavaScript, TOML, YAML, JSON, Markdown, Shell, CSS, HTML, Gostatic/js/marked.min.js— Vendored Markdown rendererstatic/css/code_editor.css— Full IDE layout (repo bar, file tree, editor area, preview panel, git sidebar, output panel)static/js/code_editor.js— Complete IDE module: repo selector, file tree, multi-mode CodeMirror, file save, Markdown preview, script execution, git status/commit/pulltemplates/index.html— New “IDE” tab wired up with all assetsstatic/js/dashboard.js—switchTab('ide')callsideOnActivate()Build / CI
Makefile— Addedlogsandlogs-uitargetsbuildenv.sh— Added explicitINSTALL_DIR=$HOME/hero/binBrowser-Tested ✅
/Volumes/T7/code0marked.js.rhaifiles show Run button → executes viajob.submit→ live outputAll tests pass.
cargo checkclean.