Skip to content

fix(ui): persist 7d/30d window toggle in URL on /status and /endpoints#4956

Closed
joaovictor91123 wants to merge 1 commit into
JSONbored:mainfrom
joaovictor91123:fix/window-toggle-url-state-3976
Closed

fix(ui): persist 7d/30d window toggle in URL on /status and /endpoints#4956
joaovictor91123 wants to merge 1 commit into
JSONbored:mainfrom
joaovictor91123:fix/window-toggle-url-state-3976

Conversation

@joaovictor91123

Copy link
Copy Markdown
Contributor

Summary

  • The 7d/30d window toggle in RecentIncidents (status.tsx) used plain useState — the selected window reset on every reload, couldn't be shared or bookmarked.
  • Same issue in ProxyUsagePanel (rpc-proxy.tsx) on /endpoints.
  • Fix: wire both to the same URL-backed pattern /explorer already uses (explorerSearchSchemaRoute.useSearch() + navigate).

Changes:

  • apps/ui/src/routes/status.tsx — add window to statusSearchSchema; RecentIncidents reads Route.useSearch().window and writes navigate({ search: (prev) => ({ ...prev, window: w }) })
  • apps/ui/src/routes/endpoints.tsx — add proxy_window to endpointsSearchSchema
  • apps/ui/src/components/metagraphed/rpc-proxy.tsx — replace useState with useSearch({ from: '/endpoints' }) + useNavigate, matching the pattern already used in status-diagnostics.tsx

Closes #3976

Gates

Check Result
typecheck
unit tests ✓ (670 passing)
prettier
build

Screenshots

The key behavioral difference is the URL: before, toggling to 30d left the URL unchanged (/status); after, it updates to /status?window=30d so the window survives reload and sharing.

/status — RecentIncidents panel

Viewport Before (7d, no URL param) After (30d, URL: ?window=30d)
Mobile · Light
Mobile · Dark
Tablet · Light
Tablet · Dark
Desktop · Light
Desktop · Dark

/endpoints — ProxyUsagePanel

Viewport Before (7d, no URL param) After (30d, URL: ?proxy_window=30d)
Mobile · Light
Mobile · Dark
Tablet · Light
Tablet · Dark
Desktop · Light
Desktop · Dark

The RecentIncidents panel on /status and ProxyUsagePanel on /endpoints
each held their 7d/30d selection in local useState, resetting to 7d on
every reload and making the selected window invisible to back/forward
navigation or link-sharing. /explorer already does this correctly via
explorerSearchSchema.

- status.tsx: add `window` to statusSearchSchema; replace useState with
  Route.useSearch() + useNavigate matching the explorer pattern
- endpoints.tsx: add `proxy_window` to endpointsSearchSchema
- rpc-proxy.tsx: replace useState with useSearch({ from: '/endpoints' })
  + useNavigate so ProxyUsagePanel reads and writes the URL param

Closes JSONbored#3976
@superagent-security

Copy link
Copy Markdown

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jul 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.94%. Comparing base (259928a) to head (43aa08a).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4956   +/-   ##
=======================================
  Coverage   97.94%   97.94%           
=======================================
  Files         163      163           
  Lines       19418    19418           
  Branches     7376     7376           
=======================================
  Hits        19018    19018           
  Misses         53       53           
  Partials      347      347           
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@gittensory-orb gittensory-orb Bot added the gittensor:bug Gittensor-scored bug fix or unsolicited PR — scores a 0.05x multiplier. label Jul 12, 2026
@gittensory-orb

gittensory-orb Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Warning

🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-07-13 00:44:06 UTC

3 files · 1 AI reviewer · no blockers · readiness 100/100 · CI green · clean

⏸️ Suggested Action - Manual Review

  • Touches a guarded path — held for manual review: This PR changes guardrail-protected path(s): apps/ui/src/components/metagraphed/rpc-proxy.tsx (matched apps/ui/**), apps/ui/src/routes/endpoints.tsx (matched apps/ui/**), apps/ui/src/routes/status.tsx (matched apps/ui/**).

Review summary
This PR extracts the same URL-backed search-param pattern already used by /explorer to fix two other pages (`/status` RecentIncidents and `/endpoints` ProxyUsagePanel) whose 7d/30d toggle was previously plain `useState`, losing state on reload/share as issue #3976 describes. Both migrations are mechanically correct: `window`/`proxy_window` are added to their respective search schemas with matching enum + fallback + default, `Route.useSearch()`/`useSearch({from})` replace the state read, and the toggle buttons now call `navigate({ search: (prev) => ({...prev, ...}) })` preserving other search params. The visible diff is self-consistent (e.g. `rpc-proxy.tsx` still correctly threads the destructured `window` into `rpcUsageQuery`, the hint text, and the active-tab comparison) and no visual output changes, so no blockers.

Nits — 7 non-blocking
  • The param name is inconsistent between the two surfaces (`window` on /status vs `proxy_window` on /endpoints) — worth a one-line rationale in the PR description or a shared naming convention going forward.
  • No test-path changes accompany either URL-state migration (apps/ui/src/routes/status.tsx, endpoints.tsx, rpc-proxy.tsx); a small test asserting the search param round-trips through navigate would harden this against regression.
  • Consider extracting the repeated `navigate({ search: (prev) => ({ ...prev, X: w }) })` toggle-button pattern (now duplicated across explorer/status/rpc-proxy) into a shared hook if a fourth surface needs the same treatment.
  • Add a lightweight unit/integration test verifying that clicking the 30d toggle updates the URL search param and that reading the route with `?window=30d` pre-selects the 30d tab.
  • Document the URL-search-param naming convention (window vs proxy_window vs any future *_window) in a shared constants file to avoid drift as more panels adopt this pattern.
  • Code changes lack test evidence — Add focused regression tests or explain why existing coverage is sufficient.
  • Touches a guarded path — held for manual review — A maintainer must review and merge this change.
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ✅ Linked #3976
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 132 registered-repo PR(s), 76 merged, 12 issue(s).
Contributor context ✅ Confirmed Gittensor contributor joaovictor91123; Gittensor profile; 132 PR(s), 12 issue(s).
Gate result ⚠️ Not blocking Advisory; not blocking this PR.
Review context
  • Author: joaovictor91123
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: not available
  • Official Gittensor activity: 132 PR(s), 12 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Keep the PR focused and include validation evidence before maintainer review.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
[BETA] Chat with Gittensory

Ask Gittensory a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @gittensory ask <question> answers contribution-quality Q&A with source citations and freshness.
  • @gittensory chat <question> answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @gittensory mention with a real question is routed to the closest matching read-only command automatically -- no exact syntax required.

Full command reference: https://gittensory.aethereal.dev/docs/gittensory-commands

Visual preview
Route Viewport Before (production) After (this PR's preview) Diff
/endpoints desktop before /endpoints after /endpoints
/endpoints mobile before /endpoints (mobile) after /endpoints (mobile)
/status desktop before /status after /status
/status mobile before /status (mobile) after /status (mobile)

Click any thumbnail to open the full-size screenshot. Before = production · After = this PR's preview deploy.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.

  • Re-run Gittensory review

@gittensory-orb gittensory-orb Bot added the manual-review Gittensor contributor context label Jul 12, 2026

@JSONbored JSONbored left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshots are not correctly submitted/different sizes in before + after. Please fix + resubmit, using the AI skill found in the repo (contains all instructions your AI harness needs to correctly submit visual evidence in the exact sizes/formats required).

@JSONbored JSONbored closed this Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix or unsolicited PR — scores a 0.05x multiplier. manual-review Gittensor contributor context

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The same 7d/30d time-window toggle is URL-backed on /explorer but plain local state (reset on every reload) on two other pages

2 participants