fix(core): allow OpenAI SDK in Tauri webview#67
Merged
Conversation
…: true) The OpenAI SDK refuses to construct in a "browser-like" environment by default, to prevent users from accidentally shipping API keys in pages served to untrusted browsers. In the DeepCode Tauri desktop app the renderer trips this guard even though the key is loaded from local Tauri-keychain storage (never exposed to a real browser). The CLI and VS Code extension run in Node, where the guard never trips anyway, so turning the flag on unconditionally is a no-op there and only matters inside the Tauri webview. Fixes the "× Failed to start: It looks like you're running in a browser-like environment" error in the desktop REPL. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The OpenAI SDK's
dangerouslyAllowBrowserguard fires in the Tauri webview, blocking the desktop REPL with× Failed to start: It looks like you're running in a browser-like environment.Set the flag to
truewhen constructing the DeepSeek client. The guard exists to prevent shipping API keys in webpages served to untrusted browsers — DeepCode never matches that case (CLI / VS Code extension / Tauri desktop all run on the user's own machine with the key in storage they control). In Node the flag is a no-op (the underlyingtypeof windowcheck never trips), so this only affects the Tauri webview.Test plan
pnpm --filter @deepcode/core buildsucceedspnpm --filter @deepcode/core test— all 478 tests pass🤖 Generated with Claude Code