Repository navigation
fix(brain-strip): reactive colorScheme so the graph doesn't paint blank white in the VS Code webview - #38
Merged
Conversation
…nk white in the VS Code webview
The session brain-strip renders its graph in a nested /brain.html iframe. Its
src baked colorScheme=${scheme} from a ONE-TIME snapshot read at mount. Inside
the amicode VS Code webview the theme arrives asynchronously (chat_panel seeds
it via ?colorScheme= -> app preload -> data-color-scheme on documentElement),
so at brain-strip mount that attribute is often not set yet. The snapshot then
falls to its default, parent and child color-schemes mismatch, and — per the
code's own comment — the browser paints the transparent iframe OPAQUE WHITE.
That is the blank box users saw where the graph should be.
Fix:
- Track the scheme reactively (createSignal + the existing MutationObserver
now setScheme) so the iframe src re-syncs to the real theme instead of a
stale mount-time snapshot.
- On every `ready` handshake from the brain (the initial one AND the one after
a scheme-driven iframe reload), clear the sent-set and restore initialFlush
so the reloaded brain re-receives the full event history — otherwise a reload
would come back empty (every id already marked sent).
typecheck (tsgo -b): clean. Rebuilt the darwin-arm64 binary (smoke test
passed) and verified in the amicode dev host.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
4 of 5 tasks
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.
Problem
The session brain-strip (the animated graph of a session's tool touches) renders in a nested
/brain.htmliframe. Users saw it as a blank white box where the graph should be — reported in the amicode dev host.Root cause:
brain-strip.tsxbakedcolorScheme=${scheme}into the iframesrcfrom a one-time snapshot read at mount. Inside the amicode VS Code webview the theme arrives asynchronously (chat_panel seeds it via?colorScheme=→ app preload →data-color-schemeondocumentElement), so at brain-strip mount that attribute is often not set yet. The snapshot falls to its default, parent/child color-schemes mismatch, and — per the component's own comment — the browser paints the transparent iframe opaque white.Fix
createSignal+ the existingMutationObservernow callssetScheme) so the iframesrcre-syncs to the real theme instead of a stale mount-time value.readyhandshake from the brain (initial, and after a scheme-driven iframe reload), clearsentand restoreinitialFlushso the reloaded brain re-receives the full event history — otherwise a reload comes back empty.Testing
tsgo -b: cleanFollow-up
Ships to users via a fork release +
opencode.lock.jsonbump in amicode (same path as #37).