feat(cmd-k): Add DSN lookup to both command palettes#108401
feat(cmd-k): Add DSN lookup to both command palettes#108401
Conversation
f75b54d to
656095f
Compare
|
i am curious, how do we expect users to discover that they can do this? |
|
this stemmed from a personal need, i first want to validate that its actually useful for others within the org and personal orgs and then think about how discovery will work, i haven't really looked into how command+k is being used / discovered as it is yet |
Add DSN lookup functionality to both the new supercharged command palette and the legacy search modal. Users can paste a DSN and get quick navigation to the corresponding project. Depends on backend PR #108400.
…ared code
- Use correct org-scoped API URL `/organizations/{slug}/dsn-lookup/`
- Reset `isLoading` to false in early-return branch to prevent stuck loading state
- Extract shared `DSN_PATTERN` and `DsnLookupResponse` to `dsnLookupUtils.ts`
Use allowNull to avoid throwing when organization context is missing,
since the command palette uses useOrganization({allowNull: true}).
- Use allowNull in DsnLookupSource to match apiSource.tsx pattern - Allow optional path segments in DSN_PATTERN for self-hosted instances
Use nullish coalescing fallback for organization slug in useApiQuery URL template to satisfy the branded ApiUrl type.
Register the DSN lookup URL in knownGetsentryApiUrls and use getApiUrl() so the query key satisfies the ApiUrl branded type required by useApiQuery.
Extract the three DSN lookup navigation targets (issues, settings, client keys) into getDsnNavTargets() in dsnLookupUtils so both command palettes use a single source of truth.
- Use useApiQuery instead of manual fetch in DsnLookupSource - Switch useDsnLookupActions to registration pattern (useCommandPaletteActions) - Remove duplicate DSN lookup URL from knownGetsentryApiUrls
23c1010 to
b75aad7
Compare
- Remove unused `key` field from DsnNavTarget interface and objects - Remove debounce on DSN query since users paste full DSNs and the regex gate already prevents unnecessary API calls
There was a problem hiding this comment.
nice! this does seem better now
There was a problem hiding this comment.
just reviewing the cursor comments now, thanks again for the reviews!
Use isLoading instead of isPending to avoid blocking SearchSources when the query is disabled. Bypass fuzzy filtering for search-result actions since they are already query-specific.
|
if it's working, the code is looking good to me |
Cached API data persisted stale DSN actions after the query changed, causing them to appear on unrelated searches via the search-result bypass.
static/app/components/commandPalette/ui/useCommandPaletteState.tsx
Outdated
Show resolved
Hide resolved
tested locally with |
Start from Fuse.js results to preserve match-quality ordering, then append search-result actions not already matched. The previous filter over displayedActions returned results in registration order, losing relevance ranking.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| staleTime: 30_000, | ||
| enabled: isDsn && !!organization && hasDsnLookup, | ||
| } | ||
| ); |
There was a problem hiding this comment.
404 retries can spam DSN endpoint
Medium Severity
useApiQuery is invoked without disabling retries, so when the DSN lookup endpoint is missing (expected 404 per PR description) or returns 404 for an invalid/not-found DSN, React Query may retry and generate multiple extra requests for a single query.
Additional Locations (1)
|
|
||
| export const DSN_PATTERN = | ||
| /^https?:\/\/([a-f0-9]{32})(:[a-f0-9]{32})?@[^/]+\/(?:[^/]+\/)*\d+$/; | ||
|
|
<img width="639" height="242" alt="CleanShot 2026-02-17 at 17 23 35" src="https://github.com/user-attachments/assets/7d7dcc8e-6f6a-4ff1-a442-d65c01aba631" /> ## Summary - Adds DSN lookup to the new supercharged command palette (`useDsnLookupActions` hook) - Adds DSN lookup to the legacy search modal (`dsnLookupSource`) - Users can paste a DSN and quickly navigate to the corresponding project ## Dependencies - **Requires #108400** (backend API endpoint) to be merged first - Frontend gracefully handles missing endpoint — API 404 results in no results shown ## Context Split from #108396 — this is the frontend half. ## Test plan - [x] Frontend tests pass (`CI=true pnpm test useDsnLookupActions`) - [ ] CI passes - [ ] Manual QA after backend PR lands
<img width="639" height="242" alt="CleanShot 2026-02-17 at 17 23 35" src="https://github.com/user-attachments/assets/7d7dcc8e-6f6a-4ff1-a442-d65c01aba631" /> ## Summary - Adds DSN lookup to the new supercharged command palette (`useDsnLookupActions` hook) - Adds DSN lookup to the legacy search modal (`dsnLookupSource`) - Users can paste a DSN and quickly navigate to the corresponding project ## Dependencies - **Requires #108400** (backend API endpoint) to be merged first - Frontend gracefully handles missing endpoint — API 404 results in no results shown ## Context Split from #108396 — this is the frontend half. ## Test plan - [x] Frontend tests pass (`CI=true pnpm test useDsnLookupActions`) - [ ] CI passes - [ ] Manual QA after backend PR lands


Summary
useDsnLookupActionshook)dsnLookupSource)Dependencies
Context
Split from #108396 — this is the frontend half.
Test plan
CI=true pnpm test useDsnLookupActions)