admin interface not fully functioning #3
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?
I don't see the job, we should be able to track whats going on
we should be able to see the logs
is it all in hero_proc???
also implement /hero_admin_connection_status
Implementation Spec for Issue #3 — Admin Interface: Jobs, Logs & Connection Status
Objective
The hero_researcher admin UI needs three improvements:
connection-status.jswidget (3-state: connected / backend-down / disconnected) including Bootstrap popover./hero_admin_connection_statusendpoint — required by the hero skill system for embedding this service's status in other dashboards.Requirements
GET /health→{ status: "ok", service: "hero_researcher_ui", version: "0.1.0" }GET /api/health→ enriched withserviceandversionfieldsGET /hero_admin_connection_status→ JSON withstatus,service,backendGET /api/jobs/:id/logs→{ jobId, lines: string[] }research.logsJSON-RPC method on the server dispatcherresearchLogs(jobId)method exported from hero_researcher_sdkbun testpasses for all packagesFiles to Modify/Create
packages/hero_researcher_server/src/job-manager.tslogs: string[]toJobFile, buffer per-job stderr/stdout (cap 2000 lines), exportgetJobLogs()packages/hero_researcher_server/src/dispatcher.tsresearch.logshandler + updaterpc.discoverpackages/hero_researcher_sdk/src/types.tsResearchLogsinterfacepackages/hero_researcher_sdk/src/client.tsresearchLogs(jobId)methodpackages/hero_researcher_ui/src/routes.ts/health,/hero_admin_connection_status,/api/jobs/:id/logs; enrich/api/healthpackages/hero_researcher_ui/public/index.htmlconnection-status.js; add log panel card + JSpackages/hero_researcher_ui/public/connection-status.jspackages/hero_researcher_ui/tests/routes.test.tspackages/hero_researcher_server/tests/dispatcher.test.tsresearch.logsImplementation Plan
Step 1 — Extend
JobFilefor log capture (job-manager.ts)logs?: string[]toJobFileinterfacespawnResearchProcess, attach readers to bothproc.stdoutandproc.stderrthat append decoded chunks tojf.logs(cap at 2000 lines), then callpersistJob(jf)getJobLogs(jobId: string): Promise<string[]>Step 2 — Add
research.logsRPC handler (dispatcher.ts)getJobLogsfrom./job-manager"research.logs"handler returning{ jobId, lines }rpc.discovermethods arrayStep 3 — Add SDK types and client method (sdk types.ts + client.ts)
ResearchLogsinterface to types.tsresearchLogs(jobId: string): Promise<ResearchLogs>to HeroResearcherClientStep 4 — Add new UI routes (routes.ts)
/health→{ status: "ok", service: "hero_researcher_ui", version: "0.1.0" }/api/healthwithserviceandversion/hero_admin_connection_status→ JSON with status + backend check via rpc.health/api/jobs/:id/logs→ callsclient.researchLogs(id), returns{ jobId, lines }Step 5 — Copy connection-status.js
/Volumes/T7/code0/hero_proc/crates/hero_proc_ui/static/js/connection-status.jstopackages/hero_researcher_ui/public/connection-status.jsStep 6 — Update index.html: connection status widget
.status-dotCSS (3 states: green/amber/red).polling-indicatorspan andcheckHealth()withconnection-status.jspoller<script src="/connection-status.js"></script>Step 7 — Update index.html: log panel
#logs-cardBootstrap card (initiallyd-none) with<pre id="logs-content">loadLogs(jobId)function that GETs/api/jobs/:id/logsand renders linesloadLogs()inviewJob(), set up 5s poll for running jobsresetView()andstopPolling()Step 8 — Add/update tests
packages/hero_researcher_ui/tests/routes.test.ts: addresearchLogsmock, test/health,/hero_admin_connection_status,/api/jobs/:id/logspackages/hero_researcher_server/tests/dispatcher.test.ts: create tests forresearch.logsAcceptance Criteria
connection-status.jsGET /health→{ status: "ok", service: "hero_researcher_ui", version: "0.1.0" }GET /api/health→ includesserviceandversionfieldsGET /hero_admin_connection_status→ JSON withstatus,service,backendGET /api/jobs/:id/logs→{ jobId, lines: string[] }bun testpasses for all packagesNotes
logsfield toJobFileis safe — existing files without it deserialize withlogs: undefined, handled via?? []connection-status.jsworks with Bootstrap 5.3.3 already loaded via CDN/hero_admin_connection_statusreturns JSON only (no HTML needed)Test Results
All packages passed:
Full output
Implementation Complete ✅
All work from this issue has been implemented and committed in
b24ebb5.Changes Made
Admin UI — Jobs & Logs Display
packages/hero_researcher_ui/public/index.html— Jobs sidebar lists all research jobs with status badges (RUNNING/COMPLETED/FAILED/CANCELLED/PENDING); clicking a job shows its log stream viaGET /api/jobs/:id/logs; logs panel is a Bootstrap card with<pre>contentpackages/hero_researcher_ui/src/routes.ts— Added/api/jobs/:id/logs,/health,/hero_admin_connection_status, and/connection-status.jsroutesConnection Status Widget
packages/hero_researcher_ui/public/connection-status.js— Copied from hero_proc_ui; provides 3-state (connected / backend-down / disconnected) animated dot with Bootstrap popoverGET /health(UI liveness) thensystem.pingvia RPC (backend liveness) every 5 s@keyframes pulseand all three dot stateshero_proc Integration (fixes "ENOENT: posix_spawn 'bun'")
packages/hero_researcher_server/src/job-manager.ts— ReplacedBun.spawnwith hero_proc JSON-RPC over Unix socket (~/hero/var/sockets/hero_proc_server.sock); usesjob.createwithinterpreter: "bun", pollsjob.status, callsjob.logsandjob.cancelpackages/hero_researcher/src/run-job.ts— Added env fallback:if (!jobId) jobId = process.env.JOB_IDso hero_proc can pass the job ID via environmentBuild System
Makefile—rundepends onbuild; addedinstall-bins(copies binaries to~/hero/bin/),logs,logs-ui,restart,statustargetsscripts/run.sh— Uses compileddist/hero_researcher_serverbinary if available; exportsHERO_RESEARCHER_ROOTso compiled server can locaterun-job.tsbuildscripts to all packages:hero_researcher_serverandhero_researcher_cliuse--compile;hero_researcher_sdkuses--target bunOpenRPC Spec & SDK Sync
packages/hero_researcher_server/openrpc.json— Addedsystem.pingandresearch.logsmethods; fixedResearchJob.id→jobId; fixedprogresstype; updated server URL to Unix socketpackages/hero_researcher_server/src/dispatcher.ts—rpc.discovernow serves the realopenrpc.json;rpc.healthreturnsversionfieldpackages/hero_researcher_sdk/src/client.ts— Fixedhealth()method name; addedping(); fixedresearchList()return type to{ jobs, total }Architecture Compliance (hero_crates_best_practices_check)
packages/hero_researcher_examples/— New package withsrc/health.tsandsrc/basic_usage.tsexamples.forgejo/workflows/ci.yaml— CI workflow: install → lint → test → buildCommit
b24ebb58301686b32575f8ea04dc814b874b0c68