shell integration. =terminal #71
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_proc#71
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?
issue 1:
only show tty enabled sessions
issue 2
check implementation with hero_router, some functionality can be reused
should be efficient, maybe we can reuse functionality from hero_router in hero_proc, so its more like a lib we an use, rather than duplication
not all functions are same, but the reusable ones could be put in lib on hero_router level
Issue #71 Implementation Spec — Shell Integration / Terminal
Objective
Two-part fix for the hero_proc admin dashboard's terminal feature:
tty: true. Currently it shows every running job, including non-TTY jobs that fail to attach.Requirements
action.tty == true). Non-TTY jobs are hidden from the list.actionSpec.tty).JobFiltershape.docs/with no code moves; a follow-up issue will be opened to do the extraction.Files to Modify (Part A only)
crates/hero_proc_ui/templates/index.html—populateTerminalJobListIIFE around line 662; add an action-spec lookup and filterjobsto only those whose action hastty=true.(No backend change required;
cachedActionsis already populated globally by the dashboard load path.)Files to Create (Part B only)
docs/proposal-shared-terminal-lib.md— design proposal describing what should be extracted fromhero_router::server::terminalinto a new shared library crate inside the hero_router workspace, and how hero_proc would consume it. (Marked clearly "DESIGN PROPOSAL — see follow-up issue.")Implementation Plan
Step 1 — UI filter on the Terminal tab
Files:
crates/hero_proc_ui/templates/index.htmlDependencies: none (server-side schema unchanged)
What to do:
In
populateTerminalJobList(currently atindex.html:662), after the existingjobs.filter(function (j) { return j.phase === 'running'; })step and before the sort, add a second filter that intersects the running set with the cached action specs:job.name(the action name inJobSummary) in the globalcachedActionsarray (already populated bydashboard.js).tty === true.cachedActions(race during startup), fall through to excluding the job — this matches the conservative behaviour of the Job-detail panel which only shows the Terminal button when the action is found AND has tty.Also update the empty-option label from
-- Select a running job --to-- Select a running TTY job --so the filter is visible to the user.Rationale for UI-side over backend-side filter:
JobSummarydoes not carrytty— the flag lives onActionSpec. Adding it would require changes toJobSummary,to_summary, the SQL row reader, plus extendingJobFilterwithtty: Option<bool>. That is a much larger blast radius for a UI-only concern.cachedActionsis already loaded by the dashboard on startup; the join is cheap.cachedActions.find(... === a.name)pattern, so the filter is consistent with existing code.Step 2 — Verify the dropdown still auto-attaches correctly
Files: none changed — manual smoke test only.
After Step 1, reload the Terminal tab and confirm:
navigateToTerminalJob(id)still works because the caller already gates onhasTty.Step 3 — Write the Part-B design proposal
Files:
docs/proposal-shared-terminal-lib.md(new file)Dependencies: Step 1 is independent and can ship first.
The document inventories actual duplication between hero_proc and hero_router and proposes a new crate
hero_terminal_libinside the hero_router workspace, exposing:session.rs—ShellType,TerminalSession,validate_name,encode_job_name,decode_job_name,shell_suffix,shell_from_suffixmanager.rs—create_session/list_sessions/get_session/delete_sessionparameterised over ahero_proc_sdkclientframe.rs— typedTerminalEventenum for the wire formatansi/mod.rs—strip_local_terminal_queries,strip_da_plaintext_artifacts,pending_query_prefix_lenplus their testsWhat stays in hero_proc:
PtyHandle, theportable_pty-based supervisor, the/api/jobs/{id}/ptyWS endpoint,pty_handlesmap, scrollback buffer.What stays in hero_router:
pty_proxyandattached()registry remain as the WS-proxy concrete implementation, calling into the new crate foransi::*and frame parsing.Migration plan (for follow-up issue):
hero_terminal_lib, move name/encoding/strip helpers + tests, repointhero_routeruse sites.manager.rs, parameterised over an injectedhero_proc_sdkclient. Theterminal.*RPC handlers inhero_routerbecome 5-line shims.TerminalEventframes, or accept both indefinitely.Acceptance Criteria
tty: true.tty: false(or nottyfield) is NOT present in the dropdown.-- Select a running TTY job --.navigateToTerminalJob.docs/proposal-shared-terminal-lib.mdexists and contains the duplication inventory and extraction shape. The file's first paragraph is> DESIGN PROPOSAL — implementation tracked in follow-up issue.Notes
JobSummaryandJobFilterstay as-is. Addingttyto either is left for a future cleanup if a backend filter is ever required.cachedActionsbeing populated. If empty (user lands directly on#terminal/<id>), the conservative behaviour is to show no jobs — preferable to showing all of them, because clicking a non-TTY job would error on attach anyway.PtyHandle, scrollback, the WS endpoint) as not duplicated — only hero_proc owns these and hero_router proxies through them.hero_terminal_libfrom the hero_router workspace via the standard CODEROOT-patch route.Test Results
Command:
cargo test --workspace --no-fail-fast(viamake test, then re-run with--no-fail-fastto enumerate all failures)Total: 416
Passed: 414
Failed: 2
Ignored: 52
Failures
Doc-test compilation errors (pre-existing, unrelated)
Five doc-test targets fail to compile because rustdoc cannot resolve
hero_proc_sdk/HeroProcRPCAPIClientsymbols inside doctests:-p hero_proc_cli --doc(E0463: can't find crate forhero_proc_sdk)-p hero_proc_integration_test --doc(28 errors: unresolvedHeroProcRPCAPIClient, etc.)-p hero_proc_integration_tests --doc(E0463: can't find crate forhero_proc_sdk)-p hero_proc_integration_tests --lib(the harness timeout above)-p hero_proc_sdk --lib(the ready marker assertion above)All five failures are pre-existing on
developmentand unrelated to this issue's changes.Notes: this issue's changes are in
crates/hero_proc_ui/templates/index.html(JS only) anddocs/proposal-shared-terminal-lib.md(markdown). The cargo suite is run as a regression sanity check.Implementation Summary
Both parts of the spec are in place. Changes are local to this branch and not yet pushed.
Files changed
crates/hero_proc_ui/templates/index.html-- Select a running TTY job --docs/proposal-shared-terminal-lib.mdhero_terminal_libextraction shape, marked as DESIGN PROPOSALPart A — UI filter
populateTerminalJobListinindex.htmlnow intersects the running-jobs list with the globalcachedActionsarray, keeping only jobs whose action spec hastty === true. The defensive guard falls back to an empty actions array ifcachedActionsis undefined or not an array — in that case the dropdown is empty rather than full of non-TTY jobs that would fail to attach. Jobs whose action name is missing or absent fromcachedActionsare excluded for the same reason.Part B — Design proposal
docs/proposal-shared-terminal-lib.mddocuments the shell/terminal/PTY duplication betweenhero_procandhero_routerand proposes a newhero_terminal_libcrate inside thehero_routerworkspace. The PTY ownership layer (PtyHandle,portable_ptysupervisor, the/api/jobs/{id}/ptyWS endpoint) explicitly stays inhero_proc. The session-management and wire-framing layer above it (session naming, ANSI/CSI scrubbing, typedTerminalEventenvelope, session CRUD) is the extraction target. A migration plan and out-of-scope list are included so a follow-up issue can implement it cleanly.Tests
cargo test --workspace --no-fail-fastwas run as a regression sanity check. Result: 414 passed, 2 failed, 52 ignored. The 2 failures (harness::tests::test_harness_starts_and_stops,ready::tests::declare_creates_marker) plus 5 doc-test compile errors are all pre-existing ondevelopmentand unrelated to this issue's changes (which touch only an HTML template and a new markdown file — no Rust source). Full output captured above.Acceptance Criteria
tty: true.tty: false(or nottyfield) is NOT present in the dropdown.-- Select a running TTY job --.navigateToTerminalJob(caller pre-gates onhasTty, so the job will pass the new filter).docs/proposal-shared-terminal-lib.mdexists and the duplication inventory and extraction shape are present. First paragraph is the> DESIGN PROPOSALblockquote.Follow-up
A separate issue should track the actual extraction of
hero_terminal_libper the migration plan indocs/proposal-shared-terminal-lib.md.