feat: add :objects browser for .GlobalEnv inspection#237
Draft
eitsupi wants to merge 6 commits into
Draft
Conversation
Add a TUI browser accessible via `:objects` (or `:objs`) that displays the current .GlobalEnv bindings as a flat list with name, class, type, and length columns. Key design decisions: - Active bindings detected via R_BindingIsActive *before* Rf_findVarInFrame to avoid forcing them (ordering prevents unintended evaluation) - PROMSXP bindings labelled "(promise)" without forcing - Explicit class from Rf_getAttrib(R_ClassSymbol); implicit class derived from typeof for objects without an explicit class attribute - Filtering with / using the existing fuzzy_match infrastructure - Refresh with r re-calls workspace_snapshot() without leaving the browser New C API symbols added to arf-libr: Rf_findVarInFrame, R_existsVarInFrame, R_BindingIsActive, R_lsInternal3, Rf_getAttrib, R_ClassSymbol, Rf_isS4 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Register :objects and :objs in MetaCommandCompleter so they appear in tab-completion - Change workspace_snapshot() to take an all_names parameter; default to false (matching R's ls() default) so dot-prefixed names including arf's own .arf_error_state/.arf_prev_error_handler are hidden - Add 'a' key toggle in the browser to show/hide dot-prefixed names; header shows "[all]" indicator when enabled Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
These two internal bindings were stored in .GlobalEnv, causing them to appear in the user's workspace (e.g. :objects browser, ls()). Move them to baseenv() instead, which is the correct location for arf's runtime infrastructure. Dot-prefixed names in baseenv are not visible to ls()/objects() by default, so the user workspace stays clean. Also switch the Rust-side lookups from rf_findvar (which follows the enclosure chain) to rf_findvarinframe (which looks only in the exact frame), since we now know the exact environment to query. Addresses the root cause flagged during :objects browser review; the lq45 task (R_withCallingErrorHandler migration) remains open as the proper long-term fix. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
baseenv() does not allow adding new bindings in R. Store .arf_error_state and .arf_prev_error_handler back in globalenv with dot prefix — these are hidden from the objects browser (all_names=FALSE default) and from ls() by default. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Fix fuzzy_match argument order (pattern, target) — filtering was effectively broken - Fix FIXED_COLS to account for 3-char " │ " separators; rows no longer exceed terminal width - Clamp scroll_offset in update_filter so the visible window stays anchored to the cursor after filter/reload - Truncate footer to terminal width before padding to prevent wrapping at narrow terminals - Guard STRING_ELT(class_sexp, 0) with a length check to avoid indexing an empty class vector across the FFI boundary Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Raise MIN_SIZE.cols from 60 to 66 (= FIXED_COLS + NAME_MIN) so the browser rejects terminals that would cause row wrapping - Use display_width-aware padding for the footer so wide Unicode characters in feedback messages do not overflow the terminal Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
:objects browser for .GlobalEnv inspection
eitsupi
commented
Jun 30, 2026
|
|
||
| // Workspace snapshot functions | ||
| // Rf_findVarInFrame(rho, sym) — look up sym in env rho only (no parent search) | ||
| pub rf_findvarinframe: unsafe extern "C" fn(SEXP, SEXP) -> SEXP, |
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.
Summary
:objects/:objsmeta-command that opens a TUI browser showing.GlobalEnvbindings (Phase 1 of the objects browser epic)R_lsInternal3,R_BindingIsActive,Rf_findVarInFrame, etc.) — no external R packages requiredls()default); toggle withaChanges
crates/arf-librRf_findVarInFrame,R_existsVarInFrame,R_BindingIsActive,R_lsInternal3,Rf_getAttrib,R_ClassSymbol,Rf_isS4r_unbound_value(),r_class_symbol()crates/arf-harpworkspacemodule:EnvEntrystruct +workspace_snapshot(all_names: bool)crates/arf-consolepager/objects_browser.rs: crossterm-based TUI with columns Name │ Class │ Type │ Lengthj/knavigate,/filter (fuzzy),atoggle hidden,rrefresh,q/Esc exit:objects/:objsto meta-command dispatch and tab-completionTest plan
:objectsopens the browser and lists.GlobalEnvbindingsakey shows them/filter matches by name and class (fuzzy)rrefresh picks up newly assigned variables(active binding)without being forcedq/ Esc returns to the REPL prompt cleanly:objsuggests:objectsand:objs🤖 Generated with Claude Code