Skip to content

fix: preserve embed params on back-to-search navigation and consolida…#3782

Open
aditya86-id wants to merge 1 commit intojaegertracing:mainfrom
aditya86-id:fix/embedded-params-navigation
Open

fix: preserve embed params on back-to-search navigation and consolida…#3782
aditya86-id wants to merge 1 commit intojaegertracing:mainfrom
aditya86-id:fix/embedded-params-navigation

Conversation

@aditya86-id
Copy link
Copy Markdown

@aditya86-id aditya86-id commented Apr 28, 2026

Which problem is this PR solving?

Resolves #3780

Description

While tracing the embedded mode flow, I noticed that navigating
Search → Trace → Back to Search silently drops uiEmbed=v0 and related
params from the return URL.

The root cause: SearchResults/index.tsx computed a single searchUrl via
stripEmbeddedState() and reused it for both fromSearch back-navigation
and the standalone new-tab link — even though only the latter should
have embed params stripped.

Fix: split into two explicit URLs:

Also hid the standalone link when forbidNewPage=true. Its only purpose
is opening search in a new tab outside the embed context — forcing
same-frame navigation to a stripped URL actively breaks the config.

On the refactor side, getEmbeddedState() and stripEmbeddedState() each
had exactly one caller, both embed-related. Moved both into
stores/embedded-store.ts, deleted utils/embedded-url.ts, and moved the
tests with them. The vi.mock of embedded-url in embedded-store.test.ts
is replaced with tests against the real implementations.

Checklist

  • I have read CONTRIBUTING_GUIDELINES.md
  • I have signed all commits
  • I have added unit tests for the new functionality
  • I have run lint and test steps successfully

AI Usage

  • Light: AI provided minor assistance (formatting, simple suggestions)

Copilot AI review requested due to automatic review settings April 28, 2026 19:33
@aditya86-id aditya86-id requested a review from a team as a code owner April 28, 2026 19:33
…te embedded state functions

Problem: Embed params (uiEmbed=v0, uiSearchHideGraph=1, etc.) were silently dropped when navigating Search → Trace → Back to Search, breaking embedded UI context.

Solution:
1. Split single computed URL into two separate URLs in SearchResults:
   - backNavUrl: preserves embed params for 'Back to Search' navigation
   - standaloneUrl: strips embed params for standalone new-tab link
2. Moved getEmbeddedState() and stripEmbeddedState() from utils/embedded-url.ts to stores/embedded-store.ts (eliminating unnecessary indirection)
3. Added forbidNewPage guard to prevent rendering standalone link when forbidNewPage config is true
4. Updated tests to reflect new behavior and consolidate test coverage

This ensures users maintain embedded context when clicking 'Back to Search' while intentionally stripping embed context for standalone links.

Signed-off-by: adityakumartiwary <adityatiwary888@gmail.com>
@aditya86-id aditya86-id force-pushed the fix/embedded-params-navigation branch from d734fd6 to de19a26 Compare April 28, 2026 19:42
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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.

[refactor]: Consolidate embedded-url utils into embedded-store and fix lost embed params in search URL

2 participants