Repository navigation
fix(rex): find the session from REX_BLOCK - #43
Closed
jonleopard wants to merge 1 commit into
Closed
jonleopard wants to merge 1 commit into
jonleopard wants to merge 1 commit into
Conversation
Rex Server 0.1.0-preview.23 and later stopped exporting REX_SESSION in new terminals because tabs can move between sessions; terminals now export REX_SERVER, REX_BLOCK and REX_BIN_DIR. Treat REX_BLOCK as the inside-Rex signal and resolve the block's current session through `rex --autostart=false --timeout 2s whoami --json` behind `axel_rex::Runner`, bounded by a 2s child-process timeout and cached once per process. Pipe collection in `wait_or_stop` is also bounded after child exit (200 ms grace over channels) so a descendant holding stdout or stderr open cannot hang detection; for `Rex::ask`, normal exits are unchanged and an abnormal lingering-pipe exit now returns `Withdrawn` instead of hanging. When Rex answers, its session wins even if a stale REX_SESSION is present. For older Rex builds (or any case where Rex cannot answer, times out, or returns invalid/null JSON), fall back to REX_SESSION if set; without REX_BLOCK or a resolved session, return None. Prefer `$REX_BIN_DIR/rex` (when that file exists) after `$AXEL_REX_BIN` and before `PATH` and app install paths in `axel_rex::program()`. Inside a Rex terminal that sets `REX_BIN_DIR`, this changes every `rex` CLI call to run the binary matching the running server rather than an older `rex` on `PATH` or failing when `rex` is omitted from `PATH`. Update `axel-tui` stream tool links to use `axel_rex::detect()` instead of reading REX_SESSION directly, update `axel doctor` and its zh-Hans translation, and align docs/CONTRACTS.md, docs/DESIGN.md and docs/RESEARCH.md. Verified on Rex 0.1.0-preview.25 in isolated temp AXEL_HOME panes (AXEL_KEYSTORE=file) with REX_BLOCK set and REX_SESSION unset: `axel doctor` resolves the real session and block both with default PATH and with PATH reduced to `/usr/bin:/bin` (no `rex` on PATH, `REX_BIN_DIR` kept); `axel thread split` opens the thread/compose/tokens panes instead of running inline, the stream emits a valid `axel-links://tools?...` OSC 8 hyperlink, and a failing stub `rex` exercises the REX_SESSION fallback. Needs manual verification at the keyboard: interactive Tab switching across panes and clicking a tool link in Rex.app.
|
@jonleopard is attempting to deploy a commit to the ludo-galabru Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
Author
|
Superseded by 36668ee / v0.3.164. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #42
Summary
Rex Server 0.1.0-preview.23 and later stopped exporting
REX_SESSIONin new terminals because tabs can move between sessions; terminals now exportREX_SERVER,REX_BLOCK, andREX_BIN_DIR.axel_rex::detect()required bothREX_SESSIONandREX_BLOCK, so Axel treated fresh Rex panes as outside Rex.crates/rex/src/lib.rs:REX_BLOCKas the inside-Rex signal and resolve the realsession:<uuid>throughRunner(rex --autostart=false --timeout 2s whoami --json), cached once per process. When Rex answers, its session wins even over a staleREX_SESSION; older Rex builds (or any failure/timeout/invalid JSON) fall back toREX_SESSION.PIPE_DRAIN_GRACE, 200 ms over channels) inwait_or_stopso a descendant holding stdout/stderr open cannot hang detection.$REX_BIN_DIR/rex(when present) after$AXEL_REX_BINand beforePATHand app install paths so inside a Rex terminal Axel invokes the binary matching the running server.crates/tui/src/stream.rs: route stream tool links throughaxel_rex::detect()instead of readingREX_SESSIONdirectly.crates/axel/src/cmd/doctor.rs&crates/i18n/translations.yaml: update the "not detected" message (English andzh-Hans) to referenceREX_BLOCK/ unavailable session.docs/CONTRACTS.md,docs/DESIGN.md,docs/RESEARCH.md: align docs withREX_BLOCK-based detection and caching.Evidence
REX_BLOCKset andREX_SESSIONunset):axel doctorreportsrex: not detected (REX_SESSION unset); launcher runs inline;axelruns inline; tool links are absent.AXEL_HOME,REX_SESSIONunset):PATH:axel doctorresolvessession:<uuid>andblock:<uuid>.PATH=/usr/bin:/bin(rexabsent fromPATH,REX_BIN_DIRpreserved):axel doctorstill resolvessession:<uuid>andblock:<uuid>.axel thread splitopens the thread/compose/tokens panes instead of running inline; stream emits a validaxel-links://tools?...OSC 8 link; a failing stubrexfalls back toREX_SESSION.5839423:cargo clippy --workspace --all-targets --locked --offline -- -D warnings: pass (0 warnings).cargo test --workspace --locked --offline: 759 passed, 0 failed, 2 ignored.cargo test --locked --offline -p axel-rex: 51 passed, 0 failed (+ 1 doctest) identically across default env, allREX_*unset, and syntheticREX_BLOCKset (puredetect_with/Fakeunit tests +/bin/shtimeout/open-pipe process tests; no test spawnsrex).Merge Danger
Door: two-way
Blast Radius: rex-detection
detect()caches its result once per process, so a long-lived process retains its initial session after a tab moves between sessions and retains a failed detection after a transient error.rexexits with a descendant holding stdout/stderr open. ForRex::ask, normal exits and the 200 ms poll interval are unchanged; in that abnormal lingering-pipe case it now returnsWithdrawninstead of hanging.$REX_BIN_DIR/rexaffects everyrexCLI call inside Rex terminals that exportREX_BIN_DIR(overriding an olderrexearlier onPATHwhile keeping$AXEL_REX_BINhighest precedence).Ctx::open(): every interactiveaxelcommand run inside a Rex terminal now runsrex --autostart=false --timeout 2s whoami --jsononce (~30 ms) even when it doesn't touch Rex (agent children stripREX_*and skip it). KeptRexEnv/detect()unchanged to stay small and avoid reshapingCONTRACTS.md; if you'd rather makeCtx's Rex handle lazy or switchdetect()to block-only /rex.control.v1and resolve the session on demand, say the word.