Skip to content

fix: preserve active time period when applying dimension filters - #5030

Merged
Pratham-Mishra04 merged 1 commit into
devfrom
07-08-fix_unwated_filters_resets_on_dashboard_and_logs_pages
Jul 9, 2026
Merged

fix: preserve active time period when applying dimension filters#5030
Pratham-Mishra04 merged 1 commit into
devfrom
07-08-fix_unwated_filters_resets_on_dashboard_and_logs_pages

Conversation

@impoiler

@impoiler impoiler commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes a bug where applying dimension filters (providers, models, keys, etc.) from the sidebar or header would inadvertently clear the active time period. In period mode, newFilters carries no start_time/end_time, so the previous logic was unconditionally writing undefined for those values and wiping the selected period. Time state is now only updated when an explicit start and end time are both present.

Also fixes navigation links in the log detail view that were replacing the entire search state instead of merging into it, which caused the active time range and other filters to be lost when clicking through to filtered log views.

Changes

  • setFilters on both the dashboard and logs pages now checks for hasExplicitTime before touching time-related URL state. If no explicit range is provided, the existing period, start_time, and end_time values are left untouched.
  • start_time/end_time are now written inside the conditional timeChanged block rather than unconditionally, removing the path that could set them to undefined.
  • All search={{ ... }} props on filter links in logDetailView.tsx have been changed to search={(prev) => ({ ...prev, ... })} so that existing URL state (including the active time range) is preserved when navigating.

Type of change

  • Bug fix
  • Feature
  • Refactor
  • Documentation
  • Chore/CI

Affected areas

  • Core (Go)
  • Transports (HTTP)
  • Providers/Integrations
  • Plugins
  • UI (React)
  • Docs

How to test

  1. Set a relative time period (e.g. "Last 24 hours") on the Logs or Dashboard page.
  2. Apply a dimension filter (e.g. select a provider or model) from the sidebar or header.
  3. Verify the active time period is still selected and the data is filtered correctly — it should not revert to an empty/default time range.
  4. Open a log detail view, click a filter link (e.g. a routing rule, key, team, or customer).
  5. Verify the logs page opens with both the clicked filter and the previously active time range applied.
cd ui
pnpm i || npm i
pnpm build || npm run build

Breaking changes

  • Yes
  • No

Related issues

Security considerations

None.

Checklist

  • I read docs/contributing/README.md and followed the guidelines
  • I added/updated tests where appropriate
  • I updated documentation where needed
  • I verified builds succeed (Go and UI)
  • I verified the CI pipeline passes locally if applicable

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 40 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 83bfa0f8-b85a-470c-8a5f-ce0dc0e85887

📥 Commits

Reviewing files that changed from the base of the PR and between 4e48235 and 9dd49c4.

📒 Files selected for processing (3)
  • ui/app/workspace/dashboard/page.tsx
  • ui/app/workspace/logs/page.tsx
  • ui/app/workspace/logs/sheets/logDetailView.tsx
📝 Walkthrough

Walkthrough

This PR changes dashboard and logs filter handling so absolute time fields are only written when both start_time and end_time are present. It also updates log detail navigation links to merge new filter params with existing query state.

Changes

Filter and query param preservation

Layer / File(s) Summary
Dashboard setFilters explicit time-range handling
ui/app/workspace/dashboard/page.tsx
setFilters checks for both start_time and end_time before converting to unix timestamps and updating time-related URL state.
Logs setFilters explicit time-range handling
ui/app/workspace/logs/page.tsx
setFilters uses an explicit start/end check for userModifiedTimeRange and period clearing, and removes conditional population of start_time/end_time from the shared URL update path.
LogDetailView links use functional search updaters
ui/app/workspace/logs/sheets/logDetailView.tsx
Links for routing rules, keys, teams, customers, business units, and users now merge with existing query params instead of replacing them.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • maximhq/bifrost#4801: Both PRs modify ui/app/workspace/dashboard/page.tsx’s setFilters URL-state adapter around period/start_time/end_time handling.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main bug fix of preserving the active time period when applying dimension filters.
Description check ✅ Passed The description is largely complete and matches the template, including summary, changes, testing, and impact sections.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 07-08-fix_unwated_filters_resets_on_dashboard_and_logs_pages

Comment @coderabbitai help to get the list of available commands.

@impoiler
impoiler marked this pull request as ready for review July 8, 2026 14:10
@coderabbitai
coderabbitai Bot requested a review from akshaydeo July 8, 2026 14:11
@greptile-apps

greptile-apps Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

Safe to merge — all three files make narrowly scoped, correct changes to URL state management with no regressions to existing functionality.

The time-guard logic is sound: both hasExplicitTime checks correctly require both timestamps to be present before touching time-related URL state. The timeChanged comparisons are type-compatible with the existing URL state representations. The functional search merge in logDetailView.tsx is the standard TanStack Router pattern for partial state updates, and adding offset: 0 and selected_log addresses the two edge cases flagged in prior review threads. No data-testid attributes are removed and no browser crypto APIs are introduced.

No files require special attention.

Important Files Changed

Filename Overview
ui/app/workspace/dashboard/page.tsx setFilters now guards time-range writes behind hasExplicitTime, preventing dimension-filter actions from clearing the active period or absolute range
ui/app/workspace/logs/page.tsx Same hasExplicitTime guard applied; start_time/end_time writes moved inside the conditional timeChanged block, removing the path that set them to undefined on dimension-filter changes
ui/app/workspace/logs/sheets/logDetailView.tsx All filter-navigation links converted from static search objects to functional merges (prev => {...prev, offset:0, selected_log:'', ...filter}), preserving time range and resetting offset/sheet state on navigation

Reviews (16): Last reviewed commit: "fix: unwated filters resets on dashboard..." | Re-trigger Greptile

Comment thread ui/app/workspace/logs/sheets/logDetailView.tsx

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@ui/app/workspace/logs/sheets/logDetailView.tsx`:
- Around line 743-749: The detail-sheet filter links are preserving the current
pagination state because the Link search updater spreads prev without resetting
offset. Update each search callback in logDetailView.tsx (the badge/link
handlers such as the routing_rule link) to explicitly set offset to 0 alongside
the new filter ids so navigation always lands on the first page of the filtered
results.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 84019987-d78e-4e5b-b784-00173895bed7

📥 Commits

Reviewing files that changed from the base of the PR and between a2be949 and efee0f3.

📒 Files selected for processing (3)
  • ui/app/workspace/dashboard/page.tsx
  • ui/app/workspace/logs/page.tsx
  • ui/app/workspace/logs/sheets/logDetailView.tsx

Comment thread ui/app/workspace/logs/sheets/logDetailView.tsx
@impoiler
impoiler force-pushed the 07-08-fix_unwated_filters_resets_on_dashboard_and_logs_pages branch from efee0f3 to 73efcd9 Compare July 9, 2026 01:38
@impoiler
impoiler force-pushed the 07-08-feat_consider_canonical_model_name_as_fallback_into_filters_and_recalculation branch from a2be949 to d19f0cc Compare July 9, 2026 01:38
@impoiler
impoiler force-pushed the 07-08-fix_unwated_filters_resets_on_dashboard_and_logs_pages branch from 73efcd9 to e121cb6 Compare July 9, 2026 03:03
@impoiler
impoiler force-pushed the 07-08-feat_consider_canonical_model_name_as_fallback_into_filters_and_recalculation branch from d19f0cc to d8627f7 Compare July 9, 2026 03:03
@impoiler
impoiler force-pushed the 07-08-fix_unwated_filters_resets_on_dashboard_and_logs_pages branch from e121cb6 to b9db7f9 Compare July 9, 2026 03:06
@impoiler
impoiler force-pushed the 07-08-feat_consider_canonical_model_name_as_fallback_into_filters_and_recalculation branch from d8627f7 to 964cf81 Compare July 9, 2026 03:06
@impoiler
impoiler force-pushed the 07-08-fix_unwated_filters_resets_on_dashboard_and_logs_pages branch from b9db7f9 to 47c47cc Compare July 9, 2026 03:14
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 9, 2026
@impoiler
impoiler force-pushed the 07-08-feat_consider_canonical_model_name_as_fallback_into_filters_and_recalculation branch from 964cf81 to becea36 Compare July 9, 2026 03:58
@impoiler
impoiler force-pushed the 07-08-fix_unwated_filters_resets_on_dashboard_and_logs_pages branch from 47c47cc to 3367726 Compare July 9, 2026 03:58
Comment thread ui/app/workspace/logs/sheets/logDetailView.tsx
@impoiler
impoiler force-pushed the 07-08-feat_consider_canonical_model_name_as_fallback_into_filters_and_recalculation branch from becea36 to 0475258 Compare July 9, 2026 04:07
@impoiler
impoiler force-pushed the 07-08-fix_unwated_filters_resets_on_dashboard_and_logs_pages branch from 3367726 to 7c2fe3c Compare July 9, 2026 04:07
@impoiler
impoiler force-pushed the 07-08-feat_consider_canonical_model_name_as_fallback_into_filters_and_recalculation branch from 0475258 to fab2b0f Compare July 9, 2026 04:23
@impoiler
impoiler force-pushed the 07-08-fix_unwated_filters_resets_on_dashboard_and_logs_pages branch from 7c2fe3c to fdc4799 Compare July 9, 2026 04:23
@impoiler
impoiler force-pushed the 07-08-feat_consider_canonical_model_name_as_fallback_into_filters_and_recalculation branch from fab2b0f to a09364b Compare July 9, 2026 04:50
@impoiler
impoiler force-pushed the 07-08-fix_unwated_filters_resets_on_dashboard_and_logs_pages branch 2 times, most recently from 37721c8 to f823121 Compare July 9, 2026 04:54
@impoiler
impoiler force-pushed the 07-08-fix_unwated_filters_resets_on_dashboard_and_logs_pages branch from f823121 to 4e48235 Compare July 9, 2026 10:58
@impoiler
impoiler force-pushed the 07-08-feat_consider_canonical_model_name_as_fallback_into_filters_and_recalculation branch from a09364b to 62560d6 Compare July 9, 2026 10:58
@impoiler
impoiler force-pushed the 07-08-fix_unwated_filters_resets_on_dashboard_and_logs_pages branch from 4e48235 to eab1035 Compare July 9, 2026 11:36
@impoiler
impoiler force-pushed the 07-08-feat_consider_canonical_model_name_as_fallback_into_filters_and_recalculation branch 2 times, most recently from 9491a4b to ca6e660 Compare July 9, 2026 12:09
@impoiler
impoiler force-pushed the 07-08-fix_unwated_filters_resets_on_dashboard_and_logs_pages branch from eab1035 to 6ae1cc0 Compare July 9, 2026 12:09

Pratham-Mishra04 commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Merge activity

  • Jul 9, 12:16 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jul 9, 12:34 PM UTC: Graphite rebased this pull request as part of a merge.
  • Jul 9, 12:35 PM UTC: @Pratham-Mishra04 merged this pull request with Graphite.

@Pratham-Mishra04
Pratham-Mishra04 changed the base branch from 07-08-feat_consider_canonical_model_name_as_fallback_into_filters_and_recalculation to graphite-base/5030 July 9, 2026 12:30
@Pratham-Mishra04
Pratham-Mishra04 changed the base branch from graphite-base/5030 to dev July 9, 2026 12:33
@Pratham-Mishra04
Pratham-Mishra04 dismissed coderabbitai[bot]’s stale review July 9, 2026 12:33

The base branch was changed.

@Pratham-Mishra04
Pratham-Mishra04 force-pushed the 07-08-fix_unwated_filters_resets_on_dashboard_and_logs_pages branch from 6ae1cc0 to 9dd49c4 Compare July 9, 2026 12:33
@Pratham-Mishra04
Pratham-Mishra04 merged commit b3853f1 into dev Jul 9, 2026
12 of 13 checks passed
@Pratham-Mishra04
Pratham-Mishra04 deleted the 07-08-fix_unwated_filters_resets_on_dashboard_and_logs_pages branch July 9, 2026 12:35
akshaydeo pushed a commit that referenced this pull request Jul 14, 2026
## Summary

Fixes a bug where applying dimension filters (providers, models, keys, etc.) from the sidebar or header would inadvertently clear the active time period. In period mode, `newFilters` carries no `start_time`/`end_time`, so the previous logic was unconditionally writing `undefined` for those values and wiping the selected period. Time state is now only updated when an explicit start and end time are both present.

Also fixes navigation links in the log detail view that were replacing the entire search state instead of merging into it, which caused the active time range and other filters to be lost when clicking through to filtered log views.

## Changes

- `setFilters` on both the dashboard and logs pages now checks for `hasExplicitTime` before touching time-related URL state. If no explicit range is provided, the existing `period`, `start_time`, and `end_time` values are left untouched.
- `start_time`/`end_time` are now written inside the conditional `timeChanged` block rather than unconditionally, removing the path that could set them to `undefined`.
- All `search={{ ... }}` props on filter links in `logDetailView.tsx` have been changed to `search={(prev) => ({ ...prev, ... })}` so that existing URL state (including the active time range) is preserved when navigating.

## Type of change

- [x] Bug fix
- [ ] Feature
- [ ] Refactor
- [ ] Documentation
- [ ] Chore/CI

## Affected areas

- [ ] Core (Go)
- [ ] Transports (HTTP)
- [ ] Providers/Integrations
- [ ] Plugins
- [x] UI (React)
- [ ] Docs

## How to test

1. Set a relative time period (e.g. "Last 24 hours") on the Logs or Dashboard page.
2. Apply a dimension filter (e.g. select a provider or model) from the sidebar or header.
3. Verify the active time period is still selected and the data is filtered correctly — it should not revert to an empty/default time range.
4. Open a log detail view, click a filter link (e.g. a routing rule, key, team, or customer).
5. Verify the logs page opens with both the clicked filter and the previously active time range applied.

```sh
cd ui
pnpm i || npm i
pnpm build || npm run build
```

## Breaking changes

- [ ] Yes
- [x] No

## Related issues

## Security considerations

None.

## Checklist

- [ ] I read `docs/contributing/README.md` and followed the guidelines
- [ ] I added/updated tests where appropriate
- [ ] I updated documentation where needed
- [ ] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable
akhsaul pushed a commit to akhsaul/bifrost that referenced this pull request Aug 27, 2026
…imhq#5030)

## Summary

Fixes a bug where applying dimension filters (providers, models, keys, etc.) from the sidebar or header would inadvertently clear the active time period. In period mode, `newFilters` carries no `start_time`/`end_time`, so the previous logic was unconditionally writing `undefined` for those values and wiping the selected period. Time state is now only updated when an explicit start and end time are both present.

Also fixes navigation links in the log detail view that were replacing the entire search state instead of merging into it, which caused the active time range and other filters to be lost when clicking through to filtered log views.

## Changes

- `setFilters` on both the dashboard and logs pages now checks for `hasExplicitTime` before touching time-related URL state. If no explicit range is provided, the existing `period`, `start_time`, and `end_time` values are left untouched.
- `start_time`/`end_time` are now written inside the conditional `timeChanged` block rather than unconditionally, removing the path that could set them to `undefined`.
- All `search={{ ... }}` props on filter links in `logDetailView.tsx` have been changed to `search={(prev) => ({ ...prev, ... })}` so that existing URL state (including the active time range) is preserved when navigating.

## Type of change

- [x] Bug fix
- [ ] Feature
- [ ] Refactor
- [ ] Documentation
- [ ] Chore/CI

## Affected areas

- [ ] Core (Go)
- [ ] Transports (HTTP)
- [ ] Providers/Integrations
- [ ] Plugins
- [x] UI (React)
- [ ] Docs

## How to test

1. Set a relative time period (e.g. "Last 24 hours") on the Logs or Dashboard page.
2. Apply a dimension filter (e.g. select a provider or model) from the sidebar or header.
3. Verify the active time period is still selected and the data is filtered correctly — it should not revert to an empty/default time range.
4. Open a log detail view, click a filter link (e.g. a routing rule, key, team, or customer).
5. Verify the logs page opens with both the clicked filter and the previously active time range applied.

```sh
cd ui
pnpm i || npm i
pnpm build || npm run build
```

## Breaking changes

- [ ] Yes
- [x] No

## Related issues

## Security considerations

None.

## Checklist

- [ ] I read `docs/contributing/README.md` and followed the guidelines
- [ ] I added/updated tests where appropriate
- [ ] I updated documentation where needed
- [ ] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable
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.

2 participants