Skip to content

feat(rex): Rex Annotate, plus popup placement and Node agent detection - #140

Merged
backnotprop merged 6 commits into
mainfrom
feat/rex-annotate
Nov 10, 2026
Merged

backnotprop merged 6 commits into
mainfrom
feat/rex-annotate

Conversation

@backnotprop

Copy link
Copy Markdown
Contributor

Summary

Add Rex Annotate: Herdr Annotate's reviews, on a key in Rex. Rex has no plugin manifest, but its init.lua can require Lua files stored beside it. So Rex Annotate is a Lua module that this binary embeds and writes. Follows #127. Refs #136.

plannotator-tui rex install        # writes ~/.config/rex/plannotator/annotate.lua
# then add to ~/.config/rex/init.lua:  require("plannotator.annotate").setup{}
rex config reload
Key Action (palette: Annotate) Runs
Shift+Cmd+O annotate_last plannotator-tui rex last
Alt+Shift+Cmd+O annotate_newest rex last --newest
Ctrl+Cmd+O annotate_open rex open (the pane's folder)
annotate_gate, annotate_terminal, annotate_find rex open --gate, rex terminal, rex find

Rex for Mac binds none of these keys. setup{ placement, keys, bin } changes them; keys = false binds none. The actions run in the Rex server, so the app's Remote Control can stay off.

Three changes:

  • Split or popup. --placement split|popup, or [rex] placement in the config file. A popup is a floating layer in the agent's own window (session.describe_block → session.new_layer). Split stays the default.
  • The agent is named by its own status report. pi runs under node, so feat(rex): open reviews in rex and send feedback back #127 saw node and offered Copy, not Send. The launcher now reads the program_status record owned by the foreground pid (effective_app, then app; claude-code is Claude), then the process name, then the script Rex reports for an interpreter.
  • rex install [--dry-run | --print]. It writes the module beside Rex's init.lua ($REX_CONFIG, else $XDG_CONFIG_HOME/rex, else ~/.config/rex), naming this binary by its absolute path, because Rex runs actions with PATH=/usr/bin:/bin:/usr/sbin:/sbin. It never edits init.lua; it prints the require line. It runs rex config check on a scratch copy (the module plus the require line in a temp dir), so the person's config is not read.
 src/rex/
+├── annotate.lua   # the module, include_str!
+├── install.rs     # `rex install`
+├── place.rs       # split or popup arguments; moved out of launch.rs
 ├── launch.rs      # + reported_host: the agent from program_status
 └── cli.rs         # + --placement, install

Evidence

On a throwaway Rex server (build 1921, server 0.1.0-preview.14, API 12) with its own socket and config dir. Fake agents: a C claude and a Node pi at …/pi-coding-agent/dist/bundle/cli.js. Both report OSC 7501 status, turn on bracketed paste, and log their input.

  • Before: on the pi pane, feat(rex): open reviews in rex and send feedback back #127's head showed Copy 0 new across 0 files (E).
    After: Send 0 new across 0 files ▸ pi in 306755 (E).
  • rex install printed created …/plannotator/annotate.lua, the require line, and rex config check: the module loads cleanly. Run again: unchanged. --dry-run wrote nothing. Without rex it printed skipped rex config check.
  • rex config check on the config dir with the module and require line: bindings: 3, actions: 6. After rex config reload, rex keymap lists the three keys from plannotator/annotate.lua.
  • rex do annotate_open --origin key on claude: split; comment; E. claude received \x1b[200~# Annotations on plan.md … > Claude: tighten step two.\n\n\n\x1b[201~\r.
  • With [rex] placement = "popup" and another window active, annotate_open on pi opened floating [0.05, 0.075, 0.9, 0.85] in pi's window, focused. Send: pi received \x1b[200~# Annotations on plan.md … > Pi: say what one step means.\n\n\n\x1b[201~\r.
  • setup{ placement = "split" } overrode the config popup. placement = "sideways" failed the action with unknown Rex placement "sideways"; expected split or popup. keys = false bound none.

New tests, for example:

an_agent_under_an_interpreter_is_named_by_its_own_status_report
a_status_left_by_another_process_names_no_agent
a_popup_floats_inside_the_agents_window_and_takes_focus
rex_opens_in_a_split_unless_a_popup_is_asked_for_and_has_no_overlay
the_module_goes_where_rex_reads_its_config_from
install_creates_then_leaves_alone_then_updates_and_a_dry_run_writes_nothing

cargo fmt --all --check, cargo clippy --workspace --all-targets -- -D warnings and cargo test --workspace pass (483 tests).

Not verified: a real keypress in the Rex app (the throwaway server had no app attached), real Claude/pi transcripts for annotate_last, and Windows (CI's check-windows).

Merge Danger

Door: two-way

Everything is under plannotator-tui rex … and the new [rex] config table. A revert removes it. People who installed the module keep a Lua file that calls flags which would then be gone.

Blast Radius: Rex

A Rex launch now asks for program_status before opening. If Rex can't answer, the process name decides, as before. The config file gains [rex]; an unknown value there is an error that names it, as in [herdr].

`rex open|last|terminal|find` always opened a split. `--placement popup`,
or `[rex] placement = "popup"` in the config file, opens a floating layer
over the agent's own window instead, so a launch from a block in a
background tab does not land over the active one. A split stays the
default because it keeps the agent in view. Rex has no overlay, so the
setting takes only split or popup.
A block running pi showed Copy instead of Send. pi runs under node, so
Rex reports its process as `node`, and `cli.js` when it is run as a
script; neither names an agent. The agent's program status does: Rex
1913 has `app: "pi"` on a record whose owner is the foreground pid. The
launcher now takes the agent from that record (`claude-code` is
Claude), then from the process name, then from the script Rex reports
an interpreter running. A record left by another process names nothing.
Rex has no plugin manifest, so getting a review on a key meant pasting
Lua into init.lua by hand, with the binary's full path, since Rex runs
actions with a bare PATH. `plannotator-tui rex install` writes Rex
Annotate to plannotator/annotate.lua beside Rex's init.lua (following
REX_CONFIG and XDG_CONFIG_HOME). The module is embedded in the binary
and names it by absolute path, so reinstalling after an upgrade keeps
the two in step.

The module defines six palette actions (annotate_last, annotate_newest,
annotate_open, annotate_gate, annotate_terminal, annotate_find), each
running `plannotator-tui rex …` on the focused block, and binds three
keys Rex for Mac leaves free: Shift+Cmd+O, Alt+Shift+Cmd+O, Ctrl+Cmd+O.
`setup{ placement, keys, bin }` changes them.

Install never edits init.lua: it prints the require line, and checks
the module with `rex config check` against a scratch copy, so the
person's own config is not read. --dry-run says what it would write;
--print writes the module to stdout.
"Inside Rex" becomes "Rex Annotate": install the binary, run
`plannotator-tui rex install`, add the require line, reload. A table
lists the keys and actions, then `setup{}` options, `[rex] placement`,
and the launchers. It also says how the agent is found, so pi under
node gets Send.
@backnotprop
backnotprop added this pull request to the merge queue Nov 10, 2026
Merged via the queue into main with commit a79e5c2 Nov 10, 2026
3 checks passed
@backnotprop
backnotprop deleted the feat/rex-annotate branch November 10, 2026 13:59
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