Skip to content

fix(agentex-ui): include account_id in investigate traces link#310

Merged
cdvillegas merged 2 commits into
mainfrom
chris-villegas/fix-investigate-traces-account-id
Jun 16, 2026
Merged

fix(agentex-ui): include account_id in investigate traces link#310
cdvillegas merged 2 commits into
mainfrom
chris-villegas/fix-investigate-traces-account-id

Conversation

@cdvillegas

@cdvillegas cdvillegas commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Pull Request Summary

The AgentEx "Investigate traces" link opened SGP monitor with only trace ID query params. When a user had multiple tenants, SGP could load traces under the wrong active account. This change reads account_id from the current AgentEx URL and appends it to the monitor link so SGP switches to the correct tenant.

Test Plan

  • Verified the link builder adds account_id when the AgentEx page URL includes account_id.
  • Agentex UI lint passed via pre-commit on the changed file.

Linear Issue

No Linear ticket.

Made with Cursor

Greptile Summary

This PR fixes a multi-tenant issue in the "Investigate traces" button by reading account_id from the current AgentEx URL and appending it to the SGP monitor link, ensuring SGP loads the correct tenant context.

  • Introduces useSafeSearchParams to extract account_id from the current page's search params and conditionally appends it to the outbound SGP URL.
  • Refactors the URL construction to use URLSearchParams for cleaner parameter handling.
  • The diff also silently changes the SGP monitor path from /beta/monitor to /monitor; this is not mentioned in the PR description and warrants confirmation that SGP no longer requires the /beta/ prefix.

Confidence Score: 4/5

The account_id forwarding logic is correct and well-guarded, but the undocumented removal of the /beta/ path segment in the monitor URL could silently break the link for all users if SGP has not retired that route.

The path change from /beta/monitor to /monitor is unmentioned in the PR description and untested in the stated test plan — if SGP still routes the monitor behind /beta/, every "Investigate traces" click will land on the wrong or missing page.

agentex-ui/components/task-header/investigate-traces-button.tsx — confirm the /beta/monitor/monitor path change is intentional and that the new route is live in SGP.

Important Files Changed

Filename Overview
agentex-ui/components/task-header/investigate-traces-button.tsx Reads account_id from search params and appends it to the SGP monitor URL; also silently changes the monitor path from /beta/monitor to /monitor

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant User
    participant AgentEx UI
    participant useSafeSearchParams
    participant SGP Monitor

    User->>AgentEx UI: Visits page with ?account_id=XYZ&task_id=ABC
    AgentEx UI->>useSafeSearchParams: read search params
    useSafeSearchParams-->>AgentEx UI: sgpAccountID = "XYZ"
    AgentEx UI->>AgentEx UI: Build URL: /monitor?trace_id=...&tt-trace-id=...&account_id=XYZ
    User->>SGP Monitor: Clicks "Investigate traces" link
    SGP Monitor-->>User: Opens monitor under account XYZ
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant User
    participant AgentEx UI
    participant useSafeSearchParams
    participant SGP Monitor

    User->>AgentEx UI: Visits page with ?account_id=XYZ&task_id=ABC
    AgentEx UI->>useSafeSearchParams: read search params
    useSafeSearchParams-->>AgentEx UI: sgpAccountID = "XYZ"
    AgentEx UI->>AgentEx UI: Build URL: /monitor?trace_id=...&tt-trace-id=...&account_id=XYZ
    User->>SGP Monitor: Clicks "Investigate traces" link
    SGP Monitor-->>User: Opens monitor under account XYZ
Loading

Fix All in Cursor Fix All in Claude Code Fix All in Codex

Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
agentex-ui/components/task-header/investigate-traces-button.tsx:31
**Silent path change from `/beta/monitor` to `/monitor`**

The old URL used `${sgpAppURL}/beta/monitor?...` but the new URL drops the `/beta/` segment. This change is not mentioned in the PR description and may be intentional (the route graduated from beta) or accidental. If SGP still serves the monitor at `/beta/monitor`, this link will silently 404 or redirect to an unrelated page for all users.

Reviews (2): Last reviewed commit: "fix(agentex-ui): use /monitor instead of..." | Re-trigger Greptile

Greptile also left 1 inline comment on this PR.

Co-authored-by: Cursor <cursoragent@cursor.com>
@cdvillegas cdvillegas requested a review from a team as a code owner June 16, 2026 00:28
if (sgpAccountID) {
params.set('account_id', sgpAccountID);
}
const sgpTracesURL = `${sgpAppURL}/beta/monitor?${params.toString()}`;

@lucyakoroleva lucyakoroleva Jun 16, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I dont think we need beta (it just redirects to /monitor)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good call, removed

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread agentex-ui/components/task-header/investigate-traces-button.tsx
@cdvillegas cdvillegas merged commit 4b03f3a into main Jun 16, 2026
15 checks passed
@cdvillegas cdvillegas deleted the chris-villegas/fix-investigate-traces-account-id branch June 16, 2026 00:36
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.

3 participants