feat(devtools): let the source inspector's open-source URL be configured - #517
feat(devtools): let the source inspector's open-source URL be configured#517thedv91 wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
Included review availability: Your plan provides up to 2 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughAdds an optional ChangesSource inspector URL configuration
Estimated code review effort: 2 (Simple) | ~15 minutes Merge Risk: ⚪ Minimal · up to 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
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
"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.
d439dea to
f211e18
Compare
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-viteserves. Anything else that injectsdata-tsd-source— an SWC plugin under Next.js, in my case — lights the overlay up correctly but has no endpoint to answer the click, andfetch(...).catch(() => {})hides the 404, so an inspect click is indistinguishable from a click that did nothing.New config key, alongside
sourceAction: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 packedpath: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
configon the next load, so a string would keep serving whatever the app was configured with the first time it ran, ignoring later changes.JSON.stringifydrops functions, so this key stays out of storage the waycustomTriggeralready does. Confirmed in the browser: changed a setting in the panel to force a settings write, andopenSourceUrlis absent from the 14 keys intanstack_devtools_settingswhile the click still routes correctly after a reload.Unset, the Vite endpoint is used exactly as before,
BASE_URLincluded. Ignored undersourceAction: "copy-path", which makes no request.Verification —
pnpm test:prequivalent green (84/84 affected tasks). Four unit tests insource-inspector.test.tsxcover the default URL, a path, an absolute URL, and the copy-path case. Exercised end to end inexamples/react/basicwith the Next-shaped builder above: the inspect click issuedGET /__nextjs_launch-editor?file=%2Fsrc%2Findex.tsx&line1=191&column1=15instead of__tsd/open-source.Independent of #516 — different part of the file. Whichever lands second, I'll rebase.
✅ Checklist
pnpm test:pr.🚀 Release Impact
Summary by CodeRabbit
New Features
openSourceUrlsetting to customize where source-inspector links open files.Documentation
copy-pathbehavior.