fix(socratiq): enable AI companion and free Ctrl+/ from search - #1978
Open
farhan523 wants to merge 1 commit into
Open
fix(socratiq): enable AI companion and free Ctrl+/ from search#1978farhan523 wants to merge 1 commit into
farhan523 wants to merge 1 commit into
Conversation
The SocratiQ AI learning companion was fully disabled and, even when enabled, its documented Ctrl+/ shortcut opened Quarto's search box instead of the chat. This restores a working end-to-end experience. Changes: - Re-enable the SocratiQ bundle in the vol1/vol2 HTML configs and add tools/scripts/socratiQ/*.js as a project resource so it is served. - Add socratiq-search-shortcut-fix.js: Quarto's search binds the "/" key on keyup and ignores modifiers, so Ctrl/Cmd+/ also matched and opened search. SocratiQ's handler runs on keydown; preventDefault there cannot stop Quarto's separate keyup listener. The shim stopImmediatePropagation()s "/" keyup only when Ctrl/Cmd is held, freeing Ctrl+/ for SocratiQ while leaving plain "/" search intact. - Fix the chat panel flashing open-then-closed on page load: the slide-out menu shipped with `transition-transform` in its initial markup, so the pre-style first paint animated as styles applied. Remove it from the initial template (src_shadow + built bundle); the open/close handlers re-add it, so animations still work. Note: the bundle was disabled "pending quiz regeneration"; this PR re-enables it. Maintainers should confirm the quiz pipeline is ready before merging the enable portion.
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
On the SocratiQ page the docs tell readers to press
Ctrl + /to open the AI chat. In practice:Ctrl + /opens Quarto's search box, not the chat.Root causes (traced in code)
<script … bundle.js>tag is commented out inconfig/_quarto-html-vol1.yml/-vol2.yml("disabled pending quiz regeneration").quarto-search.js) binds the/key onkeyupand checks onlyevent.key === "/", ignoring modifiers — soCtrl + /matches and opens search. SocratiQ's own handler runs onkeydownand callspreventDefault(), which cannot stop Quarto's separatekeyuplistener.transition-transformin its initial markup. On first paint (before the shadow-root styles apply), the panel renders on-screen, then animates off as styles load — a visible flash.Changes
tools/scripts/socratiQ/*.jsas a project resource so the bundle is served.socratiq-search-shortcut-fix.js(new): a capture-phasekeyuplistener thatstopImmediatePropagation()s/only when Ctrl/Cmd is held, freeingCtrl + /for SocratiQ while leaving plain/search untouched.transition-transformfrom the panel's initial template insocratiq/src_shadow/index.html+indexHtml.js(and the builtbundle.jsto match). The open/close handlers re-add the class, so animations still work — only the first-paint flash is gone.Before → After (for readers)
Ctrl + //This PR re-enables a bundle that was intentionally turned off "pending quiz regeneration." If the quiz pipeline isn't ready, you may want to merge only the shortcut + flash fixes and keep the enable out — happy to split the PR that way. The shortcut and flash fixes are correct and low-risk regardless of when the bundle is enabled.
The
bundle.jschange is a build artifact; the same fix is applied to its source insocratiq/src_shadow/, so a rebuild reproduces it.Testing
Verified locally with
quarto preview:Ctrl + /opens the chat panel (no search box), plain/still opens search, no load flash, and chat streams responses end-to-end via the Cloudflare workers (tested through a local CORS proxy since the workers allowlistmlsysbook.ai).