Skip to content

feat(bin): add Firstmate commands to the Rex command palette - #5

Merged
roderik merged 3 commits into
mainfrom
fm/rex-backend-p4
Oct 22, 2026
Merged

roderik merged 3 commits into
mainfrom
fm/rex-backend-p4

Conversation

@roderik

@roderik roderik commented Oct 22, 2026

Copy link
Copy Markdown
Owner

Summary

Part of Rex Phase 4: Firstmate commands in the Rex command palette (A1, A2, D, E from the Phase 4 pick).

  • A1, look-only commands plus installer: Show Fleet, This Worker, Peek Worker, and Go to Waiting Worker. bin/fm-rex-palette.sh install|uninstall owns one marked block at the top of the Rex init.lua. The new file must pass rex config check before it replaces the old one, and a backup is kept. Uninstall restores the file byte for byte. When Firstmate's module fails to load, the rest of the config still loads.
  • A2, acting commands: Answer Decision, Tell Firstmate, and Request Merge only file a captain inbox note through bin/fm-inbox.sh. They never steer a worker or merge, so merges always go through Firstmate.
  • D, remote second mates: a pane on another host, such as ds9, resolves to its second mate from this home's records. Popups, and Go to Waiting Worker for a remote second mate, always use this machine's fm-local session.
  • E, away pane: Show or Hide Away Pane toggles the away supervisor's detached block into the layout and back out, without stopping it.
  • No default key bindings: shortcuts are assigned in the Rex app.

bin/backends/rex-palette.lua defines the actions, and bin/fm-rex-popup.sh plans each action and runs the popup bodies. docs/rex-backend.md "Command palette" owns the public contract.

Validation

  • tests/fm-rex-palette.test.sh (fake rex) passes 14 of 14 checks: installer placement, idempotence, reload, refusals, symlinks, pane resolution (local and remote), goto ranking and remote selection, the away toggle, and the inbox-only acting popups.
  • tests/fm-rex-palette-smoke.test.sh passes 7 of 7 on a private lab Rex server. The lab's live-server tripwire was clean.
  • bin/fm-lint.sh and bin/fm-doc-audience-check.sh are clean.
  • The no-mistakes pipeline was not used for delivery. Its review agent timed out twice at the 30-minute limit, so this PR was opened directly. An earlier no-mistakes review round raised 10 findings, and all of them are addressed in the last two commits.

Add a Firstmate group to Rex's command palette: Show Fleet, This Worker,
Peek Worker, Go to Waiting Worker, Show or Hide Away Pane, Answer
Decision, Tell Firstmate, and Request Merge.

- bin/fm-rex-palette.sh installs, removes, checks, and reports one marked
  block at the top of this machine's Rex init.lua: it refuses unbalanced
  markers, a failing config check, and a remote server, backs the file up,
  keeps its mode, edits a symlink's target, and uninstalls byte for byte.
  No key is bound.
- bin/backends/rex-palette.lua defines the actions; each asks
  bin/fm-rex-popup.sh plan what to do, opens a floating popup, and moves
  the view only for a key or palette use.
- bin/fm-rex-popup.sh resolves the focused pane to a task, or a pane on
  another host to its remote second mate, shows popups on this machine,
  ranks waiting workers for goto, and shows or hides the away daemon's
  detached block. The acting popups only file captain inbox notes;
  nothing steers a worker or merges.
- Tests: a fake-rex unit suite and a token-free lab-server smoke, mapped
  to the rex family; docs and dated verification evidence.
… surface

Go to Waiting Worker shows this machine's fm-local session for a remote
second mate instead of selecting another host's session id. The away
command is a plain toggle, the installer keeps only install and uninstall,
an unchanged install still reloads, and This Worker shows its fallback
for a task with no status line.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-22T14:27:23.436122Z d34eba6 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@roderik
roderik merged commit ad872a9 into main Oct 22, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d34eba6217

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread bin/fm-rex-popup.sh
Comment on lines +409 to +414
snapshot | jq -r --arg t "${1:-}" '
[ ((.tasks // [])[] | select($t == "" or .id == $t) | . as $r
| ($r.hints.open_decisions // [])[] | [$r.id, (.key // ""), (.summary // "")]),
((.backlog.records // [])[] | select(.captain_actionable == true) | select($t == "" or .id == $t)
| [.id, "", (.hold_reason // .title // "")]) ]
| .[] | map(gsub("[\t\n\r]"; " ")) | @tsv'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Include remote secondmate decisions in Answer Decision

Captain, when the focused worker is managed by a remote secondmate, its open decisions are exposed by the fleet snapshot under secondmate_current.records[].decisions_open, but this query only reads local .tasks[].hints.open_decisions and .backlog.records[].captain_actionable. As a result, Answer Decision reports no pending decision (or omits it from the list) and cannot file an answer for remote secondmate workers.

Useful? React with 👍 / 👎.

Comment thread bin/fm-rex-popup.sh
Comment on lines +224 to +237
first_waiting() {
local meta id kind rank best='' best_rank=9
for meta in "$STATE"/*.meta; do
[ -f "$meta" ] && [ ! -L "$meta" ] || continue
id=${meta##*/}
id=${id%.meta}
task_ok "$id" || continue
[ "$(fm_meta_get "$meta" backend)" = rex ] || [ "$(fm_meta_get "$meta" remote_backend)" = rex ] || continue
kind=$(fm_meta_get "$meta" kind)
rank=$(waiting_rank "$id" "${kind:-ship}")
[ -n "$rank" ] && [ "$rank" -lt "$best_rank" ] || continue
best=$id
best_rank=$rank
done

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Rank remote secondmate child waits in Go to Waiting Worker

When a child of a remote secondmate is waiting on the captain, Go to Waiting Worker does not see it: first_waiting ranks only the parent home's state/<id>.status for each metadata record, while remote child decisions and holds are published in secondmate_current.records[].decisions_open and holds. This can select a lower-priority local task or report that nobody is waiting even though a remote worker has an actionable decision.

Useful? React with 👍 / 👎.

Comment thread bin/fm-rex-popup.sh
Comment on lines +473 to +480
body_merge() {
local task=${1:-} rows url t confirm
rows=$(snapshot | jq -r --arg t "$task" \
'(.tasks // [])[] | select($t == "" or .id == $t) | select((.pr.url // "") != "") | [.id, "", .pr.url] | @tsv')
if [ -z "$rows" ] && [ -n "$task" ]; then
printf 'No pull request is recorded for %s; showing every recorded one.\n\n' "$task"
rows=$(snapshot | jq -r '(.tasks // [])[] | select((.pr.url // "") != "") | [.id, "", .pr.url] | @tsv')
fi

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Include remote child pull requests in Request Merge

For a pull request belonging to a worker under a remote secondmate, the fleet snapshot exposes that worker through the secondmate summary rather than as a local .tasks[] row, but this query only scans (.tasks // [])[] for .pr.url. The Request Merge popup therefore reports no pull request (or only lists local workers) and cannot file a merge request for remote secondmate work.

Useful? React with 👍 / 👎.

Comment thread bin/fm-rex-popup.sh
Comment on lines +211 to +214
out=$(FM_BACKEND_REX_SERVER=$(fm_meta_get "$meta" rex_server) fm_backend_rex_block_inspect "$(fm_meta_get "$meta" window)") \
&& out=$(printf '%s' "$out" | jq -r '.block.window_id // empty' 2>/dev/null) \
&& [ -n "$out" ] && G_WINDOW=$out
return 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Fail Go to Waiting Worker when its tab is stale

If a local worker's recorded Rex session or block has been deleted or its server is unreachable, fm_backend_rex_block_inspect fails, but this && chain is ignored and goto_target still returns success with the stale metadata window. fm_goto then emits a selection for a nonexistent tab instead of reporting that the worker no longer has a live Rex target.

Useful? React with 👍 / 👎.

Comment thread bin/fm-rex-popup.sh
Comment on lines +356 to +365
file_note() { # <text>
local text=$1 rid out rc
rid="rex-palette-$(date +%s)-$$-$RANDOM"
out=$("$SCRIPT_DIR/fm-inbox.sh" note --request-id "$rid" -- "$text" 2>&1)
rc=$?
case "$rc" in
0) printf '\nFiled for Firstmate:\n %s\n' "$text" ;;
3) printf '\nSaved for Firstmate, but its wake could not be queued; Firstmate sees it at its next inbox read:\n %s\n' "$text" ;;
*) printf '\nCould not file the note (%s): %s\n' "$rc" "$out" ;;
esac

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Propagate inbox write failures from acting popups

When fm-inbox.sh note fails with any status other than 0 or 3, file_note prints an error but then returns the success status of printf; the answer, note, and merge popup bodies therefore exit successfully even though the requested captain inbox action was not saved. Rex callers and automation cannot distinguish a completed action from a failed write.

Useful? React with 👍 / 👎.

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.

1 participant