🦌 Add speculative PR metadata generation to hide Claude latency#258
Open
🦌 Add speculative PR metadata generation to hide Claude latency#258
Conversation
zdavison
commented
Mar 25, 2026
packages/deerbox/src/config.ts
Outdated
| /** | ||
| * Start generating PR metadata speculatively while the user reads the | ||
| * post-session menu. Hides most of the Claude inference latency on the | ||
| * happy path (user picks "p"). Incurs an extra Claude API call if the |
Owner
Author
There was a problem hiding this comment.
why does this incur an extra claude api call for other options?
list each option and what happens
also, speculativeClose should also work for m because commit message is generated with claude, and its used for both m and p
zdavison
commented
Mar 25, 2026
packages/shared/src/git/finalize.ts
Outdated
| /** | ||
| * Pre-computed PR metadata from a speculative generation started before the | ||
| * user was prompted. If provided, skips `findPRTemplate` + `generatePRMetadata`. | ||
| * Note: generated before stageAndCommit, so may miss last-minute uncommitted changes. |
Owner
Author
There was a problem hiding this comment.
Is this going to cause problems? the flow before was stageAndCommit -> generate right? now it'S generating before stageAndCommit?
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
Adds an experimental
speculative_closefeature that starts generating PR metadata (branch name, title, body) in the background while the user is reading the post-session menu. On the happy path where the user picks "p" (create PR), the metadata is already ready or nearly ready, hiding most of the Claude inference latency.If the user picks any other option, the speculative work is discarded at the cost of one extra Claude API call.
Changes
packages/deerbox/src/config.ts— addsexperimental.speculativeCloseconfig option with TOML and repo-local parsing supportpackages/deerbox/src/cli.ts— passesspeculativeClosefrom config into the post-session contextpackages/deerbox/src/post-session.ts— kicks off speculative fetch and metadata generation before prompting the user; passes result tocreatePR; also fixesdestroy()to use.catch(() => {})instead of awaitingpackages/shared/src/git/finalize.ts— exportsgeneratePRMetadataandPRMetadata; adds optionalfetchDoneparam to reuse a prefetch; parallelises the three git reads after fetch usingPromise.all;createPullRequestaccepts and usesspeculativeMetadatapackages/deerbox/src/git/finalize.ts— re-exportsgeneratePRMetadataandPRMetadatafrom sharedpackages/shared/src/index.ts— exportsgeneratePRMetadataandPRMetadatafrom the shared package