Skip to content

fix(rex): find the session from REX_BLOCK when REX_SESSION is unset - #39

Merged
rednafi merged 1 commit into
rednafi:masterfrom
jordanbyron:fix/rex-block-session
Dec 2, 2026
Merged

rednafi merged 1 commit into
rednafi:masterfrom
jordanbyron:fix/rex-block-session

Conversation

@jordanbyron

@jordanbyron jordanbyron commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Since Rex 0.1.0-preview.23, a pane gets REX_BLOCK and REX_SERVER but no REX_SESSION. rex.New reads a missing REX_SESSION as "outside Rex", so rexdiff running inside Rex shows "not in Rex". s can't send, the agent label is missing, and the last-turn scope never starts.

Fix

When REX_SESSION is unset, rex.New uses REX_BLOCK as the session. Rex accepts a block ID for -s and uses the session that holds the block. I ran api call, session inspect and events with a block ID by hand against 0.1.0-preview.25, and the e2e run below covers the rest. Nothing changes when REX_SESSION is set.

TestNewWithoutSession covers a pane that has only REX_BLOCK.

Testing

  • go vet, go test -race -count=1, golangci-lint v2.15.0, go fix -diff, go mod tidy -diff and govulncheck are clean.
  • REXDIFF_REX=$(which rex) go test ./test/ passes.
  • test/e2e.sh against Rex 0.1.0-preview.25: all 51 steps pass on this branch. master fails at step 6, "rexdiff opens with the changes and finds the agent".

A separate e2e failure

test/e2e.sh stops at step 5 on master and on this branch. In a session with no client attached, which is how the script makes its session, preview.25 leaves owner out of session.list_blocks and block inspect. rexdiff doesn't read owner. For the runs above I removed owner from the fixtures locally; that change isn't in this PR. I can send it on its own if you want it.

Closes #41

🤖 Generated with Claude Code

Since Rex 0.1.0-preview.23 a pane gets REX_BLOCK but no REX_SESSION, so
rex.New reported "not in Rex" inside Rex and turned off sending, agent
labels and the last-turn scope. Every rex command rexdiff runs accepts a
block ID for -s and uses the session that holds it, so fall back to it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rednafi

rednafi commented Dec 2, 2026

Copy link
Copy Markdown
Owner

Thanks, merging.

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.

"not in Rex" on recent Rex builds: REX_SESSION is no longer set in terminals

2 participants