Skip to content

RI-8294 Add nearby-elements context band to the array Search tab#6119

Open
VaskoAtanasovRedis wants to merge 5 commits into
mainfrom
fe/RI-8294/search-context-band
Open

RI-8294 Add nearby-elements context band to the array Search tab#6119
VaskoAtanasovRedis wants to merge 5 commits into
mainfrom
fe/RI-8294/search-context-band

Conversation

@VaskoAtanasovRedis

@VaskoAtanasovRedis VaskoAtanasovRedis commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

What

Adds the Context option to the array Search tab (Slice 4 of the ARGREP search vertical, parent RI-8221). It's opt-in via a toggle in the Search Options section (off by default): once enabled, expanding a result row shows ±N neighbouring elements around the match, with the matched row highlighted and the count adjustable.

  • Neighbours are fetched via the existing ARGETRANGE endpoint into local component state — the View tab's array slice is left untouched.
  • The ±N index window is computed in BigInt, clamped at 0 and capped at ARRAY_INDEX_MAX, so no negative or out-of-range index is ever requested (u64-as-string contract).
  • ArrayDetailsTable gains optional row-expansion passthrough; the View / Aggregate tabs are unchanged (no expansion props → no expand affordance).
  • Options panel reorganized: Range + Context on one row, a divider, then NOCASE / WITHVALUES / LIMIT — each with its own (i) hint.

Testing

  • yarn test — 200 array-details / slice / util tests pass, including: clamp-at-0, BigInt-exact-past-2^53, thunk writes nothing to the slice, off-by-default ⇒ no expand and no fetch, and refetch-on-count-change.
  • yarn lint clean; yarn type-check adds zero new errors.
  • Manual: open an array key (behind dev-array) → Search → run a query → expand Options, tick Context → expand a match to see the ±N band (matched row highlighted); toggle Context off → rows are no longer expandable.
Light Dark
image image
image image
image image

Closes #RI-8294


Note

Medium Risk
Adds on-demand ARGETRANGE fetches and row expansion only on Search; neighbour loads are isolated from the View slice with abort/clamp safeguards, but wrong range math could still stress large windows (capped at ±50).

Overview
Adds an opt-in Context control to the array Search tab so users can expand a match row and see ±N neighbouring elements (matched row highlighted), without changing ARGREP itself.

Search form & state: New Context toggle and count (capped at 50) live in Options, separate from search options so they never appear in the command preview. The options panel is reorganized (Range + Context on one row, divider, then NOCASE / WITHVALUES / LIMIT) with per-control InfoHint tooltips. SearchTab owns context state (off by default), resets it on form reset and key switch, and only enables row expansion when Context is on.

Table & neighbour fetch: ArrayDetailsTable optionally forwards row-expansion props to the shared Table; View/Aggregate tabs omit them. Expanding a row renders NeighbourBand, which calls a new fetchArrayNeighbours thunk (ARGETRANGE) into local state only (View-tab data.elements untouched), with abort + stale-response guards. Index windows use new getNeighbourRange (BigInt, clamped at 0 and max u64).

Reviewed by Cursor Bugbot for commit cddfbfc. Bugbot is set up for automated code reviews on this repo. Configure here.

@jit-ci

jit-ci Bot commented Jun 26, 2026

Copy link
Copy Markdown

🛡️ Jit Security Scan Results

CRITICAL HIGH MEDIUM

✅ No security findings were detected in this PR


Security scan by Jit

@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: f6f9010597

ℹ️ 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".

…I-8294]

Adds an opt-in "Context" option in the Search Options section (off by
default): expanding a match shows ±N neighbouring elements, fetched via the
existing ARGETRANGE endpoint into local component state so the View tab's
slice is left untouched. The matched row is highlighted and the count is
adjustable. Neighbour index math uses BigInt, clamped at 0 and capped at
ARRAY_INDEX_MAX, so no negative or out-of-range index is ever requested.

References: #RI-8294
@VaskoAtanasovRedis VaskoAtanasovRedis force-pushed the fe/RI-8294/search-context-band branch from f6f9010 to f87e54e Compare June 26, 2026 12:04
The "Reset to defaults" button only reset the query hook's state; the
SearchTab-owned Context toggle/count were left untouched, so a reset could
leave rows expandable at the previous count. Restore them to their defaults
on reset too. Addresses Codex review (P2) on PR #6119.

References: #RI-8294

@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: 123f1adc13

ℹ️ 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".

Two review findings on PR #6119:
- Cursor: toggling Context off left an already-expanded match still rendering
  the neighbour band (and firing its fetch). Gate renderExpandedRow on
  context.enabled so the band unmounts when Context is disabled.
- Codex: the SearchTab-owned context state was not reset on a key switch (the
  tab stays mounted across keys), so a new key inherited the previous key's
  toggle/count. Reset it on a real key change, mirroring useArraySearchQuery.

References: #RI-8294

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c88af84. Configure here.

@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: c88af84b2d

ℹ️ 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".

…[RI-8294]

A neighbour ARGETRANGE fetch for a previous ±N count could settle before the
effect's deferred abort cleanup runs and overwrite the band with the wrong
window. Track the latest requested window and ignore any response that no
longer matches it. Addresses Cursor review (Medium) on PR #6119.

References: #RI-8294
A fractional context count (e.g. 1.5) reached getNeighbourRange, where
BigInt() throws on non-integers and broke the Search tab on expand. Round the
count at the input, and defensively coerce it to a non-negative integer in
getNeighbourRange so no bad value can throw. Addresses Codex review (P2) on
PR #6119.

References: #RI-8294
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