Skip to content

feat(devtools): let the source inspector's open-source URL be configured - #517

Open
thedv91 wants to merge 1 commit into
TanStack:mainfrom
thedv91:feat-configurable-open-source-url
Open

feat(devtools): let the source inspector's open-source URL be configured#517
thedv91 wants to merge 1 commit into
TanStack:mainfrom
thedv91:feat-configurable-open-source-url

Conversation

@thedv91

@thedv91 thedv91 commented Aug 22, 2026

Copy link
Copy Markdown

Implements #514. That discussion hasn't been answered yet, so treat this as the concrete version of the proposal rather than something agreed — happy to reshape it or close it if you'd rather the key looked different.

🎯 Changes

sourceAction: "ide-warp" requests __tsd/open-source?source=…, which only @tanstack/devtools-vite serves. Anything else that injects data-tsd-source — an SWC plugin under Next.js, in my case — lights the overlay up correctly but has no endpoint to answer the click, and fetch(...).catch(() => {}) hides the 404, so an inspect click is indistinguishable from a click that did nothing.

New config key, alongside sourceAction:

<TanStackDevtools
  config={{
    openSourceUrl: (source) => `/api/open-editor?at=${encodeURIComponent(source)}`,
  }}
/>

Two decisions worth flagging, both arguable:

The whole URL, not just its base. Another host generally wants another parameter shape — Next's own editor endpoint takes the position split into file, line1, column1, not the packed path:line:column. A configurable base would still leave that host with no route.

A function, not a string. Settings are persisted to local storage and take priority over config on the next load, so a string would keep serving whatever the app was configured with the first time it ran, ignoring later changes. JSON.stringify drops functions, so this key stays out of storage the way customTrigger already does. Confirmed in the browser: changed a setting in the panel to force a settings write, and openSourceUrl is absent from the 14 keys in tanstack_devtools_settings while the click still routes correctly after a reload.

Unset, the Vite endpoint is used exactly as before, BASE_URL included. Ignored under sourceAction: "copy-path", which makes no request.

Verificationpnpm test:pr equivalent green (84/84 affected tasks). Four unit tests in source-inspector.test.tsx cover the default URL, a path, an absolute URL, and the copy-path case. Exercised end to end in examples/react/basic with the Next-shaped builder above: the inspect click issued GET /__nextjs_launch-editor?file=%2Fsrc%2Findex.tsx&line1=191&column1=15 instead of __tsd/open-source.

Independent of #516 — different part of the file. Whichever lands second, I'll rebase.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm test:pr.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.

Summary by CodeRabbit

  • New Features

    • Added an optional openSourceUrl setting to customize where source-inspector links open files.
    • Supports relative paths, absolute URLs, and custom editor or framework endpoints.
    • Retains the default Vite source-opening behavior when no custom URL is configured.
  • Documentation

    • Added configuration guidance and examples for non-Vite setups, including Next.js.
    • Clarified source opening and copy-path behavior.

@coderabbitai

coderabbitai Bot commented Aug 22, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e3a8be5f-cca2-4cae-8244-9afcd93b55b1

📥 Commits

Reviewing files that changed from the base of the PR and between 566d39b and d439dea.

📒 Files selected for processing (5)
  • .changeset/configurable-open-source-url.md
  • docs/source-inspector.md
  • packages/devtools/src/components/source-inspector.test.tsx
  • packages/devtools/src/components/source-inspector.tsx
  • packages/devtools/src/context/devtools-store.ts

Included review availability: Your plan provides up to 2 included reviews per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Adds an optional openSourceUrl callback to configure source-opening requests. The source inspector preserves the default Vite endpoint, supports custom relative or absolute URLs, and includes tests and documentation for non-Vite integrations.

Changes

Source inspector URL configuration

Layer / File(s) Summary
Source URL contract and request flow
packages/devtools/src/context/devtools-store.ts, packages/devtools/src/components/source-inspector.tsx, packages/devtools/src/components/source-inspector.test.tsx
The store exposes settings.openSourceUrl. The source inspector uses the callback when configured and otherwise builds the default __tsd/open-source URL. Tests cover default, custom, absolute, and copy-path behavior.
Configuration documentation and release note
docs/source-inspector.md, .changeset/configurable-open-source-url.md
The documentation describes non-Vite configuration, URL examples, default Vite behavior, and copy-path handling. The changeset records the patch release.

Estimated code review effort: 2 (Simple) | ~15 minutes

Merge Risk: ⚪ Minimal · up to d439d

The change adds an optional configurable source-inspector URL while preserving existing behavior when unset; no actionable merge-blocking risk remains after normal checks.

Sequence Diagram(s)

sequenceDiagram
  participant SourceInspector
  participant DevtoolsStore
  participant SourceEndpoint
  SourceInspector->>DevtoolsStore: Read settings().openSourceUrl
  DevtoolsStore-->>SourceInspector: Return configured URL or default URL
  SourceInspector->>SourceEndpoint: Fetch source-opening URL
Loading

Suggested reviewers: alemtuzlak

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: configurable source-inspector open-source URLs.
Description check ✅ Passed The description explains the change, motivation, design decisions, testing, checklist completion, and generated changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 3 files. (2 skipped: 2 unsupported.)
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

"ide-warp" requests __tsd/open-source, which only @tanstack/devtools-vite
serves. Anything else that injects data-tsd-source -- an SWC plugin under
Next.js, for instance -- drives the overlay fine but has no endpoint to answer
the click, and fetch(...).catch(() => {}) hides the 404, so the click looks
like it did nothing.

openSourceUrl takes the clicked element's data-tsd-source value and returns
the URL to request. The whole URL rather than just its base, because another
host generally wants another parameter shape: Next's own editor endpoint takes
the position split into file, line1 and column1.

A function rather than a string: settings are persisted to local storage and
take priority over config on the next load, so a string would keep serving
whatever the app was configured with the first time it ran. JSON.stringify
drops functions, which keeps the key out of storage the way customTrigger
already is.
@thedv91
thedv91 force-pushed the feat-configurable-open-source-url branch from d439dea to f211e18 Compare August 22, 2026 03:43
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.

1 participant