fix(opencode): CSP, cache headers, Anthropic prefill, idle timeout, and WebSocket URL credentials#18091
Open
Dredok wants to merge 4 commits intoanomalyco:devfrom
Open
fix(opencode): CSP, cache headers, Anthropic prefill, idle timeout, and WebSocket URL credentials#18091Dredok wants to merge 4 commits intoanomalyco:devfrom
Dredok wants to merge 4 commits intoanomalyco:devfrom
Conversation
…sets perf(watcher): debounce file watcher invalidations test(watcher): update tests for debounce
Contributor
|
The following comment was made by an LLM, it may be inaccurate: I found one potentially related PR: PR #14772: "fix: disable assistant prefill for Claude 4.6 models" This PR appears to address a similar issue with Anthropic prefill support for Claude 4.6 models. However, since PR #18091 is the current PR and it's specifically fixing the prefill guard with trailing assistant message stripping (a more comprehensive solution), PR #14772 may be an older or related approach to the same problem. Check if #14772 is still open or if it overlaps with the prefill fix in the current PR. |
b523d43 to
8154923
Compare
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.
Issue for this PR
Closes #18084
Type of change
What does this PR do?
Fixes five bugs:
CSP blocks changelog fetch —
connect-srcin the server's CSP header was missinghttps://opencode.ai, so the web UI couldn't load the changelog. Added the origin.Proxied assets re-downloaded every page load — responses proxied from
app.opencode.aihad noCache-Control. Now hashed assets under/assets/getimmutable, max-age=1yand everything else gets a 5-minute default.Anthropic prefill error — conversations ending with an assistant message cause
"This model does not support assistant message prefill"on claude-sonnet-4-6 / claude-opus-4-6. Added a guard innormalizeMessagesthat strips trailing assistant messages before sending to Anthropic/Bedrock/Vertex.Connection accumulation —
Bun.servewas configured withidleTimeout: 0(never close idle connections). Over time HTTP keep-alive connections accumulate until the browser hits its per-host limit (~256) and new requests fail withERR_INSUFFICIENT_RESOURCES. Changed toidleTimeout: 120(2 minutes). SSE streams are unaffected because they have a 10-second heartbeat.WebSocket URL has spurious credentials — the terminal WebSocket URL unconditionally set
url.username = "opencode"even when no password was configured, producing URLs likewss://opencode@host/pty/.... The@in the URL confused browsers and reverse proxies, causingERR_NETWORK_CHANGEDerrors and reconnection loops. Now credentials are only set when a password is actually configured.Also includes a performance improvement: file watcher invalidations are now debounced (150 ms) so rapid agent writes don't fire N parallel HTTP requests.
How did you verify your code works?
bun run --cwd packages/opencode build -- --single --skip-install— passes.Cache-Controlheaders on proxied assets.ss -tnp | grep :4096 | wc -l— went from 201 stale connections down to ~5 after restart with the new idle timeout.opencode@when no password is configured — no moreERR_NETWORK_CHANGEDin Chrome console.Screenshots / recordings
No UI changes.
Checklist