Skip to content

feat(backends): open hc task terminals beside the Firstmate that launched them - #8003

Open
LuizBrugnera wants to merge 3 commits into
kunchenguid:mainfrom
LuizBrugnera:fm/hc-space-inheritance
Open

LuizBrugnera wants to merge 3 commits into
kunchenguid:mainfrom
LuizBrugnera:fm/hc-space-inheritance

Conversation

@LuizBrugnera

@LuizBrugnera LuizBrugnera commented Oct 30, 2026 •

Copy link
Copy Markdown

Intent

Follow-up to #7963 (the experimental, explicit-only hc / herdr-core runtime backend), offered on that PR as "optional space and parent inheritance" and accepted by its author for after it landed.
Goal: an opt-in, FM_HC_BESIDE_FIRSTMATE=1, that opens each hc task terminal beside the Firstmate that launched it in Herdr.app.
With the opt-in set and Firstmate running inside a live hc terminal of the same session, each task terminal is created as that terminal's child (--parent <firstmate terminal> --outlive-parent --no-notify) with the same herdr.space label, so the crew shows as its sub-agents with one tab each.
The default does not change: with the opt-in unset or any value other than 1, or with no qualifying Firstmate terminal, behavior stays exactly as #7963 shipped it: --no-parent and herdr.space=${FM_HC_SPACE:-fm-<hometag>}.
An explicit FM_HC_SPACE still wins over the caller's space.
Deliberate decisions: HC_TERMINAL_ID is only a hint and is never used to select the backend (hc stays explicit-only).
The adapter accepts it as the parent only when hc get on the task's own session reports that terminal live and the terminal's own process (its top-level pid, the shell hc started in it, not foreground.pid) is an ancestor of the spawning process (a bounded walk of 64 parents).
The terminal's shell pid is deliberate: it is an ancestor of whatever runs inside the terminal, so the check holds when Firstmate runs under a launcher or wrapper that holds the foreground, and it still rejects an id inherited through a tmux or Herdr server, which daemonize outside that shell's tree.
A stale id, an id from another session, or an inherited id of an unrelated terminal falls back to the default with no error.
--outlive-parent stays, so closing or restarting the Firstmate terminal never kills its crew.
Keep #7963's names (backend hc, firstmate.* labels, hc_terminal); no private host names, IPs, accounts or people; one sentence per line in Markdown.

What Changed

  • bin/backends/hc.sh adds fm_backend_hc_caller_terminal. It treats HC_TERMINAL_ID only as a hint. The id is accepted only when hc get on the task's session reports that terminal live and the terminal's top-level shell pid is an ancestor of the spawning process, checked by walking up at most 64 parents. A stale id, an id from another session, or an id inherited from an unrelated terminal returns nothing, with no error.
  • fm_backend_hc_create_task consults it only when FM_HC_BESIDE_FIRSTMATE=1. When a caller terminal is found, the task starts with --parent <firstmate terminal> instead of --no-parent and uses that terminal's herdr.space label. The space is chosen in this order: FM_HC_SPACE, then the caller's space, then fm-<hometag>. --outlive-parent and --no-notify are always passed. Without the opt-in, or when no caller terminal is found, behavior is the same as feat(backends): add experimental explicit-only hc (herdr-core) runtime backend #7963.
  • Tests and docs:
    • Fake-hc tests in tests/fm-backend-hc.test.sh check that with the opt-in unset, 0, or yes, a qualifying Firstmate terminal is neither looked up nor adopted, while the same setup with 1 adopts it. With the opt-in on, they cover an ancestor caller, the FM_HC_SPACE override, a caller with no space, a live terminal that is not an ancestor, and an unknown id.
    • The real-hc smoke suite in tests/fm-backend-hc-smoke.test.sh checks that a task created inside a stand-in Firstmate terminal has no parent and gets the default space by default, and with the opt-in reports that terminal as parent and shares its space. It also checks that, with the opt-in on, a task created from outside has no parent and gets the default space.
    • docs/hc-backend.md documents the opt-in and its placement rules, and docs/verification/runtime-backends.md records the smoke run.

Update: opt-in instead of a new default

Following the review discussion, side-by-side placement is now opt-in, so the default layout stays the same for homes on hc and on the Herdr TUI.
This update was pushed directly, without a new no-mistakes run, so the Testing and Pipeline sections below describe the earlier default-on head (12ea73a5).
For this head, checks were run by hand:

  • bash tests/fm-backend-hc.test.sh: 14 of 14 pass, including the new opt-in case.
  • Removing the opt-in gate makes the new fake-hc case fail (not ok - opt-in unset: the task must start with no parent).
  • tests/fm-backend-hc-smoke.test.sh against real hc 0.1.14 (installed into a throwaway directory with the official installer, which checks its SHA-256, then removed): all pass, transcript in docs/verification/runtime-backends.md.
  • bin/fm-lint.sh and bin/fm-doc-audience-check.sh pass.
    The branch is still based on the merge base of feat(backends): add experimental explicit-only hc (herdr-core) runtime backend #7963, so the conflict with main that was already flagged is unchanged.

🤖 Generated with Claude Code

Risk Assessment

✅ Low: The change matches the intent. It is bounded to the explicit-only hc backend, adopts a parent only after a live same-session hc get and a bounded check that the terminal's shell is an ancestor, otherwise falls back silently to the #7963 behavior, and has fake-hc and real-hc tests for each required case.

Testing

hc was not on PATH, so I installed hc 0.1.14 into a disposable /tmp directory from herdr-core's official installer and deleted it when done. With that binary I ran the real-hc smoke suite, which passed, including the new stand-in Firstmate terminal case. The fake-hc suite passed all 13 cases. I also ran 11 adversarial live checks of my own against two private real hc cores, all of which passed: - A task launched through a wrapper that holds the foreground (foreground pid differs from the shell pid) still becomes the Firstmate terminal's child in its space. - FM_HC_SPACE overrides the caller's space and keeps the parent. - An inherited id reaching a setsid-daemonized process, or a tmux server started inside the terminal, falls back to no parent and the home space. - An id from another session falls back too, even when the same address is live in the target session. - An unknown id, a live non-ancestor id, and the stale id of a closed Firstmate terminal all fall back with no error. - Children stay live after their Firstmate terminal is killed. A mutation that bypasses the ancestry walk makes the fake suite fail on the non-ancestor case, as the intent requires. Because that check is a unit-suite mutation and not a live product run, it is recorded as untested. Logs and the scenario script are in the evidence directory. There is no UI surface to screenshot. The hc CLI reports parent and labels as JSON, which the logs capture. The worktree is clean, and all private cores and temp dirs I created are gone.

  • Live validation: ✅ go - 7 of 8 scenarios driven live against the product
Scenario Result Live Evidence
Task created inside a stand-in Firstmate hc terminal reports that terminal as parent and its herdr.space; task created outside has no parent and fm-<hometag> ✅ pass live hc-smoke-real-hc-0.1.14.log ('a task created inside Firstmate's own hc terminal joins its space as its child')
Firstmate under a wrapper that holds the terminal foreground still parents its tasks ✅ pass live hc-adversarial-live.log scenario 1 (foreground pid != shell pid, child parent=t1 space=fm-space)
Explicit FM_HC_SPACE wins over the caller's space while keeping the parent ✅ pass live hc-adversarial-live.log scenario 2 (t1 chosen)
Inherited HC_TERMINAL_ID reaching a daemonized process or a tmux server started inside the terminal does not adopt the terminal ✅ pass live hc-adversarial-live.log scenarios 3 and 3b (none fm-<hometag>)
Id from another hc session falls back to no parent even when the same address is live in the task's session ✅ pass live hc-adversarial-live.log scenario 4
Unknown, live non-ancestor, and stale (closed) ids fall back to --no-parent and the home space with no error ✅ pass live hc-adversarial-live.log scenarios 5, 5b, 6b
Killing the Firstmate terminal leaves its child tasks running (--outlive-parent) ✅ pass live hc-adversarial-live.log scenario 6 (parent finished, children t2/t3 live)
Removing the ancestry check makes the fake-hc test fail ⏸️ untested no The prior payload records this only as a mutation run of the fake-hc unit suite on a throwaway repo copy, not a live product run, so it did not establish a live result. The live non-ancestor fallback…
Evidence: Real-hc smoke suite transcript (hc 0.1.14)

Source: Real-hc smoke suite transcript (hc 0.1.14)

ok - hc smoke: create_task started fmt3609249:t1
ok - hc smoke: current_path follows the shell's cwd
ok - hc smoke: send_text_line ran the command and capture shows its output
ok - hc smoke: agent_state reads dead for a shell and alive for an agent-named foreground
ok - hc smoke: kill closes and removes the terminal
ok - hc smoke: a task created inside Firstmate's own hc terminal joins its space as its child
FM_TEST_COMPLETE
Evidence: Adversarial live scenarios transcript

Source: Adversarial live scenarios transcript

stand-in Firstmate terminal: fmA3655287:t1 ({"pid":3655400,"state":"live","labels":{"herdr.space":"fm-space"}})
  foreground while wrapper runs: {"pid":3655400,"fg":3656323}
PASS - 1 wrapper holding foreground: child of Firstmate in its space (got: t1 fm-space)
PASS - 2 FM_HC_SPACE wins over caller space, parent kept (got: t1 chosen)
PASS - 3 daemonized descendant with inherited HC_TERMINAL_ID: no parent, home space (got: none fm-firstmate-e25f7f5d)
PASS - 3b inherited id inside a tmux server started in the terminal: no parent, home space (got: none fm-firstmate-e25f7f5d)
  core B terminal: fmB3655287:t1 (core A has t1 live with same-style address)
PASS - 4 id from another session (address collides with a live A terminal): no parent (got: none fm-firstmate-e25f7f5d)
PASS - 5 unknown HC_TERMINAL_ID: no parent, no error (got: none fm-firstmate-e25f7f5d)
PASS - 5b live non-ancestor terminal id: no parent, home space (got: none fm-firstmate-e25f7f5d)
PASS - 6a Firstmate terminal state after close (got: finished)
PASS - 6 child t2 still live after its Firstmate terminal closed (got: live)
PASS - 6 child t3 still live after its Firstmate terminal closed (got: live)
PASS - 6b stale id of the closed Firstmate terminal: no parent (got: none fm-firstmate-e25f7f5d)
--- core A listing
{"address":"t2","parent":"t1","state":"live","space":null,"tab":null}
{"address":"t3","parent":"t1","state":"live","space":null,"tab":null}
{"address":"t4","parent":null,"state":"live","space":null,"tab":null}
{"address":"t5","parent":null,"state":"live","space":null,"tab":null}
{"address":"t6","parent":null,"state":"live","space":null,"tab":null}
{"address":"t7","parent":null,"state":"live","space":null,"tab":null}
{"address":"t8","parent":null,"state":"live","space":null,"tab":null}
{"address":"t9","parent":null,"state":"live","space":null,"tab":null}
FAILS=0
Evidence: Adversarial live scenario script

Source: Adversarial live scenario script

#!/usr/bin/env bash
# Adversarial live scenarios for hc caller-terminal inheritance, against private real hc cores.
set -u
ROOT=$1
HC_ROOT=$(mktemp -d /tmp/fmhcA.XXXXXX)
FM_HOME_DIR="$HC_ROOT/home"; WORK_DIR="$HC_ROOT/work"
mkdir -p "$FM_HOME_DIR" "$WORK_DIR" "$HC_ROOT/config" "$HC_ROOT/data" "$HC_ROOT/cache"
WORK_DIR=$(cd "$WORK_DIR" && pwd -P)
unset HC_TERMINAL_ID HC_TERMINAL_SOCKET HC_SCOPE HC_SOCKET
A="fmA$$"; B="fmB$$"
export HC_SESSION=$A
export XDG_STATE_HOME="$HC_ROOT" XDG_RUNTIME_DIR="$HC_ROOT" XDG_CONFIG_HOME="$HC_ROOT/config"
export XDG_DATA_HOME="$HC_ROOT/data" XDG_CACHE_HOME="$HC_ROOT/cache"
export FM_HOME="$FM_HOME_DIR" FM_ROOT_OVERRIDE="$FM_HOME_DIR"
cleanup() { HC_SESSION=$A hc server stop --json >/dev/null 2>&1; HC_SESSION=$B hc server stop --json >/dev/null 2>&1; rm -rf "$HC_ROOT"; }
trap cleanup EXIT
. "$ROOT/bin/fm-backend.sh"; fm_backend_source hc || exit 2
HT=$(fm_backend_hometag)
FAILS=0
check() { if [ "$1" = "$2" ]; then echo "PASS - $3 (got: $1)"; else echo "FAIL - $3 (want: $2, got: $1)"; FAILS=$((FAILS+1)); fi; }
wait_file() { local i=0; while [ $i -lt 200 ]; do [ -s "$1" ] && return 0; sleep 0.1; i=$((i+1)); done; return 1; }
desc() { fm_backend_hc_cli "$1" get --json "$2" | jq -r '[.parent // "none", .labels["herdr.space"] // ""] | @tsv' | tr '\t' ' '; }
HC_SESSION=$A hc server status --json >/dev/null || exit 3
HC_SESSION=$B hc server status --json >/dev/null || exit 3
mk() { # <session> <space> -> address
  HC_SESSION=$1 hc run --bg --json --no-parent --label herdr.space=$2 --cwd "$WORK_DIR" | jq -r '.address // empty'; }
inner() { # <file> <label> <session> -> script that runs create_task
  cat > "$HC_ROOT/$1.sh" <<EOF
unset HC_SESSION
. '$ROOT/bin/fm-backend.sh'; fm_backend_source hc
fm_backend_hc_create_task '$3' '$2' '$WORK_DIR' > '$HC_ROOT/$2.addr' 2> '$HC_ROOT/$2.err'
EOF
}
ENVP="FM_HOME='$FM_HOME_DIR' FM_ROOT_OVERRIDE='$FM_HOME_DIR'"

FM=$(mk $A fm-space); echo "stand-in Firstmate terminal: $A:$FM ($(fm_backend_hc_cli $A get --json $FM | jq -c '{pid,state,labels}'))"

# 1. Wrapper/launcher holding the foreground: create_task runs two bash levels below the shell.
inner s1 fm-wrapped $A
fm_backend_hc_cli $A send --json "$FM" "$ENVP bash -c 'bash -c \"sleep 2; bash $HC_ROOT/s1.sh\"'" >/dev/null
sleep 1; echo "  foreground while wrapper runs: $(fm_backend_hc_cli $A get --json $FM | jq -c '{pid, fg: .foreground.pid}')"
wait_file "$HC_ROOT/fm-wrapped.addr" || echo "  no addr: $(cat $HC_ROOT/fm-wrapped.err)"
C1=$(cat "$HC_ROOT/fm-wrapped.addr"); check "$(desc $A $C1)" "$FM fm-space" "1 wrapper holding foreground: child of Firstmate in its space"

# 2. FM_HC_SPACE override from inside.
inner s2 fm-override $A
fm_backend_hc_cli $A send --json "$FM" "$ENVP FM_HC_SPACE=chosen bash $HC_ROOT/s2.sh" >/dev/null
wait_file "$HC_ROOT/fm-override.addr"; C2=$(cat "$HC_ROOT/fm-override.addr")
check "$(desc $A $C2)" "$FM chosen" "2 FM_HC_SPACE wins over caller space, parent kept"

# 3. Inherited id through a daemonized process (setsid -f escapes the shell's tree, like a tmux/Herdr server).
inner s3 fm-daemon $A
fm_backend_hc_cli $A send --json "$FM" "$ENVP setsid -f bash $HC_ROOT/s3.sh </dev/null >/dev/null 2>&1" >/dev/null
wait_file "$HC_ROOT/fm-daemon.addr"; C3=$(cat "$HC_ROOT/fm-daemon.addr")
check "$(desc $A $C3)" "none fm-$HT" "3 daemonized descendant with inherited HC_TERMINAL_ID: no parent, home space"

# 3b. Inherited id through a real tmux server started inside the Firstmate terminal (private socket).
inner s3b fm-tmux $A
fm_backend_hc_cli $A send --json "$FM" "TMUX_TMPDIR=$HC_ROOT tmux -L fmhcadv new-session -d -s x \"$ENVP bash $HC_ROOT/s3b.sh\"" >/dev/null
wait_file "$HC_ROOT/fm-tmux.addr"; C3b=$(cat "$HC_ROOT/fm-tmux.addr")
check "$(desc $A $C3b)" "none fm-$HT" "3b inherited id inside a tmux server started in the terminal: no parent, home space"
TMUX_TMPDIR=$HC_ROOT tmux -L fmhcadv kill-server 2>/dev/null

# 4. Id from another session: a terminal in core B creates a task in core A. Make sure core A has a live
#    terminal with the SAME address (unrelated), so only the session/ancestry checks can reject it.
FB=$(mk $B space-b); echo "  core B terminal: $B:$FB (core A has $FM live with same-style address)"
inner s4 fm-foreign $A
fm_backend_hc_cli $B send --json "$FB" "$ENVP bash $HC_ROOT/s4.sh" >/dev/null
wait_file "$HC_ROOT/fm-foreign.addr"; C4=$(cat "$HC_ROOT/fm-foreign.addr")
check "$(desc $A $C4)" "none fm-$HT" "4 id from another session (address collides with a live A terminal): no parent"

# 5. Stale / unknown id from outside.
C5=$(HC_TERMINAL_ID=t999 fm_backend_hc_create_task $A fm-stale "$WORK_DIR" 2>&1) || echo "  error: $C5"
check "$(desc $A $C5)" "none fm-$HT" "5 unknown HC_TERMINAL_ID: no parent, no error"

# 5b. A live but non-ancestor terminal id set by hand from outside.
C5b=$(HC_TERMINAL_ID=$FM fm_backend_hc_create_task $A fm-nonanc "$WORK_DIR" 2>&1) || echo "  error: $C5b"
check "$(desc $A $C5b)" "none fm-$HT" "5b live non-ancestor terminal id: no parent, home space"

# 6. --outlive-parent: closing the Firstmate terminal leaves its children running.
fm_backend_hc_cli $A kill --json "$FM" >/dev/null 2>&1
sleep 1
check "$(fm_backend_hc_cli $A get --json $FM 2>/dev/null | jq -r '.state // "gone"' || echo gone)" finished "6a Firstmate terminal state after close"
for c in $C1 $C2; do check "$(fm_backend_hc_cli $A get --json $c | jq -r .state)" live "6 child $c still live after its Firstmate terminal closed"; done

# 6b. After the parent is gone, a stale id from a previously-valid Firstmate falls back.
C6=$(HC_TERMINAL_ID=$FM fm_backend_hc_create_task $A fm-after "$WORK_DIR" 2>&1) || echo "  error: $C6"
check "$(desc $A $C6)" "none fm-$HT" "6b stale id of the closed Firstmate terminal: no parent"

echo "--- core A listing"; fm_backend_hc_cli $A ls --json | jq -c '(if type=="array" then .[] else (.terminals // .items // [])[] end) | {address, parent, state, space: .labels["herdr.space"], tab: .labels["herdr.tab"]}' 2>/dev/null
echo "FAILS=$FAILS"
Evidence: Fake-hc suite transcript

Source: Fake-hc suite transcript

1..13
ok - hc: explicit-only, spawn-capable, with its tool set
ok - hc: create_task starts an independent labeled terminal and refuses a duplicate
ok - hc: inside Firstmate's own hc terminal a task joins its space as a child; a non-ancestor or unknown id is ignored
ok - hc: fm-control interrupt delivers the harness's interrupt key
ok - hc: another task's, another home's, or an unlabeled terminal gets no input and no close
ok - hc: an empty session never falls through to the ambient core
ok - hc: an inherited HC_SOCKET never overrides the session pin
ok - hc: agent_state maps foreground, finished, not_found and core errors onto the shared vocabulary
ok - hc: agent_state reads a shell wrapper's process group before calling it dead
ok - hc: kill ends and removes the terminal and refuses when it survives
ok - hc: teardown's expected label refuses another task's terminal and closes the matching one
ok - hc: capture, visible capture, and current path read the recorded terminal
ok - hc: endpoint validation requires window to equal hc_session:hc_terminal
FM_TEST_COMPLETE
Evidence: Mutation (ancestry check removed) makes the fake test fail

Source: Mutation (ancestry check removed) makes the fake test fail

1..13
not ok - HC_TERMINAL_ID=t3 must not adopt a parent (missing: '--no-parent')
--- output ---
HC_SESSION=fmtest HC_SOCKET=^_run^_--bg^_--json^_--parent^_t3^_--outlive-parent^_--no-notify^_--cwd^_/proj^_--label^_firstmate.task=fm-b-t3^_--label^_firstmate.home=firstmate-963ba506^_--label^_herdr.space=space-other^_--label^_herdr.tab=firstmate-963ba506-fm-b-t3
Evidence: Adversarial results summary
PASS 1 wrapper holding foreground (pid 3655400, fg 3656323): t1 fm-space
PASS 2 FM_HC_SPACE override: t1 chosen
PASS 3 setsid daemon: none fm-<hometag>
PASS 3b tmux server inside terminal: none fm-<hometag>
PASS 4 other-session id colliding with live A:t1: none
PASS 5 unknown id: none
PASS 5b live non-ancestor: none
PASS 6 children live after parent killed
PASS 6b stale id after close: none

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 7 of 8 scenarios driven live against the product
Scenario Result Live Evidence
Task created inside a stand-in Firstmate hc terminal reports that terminal as parent and its herdr.space; task created outside has no parent and fm-<hometag> ✅ pass live hc-smoke-real-hc-0.1.14.log ('a task created inside Firstmate's own hc terminal joins its space as its child')
Firstmate under a wrapper that holds the terminal foreground still parents its tasks ✅ pass live hc-adversarial-live.log scenario 1 (foreground pid != shell pid, child parent=t1 space=fm-space)
Explicit FM_HC_SPACE wins over the caller's space while keeping the parent ✅ pass live hc-adversarial-live.log scenario 2 (t1 chosen)
Inherited HC_TERMINAL_ID reaching a daemonized process or a tmux server started inside the terminal does not adopt the terminal ✅ pass live hc-adversarial-live.log scenarios 3 and 3b (none fm-<hometag>)
Id from another hc session falls back to no parent even when the same address is live in the task's session ✅ pass live hc-adversarial-live.log scenario 4
Unknown, live non-ancestor, and stale (closed) ids fall back to --no-parent and the home space with no error ✅ pass live hc-adversarial-live.log scenarios 5, 5b, 6b
Killing the Firstmate terminal leaves its child tasks running (--outlive-parent) ✅ pass live hc-adversarial-live.log scenario 6 (parent finished, children t2/t3 live)
Removing the ancestry check makes the fake-hc test fail ⏸️ untested no The prior payload records this only as a mutation run of the fake-hc unit suite on a throwaway repo copy, not a live product run, so it did not establish a live result. The live non-ancestor fallback…
  • Installed hc 0.1.14 from the official install script into a disposable /tmp dir (HC_VERSION=0.1.14 HC_INSTALL_DIR=/tmp/hcdl.*/bin) and removed it afterwards
  • env -u HC_TERMINAL_ID -u HC_SESSION PATH=/tmp/hcdl.*/bin:$PATH bash tests/fm-backend-hc-smoke.test.sh (real hc, private core)
  • bash tests/fm-backend-hc.test.sh (fake-hc suite, 13 cases)
  • bash hc-adversarial-live.sh &lt;worktree&gt;: 11 live checks on two private real hc cores (wrapper-held foreground, FM_HC_SPACE override, setsid-daemonized descendant, tmux server started inside the terminal, colliding id from another session, unknown id, live non-ancestor id, parent closed with children still live, stale id after close)
  • Mutation check: a throwaway copy of the repo with the ancestry walk short-circuited, then ran tests/fm-backend-hc.test.sh on it
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

When Firstmate itself runs in a live hc terminal of the task's session,
create_task now makes the task terminal that terminal's child and gives it
that terminal's herdr.space, so Herdr.app shows the crew as sub-agents in
the Firstmate's own space. FM_HC_SPACE still wins when set, and outside an
hc terminal nothing changes: --no-parent and fm-<hometag>.

HC_TERMINAL_ID reaches every descendant of an hc terminal, including ones
attached to another session's core, so it counts only when the address
answers live in the task's session and that terminal's shell pid is an
ancestor of the spawning process. --outlive-parent and --no-notify still
apply, so a task survives Firstmate's exit and hc never types into
Firstmate's composer.

Fake-hc cases cover a real ancestor, an explicit FM_HC_SPACE, an unplaced
caller, a live non-ancestor, and an unknown id; a real-hc smoke case runs
create_task inside a stand-in Firstmate terminal (hc 0.1.14, Linux).
@greptile-apps

greptile-apps Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the previous finding is fixed and no new issues were found.

Reviews (2) · Last reviewed commit: "no-mistakes(ci): I added FM_HC_SPACE to ..." · Reviewed by Greptile

Comment thread tests/fm-backend-hc-smoke.test.sh Resolved
…sts/fm-backend-hc-smoke.test.sh (line 37), so it now reads `unset HC_TERMINAL_ID HC_TERMINAL_SOCKET HC_SCOPE HC_SOCKET FM_HC_SPACE`. This was the only change, as you asked. The rule behind it is that the smoke suite's outside-task check must not depend on the developer's environment. The suite's only other inherited `herdr.space` input is HC_TERMINAL_ID, and that line already unsets it. `bash -n` passes. I could not run the smoke suite itself: hc is not on PATH here, so the script printed `skip: hc not found` and exited before running any checks
AokDesu added a commit to AokDesu/firstmate that referenced this pull request Nov 3, 2026
…nals beside the Firstmate that launched them

# Conflicts:
#	bin/backends/hc.sh
#	docs/hc-backend.md
#	tests/fm-backend-hc-smoke.test.sh
#	tests/fm-backend-hc.test.sh
@MarceloCajueiro

Copy link
Copy Markdown

Hi! I'm following this one closely: I'm waiting on the hc backend work to move my Firstmate setup to the Herdr desktop app. Having task terminals open next to the Firstmate that launched them would make the app layout much more usable for me.

If anything is needed to move this forward (testing on macOS against a real Herdr.app/herdr-core, reproducing a review finding, or picking up a follow-up), I'm happy to help. Just let me know.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @LuizBrugnera, and sorry for the wait. I approved your first-time fork CI, and the quick checks pass on 12ea73a5. The attestation binds the head with no skipped steps, the live adversarial run is thorough, and Greptile's one thread is resolved. Contract-class (my own read): new-default. Since #8060, main auto-selects hc inside Herdr app terminals, so an unconfigured home running there would now get its crew as child terminals in Firstmate's space. That is a default layout change, so it's Kun's call. VISION: aligns. The conflict with main is ours to fix on Kun's word. This is waiting on Kun, not on you. Thanks too @MarceloCajueiro for offering to test on macOS.

@LuizBrugnera

Copy link
Copy Markdown
Author

Thanks for the thorough triage and for approving the fork CI. Understood that this waits on Kun's call on the default layout. If Kun prefers keeping today's layout as the default, I can put the side-by-side terminals behind an opt-in instead, or rebase onto main myself once there's a decision. Happy to adjust either way.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @LuizBrugnera for the kind reply and for offering both options. You don't need to rebase. The conflict with main is ours to fix if Kun says go. I've noted your offer to put the side-by-side terminals behind an opt-in so Kun has it when he decides. Until then, nothing is needed from you. This is waiting on Kun, not on you.

@rchristensen

Copy link
Copy Markdown
Contributor

Weighing in on the open question here: we'd prefer the side-by-side layout as an opt-in rather than the new default. We expect to keep running both hc and the Herdr TUI going forward, so the default layout should keep working for homes on either one, with beside-the-launcher terminals available for homes that want them. @LuizBrugnera's offer to put this behind an opt-in sounds like the right shape to us. Thanks for the careful work on this.

…STMATE=1)

Task terminals open as children of Firstmate's own hc terminal, in its
herdr.space, only when FM_HC_BESIDE_FIRSTMATE=1. Unset or any other value
keeps the kunchenguid#7963 default: --no-parent and herdr.space=FM_HC_SPACE or
fm-<hometag>. Tests cover the default staying off and the opt-in on; the
docs and the real-hc smoke record describe the opt-in.
@LuizBrugnera

Copy link
Copy Markdown
Author

@rchristensen thanks for weighing in. Side-by-side placement is now opt-in (16740b2): by default hc task terminals keep #7963's layout (--no-parent, herdr.space=${FM_HC_SPACE:-fm-<hometag>}), so nothing changes for homes on hc or the Herdr TUI.
To enable it, set FM_HC_BESIDE_FIRSTMATE=1 in the environment Firstmate runs in; then, when Firstmate itself runs in a live hc terminal, each task terminal opens as its child in its Herdr.app space. Docs are in docs/hc-backend.md under "Opt-in: task terminals beside Firstmate".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants