put route in #... logs #17
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?
to allow us to specify logs to show e.g.
http://localhost:9999/#logs/hero_collab_ui
is always start of the logs
Implementation Spec: Issue #17 — Hash-based routing for the logs viewer (
#logs/<service>)Objective
When a user navigates to
http://localhost:9999/#logs/hero_collab_ui, the dashboard must automatically:hero_collab_uiin the source tree.The
#logs/<name>hash must be preserved and kept in sync as the user interacts with the logs view.Requirements
#logs/<service_name>on page load must switch to the Logs tab, preselect the named source, and triggerloadLogs().navigateToLogs(srcName)must updatelocation.hashto#logs/<srcName>so the resulting URL is shareable.#logs.#logs./logs/{name}pathname route bug (loadLogs() never called) must also be fixed.Files to Modify
crates/hero_proc_ui/static/js/dashboard.js— all logic changesImplementation Plan
Step 1 — Fix
switchTabto preserve#logs/<name>hashesExtend the guard in
switchTab(around line 447) to preserve#logs/<service>hashes when switching to the logs tab, matching the existing#terminal/<jobId>pattern.Step 2 — Handle
#logs/<service>in thehashchangeevent listenerAdd a
logs/branch in thehashchangelistener (around line 3779) so that hash changes to#logs/fooswitch to the logs tab, preselect the source, and callloadLogs().Step 3 — Fix
DOMContentLoadedinitialisation for the#logs/<name>hashIn the
DOMContentLoadedhandler, add alogs/branch that extracts the service name and callspreselectSource()+loadLogs()afterrefreshSourceTree(). Also fix the existing pathname/logs/{name}branch to actually callloadLogs().Step 4 — Update
navigateToLogsto write#logs/<service>into the hashAfter
switchTab('logs'), usehistory.replaceState(null, '', '#logs/' + encodeURIComponent(srcName))so the URL is shareable. UsereplaceState(notlocation.hash =) to avoid triggering the hashchange listener.Step 5 (Optional) — Keep hash in sync when user manually changes source selection
Add
updateLogsHash()helper called frompreselectSource,selectAllSources, anddeselectAllSources.Acceptance Criteria
http://localhost:9999/#logs/hero_collab_uiopens Logs tab with that service preselected and logs loaded#logs/foo) works without page reload#logs/<service_name>#logs/hero_collab_uidoes NOT reset hash to#logs#logs(no service) opens Logs tab with all sources and runs default query/logs/hero_collab_uipathname route now actually shows logs (bug fix)#docs/,#terminal/,#servicesunaffectedNotes
history.replaceState(notlocation.hash =) when silently updating the URL to avoid triggering hashchange recursion.preselectSource()calls must be inside.then()afterrefreshSourceTree()due to async source tree loading.Test Results
Details
The test suite failed to compile due to a struct field mismatch in the integration test:
File:
tests/integration/tests/pty.rs:154Error:
error[E0560]: struct hero_proc_sdk::ActionSpec has no field named argsThe integration test references a field
argsonhero_proc_sdk::ActionSpec, but that field does not exist. Available fields include:depends_on,description,dir,env,health_checks, and 6 others.This appears to be a stale integration test that has not been updated to reflect changes in the
ActionSpecstruct inhero_proc_sdk.Warnings (non-fatal)
crates/hero_proc_lib/src/db/logs/store.rs:9— unused importpartition_pathcrates/hero_proc_lib/src/db/integration_tests.rs:614— unused importActionSpectests/integration/src/fixtures.rs:84— dead code:shell_escapefunctioncrates/hero_proc_integration_test/src/tests/stress.rs:24— dead code:timestampfieldtests/integration/tests/pty.rs:219— unused importSinkExttests/integration/tests/service_management.rs— dead code:add_loop_serviceandadd_dependent_serviceNote
The main changed file (
crates/hero_proc_ui/static/js/dashboard.js) is a static JS file and is not directly tested bycargo test. The compile failure is pre-existing in the Rust integration tests.Implementation Complete ✅
Changes Made
crates/hero_proc_ui/static/js/dashboard.js(all JS changes — no Rust changes needed):switchTab— preserve#logs/<service>hashes (Step 1): Extended the hash guard to also preserve#logs/<name>when switching to the Logs tab, matching the existing#terminal/<jobId>pattern. Clicking the Logs tab button no longer strips the service name from the URL.hashchangelistener — handle#logs/<service>(Step 2): Addedlogs/andlogsbranches so live hash navigation (e.g. editing the address bar) automatically switches to the Logs tab, preselects the named service in the source tree, and callsloadLogs().DOMContentLoaded— cold-load support for#logs/<name>(Step 3): Addedlogs/branch in the initial hash-parsing block. Also fixed the existing pathname-based/logs/{name}handler which had a bug whereloadLogs()was never called afterpreselectSource().navigateToLogs— shareable URL (Step 4): Addedhistory.replaceState(null, '', '#logs/' + encodeURIComponent(srcName))afterswitchTab('logs'). UsesreplaceState(notlocation.hash =) to avoid re-triggering the hashchange listener. "View Logs" button now produces a bookmarkable/shareable URL.updateLogsHash()helper — hash kept in sync (Step 5): New helper called frompreselectSource,selectAllSources, anddeselectAllSources. Writes#logs/<single-source>or#logsto the URL bar as the user interacts with the source tree.tests/integration/tests/pty.rs— fixed stale test that referenced the removedActionSpec.argsfield (pre-existing compile error, unrelated to the issue feature).Test Results
harness.rsis unrelated and unchanged.Acceptance Criteria
http://localhost:9999/#logs/hero_collab_uiopens Logs tab with that service preselected and logs loaded#logs/foo) works without page reload#logs/<service_name>#logs/hero_collab_uidoes NOT reset hash to#logs#logs(no service) opens Logs tab with all sources and runs default query/logs/hero_collab_uipathname route now actually shows logs (bug fix)#docs/,#terminal/,#servicesunaffectedImplementation committed:
24de8afBrowse:
24de8af