Repository navigation
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #6450 +/- ##
==========================================
- Coverage 85.22% 82.71% -2.52%
==========================================
Files 372 414 +42
Lines 40786 44193 +3407
Branches 11686 12918 +1232
==========================================
+ Hits 34760 36554 +1794
- Misses 5586 7195 +1609
- Partials 440 444 +4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Move the Node-only parts of ProfileQuerier (loading a profile from a file or URL, saving it to disk, reading source map files and the in-thread source map runner) into a ProfileQuerierNode subclass in profile-query/node.ts. Also narrow the store the querier needs to a QuerierStore type with just getState and dispatch, so a thunk can query the live app store.
Move the command and result types, the text formatters, the permalink view mapping, and the command dispatch that used to live in Daemon.processCommand into src/profile-query/cli/, so the web app can run pq commands against its own store. The daemon now calls executeClientCommand and passes itself the file system commands (profile save, sourcemap apply) that only it can run.
Move the commander definitions of the query commands into src/profile-query/cli/commands/. Instead of talking to the daemon directly, they now get a CommandContext from the entry point that says how to run a command, print extra output, report a failure, and access local files. Commands that need local files are left out when there is no file system.
runProfilerCliCommand parses a pq command line with the shared commander definitions and runs it with a ProfileQuerier on the app's live store, so commands like thread select and zoom push change the UI. Output is captured as text, usage and query errors are reported instead of thrown, and long output is truncated. commander imports a few Node built-ins at module level, so the web build now redirects those imports to small browser shims.
The chat sends the conversation to the Anthropic Messages API straight from the browser with a key the user provides, and gives the model one tool, run_profiler_cli, that runs pq commands on the live store through the browser executor. The system prompt is the pq guide and schemas, cached, and each user message ends with a description of the current view. runChatTurn is the agentic loop, kept free of Redux. It keeps the history append-only and answers every tool call, also when a turn is cancelled, cut off or hits the tool call limit. The thunks in actions/chat.ts load the SDK and the executor on demand, throttle the streamed text, and drop the results of a turn whose conversation was reset in the meantime.
A full-height drawer on the right of the profile viewer, opened from a new
menu button. It asks for an Anthropic API key first, with a note on what is
sent to Anthropic, then shows the conversation: the user's messages, the
answers rendered as markdown, and every profiler-cli command the model ran
as a collapsed chip that expands to its output. The drawer is loaded lazily
so the markdown renderer stays out of the main bundle.
The feature is hidden unless enabled from the console with
localStorage.setItem('profiler.chat.enabled', 'true').
Turn notices and errors are now stored as typed values instead of English
strings, so the drawer can localize them.
A rejected key is no longer forgotten: the drawer shows the API's error
message instead, because a 401 can also mean the organization doesn't allow
browser requests, in which case the key is valid.
Move the Anthropic streaming code behind a ChatProvider interface, so the agentic loop can run against other wire formats. The conversation is now stored in the provider's own message format, tagged with that format, and the transcript is derived from it in an SDK-free module.
Add a provider for the OpenAI Chat Completions API, which OpenAI, local servers such as Ollama or LM Studio, and gateways all implement. The API key form becomes a provider settings form with the presets Anthropic, OpenAI, Local and Custom. OpenAI-compatible presets need a model, which the form suggests from the server's model list. Settings are stored per preset in localStorage, and switching provider starts a new chat, as conversations are kept in each provider's own message format.
Add an OpenRouter preset whose API key comes from OpenRouter's OAuth PKCE flow, so that people can use the chat with an account rather than an API key from a provider console, without a server on our side. The auth page opens in a popup, so that the profile isn't unloaded, and redirects to a static callback page that hands the code back over a BroadcastChannel. The code is then exchanged for a key, which is stored right away. Pasting a key still works, and the model list only shows models that support tool calling.
Describe the presets and their settings, the "Connect OpenRouter" flow, how to let a local model server accept requests from the profiler, and where each provider sends the data.
OpenAI's Chat Completions endpoint rejects function tools together with reasoning on some models, e.g. gpt-6-luna, which fails every request since the chat relies on its profiler-cli tool. Add a provider for the Responses API, which supports both, and use it for the OpenAI preset. The other OpenAI-compatible presets stay on Chat Completions, which is what those servers implement. Requests use store: false, and the encrypted reasoning items are sent back unchanged so that the model keeps its reasoning across tool calls. Strict tool schemas were only used for OpenAI, so Chat Completions requests no longer have that option.
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.
Main | Deploy preview
This PR adds an experimental chat drawer that answers questions about the open profile. The model inspects the profile by running profiler-cli (pq) commands against the live Redux store, so commands like
thread selectorzoom pushalso update the view.ProfileQuerierand the pq command definitions browser-safe, so the CLI and the chat share them.window.experimental.enableProfileChat().